1const xu=()=>{};var aa={};const $l={NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"};const b=function(n,e){if(!n)throw rn(e)},rn=function(n){return new Error("Firebase Database ("+$l.SDK_VERSION+") INTERNAL ASSERT FAILED: "+n)};const Gl=function(n){const e=[];let t=0;for(let i=0;i<n.length;i++){let s=n.charCodeAt(i);s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&i+1<n.length&&(n.charCodeAt(i+1)&64512)===56320?(s=65536+((s&1023)<<10)+(n.charCodeAt(++i)&1023),e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128)}return e},Uu=function(n){const e=[];let t=0,i=0;for(;t<n.length;){const s=n[t++];if(s<128)e[i++]=String.fromCharCode(s);else if(s>191&&s<224){const o=n[t++];e[i++]=String.fromCharCode((s&31)<<6|o&63)}else if(s>239&&s<365){const o=n[t++],a=n[t++],h=n[t++],u=((s&7)<<18|(o&63)<<12|(a&63)<<6|h&63)-65536;e[i++]=String.fromCharCode(55296+(u>>10)),e[i++]=String.fromCharCode(56320+(u&1023))}else{const o=n[t++],a=n[t++];e[i++]=String.fromCharCode((s&15)<<12|(o&63)<<6|a&63)}}return e.join("")},Ji={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:typeof atob=="function",encodeByteArray(n,e){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();const t=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,i=[];for(let s=0;s<n.length;s+=3){const o=n[s],a=s+1<n.length,h=a?n[s+1]:0,u=s+2<n.length,f=u?n[s+2]:0,E=o>>2,y=(o&3)<<4|h>>4;let S=(h&15)<<2|f>>6,k=f&63;u||(k=64,a||(S=64)),i.push(t[E],t[y],t[S],t[k])}return i.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray(Gl(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):Uu(this.decodeStringToByteArray(n,e))},decodeStringToByteArray(n,e){this.init_();const t=e?this.charToByteMapWebSafe_:this.charToByteMap_,i=[];for(let s=0;s<n.length;){const o=t[n.charAt(s++)],h=s<n.length?t[n.charAt(s)]:0;++s;const f=s<n.length?t[n.charAt(s)]:64;++s;const y=s<n.length?t[n.charAt(s)]:64;if(++s,o==null||h==null||f==null||y==null)throw new Fu;const S=o<<2|h>>4;if(i.push(S),f!==64){const k=h<<4&240|f>>2;if(i.push(k),y!==64){const R=f<<6&192|y;i.push(R)}}}return i},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let n=0;n<this.ENCODED_VALS.length;n++)this.byteToCharMap_[n]=this.ENCODED_VALS.charAt(n),this.charToByteMap_[this.byteToCharMap_[n]]=n,this.byteToCharMapWebSafe_[n]=this.ENCODED_VALS_WEBSAFE.charAt(n),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[n]]=n,n>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(n)]=n,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(n)]=n)}}};class Fu extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const zl=function(n){const e=Gl(n);return Ji.encodeByteArray(e,!0)},ql=function(n){return zl(n).replace(/\./g,"")},Ri=function(n){try{return Ji.decodeString(n,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function Vu(n){return Kl(void 0,n)}function Kl(n,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:const t=e;return new Date(t.getTime());case Object:n===void 0&&(n={});break;case Array:n=[];break;default:return e}for(const t in e)!e.hasOwnProperty(t)||!Bu(t)||(n[t]=Kl(n[t],e[t]));return n}function Bu(n){return n!=="__proto__"}function Wu(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}const Hu=()=>Wu().__FIREBASE_DEFAULTS__,ju=()=>{if(typeof process>"u"||typeof aa>"u")return;const n=aa.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},$u=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;
1]+)/)}catch{return}const e=n&&Ri(n[1]);return e&&JSON.parse(e)},Tr=()=>{try{return xu()||Hu()||ju()||$u()}catch(n){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},Gu=n=>Tr()?.emulatorHosts?.[n],Yl=()=>Tr()?.config,Xl=n=>Tr()?.[`_${n}`];class Hn{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,i)=>{t?this.reject(t):this.resolve(i),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,i))}}}function Qi(n){try{return(n.startsWith("http://")||n.startsWith("https://")?new URL(n).hostname:n).endsWith(".cloudworkstations.dev")}catch{return!1}}async function zu(n){return(await fetch(n,{credentials:"include"})).ok}const Dn={};function qu(){const n={prod:[],emulator:[]};for(const e of Object.keys(Dn))Dn[e]?n.emulator.push(e):n.prod.push(e);return n}function Ku(n){let e=document.getElementById(n),t=!1;return e||(e=document.createElement("div"),e.setAttribute("id",n),t=!0),{created:t,element:e}}let la=!1;function Yu(n,e){if(typeof window>"u"||typeof document>"u"||!Qi(window.location.host)||Dn[n]===e||Dn[n]||la)return;Dn[n]=e;function t(S){return`__firebase__banner__${S}`}const i="__firebase__banner",o=qu().prod.length>0;function a(){const S=document.getElementById(i);S&&S.remove()}function h(S){S.style.display="flex",S.style.background="#7faaf0",S.style.position="fixed",S.style.bottom="5px",S.style.left="5px",S.style.padding=".5em",S.style.borderRadius="5px",S.style.alignItems="center"}function u(S,k){S.setAttribute("width","24"),S.setAttribute("id",k),S.setAttribute("height","24"),S.setAttribute("viewBox","0 0 24 24"),S.setAttribute("fill","none"),S.style.marginLeft="-6px"}function f(){const S=document.createElement("span");return S.style.cursor="pointer",S.style.marginLeft="16px",S.style.fontSize="24px",S.innerHTML=" ×",S.onclick=()=>{la=!0,a()},S}function E(S,k){S.setAttribute("id",k),S.innerText="Learn more",S.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",S.setAttribute("target","__blank"),S.style.paddingLeft="5px",S.style.textDecoration="underline"}function y(){const S=Ku(i),k=t("text"),R=document.getElementById(k)||document.createElement("span"),O=t("learnmore"),N=document.getElementById(O)||document.createElement("a"),Y=t("preprendIcon"),Q=document.getElementById(Y)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(S.created){const K=S.element;h(K),E(N,O);const X=f();u(Q,Y),K.append(Q,R,N,X),document.body.appendChild(K)}o?(R.innerText="Preview backend disconnected.",Q.innerHTML=`<g clip-path="url(#clip0_6013_33858)"> 2<path d="M4.8 17.6L12 5.6L19.2 17.6H4.8ZM6.91667 16.4H17.0833L12 7.93333L6.91667 16.4ZM12 15.6C12.1667 15.6 12.3056 15.5444 12.4167 15.4333C12.5389 15.3111 12.6 15.1667 12.6 15C12.6 14.8333 12.5389 14.6944 12.4167 14.5833C12.3056 14.4611 12.1667 14.4 12 14.4C11.8333 14.4 11.6889 14.4611 11.5667 14.5833C11.4556 14.6944 11.4 14.8333 11.4 15C11.4 15.1667 11.4556 15.3111 11.5667 15.4333C11.6889 15.5444 11.8333 15.6 12 15.6ZM11.4 13.6H12.6V10.4H11.4V13.6Z" fill="#212121"/> 3</g> 4<defs> 5<clipPath id="clip0_6013_33858"> 6<rect width="24" height="24" fill="white"/> 7</clipPath> 8</defs>`):(Q.innerHTML=`<g clip-path="url(#clip0_6083_34804)"> 9<path d="M11.4 15.2H12.6V11.2H11.4V15.2ZM12 10C12.1667 10 12.3056 9.94444 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"/> 10</g> 11<defs> 12<clipPath id="clip0_6083_34804"> 13<rect width="24" height="24" fill="white"/> 14</clipPath> 15</defs>`,R.innerText="Preview backend running in this workspace."),R.setAttribute("id",k)}
15document.readyState==="loading"?window.addEventListener("DOMContentLoaded",y):y()}function fe(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function Sr(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(fe())}function Xu(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function Ju(){const n=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof n=="object"&&n.id!==void 0}function Jl(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function Qu(){const n=fe();return n.indexOf("MSIE ")>=0||n.indexOf("Trident/")>=0}function Zu(){return $l.NODE_ADMIN===!0}function Ql(){try{return typeof indexedDB=="object"}catch{return!1}}function ed(){return new Promise((n,e)=>{try{let t=!0;const i="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(i);s.onsuccess=()=>{s.result.close(),t||self.indexedDB.deleteDatabase(i),n(!0)},s.onupgradeneeded=()=>{t=!1},s.onerror=()=>{e(s.error?.message||"")}}catch(t){e(t)}})}const td="FirebaseError";class $e extends Error{constructor(e,t,i){super(t),this.code=e,this.customData=i,this.name=td,Object.setPrototypeOf(this,$e.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,on.prototype.create)}}class on{constructor(e,t,i){this.service=e,this.serviceName=t,this.errors=i}create(e,...t){const i=t[0]||{},s=`${this.service}/${e}`,o=this.errors[e],a=o?nd(o,i):"Error",h=`${this.serviceName}: ${a} (${s}).`;return new $e(s,h,i)}}function nd(n,e){return n.replace(id,(t,i)=>{const s=e[i];return s!=null?String(s):`<${i}?>`})}const id=/\{\$([^}]+)}/g;function jn(n){return JSON.parse(n)}function re(n){return JSON.stringify(n)}const Zl=function(n){let e={},t={},i={},s="";try{const o=n.split(".");e=jn(Ri(o[0])||""),t=jn(Ri(o[1])||""),s=o[2],i=t.d||{},delete t.d}catch{}return{header:e,claims:t,data:i,signature:s}},sd=function(n){const e=Zl(n),t=e.claims;return!!t&&typeof t=="object"&&t.hasOwnProperty("iat")},rd=function(n){const e=Zl(n).claims;return typeof e=="object"&&e.admin===!0};function et(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function Zt(n,e){if(Object.prototype.hasOwnProperty.call(n,e))return n[e]}function Zs(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function ki(n,e,t){const i={};for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(i[s]=e.call(t,n[s],s,n));return i}function en(n,e){if(n===e)return!0;const t=Object.keys(n),i=Object.keys(e);for(const s of t){if(!i.includes(s))return!1;const o=n[s],a=e[s];if(ca(o)&&ca(a)){if(!en(o,a))return!1}else if(o!==a)return!1}for(const s of i)if(!t.includes(s))return!1;return!0}function ca(n){return n!==null&&typeof n=="object"}function an(n){const e=[];for(const[t,i]of Object.entries(n))Array.isArray(i)?i.forEach(s=>{e.push(encodeURIComponent(t)+"="+encodeURIComponent(s))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(i));return e.length?"&"+e.join("&"):""}class od{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=512/8,this.pad_[0]=128;for(let e=1;e<this.blockSize;++e)this.pad_[e]=0;this.reset()}reset(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0}compress_(e,t){t||(t=0);const i=this.W_;if(typeof e=="string")for(let y=0;y<16;y++)i[y]=e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3),t+=4;else for(let y=0;y<16;y++)i[y]=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3],t+=4;for(let y=16;y<80;y++){const S=i[y-3]^i[y-8]^i[y-14]^i[y-16];i[y]=(S<<1|S>>>31)&4294967295}let s=this.chain_[0],o=this.chain_[1],a=this.chain_[2],h=this.chain_[3],u=this.chain_[4],f,E;for(let y=0;y<80;y++){y<40?y<20?(f=h^o&(a^h),E=1518500249):(f=o^a^h,E=1859775393):y<60?(f=o&a|h&(o|a),E=2400959708):(f=o^a^h,E=3395469782);const S=(s<<5|s>>>27)+f+u+E+i[y]&4294967295;u=h,h=a,a=(o<<30|o>>>2)&4294967295,o=s,s=S}this.chain_[0]=this.chain_[0]+s&4294967295,this.chain_[1]=this.chain_[1]+o&4294967295,this.chain_[2]=this.chain_[2]+a&4294967295,this.chain_[3]=this.chain_[3]+h&4294967295,this.chain_[4]=this.chain_[4]+u&4294967295}update(e,t){if(e==null)return;t===void 0&&(t=e.length);const i=t-this.blockSize;let s=0;const o=this.buf_;let a=this.inbuf_;for(;s<t;){if(a===0)for(;s<=i;)this.compress_(e,s),s+=this.blockSize;if(typeof e=="string"){for(;s<t;)if(o[a]=e.charCodeAt(s),++a,++s,a===this.blockSize){this.compress_(o),a=0;break}}else for(;s<t;)if(o[a]=e[s],++a,++s,a===this.blockSize){this.compress_(o),a=0;break}}this.inbuf_=a,this.total_+=t}digest(){const e=[];let t=this.total_*8;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let s=this.blockSize-1;s>=56;s--)this.buf_[s]=t&255,t/=256;this.compress_(this.buf_);let i=0;for(let s=0;s<5;s++)for(let o=24;o>=0;o-=8)e[i]=this.chain_[s]>>o&255,++i;return e}}function ad(n,e){const t=new ld(n,e);return t.subscribe.bind(t)}class ld{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Prom
15ise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(i=>{this.error(i)})}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,i){let s;if(e===void 0&&t===void 0&&i===void 0)throw new Error("Missing Observer.");cd(e,["next","error","complete"])?s=e:s={next:e,error:t,complete:i},s.next===void 0&&(s.next=xs),s.error===void 0&&(s.error=xs),s.complete===void 0&&(s.complete=xs);const o=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?s.error(this.finalError):s.complete()}catch{}}),this.observers.push(s),o}unsubscribeOne(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&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(this.observers!==void 0&&this.observers[e]!==void 0)try{t(this.observers[e])}catch(i){typeof console<"u"&&console.error&&console.error(i)}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function cd(n,e){if(typeof n!="object"||n===null)return!1;for(const t of e)if(t in n&&typeof n[t]=="function")return!0;return!1}function xs(){}function hd(n,e){return`${n} failed: ${e} argument `}const ud=function(n){const e=[];let t=0;for(let i=0;i<n.length;i++){let s=n.charCodeAt(i);if(s>=55296&&s<=56319){const o=s-55296;i++,b(i<n.length,"Surrogate pair missing trail surrogate.");const a=n.charCodeAt(i)-56320;s=65536+(o<<10)+a}s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):s<65536?(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128)}return e},Zi=function(n){let e=0;for(let t=0;t<n.length;t++){const i=n.charCodeAt(t);i<128?e++:i<2048?e+=2:i>=55296&&i<=56319?(e+=4,t++):e+=3}return e};function Ge(n){return n&&n._delegate?n._delegate:n}class Oe{constructor(e,t,i){this.name=e,this.instanceFactory=t,this.type=i,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 St="[DEFAULT]";class dd{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 i=new Hn;
15if(this.instancesDeferred.set(t,i),this.isInitialized(t)||this.shouldAutoInitialize())try{const s=this.getOrInitializeService({instanceIdentifier:t});s&&i.resolve(s)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){const t=this.normalizeInstanceIdentifier(e?.identifier),i=e?.optional??!1;if(this.isInitialized(t)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:t})}catch(s){if(i)return null;throw s}else{if(i)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,!!this.shouldAutoInitialize()){if(pd(e))try{this.getOrInitializeService({instanceIdentifier:St})}catch{}for(const[t,i]of this.instancesDeferred.entries()){const s=this.normalizeInstanceIdentifier(t);try{const o=this.getOrInitializeService({instanceIdentifier:s});i.resolve(o)}catch{}}}}clearInstance(e=St){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(t=>"INTERNAL"in t).map(t=>t.INTERNAL.delete()),...e.filter(t=>"_delete"in t).map(t=>t._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=St){return this.instances.has(e)}getOptions(e=St){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,i=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(i))throw Error(`${this.name}(${i}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const s=this.getOrInitializeService({instanceIdentifier:i,options:t});for(const[o,a]of this.instancesDeferred.entries()){const h=this.normalizeInstanceIdentifier(o);i===h&&a.resolve(s)}return s}onInit(e,t){const i=this.normalizeInstanceIdentifier(t),s=this.onInitCallbacks.get(i)??new Set;s.add(e),this.onInitCallbacks.set(i,s);const o=this.instances.get(i);return o&&e(o,i),()=>{s.delete(e)}}invokeOnInitCallbacks(e,t){const i=this.onInitCallbacks.get(t);if(i)for(const s of i)try{s(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let i=this.instances.get(e);if(!i&&this.component&&(i=this.component.instanceFactory(this.container,{instanceIdentifier:fd(e),options:t}),this.instances.set(e,i),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(i,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,i)}catch{}return i||null}normalizeInstanceIdentifier(e=St){return this.component?this.component.multipleInstances?e:St:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function fd(n){return n===St?void 0:n}function pd(n){return n.instantiationMode==="EAGER"}class gd{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 dd(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}var B;(function(n){n[n.DEBUG=0]="DEBUG",n[n.VERBOSE=1]="VERBOSE",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.SILENT=5]="SILENT"})(B||(B={}));const _d={debug:B.DEBUG,verbose:B.VERBOSE,info:B.INFO,warn:B.WARN,error:B.ERROR,silent:B.SILENT},md=B.INFO,yd={[B.DEBUG]:"log",[B.VERBOSE]:"log",[B.INFO]:"info",[B.WARN]:"warn",[B.ERROR]:"error"},vd=(n,e,...t)=>{if(e<n.logLevel)return;const i=new Date().toISOString(),s=yd[e];if(s)console[s](`[${i}] ${n.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class Kn{constructor(e){this.name=e,this._logLevel=md,this._logHandler=vd,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in B))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?_d[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")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,B.DEBUG,...e),this._logHandler(this,B.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,B.VERBOSE,...e),this._logHandler(this,B.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,B.INFO,...e),this._logHandler(this,B.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,B.WARN,...e),this._logHandler(this,B.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,B.ERROR,...e),this._logHandler(this,B.ERROR,...e)}}const wd=(n,e)=>e.some(t=>n instanceof t);let ha,ua;function Ed(){return ha||(ha=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Id(){return ua||(ua=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const ec=new WeakMap,er=new WeakMap,tc=new WeakMap,Us=new WeakMap,Cr=new WeakMap;function Td(n){const e=new Promise((t,i)=>{const s=()=>{n.removeEventListener("success",o),n.removeEventListener("error",a)},o=()=>{t(ft(n.result)),s()},a=()=>{i(n.error),s()};n.addEventListener("success",o),n.addEventListener("error",a)});return e.then(t=>{t instanceof IDBCursor&&ec.set(t,n)}).catch(()=>{}),Cr.set(e,n),e}
15function Sd(n){if(er.has(n))return;const e=new Promise((t,i)=>{const s=()=>{n.removeEventListener("complete",o),n.removeEventListener("error",a),n.removeEventListener("abort",a)},o=()=>{t(),s()},a=()=>{i(n.error||new DOMException("AbortError","AbortError")),s()};n.addEventListener("complete",o),n.addEventListener("error",a),n.addEventListener("abort",a)});er.set(n,e)}let tr={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return er.get(n);if(e==="objectStoreNames")return n.objectStoreNames||tc.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return ft(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function Cd(n){tr=n(tr)}function Ad(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const i=n.call(Fs(this),e,...t);return tc.set(i,e.sort?e.sort():[e]),ft(i)}:Id().includes(n)?function(...e){return n.apply(Fs(this),e),ft(ec.get(this))}:function(...e){return ft(n.apply(Fs(this),e))}}function bd(n){return typeof n=="function"?Ad(n):(n instanceof IDBTransaction&&Sd(n),wd(n,Ed())?new Proxy(n,tr):n)}function ft(n){if(n instanceof IDBRequest)return Td(n);if(Us.has(n))return Us.get(n);const e=bd(n);return e!==n&&(Us.set(n,e),Cr.set(e,n)),e}const Fs=n=>Cr.get(n);function Rd(n,e,{blocked:t,upgrade:i,blocking:s,terminated:o}={}){const a=indexedDB.open(n,e),h=ft(a);return i&&a.addEventListener("upgradeneeded",u=>{i(ft(a.result),u.oldVersion,u.newVersion,ft(a.transaction),u)}),t&&a.addEventListener("blocked",u=>t(u.oldVersion,u.newVersion,u)),h.then(u=>{o&&u.addEventListener("close",()=>o()),s&&u.addEventListener("versionchange",f=>s(f.oldVersion,f.newVersion,f))}).catch(()=>{}),h}const kd=["get","getKey","getAll","getAllKeys","count"],Nd=["put","add","delete","clear"],Vs=new Map;function da(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(Vs.get(e))return Vs.get(e);const t=e.replace(/FromIndex$/,""),i=e!==t,s=Nd.includes(t);if(!(t in(i?IDBIndex:IDBObjectStore).prototype)||!(s||kd.includes(t)))return;const o=async function(a,...h){const u=this.transaction(a,s?"readwrite":"readonly");let f=u.store;return i&&(f=f.index(h.shift())),(await Promise.all([f[t](...h),s&&u.done]))[0]};return Vs.set(e,o),o}Cd(n=>({...n,get:(e,t,i)=>da(e,t)||n.get(e,t,i),has:(e,t)=>!!da(e,t)||n.has(e,t)}));class Pd{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(Od(t)){const i=t.getImmediate();return`${i.library}/${i.version}`}else return null}).filter(t=>t).join(" ")}}function Od(n){return n.getComponent()?.type==="VERSION"}const nr="@firebase/app",fa="0.14.6";const Qe=new Kn("@firebase/app"),Dd="@firebase/app-compat",Md="@firebase/analytics-compat",Ld="@firebase/analytics",xd="@firebase/app-check-compat",Ud="@firebase/app-check",Fd="@firebase/auth",Vd="@firebase/auth-compat",Bd="@firebase/database",Wd="@firebase/data-connect",Hd="@firebase/database-compat",jd="@firebase/functions",$d="@firebase/functions-compat",Gd="@firebase/installations",zd="@firebase/installations-compat",qd="@firebase/messaging",Kd="@firebase/messaging-compat",Yd="@firebase/performance",Xd="@firebase/performance-compat",Jd="@firebase/remote-config",Qd="@firebase/remote-config-compat",Zd="@firebase/storage",ef="@firebase/storage-compat",tf="@firebase/firestore",nf="@firebase/ai",sf="@firebase/firestore-compat",rf="firebase",of="12.6.0";const ir="[DEFAULT]",af={[nr]:"fire-core",[Dd]:"fire-core-compat",[Ld]:"fire-analytics",[Md]:"fire-analytics-compat",[Ud]:"fire-app-check",[xd]:"fire-app-check-compat",[Fd]:"fire-auth",[Vd]:"fire-auth-compat",[Bd]:"fire-rtdb",[Wd]:"fire-data-connect",[Hd]:"fire-rtdb-compat",[jd]:"fire-fn",[$d]:"fire-fn-compat",[Gd]:"fire-iid",[zd]:"fire-iid-compat",[qd]:"fire-fcm",[Kd]:"fire-fcm-compat",[Yd]:"fire-perf",[Xd]:"fire-perf-compat",[Jd]:"fire-rc",[Qd]:"fire-rc-compat",[Zd]:"fire-gcs",[ef]:"fire-gcs-compat",[tf]:"fire-fst",[sf]:"fire-fst-compat",[nf]:"fire-vertex","fire-js":"fire-js",[rf]:"fire-js-all"};const Ni=new Map,lf=new Map,sr=new Map;function pa(n,e){try{n.container.addComponent(e)}catch(t){Qe.debug(`Component ${e.name} failed to register with FirebaseApp ${n.name}`,t)}}function We(n){const e=n.name;if(sr.has(e))return Qe.debug(`There were multiple attempts to register component ${e}.`),!1;sr.set(e,n);for(const t of Ni.values())pa(t,n);for(const t of lf.values())pa(t,n);return!0}function nc(n,e){const t=n.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),n.container.getProvider(e)}function ye(n){return n==null?!1:n.settings!==void 0}const cf={"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.","invali
15d-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-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."},pt=new on("app","Firebase",cf);class hf{constructor(e,t,i){this._isDeleted=!1,this._options={...e},this._config={...t},this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=i,this.container.addComponent(new Oe("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 pt.create("app-deleted",{appName:this._name})}}const yt=of;function uf(n,e={}){let t=n;typeof e!="object"&&(e={name:e});const i={name:ir,automaticDataCollectionEnabled:!0,...e},s=i.name;if(typeof s!="string"||!s)throw pt.create("bad-app-name",{appName:String(s)});if(t||(t=Yl()),!t)throw pt.create("no-options");const o=Ni.get(s);if(o){if(en(t,o.options)&&en(i,o.config))return o;throw pt.create("duplicate-app",{appName:s})}const a=new gd(s);for(const u of sr.values())a.addComponent(u);const h=new hf(t,i,a);return Ni.set(s,h),h}function df(n=ir){const e=Ni.get(n);if(!e&&n===ir&&Yl())return uf();if(!e)throw pt.create("no-app",{appName:n});return e}function ve(n,e,t){let i=af[n]??n;t&&(i+=`-${t}`);const s=i.match(/\s|\//),o=e.match(/\s|\//);if(s||o){const a=[`Unable to register library "${i}" with version "${e}":`];s&&a.push(`library name "${i}" contains illegal characters (whitespace or "/")`),s&&o&&a.push("and"),o&&a.push(`version name "${e}" contains illegal characters (whitespace or "/")`),Qe.warn(a.join(" "));return}We(new Oe(`${i}-version`,()=>({library:i,version:e}),"VERSION"))}const ff="firebase-heartbeat-database",pf=1,$n="firebase-heartbeat-store";let Bs=null;function ic(){return Bs||(Bs=Rd(ff,pf,{upgrade:(n,e)=>{switch(e){case 0:try{n.createObjectStore($n)}catch(t){console.warn(t)}}}}).catch(n=>{throw pt.create("idb-open",{originalErrorMessage:n.message})})),Bs}async function gf(n){try{const t=(await ic()).transaction($n),i=await t.objectStore($n).get(sc(n));return await t.done,i}catch(e){if(e instanceof $e)Qe.warn(e.message);else{const t=pt.create("idb-get",{originalErrorMessage:e?.message});Qe.warn(t.message)}}}async function ga(n,e){try{const i=(await ic()).transaction($n,"readwrite");await i.objectStore($n).put(e,sc(n)),await i.done}catch(t){if(t instanceof $e)Qe.warn(t.message);else{const i=pt.create("idb-set",{originalErrorMessage:t?.message});Qe.warn(i.message)}}}function sc(n){return`${n.name}!${n.options.appId}`}const _f=1024,mf=30;class yf{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new wf(t),this._heartbeatsCachePromise=this._storage.read().then(i=>(this._heartbeatsCache=i,i))}async triggerHeartbeat(){try{const t=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),i=_a();if(this._heartbeatsCache?.heartbeats==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null)||this._heartbeatsCache.lastSentHeartbeatDate===i||this._heartbeatsCache.heartbeats.some(s=>s.date===i))return;if(this._heartbeatsCache.heartbeats.push({date:i,agent:t}),this._heartbeatsCache.heartbeats.length>mf){const s=Ef(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(s,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){Qe.warn(e)}}async getHeartbeatsHeader(){try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null||this._heartbeatsCache.heartbeats.length===0)return"";const e=_a(),{heartbeatsToSend:t,unsentEntries:i}=vf(this._heartbeatsCache.heartbeats),s=ql(JSON.stringify({version:2,heartbeats:t}));return this._heartbeatsCache.lastSentHeartbeatDate=e,i.length>0?(this._heartbeatsCache.heartbeats=i,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),s}
15catch(e){return Qe.warn(e),""}}}function _a(){return new Date().toISOString().substring(0,10)}function vf(n,e=_f){const t=[];let i=n.slice();for(const s of n){const o=t.find(a=>a.agent===s.agent);if(o){if(o.dates.push(s.date),ma(t)>e){o.dates.pop();break}}else if(t.push({agent:s.agent,dates:[s.date]}),ma(t)>e){t.pop();break}i=i.slice(1)}return{heartbeatsToSend:t,unsentEntries:i}}class wf{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return Ql()?ed().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const t=await gf(this.app);return t?.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){const i=await this.read();return ga(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??i.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){if(await this._canUseIndexedDBPromise){const i=await this.read();return ga(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??i.lastSentHeartbeatDate,heartbeats:[...i.heartbeats,...e.heartbeats]})}else return}}function ma(n){return ql(JSON.stringify({version:2,heartbeats:n})).length}function Ef(n){if(n.length===0)return-1;let e=0,t=n[0].date;for(let i=1;i<n.length;i++)n[i].date<t&&(t=n[i].date,e=i);return e}function If(n){We(new Oe("platform-logger",e=>new Pd(e),"PRIVATE")),We(new Oe("heartbeat",e=>new yf(e),"PRIVATE")),ve(nr,fa,n),ve(nr,fa,"esm2020"),ve("fire-js","")}If("");var ya=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};var Ar;(function(){var n;function e(v,p){function _(){}_.prototype=p.prototype,v.F=p.prototype,v.prototype=new _,v.prototype.constructor=v,v.D=function(w,m,T){for(var g=Array(arguments.length-2),pe=2;pe<arguments.length;pe++)g[pe-2]=arguments[pe];return p.prototype[m].apply(w,g)}}function t(){this.blockSize=-1}function i(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.C=Array(this.blockSize),this.o=this.h=0,this.u()}e(i,t),i.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function s(v,p,_){_||(_=0);const w=Array(16);if(typeof p=="string")for(var m=0;m<16;++m)w[m]=p.charCodeAt(_++)|p.charCodeAt(_++)<<8|p.charCodeAt(_++)<<16|p.charCodeAt(_++)<<24;else for(m=0;m<16;++m)w[m]=p[_++]|p[_++]<<8|p[_++]<<16|p[_++]<<24;p=v.g[0],_=v.g[1],m=v.g[2];let T=v.g[3],g;g=p+(T^_&(m^T))+w[0]+3614090360&4294967295,p=_+(g<<7&4294967295|g>>>25),g=T+(m^p&(_^m))+w[1]+3905402710&4294967295,T=p+(g<<12&4294967295|g>>>20),g=m+(_^T&(p^_))+w[2]+606105819&4294967295,m=T+(g<<17&4294967295|g>>>15),g=_+(p^m&(T^p))+w[3]+3250441966&4294967295,_=m+(g<<22&4294967295|g>>>10),g=p+(T^_&(m^T))+w[4]+4118548399&4294967295,p=_+(g<<7&4294967295|g>>>25),g=T+(m^p&(_^m))+w[5]+1200080426&4294967295,T=p+(g<<12&4294967295|g>>>20),g=m+(_^T&(p^_))+w[6]+2821735955&4294967295,m=T+(g<<17&4294967295|g>>>15),g=_+(p^m&(T^p))+w[7]+4249261313&4294967295,_=m+(g<<22&4294967295|g>>>10),g=p+(T^_&(m^T))+w[8]+1770035416&4294967295,p=_+(g<<7&4294967295|g>>>25),g=T+(m^p&(_^m))+w[9]+2336552879&4294967295,T=p+(g<<12&4294967295|g>>>20),g=m+(_^T&(p^_))+w[10]+4294925233&4294967295,m=T+(g<<17&4294967295|g>>>15),g=_+(p^m&(T^p))+w[11]+2304563134&4294967295,_=m+(g<<22&4294967295|g>>>10),g=p+(T^_&(m^T))+w[12]+1804603682&4294967295,p=_+(g<<7&4294967295|g>>>25),g=T+(m^p&(_^m))+w[13]+4254626195&4294967295,T=p+(g<<12&4294967295|g>>>20),g=m+(_^T&(p^_))+w[14]+2792965006&4294967295,m=T+(g<<17&4294967295|g>>>15),g=_+(p^m&(T^p))+w[15]+1236535329&4294967295,_=m+(g<<22&4294967295|g>>>10),g=p+(m^T&(_^m))+w[1]+4129170786&4294967295,p=_+(g<<5&4294967295|g>>>27),g=T+(_^m&(p^_))+w[6]+3225465664&4294967295,T=p+(g<<9&4294967295|g>>>23),g=m+(p^_&(T^p))+w[11]+643717713&4294967295,m=T+(g<<14&4294967295|g>>>18),g=_+(T^p&(m^T))+w[0]+3921069994&4294967295,_=m+(g<<20&4294967295|g>>>12),g=p+(m^T&(_^m))+w[5]+3593408605&4294967295,p=_+(g<<5&4294967295|g>>>27),g=T+(_^m&(p^_))+w[10]+38016083&4294967295,T=p+(g<<9&4294967295|g>>>23),g=m+(p^_&(T^p))+w[15]+3634488961&4294967295,m=T+(g<<14&4294967295|g>>>18),g=_+(T^p&(m^T))+w[4]+3889429448&4294967295,_=m+(g<<20&4294967295|g>>>12),g=p+(m^T&(_^m))+w[9]+568446438&4294967295,p=_+(g<<5&4294967295|g>>>27),g=T+(_^m&(p^_))+w[14]+3275163606&4294967295,T=p+(g<<9&4294967295|g>>>23),g=m+(p^_&(T^p))+w[3]+4107603335&4294967295,m=T+(g<<14&4294967295|g>>>18),g=_+(T^p&(m^T))+w[8]+1163531501&4294967295,_=m+(g<<20&4294967295|g>>>12),g=p+(m^T&(_^m))+w[13]+2850285829&4294967295,p=_+(g<<5&4294967295|g>>>27),g=T+(_^m&(p^_))+w[2]+4243563512&4294967295,T=p+(g<<9&4294967295|g>>>23),g=m+(p^_&(T^p))+w[7]+1735328473&4294967295,m=T+(g<<14&4294967295|g>>>18),g=_+(T^p&(m^T))+w[12]+2368359562&4294967295,_=m+(g<<20&4294967295|g>>>12),g=p+(_^m^T)+w[5]+4294588738&4294967295,p=_+(g<<4&4294967295|g>>>28),g=T+(p^_^m)+w[8]+2272392833&4294967295,T=p+(g<<11&4294967295|g>>>21),g=m+(T^p^_)+w[11]+1839030562&4294967295,m=T+(g<<16&4294967295|g>>>16),g=_+(m^T^p)+w[14]+4259657740&4294967295,_=m+(g<<23&4294967295|g>>>9),g=p+(_^m^T)+w[1]+2763975236&4294967295,p=_+(g<<4&4294967295|g>>>28),g=T+(p^_^m)+w[4]+1272893353&4294967295,T=p+(g<<11&4294967295|g>>>21),g=m+(T^p^_)+w[7]+4139469664&4294967295,m=T+(g<<16&4294967295|g>>>16),g=_+(m^T^p)+w[10]+3200236656&4294967295,_=m+(g<<23&4294967295|g>>>9),g=p+(_^m^T)+w[13]+681279174&4294967295,p=_+(g<<4&4294967295|g>>>28),g=T+(p^_^m)+w[0]+3936430074&4294967295,T=p+(g<<11&4294967295|g>>>21),g=m+(T^p^_)+w[3]+3572445317&4294967295,m=T+(g<<16&4294967295|g>>>16),g=_+(m^T^p)+w[6]+76029189&4294967295,_=m+(g<<23&4294967295|g>>>9),g=p+(_^m^T)+w[9]+3654602809&4294967295,p=_+(g<<4&4294967295|g>>>28),g=T+(p^_^m)+w[12]+3873151461&4294967295,T=p+(g<<11&4294967295|g>>>21),g=m+(T^p^_)+w[15]+530742520&4294967295,m=T+(g<<16&4294967295|g>>>16),g=_+(m^T^p)+w[2]+3299628645&4294967295,_=m+(g<<23&4294967295|g>>>9),g=p+(m^(_|~T))+w[0]+4096336452&4294967295,p=_+(g<<6&4294967295|g>>>26),g=T+(_^(p|~m))+w[7]+1126891415&4294967295,T=p+(g<<10&4294967295|g>>>22),g=m+(p^(T|~_))+w[14]+2878612391&4294967295,m=T+(g<<15&4294967295|g>>>17),g=_+(T^(m|~p))+w[5]+4237533241&4294967295,_=m+(g<<21&4294967295|g>>>11),g=p+(m^(_|~T))+w[12]+1700485571&4294967295,p=_+(g<<6&4294967295|g>>>26),g=T+(_^(p|~m))+w[3]+2399980690&4294967295,T=p+(g<<10&4294967295|g>>>22),g=m+(p^(T|~_))+w[10]+4293915773&4294967295,m=T+(g<<15&4294967295|g>>>17),g=_+(T^(m|~p))+w[1]+2240044497&4294967295,_=m+(g<<21&4294967295|g>>>11),g=p+(m^(_|~T))+w[8]+1873313359&4294967295,p=_+(g<<6&4294967295|g>>>26),g=T+(_^(p|~m))+w[15]+4264355552&4294967295,T=p+(g<<10&4294967295|g>>>22),g=m+(p^(T|~_))+w[6]+2734768916&4294967295,m=T+(g<<15&4294967295|g>>>17),g=_+(T^(m|~p))+w[13]+1309151649&4294967295,_=m+(g<<21&4294967295|g>>>11),g=p+(m^(_|~T))+w[4]+4149444226&4294967295,p=_+(g<<6&4294967295|g>>>26),g=T+(_^(p|~m))+w[11]+3174756917&4294967295,T=p+(g<<10&4294967295|g>>>22),g=m+(p^(T|~_))+w[2]+718787259&4294967295,m=T+(g<<15&4294967295|g>>>17),g=_+(T^(m|~p))+w[9]+3951481745&4294967295,v.g[0]=v.g[0]+p&4294967295,v.g[1]=v.g[1]+(m+(g<<21&4294967295|g>>>11))&4294967295,v.g[2]=v.g[2]+m&4294967295,v.g[3]=v.g[3]+T&4294967295}i.prototype.v=function(v,p){p===void 0&&(p=v.length);const _=p-this.blockSize,w=this.C;let m=this.h,T=0;for(;T<p;){if(m==0)for(;T<=_;)s(this,v,T),T+=this.blockSize;if(typeof v=="string"){for(;T<p;)if(w[m++]=v.charCodeAt(T++),m==this.blockSize){s(this,w),m=0;break}}else for(;T<p;
15)if(w[m++]=v[T++],m==this.blockSize){s(this,w),m=0;break}}this.h=m,this.o+=p},i.prototype.A=function(){var v=Array((this.h<56?this.blockSize:this.blockSize*2)-this.h);v[0]=128;for(var p=1;p<v.length-8;++p)v[p]=0;p=this.o*8;for(var _=v.length-8;_<v.length;++_)v[_]=p&255,p/=256;for(this.v(v),v=Array(16),p=0,_=0;_<4;++_)for(let w=0;w<32;w+=8)v[p++]=this.g[_]>>>w&255;return v};function o(v,p){var _=h;return Object.prototype.hasOwnProperty.call(_,v)?_[v]:_[v]=p(v)}function a(v,p){this.h=p;const _=[];let w=!0;for(let m=v.length-1;m>=0;m--){const T=v[m]|0;w&&T==p||(_[m]=T,w=!1)}this.g=_}var h={};function u(v){return-128<=v&&v<128?o(v,function(p){return new a([p|0],p<0?-1:0)}):new a([v|0],v<0?-1:0)}function f(v){if(isNaN(v)||!isFinite(v))return y;if(v<0)return N(f(-v));const p=[];let _=1;for(let w=0;v>=_;w++)p[w]=v/_|0,_*=4294967296;return new a(p,0)}function E(v,p){if(v.length==0)throw Error("number format error: empty string");if(p=p||10,p<2||36<p)throw Error("radix out of range: "+p);if(v.charAt(0)=="-")return N(E(v.substring(1),p));if(v.indexOf("-")>=0)throw Error('number format error: interior "-" character');const _=f(Math.pow(p,8));let w=y;for(let T=0;T<v.length;T+=8){var m=Math.min(8,v.length-T);const g=parseInt(v.substring(T,T+m),p);m<8?(m=f(Math.pow(p,m)),w=w.j(m).add(f(g))):(w=w.j(_),w=w.add(f(g)))}return w}var y=u(0),S=u(1),k=u(16777216);n=a.prototype,n.m=function(){if(O(this))return-N(this).m();let v=0,p=1;for(let _=0;_<this.g.length;_++){const w=this.i(_);v+=(w>=0?w:4294967296+w)*p,p*=4294967296}return v},n.toString=function(v){if(v=v||10,v<2||36<v)throw Error("radix out of range: "+v);if(R(this))return"0";if(O(this))return"-"+N(this).toString(v);const p=f(Math.pow(v,6));var _=this;let w="";for(;;){const m=X(_,p).g;_=Y(_,m.j(p));let T=((_.g.length>0?_.g[0]:_.h)>>>0).toString(v);if(_=m,R(_))return T+w;for(;T.length<6;)T="0"+T;w=T+w}},n.i=function(v){return v<0?0:v<this.g.length?this.g[v]:this.h};function R(v){if(v.h!=0)return!1;for(let p=0;p<v.g.length;p++)if(v.g[p]!=0)return!1;return!0}function O(v){return v.h==-1}n.l=function(v){return v=Y(this,v),O(v)?-1:R(v)?0:1};function N(v){const p=v.g.length,_=[];for(let w=0;w<p;w++)_[w]=~v.g[w];return new a(_,~v.h).add(S)}n.abs=function(){return O(this)?N(this):this},n.add=function(v){const p=Math.max(this.g.length,v.g.length),_=[];let w=0;for(let m=0;m<=p;m++){let T=w+(this.i(m)&65535)+(v.i(m)&65535),g=(T>>>16)+(this.i(m)>>>16)+(v.i(m)>>>16);w=g>>>16,T&=65535,g&=65535,_[m]=g<<16|T}return new a(_,_[_.length-1]&-2147483648?-1:0)};function Y(v,p){return v.add(N(p))}n.j=function(v){if(R(this)||R(v))return y;if(O(this))return O(v)?N(this).j(N(v)):N(N(this).j(v));if(O(v))return N(this.j(N(v)));if(this.l(k)<0&&v.l(k)<0)return f(this.m()*v.m());const p=this.g.length+v.g.length,_=[];for(var w=0;w<2*p;w++)_[w]=0;for(w=0;w<this.g.length;w++)for(let m=0;m<v.g.length;m++){const T=this.i(w)>>>16,g=this.i(w)&65535,pe=v.i(m)>>>16,vt=v.i(m)&65535;_[2*w+2*m]+=g*vt,Q(_,2*w+2*m),_[2*w+2*m+1]+=T*vt,Q(_,2*w+2*m+1),_[2*w+2*m+1]+=g*pe,Q(_,2*w+2*m+1),_[2*w+2*m+2]+=T*pe,Q(_,2*w+2*m+2)}for(v=0;v<p;v++)_[v]=_[2*v+1]<<16|_[2*v];for(v=p;v<2*p;v++)_[v]=0;return new a(_,0)};function Q(v,p){for(;(v[p]&65535)!=v[p];)v[p+1]+=v[p]>>>16,v[p]&=65535,p++}function K(v,p){this.g=v,this.h=p}function X(v,p){if(R(p))throw Error("division by zero");if(R(v))return new K(y,y);if(O(v))return p=X(N(v),p),new K(N(p.g),N(p.h));if(O(p))return p=X(v,N(p)),new K(N(p.g),p.h);if(v.g.length>30){if(O(v)||O(p))throw Error("slowDivide_ only works with positive integers.");for(var _=S,w=p;w.l(v)<=0;)_=_e(_),w=_e(w);var m=oe(_,1),T=oe(w,1);for(w=oe(w,2),_=oe(_,2);!R(w);){var g=T.add(w);g.l(v)<=0&&(m=m.add(_),T=g),w=oe(w,1),_=oe(_,1)}return p=Y(v,m.j(p)),new K(m,p)}for(m=y;v.l(p)>=0;){for(_=Math.max(1,Math.floor(v.m()/p.m())),w=Math.ceil(Math.log(_)/Math.LN2),w=w<=48?1:Math.pow(2,w-48),T=f(_),g=T.j(p);O(g)||g.l(v)>0;)_-=w,T=f(_),g=T.j(p);R(T)&&(T=S),m=m.add(T),v=Y(v,g)}return new K(m,v)}n.B=function(v){return X(this,v).h},n.and=function(v){const p=Math.max(this.g.length,v.g.length),_=[];for(let w=0;w<p;w++)_[w]=this.i(w)&v.i(w);return new a(_,this.h&v.h)},n.or=function(v){const p=Math.max(this.g.length,v.g.length),_=[];for(let w=0;w<p;w++)_[w]=this.i(w)|v.i(w);return new a(_,this.h|v.h)},n.xor=function(v){const p=Math.max(this.g.length,v.g.length),_=[];for(let w=0;w<p;w++)_[w]=this.i(w)^v.i(w);return new a(_,this.h^v.h)};function _e(v){const p=v.g.length+1,_=[];for(let w=0;w<p;w++)_[w]=v.i(w)<<1|v.i(w-1)>>>31;return new a(_,v.h)}function oe(v,p){const _=p>>5;p%=32;const w=v.g.length-_,m=[];for(let T=0;T<w;T++)m[T]=p>0?v.i(T+_)>>>p|v.i(T+_+1)<<32-p:v.i(T+_);return new a(m,v.h)}i.prototype.digest=i.prototype.A,i.prototype.reset=i.prototype.u,i.prototype.update=i.prototype.v,a.prototype.add=a.prototype.add,a.prototype.multiply=a.prototype.j,a.prototype.modulo=a.prototype.B,a.prototype.compare=a.prototype.l,a.prototype.toNumber=a.prototype.m,a.prototype.toString=a.prototype.toString,a.prototype.getBits=a.prototype.i,a.fromNumber=f,a.fromString=E,Ar=a}).apply(typeof ya<"u"?ya:typeof self<"u"?self:typeof window<"u"?window:{});var _i=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};(function(){var n,e=Object.defineProperty;function t(r){r=[typeof globalThis=="object"&&globalThis,r,typeof window=="object"&&window,typeof self=="object"&&self,typeof _i=="object"&&_i];for(var l=0;l<r.length;++l){var c=r[l];if(c&&c.Math==Math)return c}throw Error("Cannot find global object")}var i=t(this);function s(r,l){if(l)e:{var c=i;r=r.split(".");for(var d=0;d<r.length-1;d++){var I=r[d];if(!(I in c))break e;c=c[I]}r=r[r.length-1],d=c[r],l=l(d),l!=d&&l!=null&&e(c,r,{configurable:!0,writable:!0,value:l})}}s("Symbol.dispose",function(r){return r||Symbol("Symbol.dispose")}),s("Array.prototype.values",function(r){return r||function(){return this[Symbol.iterator]()}}),s("Object.entries",function(r){return r||function(l){var c=[],d;for(d in l)Object.prototype.hasOwnProperty.call(l,d)&&c.push([d,l[d]]);return c}});var o=o||{},a=this||self;function h(r){var l=typeof r;return l=="object"&&r!=null||l=="function"}function u(r,l,c){return r.call.apply(r.bind,arguments)}function f(r,l,c){return f=u,f.apply(null,arguments)}
15function E(r,l){var c=Array.prototype.slice.call(arguments,1);return function(){var d=c.slice();return d.push.apply(d,arguments),r.apply(this,d)}}function y(r,l){function c(){}c.prototype=l.prototype,r.Z=l.prototype,r.prototype=new c,r.prototype.constructor=r,r.Ob=function(d,I,C){for(var A=Array(arguments.length-2),D=2;D<arguments.length;D++)A[D-2]=arguments[D];return l.prototype[I].apply(d,A)}}var S=typeof AsyncContext<"u"&&typeof AsyncContext.Snapshot=="function"?r=>r&&AsyncContext.Snapshot.wrap(r):r=>r;function k(r){const l=r.length;if(l>0){const c=Array(l);for(let d=0;d<l;d++)c[d]=r[d];return c}return[]}function R(r,l){for(let d=1;d<arguments.length;d++){const I=arguments[d];var c=typeof I;if(c=c!="object"?c:I?Array.isArray(I)?"array":c:"null",c=="array"||c=="object"&&typeof I.length=="number"){c=r.length||0;const C=I.length||0;r.length=c+C;for(let A=0;A<C;A++)r[c+A]=I[A]}else r.push(I)}}class O{constructor(l,c){this.i=l,this.j=c,this.h=0,this.g=null}get(){let l;return this.h>0?(this.h--,l=this.g,this.g=l.next,l.next=null):l=this.i(),l}}function N(r){a.setTimeout(()=>{throw r},0)}function Y(){var r=v;let l=null;return r.g&&(l=r.g,r.g=r.g.next,r.g||(r.h=null),l.next=null),l}class Q{constructor(){this.h=this.g=null}add(l,c){const d=K.get();d.set(l,c),this.h?this.h.next=d:this.g=d,this.h=d}}var K=new O(()=>new X,r=>r.reset());class X{constructor(){this.next=this.g=this.h=null}set(l,c){this.h=l,this.g=c,this.next=null}reset(){this.next=this.g=this.h=null}}let _e,oe=!1,v=new Q,p=()=>{const r=Promise.resolve(void 0);_e=()=>{r.then(_)}};function _(){for(var r;r=Y();){try{r.h.call(r.g)}catch(c){N(c)}var l=K;l.j(r),l.h<100&&(l.h++,r.next=l.g,l.g=r)}oe=!1}function w(){this.u=this.u,this.C=this.C}w.prototype.u=!1,w.prototype.dispose=function(){this.u||(this.u=!0,this.N())},w.prototype[Symbol.dispose]=function(){this.dispose()},w.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function m(r,l){this.type=r,this.g=this.target=l,this.defaultPrevented=!1}m.prototype.h=function(){this.defaultPrevented=!0};var T=(function(){if(!a.addEventListener||!Object.defineProperty)return!1;var r=!1,l=Object.defineProperty({},"passive",{get:function(){r=!0}});try{const c=()=>{};a.addEventListener("test",c,l),a.removeEventListener("test",c,l)}catch{}return r})();function g(r){return/^[\s\xa0]*$/.test(r)}function pe(r,l){m.call(this,r?r.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,r&&this.init(r,l)}y(pe,m),pe.prototype.init=function(r,l){const c=this.type=r.type,d=r.changedTouches&&r.changedTouches.length?r.changedTouches[0]:null;this.target=r.target||r.srcElement,this.g=l,l=r.relatedTarget,l||(c=="mouseover"?l=r.fromElement:c=="mouseout"&&(l=r.toElement)),this.relatedTarget=l,d?(this.clientX=d.clientX!==void 0?d.clientX:d.pageX,this.clientY=d.clientY!==void 0?d.clientY:d.pageY,this.screenX=d.screenX||0,this.screenY=d.screenY||0):(this.clientX=r.clientX!==void 0?r.clientX:r.pageX,this.clientY=r.clientY!==void 0?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0),this.button=r.button,this.key=r.key||"",this.ctrlKey=r.ctrlKey,this.altKey=r.altKey,this.shiftKey=r.shiftKey,this.metaKey=r.metaKey,this.pointerId=r.pointerId||0,this.pointerType=r.pointerType,this.state=r.state,this.i=r,r.defaultPrevented&&pe.Z.h.call(this)},pe.prototype.h=function(){pe.Z.h.call(this);const r=this.i;r.preventDefault?r.preventDefault():r.returnValue=!1};var vt="closure_listenable_"+(Math.random()*1e6|0),nu=0;function iu(r,l,c,d,I){this.listener=r,this.proxy=null,this.src=l,this.type=c,this.capture=!!d,this.ha=I,this.key=++nu,this.da=this.fa=!1}function si(r){r.da=!0,r.listener=null,r.proxy=null,r.src=null,r.ha=null}function ri(r,l,c){for(const d in r)l.call(c,r[d],d,r)}function su(r,l){for(const c in r)l.call(void 0,r[c],c,r)}function ao(r){const l={};for(const c in r)l[c]=r[c];return l}const lo="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleStr
15ing toString valueOf".split(" ");function co(r,l){let c,d;for(let I=1;I<arguments.length;I++){d=arguments[I];for(c in d)r[c]=d[c];for(let C=0;C<lo.length;C++)c=lo[C],Object.prototype.hasOwnProperty.call(d,c)&&(r[c]=d[c])}}function oi(r){this.src=r,this.g={},this.h=0}oi.prototype.add=function(r,l,c,d,I){const C=r.toString();r=this.g[C],r||(r=this.g[C]=[],this.h++);const A=us(r,l,d,I);return A>-1?(l=r[A],c||(l.fa=!1)):(l=new iu(l,this.src,C,!!d,I),l.fa=c,r.push(l)),l};function hs(r,l){const c=l.type;if(c in r.g){var d=r.g[c],I=Array.prototype.indexOf.call(d,l,void 0),C;(C=I>=0)&&Array.prototype.splice.call(d,I,1),C&&(si(l),r.g[c].length==0&&(delete r.g[c],r.h--))}}function us(r,l,c,d){for(let I=0;I<r.length;++I){const C=r[I];if(!C.da&&C.listener==l&&C.capture==!!c&&C.ha==d)return I}return-1}var ds="closure_lm_"+(Math.random()*1e6|0),fs={};function ho(r,l,c,d,I){if(Array.isArray(l)){for(let C=0;C<l.length;C++)ho(r,l[C],c,d,I);return null}return c=po(c),r&&r[vt]?r.J(l,c,h(d)?!!d.capture:!1,I):ru(r,l,c,!1,d,I)}function ru(r,l,c,d,I,C){if(!l)throw Error("Invalid event type");const A=h(I)?!!I.capture:!!I;let D=gs(r);if(D||(r[ds]=D=new oi(r)),c=D.add(l,c,d,A,C),c.proxy)return c;if(d=ou(),c.proxy=d,d.src=r,d.listener=c,r.addEventListener)T||(I=A),I===void 0&&(I=!1),r.addEventListener(l.toString(),d,I);else if(r.attachEvent)r.attachEvent(fo(l.toString()),d);else if(r.addListener&&r.removeListener)r.addListener(d);else throw Error("addEventListener and attachEvent are unavailable.");return c}function ou(){function r(c){return l.call(r.src,r.listener,c)}const l=au;return r}function uo(r,l,c,d,I){if(Array.isArray(l))for(var C=0;C<l.length;C++)uo(r,l[C],c,d,I);else d=h(d)?!!d.capture:!!d,c=po(c),r&&r[vt]?(r=r.i,C=String(l).toString(),C in r.g&&(l=r.g[C],c=us(l,c,d,I),c>-1&&(si(l[c]),Array.prototype.splice.call(l,c,1),l.length==0&&(delete r.g[C],r.h--)))):r&&(r=gs(r))&&(l=r.g[l.toString()],r=-1,l&&(r=us(l,c,d,I)),(c=r>-1?l[r]:null)&&ps(c))}function ps(r){if(typeof r!="number"&&r&&!r.da){var l=r.src;if(l&&l[vt])hs(l.i,r);else{var c=r.type,d=r.proxy;l.removeEventListener?l.removeEventListener(c,d,r.capture):l.detachEvent?l.detachEvent(fo(c),d):l.addListener&&l.removeListener&&l.removeListener(d),(c=gs(l))?(hs(c,r),c.h==0&&(c.src=null,l[ds]=null)):si(r)}}}function fo(r){return r in fs?fs[r]:fs[r]="on"+r}function au(r,l){if(r.da)r=!0;else{l=new pe(l,this);const c=r.listener,d=r.ha||r.src;r.fa&&ps(r),r=c.call(d,l)}return r}function gs(r){return r=r[ds],r instanceof oi?r:null}var _s="__closure_events_fn_"+(Math.random()*1e9>>>0);function po(r){return typeof r=="function"?r:(r[_s]||(r[_s]=function(l){return r.handleEvent(l)}),r[_s])}function ae(){w.call(this),this.i=new oi(this),this.M=this,this.G=null}y(ae,w),ae.prototype[vt]=!0,ae.prototype.removeEventListener=function(r,l,c,d){uo(this,r,l,c,d)};function ue(r,l){var c,d=r.G;if(d)for(c=[];d;d=d.G)c.push(d);if(r=r.M,d=l.type||l,typeof l=="string")l=new m(l,r);else if(l instanceof m)l.target=l.target||r;else{var I=l;l=new m(d,r),co(l,I)}I=!0;let C,A;if(c)for(A=c.length-1;A>=0;A--)C=l.g=c[A],I=ai(C,d,!0,l)&&I;if(C=l.g=r,I=ai(C,d,!0,l)&&I,I=ai(C,d,!1,l)&&I,c)for(A=0;A<c.length;A++)C=l.g=c[A],I=ai(C,d,!1,l)&&I}ae.prototype.N=function(){if(ae.Z.N.call(this),this.i){var r=this.i;for(const l in r.g){const c=r.g[l];for(let d=0;d<c.length;d++)si(c[d]);delete r.g[l],r.h--}}this.G=null},ae.prototype.J=function(r,l,c,d){return this.i.add(String(r),l,!1,c,d)},ae.prototype.K=function(r,l,c,d){return this.i.add(String(r),l,!0,c,d)};function ai(r,l,c,d){if(l=r.i.g[String(l)],!l)return!0;l=l.concat();let I=!0;for(let C=0;C<l.length;++C){const A=l[C];if(A&&!A.da&&A.capture==c){const D=A.listener,ee=A.ha||A.src;A.fa&&hs(r.i,A),I=D.call(ee,d)!==!1&&I}}return I&&!d.defaultPrevented}function lu(r,l){if(typeof r!="function")if(r&&typeof r.handleEvent=="function")r=f(r.handleEvent,r);else throw Error("Invalid listener argument");return Number(l)>2147483647?-1:a.setTimeout(r,l||0)}function go(r){r.g=lu(()=>{r.g=null,r.i&&(r.i=!1,go(r))},r.l);const l=r.h;r.h=null,r.m.apply(null,l)}class cu extends w{constructor(l,c){super(),this.m=l,this.l=c,this.h=null,this.i=!1,this.g=null}j(l){this.h=arguments,this.g?this.i=!0:go(this)}N(){super.N(),this.g&&(a.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function dn(r){w.call(this),this.h=r,this.g={}}y(dn,w);var _o=[];function mo(r){ri(r.g,function(l,c){this.g.hasOwnProperty(c)&&ps(l)},r),r.g={}}dn.prototype.N=function(){dn.Z.N.call(this),mo(this)},dn.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var ms=a.JSON.stringify,hu=a.JSON.parse,uu=class{stringify(r){return a.JSON.stringify(r,void 0)}parse(r){return a.JSON.parse(r,void 0)}};function yo(){}function du(){}var fn={OPEN:"a",hb:"b",ERROR:"c",tb:"d"};function ys(){m.call(this,"d")}y(ys,m);function vs(){m.call(this,"c")}y(vs,m);var Bt={},vo=null;function ws(){return vo=vo||new ae}Bt.Ia="serverreachability";function wo(r){m.call(this,Bt.Ia,r)}y(wo,m);function pn(r){const l=ws();ue(l,new wo(l))}Bt.STAT_EVENT="statevent";function Eo(r,l){m.call(this,Bt.STAT_EVENT,r),this.stat=l}y(Eo,m);function de(r){const l=ws();ue(l,new Eo(l,r))}Bt.Ja="timingevent";function Io(r,l){m.call(this,Bt.Ja,r),this.size=l}y(Io,m);function gn(r,l){if(typeof r!="function")throw Error("Fn must not be null and must be a function");return a.setTimeout(function(){r()},l)}function _n(){this.g=!0}_n.prototype.ua=function(){this.g=!1};function fu(r,l,c,d,I,C){r.info(function(){if(r.g)if(C){var A="",D=C.split("&");for(let j=0;j<D.length;j++){var ee=D[j].split("=");if(ee.length>1){const te=ee[0];ee=ee[1];const Le=te.split("_");A=Le.length>=2&&Le[1]=="type"?A+(te+"="+ee+"&"):A+(te+"=redacted&")}}}else A=null;else A=C;return"XMLHTTP REQ ("+d+") [attempt "+I+"]: "+l+` 16`+c+` 17`+A})}function pu(r,l,c,d,I,C,A){r.info(function(){return"XMLHTTP RESP ("+d+") [ attempt "+I+"]: "+l+` 18`+c+` 19`+C+" "+A})}function Wt(r,l,c,d){r.info(function(){return"XMLHTTP TEXT ("+l+"): "+_u(r,c)+(d?" "+d:"")})}function gu(r,l){r.info(function(){return"TIMEOUT: "+l})}_n.prototype.info=function(){};function _u(r,l){if(!r.g)return l;if(!l)return null;try{const C=JSON.parse(l);if(C){for(r=0;r<C.length;r++)if(Array.isArray(C[r])){var c=C[r];if(!(c.length<2)){var d=c[1];if(Array.isArray(d)&&!(d.length<1)){var I=d[0];if(I!="noop"&&I!="stop"&&I!="close")for(let A=1;A<d.length;A++)d[A]=""}}}}return ms(C)}catch{return l}}var Es={NO_ERROR:0,TIMEOUT:8},mu={},To;function Is(){}y(Is,yo),Is.prototype.g=function(){return new XMLHttpRequest},To=new Is;function mn(r){return encodeURIComponent(String(r))}function yu(r){var l=1;r=r.split(":");const c=[];for(;l>0&&r.length;)c.push(r.shift()),l--;return r.length&&c.push(r.join(":")),c}function tt(r,l,c,d){this.j=r,this.i=l,this.l=c,this.S=d||1,this.V=new dn(this),this.H=45e3,this.J=null,this.o=!1,this.u=this.B=this.A=this.M=this.F=this.T=this.D=null,this.G=[],this.g=null,this.C=0,this.m=this.v=null,this.X=-1,this.K=!1,this.P=0,this.O=null,this.W=this.L=this.U=this.R=!1,this.h=new So}function So(){this.i=null,this.g="",this.h=!1}var Co={},Ts={};function Ss(r,l,c){r.M=1,r.A=ci(Me(l)),r.u=c,r.R=!0,Ao(r,null)}function Ao(r,l){r.F=Date.now(),li(r),r.B=Me(r.A);var c=r.B,d=r.S;
19Array.isArray(d)||(d=[String(d)]),Vo(c.i,"t",d),r.C=0,c=r.j.L,r.h=new So,r.g=ia(r.j,c?l:null,!r.u),r.P>0&&(r.O=new cu(f(r.Y,r,r.g),r.P)),l=r.V,c=r.g,d=r.ba;var I="readystatechange";Array.isArray(I)||(I&&(_o[0]=I.toString()),I=_o);for(let C=0;C<I.length;C++){const A=ho(c,I[C],d||l.handleEvent,!1,l.h||l);if(!A)break;l.g[A.key]=A}l=r.J?ao(r.J):{},r.u?(r.v||(r.v="POST"),l["Content-Type"]="application/x-www-form-urlencoded",r.g.ea(r.B,r.v,r.u,l)):(r.v="GET",r.g.ea(r.B,r.v,null,l)),pn(),fu(r.i,r.v,r.B,r.l,r.S,r.u)}tt.prototype.ba=function(r){r=r.target;const l=this.O;l&&st(r)==3?l.j():this.Y(r)},tt.prototype.Y=function(r){try{if(r==this.g)e:{const D=st(this.g),ee=this.g.ya(),j=this.g.ca();if(!(D<3)&&(D!=3||this.g&&(this.h.h||this.g.la()||zo(this.g)))){this.K||D!=4||ee==7||(ee==8||j<=0?pn(3):pn(2)),Cs(this);var l=this.g.ca();this.X=l;var c=vu(this);if(this.o=l==200,pu(this.i,this.v,this.B,this.l,this.S,D,l),this.o){if(this.U&&!this.L){t:{if(this.g){var d,I=this.g;if((d=I.g?I.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!g(d)){var C=d;break t}}C=null}if(r=C)Wt(this.i,this.l,r,"Initial handshake response via X-HTTP-Initial-Response"),this.L=!0,As(this,r);else{this.o=!1,this.m=3,de(12),wt(this),yn(this);break e}}if(this.R){r=!0;let te;for(;!this.K&&this.C<c.length;)if(te=wu(this,c),te==Ts){D==4&&(this.m=4,de(14),r=!1),Wt(this.i,this.l,null,"[Incomplete Response]");break}else if(te==Co){this.m=4,de(15),Wt(this.i,this.l,c,"[Invalid Chunk]"),r=!1;break}else Wt(this.i,this.l,te,null),As(this,te);if(bo(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),D!=4||c.length!=0||this.h.h||(this.m=1,de(16),r=!1),this.o=this.o&&r,!r)Wt(this.i,this.l,c,"[Invalid Chunked Response]"),wt(this),yn(this);else if(c.length>0&&!this.W){this.W=!0;var A=this.j;A.g==this&&A.aa&&!A.P&&(A.j.info("Great, no buffering proxy detected. Bytes received: "+c.length),Ms(A),A.P=!0,de(11))}}else Wt(this.i,this.l,c,null),As(this,c);D==4&&wt(this),this.o&&!this.K&&(D==4?Zo(this.j,this):(this.o=!1,li(this)))}else Mu(this.g),l==400&&c.indexOf("Unknown SID")>0?(this.m=3,de(12)):(this.m=0,de(13)),wt(this),yn(this)}}}catch{}finally{}};function vu(r){if(!bo(r))return r.g.la();const l=zo(r.g);if(l==="")return"";let c="";const d=l.length,I=st(r.g)==4;if(!r.h.i){if(typeof TextDecoder>"u")return wt(r),yn(r),"";r.h.i=new a.TextDecoder}for(let C=0;C<d;C++)r.h.h=!0,c+=r.h.i.decode(l[C],{stream:!(I&&C==d-1)});return l.length=0,r.h.g+=c,r.C=0,r.h.g}function bo(r){return r.g?r.v=="GET"&&r.M!=2&&r.j.Aa:!1}function wu(r,l){var c=r.C,d=l.indexOf(` 20`,c);return d==-1?Ts:(c=Number(l.substring(c,d)),isNaN(c)?Co:(d+=1,d+c>l.length?Ts:(l=l.slice(d,d+c),r.C=d+c,l)))}tt.prototype.cancel=function(){this.K=!0,wt(this)};function li(r){r.T=Date.now()+r.H,Ro(r,r.H)}function Ro(r,l){if(r.D!=null)throw Error("WatchDog timer not null");r.D=gn(f(r.aa,r),l)}function Cs(r){r.D&&(a.clearTimeout(r.D),r.D=null)}tt.prototype.aa=function(){this.D=null;const r=Date.now();r-this.T>=0?(gu(this.i,this.B),this.M!=2&&(pn(),de(17)),wt(this),this.m=2,yn(this)):Ro(this,this.T-r)};function yn(r){r.j.I==0||r.K||Zo(r.j,r)}function wt(r){Cs(r);var l=r.O;l&&typeof l.dispose=="function"&&l.dispose(),r.O=null,mo(r.V),r.g&&(l=r.g,r.g=null,l.abort(),l.dispose())}function As(r,l){try{var c=r.j;if(c.I!=0&&(c.g==r||bs(c.h,r))){if(!r.L&&bs(c.h,r)&&c.I==3){try{var d=c.Ba.g.parse(l)}catch{d=null}if(Array.isArray(d)&&d.length==3){var I=d;if(I[0]==0){e:if(!c.v){if(c.g)if(c.g.F+3e3<r.F)pi(c),di(c);else break e;Ds(c),de(18)}}else c.xa=I[1],0<c.xa-c.K&&I[2]<37500&&c.F&&c.A==0&&!c.C&&(c.C=gn(f(c.Va,c),6e3));Po(c.h)<=1&&c.ta&&(c.ta=void 0)}else It(c,11)}else if((r.L||c.g==r)&&pi(c),!g(l))for(I=c.Ba.g.parse(l),l=0;l<I.length;l++){let j=I[l];const te=j[0];if(!(te<=c.K))if(c.K=te,j=j[1],c.I==2)if(j[0]=="c"){c.M=j[1],c.ba=j[2];const Le=j[3];Le!=null&&(c.ka=Le,c.j.info("VER="+c.ka));const Tt=j[4];Tt!=null&&(c.za=Tt,c.j.info("SVER="+c.za));const rt=j[5];rt!=null&&typeof rt=="number"&&rt>0&&(d=1.5*rt,c.O=d,c.j.info("backChannelRequestTimeoutMs_="+d)),d=c;const ot=r.g;if(ot){const gi=ot.g?ot.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(gi){var C=d.h;C.g||gi.indexOf("spdy")==-1&&gi.indexOf("quic")==-1&&gi.indexOf("h2")==-1||(C.j=C.l,C.g=new Set,C.h&&(Rs(C,C.h),C.h=null))}if(d.G){const Ls=ot.g?ot.g.getResponseHeader("X-HTTP-Session-Id"):null;Ls&&(d.wa=Ls,$(d.J,d.G,Ls))}}c.I=3,c.l&&c.l.ra(),c.aa&&(c.T=Date.now()-r.F,c.j.info("Handshake RTT: "+c.T+"ms")),d=c;var A=r;if(d.na=na(d,d.L?d.ba:null,d.W),A.L){Oo(d.h,A);var D=A,ee=d.O;ee&&(D.H=ee),D.D&&(Cs(D),li(D)),d.g=A}else Jo(d);c.i.length>0&&fi(c)}else j[0]!="stop"&&j[0]!="close"||It(c,7);else c.I==3&&(j[0]=="stop"||j[0]=="close"?j[0]=="stop"?It(c,7):Os(c):j[0]!="noop"&&c.l&&c.l.qa(j),c.A=0)}}pn(4)}catch{}}var Eu=class{constructor(r,l){this.g=r,this.map=l}};function ko(r){this.l=r||10,a.PerformanceNavigationTiming?(r=a.performance.getEntriesByType("navigation"),r=r.length>0&&(r[0].nextHopProtocol=="hq"||r[0].nextHopProtocol=="h2")):r=!!(a.chrome&&a.chrome.loadTimes&&a.chrome.loadTimes()&&a.chrome.loadTimes().wasFetchedViaSpdy),this.j=r?this.l:1,this.g=null,this.j>1&&(this.g=new Set),this.h=null,this.i=[]}function No(r){return r.h?!0:r.g?r.g.size>=r.j:!1}function Po(r){return r.h?1:r.g?r.g.size:0}function bs(r,l){return r.h?r.h==l:r.g?r.g.has(l):!1}function Rs(r,l){r.g?r.g.add(l):r.h=l}function Oo(r,l){r.h&&r.h==l?r.h=null:r.g&&r.g.has(l)&&r.g.delete(l)}ko.prototype.cancel=function(){if(this.i=Do(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const r of this.g.values())r.cancel();this.g.clear()}};function Do(r){if(r.h!=null)return r.i.concat(r.h.G);
20if(r.g!=null&&r.g.size!==0){let l=r.i;for(const c of r.g.values())l=l.concat(c.G);return l}return k(r.i)}var Mo=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function Iu(r,l){if(r){r=r.split("&");for(let c=0;c<r.length;c++){const d=r[c].indexOf("=");let I,C=null;d>=0?(I=r[c].substring(0,d),C=r[c].substring(d+1)):I=r[c],l(I,C?decodeURIComponent(C.replace(/\+/g," ")):"")}}}function nt(r){this.g=this.o=this.j="",this.u=null,this.m=this.h="",this.l=!1;let l;r instanceof nt?(this.l=r.l,vn(this,r.j),this.o=r.o,this.g=r.g,wn(this,r.u),this.h=r.h,ks(this,Bo(r.i)),this.m=r.m):r&&(l=String(r).match(Mo))?(this.l=!1,vn(this,l[1]||"",!0),this.o=En(l[2]||""),this.g=En(l[3]||"",!0),wn(this,l[4]),this.h=En(l[5]||"",!0),ks(this,l[6]||"",!0),this.m=En(l[7]||"")):(this.l=!1,this.i=new Tn(null,this.l))}nt.prototype.toString=function(){const r=[];var l=this.j;l&&r.push(In(l,Lo,!0),":");var c=this.g;return(c||l=="file")&&(r.push("//"),(l=this.o)&&r.push(In(l,Lo,!0),"@"),r.push(mn(c).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),c=this.u,c!=null&&r.push(":",String(c))),(c=this.h)&&(this.g&&c.charAt(0)!="/"&&r.push("/"),r.push(In(c,c.charAt(0)=="/"?Cu:Su,!0))),(c=this.i.toString())&&r.push("?",c),(c=this.m)&&r.push("#",In(c,bu)),r.join("")},nt.prototype.resolve=function(r){const l=Me(this);let c=!!r.j;c?vn(l,r.j):c=!!r.o,c?l.o=r.o:c=!!r.g,c?l.g=r.g:c=r.u!=null;var d=r.h;if(c)wn(l,r.u);else if(c=!!r.h){if(d.charAt(0)!="/")if(this.g&&!this.h)d="/"+d;else{var I=l.h.lastIndexOf("/");I!=-1&&(d=l.h.slice(0,I+1)+d)}if(I=d,I==".."||I==".")d="";else if(I.indexOf("./")!=-1||I.indexOf("/.")!=-1){d=I.lastIndexOf("/",0)==0,I=I.split("/");const C=[];for(let A=0;A<I.length;){const D=I[A++];D=="."?d&&A==I.length&&C.push(""):D==".."?((C.length>1||C.length==1&&C[0]!="")&&C.pop(),d&&A==I.length&&C.push("")):(C.push(D),d=!0)}d=C.join("/")}else d=I}return c?l.h=d:c=r.i.toString()!=="",c?ks(l,Bo(r.i)):c=!!r.m,c&&(l.m=r.m),l};function Me(r){return new nt(r)}function vn(r,l,c){r.j=c?En(l,!0):l,r.j&&(r.j=r.j.replace(/:$/,""))}function wn(r,l){if(l){if(l=Number(l),isNaN(l)||l<0)throw Error("Bad port number "+l);r.u=l}else r.u=null}function ks(r,l,c){l instanceof Tn?(r.i=l,Ru(r.i,r.l)):(c||(l=In(l,Au)),r.i=new Tn(l,r.l))}function $(r,l,c){r.i.set(l,c)}function ci(r){return $(r,"zx",Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^Date.now()).toString(36)),r}function En(r,l){return r?l?decodeURI(r.replace(/%25/g,"%2525")):decodeURIComponent(r):""}function In(r,l,c){return typeof r=="string"?(r=encodeURI(r).replace(l,Tu),c&&(r=r.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),r):null}function Tu(r){return r=r.charCodeAt(0),"%"+(r>>4&15).toString(16)+(r&15).toString(16)}var Lo=/[#\/\?@]/g,Su=/[#\?:]/g,Cu=/[#\?]/g,Au=/[#\?@]/g,bu=/#/g;function Tn(r,l){this.h=this.g=null,this.i=r||null,this.j=!!l}function Et(r){r.g||(r.g=new Map,r.h=0,r.i&&Iu(r.i,function(l,c){r.add(decodeURIComponent(l.replace(/\+/g," ")),c)}))}n=Tn.prototype,n.add=function(r,l){Et(this),this.i=null,r=Ht(this,r);let c=this.g.get(r);return c||this.g.set(r,c=[]),c.push(l),this.h+=1,this};function xo(r,l){Et(r),l=Ht(r,l),r.g.has(l)&&(r.i=null,r.h-=r.g.get(l).length,r.g.delete(l))}function Uo(r,l){return Et(r),l=Ht(r,l),r.g.has(l)}n.forEach=function(r,l){Et(this),this.g.forEach(function(c,d){c.forEach(function(I){r.call(l,I,d,this)},this)},this)};function Fo(r,l){Et(r);let c=[];if(typeof l=="string")Uo(r,l)&&(c=c.concat(r.g.get(Ht(r,l))));else for(r=Array.from(r.g.values()),l=0;l<r.length;l++)c=c.concat(r[l]);return c}n.set=function(r,l){return Et(this),this.i=null,r=Ht(this,r),Uo(this,r)&&(this.h-=this.g.get(r).length),this.g.set(r,[l]),this.h+=1,this},n.get=function(r,l){return r?(r=Fo(this,r),r.length>0?String(r[0]):l):l};function Vo(r,l,c){xo(r,l),c.length>0&&(r.i=null,r.g.set(Ht(r,l),k(c)),r.h+=c.length)}n.toString=function(){if(this.i)return this.i;if(!this.g)return"";const r=[],l=Array.from(this.g.keys());for(let d=0;d<l.length;d++){var c=l[d];const I=mn(c);c=Fo(this,c);for(let C=0;C<c.length;C++){let A=I;c[C]!==""&&(A+="="+mn(c[C])),r.push(A)}}return this.i=r.join("&")};function Bo(r){const l=new Tn;return l.i=r.i,r.g&&(l.g=new Map(r.g),l.h=r.h),l}function Ht(r,l){return l=String(l),r.j&&(l=l.toLowerCase()),l}function Ru(r,l){l&&!r.j&&(Et(r),r.i=null,r.g.forEach(function(c,d){const I=d.toLowerCase();d!=I&&(xo(this,d),Vo(this,I,c))},r)),r.j=l}function ku(r,l){const c=new _n;if(a.Image){const d=new Image;d.onload=E(it,c,"TestLoadImage: loaded",!0,l,d),d.onerror=E(it,c,"TestLoadImage: error",!1,l,d),d.onabort=E(it,c,"TestLoadImage: abort",!1,l,d),d.ontimeout=E(it,c,"TestLoadImage: timeout",!1,l,d),a.setTimeout(function(){d.ontimeout&&d.ontimeout()},1e4),d.src=r}else l(!1)}function Nu(r,l){const c=new _n,d=new AbortController,I=setTimeout(()=>{d.abort(),it(c,"TestPingServer: timeout",!1,l)},1e4);fetch(r,{signal:d.signal}).then(C=>{clearTimeout(I),C.ok?it(c,"TestPingServer: ok",!0,l):it(c,"TestPingServer: server error",!1,l)}
20).catch(()=>{clearTimeout(I),it(c,"TestPingServer: error",!1,l)})}function it(r,l,c,d,I){try{I&&(I.onload=null,I.onerror=null,I.onabort=null,I.ontimeout=null),d(c)}catch{}}function Pu(){this.g=new uu}function Ns(r){this.i=r.Sb||null,this.h=r.ab||!1}y(Ns,yo),Ns.prototype.g=function(){return new hi(this.i,this.h)};function hi(r,l){ae.call(this),this.H=r,this.o=l,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.A=new Headers,this.h=null,this.F="GET",this.D="",this.g=!1,this.B=this.j=this.l=null,this.v=new AbortController}y(hi,ae),n=hi.prototype,n.open=function(r,l){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.F=r,this.D=l,this.readyState=1,Cn(this)},n.send=function(r){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");if(this.v.signal.aborted)throw this.abort(),Error("Request was aborted.");this.g=!0;const l={headers:this.A,method:this.F,credentials:this.m,cache:void 0,signal:this.v.signal};r&&(l.body=r),(this.H||a).fetch(new Request(this.D,l)).then(this.Pa.bind(this),this.ga.bind(this))},n.abort=function(){this.response=this.responseText="",this.A=new Headers,this.status=0,this.v.abort(),this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),this.readyState>=1&&this.g&&this.readyState!=4&&(this.g=!1,Sn(this)),this.readyState=0},n.Pa=function(r){if(this.g&&(this.l=r,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=r.headers,this.readyState=2,Cn(this)),this.g&&(this.readyState=3,Cn(this),this.g)))if(this.responseType==="arraybuffer")r.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(typeof a.ReadableStream<"u"&&"body"in r){if(this.j=r.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.B=new TextDecoder;Wo(this)}else r.text().then(this.Oa.bind(this),this.ga.bind(this))};function Wo(r){r.j.read().then(r.Ma.bind(r)).catch(r.ga.bind(r))}n.Ma=function(r){if(this.g){if(this.o&&r.value)this.response.push(r.value);else if(!this.o){var l=r.value?r.value:new Uint8Array(0);(l=this.B.decode(l,{stream:!r.done}))&&(this.response=this.responseText+=l)}r.done?Sn(this):Cn(this),this.readyState==3&&Wo(this)}},n.Oa=function(r){this.g&&(this.response=this.responseText=r,Sn(this))},n.Na=function(r){this.g&&(this.response=r,Sn(this))},n.ga=function(){this.g&&Sn(this)};function Sn(r){r.readyState=4,r.l=null,r.j=null,r.B=null,Cn(r)}n.setRequestHeader=function(r,l){this.A.append(r,l)},n.getResponseHeader=function(r){return this.h&&this.h.get(r.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";const r=[],l=this.h.entries();for(var c=l.next();!c.done;)c=c.value,r.push(c[0]+": "+c[1]),c=l.next();return r.join(`\r 21`)};function Cn(r){r.onreadystatechange&&r.onreadystatechange.call(r)}Object.defineProperty(hi.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(r){this.m=r?"include":"same-origin"}});function Ho(r){let l="";return ri(r,function(c,d){l+=d,l+=":",l+=c,l+=`\r 22`}),l}function Ps(r,l,c){e:{for(d in c){var d=!1;break e}d=!0}d||(c=Ho(c),typeof r=="string"?c!=null&&mn(c):$(r,l,c))}function J(r){ae.call(this),this.headers=new Map,this.L=r||null,this.h=!1,this.g=null,this.D="",this.o=0,this.l="",this.j=this.B=this.v=this.A=!1,this.m=null,this.F="",this.H=!1}y(J,ae);var Ou=/^https?$/i,Du=["POST","PUT"];n=J.prototype,n.Fa=function(r){this.H=r},n.ea=function(r,l,c,d){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+r);l=l?l.toUpperCase():"GET",this.D=r,this.l="",this.o=0,this.A=!1,this.h=!0,this.g=this.L?this.L.g():To.g(),this.g.onreadystatechange=S(f(this.Ca,this));try{this.B=!0,this.g.open(l,String(r),!0),this.B=!1}catch(C){jo(this,C);return}if(r=c||"",c=new Map(this.headers),d)if(Object.getPrototypeOf(d)===Object.prototype)for(var I in d)c.set(I,d[I]);else if(typeof d.keys=="function"&&typeof d.get=="function")for(const C of d.keys())c.set(C,d.get(C));else throw Error("Unknown input type for opt_headers: "+String(d));d=Array.from(c.keys()).find(C=>C.toLowerCase()=="content-type"),I=a.FormData&&r instanceof a.FormData,!(Array.prototype.indexOf.call(Du,l,void 0)>=0)||d||I||c.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[C,A]of c)this.g.setRequestHeader(C,A);this.F&&(this.g.responseType=this.F),"withCredentials"in this.g&&this.g.withCredentials!==this.H&&(this.g.withCredentials=this.H);try{this.m&&(clearTimeout(this.m),this.m=null),this.v=!0,this.g.send(r),this.v=!1}catch(C){jo(this,C)}};function jo(r,l){r.h=!1,r.g&&(r.j=!0,r.g.abort(),r.j=!1),r.l=l,r.o=5,$o(r),ui(r)}function $o(r){r.A||(r.A=!0,ue(r,"complete"),ue(r,"error"))}n.abort=function(r){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.o=r||7,ue(this,"complete"),ue(this,"abort"),ui(this))},n.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),ui(this,!0)),J.Z.N.call(this)}
22,n.Ca=function(){this.u||(this.B||this.v||this.j?Go(this):this.Xa())},n.Xa=function(){Go(this)};function Go(r){if(r.h&&typeof o<"u"){if(r.v&&st(r)==4)setTimeout(r.Ca.bind(r),0);else if(ue(r,"readystatechange"),st(r)==4){r.h=!1;try{const C=r.ca();e:switch(C){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var l=!0;break e;default:l=!1}var c;if(!(c=l)){var d;if(d=C===0){let A=String(r.D).match(Mo)[1]||null;!A&&a.self&&a.self.location&&(A=a.self.location.protocol.slice(0,-1)),d=!Ou.test(A?A.toLowerCase():"")}c=d}if(c)ue(r,"complete"),ue(r,"success");else{r.o=6;try{var I=st(r)>2?r.g.statusText:""}catch{I=""}r.l=I+" ["+r.ca()+"]",$o(r)}}finally{ui(r)}}}}function ui(r,l){if(r.g){r.m&&(clearTimeout(r.m),r.m=null);const c=r.g;r.g=null,l||ue(r,"ready");try{c.onreadystatechange=null}catch{}}}n.isActive=function(){return!!this.g};function st(r){return r.g?r.g.readyState:0}n.ca=function(){try{return st(this)>2?this.g.status:-1}catch{return-1}},n.la=function(){try{return this.g?this.g.responseText:""}catch{return""}},n.La=function(r){if(this.g){var l=this.g.responseText;return r&&l.indexOf(r)==0&&(l=l.substring(r.length)),hu(l)}};function zo(r){try{if(!r.g)return null;if("response"in r.g)return r.g.response;switch(r.F){case"":case"text":return r.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in r.g)return r.g.mozResponseArrayBuffer}return null}catch{return null}}function Mu(r){const l={};r=(r.g&&st(r)>=2&&r.g.getAllResponseHeaders()||"").split(`\r 23`);for(let d=0;d<r.length;d++){if(g(r[d]))continue;var c=yu(r[d]);const I=c[0];if(c=c[1],typeof c!="string")continue;c=c.trim();const C=l[I]||[];l[I]=C,C.push(c)}su(l,function(d){return d.join(", ")})}n.ya=function(){return this.o},n.Ha=function(){return typeof this.l=="string"?this.l:String(this.l)};function An(r,l,c){return c&&c.internalChannelParams&&c.internalChannelParams[r]||l}function qo(r){this.za=0,this.i=[],this.j=new _n,this.ba=this.na=this.J=this.W=this.g=this.wa=this.G=this.H=this.u=this.U=this.o=null,this.Ya=this.V=0,this.Sa=An("failFast",!1,r),this.F=this.C=this.v=this.m=this.l=null,this.X=!0,this.xa=this.K=-1,this.Y=this.A=this.D=0,this.Qa=An("baseRetryDelayMs",5e3,r),this.Za=An("retryDelaySeedMs",1e4,r),this.Ta=An("forwardChannelMaxRetries",2,r),this.va=An("forwardChannelRequestTimeoutMs",2e4,r),this.ma=r&&r.xmlHttpFactory||void 0,this.Ua=r&&r.Rb||void 0,this.Aa=r&&r.useFetchStreams||!1,this.O=void 0,this.L=r&&r.supportsCrossDomainXhr||!1,this.M="",this.h=new ko(r&&r.concurrentRequestLimit),this.Ba=new Pu,this.S=r&&r.fastHandshake||!1,this.R=r&&r.encodeInitMessageHeaders||!1,this.S&&this.R&&(this.R=!1),this.Ra=r&&r.Pb||!1,r&&r.ua&&this.j.ua(),r&&r.forceLongPolling&&(this.X=!1),this.aa=!this.S&&this.X&&r&&r.detectBufferingProxy||!1,this.ia=void 0,r&&r.longPollingTimeout&&r.longPollingTimeout>0&&(this.ia=r.longPollingTimeout),this.ta=void 0,this.T=0,this.P=!1,this.ja=this.B=null}n=qo.prototype,n.ka=8,n.I=1,n.connect=function(r,l,c,d){de(0),this.W=r,this.H=l||{},c&&d!==void 0&&(this.H.OSID=c,this.H.OAID=d),this.F=this.X,this.J=na(this,null,this.W),fi(this)};function Os(r){if(Ko(r),r.I==3){var l=r.V++,c=Me(r.J);if($(c,"SID",r.M),$(c,"RID",l),$(c,"TYPE","terminate"),bn(r,c),l=new tt(r,r.j,l),l.M=2,l.A=ci(Me(c)),c=!1,a.navigator&&a.navigator.sendBeacon)try{c=a.navigator.sendBeacon(l.A.toString(),"")}catch{}!c&&a.Image&&(new Image().src=l.A,c=!0),c||(l.g=ia(l.j,null),l.g.ea(l.A)),l.F=Date.now(),li(l)}ta(r)}function di(r){r.g&&(Ms(r),r.g.cancel(),r.g=null)}function Ko(r){di(r),r.v&&(a.clearTimeout(r.v),r.v=null),pi(r),r.h.cancel(),r.m&&(typeof r.m=="number"&&a.clearTimeout(r.m),r.m=null)}function fi(r){if(!No(r.h)&&!r.m){r.m=!0;var l=r.Ea;_e||p(),oe||(_e(),oe=!0),v.add(l,r),r.D=0}}function Lu(r,l){return Po(r.h)>=r.h.j-(r.m?1:0)?!1:r.m?(r.i=l.G.concat(r.i),!0):r.I==1||r.I==2||r.D>=(r.Sa?0:r.Ta)?!1:(r.m=gn(f(r.Ea,r,l),ea(r,r.D)),r.D++,!0)}n.Ea=function(r){if(this.m)if(this.m=null,this.I==1){if(!r){this.V=Math.floor(Math.random()*1e5),r=this.V++;const I=new tt(this,this.j,r);let C=this.o;if(this.U&&(C?(C=ao(C),co(C,this.U)):C=this.U),this.u!==null||this.R||(I.J=C,C=null),this.S)e:{for(var l=0,c=0;c<this.i.length;c++){t:{var d=this.i[c];
23if("__data__"in d.map&&(d=d.map.__data__,typeof d=="string")){d=d.length;break t}d=void 0}if(d===void 0)break;if(l+=d,l>4096){l=c;break e}if(l===4096||c===this.i.length-1){l=c+1;break e}}l=1e3}else l=1e3;l=Xo(this,I,l),c=Me(this.J),$(c,"RID",r),$(c,"CVER",22),this.G&&$(c,"X-HTTP-Session-Id",this.G),bn(this,c),C&&(this.R?l="headers="+mn(Ho(C))+"&"+l:this.u&&Ps(c,this.u,C)),Rs(this.h,I),this.Ra&&$(c,"TYPE","init"),this.S?($(c,"$req",l),$(c,"SID","null"),I.U=!0,Ss(I,c,null)):Ss(I,c,l),this.I=2}}else this.I==3&&(r?Yo(this,r):this.i.length==0||No(this.h)||Yo(this))};function Yo(r,l){var c;l?c=l.l:c=r.V++;const d=Me(r.J);$(d,"SID",r.M),$(d,"RID",c),$(d,"AID",r.K),bn(r,d),r.u&&r.o&&Ps(d,r.u,r.o),c=new tt(r,r.j,c,r.D+1),r.u===null&&(c.J=r.o),l&&(r.i=l.G.concat(r.i)),l=Xo(r,c,1e3),c.H=Math.round(r.va*.5)+Math.round(r.va*.5*Math.random()),Rs(r.h,c),Ss(c,d,l)}function bn(r,l){r.H&&ri(r.H,function(c,d){$(l,d,c)}),r.l&&ri({},function(c,d){$(l,d,c)})}function Xo(r,l,c){c=Math.min(r.i.length,c);const d=r.l?f(r.l.Ka,r.l,r):null;e:{var I=r.i;let D=-1;for(;;){const ee=["count="+c];D==-1?c>0?(D=I[0].g,ee.push("ofs="+D)):D=0:ee.push("ofs="+D);let j=!0;for(let te=0;te<c;te++){var C=I[te].g;const Le=I[te].map;if(C-=D,C<0)D=Math.max(0,I[te].g-100),j=!1;else try{C="req"+C+"_"||"";try{var A=Le instanceof Map?Le:Object.entries(Le);for(const[Tt,rt]of A){let ot=rt;h(rt)&&(ot=ms(rt)),ee.push(C+Tt+"="+encodeURIComponent(ot))}}catch(Tt){throw ee.push(C+"type="+encodeURIComponent("_badmap")),Tt}}catch{d&&d(Le)}}if(j){A=ee.join("&");break e}}A=void 0}return r=r.i.splice(0,c),l.G=r,A}function Jo(r){if(!r.g&&!r.v){r.Y=1;var l=r.Da;_e||p(),oe||(_e(),oe=!0),v.add(l,r),r.A=0}}function Ds(r){return r.g||r.v||r.A>=3?!1:(r.Y++,r.v=gn(f(r.Da,r),ea(r,r.A)),r.A++,!0)}n.Da=function(){if(this.v=null,Qo(this),this.aa&&!(this.P||this.g==null||this.T<=0)){var r=4*this.T;this.j.info("BP detection timer enabled: "+r),this.B=gn(f(this.Wa,this),r)}},n.Wa=function(){this.B&&(this.B=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.P=!0,de(10),di(this),Qo(this))};function Ms(r){r.B!=null&&(a.clearTimeout(r.B),r.B=null)}function Qo(r){r.g=new tt(r,r.j,"rpc",r.Y),r.u===null&&(r.g.J=r.o),r.g.P=0;var l=Me(r.na);$(l,"RID","rpc"),$(l,"SID",r.M),$(l,"AID",r.K),$(l,"CI",r.F?"0":"1"),!r.F&&r.ia&&$(l,"TO",r.ia),$(l,"TYPE","xmlhttp"),bn(r,l),r.u&&r.o&&Ps(l,r.u,r.o),r.O&&(r.g.H=r.O);var c=r.g;r=r.ba,c.M=1,c.A=ci(Me(l)),c.u=null,c.R=!0,Ao(c,r)}n.Va=function(){this.C!=null&&(this.C=null,di(this),Ds(this),de(19))};function pi(r){r.C!=null&&(a.clearTimeout(r.C),r.C=null)}function Zo(r,l){var c=null;if(r.g==l){pi(r),Ms(r),r.g=null;var d=2}else if(bs(r.h,l))c=l.G,Oo(r.h,l),d=1;else return;if(r.I!=0){if(l.o)if(d==1){c=l.u?l.u.length:0,l=Date.now()-l.F;var I=r.D;d=ws(),ue(d,new Io(d,c)),fi(r)}else Jo(r);else if(I=l.m,I==3||I==0&&l.X>0||!(d==1&&Lu(r,l)||d==2&&Ds(r)))switch(c&&c.length>0&&(l=r.h,l.i=l.i.concat(c)),I){case 1:It(r,5);break;case 4:It(r,10);break;case 3:It(r,6);break;default:It(r,2)}}}function ea(r,l){let c=r.Qa+Math.floor(Math.random()*r.Za);return r.isActive()||(c*=2),c*l}function It(r,l){if(r.j.info("Error code "+l),l==2){var c=f(r.bb,r),d=r.Ua;const I=!d;d=new nt(d||"//www.google.com/images/cleardot.gif"),a.location&&a.location.protocol=="http"||vn(d,"https"),ci(d),I?ku(d.toString(),c):Nu(d.toString(),c)}else de(2);r.I=0,r.l&&r.l.pa(l),ta(r),Ko(r)}n.bb=function(r){r?(this.j.info("Successfully pinged google.com"),de(2)):(this.j.info("Failed to ping google.com"),de(1))};function ta(r){if(r.I=0,r.ja=[],r.l){const l=Do(r.h);(l.length!=0||r.i.length!=0)&&(R(r.ja,l),R(r.ja,r.i),r.h.i.length=0,k(r.i),r.i.length=0),r.l.oa()}}function na(r,l,c){var d=c instanceof nt?Me(c):new nt(c);if(d.g!="")l&&(d.g=l+"."+d.g),wn(d,d.u);else{var I=a.location;d=I.protocol,l=l?l+"."+I.hostname:I.hostname,I=+I.port;const C=new nt(null);d&&vn(C,d),l&&(C.g=l),I&&wn(C,I),c&&(C.h=c),d=C}return c=r.G,l=r.wa,c&&l&&$(d,c,l),$(d,"VER",r.ka),bn(r,d),d}function ia(r,l,c){if(l&&!r.L)throw Error("Can't create secondary domain capable XhrIo object.");return l=r.Aa&&!r.ma?new J(new Ns({ab:c})):new J(r.ma),l.Fa(r.L),l}n.isActive=function(){return!!this.l&&this.l.isActive(this)};function sa(){}n=sa.prototype,n.ra=function(){},n.qa=function(){},n.pa=function(){},n.oa=function(){},n.isActive=function(){return!0},n.Ka=function(){};function Ee(r,l){ae.call(this),this.g=new qo(l),this.l=r,this.h=l&&l.messageUrlParams||null,r=l&&l.messageHeaders||null,l&&l.clientProtocolHeaderRequired&&(r?r["X-Client-Protocol"]="webchannel":r={"X-Client-Protocol":"webchannel"}),this.g.o=r,r=l&&l.initMessageHeaders||null,l&&l.messageContentType&&(r?r["X-WebChannel-Content-Type"]=l.messageContentType:r={"X-WebChannel-Content-Type":l.messageContentType}),l&&l.sa&&(r?r["X-WebChannel-Client-Profile"]=l.sa:r={"X-WebChannel-Client-Profile":l.sa}),this.g.U=r,(r=l&&l.Qb)&&!g(r)&&(this.g.u=r),this.A=l&&l.supportsCrossDomainXhr||!1,this.v=l&&l.sendRawJson||!1,(l=l&&l.httpSessionIdParam)&&!g(l)&&(this.g.G=l,r=this.h,r!==null&&l in r&&(r=this.h,l in r&&delete r[l])),this.j=new jt(this)}y(Ee,ae),Ee.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},Ee.prototype.close=function(){Os(this.g)},Ee.prototype.o=function(r){var l=this.g;if(typeof r=="string"){var c={};c.__data__=r,r=c}else this.v&&(c={},c.__data__=ms(r),r=c);l.i.push(new Eu(l.Ya++,r)),l.I==3&&fi(l)},Ee.prototype.N=function(){this.g.l=null,delete this.j,Os(this.g),delete this.g,Ee.Z.N.call(this)};function ra(r){ys.call(this),r.__headers__&&(this.headers=r.__headers__,this.statusCode=r.__status__,delete r.__headers__,delete r.__status__);var l=r.__sm__;if(l){e:{for(const c in l){r=c;break e}r=void 0}(this.i=r)&&(r=this.i,l=l!==null&&r in l?l[r]:void 0),this.data=l}else this.data=r}y(ra,ys);function oa(){vs.call(this),this.status=1}y(oa,vs);function jt(r){this.g=r}y(jt,sa),jt.prototype.ra=function(){ue(this.g,"a")},jt.prototype.qa=function(r){ue(this.g,new ra(r))},jt.prototype.pa=function(r){ue(this.g,new oa)},jt.prototype.oa=function(){ue(this.g,"b")},Ee.prototype.send=Ee.prototype.o,Ee.prototype.open=Ee.prototype.m,Ee.prototype.close=Ee.prototype.close,Es.NO_ERROR=0,Es.TIMEOUT=8,Es.HTTP_ERROR=6,mu.COMPLETE="complete",du.EventType=fn,fn.OPEN="a",fn.CLOSE="b",fn.ERROR="c",fn.MESSAGE="d",ae.prototype.listen=ae.prototype.J,J.prototype.listenOnce=J.prototype.K,J.prototype.getLastError=J.prototype.Ha,J.prototype.getLastErrorCode=J.prototype.ya,J.prototype.getStatus=J.prototype.ca,J.prototype.getResponseJson=J.prototype.La,J.prototype.getResponseText=J.prototype.la,J.prototype.send=J.prototype.ea,J.prototype.setWithCredentials=J.prototype.Fa}).apply(typeof _i<"u"?_i:typeof self<"u"?self:typeof window<"u"?window:{});const va="@firebase/firestore",wa="4.9.2";class me{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}me.UNAUTHENTICATED=new me(null),me.GOOGLE_CREDENTIALS=new me("google-credentials-uid"),me.FIRST_PARTY=new me("first-party-uid"),me.MOCK_USER=new me("mock-user");let es="12.3.0";const Pi=new Kn("@firebase/firestore");function Ae(n,...e){if(Pi.logLevel<=B.DEBUG){const t=e.map(oc);Pi.debug(`Firestore (${es}): ${n}`,...t)}}function rc(n,...e){if(Pi.logLevel<=B.ERROR){const t=e.map(oc);Pi.error(`Firestore (${es}): ${n}`,...t)}}function oc(n){if(typeof n=="string")return n;try{return(function(t){return JSON.stringify(t)})(n)}catch{return n}}function Oi(n,e,t){let i="Unexpected state";
23typeof e=="string"?i=e:t=e,ac(n,i,t)}function ac(n,e,t){let i=`FIRESTORE (${es}) INTERNAL ASSERTION FAILED: ${e} (ID: ${n.toString(16)})`;if(t!==void 0)try{i+=" CONTEXT: "+JSON.stringify(t)}catch{i+=" CONTEXT: "+t}throw rc(i),new Error(i)}function Mn(n,e,t,i){let s="Unexpected state";typeof t=="string"?s=t:i=t,n||ac(e,s,i)}const F={CANCELLED:"cancelled",INVALID_ARGUMENT:"invalid-argument",FAILED_PRECONDITION:"failed-precondition"};class V extends $e{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class Ln{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class Tf{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class Sf{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(me.UNAUTHENTICATED)))}shutdown(){}}class Cf{constructor(e){this.t=e,this.currentUser=me.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){Mn(this.o===void 0,42304);let i=this.i;const s=u=>this.i!==i?(i=this.i,t(u)):Promise.resolve();let o=new Ln;this.o=()=>{this.i++,this.currentUser=this.u(),o.resolve(),o=new Ln,e.enqueueRetryable((()=>s(this.currentUser)))};const a=()=>{const u=o;e.enqueueRetryable((async()=>{await u.promise,await s(this.currentUser)}))},h=u=>{Ae("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=u,this.o&&(this.auth.addAuthTokenListener(this.o),a())};this.t.onInit((u=>h(u))),setTimeout((()=>{if(!this.auth){const u=this.t.getImmediate({optional:!0});u?h(u):(Ae("FirebaseAuthCredentialsProvider","Auth not yet detected"),o.resolve(),o=new Ln)}}),0),a()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then((i=>this.i!==e?(Ae("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):i?(Mn(typeof i.accessToken=="string",31837,{l:i}),new Tf(i.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 Mn(e===null||typeof e=="string",2055,{h:e}),new me(e)}}class Af{constructor(e,t,i){this.P=e,this.T=t,this.I=i,this.type="FirstParty",this.user=me.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 bf{constructor(e,t,i){this.P=e,this.T=t,this.I=i}getToken(){return Promise.resolve(new Af(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable((()=>t(me.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class Ea{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 Rf{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,ye(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){Mn(this.o===void 0,3512);const i=o=>{o.error!=null&&Ae("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${o.error.message}`);const a=o.token!==this.m;return this.m=o.token,Ae("FirebaseAppCheckTokenProvider",`Received ${a?"new":"existing"} token.`),a?t(o.token):Promise.resolve()};this.o=o=>{e.enqueueRetryable((()=>i(o)))};const s=o=>{Ae("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=o,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit((o=>s(o))),setTimeout((()=>{if(!this.appCheck){const o=this.V.getImmediate({optional:!0});o?s(o):Ae("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){if(this.p)return Promise.resolve(new Ea(this.p));const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((t=>t?(Mn(typeof t.token=="string",44558,{tokenResult:t}),this.m=t.token,new Ea(t.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}function kf(n){const e=typeof self<"u"&&(self.crypto||self.msCrypto),t=new Uint8Array(n);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let i=0;i<n;
23i++)t[i]=Math.floor(256*Math.random());return t}class Nf{static newId(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=62*Math.floor(4.129032258064516);let i="";for(;i.length<20;){const s=kf(40);for(let o=0;o<s.length;++o)i.length<20&&s[o]<t&&(i+=e.charAt(s[o]%62))}return i}}function _t(n,e){return n<e?-1:n>e?1:0}function Pf(n,e){const t=Math.min(n.length,e.length);for(let i=0;i<t;i++){const s=n.charAt(i),o=e.charAt(i);if(s!==o)return Ws(s)===Ws(o)?_t(s,o):Ws(s)?1:-1}return _t(n.length,e.length)}const Of=55296,Df=57343;function Ws(n){const e=n.charCodeAt(0);return e>=Of&&e<=Df}const Ia="__name__";class xe{constructor(e,t,i){t===void 0?t=0:t>e.length&&Oi(637,{offset:t,range:e.length}),i===void 0?i=e.length-t:i>e.length-t&&Oi(1746,{length:i,range:e.length-t}),this.segments=e,this.offset=t,this.len=i}get length(){return this.len}isEqual(e){return xe.comparator(this,e)===0}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof xe?e.forEach((i=>{t.push(i)})):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,i=this.limit();t<i;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const i=Math.min(e.length,t.length);for(let s=0;s<i;s++){const o=xe.compareSegments(e.get(s),t.get(s));if(o!==0)return o}return _t(e.length,t.length)}static compareSegments(e,t){const i=xe.isNumericId(e),s=xe.isNumericId(t);return i&&!s?-1:!i&&s?1:i&&s?xe.extractNumericId(e).compare(xe.extractNumericId(t)):Pf(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return Ar.fromString(e.substring(4,e.length-2))}}class Se extends xe{construct(e,t,i){return new Se(e,t,i)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const i of e){if(i.indexOf("//")>=0)throw new V(F.INVALID_ARGUMENT,`Invalid segment (${i}). Paths must not contain // in them.`);t.push(...i.split("/").filter((s=>s.length>0)))}return new Se(t)}static emptyPath(){return new Se([])}}const Mf=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class At extends xe{construct(e,t,i){return new At(e,t,i)}static isValidIdentifier(e){return Mf.test(e)}canonicalString(){return this.toArray().map((e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),At.isValidIdentifier(e)||(e="`"+e+"`"),e))).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===Ia}static keyField(){return new At([Ia])}static fromServerFormat(e){const t=[];let i="",s=0;const o=()=>{if(i.length===0)throw new V(F.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(i),i=""};let a=!1;for(;s<e.length;){const h=e[s];if(h==="\\"){if(s+1===e.length)throw new V(F.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const u=e[s+1];if(u!=="\\"&&u!=="."&&u!=="`")throw new V(F.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);i+=u,s+=2}else h==="`"?(a=!a,s++):h!=="."||a?(i+=h,s++):(o(),s++)}if(o(),a)throw new V(F.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new At(t)}static emptyPath(){return new At([])}}class bt{constructor(e){this.path=e}static fromPath(e){return new bt(Se.fromString(e))}static fromName(e){return new bt(Se.fromString(e).popFirst(5))}static empty(){return new bt(Se.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&Se.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return Se.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new bt(new Se(e.slice()))}}function Lf(n,e,t,i){if(e===!0&&i===!0)throw new V(F.INVALID_ARGUMENT,`${n} and ${t} cannot be used together.`)}function xf(n){return typeof n=="object"&&n!==null&&(Object.getPrototypeOf(n)===Object.prototype||Ob
23ject.getPrototypeOf(n)===null)}function Z(n,e){const t={typeString:n};return e&&(t.value=e),t}function Yn(n,e){if(!xf(n))throw new V(F.INVALID_ARGUMENT,"JSON must be an object");let t;for(const i in e)if(e[i]){const s=e[i].typeString,o="value"in e[i]?{value:e[i].value}:void 0;if(!(i in n)){t=`JSON missing required field: '${i}'`;break}const a=n[i];if(s&&typeof a!==s){t=`JSON field '${i}' must be a ${s}.`;break}if(o!==void 0&&a!==o.value){t=`Expected '${i}' field to equal '${o.value}'`;break}}if(t)throw new V(F.INVALID_ARGUMENT,t);return!0}const Ta=-62135596800,Sa=1e6;class Ue{static now(){return Ue.fromMillis(Date.now())}static fromDate(e){return Ue.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),i=Math.floor((e-1e3*t)*Sa);return new Ue(t,i)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new V(F.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new V(F.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<Ta)throw new V(F.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new V(F.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/Sa}_compareTo(e){return this.seconds===e.seconds?_t(this.nanoseconds,e.nanoseconds):_t(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:Ue._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(Yn(e,Ue._jsonSchema))return new Ue(e.seconds,e.nanoseconds)}valueOf(){const e=this.seconds-Ta;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}Ue._jsonSchemaVersion="firestore/timestamp/1.0",Ue._jsonSchema={type:Z("string",Ue._jsonSchemaVersion),seconds:Z("number"),nanoseconds:Z("number")};function Uf(n){return n.name==="IndexedDbTransactionError"}class Ff extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class Ot{constructor(e){this.binaryString=e}static fromBase64String(e){const t=(function(s){try{return atob(s)}catch(o){throw typeof DOMException<"u"&&o instanceof DOMException?new Ff("Invalid base64 string: "+o):o}})(e);return new Ot(t)}static fromUint8Array(e){const t=(function(s){let o="";for(let a=0;a<s.length;++a)o+=String.fromCharCode(s[a]);return o})(e);return new Ot(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(function(t){return btoa(t)})(this.binaryString)}toUint8Array(){return(function(t){const i=new Uint8Array(t.length);for(let s=0;s<t.length;s++)i[s]=t.charCodeAt(s);return i})(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return _t(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}Ot.EMPTY_BYTE_STRING=new Ot("");const Ca="(default)";class Di{constructor(e,t){this.projectId=e,this.database=t||Ca}static empty(){return new Di("","")}get isDefaultDatabase(){return this.database===Ca}isEqual(e){return e instanceof Di&&e.projectId===this.projectId&&e.database===this.database}}class Vf{constructor(e,t=null,i=[],s=[],o=null,a="F",h=null,u=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=i,this.filters=s,this.limit=o,this.limitType=a,this.startAt=h,this.endAt=u,this.Ie=null,this.Ee=null,this.de=null,this.startAt,this.endAt}}function Bf(n){return new Vf(n)}var Aa,L;(L=Aa||(Aa={}))[L.OK=0]="OK",L[L.CANCELLED=1]="CANCELLED",L[L.UNKNOWN=2]="UNKNOWN",L[L.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",L[L.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",L[L.NOT_FOUND=5]="NOT_FOUND",L[L.ALREADY_EXISTS=6]="ALREADY_EXISTS",L[L.PERMISSION_DENIED=7]="PERMISSION_DENIED",L[L.UNAUTHENTICATED=16]="UNAUTHENTICATED",L[L.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",L[L.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",L[L.ABORTED=10]="ABORTED",L[L.OUT_OF_RANGE=11]="OUT_OF_RANGE",L[L.UNIMPLEMENT
23ED=12]="UNIMPLEMENTED",L[L.INTERNAL=13]="INTERNAL",L[L.UNAVAILABLE=14]="UNAVAILABLE",L[L.DATA_LOSS=15]="DATA_LOSS";new Ar([4294967295,4294967295],0);const Wf=41943040;const Hf=1048576;function Hs(){return typeof document<"u"?document:null}class jf{constructor(e,t,i=1e3,s=1.5,o=6e4){this.Mi=e,this.timerId=t,this.d_=i,this.A_=s,this.R_=o,this.V_=0,this.m_=null,this.f_=Date.now(),this.reset()}reset(){this.V_=0}g_(){this.V_=this.R_}p_(e){this.cancel();const t=Math.floor(this.V_+this.y_()),i=Math.max(0,Date.now()-this.f_),s=Math.max(0,t-i);s>0&&Ae("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.V_} ms, delay with jitter: ${t} ms, last attempt: ${i} ms ago)`),this.m_=this.Mi.enqueueAfterDelay(this.timerId,s,(()=>(this.f_=Date.now(),e()))),this.V_*=this.A_,this.V_<this.d_&&(this.V_=this.d_),this.V_>this.R_&&(this.V_=this.R_)}w_(){this.m_!==null&&(this.m_.skipDelay(),this.m_=null)}cancel(){this.m_!==null&&(this.m_.cancel(),this.m_=null)}y_(){return(Math.random()-.5)*this.V_}}class br{constructor(e,t,i,s,o){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=i,this.op=s,this.removalCallback=o,this.deferred=new Ln,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((a=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(e,t,i,s,o){const a=Date.now()+i,h=new br(e,t,a,s,o);return h.start(i),h}start(e){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new V(F.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then((e=>this.deferred.resolve(e)))):Promise.resolve()))}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}var ba,Ra;(Ra=ba||(ba={})).Ma="default",Ra.Cache="cache";function $f(n){const e={};return n.timeoutSeconds!==void 0&&(e.timeoutSeconds=n.timeoutSeconds),e}const ka=new Map;const Gf="firestore.googleapis.com",Na=!0;class Pa{constructor(e){if(e.host===void 0){if(e.ssl!==void 0)throw new V(F.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=Gf,this.ssl=Na}else this.host=e.host,this.ssl=e.ssl??Na;if(this.isUsingEmulator=e.emulatorOptions!==void 0,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=Wf;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<Hf)throw new V(F.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}Lf("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=$f(e.experimentalLongPollingOptions??{}),(function(i){if(i.timeoutSeconds!==void 0){if(isNaN(i.timeoutSeconds))throw new V(F.INVALID_ARGUMENT,`invalid long polling timeout: ${i.timeoutSeconds} (must not be NaN)`);if(i.timeoutSeconds<5)throw new V(F.INVALID_ARGUMENT,`invalid long polling timeout: ${i.timeoutSeconds} (minimum allowed value is 5)`);if(i.timeoutSeconds>30)throw new V(F.INVALID_ARGUMENT,`invalid long polling timeout: ${i.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(i,s){return i.timeoutSeconds===s.timeoutSeconds})(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class zf{constructor(e,t,i,s){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=i,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Pa({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new V(F.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!=="notTerminated"}_setSettings(e){if(this._settingsFrozen)throw new V(F.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 Pa(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=(function(i){if(!i)return new Sf;switch(i.type){case"firstParty":return new bf(i.sessionIndex||"0",i.iamToken||null,i.authTokenFactory||null);case"provider":return i.client;default:throw new V(F.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invali
23d credential type")}})(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return(function(t){const i=ka.get(t);i&&(Ae("ComponentProvider","Removing Datastore"),ka.delete(t),i.terminate())})(this),Promise.resolve()}}class Rr{constructor(e,t,i){this.converter=t,this._query=i,this.type="query",this.firestore=e}withConverter(e){return new Rr(this.firestore,e,this._query)}}class Fe{constructor(e,t,i){this.converter=t,this._key=i,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 kr(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new Fe(this.firestore,e,this._key)}toJSON(){return{type:Fe._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,i){if(Yn(t,Fe._jsonSchema))return new Fe(e,i||null,new bt(Se.fromString(t.referencePath)))}}Fe._jsonSchemaVersion="firestore/documentReference/1.0",Fe._jsonSchema={type:Z("string",Fe._jsonSchemaVersion),referencePath:Z("string")};class kr extends Rr{constructor(e,t,i){super(e,t,Bf(i)),this._path=i,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 Fe(this.firestore,null,new bt(e))}withConverter(e){return new kr(this.firestore,e,this._path)}}const Oa="AsyncQueue";class Da{constructor(e=Promise.resolve()){this.Xu=[],this.ec=!1,this.tc=[],this.nc=null,this.rc=!1,this.sc=!1,this.oc=[],this.M_=new jf(this,"async_queue_retry"),this._c=()=>{const i=Hs();i&&Ae(Oa,"Visibility state changed to "+i.visibilityState),this.M_.w_()},this.ac=e;const t=Hs();t&&typeof t.addEventListener=="function"&&t.addEventListener("visibilitychange",this._c)}get isShuttingDown(){return this.ec}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.uc(),this.cc(e)}enterRestrictedMode(e){if(!this.ec){this.ec=!0,this.sc=e||!1;const t=Hs();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this._c)}}enqueue(e){if(this.uc(),this.ec)return new Promise((()=>{}));const t=new Ln;return this.cc((()=>this.ec&&this.sc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise))).then((()=>t.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.Xu.push(e),this.lc())))}async lc(){if(this.Xu.length!==0){try{await this.Xu[0](),this.Xu.shift(),this.M_.reset()}catch(e){if(!Uf(e))throw e;Ae(Oa,"Operation failed with retryable error: "+e)}this.Xu.length>0&&this.M_.p_((()=>this.lc()))}}cc(e){const t=this.ac.then((()=>(this.rc=!0,e().catch((i=>{throw this.nc=i,this.rc=!1,rc("INTERNAL UNHANDLED ERROR: ",Ma(i)),i})).then((i=>(this.rc=!1,i))))));return this.ac=t,t}enqueueAfterDelay(e,t,i){this.uc(),this.oc.indexOf(e)>-1&&(t=0);const s=br.createAndSchedule(this,e,t,i,(o=>this.hc(o)));return this.tc.push(s),s}uc(){this.nc&&Oi(47125,{Pc:Ma(this.nc)})}verifyOperationInProgress(){}async Tc(){let e;do e=this.ac,await e;while(e!==this.ac)}Ic(e){for(const t of this.tc)if(t.timerId===e)return!0;return!1}Ec(e){return this.Tc().then((()=>{this.tc.sort(((t,i)=>t.targetTimeMs-i.targetTimeMs));for(const t of this.tc)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.Tc()}))}dc(e){this.oc.push(e)}hc(e){const t=this.tc.indexOf(e);this.tc.splice(t,1)}}function Ma(n){let e=n.message||"";return n.stack&&(e=n.stack.includes(n.message)?n.stack:n.message+` 24`+n.stack),e}class qf extends zf{constructor(e,t,i,s){super(e,t,i,s),this.type="firestore",this._queue=new Da,this._persistenceKey=s?.name||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new Da(e),this._firestoreClient=void 0,await e}}}class qe{constructor(e){this._byteString=e}static fromBase64String(e){try{return new qe(Ot.fromBase64String(e))}catch(t){throw new V(F.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new qe(Ot.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:qe._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(Yn(e,qe._jsonSchema))return qe.fromBase64String(e.bytes)}}
24qe._jsonSchemaVersion="firestore/bytes/1.0",qe._jsonSchema={type:Z("string",qe._jsonSchemaVersion),bytes:Z("string")};class lc{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new V(F.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new At(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}class kt{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new V(F.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new V(F.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}_compareTo(e){return _t(this._lat,e._lat)||_t(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:kt._jsonSchemaVersion}}static fromJSON(e){if(Yn(e,kt._jsonSchema))return new kt(e.latitude,e.longitude)}}kt._jsonSchemaVersion="firestore/geoPoint/1.0",kt._jsonSchema={type:Z("string",kt._jsonSchemaVersion),latitude:Z("number"),longitude:Z("number")};class Nt{constructor(e){this._values=(e||[]).map((t=>t))}toArray(){return this._values.map((e=>e))}isEqual(e){return(function(i,s){if(i.length!==s.length)return!1;for(let o=0;o<i.length;++o)if(i[o]!==s[o])return!1;return!0})(this._values,e._values)}toJSON(){return{type:Nt._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(Yn(e,Nt._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every((t=>typeof t=="number")))return new Nt(e.vectorValues);throw new V(F.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}Nt._jsonSchemaVersion="firestore/vectorValue/1.0",Nt._jsonSchema={type:Z("string",Nt._jsonSchemaVersion),vectorValues:Z("object")};const Kf=new RegExp("[~\\*/\\[\\]]");function Yf(n,e,t){if(e.search(Kf)>=0)throw La(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,n);try{return new lc(...e.split("."))._internalPath}catch{throw La(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,n)}}function La(n,e,t,i,s){let o=`Function ${e}() called with invalid data`;o+=". ";let a="";return new V(F.INVALID_ARGUMENT,o+n+a)}class cc{constructor(e,t,i,s,o){this._firestore=e,this._userDataWriter=t,this._key=i,this._document=s,this._converter=o}get id(){return this._key.path.lastSegment()}get ref(){return new Fe(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new Xf(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(hc("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}}class Xf extends cc{data(){return super.data()}}function hc(n,e){return typeof e=="string"?Yf(n,e):e instanceof lc?e._internalPath:e._delegate._internalPath}class mi{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class qt extends cc{constructor(e,t,i,s,o,a){super(e,t,i,s,a),this._firestore=e,this._firestoreImpl=e,this.metadata=o}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new Ti(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 i=this._document.data.field(hc("DocumentSnapshot.get",e));if(i!==null)return this._userDataWriter.convertValue(i,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new V(F.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=qt._jsonSchemaVersion,t.bundle="",t.bundleSource="DocumentSnapshot",t.bundleName=this._key.toString(),!e||!e.isValidDocument()||!e.isFoundDocument()?t:(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),t.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),t)}}qt._jsonSchemaVersion="firestore/documentSnapshot/1.0",qt._jsonSchema={type:Z("string",qt._jsonSchemaVersion),bundleSource:Z("string","DocumentSnapshot"),bundleName:Z("string"),bundle:Z("string")};class Ti extends qt{data(e={}){return super.data(e)}}class xn{constructor(e,t,i,s){this._firestore=e,this._userDataWriter=t,this._snapshot=s,this.metadata=new mi(s.hasPendingWrites,s.fromCache),this.query=i}get docs(){const e=[];return this.forEach((t=>e.push(t))),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach((i=>{e.call(t,new Ti(this._firestore,this._userDataWriter,i.key,i,new mi(this._snapshot.mutatedKeys.has(i.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new V(F.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(s,o){if(s._snapshot.oldDocs.isEmpty()){let a=0;return s._snapshot.docChanges.map((h=>{const u=new Ti(s._firestore,s._userDataWriter,h.doc.key,h.doc,new mi(s._snapshot.mutatedKeys.has(h.doc.key),s._snapshot.fromCache),s.query.converter);return h.doc,{type:"added",doc:u,oldIndex:-1,newIndex:a++}}))}{let a=s._snapshot.oldDocs;return s._snapshot.docChanges.filter((h=>o||h.type!==3)).map((h=>{const u=new Ti(s._firestore,s._userDataWriter,h.doc.key,h.doc,new mi(s._snapshot.mutatedKeys.has(h.doc.key),s._snapshot.fromCache),s.query.converter);let f=-1,E=-1;return h.type!==0&&(f=a.indexOf(h.doc.key),a=a.delete(h.doc.key)),h.type!==1&&(a=a.add(h.doc),E=a.indexOf(h.doc.key)),{type:Jf(h.type),doc:u,oldIndex:f,newIndex:E}}))}})(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new V(F.FAILED_PRECONDITION,"QuerySnapsh
24ot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e={};e.type=xn._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=Nf.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const t=[],i=[],s=[];return this.docs.forEach((o=>{o._document!==null&&(t.push(o._document),i.push(this._userDataWriter.convertObjectMap(o._document.data.value.mapValue.fields,"previous")),s.push(o.ref.path))})),e.bundle=(this._firestore,this.query._query,e.bundleName,"NOT SUPPORTED"),e}}function Jf(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return Oi(61501,{type:n})}}xn._jsonSchemaVersion="firestore/querySnapshot/1.0",xn._jsonSchema={type:Z("string",xn._jsonSchemaVersion),bundleSource:Z("string","QuerySnapshot"),bundleName:Z("string"),bundle:Z("string")};(function(e,t=!0){(function(s){es=s})(yt),We(new Oe("firestore",((i,{instanceIdentifier:s,options:o})=>{const a=i.getProvider("app").getImmediate(),h=new qf(new Cf(i.getProvider("auth-internal")),new Rf(a,i.getProvider("app-check-internal")),(function(f,E){if(!Object.prototype.hasOwnProperty.apply(f.options,["projectId"]))throw new V(F.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new Di(f.options.projectId,E)})(a,s),a);return o={useFetchStreams:t,...o},h._setSettings(o),h}),"PUBLIC").setMultipleInstances(!0)),ve(va,wa,e),ve(va,wa,"esm2020")})();function uc(){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 Qf=uc,dc=new on("auth","Firebase",uc());const Mi=new Kn("@firebase/auth");function Zf(n,...e){Mi.logLevel<=B.WARN&&Mi.warn(`Auth (${yt}): ${n}`,...e)}function Si(n,...e){Mi.logLevel<=B.ERROR&&Mi.error(`Auth (${yt}): ${n}`,...e)}function He(n,...e){throw Pr(n,...e)}function Ne(n,...e){return Pr(n,...e)}function Nr(n,e,t){const i={...Qf(),[e]:t};return new on("auth","Firebase",i).create(e,{appName:n.name})}function Pt(n){return Nr(n,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function fc(n,e,t){const i=t;if(!(e instanceof i))throw i.name!==e.constructor.name&&He(n,"argument-error"),Nr(n,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function Pr(n,...e){if(typeof n!="string"){const t=e[0],i=[...e.slice(1)];return i[0]&&(i[0].appName=n.name),n._errorFactory.create(t,...i)}return dc.create(n,...e)}function P(n,e,...t){if(!n)throw Pr(e,...t)}function Ke(n){const e="INTERNAL ASSERTION FAILED: "+n;throw Si(e),new Error(e)}function Ze(n,e){n||Ke(e)}function rr(){return typeof self<"u"&&self.location?.href||""}function ep(){return xa()==="http:"||xa()==="https:"}function xa(){return typeof self<"u"&&self.location?.protocol||null}function tp(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(ep()||Ju()||"connection"in navigator)?navigator.onLine:!0}function np(){if(typeof navigator>"u")return null;const n=navigator;return n.languages&&n.languages[0]||n.language||null}class Xn{constructor(e,t){this.shortDelay=e,this.longDelay=t,Ze(t>e,"Short delay should be less than long delay!"),this.isMobile=Sr()||Jl()}get(){return tp()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}function Or(n,e){Ze(n.emulator,"Emulator should always be set here");const{url:t}=n.emulator;return e?`${t}${e.startsWith("/")?e.slice(1):e}`:t}class pc{static initialize(e,t,i){this.fetchImpl=e,t&&(this.headersImpl=t),i&&(this.responseImpl=i)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<"u"&&"fetch"in self)return self.fetch;if(typeof globalThis<"u"&&globalThis.fetch)return globalThis.fetch;if(typeof fetch<"u")return fetch;Ke("Could not find fetch implementation, make sure you call FetchProvi
24der.initialize() with an appropriate polyfill")}static headers(){if(this.headersImpl)return this.headersImpl;if(typeof self<"u"&&"Headers"in self)return self.Headers;if(typeof globalThis<"u"&&globalThis.Headers)return globalThis.Headers;if(typeof Headers<"u")return Headers;Ke("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<"u"&&"Response"in self)return self.Response;if(typeof globalThis<"u"&&globalThis.Response)return globalThis.Response;if(typeof Response<"u")return Response;Ke("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}const ip={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"};const sp=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],rp=new Xn(3e4,6e4);function Dr(n,e){return n.tenantId&&!e.tenantId?{...e,tenantId:n.tenantId}:e}async function ln(n,e,t,i,s={}){return gc(n,s,async()=>{let o={},a={};i&&(e==="GET"?a=i:o={body:JSON.stringify(i)});const h=an({key:n.config.apiKey,...a}).slice(1),u=await n._getAdditionalHeaders();u["Content-Type"]="application/json",n.languageCode&&(u["X-Firebase-Locale"]=n.languageCode);const f={method:e,headers:u,...o};return Xu()||(f.referrerPolicy="no-referrer"),n.emulatorConfig&&Qi(n.emulatorConfig.host)&&(f.credentials="include"),pc.fetch()(await _c(n,n.config.apiHost,t,h),f)})}async function gc(n,e,t){n._canInitEmulator=!1;const i={...ip,...e};try{const s=new ap(n),o=await Promise.race([t(),s.promise]);s.clearNetworkTimeout();const a=await o.json();if("needConfirmation"in a)throw yi(n,"account-exists-with-different-credential",a);if(o.ok&&!("errorMessage"in a))return a;{const h=o.ok?a.errorMessage:a.error.message,[u,f]=h.split(" : ");if(u==="FEDERATED_USER_ID_ALREADY_LINKED")throw yi(n,"credential-already-in-use",a);if(u==="EMAIL_EXISTS")throw yi(n,"email-already-in-use",a);if(u==="USER_DISABLED")throw yi(n,"user-disabled",a);const E=i[u]||u.toLowerCase().replace(/[_\s]+/g,"-");if(f)throw Nr(n,E,f);He(n,E)}}catch(s){if(s instanceof $e)throw s;He(n,"network-request-failed",{message:String(s)})}}async function op(n,e,t,i,s={}){const o=await ln(n,e,t,i,s);return"mfaPendingCredential"in o&&He(n,"multi-factor-auth-required",{_serverResponse:o}),o}async function _c(n,e,t,i){const s=`${e}${t}?${i}`,o=n,a=o.config.emulator?Or(n.config,s):`${n.config.apiScheme}://${s}`;return sp.includes(t)&&(await o._persistenceManagerAvailable,o._getPersistenceType()==="COOKIE")?o._getPersistence()._getFinalTarget(a).toString():a}class ap{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((t,i)=>{this.timer=setTimeout(()=>i(Ne(this.auth,"network-request-failed")),rp.get())})}}function yi(n,e,t){const i={appName:n.name};t.email&&(i.email=t.email),t.phoneNumber&&(i.phoneNumber=t.phoneNumber);const s=Ne(n,e,i);return s.customData._tokenResponse=t,s}async function lp(n,e){return ln(n,"POST","/v1/accounts:delete",e)}
24async function Li(n,e){return ln(n,"POST","/v1/accounts:lookup",e)}function Un(n){if(n)try{const e=new Date(Number(n));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function cp(n,e=!1){const t=Ge(n),i=await t.getIdToken(e),s=Mr(i);P(s&&s.exp&&s.auth_time&&s.iat,t.auth,"internal-error");const o=typeof s.firebase=="object"?s.firebase:void 0,a=o?.sign_in_provider;return{claims:s,token:i,authTime:Un(js(s.auth_time)),issuedAtTime:Un(js(s.iat)),expirationTime:Un(js(s.exp)),signInProvider:a||null,signInSecondFactor:o?.sign_in_second_factor||null}}function js(n){return Number(n)*1e3}function Mr(n){const[e,t,i]=n.split(".");if(e===void 0||t===void 0||i===void 0)return Si("JWT malformed, contained fewer than 3 sections"),null;try{const s=Ri(t);return s?JSON.parse(s):(Si("Failed to decode base64 JWT payload"),null)}catch(s){return Si("Caught error parsing JWT payload as JSON",s?.toString()),null}}function Ua(n){const e=Mr(n);return P(e,"internal-error"),P(typeof e.exp<"u","internal-error"),P(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}async function Gn(n,e,t=!1){if(t)return e;try{return await e}catch(i){throw i instanceof $e&&hp(i)&&n.auth.currentUser===n&&await n.auth.signOut(),i}}function hp({code:n}){return n==="auth/user-disabled"||n==="auth/user-token-expired"}class up{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,this.timerId!==null&&clearTimeout(this.timerId))}getInterval(e){if(e){const t=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),t}else{this.errorBackoff=3e4;const i=(this.user.stsTokenManager.expirationTime??0)-Date.now()-3e5;return Math.max(0,i)}}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){e?.code==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}class or{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=Un(this.lastLoginAt),this.creationTime=Un(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function xi(n){const e=n.auth,t=await n.getIdToken(),i=await Gn(n,Li(e,{idToken:t}));P(i?.users.length,e,"internal-error");const s=i.users[0];n._notifyReloadListener(s);const o=s.providerUserInfo?.length?mc(s.providerUserInfo):[],a=fp(n.providerData,o),h=n.isAnonymous,u=!(n.email&&s.passwordHash)&&!a?.length,f=h?u:!1,E={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 or(s.createdAt,s.lastLoginAt),isAnonymous:f};Object.assign(n,E)}async function dp(n){const e=Ge(n);await xi(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function fp(n,e){return[...n.filter(i=>!e.some(s=>s.providerId===i.providerId)),...e]}function mc(n){return n.map(({providerId:e,...t})=>({providerId:e,uid:t.rawId||"",displayName:t.displayName||null,email:t.email||null,phoneNumber:t.phoneNumber||null,photoURL:t.photoUrl||null}))}async function pp(n,e){const t=await gc(n,{},async()=>{const i=an({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:s,apiKey:o}=n.config,a=await _c(n,s,"/v1/token",`key=${o}`),h=await n._getAdditionalHeaders();h["Content-Type"]="application/x-www-form-urlencoded";const u={method:"POST",headers:h,body:i};return n.emulatorConfig&&Qi(n.emulatorConfig.host)&&(u.credentials="include"),pc.fetch()(a,u)});return{accessToken:t.access_token,expiresIn:t.expires_in,refreshToken:t.refresh_token}}async function gp(n,e){return ln(n,"POST","/v2/accounts:revokeToken",Dr(n,e))}class Kt{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){P(e.idToken,"internal-error"),P(typeof e.idToken<"u","internal-error"),P(typeof e.refreshToken<"u","internal-error");
24const t="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):Ua(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){P(e.length!==0,"internal-error");const t=Ua(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(P(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:i,refreshToken:s,expiresIn:o}=await pp(e,t);this.updateTokensAndExpiration(i,s,Number(o))}updateTokensAndExpiration(e,t,i){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+i*1e3}static fromJSON(e,t){const{refreshToken:i,accessToken:s,expirationTime:o}=t,a=new Kt;return i&&(P(typeof i=="string","internal-error",{appName:e}),a.refreshToken=i),s&&(P(typeof s=="string","internal-error",{appName:e}),a.accessToken=s),o&&(P(typeof o=="number","internal-error",{appName:e}),a.expirationTime=o),a}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 Kt,this.toJSON())}_performRefresh(){return Ke("not implemented")}}function at(n,e){P(typeof n=="string"||typeof n>"u","internal-error",{appName:e})}class be{constructor({uid:e,auth:t,stsTokenManager:i,...s}){this.providerId="firebase",this.proactiveRefresh=new up(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=t,this.stsTokenManager=i,this.accessToken=i.accessToken,this.displayName=s.displayName||null,this.email=s.email||null,this.emailVerified=s.emailVerified||!1,this.phoneNumber=s.phoneNumber||null,this.photoURL=s.photoURL||null,this.isAnonymous=s.isAnonymous||!1,this.tenantId=s.tenantId||null,this.providerData=s.providerData?[...s.providerData]:[],this.metadata=new or(s.createdAt||void 0,s.lastLoginAt||void 0)}async getIdToken(e){const t=await Gn(this,this.stsTokenManager.getToken(this.auth,e));return P(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return cp(this,e)}reload(){return dp(this)}_assign(e){this!==e&&(P(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(t=>({...t})),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new be({...this,auth:e,stsTokenManager:this.stsTokenManager._clone()});return t.metadata._copy(this.metadata),t}_onReload(e){P(!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 i=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),i=!0),t&&await xi(this),await this.auth._persistUserIfCurrent(this),i&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(ye(this.auth.app))return Promise.reject(Pt(this.auth));const e=await this.getIdToken();return await Gn(this,lp(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return{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=>({...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){const i=t.displayName??void 0,s=t.email??void 0,o=t.phoneNumber??void 0,a=t.photoURL??void 0,h=t.tenantId??void 0,u=t._redirectEventId??void 0,f=t.createdAt??void 0,E=t.lastLoginAt??void 0,{uid:y,emailVerified:S,isAnonymous:k,providerData:R,stsTokenManager:O}=t;P(y&&O,e,"internal-error");const N=Kt.fromJSON(this.name,O);P(typeof y=="string",e,"internal-error"),at(i,e.name),at(s,e.name),P(typeof S=="boolean",e,"internal-error"),P(typeof k=="boolean",e,"internal-error"),at(o,e.name),at(a,e.name),at(h,e.name),at(u,e.name),at(f,e.name),at(E,e.name);const Y=new be({uid:y,auth:e,email:s,emailVerified:S,displayName:i,isAnonymous:k,photoURL:a,p
24honeNumber:o,tenantId:h,stsTokenManager:N,createdAt:f,lastLoginAt:E});return R&&Array.isArray(R)&&(Y.providerData=R.map(Q=>({...Q}))),u&&(Y._redirectEventId=u),Y}static async _fromIdTokenResponse(e,t,i=!1){const s=new Kt;s.updateFromServerResponse(t);const o=new be({uid:t.localId,auth:e,stsTokenManager:s,isAnonymous:i});return await xi(o),o}static async _fromGetAccountInfoResponse(e,t,i){const s=t.users[0];P(s.localId!==void 0,"internal-error");const o=s.providerUserInfo!==void 0?mc(s.providerUserInfo):[],a=!(s.email&&s.passwordHash)&&!o?.length,h=new Kt;h.updateFromIdToken(i);const u=new be({uid:s.localId,auth:e,stsTokenManager:h,isAnonymous:a}),f={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:o,metadata:new or(s.createdAt,s.lastLoginAt),isAnonymous:!(s.email&&s.passwordHash)&&!o?.length};return Object.assign(u,f),u}}const Fa=new Map;function Ye(n){Ze(n instanceof Function,"Expected a class definition");let e=Fa.get(n);return e?(Ze(e instanceof n,"Instance stored in cache mismatched with class"),e):(e=new n,Fa.set(n,e),e)}class yc{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 t===void 0?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}yc.type="NONE";const Va=yc;function Ci(n,e,t){return`firebase:${n}:${e}:${t}`}class Yt{constructor(e,t,i){this.persistence=e,this.auth=t,this.userKey=i;const{config:s,name:o}=this.auth;this.fullUserKey=Ci(this.userKey,s.apiKey,o),this.fullPersistenceKey=Ci("persistence",s.apiKey,o),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(typeof e=="string"){const t=await Li(this.auth,{idToken:e}).catch(()=>{});return t?be._fromGetAccountInfoResponse(this.auth,t,e):null}return be._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();if(await this.removeCurrentUser(),this.persistence=e,t)return this.setCurrentUser(t)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,i="authUser"){if(!t.length)return new Yt(Ye(Va),e,i);const s=(await Promise.all(t.map(async f=>{if(await f._isAvailable())return f}))).filter(f=>f);let o=s[0]||Ye(Va);const a=Ci(i,e.config.apiKey,e.name);let h=null;for(const f of t)try{const E=await f._get(a);if(E){let y;if(typeof E=="string"){const S=await Li(e,{idToken:E}).catch(()=>{});if(!S)break;y=await be._fromGetAccountInfoResponse(e,S,E)}else y=be._fromJSON(e,E);f!==o&&(h=y),o=f;break}}catch{}const u=s.filter(f=>f._shouldAllowMigration);return!o._shouldAllowMigration||!u.length?new Yt(o,e,i):(o=u[0],h&&await o._set(a,h.toJSON()),await Promise.all(t.map(async f=>{if(f!==o)try{await f._remove(a)}catch{}})),new Yt(o,e,i))}}function Ba(n){const e=n.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(Ic(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(vc(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(Sc(e))return"Blackberry";if(Cc(e))return"Webos";if(wc(e))return"Safari";if((e.includes("chrome/")||Ec(e))&&!e.includes("edge/"))return"Chrome";if(Tc(e))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,i=n.match(t);if(i?.length===2)return i[1]}return"Other"}function vc(n=fe()){return/firefox\//i.test(n)}function wc(n=fe()){const e=n.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function Ec(n=fe()){return/crios\//i.test(n)}function Ic(n=fe()){return/iemobile/i.test(n)}function Tc(n=fe()){return/android/i.test(n)}function Sc(n=fe()){return/blackberry/i.test(n)}function Cc(n=fe()){return/webos/i.test(n)}function Lr(n=fe()){return/iphone|ipad|ipod/i.test(n)||/macintosh/i.test(n)&&/mobile/i.test(n)}function _p(n=fe()){return Lr(n)&&!!window.navigator?.standalone}function mp(){return Qu()&&document.documentMode===10}function Ac(n=fe()){return Lr(n)||Tc(n)||Cc(n)||Sc(n)||/windows phone/i.test(n)||Ic(n)}function bc(n,e=[]){let t;switch(n){case"Browser":t=Ba(fe());break;case"Worker":t=`${Ba(fe())}-${n}`;break;default:t=n}const i=e.length?e.join(","):"FirebaseCore-web";return`${t}/JsCore/${yt}/${i}`}class yp{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const i=o=>new Promise((a,h)=>{try{const u=e(o);a(u)}catch(u){h(u)}});i.onAbort=t,this.queue.push(i);const s=this.queue.length-1;return()=>{this.queue[s]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const t=[];try{for(const i of this.queue)await i(e),i.onAbort&&t.push(i.onAbort)}catch(i){t.reverse();for(const s of t)try{s()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:i?.message})}}}async function vp(n,e={}){return ln(n,"GET","/v2/passwordPolicy",Dr(n,e))}const wp=6;class Ep{constructor(e){const t=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=t.minPasswordLength??wp,t.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=t.maxPasswordLength),t.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=t.containsLowercaseCharacter),t.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=t.containsUppercaseCharacter),t.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=t.containsNumericCharacter),t.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=t.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=e.allowedNonAlphanumericCharacters?.join("")??"",this.forceUpgradeOnSignin=e.forceUpgradeOnSignin??!1,this.schemaVersion=e.schemaVersion}validatePassword(e){const t={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,t),this.validatePasswordCharacterOptions(e,t),t.isValid&&
24(t.isValid=t.meetsMinPasswordLength??!0),t.isValid&&(t.isValid=t.meetsMaxPasswordLength??!0),t.isValid&&(t.isValid=t.containsLowercaseLetter??!0),t.isValid&&(t.isValid=t.containsUppercaseLetter??!0),t.isValid&&(t.isValid=t.containsNumericCharacter??!0),t.isValid&&(t.isValid=t.containsNonAlphanumericCharacter??!0),t}validatePasswordLengthOptions(e,t){const i=this.customStrengthOptions.minPasswordLength,s=this.customStrengthOptions.maxPasswordLength;i&&(t.meetsMinPasswordLength=e.length>=i),s&&(t.meetsMaxPasswordLength=e.length<=s)}validatePasswordCharacterOptions(e,t){this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);let i;for(let s=0;s<e.length;s++)i=e.charAt(s),this.updatePasswordCharacterOptionsStatuses(t,i>="a"&&i<="z",i>="A"&&i<="Z",i>="0"&&i<="9",this.allowedNonAlphanumericCharacters.includes(i))}updatePasswordCharacterOptionsStatuses(e,t,i,s,o){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=i)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=s)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=o))}}class Ip{constructor(e,t,i,s){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=i,this.config=s,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new Wa(this),this.idTokenSubscription=new Wa(this),this.beforeStateQueue=new yp(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=dc,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=s.sdkClientVersion,this._persistenceManagerAvailable=new Promise(o=>this._resolvePersistenceManagerAvailable=o)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=Ye(t)),this._initializationPromise=this.queue(async()=>{if(!this._deleted&&(this.persistenceManager=await Yt.create(this,e),this._resolvePersistenceManagerAvailable?.(),!this._deleted)){if(this._popupRedirectResolver?._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(t),this.lastNotifiedUid=this.currentUser?.uid||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{const t=await Li(this,{idToken:e}),i=await be._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(i)}catch(t){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",t),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){if(ye(this.app)){const o=this.app.settings.authIdToken;return o?new Promise(a=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(o).then(a,a))}):this.directlySetCurrentUser(null)}const t=await this.assertedPersistence.getCurrentUser();let i=t,s=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const o=this.redirectUser?._redirectEventId,a=i?._redirectEventId,h=await this.tryRedirectSignIn(e);(!o||o===a)&&h?.user&&(i=h.user,s=!0)}if(!i)return this.directlySetCurrentUser(null);if(!i._redirectEventId){if(s)try{await this.beforeStateQueue.runMiddleware(i)}catch(o){i=t,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(o))}return i?this.reloadAndSetCurrentUserOrClear(i):this.directlySetCurrentUser(null)}return P(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===i._redirectEventId?this.directlySetCurrentUser(i):this.reloadAndSetCurrentUserOrClear(i)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await xi(e)}catch(t){if(t?.code!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=np()}async _delete(){this._deleted=!0}
24async updateCurrentUser(e){if(ye(this.app))return Promise.reject(Pt(this));const t=e?Ge(e):null;return t&&P(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&&P(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 ye(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 ye(this.app)?Promise.reject(Pt(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(Ye(e))})}_getRecaptchaConfig(){return this.tenantId==null?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 this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await vp(this),t=new Ep(e);this.tenantId===null?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new on("auth","Firebase",e())}onAuthStateChanged(e,t,i){return this.registerStateListener(this.authStateSubscription,e,t,i)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,i){return this.registerStateListener(this.idTokenSubscription,e,t,i)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{const i=this.onAuthStateChanged(()=>{i(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){const t=await this.currentUser.getIdToken(),i={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:t};this.tenantId!=null&&(i.tenantId=this.tenantId),await gp(this,i)}}toJSON(){return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:this._currentUser?.toJSON()}}async _setRedirectUser(e,t){const i=await this.getOrInitRedirectPersistenceManager(t);return e===null?i.removeCurrentUser():i.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&Ye(e)||this._popupRedirectResolver;P(t,this,"argument-error"),this.redirectPersistenceManager=await Yt.create(this,[Ye(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){return this._isInitialized&&await this.queue(async()=>{}),this._currentUser?._redirectEventId===e?this._currentUser:this.redirectUser?._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(){if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const e=this.currentUser?.uid??null;this.lastNotifiedUid!==e&&(this.lastNotifiedUid=e,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,i,s){if(this._deleted)return()=>{};const o=typeof t=="function"?t:t.next.bind(t);let a=!1;const h=this._isInitialized?Promise.resolve():this._initializationPromise;if(P(h,this,"internal-error"),h.then(()=>{a||o(this.currentUser)}),typeof t=="function"){const u=e.addObserver(t,i,s);return()=>{a=!0,u()}}else{const u=e.addObserver(t);return()=>{a=!0,u()}}}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 P(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=bc(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){const e={"X-Client-Version":this.clientVersion};this.app.options.appId&&(e["X-Firebase-gmpid"]=this.app.options.appId);const t=await this.heartbeatServiceProvider.getImmediate({optional:!0})?.getHeartbeatsHeader();t&&(e["X-Firebase-Client"]=t);const i=await this._getAppCheckToken();return i&&(e["X-Firebase-AppCheck"]=i),e}async _getAppCheckToken(){if(ye(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=await this.appCheckServiceProvider.getImmediate({optional:!0})?.getToken();return e?.error&&Zf(`Error while retrieving App Check token: ${e.error}`),e?.token}}function ts(n){return Ge(n)}class Wa{constructor(e){this.auth=e,this.observer=null,this.addObserver=ad(t=>this.observer=t)}get next(){return P(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}let xr={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function Tp(n){xr=n}function Sp(n){return xr.loadJS(n)}function Cp(){return xr.gapiScript}function Ap(n){return`__${n}${Math.floor(Math.random()*1e6)}`}function bp(n,e){const t=nc(n,"auth");if(t.isInitialized()){const s=t.getImmediate(),o=t.getOptions();if(en(o,e??{}))return s;He(s,"already-initialized")}return t.initialize({options:e})}function Rp(n,e){const t=e?.persistence||[],i=(Array.isArray(t)?t:[t]).map(Ye);e?.errorMap&&n._updateErrorMap(e.errorMap),n._initializeWithPersistence(i,e?.popupRedirectResolver)}function kp(n,e,t){const i=ts(n);P(/^https?:\/\//.test(e),i,"invalid-emulator-scheme");const s=!1,o=Rc(e),{host:a,port:h}=Np(e),u=h===null?"":`:${h}`,f={url:`${o}//${a}${u}/`},E=Object.freeze({host:a,port:h,protocol:o.replace(":",""),options:Object.freeze({disableWarnings:s})});if(!i._canInitEmulator){P(i.config.emulator&&i.emulatorConfig,i,"emulator-config-failed"),P(en(f,i.config.emulator)&&en(E,i.emulatorConfig),i,"emulator-config-failed");return}i.config.emulator=f,i.emulatorConfig=E,i.settings.appVerificationDisabledForTesting=!0,Qi(a)?(zu(`${o}//${a}${u}`),Yu("Auth",!0)):Pp()}function Rc(n){const e=n.indexOf(":");return e<0?"":n.substr(0,e+1)}function Np(n){const e=Rc(n),t=/(\/\/)?([^?#/]+)/.exec(n.substr(e.length));if(!t)return{host:"",port:null};const i=t[2].split("@").pop()||"",s=/^(\[[^\]]+\])(:|$)/.exec(i);if(s){const o=s[1];return{host:o,port:Ha(i.substr(o.length+1))}}else{const[o,a]=i.split(":");return{host:o,port:Ha(a)}}}function Ha(n){if(!n)return null;const e=Number(n);return isNaN(e)?null:e}function Pp(){function n(){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)}typeof console<"u"&&typeof console.info=="function"&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."),typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?window.addEventListener("DOMContentLoaded",n):n())}class kc{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return Ke("not implemented")}_getIdTokenResponse(e){return Ke("not implemented")}_linkToIdToken(e,t){return Ke("not implemented")}_getReauthenticationResolver(e){return Ke("not implemented")}}async function Xt(n,e){return op(n,"POST","/v1/accounts:signInWithIdp",Dr(n,e))}const Op="http://localhost";class Dt extends kc{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new Dt(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&&
24(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):He("argument-error"),t}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e,{providerId:i,signInMethod:s,...o}=t;if(!i||!s)return null;const a=new Dt(i,s);return a.idToken=o.idToken||void 0,a.accessToken=o.accessToken||void 0,a.secret=o.secret,a.nonce=o.nonce,a.pendingToken=o.pendingToken||null,a}_getIdTokenResponse(e){const t=this.buildRequest();return Xt(e,t)}_linkToIdToken(e,t){const i=this.buildRequest();return i.idToken=t,Xt(e,i)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,Xt(e,t)}buildRequest(){const e={requestUri:Op,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=an(t)}return e}}class ns{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 ns{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class lt extends Jn{constructor(){super("facebook.com")}static credential(e){return Dt._fromParams({providerId:lt.PROVIDER_ID,signInMethod:lt.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return lt.credentialFromTaggedObject(e)}static credentialFromError(e){return lt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return lt.credential(e.oauthAccessToken)}catch{return null}}}lt.FACEBOOK_SIGN_IN_METHOD="facebook.com";lt.PROVIDER_ID="facebook.com";class ct extends Jn{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return Dt._fromParams({providerId:ct.PROVIDER_ID,signInMethod:ct.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return ct.credentialFromTaggedObject(e)}static credentialFromError(e){return ct.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:i}=e;if(!t&&!i)return null;try{return ct.credential(t,i)}catch{return null}}}ct.GOOGLE_SIGN_IN_METHOD="google.com";ct.PROVIDER_ID="google.com";class ht extends Jn{constructor(){super("github.com")}static credential(e){return Dt._fromParams({providerId:ht.PROVIDER_ID,signInMethod:ht.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return ht.credentialFromTaggedObject(e)}static credentialFromError(e){return ht.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return ht.credential(e.oauthAccessToken)}catch{return null}}}ht.GITHUB_SIGN_IN_METHOD="github.com";ht.PROVIDER_ID="github.com";class ut extends Jn{constructor(){super("twitter.com")}static credential(e,t){return Dt._fromParams({providerId:ut.PROVIDER_ID,signInMethod:ut.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return ut.credentialFromTaggedObject(e)}static credentialFromError(e){return ut.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:i}=e;if(!t||!i)return null;try{return ut.credential(t,i)}catch{return null}}}ut.TWITTER_SIGN_IN_METHOD="twitter.com";ut.PROVIDER_ID="twitter.com";class tn{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,i,s=!1){const o=await be._fromIdTokenResponse(e,i,s),a=ja(i);return new tn({user:o,providerId:a,_tokenResponse:i,operationType:t})}static async _forOperation(e,t,i){await e._updateTokensIfNecessary(i,!0);const s=ja(i);return new tn({user:e,providerId:s,_tokenResponse:i,operationType:t})}}function ja(n){return n.providerId?n.providerId:"phoneNumber"in n?"phone":null}class Ui extends $e{constructor(e,t,i,s){super(t.code,t.message),this.operationType=i,this.user=s,Object.setPrototypeOf(this,Ui.prototype),this.customData={appName:e.n
24ame,tenantId:e.tenantId??void 0,_serverResponse:t.customData._serverResponse,operationType:i}}static _fromErrorAndOperation(e,t,i,s){return new Ui(e,t,i,s)}}function Nc(n,e,t,i){return(e==="reauthenticate"?t._getReauthenticationResolver(n):t._getIdTokenResponse(n)).catch(o=>{throw o.code==="auth/multi-factor-auth-required"?Ui._fromErrorAndOperation(n,o,e,i):o})}async function Dp(n,e,t=!1){const i=await Gn(n,e._linkToIdToken(n.auth,await n.getIdToken()),t);return tn._forOperation(n,"link",i)}async function Mp(n,e,t=!1){const{auth:i}=n;if(ye(i.app))return Promise.reject(Pt(i));const s="reauthenticate";try{const o=await Gn(n,Nc(i,s,e,n),t);P(o.idToken,i,"internal-error");const a=Mr(o.idToken);P(a,i,"internal-error");const{sub:h}=a;return P(n.uid===h,i,"user-mismatch"),tn._forOperation(n,s,o)}catch(o){throw o?.code==="auth/user-not-found"&&He(i,"user-mismatch"),o}}async function Lp(n,e,t=!1){if(ye(n.app))return Promise.reject(Pt(n));const i="signIn",s=await Nc(n,i,e),o=await tn._fromIdTokenResponse(n,i,s);return t||await n._updateCurrentUser(o.user),o}function xp(n,e,t,i){return Ge(n).onIdTokenChanged(e,t,i)}function Up(n,e,t){return Ge(n).beforeAuthStateChanged(e,t)}function Ov(n,e,t,i){return Ge(n).onAuthStateChanged(e,t,i)}function Dv(n){return Ge(n).signOut()}const Fi="__sak";class Pc{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Fi,"1"),this.storage.removeItem(Fi),Promise.resolve(!0)):Promise.resolve(!1)}catch{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()}}const Fp=1e3,Vp=10;class Oc extends Pc{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=Ac(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const i=this.storage.getItem(t),s=this.localCache[t];i!==s&&e(t,s,i)}}onStorageEvent(e,t=!1){if(!e.key){this.forAllChangedKeys((a,h,u)=>{this.notifyListeners(a,u)});return}const i=e.key;t?this.detachListener():this.stopPolling();const s=()=>{const a=this.storage.getItem(i);!t&&this.localCache[i]===a||this.notifyListeners(i,a)},o=this.storage.getItem(i);mp()&&o!==e.newValue&&e.newValue!==e.oldValue?setTimeout(s,Vp):s()}notifyListeners(e,t){this.localCache[e]=t;const i=this.listeners[e];if(i)for(const s of Array.from(i))s(t&&JSON.parse(t))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,i)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:i}),!0)})},Fp)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){Object.keys(this.listeners).length===0&&(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),this.listeners[e].size===0&&delete this.listeners[e]),Ob
24ject.keys(this.listeners).length===0&&(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]}}Oc.type="LOCAL";const Bp=Oc;class Dc extends Pc{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}Dc.type="SESSION";const Mc=Dc;function Wp(n){return Promise.all(n.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(t){return{fulfilled:!1,reason:t}}}))}class is{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const t=this.receivers.find(s=>s.isListeningto(e));if(t)return t;const i=new is(e);return this.receivers.push(i),i}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:i,eventType:s,data:o}=t.data,a=this.handlersMap[s];if(!a?.size)return;t.ports[0].postMessage({status:"ack",eventId:i,eventType:s});const h=Array.from(a).map(async f=>f(t.origin,o)),u=await Wp(h);t.ports[0].postMessage({status:"done",eventId:i,eventType:s,response:u})}_subscribe(e,t){Object.keys(this.handlersMap).length===0&&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||this.handlersMap[e].size===0)&&delete this.handlersMap[e],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}is.receivers=[];function Ur(n="",e=10){let t="";for(let i=0;i<e;i++)t+=Math.floor(Math.random()*10);return n+t}class Hp{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,i=50){const s=typeof MessageChannel<"u"?new MessageChannel:null;if(!s)throw new Error("connection_unavailable");let o,a;return new Promise((h,u)=>{const f=Ur("",20);s.port1.start();const E=setTimeout(()=>{u(new Error("unsupported_event"))},i);a={messageChannel:s,onMessage(y){const S=y;if(S.data.eventId===f)switch(S.data.status){case"ack":clearTimeout(E),o=setTimeout(()=>{u(new Error("timeout"))},3e3);break;case"done":clearTimeout(o),h(S.data.response);break;default:clearTimeout(E),clearTimeout(o),u(new Error("invalid_response"));break}}},this.handlers.add(a),s.port1.addEventListener("message",a.onMessage),this.target.postMessage({eventType:e,eventId:f,data:t},[s.port2])}).finally(()=>{a&&this.removeMessageHandler(a)})}}function Be(){return window}function jp(n){Be().location.href=n}function Lc(){return typeof Be().WorkerGlobalScope<"u"&&typeof Be().importScripts=="function"}async function $p(){if(!navigator?.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function Gp(){return navigator?.serviceWorker?.controller||null}function zp(){return Lc()?self:null}const xc="firebaseLocalStorageDb",qp=1,Vi="firebaseLocalStorage",Uc="fbase_key";class Qn{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 ss(n,e){return n.transaction([Vi],e?"readwrite":"readonly").objectStore(Vi)}function Kp(){const n=indexedDB.deleteDatabase(xc);return new Qn(n).toPromise()}function ar(){const n=indexedDB.open(xc,qp);return new Promise((e,t)=>{n.addEventListener("error",()=>{t(n.error)}),n.addEventListener("upgradeneeded",()=>{const i=n.result;try{i.createObjectStore(Vi,{keyPath:Uc})}catch(s){t(s)}}),n.addEventListener("success",async()=>{const i=n.result;i.objectStoreNames.contains(Vi)?e(i):(i.close(),await Kp(),e(await ar()))})})}async function $a(n,e,t){const i=ss(n,!0).put({[Uc]:e,value:t});return new Qn(i).toPromise()}async function Yp(n,e){const t=ss(n,!1).get(e),i=await new Qn(t).toProm
24ise();return i===void 0?null:i.value}function Ga(n,e){const t=ss(n,!0).delete(e);return new Qn(t).toPromise()}const Xp=800,Jp=3;class Fc{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:(this.db=await ar(),this.db)}async _withRetries(e){let t=0;for(;;)try{const i=await this._openDb();return await e(i)}catch(i){if(t++>Jp)throw i;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return Lc()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=is._getInstance(zp()),this.receiver._subscribe("keyChanged",async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){if(this.activeServiceWorker=await $p(),!this.activeServiceWorker)return;this.sender=new Hp(this.activeServiceWorker);const e=await this.sender._send("ping",{},800);e&&e[0]?.fulfilled&&e[0]?.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||Gp()!==this.activeServiceWorker))try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{if(!indexedDB)return!1;const e=await ar();return await $a(e,Fi,"1"),await Ga(e,Fi),!0}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(i=>$a(i,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){const t=await this._withRetries(i=>Yp(i,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>Ga(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(s=>{const o=ss(s,!1).getAll();return new Qn(o).toPromise()});if(!e)return[];if(this.pendingWrites!==0)return[];const t=[],i=new Set;if(e.length!==0)for(const{fbase_key:s,value:o}of e)i.add(s),JSON.stringify(this.localCache[s])!==JSON.stringify(o)&&(this.notifyListeners(s,o),t.push(s));for(const s of Object.keys(this.localCache))this.localCache[s]&&!i.has(s)&&(this.notifyListeners(s,null),t.push(s));return t}notifyListeners(e,t){this.localCache[e]=t;const i=this.listeners[e];if(i)for(const s of Array.from(i))s(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),Xp)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){Object.keys(this.listeners).length===0&&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),this.listeners[e].size===0&&delete this.listeners[e]),Ob
24ject.keys(this.listeners).length===0&&this.stopPolling()}}Fc.type="LOCAL";const Qp=Fc;new Xn(3e4,6e4);function Fr(n,e){return e?Ye(e):(P(n._popupRedirectResolver,n,"argument-error"),n._popupRedirectResolver)}class Vr extends kc{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return Xt(e,this._buildIdpRequest())}_linkToIdToken(e,t){return Xt(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return Xt(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 Zp(n){return Lp(n.auth,new Vr(n),n.bypassAuthState)}function eg(n){const{auth:e,user:t}=n;return P(t,e,"internal-error"),Mp(t,new Vr(n),n.bypassAuthState)}async function tg(n){const{auth:e,user:t}=n;return P(t,e,"internal-error"),Dp(t,new Vr(n),n.bypassAuthState)}class Vc{constructor(e,t,i,s,o=!1){this.auth=e,this.resolver=i,this.user=s,this.bypassAuthState=o,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(i){this.reject(i)}})}async onAuthEvent(e){const{urlResponse:t,sessionId:i,postBody:s,tenantId:o,error:a,type:h}=e;if(a){this.reject(a);return}const u={auth:this.auth,requestUri:t,sessionId:i,tenantId:o||void 0,postBody:s||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(h)(u))}catch(f){this.reject(f)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return Zp;case"linkViaPopup":case"linkViaRedirect":return tg;case"reauthViaPopup":case"reauthViaRedirect":return eg;default:He(this.auth,"internal-error")}}resolve(e){Ze(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){Ze(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 ng=new Xn(2e3,1e4);async function Mv(n,e,t){if(ye(n.app))return Promise.reject(Ne(n,"operation-not-supported-in-this-environment"));const i=ts(n);fc(n,e,ns);const s=Fr(i,t);return new dt(i,"signInViaPopup",e,s).executeNotNull()}async function Lv(n,e,t){const i=Ge(n);fc(i.auth,e,ns);const s=Fr(i.auth,t);return new dt(i.auth,"linkViaPopup",e,s,i).executeNotNull()}class dt extends Vc{constructor(e,t,i,s,o){super(e,t,s,o),this.provider=i,this.authWindow=null,this.pollId=null,dt.currentPopupAction&&dt.currentPopupAction.cancel(),dt.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return P(e,this.auth,"internal-error"),e}async onExecution(){Ze(this.filter.length===1,"Popup operations only handle one event");const e=Ur();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(t=>{this.reject(t)}),this.resolver._isIframeWebStorageSupported(this.auth,t=>{t||this.reject(Ne(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){return this.authWindow?.associatedEvent||null}cancel(){this.reject(Ne(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,dt.currentPopupAction=null}pollUserCancellation(){const e=()=>{if(this.authWindow?.window?.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(Ne(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,ng.get())};e()}}dt.currentPopupAction=null;const ig="pendingRedirect",Ai=new Map;class sg extends Vc{constructor(e,t,i=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,i),this.eventId=null}async execute(){let e=Ai.get(this.auth._key());if(!e){try{const i=await rg(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(i)}catch(t){e=()=>Promise.reject(t)}Ai.set(this.auth._key(),e)}return this.bypassAuthState||Ai.set(this.auth._key(),()=>Promise.resolve(null)),e()}
24async onAuthEvent(e){if(e.type==="signInViaRedirect")return super.onAuthEvent(e);if(e.type==="unknown"){this.resolve(null);return}if(e.eventId){const t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function rg(n,e){const t=lg(e),i=ag(n);if(!await i._isAvailable())return!1;const s=await i._get(t)==="true";return await i._remove(t),s}function og(n,e){Ai.set(n._key(),e)}function ag(n){return Ye(n._redirectPersistence)}function lg(n){return Ci(ig,n.config.apiKey,n.name)}async function cg(n,e,t=!1){if(ye(n.app))return Promise.reject(Pt(n));const i=ts(n),s=Fr(i,e),a=await new sg(i,s,t).execute();return a&&!t&&(delete a.user._redirectEventId,await i._persistUserIfCurrent(a.user),await i._setRedirectUser(null,e)),a}const hg=600*1e3;class ug{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(i=>{this.isEventForConsumer(e,i)&&(t=!0,this.sendToConsumer(e,i),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!dg(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){if(e.error&&!Bc(e)){const i=e.error.code?.split("auth/")[1]||"internal-error";t.onError(Ne(this.auth,i))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const i=t.eventId===null||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&i}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=hg&&this.cachedEventUids.clear(),this.cachedEventUids.has(za(e))}saveEventToCache(e){this.cachedEventUids.add(za(e)),this.lastProcessedEventTime=Date.now()}}function za(n){return[n.type,n.eventId,n.sessionId,n.tenantId].filter(e=>e).join("-")}function Bc({type:n,error:e}){return n==="unknown"&&e?.code==="auth/no-auth-event"}function dg(n){switch(n.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return Bc(n);default:return!1}}async function fg(n,e={}){return ln(n,"GET","/v1/projects",e)}const pg=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,gg=/^https?/;async function _g(n){if(n.config.emulator)return;const{authorizedDomains:e}=await fg(n);for(const t of e)try{if(mg(t))return}catch{}He(n,"unauthorized-domain")}function mg(n){const e=rr(),{protocol:t,hostname:i}=new URL(e);if(n.startsWith("chrome-extension://")){const a=new URL(n);return a.hostname===""&&i===""?t==="chrome-extension:"&&n.replace("chrome-extension://","")===e.replace("chrome-extension://",""):t==="chrome-extension:"&&a.hostname===i}if(!gg.test(t))return!1;if(pg.test(n))return i===n;const s=n.replace(/\./g,"\\.");return new RegExp("^(.+\\."+s+"|"+s+")$","i").test(i)}const yg=new Xn(3e4,6e4);function qa(){const n=Be().___jsl;if(n?.H){for(const e of Object.keys(n.H))if(n.H[e].r=n.H[e].r||[],n.H[e].L=n.H[e].L||[],n.H[e].r=[...n.H[e].L],n.CP)for(let t=0;t<n.CP.length;t++)n.CP[t]=null}}function vg(n){return new Promise((e,t)=>{function i(){qa(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{qa(),t(Ne(n,"network-request-failed"))},timeout:yg.get()})}if(Be().gapi?.iframes?.Iframe)e(gapi.iframes.getContext());else if(Be().gapi?.load)i();else{const s=Ap("iframefcb");return Be()[s]=()=>{gapi.load?i():t(Ne(n,"network-request-failed"))},Sp(`${Cp()}?onload=${s}`).catch(o=>t(o))}}).catch(e=>{throw bi=null,e})}let bi=null;function wg(n){return bi=bi||vg(n),bi}const Eg=new Xn(5e3,15e3),Ig="__/auth/iframe",Tg="emulator/auth/iframe",Sg={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},Cg=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function Ag(n){const e=n.config;P(e.authDomain,n,"auth-domain-config-required");const t=e.emulator?Or(e,Tg):`https://${n.config.authDomain}/${Ig}`,i={apiKey:e.apiKey,appName:n.name,v:yt},s=Cg.get(n.config.apiHost);s&&(i.eid=s);const o=n._getFrameworks();return o.length&&(i.fw=o.join(",")),`${t}?${an(i).slice(1)}`}async function bg(n){const e=await wg(n),t=Be().gapi;return P(t,n,"internal-error"),e.open({where:document.body,url:Ag(n),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:Sg,dontclear:!0},i=>new Promise(async(s,o)=>{await i.restyle({setHideOnLeave:!1});const a=Ne(n,"network-request-failed"),h=Be().setTimeout(()=>{o(a)},Eg.get());function u(){Be().clearTimeout(h),s(i)}i.ping(u).then(u,()=>{o(a)})}))}const Rg={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},kg=500,Ng=600,Pg="_blank",Og="http://localhost";class Ka{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function Dg(n,e,t,i=kg,s=Ng){const o=Math.max((window.screen.availHeight-s)/2,0).toString(),a=Math.max((window.screen.availWi
24dth-i)/2,0).toString();let h="";const u={...Rg,width:i.toString(),height:s.toString(),top:o,left:a},f=fe().toLowerCase();t&&(h=Ec(f)?Pg:t),vc(f)&&(e=e||Og,u.scrollbars="yes");const E=Object.entries(u).reduce((S,[k,R])=>`${S}${k}=${R},`,"");if(_p(f)&&h!=="_self")return Mg(e||"",h),new Ka(null);const y=window.open(e||"",h,E);P(y,n,"popup-blocked");try{y.focus()}catch{}return new Ka(y)}function Mg(n,e){const t=document.createElement("a");t.href=n,t.target=e;const i=document.createEvent("MouseEvent");i.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),t.dispatchEvent(i)}const Lg="__/auth/handler",xg="emulator/auth/handler",Ug=encodeURIComponent("fac");async function Ya(n,e,t,i,s,o){P(n.config.authDomain,n,"auth-domain-config-required"),P(n.config.apiKey,n,"invalid-api-key");const a={apiKey:n.config.apiKey,appName:n.name,authType:t,redirectUrl:i,v:yt,eventId:s};if(e instanceof ns){e.setDefaultLanguage(n.languageCode),a.providerId=e.providerId||"",Zs(e.getCustomParameters())||(a.customParameters=JSON.stringify(e.getCustomParameters()));for(const[E,y]of Object.entries({}))a[E]=y}if(e instanceof Jn){const E=e.getScopes().filter(y=>y!=="");E.length>0&&(a.scopes=E.join(","))}n.tenantId&&(a.tid=n.tenantId);const h=a;for(const E of Object.keys(h))h[E]===void 0&&delete h[E];const u=await n._getAppCheckToken(),f=u?`#${Ug}=${encodeURIComponent(u)}`:"";return`${Fg(n)}?${an(h).slice(1)}${f}`}function Fg({config:n}){return n.emulator?Or(n,xg):`https://${n.authDomain}/${Lg}`}const $s="webStorageSupport";class Vg{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Mc,this._completeRedirectFn=cg,this._overrideRedirectResult=og}async _openPopup(e,t,i,s){Ze(this.eventManagers[e._key()]?.manager,"_initialize() not called before _openPopup()");const o=await Ya(e,t,i,rr(),s);return Dg(e,o,Ur())}async _openRedirect(e,t,i,s){await this._originValidation(e);const o=await Ya(e,t,i,rr(),s);return jp(o),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:s,promise:o}=this.eventManagers[t];return s?Promise.resolve(s):(Ze(o,"If manager is not set, promise should be"),o)}const i=this.initAndGetManager(e);return this.eventManagers[t]={promise:i},i.catch(()=>{delete this.eventManagers[t]}),i}async initAndGetManager(e){const t=await bg(e),i=new ug(e);return t.register("authEvent",s=>(P(s?.authEvent,e,"invalid-auth-event"),{status:i.onEvent(s.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:i},this.iframes[e._key()]=t,i}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send($s,{type:$s},s=>{const o=s?.[0]?.[$s];o!==void 0&&t(!!o),He(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=_g(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return Ac()||wc()||Lr()}}const Bg=Vg;var Xa="@firebase/auth",Ja="1.11.1";class Wg{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){return this.assertAuthConfigured(),this.auth.currentUser?.uid||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged(i=>{e(i?.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(){P(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}function Hg(n){switch(n){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function jg(n){We(new Oe("auth",(e,{options:t})=>{const i=e.getProvider("app").getImmediate(),s=e.getProvider("heartbeat"),o=e.getProvider("app-check-internal"),{apiKey:a,authDomain:h}=i.options;P(a&&!a.includes(":"),"invalid-api-key",{appName:i.name});const u={apiKey:a,authDomain:h,clientPlatform:n,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:bc(n)},f=new Ip(i,s,o,u);return Rp(f,t),f},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,i)=>{e.getProvider("auth-internal").initialize()})),We(new Oe("auth-internal",e=>{const t=ts(e.getProvider("auth").getImmediate());return(i=>new Wg(i))(t)},"PRIVATE").setInstantiationMode("EXPLICIT")),ve(Xa,Ja,Hg(n)),ve(Xa,Ja,"esm2020")}const $g=300,Gg=Xl("authIdTokenMaxAge")||$g;let Qa=null;const zg=n=>async e=>{const t=e&&await e.getIdTokenResult(),i=t&&(new Date().getTime()-Date.parse(t.issuedAtTime))/1e3;if(i&&i>Gg)return;const s=t?.token;Qa!==s&&(Qa=s,await fetch(n,{method:s?"POST":"DELETE",headers:s?{Authorization:`Bearer ${s}`}:{}}))};function xv(n=df()){const e=nc(n,"auth");if(e.isInitialized())return e.getImmediate();const t=bp(n,{popupRedirectResolver:Bg,persistence:[Qp,Bp,Mc]}),i=Xl("authTokenSyncURL");if(i&&typeof isSecureContext=="boolean"&&isSecureContext){const o=new URL(i,location.origin);if(location.origin===o.origin){const a=zg(o.toString());Up(t,a,()=>a(t.currentUser)),xp(t,h=>a(h))}}const s=Gu("auth");return s&&kp(t,`http://${s}`),t}function qg(){return document.getElementsByTagName("head")?.[0]??document}Tp({loadJS(n){return new Promise((e,t)=>
24{const i=document.createElement("script");i.setAttribute("src",n),i.onload=e,i.onerror=s=>{const o=Ne("internal-error");o.customData=s,t(o)},i.type="text/javascript",i.charset="UTF-8",qg().appendChild(i)})},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="});jg("Browser");var Kg="firebase",Yg="12.6.0";ve(Kg,Yg,"app");const Xg=new Map,Jg={activated:!1,tokenObservers:[]};function De(n){return Xg.get(n)||{...Jg}}const Za={RETRIAL_MIN_WAIT:30*1e3,RETRIAL_MAX_WAIT:960*1e3};class Qg{constructor(e,t,i,s,o){if(this.operation=e,this.retryPolicy=t,this.getWaitDuration=i,this.lowerBound=s,this.upperBound=o,this.pending=null,this.nextErrorWaitInterval=s,s>o)throw new Error("Proactive refresh lower bound greater than upper bound!")}start(){this.nextErrorWaitInterval=this.lowerBound,this.process(!0).catch(()=>{})}stop(){this.pending&&(this.pending.reject("cancelled"),this.pending=null)}isRunning(){return!!this.pending}async process(e){this.stop();try{this.pending=new Hn,this.pending.promise.catch(t=>{}),await Zg(this.getNextRun(e)),this.pending.resolve(),await this.pending.promise,this.pending=new Hn,this.pending.promise.catch(t=>{}),await this.operation(),this.pending.resolve(),await this.pending.promise,this.process(!0).catch(()=>{})}catch(t){this.retryPolicy(t)?this.process(!1).catch(()=>{}):this.stop()}}getNextRun(e){if(e)return this.nextErrorWaitInterval=this.lowerBound,this.getWaitDuration();{const t=this.nextErrorWaitInterval;return this.nextErrorWaitInterval*=2,this.nextErrorWaitInterval>this.upperBound&&(this.nextErrorWaitInterval=this.upperBound),t}}}function Zg(n){return new Promise(e=>{setTimeout(e,n)})}const e_={"already-initialized":"You have already called initializeAppCheck() for FirebaseApp {$appName} with different options. To avoid this error, call initializeAppCheck() with the same options as when it was originally called. This will return the already initialized instance.","use-before-activation":"App Check is being used before initializeAppCheck() is called for FirebaseApp {$appName}. Call initializeAppCheck() before instantiating other Firebase services.","fetch-network-error":"Fetch failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.","fetch-parse-error":"Fetch client could not parse response. Original error: {$originalErrorMessage}.","fetch-status-error":"Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.","storage-open":"Error thrown when opening storage. Original error: {$originalErrorMessage}.","storage-get":"Error thrown when reading from storage. Original error: {$originalErrorMessage}.","storage-set":"Error thrown when writing to storage. Original error: {$originalErrorMessage}.","recaptcha-error":"ReCAPTCHA error.","initial-throttle":"{$httpStatus} error. Attempts allowed again after {$time}",throttled:"Requests throttled due to previous {$httpStatus} error. Attempts allowed again after {$time}"},Bi=new on("appCheck","AppCheck",e_);function Wc(n){if(!De(n).activated)throw Bi.create("use-before-activation",{appName:n.name})}const t_="firebase-app-check-database",n_=1,lr="firebase-app-check-store";let vi=null;function i_(){return vi||(vi=new Promise((n,e)=>{try{const t=indexedDB.open(t_,n_);t.onsuccess=i=>{n(i.target.result)},t.onerror=i=>{e(Bi.create("storage-open",{originalErrorMessage:i.target.error?.message}))},t.onupgradeneeded=i=>{const s=i.target.result;switch(i.oldVersion){case 0:s.createObjectStore(lr,{keyPath:"compositeKey"})}}}catch(t){e(Bi.create("storage-open",{originalErrorMessage:t?.message}))}}),vi)}function s_(n,e){return r_(o_(n),e)}async function r_(n,e){const i=(await i_()).transaction(lr,"readwrite"),o=i.objectStore(lr).put({compositeKey:n,value:e});return new Promise((a,h)=>{o.onsuccess=u=>{a()},i.onerror=u=>{h(Bi.create("storage-set",{originalErrorMessage:u.target.error?.message}))}})}function o_(n){return`${n.options.appId}-${n.name}`}const cr=new Kn("@firebase/app-check");
24function el(n,e){return Ql()?s_(n,e).catch(t=>{cr.warn(`Failed to write token to IndexedDB. Error: ${t}`)}):Promise.resolve()}const a_={error:"UNKNOWN_ERROR"};function l_(n){return Ji.encodeString(JSON.stringify(n),!1)}async function hr(n,e=!1,t=!1){const i=n.app;Wc(i);const s=De(i);let o=s.token,a;if(o&&!On(o)&&(s.token=void 0,o=void 0),!o){const f=await s.cachedTokenPromise;f&&(On(f)?o=f:await el(i,void 0))}if(!e&&o&&On(o))return{token:o.token};let h=!1;try{s.exchangeTokenPromise||(s.exchangeTokenPromise=s.provider.getToken().finally(()=>{s.exchangeTokenPromise=void 0}),h=!0),o=await De(i).exchangeTokenPromise}catch(f){f.code==="appCheck/throttled"||f.code==="appCheck/initial-throttle"?cr.warn(f.message):t&&cr.error(f),a=f}let u;return o?a?On(o)?u={token:o.token,internalError:a}:u=nl(a):(u={token:o.token},s.token=o,await el(i,o)):u=nl(a),h&&d_(i,u),u}async function c_(n){const e=n.app;Wc(e);const{provider:t}=De(e);{const{token:i}=await t.getToken();return{token:i}}}function h_(n,e,t,i){const{app:s}=n,o=De(s),a={next:t,error:i,type:e};if(o.tokenObservers=[...o.tokenObservers,a],o.token&&On(o.token)){const h=o.token;Promise.resolve().then(()=>{t({token:h.token}),tl(n)}).catch(()=>{})}o.cachedTokenPromise.then(()=>tl(n))}function Hc(n,e){const t=De(n),i=t.tokenObservers.filter(s=>s.next!==e);i.length===0&&t.tokenRefresher&&t.tokenRefresher.isRunning()&&t.tokenRefresher.stop(),t.tokenObservers=i}function tl(n){const{app:e}=n,t=De(e);let i=t.tokenRefresher;i||(i=u_(n),t.tokenRefresher=i),!i.isRunning()&&t.isTokenAutoRefreshEnabled&&i.start()}function u_(n){const{app:e}=n;return new Qg(async()=>{const t=De(e);let i;if(t.token?i=await hr(n,!0):i=await hr(n),i.error)throw i.error;if(i.internalError)throw i.internalError},()=>!0,()=>{const t=De(e);if(t.token){let i=t.token.issuedAtTimeMillis+(t.token.expireTimeMillis-t.token.issuedAtTimeMillis)*.5+3e5;const s=t.token.expireTimeMillis-300*1e3;return i=Math.min(i,s),Math.max(0,i-Date.now())}else return 0},Za.RETRIAL_MIN_WAIT,Za.RETRIAL_MAX_WAIT)}function d_(n,e){const t=De(n).tokenObservers;for(const i of t)try{i.type==="EXTERNAL"&&e.error!=null?i.error(e.error):i.next(e)}catch{}}function On(n){return n.expireTimeMillis-Date.now()>0}function nl(n){return{token:l_(a_),error:n}}class f_{constructor(e,t){this.app=e,this.heartbeatServiceProvider=t}_delete(){const{tokenObservers:e}=De(this.app);for(const t of e)Hc(this.app,t.next);return Promise.resolve()}}function p_(n,e){return new f_(n,e)}function g_(n){return{getToken:e=>hr(n,e),getLimitedUseToken:()=>c_(n),addTokenListener:e=>h_(n,"INTERNAL",e),removeTokenListener:e=>Hc(n.app,e)}}const __="@firebase/app-check",m_="0.11.0",y_="app-check",il="app-check-internal";function v_(){We(new Oe(y_,n=>{const e=n.getProvider("app").getImmediate(),t=n.getProvider("heartbeat");return p_(e,t)},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((n,e,t)=>{n.getProvider(il).initialize()})),We(new Oe(il,n=>{const e=n.getProvider("app-check").getImmediate();return g_(e)},"PUBLIC").setInstantiationMode("EXPLICIT")),ve(__,m_)}v_();var sl={};const rl="@firebase/database",ol="1.1.0";let jc="";function w_(n){jc=n}class E_{constructor(e){this.domStorage_=e,this.prefix_="firebase:"}set(e,t){t==null?this.domStorage_.removeItem(this.prefixedName_(e)):this.domStorage_.setItem(this.prefixedName_(e),re(t))}get(e){const t=this.domStorage_.getItem(this.prefixedName_(e));return t==null?null:jn(t)}remove(e){this.domStorage_.removeItem(this.prefixedName_(e))}prefixedName_(e){return this.prefix_+e}toString(){return this.domStorage_.toString()}}class I_{constructor(){this.cache_={},this.isInMemoryStorage=!0}set(e,t){t==null?delete this.cache_[e]:this.cache_[e]=t}get(e){return et(this.cache_,e)?this.cache_[e]:null}remove(e){delete this.cache_[e]}}const $c=function(n){try{if(typeof window<"u"&&typeof window[n]<"u"){const e=window[n];return e.setItem("firebase:sentinel","cache"),e.removeItem("firebase:sentinel"),new E_(e)}}catch{}return new I_},Rt=$c("localStorage"),T_=$c("sessionStorage");const Jt=new Kn("@firebase/database"),S_=(function(){let n=1;return function(){return n++}})(),Gc=function(n){const e=ud(n),t=new od;t.update(e);const i=t.digest();return Ji.encodeByteArray(i)},Zn=function(...n){let e="";for(let t=0;t<n.length;t++){const i=n[t];Array.isArray(i)||i&&typeof i=="object"&&typeof i.length=="number"?e+=Zn.apply(null,i):typeof i=="object"?e+=re(i):e+=i,e+=" "}return e};let Fn=null,al=!0;const C_=function(n,e){b(!0,"Can't turn on custom loggers persistently."),Jt.logLevel=B.VERBOSE,Fn=Jt.log.bind(Jt)},le=function(...n){if(al===!0&&(al=!1,Fn===null&&T_.get("logging_enabled")===!0&&C_()),Fn){const e=Zn.apply(null,n);Fn(e)}},ei=function(n){return function(...e){le(n,...e)}},ur=function(...n){const e="FIREBASE INTERNAL ERROR: "+Zn(...n);Jt.error(e)},Mt=function(...n){const e=`FIREBASE FATAL ERROR: ${Zn(...n)}`;throw Jt.error(e),new Error(e)},we=function(...n){const e="FIREBASE WARNING: "+Zn(...n);Jt.warn(e)},A_=function(){typeof window<"u"&&window.location&&window.location.protocol&&window.location.protocol.indexOf("https:")!==-1&&we("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().")},zc=function(n){return typeof n=="number"&&(n!==n||n===Number.POSITIVE_INFINITY||n===Number.NEGATIVE_INFINITY)},b_=function(n){if(document.readyState==="complete")n();else{let e=!1;const t=function(){if(!document.body){setTimeout(t,Math.floor(10));return}e||(e=!0,n())};document.addEventListener?(document.addEventListener("DOMContentLoaded",t,!1),window.addEventListener("load",t,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",()=>{document.readyState==="complete"&&t()}),window.attachEvent("onload",t))}},nn="[MIN_NAME]",Lt="[MAX_NAME]",cn=function(n,e){if(n===e)return 0;if(n===nn||e===Lt)return-1;if(e===nn||n===Lt)return 1;{const t=ll(n),i=ll(e);return t!==null?i!==null?t-i===0?n.length-e.length:t-i:-1:i!==null?1:n<e?-1:1}},R_=function(n,e){return n===e?0:n<e?-1:1},Rn=function(n,e){if(e&&n in e)return e[n];throw new Error("Missing required key ("+n+") in object: "+re(e))},Br=function(n){if(typeof n!="object"||n===null)return re(n);const e=[];for(const i in n)e.push(i);e.sort();let t="{";for(let i=0;i<e.length;i++)i!==0&&(t+=","),t+=re(e[i]),t+=":",t+=Br(n[e[i]]);return t+="}",t},qc=function(n,e){const t=n.length;if(t<=e)return[n];const i=[];for(let s=0;s<t;s+=e)s+e>t?i.push(n.substring(s,t)):i.push(n.substring(s,s+e));return i};function Te(n,e){for(const t in n)n.hasOwnProperty(t)&&e(t,n[t])}const Kc=function(n){b(!zc(n),"Invalid JSON number");const e=11,t=52,i=(1<<e-1)-1;let s,o,a,h,u;n===0?(o=0,a=0,s=1/n===-1/0?1:0):(s=n<0,n=Math.abs(n),n>=Math.pow(2,1-i)?(h=Math.min(Math.floor(Math.log(n)/Math.LN2),i),o=h+i,a=Math.round(n*Math.pow(2,t-h)-Math.pow(2,t))):(o=0,a=Math.round(n/Math.pow(2,1-i-t))));const f=[];for(u=t;u;u-=1)f.push(a%2?1:0),a=Math.floor(a/2);for(u=e;u;u-=1)f.push(o%2?1:0),o=Math.floor(o/2);f.push(s?1:0),f.reverse();const E=f.join("");let y="";for(u=0;
24u<64;u+=8){let S=parseInt(E.substr(u,8),2).toString(16);S.length===1&&(S="0"+S),y=y+S}return y.toLowerCase()},k_=function(){return!!(typeof window=="object"&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href))},N_=function(){return typeof Windows=="object"&&typeof Windows.UI=="object"},P_=new RegExp("^-?(0*)\\d{1,10}$"),O_=-2147483648,D_=2147483647,ll=function(n){if(P_.test(n)){const e=Number(n);if(e>=O_&&e<=D_)return e}return null},ti=function(n){try{n()}catch(e){setTimeout(()=>{const t=e.stack||"";throw we("Exception was thrown by user callback.",t),e},Math.floor(0))}},M_=function(){return(typeof window=="object"&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)>=0},Vn=function(n,e){const t=setTimeout(n,e);return typeof t=="number"&&typeof Deno<"u"&&Deno.unrefTimer?Deno.unrefTimer(t):typeof t=="object"&&t.unref&&t.unref(),t};class L_{constructor(e,t){this.appCheckProvider=t,this.appName=e.name,ye(e)&&e.settings.appCheckToken&&(this.serverAppAppCheckToken=e.settings.appCheckToken),this.appCheck=t?.getImmediate({optional:!0}),this.appCheck||t?.get().then(i=>this.appCheck=i)}getToken(e){if(this.serverAppAppCheckToken){if(e)throw new Error("Attempted reuse of `FirebaseServerApp.appCheckToken` after previous usage failed.");return Promise.resolve({token:this.serverAppAppCheckToken})}return this.appCheck?this.appCheck.getToken(e):new Promise((t,i)=>{setTimeout(()=>{this.appCheck?this.getToken(e).then(t,i):t(null)},0)})}addTokenChangeListener(e){this.appCheckProvider?.get().then(t=>t.addTokenListener(e))}notifyForInvalidToken(){we(`Provided AppCheck credentials for the app named "${this.appName}" are invalid. This usually indicates your app was not initialized correctly.`)}}class x_{constructor(e,t,i){this.appName_=e,this.firebaseOptions_=t,this.authProvider_=i,this.auth_=null,this.auth_=i.getImmediate({optional:!0}),this.auth_||i.onInit(s=>this.auth_=s)}getToken(e){return this.auth_?this.auth_.getToken(e).catch(t=>t&&t.code==="auth/token-not-initialized"?(le("Got auth/token-not-initialized error. Treating as null token."),null):Promise.reject(t)):new Promise((t,i)=>{setTimeout(()=>{this.auth_?this.getToken(e).then(t,i):t(null)},0)})}addTokenChangeListener(e){this.auth_?this.auth_.addAuthTokenListener(e):this.authProvider_.get().then(t=>t.addAuthTokenListener(e))}removeTokenChangeListener(e){this.authProvider_.get().then(t=>t.removeAuthTokenListener(e))}notifyForInvalidToken(){let e='Provided authentication credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.firebaseOptions_?e+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.firebaseOptions_?e+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':e+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',we(e)}}const Wr="5",Yc="v",Xc="s",Jc="r",Qc="f",Zc=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,eh="ls",th="p",dr="ac",nh="websocket",ih="long_polling";class U_{constructor(e,t,i,s,o=!1,a="",h=!1,u=!1,f=null){this.secure=t,this.namespace=i,this.webSocketOnly=s,this.nodeAdmin=o,this.persistenceKey=a,this.includeNamespaceInQueryParams=h,this.isUsingEmulator=u,this.emulatorOptions=f,this._host=e.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=Rt.get("host:"+e)||this._host}isCacheableHost(){return this.internalHost.substr(0,2)==="s-"}isCustomHost(){return this._domain!=="firebaseio.com"&&this._domain!=="firebaseio-demo.com"}get host(){return this._host}set host(e){e!==this.internalHost&&(this.internalHost=e,this.isCacheableHost()&&Rt.set("host:"+this._host,this.internalHost))}toString(){let e=this.toURLString();return this.persistenceKey&&(e+="<"+this.persistenceKey+">"),e}toURLString(){const e=this.secure?"https://":"http://",t=this.includeNamespaceInQueryParams?`?ns=${this.namespace}`:"";return`${e}${this.host}/${t}`}}function F_(n){return n.host!==n.internalHost||n.isCustomHost()||n.includeNamespaceInQueryParams}function sh(n,e,t){b(typeof e=="string","typeof type must == string"),b(typeof t=="object","typeof params must == object");let i;if(e===nh)i=(n.secure?"wss://":"ws://")+n.internalHost+"/.ws?";else if(e===ih)i=(n.secure?"https://":"http://")+n.internalHost+"/.lp?";else throw new Error("Unknown connection type: "+e);F_(n)&&(t.ns=n.namespace);const s=[];return Te(t,(o,a)=>{s.push(o+"="+a)}),i+s.join("&")}class V_{constructor(){this.counters_={}}incrementCounter(e,t=1){et(this.counters_,e)||(this.counters_[e]=0),this.counters_[e]+=t}get(){return Vu(this.counters_)}}const Gs={},zs={};function Hr(n){const e=n.toString();return Gs[e]||(Gs[e]=new V_),Gs[e]}function B_(n,e){const t=n.toString();
24return zs[t]||(zs[t]=e()),zs[t]}class W_{constructor(e){this.onMessage_=e,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}closeAfter(e,t){this.closeAfterResponse=e,this.onClose=t,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)}handleResponse(e,t){for(this.pendingResponses[e]=t;this.pendingResponses[this.currentResponseNum];){const i=this.pendingResponses[this.currentResponseNum];delete this.pendingResponses[this.currentResponseNum];for(let s=0;s<i.length;++s)i[s]&&ti(()=>{this.onMessage_(i[s])});if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}}const cl="start",H_="close",j_="pLPCommand",$_="pRTLPCB",rh="id",oh="pw",ah="ser",G_="cb",z_="seg",q_="ts",K_="d",Y_="dframe",lh=1870,ch=30,X_=lh-ch,J_=25e3,Q_=3e4;class Gt{constructor(e,t,i,s,o,a,h){this.connId=e,this.repoInfo=t,this.applicationId=i,this.appCheckToken=s,this.authToken=o,this.transportSessionId=a,this.lastSessionId=h,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=ei(e),this.stats_=Hr(t),this.urlFn=u=>(this.appCheckToken&&(u[dr]=this.appCheckToken),sh(t,ih,u))}open(e,t){this.curSegmentNum=0,this.onDisconnect_=t,this.myPacketOrderer=new W_(e),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null},Math.floor(Q_)),b_(()=>{if(this.isClosed_)return;this.scriptTagHolder=new jr((...o)=>{const[a,h,u,f,E]=o;if(this.incrementIncomingBytes_(o),!!this.scriptTagHolder)if(this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,a===cl)this.id=h,this.password=u;else if(a===H_)h?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(h,()=>{this.onClosed_()})):this.onClosed_();else throw new Error("Unrecognized command received: "+a)},(...o)=>{const[a,h]=o;this.incrementIncomingBytes_(o),this.myPacketOrderer.handleResponse(a,h)},()=>{this.onClosed_()},this.urlFn);const i={};i[cl]="t",i[ah]=Math.floor(Math.random()*1e8),this.scriptTagHolder.uniqueCallbackIdentifier&&(i[G_]=this.scriptTagHolder.uniqueCallbackIdentifier),i[Yc]=Wr,this.transportSessionId&&(i[Xc]=this.transportSessionId),this.lastSessionId&&(i[eh]=this.lastSessionId),this.applicationId&&(i[th]=this.applicationId),this.appCheckToken&&(i[dr]=this.appCheckToken),typeof location<"u"&&location.hostname&&Zc.test(location.hostname)&&(i[Jc]=Qc);const s=this.urlFn(i);this.log_("Connecting via long-poll to "+s),this.scriptTagHolder.addTag(s,()=>{})})}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){Gt.forceAllow_=!0}static forceDisallow(){Gt.forceDisallow_=!0}static isAvailable(){return Gt.forceAllow_?!0:!Gt.forceDisallow_&&typeof document<"u"&&document.createElement!=null&&!k_()&&!N_()}markConnectionHealthy(){}shutdown_(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)}onClosed_(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))}close(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())}send(e){const t=re(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const i=zl(t),s=qc(i,X_);for(let o=0;o<s.length;o++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,s.length,s[o]),this.curSegmentNum++}addDisconnectPingFrame(e,t){this.myDisconnFrame=document.createElement("iframe");const i={};i[Y_]="t",i[rh]=e,i[oh]=t,this.myDisconnFrame.src=this.urlFn(i),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}incrementIncomingBytes_(e){const t=re(e).length;this.bytesReceived+=t,this.stats_.incrementCounter("bytes_received",t)}}class jr{constructor(e,t,i,s){this.onDisconnect=i,this.urlFn=s,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(Math.random()*1e8),this.sendNewPolls=!0;{this.uniqueCallbackIdentifier=S_(),window[j_+this.uniqueCallbackIdentifier]=e,window[$_+this.uniqueCallbackIdentifier]=t,this.myIFrame=jr.createI
24Frame_();let o="";this.myIFrame.src&&this.myIFrame.src.substr(0,11)==="javascript:"&&(o='<script>document.domain="'+document.domain+'";<\/script>');const a="<html><body>"+o+"</body></html>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(a),this.myIFrame.doc.close()}catch(h){le("frame writing exception"),h.stack&&le(h.stack),le(h)}}}static createIFrame_(){const e=document.createElement("iframe");if(e.style.display="none",document.body){document.body.appendChild(e);try{e.contentWindow.document||le("No IE domain setting required")}catch{const i=document.domain;e.src="javascript:void((function(){document.open();document.domain='"+i+"';document.close();})())"}}else throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";return e.contentDocument?e.doc=e.contentDocument:e.contentWindow?e.doc=e.contentWindow.document:e.document&&(e.doc=e.document),e}close(){this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.textContent="",setTimeout(()=>{this.myIFrame!==null&&(document.body.removeChild(this.myIFrame),this.myIFrame=null)},Math.floor(0)));const e=this.onDisconnect;e&&(this.onDisconnect=null,e())}startLongPoll(e,t){for(this.myID=e,this.myPW=t,this.alive=!0;this.newRequest_(););}newRequest_(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(this.pendingSegs.length>0?2:1)){this.currentSerial++;const e={};e[rh]=this.myID,e[oh]=this.myPW,e[ah]=this.currentSerial;let t=this.urlFn(e),i="",s=0;for(;this.pendingSegs.length>0&&this.pendingSegs[0].d.length+ch+i.length<=lh;){const a=this.pendingSegs.shift();i=i+"&"+z_+s+"="+a.seg+"&"+q_+s+"="+a.ts+"&"+K_+s+"="+a.d,s++}return t=t+i,this.addLongPollTag_(t,this.currentSerial),!0}else return!1}enqueueSegment(e,t,i){this.pendingSegs.push({seg:e,ts:t,d:i}),this.alive&&this.newRequest_()}addLongPollTag_(e,t){this.outstandingRequests.add(t);const i=()=>{this.outstandingRequests.delete(t),this.newRequest_()},s=setTimeout(i,Math.floor(J_)),o=()=>{clearTimeout(s),i()};this.addTag(e,o)}addTag(e,t){setTimeout(()=>{try{if(!this.sendNewPolls)return;const i=this.myIFrame.doc.createElement("script");i.type="text/javascript",i.async=!0,i.src=e,i.onload=i.onreadystatechange=function(){const s=i.readyState;(!s||s==="loaded"||s==="complete")&&(i.onload=i.onreadystatechange=null,i.parentNode&&i.parentNode.removeChild(i),t())},i.onerror=()=>{le("Long-poll script failed to load: "+e),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(i)}catch{}},Math.floor(1))}}const Z_=16384,em=45e3;let Wi=null;typeof MozWebSocket<"u"?Wi=MozWebSocket:typeof WebSocket<"u"&&(Wi=WebSocket);class Ce{constructor(e,t,i,s,o,a,h){this.connId=e,this.applicationId=i,this.appCheckToken=s,this.authToken=o,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=ei(this.connId),this.stats_=Hr(t),this.connURL=Ce.connectionURL_(t,a,h,s,i),this.nodeAdmin=t.nodeAdmin}static connectionURL_(e,t,i,s,o){const a={};return a[Yc]=Wr,typeof location<"u"&&location.hostname&&Zc.test(location.hostname)&&(a[Jc]=Qc),t&&(a[Xc]=t),i&&(a[eh]=i),s&&(a[dr]=s),o&&(a[th]=o),sh(e,nh,a)}open(e,t){this.onDisconnect=t,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,Rt.set("previous_websocket_failure",!0);try{let i;Zu(),this.mySock=new Wi(this.connURL,[],i)}catch(i){this.log_("Error instantiating WebSocket.");const s=i.message||i.data;s&&this.log_(s),this.onClosed_();return}this.mySock.onopen=()=>{this.log_("Websocket connected."),this.everConnected_=!0},this.mySock.onclose=()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=i=>{this.handleIncomingFrame(i)},this.mySock.onerror=i=>{this.log_("WebSocket error. Closing connection.");const s=i.message||i.data;s&&this.log_(s),this.onClosed_()}}start(){}static forceDisallow(){Ce.forceDisallow_=!0}static isAvailable(){let e=!1;if(typeof navigator<"u"&&navigator.userAgent){const t=/Android ([0-9]{0,}\.[0-9]{0,})/,i=navigator.userAgent.match(t);i&&i.length>1&&parseFloat(i[1])<4.4&&(e=!0)}return!e&&Wi!==null&&!Ce.forceDisallow_}static previouslyFailed(){return Rt.isInMemoryStorage||Rt.get("previous_websocket_failure")===!0}markConnectionHealthy(){Rt.remove("previous_websocket_failure")}appendFrame_(e){if(this.frames.push(e),this.frames.length===this.totalFrames){const t=this.frames.join("");this.frames=null;const i=jn(t);this.onMessage(i)}}handleNewFrameCount_(e){this.totalFrames=e,this.frames=[]}extractFrameCount_(e){if(b(this.frames===null,"We already have a frame buffer"),e.length<=6){const t=Number(e);if(!isNaN(t))return this.handleNewFrameCount_(t),null}return this.handleNewFrameCount_(1),e}handleIncomingFrame(e){if(this.mySock===null)return;const t=e.data;if(this.bytesReceived+=t.length,this.stats_.incrementCounter("bytes_received",t.length),this.resetKeepAlive(),this.frames!==null)this.appendFrame_(t);else{const i=this.extractFrameCount_(t);i!==null&&this.appendFrame_(i)}}send(e){this.resetKeepAlive();const t=re(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const i=qc(t,Z_);i.length>1&&this.sendString_(String(i.length));for(let s=0;s<i.length;s++)this.sendString_(i[s])}shutdown_(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)}onClosed_(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))}close(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())}resetKeepAlive(){clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(()=>{this.mySock&&this.sendString_("0"),this.resetKeepAlive()},Math.floor(em))}sendString_(e){try{this.mySock.send(e)}catch(t){this.log_("Exception thrown from WebSocket.send():",t.message||t.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}}}Ce.responsesRequiredToBeHealthy=2;Ce.healthyTimeout=3e4;class zn{static get ALL_TRANSPORTS(){return[Gt,Ce]}static get IS_TRANSPORT_INITIALIZED(){return this.globalTransportInitialized_}constructor(e){this.initTransports_(e)}initTransports_(e){const t=Ce&&Ce.isAvailable();let i=t&&!Ce.previouslyFailed();if(e.webSocketOnly&&(t||we("wss:// URL used, but browser isn't known to support websockets. Trying anyway."),i=!0),i)this.transports_=[Ce];else{const s=this.transports_=[];for(const o of zn.ALL_TRANSPORTS)o&&o.isAvailable()&&s.push(o);zn.globalTransportInitialized_=!0}}initialTransport(){if(this.transports_.length>0)return this.transports_[0];throw new Error("No transports available")}upgradeTransport(){return this.transports_.length>1?this.transports_[1]:null}}zn.globalTransportInitialized_=!1;const tm=6e4,nm=5e3,im=10*1024,sm=100*1024,qs="t",hl="d",rm="s",ul="r",om="e",dl="o",fl="a",pl="n",gl="p",am="h";class lm{constructor(e,t,i,s,o,a,h,u,f,E){this.id=e,this.repoInfo_=t,this.applicationId_=i,this.appCheckToken_=s,this.authToken_=o,this.onMessage_=a,this.onReady_=h,this.onDisconnect_=u,this.onKill_=f,this.lastSessionId=E,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=ei("c:"+this.id+":"),this.transportManager_=new zn(t),this.log_("Connection created"),this.start_()}start_(){const e=this.transportManager_.initialTransport();this.conn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,null,this.lastSessionId),this.primaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.conn_),i=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout(()=>{this.conn_&&this.conn_.open(t,i)},Math.floor(0));const s=e.healthyTimeout||0;s>0&&(this.healthyTimeout_=Vn(()=>{this.healthyTimeout_=null,this.isHealthy_||(this.conn_&&this.conn_.bytesReceived>sm?(this.log_("Connection exceeded healthy timeout but has received "+this.conn_.bytesReceived+" bytes. Marking connection healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()):this.conn_&&this.conn_.bytesSent>im?this.log_("Connection exceeded healthy timeout but has sent "+this.conn_.bytesSent+" bytes. Leaving connection alive."):(this.log_("Closing unhealthy connection after timeout."),this.close()))},Math.floor(s)))}nextTransportId_(){return"c:"+this.id+":"+this.connectionCount++}disconnReceiver_(e){return t=>{e===this.conn_?this.onConnectionLost_(t):e===this.secondaryConn_?(this.log_("Secondary connection lost."),this.onSecondaryConnectionLost_()):this.log_("closing an old connection")}}connReceiver_(e){return t=>{this.state_!==2&&(e===this.rx_?this.onPrimaryMessageReceived_(t):e===this.secondaryConn_?this.onSecondaryMessageReceived_(t):this.log_("message on old connection"))}}sendRequest(e){const t={t:"d",d:e};this.sendData_(t)}tryCleanupConnection(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)}onSecondaryControl_(e){if(qs in e){const t=e[qs];t===fl?this.upgradeIfSecondaryHealthy_():t===ul?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),(this.tx_===this.secondaryConn_||this.rx_===this.secondaryConn_)&&this.close()):t===dl&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}}onSecondaryMessageReceived_(e){const t=Rn("t",e),i=Rn("d",e);if(t==="c")this.onSecondaryControl_(i);else if(t==="d")this.pendingDataMessages.push(i);else throw new Error("Unknown protocol layer: "+t)}upgradeIfSecondaryHealthy_(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t
vendor: 17,479 bytes, lines 24-25
24:"c",d:{t:gl,d:{}}}))}proceedWithUpgrade_(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:fl,d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:pl,d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()}onPrimaryMessageReceived_(e){const t=Rn("t",e),i=Rn("d",e);t==="c"?this.onControl_(i):t==="d"&&this.onDataMessage_(i)}onDataMessage_(e){this.onPrimaryResponse_(),this.onMessage_(e)}onPrimaryResponse_(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))}onControl_(e){const t=Rn(qs,e);if(hl in e){const i=e[hl];if(t===am){const s={...i};this.repoInfo_.isUsingEmulator&&(s.h=this.repoInfo_.host),this.onHandshake_(s)}else if(t===pl){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(let s=0;s<this.pendingDataMessages.length;++s)this.onDataMessage_(this.pendingDataMessages[s]);this.pendingDataMessages=[],this.tryCleanupConnection()}else t===rm?this.onConnectionShutdown_(i):t===ul?this.onReset_(i):t===om?ur("Server Error: "+i):t===dl?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):ur("Unknown control packet command: "+t)}}onHandshake_(e){const t=e.ts,i=e.v,s=e.h;this.sessionId=e.s,this.repoInfo_.host=s,this.state_===0&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,t),Wr!==i&&we("Protocol version mismatch detected"),this.tryStartUpgrade_())}tryStartUpgrade_(){const e=this.transportManager_.upgradeTransport();e&&this.startUpgrade_(e)}startUpgrade_(e){this.secondaryConn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,this.sessionId),this.secondaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.secondaryConn_),i=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(t,i),Vn(()=>{this.secondaryConn_&&(this.log_("Timed out trying to upgrade."),this.secondaryConn_.close())},Math.floor(tm))}onReset_(e){this.log_("Reset packet received. New host: "+e),this.repoInfo_.host=e,this.state_===1?this.close():(this.closeConnections_(),this.start_())}onConnectionEstablished_(e,t){this.log_("Realtime connection established."),this.conn_=e,this.state_=1,this.onReady_&&(this.onReady_(t,this.sessionId),this.onReady_=null),this.primaryResponsesRequired_===0?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):Vn(()=>{this.sendPingOnPrimaryIfNecessary_()},Math.floor(nm))}sendPingOnPrimaryIfNecessary_(){!this.isHealthy_&&this.state_===1&&(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:gl,d:{}}}))}onSecondaryConnectionLost_(){const e=this.secondaryConn_;this.secondaryConn_=null,(this.tx_===e||this.rx_===e)&&this.close()}onConnectionLost_(e){this.conn_=null,!e&&this.state_===0?(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(Rt.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)):this.state_===1&&this.log_("Realtime connection lost."),this.close()}onConnectionShutdown_(e){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(e),this.onKill_=null),this.onDisconnect_=null,this.close()}sendData_(e){if(this.state_!==1)throw"Connection is not connected";this.tx_.send(e)}close(){this.state_!==2&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))}closeConnections_(){this.log_("Shutting down all connections"),this.conn_&&(this.conn_.close(),this.conn_=null),this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)}}class hh{put(e,t,i,s){}merge(e,t,i,s){}refreshAuthToken(e){}refreshAppCheckToken(e){}onDisconnectPut(e,t,i){}onDisconnectMerge(e,t,i){}onDisconnectCancel(e,t){}reportStats(e){}}class uh{constructor(e){this.allowedEvents_=e,this.listeners_={},b(Array.isArray(e)&&e.length>0,"Requires a non-empty array")}trigger(e,...t){if(Array.isArray(this.listeners_[e])){const i=[...this.listeners_[e]];for(let s=0;s<i.length;s++)i[s].callback.apply(i[s].context,t)}}on(e,t,i){this.validateEventType_(e),this.listeners_[e]=this.listeners_[e]||[],this.listeners_[e].push({callback:t,context:i});const s=this.getInitialEvent(e);s&&t.apply(i,s)}off(e,t,i){this.validateEventType_(e);const s=this.listeners_[e]||[];for(let o=0;o<s.length;o++)if(s[o].callback===t&&(!i||i===s[o].context)){s.splice(o,1);return}}validateEventType_(e){b(this.allowedEvents_.find(t=>t===e),"Unknown event: "+e)}}class Hi extends uh{static getInstance(){return new Hi}constructor(){super(["online"]),this.online_=!0,typeof window<"u"&&typeof window.addEventListener<"u"&&!Sr()&&(window.addEventListener("online",()=>{this.online_||(this.online_=!0,this.trigger("online",!0))},!1),window.addEventListener("offline",()=>{this.online_&&(this.online_=!1,this.trigger("online",!1))},!1))}getInitialEvent(e){return b(e==="online","Unknown event type: "+e),[this.online_]}currentlyOnline(){return this.online_}}const _l=32,ml=768;class q{constructor(e,t){if(t===void 0){this.pieces_=e.split("/");let i=0;for(let s=0;s<this.pieces_.length;s++)this.pieces_[s].length>0&&(this.pieces_[i]=this.pieces_[s],i++);this.pieces_.length=i,this.pieceNum_=0}else this.pieces_=e,this.pieceNum_=t}toString(){let e="";for(let t=this.pieceNum_;t<this.pieces_.length;t++)this.pieces_[t]!==""&&(e+="/"+this.pieces_[t]);return e||"/"}}function H(){return new q("")}function x(n){return n.pieceNum_>=n.pieces_.length?null:n.pieces_[n.pieceNum_]}function mt(n){return n.pieces_.length-n.pieceNum_}function z(n){let e=n.pieceNum_;return e<n.pieces_.length&&e++,new q(n.pieces_,e)}function dh(n){return n.pieceNum_<n.pieces_.length?n.pieces_[n.pieces_.length-1]:null}function cm(n){let e="";for(let t=n.pieceNum_;t<n.pieces_.length;t++)n.pieces_[t]!==""&&(e+="/"+encodeURIComponent(String(n.pieces_[t])));return e||"/"}function fh(n,e=0){return n.pieces_.slice(n.pieceNum_+e)}function ph(n){if(n.pieceNum_>=n.pieces_.length)return null;const e=[];for(let t=n.pieceNum_;t<n.pieces_.length-1;t++)e.push(n.pieces_[t]);return new q(e,0)}function se(n,e){const t=[];for(let i=n.pieceNum_;i<n.pieces_.length;i++)t.push(n.pieces_[i]);if(e instanceof q)for(let i=e.pieceNum_;i<e.pieces_.length;i++)t.push(e.pieces_[i]);else{const i=e.split("/");for(let s=0;s<i.length;s++)i[s].length>0&&t.push(i[s])}return new q(t,0)}function M(n){return n.pieceNum_>=n.pieces_.length}function Ie(n,e){const t=x(n),i=x(e);if(t===null)return e;if(t===i)return Ie(z(n),z(e));throw new Error("INTERNAL ERROR: innerPath ("+e+") is not within outerPath ("+n+")")}function gh(n,e){if(mt(n)!==mt(e))return!1;for(let t=n.pieceNum_,i=e.pieceNum_;t<=n.pieces_.length;t++,i++)if(n.pieces_[t]!==e.pieces_[i])return!1;return!0}function Re(n,e){let t=n.pieceNum_,i=e.pieceNum_;if(mt(n)>mt(e))return!1;for(;t<n.pieces_.length;){if(n.pieces_[t]!==e.pieces_[i])return!1;++t,++i}return!0}class hm{constructor(e,t){this.errorPrefix_=t,this.parts_=fh(e,0),this.byteLength_=Math.max(1,this.parts_.length);for(let i=0;i<this.parts_.length;i++)this.byteLength_+=Zi(this.parts_[i]);_h(this)}}function um(n,e){n.parts_.length>0&&(n.byteLength_+=1),n.parts_.push(e),n.byteLength_+=Zi(e),_h(n)}function dm(n){const e=n.parts_.pop();n.byteLength_-=Zi(e),n.parts_.length>0&&(n.byteLength_-=1)}function _h(n){if(n.byteLength_>ml)throw new Error(n.errorPrefix_+"has a key path longer than "+ml+" bytes ("+n.byteLength_+").");if(n.parts_.length>_l)throw new Error(n.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+_l+") or object contains a cycle "+Ct(n))}function Ct(n){return n.parts_.length===0?"":"in property '"+n.parts_.join(".")+"'"}class $r extends uh{static getInstance(){return new $r}constructor(){super(["visible"]);let e,t;typeof document<"u"&&typeof document.addEventListener<"u"&&(typeof document.hidden<"u"?(t="visibilitychange",e="hidden"):typeof document.mozHidden<"u"?(t="mozvisibilitychange",e="mozHidden"):typeof document.msHidden<"u"?(t="msvisibilitychange",e="msHidden"):typeof document.webkitHidden<"u"&&(t="webkitvisibilitychange",e="webkitHidden")),this.visible_=!0,t&&document.addEventListener(t,()=>{const i=!document[e];i!==this.visible_&&(this.visible_=i,this.trigger("visible",i))},!1)}getInitialEvent(e){return b(e==="visible","Unknown event type: "+e),[this.visible_]}}const kn=1e3,fm=300*1e3,yl=30*1e3,pm=1.3,gm=3e4,_m="server_kill",vl=3;class Je extends hh{constructor(e,t,i,s,o,a,h,u){if(super(),this.repoInfo_=e,this.applicationId_=t,this.onDataUpdate_=i,this.onConnectStatus_=s,this.onServerInfoUpdate_=o,this.authTokenProvider_=a,this.appCheckTokenProvider_=h,this.authOverride_=u,this.id=Je.nextPersistentConnectionId_++,this.log_=ei("p:"+this.id+":"),this.interruptReasons_={},this.listens=new Map,this.outstandingPuts_=[],this.outstandingGets_=[],this.outstandingPutCount_=0,this.outstandingGetCount_=0,this.onDisconnectRequestQueue_=[],this.connected_=!1,this.reconnectDelay_=kn,this.maxReconnectDelay_=fm,this.securityDebugCallback_=null,this.lastSessionId=null,this.establishConnectionTimer_=null,this.visible_=!1,this.requestCBHash_={},this.requestNumber_=0,this.realtime_=null,this.authToken_=null,this.appCheckToken_=null,this.forceTokenRefresh_=!1,this.invalidAuthTokenCount_=0,this.invalidAppCheckTokenCount_=0,this.firstConnection_=!0,this.lastConnectionAttemptTime_=null,this.lastConnectionEstablishedTime_=null,u)throw new Error("Auth override specified in options, but not supported on non Node.js platforms");$r.getInstance().on("visible",this.onVisible_,this),e.host.indexOf("fblocal")===-1&&Hi.getInstance().on("online",this.onOnline_,this)}sendRequest(e,t,i){const s=++this.requestNumber_,o={r:s,a:e,b:t};this.log_(re(o)),b(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(o),i&&(this.requestCBHash_[s]=i)}get(e){this.initConnection_();const t=new Hn,s={action:"g",request:{p:e._path.toString(),q:e._queryObject},onComplete:a=>{const h=a.d;a.s==="ok"?t.resolve(h):t.reject(h)}};this.outstandingGets_.push(s),this.outstandingGetCount_++;const o=this.outstandingGets_.length-1;return this.connected_&&this.sendGet_(o),t.promise}listen(e,t,i,s){this.initConnection_();const o=e._queryIdentifier,a=e._path.toString();this.log_("Listen called for "+a+" "+o),this.listens.has(a)||this.listens.set(a,new Map),b(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),b(!this.listens.get(a).has(o),"listen() called twice for same path/queryId.");const h={onComplete:s,hashFn:t,query:e,tag:i};this.listens.get(a).set(o,h),this.connected_&&this.sendListen_(h)}sendGet_(e){const t=this.outstandingGets_[e];this.sendRequest("g",t.request,i=>{delete this.outstandingGets_[e],this.outstandingGetCount_--,this.outstandingGetCount_===0&&(this.outstandingGets_=[]),t.onComplete&&t.onComplete(i)})}sendListen_(e){const t=e.query,i=t._path.toString(),s=t._queryIdentifier;this.log_("Listen on "+i+" for "+s);const o={p:i},a="q";e.tag&&(o.q=t._queryObject,o.t=e.tag),o.h=e.hashFn(),this.sendRequest(a,o,h=>{const u=h.d,f=h.s;Je.warnOnListenWarnings_(u,t),(this.listens.get(i)&&this.listens.get(i).get(s))===e&&(this.log_("listen response",h),f!=="ok"&&this.removeListen_(i,s),e.onComplete&&e.onComplete(f,u))})}static warnOnListenWarnings_(e,t){if(e&&typeof e=="object"&&et(e,"w")){const i=Zt(e,"w");if(Array.isArray(i)&&~i.indexOf("no_index")){const s='".indexOn": "'+t._queryParams.getIndex().toString()+'"',o=t._path.toString();we(`Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ${s} at ${o} to your security rules for better performance.`)}}}refreshAuthToken(e){this.authToken_=e,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},()=>{}),this.reduceReconnectDelayIfAdminCredential_(e)}reduceReconnectDelayIfAdminCredential_(e){(e&&e.length===40||rd(e))&&(this.log_("Admin auth credential detected. Reducing max reconnect time."),this.maxReconnectDelay_=yl)}refreshAppCheckToken(e){this.appCheckToken_=e,this.log_("App check token refreshed"),this.appCheckToken_?this.tryAppCheck():this.connected_&&this.sendRequest("unappeck",{},()=>{})}tryAuth(){if(this.connected_&&this.authToken_){const e=this.authToken_,t=sd(e)?"auth":"gauth",i={cred:e};this.authOverride_===null?i.noauth=!0:typeof this.authOverride_=="object"&&(i.authvar=this.authOverride_),this.sendRequest(t,i,s=>{const o=s.s,a=s.d||"error";this.authToken_===e&&(o==="ok"?this.invalidAuthTokenCount_=0:this.onAuthRevoked_(o,a))})}}tryAppCheck(){this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},e=>{const t=e.s,i=e.d||"error";t==="ok"?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(t,i)})}unlisten(e,t){const i=e._path.toString(),s=e._queryIdentifier;this.log_("Unlisten called for "+i+" "+s),b(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(i,s)&&this.connected_&&this.sendUnlisten_(i,s,e._queryObject,t)}sendUnlisten_(e,t,i,s){this.log_("Unlisten on "+e+" for "+t);const o={p:e},a="n";s&&(o.q=i,o.t=s),this.sendRequest(a,o)}onDisconnectPut(e,t,i){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",e,t,i):this.onDisconnectRequestQueue_.push({pathString:e,action:"o",data:t,onComplete:i})}onDisconnectMerge(e,t,i){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",e,t,i):this.onDisconnectRequestQueue_.push({pathString:e,action:"om",data:t,onComplete:i})}onDisconnectCancel(e,t){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",e,null,t):this.onDisconnectRequestQueue_.push({pathString:e,action:"oc",data:null,onComplete:t})}sendOnDisconnect_(e,t,i,s){const o={p:t,d:i};this.log_("onDisconnect "+e,o),this.sendRequest(e,o,a=>{s&&setTimeout(()=>{s(a.s,a.d)},Math.floor(0))})}put(e,t,i,s){this.putInternal("p",e,t,i,s)}merge(e,t,i,s){this.putInternal("m",e,t,i,s)}putInternal(e,t,i,s,o){this.initConnection_();const a={p:t,d:i};o!==void 0&&(a.h=o),this.outstandingPuts_.push({action:e,request:a,onComplete:s}),this.outstandingPutCount_++;const h=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(h):this.log_("Buffering put: "+t)}sendPut_(e){const t=this.outstandingPuts_[e].action,i=this.outstandingPuts_[e].request,s=this.outstandingPuts_[e].onComplete;this.outstandingPuts_[e].queued=this.connected_,this.sendRequest(t,i,o=>{this.log_(t+" response",o),delete this.outstandingPuts_[e],this.outstandingPutCount_--,this.outstandingPutCount_===0&&(this.outstandingPuts_=[]),s&&s(o.s,o.d)})}reportStats(e){if(this.connected_){const t={c:e};this.log_("reportStats",t),this.sendRequest("s",t,i=>{if(i.s!=="ok"){const o=i.d;this.log_("reportStats","Error sending stats: "+o)}})}}onDataMessage_(e){if("r"in e){this.log_("from server: "+re(e));const t=e.r,i=this.requestCBHash_[t];i&&(delete this.requestCBHash_[t],i(e.b))}else{if("error"in e)throw"A server-side error has occurred: "+e.error;"a"in e&&this.onDataPush_(e.a,e.b)}}onDataPush_(e,t){this.log_("handleServerMessage",e,t),e==="d"?this.onDataUpdate_(t.p,t.d,!1,t.t):e==="m"?this.onDataUpdate_(t.p,t.d,!0,t.t):e==="c"?this.onListenRevoked_(t.p,t.q):e==="ac"?this.onAuthRevoked_(t.s,t.d):e==="apc"?this.onAppCheckRevoked_(t.s,t.d):e==="sd"?this.onSecurityDebugPacket_(t):ur("Unrecognized action received from server: "+re(e)+` 25Are you using the latest client?`)}onReady_(e,t){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=new Date().getTime(),this.handleTimestamp_(e),this.lastSessionId=t,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)}scheduleConnect_(e){b(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout(()=>{this.establishConnectionTimer_=null,this.establishConnection_()},Math.floor(e))}initConnection_(){!this.realtime_&&this.firstConnection_&&this.scheduleConnect_(0)}onVisible_(e){e&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible. Reducing delay."),this.reconnectDelay_=kn,this.realtime_||this.scheduleConnect_(0)),this.visible_=e}onOnline_(e){e?(this.log_("Browser went online."),this.reconnectDelay_=kn,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline. Killing connection."),this.realtime_&&this.realtime_.close())}onRealtimeDisconnect_(){if(this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()){this.visible_?this.lastConnectionEstablishedTime_&&(new Date().getTime()-this.lastConnectionEstablishedTime_>gm&&(this.reconnectDelay_=kn),this.lastConnectionEstablishedTime_=null):(this.log_("Window isn't visible. Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=new Date().getTime());const e=Math.max(0,new Date().getTime()-this.lastConnectionAttemptTime_);let t=Math.max(0,this.reconnectDelay_-e);
25t=Math.random()*t,this.log_("Trying to reconnect in "+t+"ms"),this.scheduleConnect_(t),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,this.reconnectDelay_*pm)}this.onConnectStatus_(!1)}async establishConnection_(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=new Date().getTime(),this.lastConnectionEstablishedTime_=null;const e=this.onDataMessage_.bind(this),t=this.onReady_.bind(this),i=this.onRealtimeDisconnect_.bind(this),s=this.id+":"+Je.nextConnectionId_++,o=this.lastSessionId;let a=!1,h=null;const u=function(){h?h.close():(a=!0,i())},f=function(y){b(h,"sendRequest call when we're not connected not allowed."),h.sendRequest(y)};this.realtime_={close:u,sendRequest:f};const E=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{const[y,S]=await Promise.all([this.authTokenProvider_.getToken(E),this.appCheckTokenProvider_.getToken(E)]);a?le("getToken() completed but was canceled"):(le("getToken() completed. Creating connection."),this.authToken_=y&&y.accessToken,this.appCheckToken_=S&&S.token,h=new lm(s,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,t,i,k=>{we(k+" ("+this.repoInfo_.toString()+")"),this.interrupt(_m)},o))}catch(y){this.log_("Failed to get token: "+y),a||(this.repoInfo_.nodeAdmin&&we(y),u())}}}interrupt(e){le("Interrupting connection for reason: "+e),this.interruptReasons_[e]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())}resume(e){le("Resuming connection for reason: "+e),delete this.interruptReasons_[e],Zs(this.interruptReasons_)&&(this.reconnectDelay_=kn,this.realtime_||this.scheduleConnect_(0))}handleTimestamp_(e){const t=e-new Date().getTime();this.onServerInfoUpdate_({serverTimeOffset:t})}cancelSentTransactions_(){for(let e=0;e<this.outstandingPuts_.length;e++){const t=this.outstandingPuts_[e];t&&"h"in t.request&&t.queued&&(t.onComplete&&t.onComplete("disconnect"),delete this.outstandingPuts_[e],this.outstandingPutCount_--)}this.outstandingPutCount_===0&&(this.outstandingPuts_=[])}onListenRevoked_(e,t){let i;t?i=t.map(o=>Br(o)).join("$"):i="default";const s=this.removeListen_(e,i);s&&s.onComplete&&s.onComplete("permission_denied")}removeListen_(e,t){const i=new q(e).toString();let s;if(this.listens.has(i)){const o=this.listens.get(i);s=o.get(t),o.delete(t),o.size===0&&this.listens.delete(i)}else s=void 0;return s}onAuthRevoked_(e,t){le("Auth token revoked: "+e+"/"+t),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),(e==="invalid_token"||e==="permission_denied")&&(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=vl&&(this.reconnectDelay_=yl,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(e,t){le("App check token revoked: "+e+"/"+t),this.appCheckToken_=null,this.forceTokenRefresh_=!0,(e==="invalid_token"||e==="permission_denied")&&(this.invalidAppCheckTokenCount_++,this.invalidAppCheckTokenCount_>=vl&&this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&&console.log("FIREBASE: "+e.msg.replace(` 26`,` 27FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of this.listens.values())for(const t of e.values())this.sendListen_(t);for(let e=0;e<this.outstandingPuts_.length;e++)this.outstandingPuts_[e]&&this.sendPut_(e);for(;this.onDisconnectRequestQueue_.length;){const e=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(e.action,e.pathString,e.data,e.onComplete)}for(let e=0;e<this.outstandingGets_.length;e++)this.outstandingGets_[e]&&this.sendGet_(e)}sendConnectStats_(){const e={};let t="js";e["sdk."+t+"."+jc.replace(/\./g,"-")]=1,Sr()?e["framework.cordova"]=1:Jl()&&(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){const e=Hi.getInstance().currentlyOnline();return Zs(this.interruptReasons_)&&e}}Je.nextPersistentConnectionId_=0;Je.nextConnectionId_=0;class U{constructor(e,t){this.name=e,this.node=t}static Wrap(e,t){return new U(e,t)}}class rs{getCompare(){return this.compare.bind(this)}indexedValueChanged(e,t){const i=new U(nn,e),s=new U(nn,t);return this.compare(i,s)!==0}
vendor: 8,572 bytes, line 27
27minPost(){return U.MIN}}let wi;class mh extends rs{static get __EMPTY_NODE(){return wi}static set __EMPTY_NODE(e){wi=e}compare(e,t){return cn(e.name,t.name)}isDefinedOn(e){throw rn("KeyIndex.isDefinedOn not expected to be called.")}indexedValueChanged(e,t){return!1}minPost(){return U.MIN}maxPost(){return new U(Lt,wi)}makePost(e,t){return b(typeof e=="string","KeyIndex indexValue must always be a string."),new U(e,wi)}toString(){return".key"}}const Qt=new mh;class Ei{constructor(e,t,i,s,o=null){this.isReverse_=s,this.resultGenerator_=o,this.nodeStack_=[];let a=1;for(;!e.isEmpty();)if(e=e,a=t?i(e.key,t):1,s&&(a*=-1),a<0)this.isReverse_?e=e.left:e=e.right;else if(a===0){this.nodeStack_.push(e);break}else this.nodeStack_.push(e),this.isReverse_?e=e.right:e=e.left}getNext(){if(this.nodeStack_.length===0)return null;let e=this.nodeStack_.pop(),t;if(this.resultGenerator_?t=this.resultGenerator_(e.key,e.value):t={key:e.key,value:e.value},this.isReverse_)for(e=e.left;!e.isEmpty();)this.nodeStack_.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack_.push(e),e=e.left;return t}hasNext(){return this.nodeStack_.length>0}peek(){if(this.nodeStack_.length===0)return null;const e=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value}}}class ie{constructor(e,t,i,s,o){this.key=e,this.value=t,this.color=i??ie.RED,this.left=s??ge.EMPTY_NODE,this.right=o??ge.EMPTY_NODE}copy(e,t,i,s,o){return new ie(e??this.key,t??this.value,i??this.color,s??this.left,o??this.right)}count(){return this.left.count()+1+this.right.count()}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,i){let s=this;const o=i(e,s.key);return o<0?s=s.copy(null,null,null,s.left.insert(e,t,i),null):o===0?s=s.copy(null,t,null,null,null):s=s.copy(null,null,null,null,s.right.insert(e,t,i)),s.fixUp_()}removeMin_(){if(this.left.isEmpty())return ge.EMPTY_NODE;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 i,s;if(i=this,t(e,i.key)<0)!i.left.isEmpty()&&!i.left.isRed_()&&!i.left.left.isRed_()&&(i=i.moveRedLeft_()),i=i.copy(null,null,null,i.left.remove(e,t),null);else{if(i.left.isRed_()&&(i=i.rotateRight_()),!i.right.isEmpty()&&!i.right.isRed_()&&!i.right.left.isRed_()&&(i=i.moveRedRight_()),t(e,i.key)===0){if(i.right.isEmpty())return ge.EMPTY_NODE;s=i.right.min_(),i=i.copy(s.key,s.value,null,null,i.right.removeMin_())}i=i.copy(null,null,null,null,i.right.remove(e,t))}return i.fixUp_()}isRed_(){return this.color}fixUp_(){let e=this;return e.right.isRed_()&&!e.left.isRed_()&&(e=e.rotateLeft_()),e.left.isRed_()&&e.left.left.isRed_()&&(e=e.rotateRight_()),e.left.isRed_()&&e.right.isRed_()&&(e=e.colorFlip_()),e}moveRedLeft_(){let e=this.colorFlip_();return e.right.left.isRed_()&&(e=e.copy(null,null,null,null,e.right.rotateRight_()),e=e.rotateLeft_(),e=e.colorFlip_()),e}moveRedRight_(){let e=this.colorFlip_();return e.left.left.isRed_()&&(e=e.rotateRight_(),e=e.colorFlip_()),e}rotateLeft_(){const e=this.copy(null,null,ie.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight_(){const e=this.copy(null,null,ie.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.count()+1}check_(){if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");const e=this.left.check_();if(e!==this.right.check_())throw new Error("Black depths differ");return e+(this.isRed_()?0:1)}}ie.RED=!0;ie.BLACK=!1;class mm{copy(e,t,i,s,o){return this}insert(e,t,i){return new ie(e,t,null)}remove(e,t){return this}count(){return 0}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}check_(){return 0}isRed_(){return!1}}class ge{constructor(e,t=ge.EMPTY_NODE){this.comparator_=e,this.root_=t}insert(e,t){return new ge(this.comparator_,this.root_.insert(e,t,this.comparator_).copy(null,null,ie.BLACK,null,null))}remove(e){return new ge(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,ie.BLACK,null,null))}get(e){let t,i=this.root_;for(;!i.isEmpty();){if(t=this.comparator_(e,i.key),t===0)return i.value;t<0?i=i.left:t>0&&(i=i.right)}return null}getPredecessorKey(e){let t,i=this.root_,s=null;for(;!i.isEmpty();)if(t=this.comparator_(e,i.key),t===0){if(i.left.isEmpty())return s?s.key:null;for(i=i.left;!i.right.isEmpty();)i=i.right;return i.key}else t<0?i=i.left:t>0&&(s=i,i=i.right);throw new Error("Attempted to find predecessor key for a nonexistent key. What gives?")}isEmpty(){return this.root_.isEmpty()}count(){return this.root_.count()}minKey(){return this.root_.minKey()}maxKey(){return this.root_.maxKey()}inorderTraversal(e){return this.root_.inorderTraversal(e)}reverseTraversal(e){return this.root_.reverseTraversal(e)}getIterator(e){return new Ei(this.root_,null,this.comparator_,!1,e)}getIteratorFrom(e,t){return new Ei(this.root_,e,this.comparator_,!1,t)}getReverseIteratorFrom(e,t){return new Ei(this.root_,e,this.comparator_,!0,t)}getReverseIterator(e){return new Ei(this.root_,null,this.comparator_,!0,e)}}ge.EMPTY_NODE=new mm;function ym(n,e){return cn(n.name,e.name)}function Gr(n,e){return cn(n,e)}let fr;function vm(n){fr=n}const yh=function(n){return typeof n=="number"?"number:"+Kc(n):"string:"+n},vh=function(n){if(n.isLeafNode()){const e=n.val();b(typeof e=="string"||typeof e=="number"||typeof e=="object"&&et(e,".sv"),"Priority must be a string or number.")}else b(n===fr||n.isEmpty(),"priority of unexpected type.");b(n===fr||n.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")};let wl;class ne{static set __childrenNodeConstructor(e){wl=e}static get __childrenNodeConstructor(){return wl}constructor(e,t=ne.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=t,this.lazyHash_=null,b(this.value_!==void 0&&this.value_!==null,"LeafNode shouldn't be created with null/undefined value."),vh(this.priorityNode_)}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new ne(this.value_,e)}getImmediateChild(e){return e===".priority"?this.priorityNode_:ne.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return M(e)?this:x(e)===".priority"?this.priorityNode_:ne.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(e,t){return null}updateImmediateChild(e,t){return e===".priority"?this.updatePriority(t):t.isEmpty()&&e!==".priority"?this:ne.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,t).updatePriority(this.priorityNode_)}updateChild(e,t){const i=x(e);return i===null?t:t.isEmpty()&&i!==".priority"?this:(b(i!==".priority"||mt(e)===1,".priority must be the last token in a path"),this.updateImmediateChild(i,ne.__childrenNodeConstructor.EMPTY_NODE.updateChild(z(e),t)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(e,t){return!1}val(e){return e&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(this.lazyHash_===null){let e="";this.priorityNode_.isEmpty()||(e+="priority:"+yh(this.priorityNode_.val())+":");const t=typeof this.value_;e+=t+":",t==="number"?e+=Kc(this.value_):e+=this.value_,this.lazyHash_=Gc(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===ne.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof ne.__childrenNodeConstructor?-1:(b(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){const t=typeof e.value_,i=typeof this.value_,s=ne.VALUE_TYPE_ORDER.indexOf(t),o=ne.VALUE_TYPE_ORDER.indexOf(i);return b(s>=0,"Unknown leaf type: "+t),b(o>=0,"Unknown leaf type: "+i),s===o?i==="object"?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:o-s}withIndex(){return this}isIndexed(){return!0}equals(e){if(e===this)return!0;
27if(e.isLeafNode()){const t=e;return this.value_===t.value_&&this.priorityNode_.equals(t.priorityNode_)}else return!1}}ne.VALUE_TYPE_ORDER=["object","boolean","number","string"];let wh,Eh;function wm(n){wh=n}function Em(n){Eh=n}class Im extends rs{compare(e,t){const i=e.node.getPriority(),s=t.node.getPriority(),o=i.compareTo(s);return o===0?cn(e.name,t.name):o}isDefinedOn(e){return!e.getPriority().isEmpty()}indexedValueChanged(e,t){return!e.getPriority().equals(t.getPriority())}minPost(){return U.MIN}maxPost(){return new U(Lt,new ne("[PRIORITY-POST]",Eh))}makePost(e,t){const i=wh(e);return new U(t,new ne("[PRIORITY-POST]",i))}toString(){return".priority"}}const he=new Im;const Tm=Math.log(2);class Sm{constructor(e){const t=o=>parseInt(Math.log(o)/Tm,10),i=o=>parseInt(Array(o+1).join("1"),2);this.count=t(e+1),this.current_=this.count-1;const s=i(this.count);this.bits_=e+1&s}nextBitIsOne(){const e=!(this.bits_&1<<this.current_);return this.current_--,e}}const ji=function(n,e,t,i){n.sort(e);const s=function(u,f){const E=f-u;let y,S;if(E===0)return null;if(E===1)return y=n[u],S=t?t(y):y,new ie(S,y.node,ie.BLACK,null,null);{const k=parseInt(E/2,10)+u,R=s(u,k),O=s(k+1,f);return y=n[k],S=t?t(y):y,new ie(S,y.node,ie.BLACK,R,O)}},o=function(u){let f=null,E=null,y=n.length;const S=function(R,O){const N=y-R,Y=y;y-=R;const Q=s(N+1,Y),K=n[N],X=t?t(K):K;k(new ie(X,K.node,O,null,Q))},k=function(R){f?(f.left=R,f=R):(E=R,f=R)};for(let R=0;R<u.count;++R){const O=u.nextBitIsOne(),N=Math.pow(2,u.count-(R+1));O?S(N,ie.BLACK):(S(N,ie.BLACK),S(N,ie.RED))}return E},a=new Sm(n.length),h=o(a);return new ge(i||e,h)};let Ks;const $t={};class Xe{static get Default(){return b($t&&he,"ChildrenNode.ts has not been loaded"),Ks=Ks||new Xe({".priority":$t},{".priority":he}),Ks}constructor(e,t){this.indexes_=e,this.indexSet_=t}get(e){const t=Zt(this.indexes_,e);if(!t)throw new Error("No index defined for "+e);return t instanceof ge?t:null}hasIndex(e){return et(this.indexSet_,e.toString())}addIndex(e,t){b(e!==Qt,"KeyIndex always exists and isn't meant to be added to the IndexMap.");const i=[];let s=!1;const o=t.getIterator(U.Wrap);let a=o.getNext();for(;a;)s=s||e.isDefinedOn(a.node),i.push(a),a=o.getNext();let h;s?h=ji(i,e.getCompare()):h=$t;const u=e.toString(),f={...this.indexSet_};f[u]=e;const E={...this.indexes_};return E[u]=h,new Xe(E,f)}addToIndexes(e,t){const i=ki(this.indexes_,(s,o)=>{const a=Zt(this.indexSet_,o);if(b(a,"Missing index implementation for "+o),s===$t)if(a.isDefinedOn(e.node)){const h=[],u=t.getIterator(U.Wrap);let f=u.getNext();for(;f;)f.name!==e.name&&h.push(f),f=u.getNext();return h.push(e),ji(h,a.getCompare())}else return $t;else{const h=t.get(e.name);let u=s;return h&&(u=u.remove(new U(e.name,h))),u.insert(e,e.node)}});return new Xe(i,this.indexSet_)}removeFromIndexes(e,t){const i=ki(this.indexes_,s=>{if(s===$t)return s;{const o=t.get(e.name);
27return o?s.remove(new U(e.name,o)):s}});return new Xe(i,this.indexSet_)}}let Nn;class W{static get EMPTY_NODE(){return Nn||(Nn=new W(new ge(Gr),null,Xe.Default))}constructor(e,t,i){this.children_=e,this.priorityNode_=t,this.indexMap_=i,this.lazyHash_=null,this.priorityNode_&&vh(this.priorityNode_),this.children_.isEmpty()&&b(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}isLeafNode(){return!1}getPriority(){return this.priorityNode_||Nn}updatePriority(e){return this.children_.isEmpty()?this:new W(this.children_,e,this.indexMap_)}getImmediateChild(e){if(e===".priority")return this.getPriority();{const t=this.children_.get(e);return t===null?Nn:t}}getChild(e){const t=x(e);return t===null?this:this.getImmediateChild(t).getChild(z(e))}hasChild(e){return this.children_.get(e)!==null}updateImmediateChild(e,t){if(b(t,"We should always be passing snapshot nodes"),e===".priority")return this.updatePriority(t);{const i=new U(e,t);let s,o;t.isEmpty()?(s=this.children_.remove(e),o=this.indexMap_.removeFromIndexes(i,this.children_)):(s=this.children_.insert(e,t),o=this.indexMap_.addToIndexes(i,this.children_));const a=s.isEmpty()?Nn:this.priorityNode_;return new W(s,a,o)}}updateChild(e,t){const i=x(e);if(i===null)return t;{b(x(e)!==".priority"||mt(e)===1,".priority must be the last token in a path");const s=this.getImmediateChild(i).updateChild(z(e),t);return this.updateImmediateChild(i,s)}}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(e){if(this.isEmpty())return null;const t={};let i=0,s=0,o=!0;if(this.forEachChild(he,(a,h)=>{t[a]=h.val(e),i++,o&&W.INTEGER_REGEXP_.test(a)?s=Math.max(s,Number(a)):o=!1}),!e&&o&&s<2*i){const a=[];for(const h in t)a[h]=t[h];return a}else return e&&!this.getPriority().isEmpty()&&(t[".priority"]=this.getPriority().val()),t}hash(){if(this.lazyHash_===null){let e="";this.getPriority().isEmpty()||(e+="priority:"+yh(this.getPriority().val())+":"),this.forEachChild(he,(t,i)=>{const s=i.hash();s!==""&&(e+=":"+t+":"+s)}),this.lazyHash_=e===""?"":Gc(e)}return this.lazyHash_}getPredecessorChildName(e,t,i){const s=this.resolveIndex_(i);if(s){const o=s.getPredecessorKey(new U(e,t));return o?o.name:null}else return this.children_.getPredecessorKey(e)}getFirstChildName(e){const t=this.resolveIndex_(e);if(t){const i=t.minKey();return i&&i.name}else return this.children_.minKey()}getFirstChild(e){const t=this.getFirstChildName(e);return t?new U(t,this.children_.get(t)):null}getLastChildName(e){const t=this.resolveIndex_(e);if(t){const i=t.maxKey();return i&&i.name}else return this.children_.maxKey()}getLastChild(e){const t=this.getLastChildName(e);return t?new U(t,this.children_.get(t)):null}forEachChild(e,t){const i=this.resolveIndex_(e);return i?i.inorderTraversal(s=>t(s.name,s.node)):this.children_.inorderTraversal(t)}getIterator(e){return this.getIteratorFrom(e.minPost(),e)}getIteratorFrom(e,t){const i=this.resolveIndex_(t);if(i)return i.getIteratorFrom(e,s=>s);{const s=this.children_.getIteratorFrom(e.name,U.Wrap);let o=s.peek();for(;o!=null&&t.compare(o,e)<0;)s.getNext(),o=s.peek();return s}}getReverseIterator(e){return this.getReverseIteratorFrom(e.maxPost(),e)}getReverseIteratorFrom(e,t){const i=this.resolveIndex_(t);if(i)return i.getReverseIteratorFrom(e,s=>s);{const s=this.children_.getReverseIteratorFrom(e.name,U.Wrap);let o=s.peek();for(;o!=null&&t.compare(o,e)>0;)s.getNext(),o=s.peek();return s}}compareTo(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===ni?-1:0}withIndex(e){if(e===Qt||this.indexMap_.hasIndex(e))return this;{const t=this.indexMap_.addIndex(e,this.children_);return new W(this.children_,this.priorityNode_,t)}}isIndexed(e){return e===Qt||this.indexMap_.hasIndex(e)}equals(e){if(e===this)return!0;if(e.isLeafNode())return!1;{const t=e;if(this.getPriority().equals(t.getPriority()))if(this.children_.count()===t.children_.count()){const i=this.getIterator(he),s=t.getIterator(he);let o=i.getNext(),a=s.getNext();for(;o&&a;){if(o.name!==a.name||!o.node.equals(a.node))return!1;o=i.getNext(),a=s.getNext()}return o===null&&a===null}else return!1;else return!1}}resolveIndex_(e){return e===Qt?null:this.indexMap_.get(e.toString())}}W.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;class Cm extends W{constructor(){super(new ge(Gr),W.EMPTY_NODE,Xe.Default)}compareTo(e){return e===this?0:1}equals(e){return e===this}getPriority(){return this}getImmediateChild(e){return W.EMPTY_NODE}isEmpty(){return!1}}const ni=new Cm;Object.defineProperties(U,{MIN:{value:new U(nn,W.EMPTY_NODE)},MAX:{value:new U(Lt,ni)}});mh.__EMPTY_NODE=W.EMPTY_NODE;ne.__childrenNodeConstructor=W;vm(ni);Em(ni);const Am=!0;function ce(n,e=null){if(n===null)return W.EMPTY_NODE;
27if(typeof n=="object"&&".priority"in n&&(e=n[".priority"]),b(e===null||typeof e=="string"||typeof e=="number"||typeof e=="object"&&".sv"in e,"Invalid priority type found: "+typeof e),typeof n=="object"&&".value"in n&&n[".value"]!==null&&(n=n[".value"]),typeof n!="object"||".sv"in n){const t=n;return new ne(t,ce(e))}if(!(n instanceof Array)&&Am){const t=[];let i=!1;if(Te(n,(a,h)=>{if(a.substring(0,1)!=="."){const u=ce(h);u.isEmpty()||(i=i||!u.getPriority().isEmpty(),t.push(new U(a,u)))}}),t.length===0)return W.EMPTY_NODE;const o=ji(t,ym,a=>a.name,Gr);if(i){const a=ji(t,he.getCompare());return new W(o,ce(e),new Xe({".priority":a},{".priority":he}))}else return new W(o,ce(e),Xe.Default)}else{let t=W.EMPTY_NODE;return Te(n,(i,s)=>{if(et(n,i)&&i.substring(0,1)!=="."){const o=ce(s);(o.isLeafNode()||!o.isEmpty())&&(t=t.updateImmediateChild(i,o))}}),t.updatePriority(ce(e))}}wm(ce);class bm extends rs{constructor(e){super(),this.indexPath_=e,b(!M(e)&&x(e)!==".priority","Can't create PathIndex with empty path or .priority key")}extractChild(e){return e.getChild(this.indexPath_)}isDefinedOn(e){return!e.getChild(this.indexPath_).isEmpty()}compare(e,t){const i=this.extractChild(e.node),s=this.extractChild(t.node),o=i.compareTo(s);return o===0?cn(e.name,t.name):o}makePost(e,t){const i=ce(e),s=W.EMPTY_NODE.updateChild(this.indexPath_,i);return new U(t,s)}maxPost(){const e=W.EMPTY_NODE.updateChild(this.indexPath_,ni);return new U(Lt,e)}toString(){return fh(this.indexPath_,0).join("/")}}class Rm extends rs{compare(e,t){const i=e.node.compareTo(t.node);return i===0?cn(e.name,t.name):i}isDefinedOn(e){return!0}indexedValueChanged(e,t){return!e.equals(t)}minPost(){return U.MIN}maxPost(){return U.MAX}makePost(e,t){const i=ce(e);return new U(t,i)}toString(){return".value"}}const km=new Rm;function Nm(n){return{type:"value",snapshotNode:n}}function Pm(n,e){return{type:"child_added",snapshotNode:e,childName:n}}function Om(n,e){return{type:"child_removed",snapshotNode:e,childName:n}}function El(n,e,t){return{type:"child_changed",snapshotNode:e,childName:n,oldSnap:t}}function Dm(n,e){return{type:"child_moved",snapshotNode:e,childName:n}}class zr{constructor(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.startAfterSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.endBeforeSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=he}hasStart(){return this.startSet_}isViewFromLeft(){return this.viewFrom_===""?this.startSet_:this.viewFrom_==="l"}getIndexStartValue(){return b(this.startSet_,"Only valid if start has been set"),this.indexStartValue_}getIndexStartName(){return b(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:nn}hasEnd(){return this.endSet_}getIndexEndValue(){return b(this.endSet_,"Only valid if end has been set"),this.indexEndValue_}getIndexEndName(){return b(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:Lt}hasLimit(){return this.limitSet_}hasAnchoredLimit(){return this.limitSet_&&this.viewFrom_!==""}getLimit(){return b(this.limitSet_,"Only valid if limit has been set"),this.limit_}getIndex(){return this.index_}loadsAllData(){return!(this.startSet_||this.endSet_||this.limitSet_)}isDefault(){return this.loadsAllData()&&this.index_===he}copy(){const e=new zr;return e.limitSet_=this.limitSet_,e.limit_=this.limit_,e.startSet_=this.startSet_,e.startAfterSet_=this.startAfterSet_,e.indexStartValue_=this.indexStartValue_,e.startNameSet_=this.startNameSet_,e.indexStartName_=this.indexStartName_,e.endSet_=this.endSet_,e.endBeforeSet_=this.endBeforeSet_,e.indexEndValue_=this.indexEndValue_,e.endNameSet_=this.endNameSet_,e.indexEndName_=this.indexEndName_,e.index_=this.index_,e.viewFrom_=this.viewFrom_,e}}function Il(n){const e={};if(n.isDefault())return e;let t;if(n.index_===he?t="$priority":n.index_===km?t="$value":n.index_===Qt?t="$key":(b(n.index_ instanceof bm,"Unrecognized index type!"),t=n.index_.toString()),e.orderBy=re(t),n.startSet_){const i=n.startAfterSet_?"startAfter":"startAt";e[i]=re(n.indexStartValue_),n.startNameSet_&&(e[i]+=","+re(n.indexStartName_))}if(n.endSet_){const i=n.endBeforeSet_?"endBefore":"endAt";e[i]=re(n.indexEndValue_),n.endNameSet_&&(e[i]+=","+re(n.indexEndName_))}return n.limitSet_&&(n.isViewFromLeft()?e.limitToFirst=n.limit_:e.limitToLast=n.limit_),e}function Tl(n){const e={};if(n.startSet_&&(e.sp=n.indexStartValue_,n.startNameSet_&&(e.sn=n.indexStartName_),e.sin=!n.startAfterSet_),n.endSet_&&(e.ep=n.indexEndValue_,n.endNameSet_&&(e.en=n.indexEndName_),e.ein=!n.endBeforeSet_),n.limitSet_){e.l=n.limit_;let t=n.viewFrom_;t===""&&(n.isViewFromLeft()?t="l":t="r"),e.vf=t}return n.index_!==he&&(e.i=n.index_.toString()),e}class $i extends hh{reportStats(e){throw new Error("Method not implemented.")}static getListenId_(e,t){return t!==void 0?"tag$"+t:(b(e._queryParams.isDefault(),"should have a tag if it's not a default query."),e._path.toString())}constructor(e,t,i,s){super(),this.repoInfo_=e,this.onDataUpdate_=t,this.authTokenProvider_=i,this.appCheckTokenProvider_=s,this.log_=ei("p:rest:"),this.listens_={}}listen(e,t,i,s){const o=e._path.toString();this.log_("Listen called for "+o+" "+e._queryIdentifier);const a=$i.getListenId_(e,i),h={};this.listens_[a]=h;const u=Il(e._queryParams);this.restRequest_(o+".json",u,(f,E)=>{let y=E;
27if(f===404&&(y=null,f=null),f===null&&this.onDataUpdate_(o,y,!1,i),Zt(this.listens_,a)===h){let S;f?f===401?S="permission_denied":S="rest_error:"+f:S="ok",s(S,null)}})}unlisten(e,t){const i=$i.getListenId_(e,t);delete this.listens_[i]}get(e){const t=Il(e._queryParams),i=e._path.toString(),s=new Hn;return this.restRequest_(i+".json",t,(o,a)=>{let h=a;o===404&&(h=null,o=null),o===null?(this.onDataUpdate_(i,h,!1,null),s.resolve(h)):s.reject(new Error(h))}),s.promise}refreshAuthToken(e){}restRequest_(e,t={},i){return t.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then(([s,o])=>{s&&s.accessToken&&(t.auth=s.accessToken),o&&o.token&&(t.ac=o.token);const a=(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host+e+"?ns="+this.repoInfo_.namespace+an(t);this.log_("Sending REST request for "+a);const h=new XMLHttpRequest;h.onreadystatechange=()=>{if(i&&h.readyState===4){this.log_("REST Response for "+a+" received. status:",h.status,"response:",h.responseText);let u=null;if(h.status>=200&&h.status<300){try{u=jn(h.responseText)}catch{we("Failed to parse JSON response for "+a+": "+h.responseText)}i(null,u)}else h.status!==401&&h.status!==404&&we("Got unsuccessful REST response for "+a+" Status: "+h.status),i(h.status);i=null}},h.open("GET",a,!0),h.send()})}}class Mm{constructor(){this.rootNode_=W.EMPTY_NODE}getNode(e){return this.rootNode_.getChild(e)}updateSnapshot(e,t){this.rootNode_=this.rootNode_.updateChild(e,t)}}function Gi(){return{value:null,children:new Map}}function Ih(n,e,t){if(M(e))n.value=t,n.children.clear();else if(n.value!==null)n.value=n.value.updateChild(e,t);else{const i=x(e);n.children.has(i)||n.children.set(i,Gi());const s=n.children.get(i);e=z(e),Ih(s,e,t)}}function pr(n,e,t){n.value!==null?t(e,n.value):Lm(n,(i,s)=>{const o=new q(e.toString()+"/"+i);pr(s,o,t)})}function Lm(n,e){n.children.forEach((t,i)=>{e(i,t)})}class xm{constructor(e){this.collection_=e,this.last_=null}get(){const e=this.collection_.get(),t={...e};return this.last_&&Te(this.last_,(i,s)=>{t[i]=t[i]-s}),this.last_=e,t}}const Sl=10*1e3,Um=30*1e3,Fm=300*1e3;class Vm{constructor(e,t){this.server_=t,this.statsToReport_={},this.statsListener_=new xm(e);const i=Sl+(Um-Sl)*Math.random();Vn(this.reportStats_.bind(this),Math.floor(i))}reportStats_(){const e=this.statsListener_.get(),t={};let i=!1;Te(e,(s,o)=>{o>0&&et(this.statsToReport_,s)&&(t[s]=o,i=!0)}),i&&this.server_.reportStats(t),Vn(this.reportStats_.bind(this),Math.floor(Math.random()*2*Fm))}}var Ve;(function(n){n[n.OVERWRITE=0]="OVERWRITE",n[n.MERGE=1]="MERGE",n[n.ACK_USER_WRITE=2]="ACK_USER_WRITE",n[n.LISTEN_COMPLETE=3]="LISTEN_COMPLETE"})(Ve||(Ve={}));function Th(){return{fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}function Sh(){return{fromUser:!1,fromServer:!0,queryId:null,tagged:!1}}function Ch(n){return{fromUser:!1,fromServer:!0,queryId:n,tagged:!0}}class zi{constructor(e,t,i){this.path=e,this.affectedTree=t,this.revert=i,this.type=Ve.ACK_USER_WRITE,this.source=Th()}operationForChild(e){if(M(this.path)){if(this.affectedTree.value!=null)return b(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{const t=this.affectedTree.subtree(new q(e));return new zi(H(),t,this.revert)}}else return b(x(this.path)===e,"operationForChild called for unrelated child."),new zi(z(this.path),this.affectedTree,this.revert)}}class xt{constructor(e,t,i){this.source=e,this.path=t,this.snap=i,this.type=Ve.OVERWRITE}operationForChild(e){return M(this.path)?new xt(this.source,H(),this.snap.getImmediateChild(e)):new xt(this.source,z(this.path),this.snap)}}class qn{constructor(e,t,i){this.source=e,this.path=t,this.children=i,this.type=Ve.MERGE}operationForChild(e){if(M(this.path)){const t=this.children.subtree(new q(e));return t.isEmpty()?null:t.value?new xt(this.source,H(),t.value):new qn(this.source,H(),t)}else return b(x(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new qn(this.source,z(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}class qr{constructor(e,t,i){this.node_=e,this.fullyInitialized_=t,this.filtered_=i}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(e){if(M(e))return this.isFullyInitialized()&&!this.filtered_;const t=x(e);return this.isCompleteForChild(t)}isCompleteForChild(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)}getNode(){return this.node_}}function Bm(n,e,t,i){const s=[],o=[];return e.forEach(a=>{a.type==="child_changed"&&n.index_.indexedValueChanged(a.oldSnap,a.snapshotNode)&&o.push(Dm(a.childName,a.snapshotNode))}
27),Pn(n,s,"child_removed",e,i,t),Pn(n,s,"child_added",e,i,t),Pn(n,s,"child_moved",o,i,t),Pn(n,s,"child_changed",e,i,t),Pn(n,s,"value",e,i,t),s}function Pn(n,e,t,i,s,o){const a=i.filter(h=>h.type===t);a.sort((h,u)=>Hm(n,h,u)),a.forEach(h=>{const u=Wm(n,h,o);s.forEach(f=>{f.respondsTo(h.type)&&e.push(f.createEvent(u,n.query_))})})}function Wm(n,e,t){return e.type==="value"||e.type==="child_removed"||(e.prevName=t.getPredecessorChildName(e.childName,e.snapshotNode,n.index_)),e}function Hm(n,e,t){if(e.childName==null||t.childName==null)throw rn("Should only compare child_ events.");const i=new U(e.childName,e.snapshotNode),s=new U(t.childName,t.snapshotNode);return n.index_.compare(i,s)}function Ah(n,e){return{eventCache:n,serverCache:e}}function Bn(n,e,t,i){return Ah(new qr(e,t,i),n.serverCache)}function bh(n,e,t,i){return Ah(n.eventCache,new qr(e,t,i))}function gr(n){return n.eventCache.isFullyInitialized()?n.eventCache.getNode():null}function Ut(n){return n.serverCache.isFullyInitialized()?n.serverCache.getNode():null}let Ys;const jm=()=>(Ys||(Ys=new ge(R_)),Ys);class G{static fromObject(e){let t=new G(null);return Te(e,(i,s)=>{t=t.set(new q(i),s)}),t}constructor(e,t=jm()){this.value=e,this.children=t}isEmpty(){return this.value===null&&this.children.isEmpty()}findRootMostMatchingPathAndValue(e,t){if(this.value!=null&&t(this.value))return{path:H(),value:this.value};if(M(e))return null;{const i=x(e),s=this.children.get(i);if(s!==null){const o=s.findRootMostMatchingPathAndValue(z(e),t);return o!=null?{path:se(new q(i),o.path),value:o.value}:null}else return null}}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,()=>!0)}subtree(e){if(M(e))return this;{const t=x(e),i=this.children.get(t);return i!==null?i.subtree(z(e)):new G(null)}}set(e,t){if(M(e))return new G(t,this.children);{const i=x(e),o=(this.children.get(i)||new G(null)).set(z(e),t),a=this.children.insert(i,o);return new G(this.value,a)}}remove(e){if(M(e))return this.children.isEmpty()?new G(null):new G(null,this.children);{const t=x(e),i=this.children.get(t);if(i){const s=i.remove(z(e));let o;return s.isEmpty()?o=this.children.remove(t):o=this.children.insert(t,s),this.value===null&&o.isEmpty()?new G(null):new G(this.value,o)}else return this}}get(e){if(M(e))return this.value;{const t=x(e),i=this.children.get(t);return i?i.get(z(e)):null}}setTree(e,t){if(M(e))return t;{const i=x(e),o=(this.children.get(i)||new G(null)).setTree(z(e),t);let a;return o.isEmpty()?a=this.children.remove(i):a=this.children.insert(i,o),new G(this.value,a)}}fold(e){return this.fold_(H(),e)}fold_(e,t){const i={};return this.children.inorderTraversal((s,o)=>{i[s]=o.fold_(se(e,s),t)}),t(e,this.value,i)}findOnPath(e,t){return this.findOnPath_(e,H(),t)}findOnPath_(e,t,i){const s=this.value?i(t,this.value):!1;if(s)return s;if(M(e))return null;{const o=x(e),a=this.children.get(o);return a?a.findOnPath_(z(e),se(t,o),i):null}}foreachOnPath(e,t){return this.foreachOnPath_(e,H(),t)}foreachOnPath_(e,t,i){if(M(e))return this;{this.value&&i(t,this.value);const s=x(e),o=this.children.get(s);return o?o.foreachOnPath_(z(e),se(t,s),i):new G(null)}}foreach(e){this.foreach_(H(),e)}foreach_(e,t){this.children.inorderTraversal((i,s)=>{s.foreach_(se(e,i),t)}),this.value&&t(e,this.value)}foreachChild(e){this.children.inorderTraversal((t,i)=>{i.value&&e(t,i.value)})}}class Pe{constructor(e){this.writeTree_=e}static empty(){return new Pe(new G(null))}}function Wn(n,e,t){if(M(e))return new Pe(new G(t));{const i=n.writeTree_.findRootMostValueAndPath(e);if(i!=null){const s=i.path;let o=i.value;const a=Ie(s,e);return o=o.updateChild(a,t),new Pe(n.writeTree_.set(s,o))}else{const s=new G(t),o=n.writeTree_.setTree(e,s);return new Pe(o)}}}function Cl(n,e,t){let i=n;return Te(t,(s,o)=>{i=Wn(i,se(e,s),o)}),i}function Al(n,e){if(M(e))return Pe.empty();{const t=n.writeTree_.setTree(e,new G(null));return new Pe(t)}}function _r(n,e){return Ft(n,e)!=null}function Ft(n,e){const t=n.writeTree_.findRootMostValueAndPath(e);return t!=null?n.writeTree_.get(t.path).getChild(Ie(t.path,e)):null}function bl(n){const e=[],t=n.writeTree_.value;return t!=null?t.isLeafNode()||t.forEachChild(he,(i,s)=>{e.push(new U(i,s))}):n.writeTree_.children.inorderTraversal((i,s)=>{s.value!=null&&e.push(new U(i,s.value))}),e}function gt(n,e){if(M(e))return n;{const t=Ft(n,e);return t!=null?new Pe(new G(t)):new Pe(n.writeTree_.subtree(e))}}function mr(n){return n.writeTree_.isEmpty()}function sn(n,e){return Rh(H(),n.writeTree_,e)}function Rh(n,e,t){if(e.value!=null)return t.updateChild(n,e.value);{let i=null;return e.children.inorderTraversal((s,o)=>
27{s===".priority"?(b(o.value!==null,"Priority writes must always be leaf nodes"),i=o.value):t=Rh(se(n,s),o,t)}),!t.getChild(n).isEmpty()&&i!==null&&(t=t.updateChild(se(n,".priority"),i)),t}}function kh(n,e){return Mh(e,n)}function $m(n,e,t,i,s){b(i>n.lastWriteId,"Stacking an older write on top of newer ones"),s===void 0&&(s=!0),n.allWrites.push({path:e,snap:t,writeId:i,visible:s}),s&&(n.visibleWrites=Wn(n.visibleWrites,e,t)),n.lastWriteId=i}function Gm(n,e){for(let t=0;t<n.allWrites.length;t++){const i=n.allWrites[t];if(i.writeId===e)return i}return null}function zm(n,e){const t=n.allWrites.findIndex(h=>h.writeId===e);b(t>=0,"removeWrite called with nonexistent writeId.");const i=n.allWrites[t];n.allWrites.splice(t,1);let s=i.visible,o=!1,a=n.allWrites.length-1;for(;s&&a>=0;){const h=n.allWrites[a];h.visible&&(a>=t&&qm(h,i.path)?s=!1:Re(i.path,h.path)&&(o=!0)),a--}if(s){if(o)return Km(n),!0;if(i.snap)n.visibleWrites=Al(n.visibleWrites,i.path);else{const h=i.children;Te(h,u=>{n.visibleWrites=Al(n.visibleWrites,se(i.path,u))})}return!0}else return!1}function qm(n,e){if(n.snap)return Re(n.path,e);for(const t in n.children)if(n.children.hasOwnProperty(t)&&Re(se(n.path,t),e))return!0;return!1}function Km(n){n.visibleWrites=Nh(n.allWrites,Ym,H()),n.allWrites.length>0?n.lastWriteId=n.allWrites[n.allWrites.length-1].writeId:n.lastWriteId=-1}function Ym(n){return n.visible}function Nh(n,e,t){let i=Pe.empty();for(let s=0;s<n.length;++s){const o=n[s];if(e(o)){const a=o.path;let h;if(o.snap)Re(t,a)?(h=Ie(t,a),i=Wn(i,h,o.snap)):Re(a,t)&&(h=Ie(a,t),i=Wn(i,H(),o.snap.getChild(h)));else if(o.children){if(Re(t,a))h=Ie(t,a),i=Cl(i,h,o.children);else if(Re(a,t))if(h=Ie(a,t),M(h))i=Cl(i,H(),o.children);else{const u=Zt(o.children,x(h));if(u){const f=u.getChild(z(h));i=Wn(i,H(),f)}}}else throw rn("WriteRecord should have .snap or .children")}}return i}function Ph(n,e,t,i,s){if(!i&&!s){const o=Ft(n.visibleWrites,e);if(o!=null)return o;{const a=gt(n.visibleWrites,e);if(mr(a))return t;if(t==null&&!_r(a,H()))return null;{const h=t||W.EMPTY_NODE;return sn(a,h)}}}else{const o=gt(n.visibleWrites,e);if(!s&&mr(o))return t;if(!s&&t==null&&!_r(o,H()))return null;{const a=function(f){return(f.visible||s)&&(!i||!~i.indexOf(f.writeId))&&(Re(f.path,e)||Re(e,f.path))},h=Nh(n.allWrites,a,e),u=t||W.EMPTY_NODE;return sn(h,u)}}}function Xm(n,e,t){let i=W.EMPTY_NODE;const s=Ft(n.visibleWrites,e);if(s)return s.isLeafNode()||s.forEachChild(he,(o,a)=>{i=i.updateImmediateChild(o,a)}),i;if(t){const o=gt(n.visibleWrites,e);return t.forEachChild(he,(a,h)=>{const u=sn(gt(o,new q(a)),h);i=i.updateImmediateChild(a,u)}),bl(o).forEach(a=>{i=i.updateImmediateChild(a.name,a.node)}),i}else{const o=gt(n.visibleWrites,e);return bl(o).forEach(a=>{i=i.updateImmediateChild(a.name,a.node)}),i}}function Jm(n,e,t,i,s){b(i||s,"Either existingEventSnap or existingServerSnap must exist");const o=se(e,t);if(_r(n.visibleWrites,o))return null;{const a=gt(n.visibleWrites,o);return mr(a)?s.getChild(t):sn(a,s.getChild(t))}}function Qm(n,e,t,i){const s=se(e,t),o=Ft(n.visibleWrites,s);if(o!=null)return o;if(i.isCompleteForChild(t)){const a=gt(n.visibleWrites,s);return sn(a,i.getNode().getImmediateChild(t))}else return null}function Zm(n,e){return Ft(n.visibleWrites,e)}function ey(n,e,t,i,s,o,a){let h;const u=gt(n.visibleWrites,e),f=Ft(u,H());if(f!=null)h=f;else if(t!=null)h=sn(u,t);else return[];if(h=h.withIndex(a),!h.isEmpty()&&!h.isLeafNode()){const E=[],y=a.getCompare(),S=o?h.getReverseIteratorFrom(i,a):h.getIteratorFrom(i,a);let k=S.getNext();for(;k&&E.length<s;)y(k,i)!==0&&E.push(k),k=S.getNext();return E}else return[]}function ty(){return{visibleWrites:Pe.empty(),allWrites:[],lastWriteId:-1}}function yr(n,e,t,i){return Ph(n.writeTree,n.treePath,e,t,i)}function Oh(n,e){return Xm(n.writeTree,n.treePath,e)}function Rl(n,e,t,i){return Jm(n.writeTree,n.treePath,e,t,i)}function qi(n,e){return Zm(n.writeTree,se(n.treePath,e))}function ny(n,e,t,i,s,o){return ey(n.writeTree,n.treePath,e,t,i,s,o)}function Kr(n,e,t){return Qm(n.writeTree,n.treePath,e,t)}function Dh(n,e){return Mh(se(n.treePath,e),n.writeTree)}function Mh(n,e){return{treePath:n,writeTree:e}}class iy{constructor(){this.changeMap=new Map}trackChildChange(e){const t=e.type,i=e.childName;b(t==="child_added"||t==="child_changed"||t==="child_removed","Only child changes supported for tracking"),b(i!==".priority","Only non-priority child changes can be tracked.");const s=this.changeMap.get(i);if(s){const o=s.type;if(t==="child_added"&&o==="child_removed")this.changeMap.set(i,El(i,e.snapshotNode,s.snapshotNode));else if(t==="child_removed"&&o==="child_added")this.changeMap.delete(i);else if(t==="child_removed"&&o==="child_changed")this.changeMap.set(i,Om(i,s.oldSnap));else if(t==="child_changed"&&o==="child_added")this.changeMap.set(i,Pm(i,e.snapshotNode));else if(t==="child_changed"&&o==="child_changed")this.changeMap.set(i,El(i,e.snapshotNode,s.oldSnap));else throw rn("Illegal combination of changes: "+e+" occurred after "+s)}else this.changeMap.set(i,e)}getChanges(){return Array.from(this.changeMap.values())}}class sy{getCompleteChild(e){return null}getChildAfterChild(e,t,i){return null}}const Lh=new sy;class Yr{constructor(e,t,i=null){this.writes_=e,this.viewCache_=t,this.optCompleteServerCache_=i}getCompleteChild(e){const t=this.viewCache_.eventCache;if(t.isCompleteForChild(e))return t.getNode().getImmediateChild(e);{const i=this.optCompleteServerCache_!=null?new qr(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return Kr(this.writes_,e,i)}}getChildAfterChild(e,t,i){const s=this.optCompleteServerCache_!=null?this.optCompleteServerCache_:Ut(this.viewCache_),o=ny(this.writes_,s,t,1,i,e);return o.length===0?null:o[0]}}function ry(n,e){b(e.eventCache.getNode().isIndexed(n.filter.getIndex()),"Event snap not indexed"),b(e.serverCache.getNode().isIndexed(n.filter.getIndex()),"Server snap not indexed")}function oy(n,e,t,i,s){const o=new iy;let a,h;
27if(t.type===Ve.OVERWRITE){const f=t;f.source.fromUser?a=vr(n,e,f.path,f.snap,i,s,o):(b(f.source.fromServer,"Unknown source."),h=f.source.tagged||e.serverCache.isFiltered()&&!M(f.path),a=Ki(n,e,f.path,f.snap,i,s,h,o))}else if(t.type===Ve.MERGE){const f=t;f.source.fromUser?a=ly(n,e,f.path,f.children,i,s,o):(b(f.source.fromServer,"Unknown source."),h=f.source.tagged||e.serverCache.isFiltered(),a=wr(n,e,f.path,f.children,i,s,h,o))}else if(t.type===Ve.ACK_USER_WRITE){const f=t;f.revert?a=uy(n,e,f.path,i,s,o):a=cy(n,e,f.path,f.affectedTree,i,s,o)}else if(t.type===Ve.LISTEN_COMPLETE)a=hy(n,e,t.path,i,o);else throw rn("Unknown operation type: "+t.type);const u=o.getChanges();return ay(e,a,u),{viewCache:a,changes:u}}function ay(n,e,t){const i=e.eventCache;if(i.isFullyInitialized()){const s=i.getNode().isLeafNode()||i.getNode().isEmpty(),o=gr(n);(t.length>0||!n.eventCache.isFullyInitialized()||s&&!i.getNode().equals(o)||!i.getNode().getPriority().equals(o.getPriority()))&&t.push(Nm(gr(e)))}}function xh(n,e,t,i,s,o){const a=e.eventCache;if(qi(i,t)!=null)return e;{let h,u;if(M(t))if(b(e.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),e.serverCache.isFiltered()){const f=Ut(e),E=f instanceof W?f:W.EMPTY_NODE,y=Oh(i,E);h=n.filter.updateFullNode(e.eventCache.getNode(),y,o)}else{const f=yr(i,Ut(e));h=n.filter.updateFullNode(e.eventCache.getNode(),f,o)}else{const f=x(t);if(f===".priority"){b(mt(t)===1,"Can't have a priority with additional path components");const E=a.getNode();u=e.serverCache.getNode();const y=Rl(i,t,E,u);y!=null?h=n.filter.updatePriority(E,y):h=a.getNode()}else{const E=z(t);let y;if(a.isCompleteForChild(f)){u=e.serverCache.getNode();const S=Rl(i,t,a.getNode(),u);S!=null?y=a.getNode().getImmediateChild(f).updateChild(E,S):y=a.getNode().getImmediateChild(f)}else y=Kr(i,f,e.serverCache);y!=null?h=n.filter.updateChild(a.getNode(),f,y,E,s,o):h=a.getNode()}}return Bn(e,h,a.isFullyInitialized()||M(t),n.filter.filtersNodes())}}function Ki(n,e,t,i,s,o,a,h){const u=e.serverCache;let f;const E=a?n.filter:n.filter.getIndexedFilter();if(M(t))f=E.updateFullNode(u.getNode(),i,null);else if(E.filtersNodes()&&!u.isFiltered()){const k=u.getNode().updateChild(t,i);f=E.updateFullNode(u.getNode(),k,null)}else{const k=x(t);if(!u.isCompleteForPath(t)&&mt(t)>1)return e;const R=z(t),N=u.getNode().getImmediateChild(k).updateChild(R,i);k===".priority"?f=E.updatePriority(u.getNode(),N):f=E.updateChild(u.getNode(),k,N,R,Lh,null)}const y=bh(e,f,u.isFullyInitialized()||M(t),E.filtersNodes()),S=new Yr(s,y,o);return xh(n,y,t,s,S,h)}function vr(n,e,t,i,s,o,a){const h=e.eventCache;let u,f;const E=new Yr(s,e,o);if(M(t))f=n.filter.updateFullNode(e.eventCache.getNode(),i,a),u=Bn(e,f,!0,n.filter.filtersNodes());else{const y=x(t);if(y===".priority")f=n.filter.updatePriority(e.eventCache.getNode(),i),u=Bn(e,f,h.isFullyInitialized(),h.isFiltered());else{const S=z(t),k=h.getNode().getImmediateChild(y);let R;if(M(S))R=i;else{const O=E.getCompleteChild(y);O!=null?dh(S)===".priority"&&O.getChild(ph(S)).isEmpty()?R=O:R=O.updateChild(S,i):R=W.EMPTY_NODE}if(k.equals(R))u=e;else{const O=n.filter.updateChild(h.getNode(),y,R,S,E,a);u=Bn(e,O,h.isFullyInitialized(),n.filter.filtersNodes())}}}return u}function kl(n,e){return n.eventCache.isCompleteForChild(e)}function ly(n,e,t,i,s,o,a){let h=e;return i.foreach((u,f)=>{const E=se(t,u);kl(e,x(E))&&(h=vr(n,h,E,f,s,o,a))}),i.foreach((u,f)=>{const E=se(t,u);kl(e,x(E))||(h=vr(n,h,E,f,s,o,a))}),h}function Nl(n,e,t){return t.foreach((i,s)=>{e=e.updateChild(i,s)}),e}function wr(n,e,t,i,s,o,a,h){if(e.serverCache.getNode().isEmpty()&&!e.serverCache.isFullyInitialized())return e;let u=e,f;M(t)?f=i:f=new G(null).setTree(t,i);const E=e.serverCache.getNode();return f.children.inorderTraversal((y,S)=>{if(E.hasChild(y)){const k=e.serverCache.getNode().getImmediateChild(y),R=Nl(n,k,S);u=Ki(n,u,new q(y),R,s,o,a,h)}}),f.children.inorderTraversal((y,S)=>{const k=!e.serverCache.isCompleteForChild(y)&&S.value===null;if(!E.hasChild(y)&&!k){const R=e.serverCache.getNode().getImmediateChild(y),O=Nl(n,R,S);u=Ki(n,u,new q(y),O,s,o,a,h)}}),u}function cy(n,e,t,i,s,o,a){if(qi(s,t)!=null)return e;const h=e.serverCache.isFiltered(),u=e.serverCache;
27if(i.value!=null){if(M(t)&&u.isFullyInitialized()||u.isCompleteForPath(t))return Ki(n,e,t,u.getNode().getChild(t),s,o,h,a);if(M(t)){let f=new G(null);return u.getNode().forEachChild(Qt,(E,y)=>{f=f.set(new q(E),y)}),wr(n,e,t,f,s,o,h,a)}else return e}else{let f=new G(null);return i.foreach((E,y)=>{const S=se(t,E);u.isCompleteForPath(S)&&(f=f.set(E,u.getNode().getChild(S)))}),wr(n,e,t,f,s,o,h,a)}}function hy(n,e,t,i,s){const o=e.serverCache,a=bh(e,o.getNode(),o.isFullyInitialized()||M(t),o.isFiltered());return xh(n,a,t,i,Lh,s)}function uy(n,e,t,i,s,o){let a;if(qi(i,t)!=null)return e;{const h=new Yr(i,e,s),u=e.eventCache.getNode();let f;if(M(t)||x(t)===".priority"){let E;if(e.serverCache.isFullyInitialized())E=yr(i,Ut(e));else{const y=e.serverCache.getNode();b(y instanceof W,"serverChildren would be complete if leaf node"),E=Oh(i,y)}E=E,f=n.filter.updateFullNode(u,E,o)}else{const E=x(t);let y=Kr(i,E,e.serverCache);y==null&&e.serverCache.isCompleteForChild(E)&&(y=u.getImmediateChild(E)),y!=null?f=n.filter.updateChild(u,E,y,z(t),h,o):e.eventCache.getNode().hasChild(E)?f=n.filter.updateChild(u,E,W.EMPTY_NODE,z(t),h,o):f=u,f.isEmpty()&&e.serverCache.isFullyInitialized()&&(a=yr(i,Ut(e)),a.isLeafNode()&&(f=n.filter.updateFullNode(f,a,o)))}return a=e.serverCache.isFullyInitialized()||qi(i,H())!=null,Bn(e,f,a,n.filter.filtersNodes())}}function dy(n,e){const t=Ut(n.viewCache_);return t&&(n.query._queryParams.loadsAllData()||!M(e)&&!t.getImmediateChild(x(e)).isEmpty())?t.getChild(e):null}function Pl(n,e,t,i){e.type===Ve.MERGE&&e.source.queryId!==null&&(b(Ut(n.viewCache_),"We should always have a full cache before handling merges"),b(gr(n.viewCache_),"Missing event cache, even though we have a server cache"));const s=n.viewCache_,o=oy(n.processor_,s,e,t,i);return ry(n.processor_,o.viewCache),b(o.viewCache.serverCache.isFullyInitialized()||!s.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),n.viewCache_=o.viewCache,fy(n,o.changes,o.viewCache.eventCache.getNode())}function fy(n,e,t,i){const s=n.eventRegistrations_;return Bm(n.eventGenerator_,e,t,s)}let Ol;function py(n){b(!Ol,"__referenceConstructor has already been defined"),Ol=n}function Xr(n,e,t,i){const s=e.source.queryId;if(s!==null){const o=n.views.get(s);return b(o!=null,"SyncTree gave us an op for an invalid query."),Pl(o,e,t,i)}else{let o=[];for(const a of n.views.values())o=o.concat(Pl(a,e,t,i));return o}}function Jr(n,e){let t=null;for(const i of n.views.values())t=t||dy(i,e);return t}let Dl;function gy(n){b(!Dl,"__referenceConstructor has already been defined"),Dl=n}class Ml{constructor(e){this.listenProvider_=e,this.syncPointTree_=new G(null),this.pendingWriteTree_=ty(),this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function _y(n,e,t,i,s){return $m(n.pendingWriteTree_,e,t,i,s),s?as(n,new xt(Th(),e,t)):[]}function zt(n,e,t=!1){const i=Gm(n.pendingWriteTree_,e);if(zm(n.pendingWriteTree_,e)){let o=new G(null);return i.snap!=null?o=o.set(H(),!0):Te(i.children,a=>{o=o.set(new q(a),!0)}),as(n,new zi(i.path,o,t))}else return[]}function os(n,e,t){return as(n,new xt(Sh(),e,t))}function my(n,e,t){const i=G.fromObject(t);return as(n,new qn(Sh(),e,i))}function yy(n,e,t,i){const s=Bh(n,i);if(s!=null){const o=Wh(s),a=o.path,h=o.queryId,u=Ie(a,e),f=new xt(Ch(h),u,t);return Hh(n,a,f)}else return[]}function vy(n,e,t,i){const s=Bh(n,i);if(s){const o=Wh(s),a=o.path,h=o.queryId,u=Ie(a,e),f=G.fromObject(t),E=new qn(Ch(h),u,f);return Hh(n,a,E)}else return[]}function Uh(n,e,t){const s=n.pendingWriteTree_,o=n.syncPointTree_.findOnPath(e,(a,h)=>{const u=Ie(a,e),f=Jr(h,u);if(f)return f});return Ph(s,e,o,t,!0)}function as(n,e){return Fh(e,n.syncPointTree_,null,kh(n.pendingWriteTree_,H()))}function Fh(n,e,t,i){if(M(n.path))return Vh(n,e,t,i);{const s=e.get(H());t==null&&s!=null&&(t=Jr(s,H()));let o=[];const a=x(n.path),h=n.operationForChild(a),u=e.children.get(a);if(u&&h){const f=t?t.getImmediateChild(a):null,E=Dh(i,a);o=o.concat(Fh(h,u,f,E))}return s&&(o=o.concat(Xr(s,n,i,t))),o}}function Vh(n,e,t,i){const s=e.get(H());t==null&&s!=null&&(t=Jr(s,H()));let o=[];return e.children.inorderTraversal((a,h)=>{const u=t?t.getImmediateChild(a):null,f=Dh(i,a),E=n.operationForChild(a);
27E&&(o=o.concat(Vh(E,h,u,f)))}),s&&(o=o.concat(Xr(s,n,i,t))),o}function Bh(n,e){return n.tagToQueryMap.get(e)}function Wh(n){const e=n.indexOf("$");return b(e!==-1&&e<n.length-1,"Bad queryKey."),{queryId:n.substr(e+1),path:new q(n.substr(0,e))}}function Hh(n,e,t){const i=n.syncPointTree_.get(e);b(i,"Missing sync point for query tag that we're tracking");const s=kh(n.pendingWriteTree_,e);return Xr(i,t,s,null)}class Qr{constructor(e){this.node_=e}getImmediateChild(e){const t=this.node_.getImmediateChild(e);return new Qr(t)}node(){return this.node_}}class Zr{constructor(e,t){this.syncTree_=e,this.path_=t}getImmediateChild(e){const t=se(this.path_,e);return new Zr(this.syncTree_,t)}node(){return Uh(this.syncTree_,this.path_)}}const wy=function(n){return n=n||{},n.timestamp=n.timestamp||new Date().getTime(),n},Ll=function(n,e,t){if(!n||typeof n!="object")return n;if(b(".sv"in n,"Unexpected leaf node or priority contents"),typeof n[".sv"]=="string")return Ey(n[".sv"],e,t);if(typeof n[".sv"]=="object")return Iy(n[".sv"],e);b(!1,"Unexpected server value: "+JSON.stringify(n,null,2))},Ey=function(n,e,t){switch(n){case"timestamp":return t.timestamp;default:b(!1,"Unexpected server value: "+n)}},Iy=function(n,e,t){n.hasOwnProperty("increment")||b(!1,"Unexpected server value: "+JSON.stringify(n,null,2));const i=n.increment;typeof i!="number"&&b(!1,"Unexpected increment value: "+i);const s=e.node();if(b(s!==null&&typeof s<"u","Expected ChildrenNode.EMPTY_NODE for nulls"),!s.isLeafNode())return i;const a=s.getValue();return typeof a!="number"?i:a+i},Ty=function(n,e,t,i){return eo(e,new Zr(t,n),i)},Sy=function(n,e,t){return eo(n,new Qr(e),t)};function eo(n,e,t){const i=n.getPriority().val(),s=Ll(i,e.getImmediateChild(".priority"),t);let o;if(n.isLeafNode()){const a=n,h=Ll(a.getValue(),e,t);return h!==a.getValue()||s!==a.getPriority().val()?new ne(h,ce(s)):n}else{const a=n;return o=a,s!==a.getPriority().val()&&(o=o.updatePriority(new ne(s))),a.forEachChild(he,(h,u)=>{const f=eo(u,e.getImmediateChild(h),t);f!==u&&(o=o.updateImmediateChild(h,f))}),o}}class to{constructor(e="",t=null,i={children:{},childCount:0}){this.name=e,this.parent=t,this.node=i}}function no(n,e){let t=e instanceof q?e:new q(e),i=n,s=x(t);for(;s!==null;){const o=Zt(i.node.children,s)||{children:{},childCount:0};i=new to(s,i,o),t=z(t),s=x(t)}return i}function hn(n){return n.node.value}function jh(n,e){n.node.value=e,Er(n)}function $h(n){return n.node.childCount>0}function Cy(n){return hn(n)===void 0&&!$h(n)}function ls(n,e){Te(n.node.children,(t,i)=>{e(new to(t,n,i))})}function Gh(n,e,t,i){t&&e(n),ls(n,s=>{Gh(s,e,!0)})}function Ay(n,e,t){let i=n.parent;for(;i!==null;){if(e(i))return!0;i=i.parent}return!1}function ii(n){return new q(n.parent===null?n.name:ii(n.parent)+"/"+n.name)}function Er(n){n.parent!==null&&by(n.parent,n.name,n)}function by(n,e,t){const i=Cy(t),s=et(n.node.children,e);i&&s?(delete n.node.children[e],n.node.childCount--,Er(n)):!i&&!s&&(n.node.children[e]=t.node,n.node.childCount++,Er(n))}const Ry=/[\[\].#$\/\u0000-\u001F\u007F]/,ky=/[\[\].#$\u0000-\u001F\u007F]/,Xs=10*1024*1024,zh=function(n){return typeof n=="string"&&n.length!==0&&!Ry.test(n)},Ny=function(n){return typeof n=="string"&&n.length!==0&&!ky.test(n)},Py=function(n){return n&&(n=n.replace(/^\/*\.info(\/|$)/,"/")),Ny(n)},qh=function(n,e,t){const i=t instanceof q?new hm(t,n):t;if(e===void 0)throw new Error(n+"contains undefined "+Ct(i));if(typeof e=="function")throw new Error(n+"contains a function "+Ct(i)+" with contents = "+e.toString());if(zc(e))throw new Error(n+"contains "+e.toString()+" "+Ct(i));if(typeof e=="string"&&e.length>Xs/3&&Zi(e)>Xs)throw new Error(n+"contains a string greater than "+Xs+" utf8 bytes "+Ct(i)+" ('"+e.substring(0,50)+"...')");if(e&&typeof e=="object"){let s=!1,o=!1;if(Te(e,(a,h)=>{if(a===".value")s=!0;else if(a!==".priority"&&a!==".sv"&&(o=!0,!zh(a)))throw new Error(n+" contains an invalid key ("+a+") "+Ct(i)+`. Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"`);um(i,a),qh(n,h,i),dm(i)}),s&&o)throw new Error(n+' contains ".value" child '+Ct(i)+" in addition to actual children.")}},Oy=function(n,e){const t=e.path.toString();if(typeof e.repoInfo.host!="string"||e.repoInfo.host.length===0||!zh(e.repoInfo.namespace)&&e.repoInfo.host.split(":")[0]!=="localhost"||t.length!==0&&!Py(t))throw new Error(hd(n,"url")+`must be a valid firebase URL and the path can't
27contain ".", "#", "$", "[", or "]".`)};class Dy{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function My(n,e){let t=null;for(let i=0;i<e.length;i++){const s=e[i],o=s.getPath();t!==null&&!gh(o,t.path)&&(n.eventLists_.push(t),t=null),t===null&&(t={events:[],path:o}),t.events.push(s)}t&&n.eventLists_.push(t)}function Vt(n,e,t){My(n,t),Ly(n,i=>Re(i,e)||Re(e,i))}function Ly(n,e){n.recursionDepth_++;let t=!0;for(let i=0;i<n.eventLists_.length;i++){const s=n.eventLists_[i];if(s){const o=s.path;e(o)?(xy(n.eventLists_[i]),n.eventLists_[i]=null):t=!1}}t&&(n.eventLists_=[]),n.recursionDepth_--}function xy(n){for(let e=0;e<n.events.length;e++){const t=n.events[e];if(t!==null){n.events[e]=null;const i=t.getEventRunner();Fn&&le("event: "+t.toString()),ti(i)}}}const Uy="repo_interrupt",Fy=25;class Vy{constructor(e,t,i,s){this.repoInfo_=e,this.forceRestClient_=t,this.authTokenProvider_=i,this.appCheckProvider_=s,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new Dy,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=Gi(),this.transactionQueueTree_=new to,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function By(n,e,t){if(n.stats_=Hr(n.repoInfo_),n.forceRestClient_||M_())n.server_=new $i(n.repoInfo_,(i,s,o,a)=>{xl(n,i,s,o,a)},n.authTokenProvider_,n.appCheckProvider_),setTimeout(()=>Ul(n,!0),0);else{if(typeof t<"u"&&t!==null){if(typeof t!="object")throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{re(t)}catch(i){throw new Error("Invalid authOverride provided: "+i)}}n.persistentConnection_=new Je(n.repoInfo_,e,(i,s,o,a)=>{xl(n,i,s,o,a)},i=>{Ul(n,i)},i=>{Hy(n,i)},n.authTokenProvider_,n.appCheckProvider_,t),n.server_=n.persistentConnection_}n.authTokenProvider_.addTokenChangeListener(i=>{n.server_.refreshAuthToken(i)}),n.appCheckProvider_.addTokenChangeListener(i=>{n.server_.refreshAppCheckToken(i.token)}),n.statsReporter_=B_(n.repoInfo_,()=>new Vm(n.stats_,n.server_)),n.infoData_=new Mm,n.infoSyncTree_=new Ml({startListening:(i,s,o,a)=>{let h=[];const u=n.infoData_.getNode(i._path);return u.isEmpty()||(h=os(n.infoSyncTree_,i._path,u),setTimeout(()=>{a("ok")},0)),h},stopListening:()=>{}}),io(n,"connected",!1),n.serverSyncTree_=new Ml({startListening:(i,s,o,a)=>(n.server_.listen(i,o,s,(h,u)=>{const f=a(h,u);Vt(n.eventQueue_,i._path,f)}),[]),stopListening:(i,s)=>{n.server_.unlisten(i,s)}})}function Wy(n){const t=n.infoData_.getNode(new q(".info/serverTimeOffset")).val()||0;return new Date().getTime()+t}function Kh(n){return wy({timestamp:Wy(n)})}function xl(n,e,t,i,s){n.dataUpdateCount++;const o=new q(e);t=n.interceptServerDataCallback_?n.interceptServerDataCallback_(e,t):t;let a=[];if(s)if(i){const u=ki(t,f=>ce(f));a=vy(n.serverSyncTree_,o,u,s)}else{const u=ce(t);a=yy(n.serverSyncTree_,o,u,s)}else if(i){const u=ki(t,f=>ce(f));a=my(n.serverSyncTree_,o,u)}else{const u=ce(t);a=os(n.serverSyncTree_,o,u)}let h=o;a.length>0&&(h=ro(n,o)),Vt(n.eventQueue_,h,a)}function Ul(n,e){io(n,"connected",e),e===!1&&$y(n)}function Hy(n,e){Te(e,(t,i)=>{io(n,t,i)})}function io(n,e,t){const i=new q("/.info/"+e),s=ce(t);n.infoData_.updateSnapshot(i,s);const o=os(n.infoSyncTree_,i,s);Vt(n.eventQueue_,i,o)}function jy(n){return n.nextWriteId_++}function $y(n){Yh(n,"onDisconnectEvents");const e=Kh(n),t=Gi();pr(n.onDisconnect_,H(),(s,o)=>{const a=Ty(s,o,n.serverSyncTree_,e);Ih(t,s,a)});let i=[];pr(t,H(),(s,o)=>{i=i.concat(os(n.serverSyncTree_,s,o));const a=Ky(n,s);ro(n,a)}),n.onDisconnect_=Gi(),Vt(n.eventQueue_,H(),i)}function Gy(n){n.persistentConnection_&&n.persistentConnection_.interrupt(Uy)}function Yh(n,...e){let t="";n.persistentConnection_&&(t=n.persistentConnection_.id+":"),le(t,...e)}function Xh(n,e,t){return Uh(n.serverSyncTree_,e,t)||W.EMPTY_NODE}function so(n,e=n.transactionQueueTree_){if(e||cs(n,e),hn(e)){const t=Qh(n,e);b(t.length>0,"Sending zero length transaction queue"),t.every(s=>s.status===0)&&zy(n,ii(e),t)}else $h(e)&&ls(e,t=>{so(n,t)})}function zy(n,e,t){const i=t.map(f=>f.currentWriteId),s=Xh(n,e,i);let o=s;const a=s.hash();for(let f=0;f<t.length;f++){const E=t[f];b(E.status===0,"tryToSendTransactionQueue_: items in queue should all be run."),E.status=1,E.retryCount++;const y=Ie(e,E.path);o=o.updateChild(y,E.currentOutputSnapshotRaw)}const h=o.val(!0),u=e;n.server_.put(u.toString(),h,f=>{Yh(n,"transaction put response",{path:u.toString(),status:f});let E=[];if(f==="ok"){const y=[];for(let S=0;S<t.length;S++)t[S].status=2,E=E.concat(zt(n.serverSyncTree_,t[S].currentWriteId)),t[S].onComplete&&y.push(()=>t[S].onComplete(null,!0,t[S].currentOutputSnapshotResolved)),t[S].unwatcher();cs(n,no(n.transactionQueueTree_,e)),so(n,n.transactionQueueTree_),Vt(n.eventQueue_,e,E);for(let S=0;S<y.length;S++)ti(y[S])}else{if(f==="datastale")for(let y=0;y<t.length;y++)t[y].status===3?t[y].status=4:t[y].status=0;else{we("transaction at "+u.toString()+" failed: "+f);for(let y=0;y<t.length;y++)t[y].status=4,t[y].abortReason=f}ro(n,e)}},a)}function ro(n,e){const t=Jh(n,e),i=ii(t),s=Qh(n,t);return qy(n,s,i),i}function qy(n,e,t){if(e.length===0)return;const i=[];let s=[];const a=e.filter(h=>h.status===0).map(h=>h.currentWriteId);for(let h=0;h<e.length;h++){const u=e[h],f=Ie(t,u.path);let E=!1,y;if(b(f!==null,"rerunTransactionsUnderNode_: relativePath should not be null."),u.status===4)E=!0,y=u.abortReason,s=s.concat(zt(n.serverSyncTree_,u.currentWriteId,!0));else if(u.status===0)if(u.retryCount>=Fy)E=!0,y="maxretry",s=s.concat(zt(n.serverSyncTree_,u.currentWriteId,!0));else{const S=Xh(n,u.path,a);u.currentInputSnapshot=S;const k=e[h].update(S.val());if(k!==void 0){qh("transaction failed: Data returned ",k,u.path);let R=ce(k);typeof k=="object"&&k!=null&&et(k,".priority")||(R=R.updatePriority(S.getPri
27ority()));const N=u.currentWriteId,Y=Kh(n),Q=Sy(R,S,Y);u.currentOutputSnapshotRaw=R,u.currentOutputSnapshotResolved=Q,u.currentWriteId=jy(n),a.splice(a.indexOf(N),1),s=s.concat(_y(n.serverSyncTree_,u.path,Q,u.currentWriteId,u.applyLocally)),s=s.concat(zt(n.serverSyncTree_,N,!0))}else E=!0,y="nodata",s=s.concat(zt(n.serverSyncTree_,u.currentWriteId,!0))}Vt(n.eventQueue_,t,s),s=[],E&&(e[h].status=2,(function(S){setTimeout(S,Math.floor(0))})(e[h].unwatcher),e[h].onComplete&&(y==="nodata"?i.push(()=>e[h].onComplete(null,!1,e[h].currentInputSnapshot)):i.push(()=>e[h].onComplete(new Error(y),!1,null))))}cs(n,n.transactionQueueTree_);for(let h=0;h<i.length;h++)ti(i[h]);so(n,n.transactionQueueTree_)}function Jh(n,e){let t,i=n.transactionQueueTree_;for(t=x(e);t!==null&&hn(i)===void 0;)i=no(i,t),e=z(e),t=x(e);return i}function Qh(n,e){const t=[];return Zh(n,e,t),t.sort((i,s)=>i.order-s.order),t}function Zh(n,e,t){const i=hn(e);if(i)for(let s=0;s<i.length;s++)t.push(i[s]);ls(e,s=>{Zh(n,s,t)})}function cs(n,e){const t=hn(e);if(t){let i=0;for(let s=0;s<t.length;s++)t[s].status!==2&&(t[i]=t[s],i++);t.length=i,jh(e,t.length>0?t:void 0)}ls(e,i=>{cs(n,i)})}function Ky(n,e){const t=ii(Jh(n,e)),i=no(n.transactionQueueTree_,e);return Ay(i,s=>{Js(n,s)}),Js(n,i),Gh(i,s=>{Js(n,s)}),t}function Js(n,e){const t=hn(e);if(t){const i=[];let s=[],o=-1;for(let a=0;a<t.length;a++)t[a].status===3||(t[a].status===1?(b(o===a-1,"All SENT items should be at beginning of queue."),o=a,t[a].status=3,t[a].abortReason="set"):(b(t[a].status===0,"Unexpected transaction status in abort"),t[a].unwatcher(),s=s.concat(zt(n.serverSyncTree_,t[a].currentWriteId,!0)),t[a].onComplete&&i.push(t[a].onComplete.bind(null,new Error("set"),!1,null))));o===-1?jh(e,void 0):t.length=o+1,Vt(n.eventQueue_,ii(e),s);for(let a=0;a<i.length;a++)ti(i[a])}}function Yy(n){let e="";const t=n.split("/");for(let i=0;i<t.length;i++)if(t[i].length>0){let s=t[i];try{s=decodeURIComponent(s.replace(/\+/g," "))}catch{}e+="/"+s}return e}function Xy(n){const e={};n.charAt(0)==="?"&&(n=n.substring(1));for(const t of n.split("&")){if(t.length===0)continue;const i=t.split("=");i.length===2?e[decodeURIComponent(i[0])]=decodeURIComponent(i[1]):we(`Invalid query segment '${t}' in query '${n}'`)}return e}const Fl=function(n,e){const t=Jy(n),i=t.namespace;t.domain==="firebase.com"&&Mt(t.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),(!i||i==="undefined")&&t.domain!=="localhost"&&Mt("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),t.secure||A_();const s=t.scheme==="ws"||t.scheme==="wss";return{repoInfo:new U_(t.host,t.secure,i,s,e,"",i!==t.subdomain),path:new q(t.pathString)}},Jy=function(n){let e="",t="",i="",s="",o="",a=!0,h="https",u=443;if(typeof n=="string"){let f=n.indexOf("//");f>=0&&(h=n.substring(0,f-1),n=n.substring(f+2));let E=n.indexOf("/");E===-1&&(E=n.length);let y=n.indexOf("?");y===-1&&(y=n.length),e=n.substring(0,Math.min(E,y)),E<y&&(s=Yy(n.substring(E,y)));const S=Xy(n.substring(Math.min(n.length,y)));f=e.indexOf(":"),f>=0?(a=h==="https"||h==="wss",u=parseInt(e.substring(f+1),10)):f=e.length;const k=e.slice(0,f);if(k.toLowerCase()==="localhost")t="localhost";else if(k.split(".").length<=2)t=k;else{const R=e.indexOf(".");i=e.substring(0,R).toLowerCase(),t=e.substring(R+1),o=i}"ns"in S&&(o=S.ns)}return{host:e,port:u,domain:t,subdomain:i,secure:a,scheme:h,pathString:s,namespace:o}};class oo{constructor(e,t,i,s){this._repo=e,this._path=t,this._queryParams=i,this._orderByCalled=s}get key(){return M(this._path)?null:dh(this._path)}get ref(){return new un(this._repo,this._path)}get _queryIdentifier(){const e=Tl(this._queryParams),t=Br(e);return t==="{}"?"default":t}get _queryObject(){return Tl(this._queryParams)}isEqual(e){if(e=Ge(e),!(e instanceof oo))return!1;const t=this._repo===e._repo,i=gh(this._path,e._path),s=this._queryIdentifier===e._queryIdentifier;return t&&i&&s}toJSON(){return this.toString()}toString(){return this._repo.toString()+cm(this._path)}}class un extends oo{constructor(e,t){super(e,t,new zr,!1)}get parent(){const e=ph(this._path);return e===null?null:new un(this._repo,e)}get root(){let e=this;for(;e.parent!==null;)e=e.parent;return e}}py(un);gy(un);const Qy="FIREBASE_DATABASE_EMULATOR_HOST",Ir={};let Zy=!1;function ev(n,e,t,i,s){let o=i||n.options.databaseURL;o===void 0&&(n.options.projectId||Mt("Can't determine Firebase Database URL. Be sure to include a Project ID when calling firebase.initializeApp()."),le("Using default host for project ",n.options.projectId),o=`${n.options.projectId}-default-rtdb.firebaseio.com`);let a=Fl(o,s),h=a.repoInfo,u;typeof process<"u"&&sl&&(u=sl[Qy]),u?(o=`http://${u}?ns=${h.namespace}`,a=Fl(o,s),h=a.repoInfo):a.repoInfo.secure;const f=new x_(n.name,n.options,e);Oy("Invalid Firebase Database URL",a),M(a.path)||Mt("Database URL must point to the root of a Firebase Database (not including a child path).");const E=nv(h,n,f,new L_(n,t));return new iv(E,n)}function tv(n,e){const t=Ir[e];(!t||t[n.key]!==n)&&Mt(`Database ${e}(${n.repoInfo_}) has already been deleted.`),Gy(n),delete t[n.key]}function nv(n,e,t,i){let s=Ir[e.name];s||(s={},Ir[e.name]=s);let o=s[n.toURLString()];return o&&Mt("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),o=new Vy(n,Zy,t,i),s[n.toURLString()]=o,o}class iv{constructor(e,t){this._repoInternal=e,this.app=t,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(By(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new un(this._repo,H())),this._rootInternal}_delete(){return this._rootInternal!==null&&(tv(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(e){this._rootInternal===null&&Mt("Cannot call "+e+" on a deleted database.")}}function sv(n){w_(yt),We(new Oe("database",(e,{instanceIdentifier:t})=>{const i=e.getProvider("app").getImmediate(),s=e.getProvider("auth-internal"),o=e.getProvider("app-check-internal");return ev(i,s,o,t)},"PUBLIC").setMultipleInstances(!0)),ve(rl,ol,n),ve(rl,ol,"esm2020")}Je.prototype.simpleListen=function(n,e){this.sendRequest("q",{p:n},e)};Je.prototype.echo=function(n,e){this.sendRequest("echo",{d:n},e)};sv();const eu="firebasestorage.googleapis.com",rv="storageBucket",ov=120*1e3,av=600*1e3;class ze extends $e{constructor(e,t,i=0){super(Qs(e),`Firebase Storage: ${t} (${Qs(e)})`),this.status_=i,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,ze.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return Qs(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage} 28${this.customData.serverResponse}`:this.message=this._baseMessage}}var je;(function(n){n.UNKNOWN="unknown",n.OBJECT_NOT_FOUND="object-not-found",n.BUCKET_NOT_FOUND="bucket-not-found",n.PROJECT_NOT_FOUND="project-not-found",n.QUOTA_EXCEEDED="quota-exceeded",n.UNAUTHENTICATED="unauthenticated",n.UNAUTHORIZED="unauthorized",n.UNAUTHORIZED_APP="unauthorized-app",n.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",n.INVALID_CHECKSUM="invalid-checksum",n.CANCELED="canceled",n.INVALID_EVENT_NAME="invalid-event-name",n.INVALID_URL="invalid-url",n.INVALID_DEFAULT_BUCKET="invalid-default-bucket",n.NO_DEFAULT_BUCKET="no-default-bucket",n.CANNOT_SLICE_BLOB="cannot-slice-blob",n.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",n.NO_DOWNLOAD_URL="no-download-url",n.INVALID_ARGUMENT="invalid-argument",n.INVALID_ARGUMENT_COUNT="invalid-argument-count",n.APP_DELETED="app-deleted",n.INVALID_ROOT_OPERATION="invalid-root-operation",n.INVALID_FORMAT="invalid-format",n.INTERNAL_ERROR="internal-error",n.UNSUPPORTED_ENVIRONMENT="unsupported-environment"})(je||(je={}));function Qs(n){return"storage/"+n}function lv(){const n="An unknown error occurred, please check the error payload for server response.";return new ze(je.UNKNOWN,n)}function cv(){return new ze(je.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function hv(){return new ze(je.CANCELED,"User canceled the upload/download.")}function uv(n){return new ze(je.INVALID_URL,"Invalid URL '"+n+"'.")}function dv(n){return new ze(je.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+n+"'.")}function Vl(n){return new ze(je.INVALID_ARGUMENT,n)}function tu(){return new ze(je.APP_DELETED,"The Firebase app was deleted.")}function fv(n){return new ze(je.INVALID_ROOT_OPERATION,"The operation '"+n+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}class ke{constructor(e,t){this.bucket=e,this.path_=t}get path(){return this.path_}get isRoot(){return this.path.length===0}fullServerUrl(){const e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(e,t){let i;try{i=ke.makeFromUrl(e,t)}catch{return new ke(e,"")}if(i.path==="")return i;throw dv(e)}static makeFromUrl(e,t){let i=null;const s="([A-Za-z0-9.\\-_]+)";function o(X){X.path.charAt(X.path.length-1)==="/"&&(X.path_=X.path_.slice(0,-1))}const a="(/(.*))?$",h=new RegExp("^gs://"+s+a,"i"),u={bucket:1,path:3};function f(X){X.path_=decodeURIComponent(X.path)}const E="v[A-Za-z0-9_]+",y=t.replace(/[.]/g,"\\."),S="(/([^?#]*).*)?$",k=new RegExp(`^https?://${y}/${E}/b/${s}/o${S}`,"i"),R={bucket:1,path:3},O=t===eu?"(?:storage.googleapis.com|storage.cloud.google.com)":t,N="([^?#]*)",Y=new RegExp(`^https?://${O}/${s}/${N}`,"i"),K=[{regex:h,indices:u,postModify:o},{regex:k,indices:R,postModify:f},{regex:Y,indices:{bucket:1,path:2},postModify:f}];for(let X=0;X<K.length;X++){const _e=K[X],oe=_e.regex.exec(e);if(oe){const v=oe[_e.indices.bucket];let p=oe[_e.indices.path];p||(p=""),i=new ke(v,p),_e.postModify(i);break}}if(i==null)throw uv(e);return i}}class pv{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}}
28function gv(n,e,t){let i=1,s=null,o=null,a=!1,h=0;function u(){return h===2}let f=!1;function E(...N){f||(f=!0,e.apply(null,N))}function y(N){s=setTimeout(()=>{s=null,n(k,u())},N)}function S(){o&&clearTimeout(o)}function k(N,...Y){if(f){S();return}if(N){S(),E.call(null,N,...Y);return}if(u()||a){S(),E.call(null,N,...Y);return}i<64&&(i*=2);let K;h===1?(h=2,K=0):K=(i+Math.random())*1e3,y(K)}let R=!1;function O(N){R||(R=!0,S(),!f&&(s!==null?(N||(h=2),clearTimeout(s),y(0)):N||(h=1)))}return y(0),o=setTimeout(()=>{a=!0,O(!0)},t),O}function _v(n){n(!1)}function mv(n){return n!==void 0}function Bl(n,e,t,i){if(i<e)throw Vl(`Invalid value for '${n}'. Expected ${e} or greater.`);if(i>t)throw Vl(`Invalid value for '${n}'. Expected ${t} or less.`)}function yv(n){const e=encodeURIComponent;let t="?";for(const i in n)if(n.hasOwnProperty(i)){const s=e(i)+"="+e(n[i]);t=t+s+"&"}return t=t.slice(0,-1),t}var Yi;(function(n){n[n.NO_ERROR=0]="NO_ERROR",n[n.NETWORK_ERROR=1]="NETWORK_ERROR",n[n.ABORT=2]="ABORT"})(Yi||(Yi={}));function vv(n,e){const t=n>=500&&n<600,s=[408,429].indexOf(n)!==-1,o=e.indexOf(n)!==-1;return t||s||o}class wv{constructor(e,t,i,s,o,a,h,u,f,E,y,S=!0,k=!1){this.url_=e,this.method_=t,this.headers_=i,this.body_=s,this.successCodes_=o,this.additionalRetryCodes_=a,this.callback_=h,this.errorCallback_=u,this.timeout_=f,this.progressCallback_=E,this.connectionFactory_=y,this.retry=S,this.isUsingEmulator=k,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((R,O)=>{this.resolve_=R,this.reject_=O,this.start_()})}start_(){const e=(i,s)=>{if(s){i(!1,new Ii(!1,null,!0));return}const o=this.connectionFactory_();this.pendingConnection_=o;const a=h=>{const u=h.loaded,f=h.lengthComputable?h.total:-1;this.progressCallback_!==null&&this.progressCallback_(u,f)};this.progressCallback_!==null&&o.addUploadProgressListener(a),o.send(this.url_,this.method_,this.isUsingEmulator,this.body_,this.headers_).then(()=>{this.progressCallback_!==null&&o.removeUploadProgressListener(a),this.pendingConnection_=null;const h=o.getErrorCode()===Yi.NO_ERROR,u=o.getStatus();if(!h||vv(u,this.additionalRetryCodes_)&&this.retry){const E=o.getErrorCode()===Yi.ABORT;i(!1,new Ii(!1,null,E));return}const f=this.successCodes_.indexOf(u)!==-1;i(!0,new Ii(f,o))})},t=(i,s)=>{const o=this.resolve_,a=this.reject_,h=s.connection;if(s.wasSuccessCode)try{const u=this.callback_(h,h.getResponse());mv(u)?o(u):o()}catch(u){a(u)}else if(h!==null){const u=lv();
28u.serverResponse=h.getErrorText(),this.errorCallback_?a(this.errorCallback_(h,u)):a(u)}else if(s.canceled){const u=this.appDelete_?tu():hv();a(u)}else{const u=cv();a(u)}};this.canceled_?t(!1,new Ii(!1,null,!0)):this.backoffId_=gv(e,t,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&_v(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}}class Ii{constructor(e,t,i){this.wasSuccessCode=e,this.connection=t,this.canceled=!!i}}function Ev(n,e){e!==null&&e.length>0&&(n.Authorization="Firebase "+e)}function Iv(n,e){n["X-Firebase-Storage-Version"]="webjs/"+(e??"AppManager")}function Tv(n,e){e&&(n["X-Firebase-GMPID"]=e)}function Sv(n,e){e!==null&&(n["X-Firebase-AppCheck"]=e)}function Cv(n,e,t,i,s,o,a=!0,h=!1){const u=yv(n.urlParams),f=n.url+u,E=Object.assign({},n.headers);return Tv(E,e),Ev(E,t),Iv(E,o),Sv(E,i),new wv(f,n.method,E,n.body,n.successCodes,n.additionalRetryCodes,n.handler,n.errorHandler,n.timeout,n.progressCallback,s,a,h)}function Av(n){if(n.length===0)return null;const e=n.lastIndexOf("/");return e===-1?"":n.slice(0,e)}function bv(n){const e=n.lastIndexOf("/",n.length-2);return e===-1?n:n.slice(e+1)}class Xi{constructor(e,t){this._service=e,t instanceof ke?this._location=t:this._location=ke.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new Xi(e,t)}get root(){const e=new ke(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return bv(this._location.path)}get storage(){return this._service}get parent(){const e=Av(this._location.path);if(e===null)return null;const t=new ke(this._location.bucket,e);return new Xi(this._service,t)}_throwIfRoot(e){if(this._location.path==="")throw fv(e)}}function Wl(n,e){const t=e?.[rv];return t==null?null:ke.makeFromBucketSpec(t,n)}class Rv{constructor(e,t,i,s,o,a=!1){this.app=e,this._authProvider=t,this._appCheckProvider=i,this._url=s,this._firebaseVersion=o,this._isUsingEmulator=a,this._bucket=null,this._host=eu,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=ov,this._maxUploadRetryTime=av,this._requests=new Set,s!=null?this._bucket=ke.makeFromBucketSpec(s,this._host):this._bucket=Wl(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,this._url!=null?this._bucket=ke.makeFromBucketSpec(this._url,e):this._bucket=Wl(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){Bl("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){Bl("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;const e=this._authProvider.getImmediate({optional:!0});if(e){const t=await e.getToken();if(t!==null)return t.accessToken}return null}async _getAppCheckToken(){if(ye(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=this._appCheckProvider.getImmediate({optional:!0});return e?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new Xi(this,e)}_makeRequest(e,t,i,s,o=!0){if(this._deleted)return new pv(tu());{const a=Cv(e,this._appId,i,s,t,this._firebaseVersion,o,this._isUsingEmulator);return this._requests.add(a),a.getPromise().then(()=>this._requests.delete(a),()=>this._requests.delete(a)),a}}async makeRequestWithTokens(e,t){const[i,s]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,i,s).getPromise()}}const Hl="@firebase/storage",jl="0.14.0";
28const kv="storage";function Nv(n,{instanceIdentifier:e}){const t=n.getProvider("app").getImmediate(),i=n.getProvider("auth-internal"),s=n.getProvider("app-check-internal");return new Rv(t,i,s,e,yt)}function Pv(){We(new Oe(kv,Nv,"PUBLIC").setMultipleInstances(!0)),ve(Hl,jl,""),ve(Hl,jl,"esm2020")}Pv();export{kt as G,Ue as T,ut as a,ct as b,Mv as c,xp as d,df as e,bp as f,xv as g,Bg as h,uf as i,Qp as j,Bp as k,Lv as l,Ov as o,Qf as p,Dv as s};
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.