cic-kit 0.0.11 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/cic-kit.css +1 -1
- package/dist/cmp/Accordion/Accordion.vue.d.ts +25 -0
- package/dist/cmp/Avatar/Avatar.vue.d.ts +23 -0
- package/dist/cmp/Avatar/AvatarUser.d.ts +51 -0
- package/dist/cmp/Avatar/AvatarUserCmp.vue.d.ts +7 -0
- package/dist/cmp/Avatar/AvatarUserEditor.vue.d.ts +3 -0
- package/dist/cmp/Avatar/AvatarUserPicker.vue.d.ts +16 -0
- package/dist/cmp/Avatar/AvatarUserPickerGender.vue.d.ts +18 -0
- package/dist/cmp/Btn/Btn.vue.d.ts +34 -0
- package/dist/cmp/Btn/BtnGoogleLogin.vue.d.ts +3 -0
- package/dist/cmp/Btn/PwaUpdateButton.vue.d.ts +3 -0
- package/dist/cmp/Container/ContainerSideTabs.vue.d.ts +120 -0
- package/dist/cmp/Container/ContainerSubSettings.vue.d.ts +17 -0
- package/dist/cmp/Container/SideTabCmp.vue.d.ts +59 -0
- package/dist/cmp/Container/SideTabs.d.ts +13 -0
- package/dist/cmp/Container/SideTabsList.vue.d.ts +46 -0
- package/dist/cmp/File/FirebaseStrorage.d.ts +61 -0
- package/dist/cmp/File/ImgUploader.vue.d.ts +34 -0
- package/dist/cmp/Logo/Logo.vue.d.ts +11 -0
- package/dist/cmp/Modal/Modal.vue.d.ts +85 -0
- package/dist/cmp/ModalDev/HomeViewDev.vue.d.ts +3 -0
- package/dist/cmp/ModalDev/ModalDev.vue.d.ts +26 -0
- package/dist/cmp/ModalDev/view/AppConfigViewDev.vue.d.ts +3 -0
- package/dist/cmp/ModalDev/view/FireStoreDevView.vue.d.ts +7 -0
- package/dist/cmp/ModalDev/view/LSViewDev.vue.d.ts +3 -0
- package/dist/cmp/ModalDev/view/MsgPushViewDev.vue.d.ts +3 -0
- package/dist/cmp/RegisterSW.vue.d.ts +13 -0
- package/dist/cmp/checkVersionPkg/checkVersionPkg.d.ts +1 -0
- package/dist/cmp/firebase/FirestoreStore.d.ts +2 -2
- package/dist/cmp/form-validator/InputValueParser.d.ts +1 -1
- package/dist/cmp/header/useChangeHeader.d.ts +2 -0
- package/dist/cmp/header/useHeaderExtra.d.ts +2 -0
- package/dist/cmp/header/useHideHeader.d.ts +1 -0
- package/dist/cmp/input/Gender/FieldGender.vue.d.ts +31 -0
- package/dist/cmp/input/PhoneNumber/FieldPhoneNumber.vue.d.ts +37 -0
- package/dist/cmp/input/Tag/ColorTag.d.ts +6 -0
- package/dist/cmp/input/Tag/ColorTagInput.vue.d.ts +37 -0
- package/dist/cmp/input/Tag/TagInput.vue.d.ts +27 -0
- package/dist/cmp/input/Tag/colorTagDB/foodPreferenceTags.d.ts +2 -0
- package/dist/cmp/input/Text/InputField.vue.d.ts +34 -0
- package/dist/cmp/input/Tiptap/TiptapField.vue.d.ts +15 -0
- package/dist/cmp/layout/FooterApp.vue.d.ts +3 -0
- package/dist/cmp/layout/HeaderApp.vue.d.ts +3 -0
- package/dist/cmp/layout/ToolbarTab.vue.d.ts +10 -0
- package/dist/cmp/loading/LoaderCmp.vue.d.ts +3 -0
- package/dist/cmp/loading/LoadingText.vue.d.ts +3 -0
- package/dist/cmp/loading/loadingController.d.ts +8 -0
- package/dist/cmp/offCanvas/Offcanvas.vue.d.ts +45 -0
- package/dist/cmp/offCanvas/OffcanvasCmp.vue.d.ts +78 -0
- package/dist/cmp/offCanvas/useSetOffCanvasTabs.d.ts +2 -0
- package/dist/cmp/testUtility/delay.d.ts +5 -0
- package/dist/cmp/testUtility/generaColore.d.ts +6 -0
- package/dist/cmp/testUtility/generaDate.d.ts +55 -0
- package/dist/cmp/testUtility/generaDatiPersonali.d.ts +35 -0
- package/dist/cmp/testUtility/generaNumero.d.ts +5 -0
- package/dist/cmp/testUtility/generaTesto.d.ts +17 -0
- package/dist/cmp/testUtility/pickRandom.d.ts +5 -0
- package/dist/cmp/toast/ToastCmp.vue.d.ts +3 -0
- package/dist/cmp/toolbar/useChangeToolbar.d.ts +3 -0
- package/dist/cmp/useDebounce/useDebounce.d.ts +1 -0
- package/dist/cmp/viewer/ObjectDataViewer.vue.d.ts +6 -0
- package/dist/defaultViews/ErrorView.vue.d.ts +7 -0
- package/dist/defaultViews/user/LoginView.vue.d.ts +3 -0
- package/dist/defaultViews/user/RegisterView.vue.d.ts +3 -0
- package/dist/defaultViews/user/ResetPasswordView.vue.d.ts +3 -0
- package/dist/defaultViews/user/UserView.vue.d.ts +3 -0
- package/dist/defaultViews/user/usersettings/UserFormPersonalInfo.vue.d.ts +3 -0
- package/dist/defaultViews/user/usersettings/UserFormPersonalInfoTest.vue.d.ts +3 -0
- package/dist/index.cjs +20 -20
- package/dist/index.d.ts +9 -6
- package/dist/index.mjs +9752 -6081
- package/dist/models/AppConfig.d.ts +18 -0
- package/dist/models/UserPublic.d.ts +27 -0
- package/dist/stores/appConfigStore.d.ts +9 -0
- package/dist/stores/currentUserStore.d.ts +189 -0
- package/dist/stores/store.d.ts +233 -0
- package/dist/stores/userPublicStore.d.ts +524 -0
- package/docs/Btn.md +26 -0
- package/docs/LS.md +27 -0
- package/docs/Modal.md +43 -0
- package/docs/_.md +0 -0
- package/docs/toast.md +29 -0
- package/package.json +4 -2
package/dist/index.cjs
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("vue"),gm=require("vue-router"),_m=["id"],ym={class:"accordion-item"},Tm={class:"accordion-header"},wm=["data-bs-target","aria-controls","disabled"],Em=["id","data-bs-parent"],vm={class:"accordion-body"},Im={key:0},Eh=_.defineComponent({inheritAttrs:!1,__name:"Accordion",props:{id:{},title:{},defaultOpen:{type:Boolean},disabled:{type:Boolean}},emits:["open"],setup(n,{emit:e}){const t=n,r=e,s=_.useSlots(),i=_.useAttrs(),a=_.computed(()=>t.id??"accordionDefault"),c=_.computed(()=>!!t.disabled),u=_.computed(()=>!!s.default?.().length),h=_.computed(()=>!!s.header?.().length);function f(m){if(c.value){m.preventDefault(),m.stopPropagation();return}r("open",m)}return(m,y)=>(_.openBlock(),_.createElementBlock("div",_.mergeProps({class:"accordion",id:a.value},_.unref(i)),[_.createElementVNode("div",ym,[_.createElementVNode("h2",Tm,[_.createElementVNode("button",{class:"accordion-button collapsed p-2",type:"button","data-bs-toggle":"collapse","data-bs-target":`#collapseOne-${a.value}`,"aria-expanded":"false","aria-controls":`collapseOne-${a.value}`,disabled:c.value,onClick:f},[h.value?_.renderSlot(m.$slots,"header",{key:0}):(_.openBlock(),_.createElementBlock(_.Fragment,{key:1},[_.createTextVNode(_.toDisplayString(t.title??"- default -"),1)],64))],8,wm)]),_.createElementVNode("div",{id:`collapseOne-${a.value}`,class:"accordion-collapse collapse","data-bs-parent":`#${a.value}`},[_.createElementVNode("div",vm,[u.value?_.createCommentVNode("",!0):(_.openBlock(),_.createElementBlock("p",Im,[...y[0]||(y[0]=[_.createTextVNode(" - ",-1),_.createElementVNode("span",{class:"material-symbols-outlined text-warning"}," warning ",-1),_.createTextVNode(" - ",-1)])])),_.renderSlot(m.$slots,"default")])],8,Em)])],16,_m))}});let Am=(n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),"");class vh{type;id;title;message;duration;timer;createdAt;logo;component;componentProps;actions;closeAction;constructor({type:e="info",title:t,message:r,logo:s,duration:i=3e3,component:a,componentProps:c,actions:u,closeAction:h}){if(this.type=e,this.id=Am(),this.title=t,this.message=r,this.duration=i,this.component=a,this.componentProps=c,this.actions=u,this.closeAction=h,this.timer=null,this.createdAt=null,this.logo=s,!this.logo)switch(e){case"info":this.logo='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960" fill="currentcolor"><path d="M480-80q-33 0-56.5-23.5T400-160h160q0 33-23.5 56.5T480-80ZM320-200v-80h320v80H320Zm10-120q-69-41-109.5-110T180-580q0-125 87.5-212.5T480-880q125 0 212.5 87.5T780-580q0 81-40.5 150T630-320H330Zm24-80h252q45-32 69.5-79T700-580q0-92-64-156t-156-64q-92 0-156 64t-64 156q0 54 24.5 101t69.5 79Zm126 0Z"/></svg>';break;case"error":this.logo='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960" fill="currentcolor"><path d="M480-280q17 0 28.5-11.5T520-320q0-17-11.5-28.5T480-360q-17 0-28.5 11.5T440-320q0 17 11.5 28.5T480-280Zm-40-160h80v-240h-80v240Zm40 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z" /></svg>';break;case"success":this.logo='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960" fill="currentcolor"><path d="M480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q65 0 123 19t107 53l-58 59q-38-24-81-37.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160q133 0 226.5-93.5T800-480q0-18-2-36t-6-35l65-65q11 32 17 66t6 70q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm-56-216L254-466l56-56 114 114 400-401 56 56-456 457Z" /></svg>';break;case"warning":this.logo='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960" fill="currentcolor"><path d="m40-120 440-760 440 760H40Zm138-80h604L480-720 178-200Zm302-40q17 0 28.5-11.5T520-280q0-17-11.5-28.5T480-320q-17 0-28.5 11.5T440-280q0 17 11.5 28.5T480-240Zm-40-120h80v-200h-80v200Zm40-100Z"/></svg>';break;case"primary":this.logo='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960" fill="currentcolor"><path d="M480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-80q-100 0-170-70t-70-170q0-100 70-170t170-70q100 0 170 70t70 170q0 100-70 170t-170 70Zm0-80q66 0 113-47t47-113q0-66-47-113t-113-47q-66 0-113 47t-47 113q0 66 47 113t113 47Zm0-80q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Z"/></svg>';break;case"log":this.logo='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#0400ffff"><path d="M480-200q66 0 113-47t47-113v-160q0-66-47-113t-113-47q-66 0-113 47t-47 113v160q0 66 47 113t113 47Zm-80-120h160v-80H400v80Zm0-160h160v-80H400v80Zm80 40Zm0 320q-65 0-120.5-32T272-240H160v-80h84q-3-20-3.5-40t-.5-40h-80v-80h80q0-20 .5-40t3.5-40h-84v-80h112q14-23 31.5-43t40.5-35l-64-66 56-56 86 86q28-9 57-9t57 9l88-86 56 56-66 66q23 15 41.5 34.5T688-640h112v80h-84q3 20 3.5 40t.5 40h80v80h-80q0 20-.5 40t-3.5 40h84v80H688q-32 56-87.5 88T480-120Z"/></svg>';break;case"logError":this.logo='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#ff0000ff"><path d="M480-200q66 0 113-47t47-113v-160q0-66-47-113t-113-47q-66 0-113 47t-47 113v160q0 66 47 113t113 47Zm-80-120h160v-80H400v80Zm0-160h160v-80H400v80Zm80 40Zm0 320q-65 0-120.5-32T272-240H160v-80h84q-3-20-3.5-40t-.5-40h-80v-80h80q0-20 .5-40t3.5-40h-84v-80h112q14-23 31.5-43t40.5-35l-64-66 56-56 86 86q28-9 57-9t57 9l88-86 56 56-66 66q23 15 41.5 34.5T688-640h112v80h-84q3 20 3.5 40t.5 40h80v80h-80q0 20-.5 40t-3.5 40h84v80H688q-32 56-87.5 88T480-120ZM40-720v-120q0-33 23.5-56.5T120-920h120v80H120v120H40ZM240-40H120q-33 0-56.5-23.5T40-120v-120h80v120h120v80Zm480 0v-80h120v-120h80v120q0 33-23.5 56.5T840-40H720Zm120-680v-120H720v-80h120q33 0 56.5 23.5T920-840v120h-80Z"/></svg>';break;default:this.logo='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960" fill="currentcolor"><path d="M160-200v-80h80v-280q0-83 50-147.5T420-792v-28q0-25 17.5-42.5T480-880q25 0 42.5 17.5T540-820v28q80 20 130 84.5T720-560v280h80v80H160Zm320-300Zm0 420q-33 0-56.5-23.5T400-160h160q0 33-23.5 56.5T480-80ZM320-280h320v-280q0-66-47-113t-113-47q-66 0-113 47t-47 113v280Z" /></svg>';break}}start(e){if(this.duration===null){this.createdAt=null,this.timer=null;return}this.createdAt=Date.now(),this.timer=e}stop(){if(this.timer){if(clearTimeout(this.timer),this.timer=null,this.duration===null){this.createdAt=null;return}const e=Date.now()-(this.createdAt??Date.now()),t=this.duration-e;this.duration=Math.max(t,0)}}}function bm(n,e){try{return JSON.parse(n)}catch{U.logError(`Errore${e?' "'+e+'"':""} nel JSON.parse`);return}}const Ce={defaultKey:{isDev:"isDev",debugMod:"debugMod",currentUser:"currentUser",appConfig:"appConfig",lastLoginCurrentUser:"lastLoginCurrentUser"},getStr(n){const e=localStorage.getItem(n);if(e)return e},getParsed(n){const e=this.getStr(n);return e&&bm(e,n)},set(n,e){try{const t=JSON.stringify(e);return localStorage.setItem(n,t),t}catch(t){const r=t?.name==="QuotaExceededError"?"Spazio di archiviazione locale esaurito":`Errore nel salvataggio di "${n}"`;return U.logError(r),null}},update(n,e){const t=this.getParsed(n);return Array.isArray(t)?(t.push(e),this.set(n,t)):t&&typeof t=="object"?this.set(n,{...t,...e}):(U.logError("Devi usare set. typeof existing non è un object o array"),t)},push(n,...e){const t=this.getParsed(n);return Array.isArray(t)?(t.push(...e),this.set(n,t)):(U.logError(`push fallito: "${n}" non è un array`),t)},remove(n){try{localStorage.removeItem(n)}catch{U.logError(`Errore nella rimozione di "${n}"`)}},delete(n){this.remove(n)},has(n){try{return localStorage.getItem(n)!==null}catch{return!1}},keys(){return Object.keys(localStorage)},clear(n){try{const e=new Set(n?Array.isArray(n)?n:[n]:[]);for(let t=localStorage.length-1;t>=0;t--){const r=localStorage.key(t);r&&(e.has(r)||localStorage.removeItem(r))}}catch{U.logError("Errore nel pulire lo storage")}},migrate(n,e){const t=this.getStr(n);t!==void 0&&(this.set(e,t),this.remove(n))}},je=_.reactive({isDev:Ce.getParsed(Ce.defaultKey.isDev)!==void 0?Ce.getParsed(Ce.defaultKey.isDev):location.hostname==="localhost"||location.hostname==="127.0.0.1",debugMod:Ce.getParsed(Ce.defaultKey.debugMod),debugFirestore:!1}),U=_.reactive({queue:[],start(n){if(n.duration===null){n.start(null);return}n.start(setTimeout(()=>this.removeToastById(n.id),n.duration))},startAll(){for(const n of this.queue)this.start(n)},stop(n){if(n.timer){if(clearTimeout(n.timer),n.timer=null,n.duration===null){n.createdAt=null;return}const e=Date.now()-(n.createdAt??Date.now()),t=n.duration-e;n.duration=Math.max(t,0)}},stopAll(){for(const n of this.queue)n.stop()},removeToastByIndex(n){const e=this.queue[n];e?this.stop(e):console.error("toast to stop not found"),this.queue.splice(n,1)},removeToastById(n){for(const e in this.queue){const t=Number(e);if(this.queue[t]?.id===n){this.removeToastByIndex(t);break}}},_addToast(n,e,t){t=t===void 0?3e3:t;const r=new vh({type:n,title:typeof e=="object"?e.title:e,message:typeof e=="object"?e.message:void 0,logo:typeof e=="object"?e.logo:void 0,component:typeof e=="object"?e.component:void 0,componentProps:typeof e=="object"?e.componentProps:void 0,actions:typeof e=="object"?e.actions:void 0,closeAction:typeof e=="object"?e.closeAction:void 0,duration:t});this.queue.push(r),this.start(r)},info(n,e){this._addToast("info",n,e)},error(n,e){if(je.debugMod){const t=typeof n=="object"?`${n.title} ${n?.message??""} `:n;console.log("[ERROR]: "+t),console.error(t)}this._addToast("error",n,e)},danger(n,e){this.error(n,e)},success(n,e){this._addToast("success",n,e)},warning(n,e){if(je.debugMod){const t=typeof n=="object"?`${n.title} ${n?.message??""} `:n;console.log("[WARNING]: "+t),console.warn(t)}this._addToast("warning",n,e)},primary(n,e){this._addToast("primary",n,e)},secondary(n,e){this._addToast("secondary",n,e)},log(n,e){je.debugMod&&(console.log(typeof n=="object"?`${n.title} ${n?.message??""} `:n),this._addToast("log",n,e===void 0?5e3:e))},logError(n,e){if(!je.debugMod)return;const t=typeof n=="object"?`${n.title} ${n?.message??""} `:n;console.log("[ERROR]: "+t),console.error(t),this._addToast("logError",n,e===void 0?5e3:e)}});async function Ih({url:n,text:e,title:t}){if(navigator.share)try{await navigator.share({title:t??"Condividi",text:e??"",url:n})}catch{await navigator.clipboard.writeText(n),U.success("Link copiato negli appunti")}else await navigator.clipboard.writeText(n),U.success("Link copiato negli appunti")}const Sm=["type","disabled","aria-busy"],Rm={class:"material-symbols-outlined","aria-hidden":"true"},Pm=_.defineComponent({inheritAttrs:!1,__name:"Btn",props:{variant:{},color:{},size:{},block:{type:Boolean},disabled:{type:Boolean},type:{},to:{},loading:{type:Boolean},icon:{},share:{}},emits:["click"],setup(n,{emit:e}){const t=n,r=e,s=_.useSlots(),i=_.useAttrs(),a=gm.useRouter(),c=_.computed(()=>!!t.disabled||!!t.loading),u=_.computed(()=>{const k=t.color??"dark",V=(t.variant??"solid")==="solid"?`btn-${k}`:`btn-outline-${k}`,N=t.variant==="ghost"?"border-0":"",$=t.size?`btn-${t.size}`:"",W=t.block?"w-100":"",Q=t.variant==="link"?"btn-ms-link":"";return["btn",V,Q,N,$,W].filter(Boolean).join(" ")}),h=_.computed(()=>!!s.default?.().length),f=_.computed(()=>{if(t.icon&&t.icon.trim().length>0)return t.icon.trim();if(!h.value)return"error"});function m(S){if(c.value){S.preventDefault(),S.stopPropagation();return}r("click",S),t.share&&Ih(t.share),t.to&&(t.type==="submit"&&S.preventDefault(),S.stopPropagation(),a.push(t.to))}const y=_.computed(()=>t.to?"button":t.type??"button");return(S,k)=>(_.openBlock(),_.createElementBlock("button",_.mergeProps(_.unref(i),{class:[u.value,_.unref(i).class],type:y.value,disabled:c.value,"aria-busy":n.loading||void 0,onClick:m}),[n.loading&&f.value?(_.openBlock(),_.createElementBlock(_.Fragment,{key:0},[k[0]||(k[0]=_.createElementVNode("span",{class:"me-2 d-inline-flex align-middle"},[_.createElementVNode("span",{class:"spinner-border spinner-border-sm align-middle",role:"status","aria-hidden":"true"})],-1)),_.renderSlot(S.$slots,"default",{},void 0,!0)],64)):n.loading&&!f.value?(_.openBlock(),_.createElementBlock(_.Fragment,{key:1},[k[1]||(k[1]=_.createElementVNode("span",{class:"spinner-border spinner-border-sm align-middle",role:"status","aria-hidden":"true"},null,-1)),k[2]||(k[2]=_.createElementVNode("span",{class:"visually-hidden"},"Loading…",-1))],64)):(_.openBlock(),_.createElementBlock(_.Fragment,{key:2},[f.value?(_.openBlock(),_.createElementBlock("span",{key:0,class:_.normalizeClass(`${h.value?"me-2 ":""}d-inline-flex align-middle`)},[_.createElementVNode("span",Rm,_.toDisplayString(f.value),1)],2)):_.createCommentVNode("",!0),_.renderSlot(S.$slots,"default",{},void 0,!0)],64))],16,Sm))}}),ca=(n,e)=>{const t=n.__vccOpts||n;for(const[r,s]of e)t[r]=s;return t},gr=ca(Pm,[["__scopeId","data-v-1caf3817"]]),Cm=["onMouseenter"],km=["innerHTML"],Nm={class:"message-text-container text-dark"},Dm={class:"message-text mb-0"},Vm={class:"sub-content"},Om={key:0,class:"sub-text mb-0"},Lm={key:2,class:"text-end"},Mm=["onClick"],xm=_.defineComponent({__name:"ToastCmp",setup(n){const e=_.ref(null),t=_.computed(()=>U.queue||[]);function r(a){e.value=a,U.stopAll()}function s(){e.value=null,U.startAll()}function i(a){e.value=null,U.removeToastById(a)}return(a,c)=>(_.openBlock(),_.createBlock(_.TransitionGroup,{name:"toast-fade",tag:"div",class:"toast-wrapper"},{default:_.withCtx(()=>[(_.openBlock(!0),_.createElementBlock(_.Fragment,null,_.renderList(t.value,(u,h)=>(_.openBlock(),_.createElementBlock("div",{key:u.id,class:_.normalizeClass(["toast-card",[u.type,{expanded:e.value===null?h===t.value.length-1:e.value===u.id}]]),onMouseenter:f=>r(u.id),onMouseleave:s},[_.createElementVNode("div",{class:"icon-container",innerHTML:u.logo},null,8,km),_.createElementVNode("div",Nm,[_.createElementVNode("p",Dm,_.toDisplayString(u.title),1),_.createElementVNode("div",Vm,[u.message?(_.openBlock(),_.createElementBlock("p",Om,_.toDisplayString(u.message),1)):_.createCommentVNode("",!0),u.component?(_.openBlock(),_.createBlock(_.resolveDynamicComponent(u.component),_.mergeProps({key:1,ref_for:!0},u.componentProps,{class:"mt-2 me-2"}),_.createSlots({_:2},[u.componentProps?.children?{name:"default",fn:_.withCtx(()=>[_.createTextVNode(_.toDisplayString(typeof u.componentProps.children=="function"?u.componentProps.children():u.componentProps.children),1)]),key:"0"}:void 0]),1040)):_.createCommentVNode("",!0),u.actions?(_.openBlock(),_.createElementBlock("div",Lm,[u.closeAction!==!1?(_.openBlock(),_.createBlock(gr,{key:0,variant:"link",class:"mt-2 me-1"},{default:_.withCtx(()=>[...c[0]||(c[0]=[_.createTextVNode("close",-1)])]),_:1})):_.createCommentVNode("",!0),(_.openBlock(!0),_.createElementBlock(_.Fragment,null,_.renderList(u.actions,(f,m)=>(_.openBlock(),_.createElementBlock(_.Fragment,{key:u.id+"-action-"+m},[f.content?(_.openBlock(),_.createBlock(gr,{key:0,onClick:()=>{f.onClick(),i(u.id)},icon:f.icon,variant:f.variant,color:f.color,disabled:typeof f.disabled=="function"?f.disabled():f.disabled,class:_.normalizeClass(["mt-2","me-2",f.class]),style:_.normalizeStyle(f.style)},{default:_.withCtx(()=>[_.createTextVNode(_.toDisplayString(f.content),1)]),_:2},1032,["onClick","icon","variant","color","disabled","class","style"])):(_.openBlock(),_.createBlock(gr,{key:1,onClick:()=>{f.onClick(),i(u.id)},icon:f.icon,variant:f.variant,color:f.color,disabled:typeof f.disabled=="function"?f.disabled():f.disabled,class:_.normalizeClass(["mt-2","me-2",f.class]),style:_.normalizeStyle(f.style)},null,8,["onClick","icon","variant","color","disabled","class","style"]))],64))),128))])):_.createCommentVNode("",!0)])]),(_.openBlock(),_.createElementBlock("svg",{class:"cross-icon",viewBox:"0 0 15 15",fill:"currentColor",onClick:f=>i(u.id)},[...c[1]||(c[1]=[_.createElementVNode("path",{d:"M11.78 4.03c.23-.23.23-.6 0-.83s-.6-.23-.83 0L7.5 6.69 4.03 3.2c-.23-.23-.6-.23-.83 0s-.23.6 0 .83L6.69 7.5 3.2 10.97c-.23.23-.23.6 0 .83s.6.23.83 0L7.5 8.31l3.47 3.47c.23.23.6.23.83 0s.23-.6 0-.83L8.31 7.5l3.47-3.47z"},null,-1)])],8,Mm))],42,Cm))),128))]),_:1}))}}),Ah=ca(xm,[["__scopeId","data-v-2cc28e46"]]),Fm=["for"],Um={key:0,class:"text-danger"},Bm=["disabled","readonly"],qm={value:""},$m=["id"],bh=_.defineComponent({__name:"FieldGender",props:{modelValue:{},field:{},fv:{},label:{type:[String,Boolean],default:!1},placeholder:{default:"—"},errors:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},required:{type:Boolean,default:!1},class:{},style:{},classLabel:{}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,r=e,s=_.computed({get(){return t.modelValue??""},set(a){r("update:modelValue",a??"")}}),i=_.computed(()=>typeof t.label!="string"&&t.label!==!0&&t.label!==!1);return(a,c)=>(_.openBlock(),_.createElementBlock(_.Fragment,null,[n.label&&!i.value?(_.openBlock(),_.createElementBlock("label",{key:0,class:_.normalizeClass(["form-label",t.classLabel]),for:n.fv.getFieldId(n.field)},[_.createTextVNode(_.toDisplayString(n.label===!0?n.field:n.label)+" ",1),n.required?(_.openBlock(),_.createElementBlock("span",Um," *")):_.createCommentVNode("",!0)],10,Fm)):n.label&&i.value?(_.openBlock(),_.createBlock(_.resolveDynamicComponent(n.label),{key:1,for:n.fv.getFieldId(n.field)},null,8,["for"])):_.createCommentVNode("",!0),_.withDirectives(_.createElementVNode("select",_.mergeProps({class:"form-select","onUpdate:modelValue":c[0]||(c[0]=u=>s.value=u)},n.fv.getFieldProps(n.field),{class:t.class,style:t.style,disabled:n.disabled,readonly:n.readonly}),[_.createElementVNode("option",qm,_.toDisplayString(n.placeholder),1),c[1]||(c[1]=_.createElementVNode("option",{value:"m"},"Maschio",-1)),c[2]||(c[2]=_.createElementVNode("option",{value:"f"},"Femmina",-1)),c[3]||(c[3]=_.createElementVNode("option",{value:"o"},"Altro / Preferisco non dirlo",-1))],16,Bm),[[_.vModelSelect,s.value]]),n.errors?(_.openBlock(),_.createElementBlock("div",{key:2,id:n.fv.getFieldIdError(n.field),class:"invalid-feedback"},_.toDisplayString(n.fv.showError(n.field)),9,$m)):_.createCommentVNode("",!0)],64))}}),jm=["for"],zm={class:"d-flex gap-2"},Hm=["placeholder","disabled","readonly"],Gm=["placeholder","disabled","readonly"],Km=["id"],Wm=_.defineComponent({__name:"FieldPhoneNumber",props:{modelValue:{},field:{},fv:{},label:{type:[String,Boolean],default:!1},placeholder:{default:"333 1234567"},placeholderPrefix:{default:"+39"},errors:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},class:{},style:{},disabledPrefix:{type:Boolean},disabledNumber:{type:Boolean},readonlyPrefix:{type:Boolean},readonlyNumber:{type:Boolean},classPrefix:{},classNumber:{},stylePrefix:{},styleNumber:{}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,r=e,s=_.computed({get(){return t.modelValue?.[0]??t.placeholderPrefix??""},set(k){r("update:modelValue",[k,t.modelValue?.[1]??""])}}),i=_.computed({get(){return t.modelValue?.[1]??""},set(k){r("update:modelValue",[t.modelValue?.[0]??t.placeholderPrefix??"",k])}}),a=_.computed(()=>t.disabledPrefix??t.disabled),c=_.computed(()=>t.disabledNumber??t.disabled),u=_.computed(()=>t.readonlyPrefix??t.readonly),h=_.computed(()=>t.readonlyNumber??t.readonly),f=_.computed(()=>[t.class,t.classPrefix]),m=_.computed(()=>[t.class,t.classNumber]),y=_.computed(()=>[t.style,t.stylePrefix]),S=_.computed(()=>[t.style,t.styleNumber]);return(k,V)=>(_.openBlock(),_.createElementBlock(_.Fragment,null,[n.label?(_.openBlock(),_.createElementBlock("label",{key:0,class:"form-label",for:n.fv.getFieldId(n.field)},_.toDisplayString(n.label===!0?n.field:n.label),9,jm)):_.createCommentVNode("",!0),_.createElementVNode("div",zm,[_.withDirectives(_.createElementVNode("input",{type:"text","onUpdate:modelValue":V[0]||(V[0]=N=>s.value=N),class:_.normalizeClass(["form-control prefix-width",f.value]),style:_.normalizeStyle(y.value),placeholder:n.placeholderPrefix,disabled:a.value,readonly:u.value,autocomplete:"tel-country-code",inputmode:"tel"},null,14,Hm),[[_.vModelText,s.value]]),_.withDirectives(_.createElementVNode("input",_.mergeProps({type:"text","onUpdate:modelValue":V[1]||(V[1]=N=>i.value=N)},n.fv.getFieldProps(n.field),{class:["form-control",m.value],style:S.value,placeholder:n.placeholder,disabled:c.value,readonly:h.value,autocomplete:"tel",inputmode:"tel"}),null,16,Gm),[[_.vModelText,i.value]])]),n.errors?(_.openBlock(),_.createElementBlock("div",{key:1,id:n.fv.getFieldIdError(n.field),class:"invalid-feedback"},_.toDisplayString(n.fv.showError(n.field)),9,Km)):_.createCommentVNode("",!0)],64))}}),Sh=ca(Wm,[["__scopeId","data-v-d70bf135"]]),Qm=["for"],Jm={key:0,class:"text-danger"},Ym=["type","placeholder","disabled","readonly","autocomplete","inputmode"],Xm=["id"],Rh=_.defineComponent({__name:"InputField",props:{modelValue:{},field:{},fv:{},label:{type:[String,Boolean],default:!1},placeholder:{default:""},errors:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},required:{type:Boolean,default:!1},class:{},style:{},classLabel:{},type:{default:"text"},autocomplete:{},inputmode:{}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,r=e,s=_.computed({get(){return t.modelValue??""},set(a){r("update:modelValue",a??"")}}),i=_.computed(()=>typeof t.label!="string"&&t.label!==!0&&t.label!==!1);return(a,c)=>(_.openBlock(),_.createElementBlock(_.Fragment,null,[n.label&&!i.value?(_.openBlock(),_.createElementBlock("label",{key:0,class:_.normalizeClass(["form-label",t.classLabel]),for:n.fv.getFieldId(n.field)},[_.createTextVNode(_.toDisplayString(n.label===!0?n.field:n.label)+" ",1),n.required?(_.openBlock(),_.createElementBlock("span",Jm," *")):_.createCommentVNode("",!0)],10,Qm)):n.label&&i.value?(_.openBlock(),_.createBlock(_.resolveDynamicComponent(n.label),{key:1,for:n.fv.getFieldId(n.field)},null,8,["for"])):_.createCommentVNode("",!0),_.withDirectives(_.createElementVNode("input",_.mergeProps({type:n.type,"onUpdate:modelValue":c[0]||(c[0]=u=>s.value=u)},n.fv.getFieldProps(n.field),{class:["form-control",t.class],style:t.style,placeholder:n.placeholder,disabled:n.disabled,readonly:n.readonly,autocomplete:n.autocomplete,inputmode:n.inputmode}),null,16,Ym),[[_.vModelDynamic,s.value]]),n.errors?(_.openBlock(),_.createElementBlock("div",{key:2,id:n.fv.getFieldIdError(n.field),class:"invalid-feedback"},_.toDisplayString(n.fv.showError(n.field)),9,Xm)):_.createCommentVNode("",!0)],64))}}),Zm=()=>{};const Ph=function(n){const e=[];let t=0;for(let r=0;r<n.length;r++){let s=n.charCodeAt(r);s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&r+1<n.length&&(n.charCodeAt(r+1)&64512)===56320?(s=65536+((s&1023)<<10)+(n.charCodeAt(++r)&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},eg=function(n){const e=[];let t=0,r=0;for(;t<n.length;){const s=n[t++];if(s<128)e[r++]=String.fromCharCode(s);else if(s>191&&s<224){const i=n[t++];e[r++]=String.fromCharCode((s&31)<<6|i&63)}else if(s>239&&s<365){const i=n[t++],a=n[t++],c=n[t++],u=((s&7)<<18|(i&63)<<12|(a&63)<<6|c&63)-65536;e[r++]=String.fromCharCode(55296+(u>>10)),e[r++]=String.fromCharCode(56320+(u&1023))}else{const i=n[t++],a=n[t++];e[r++]=String.fromCharCode((s&15)<<12|(i&63)<<6|a&63)}}return e.join("")},Ch={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_,r=[];for(let s=0;s<n.length;s+=3){const i=n[s],a=s+1<n.length,c=a?n[s+1]:0,u=s+2<n.length,h=u?n[s+2]:0,f=i>>2,m=(i&3)<<4|c>>4;let y=(c&15)<<2|h>>6,S=h&63;u||(S=64,a||(y=64)),r.push(t[f],t[m],t[y],t[S])}return r.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray(Ph(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):eg(this.decodeStringToByteArray(n,e))},decodeStringToByteArray(n,e){this.init_();const t=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let s=0;s<n.length;){const i=t[n.charAt(s++)],c=s<n.length?t[n.charAt(s)]:0;++s;const h=s<n.length?t[n.charAt(s)]:64;++s;const m=s<n.length?t[n.charAt(s)]:64;if(++s,i==null||c==null||h==null||m==null)throw new tg;const y=i<<2|c>>4;if(r.push(y),h!==64){const S=c<<4&240|h>>2;if(r.push(S),m!==64){const k=h<<6&192|m;r.push(k)}}}return r},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 tg extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const ng=function(n){const e=Ph(n);return Ch.encodeByteArray(e,!0)},Ss=function(n){return ng(n).replace(/\./g,"")},kh=function(n){try{return Ch.decodeString(n,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function rg(){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 sg=()=>rg().__FIREBASE_DEFAULTS__,ig=()=>{if(typeof process>"u"||typeof process.env>"u")return;const n=process.env.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},og=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=n&&kh(n[1]);return e&&JSON.parse(e)},si=()=>{try{return Zm()||sg()||ig()||og()}catch(n){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},Nh=n=>si()?.emulatorHosts?.[n],la=n=>{const e=Nh(n);if(!e)return;const t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const r=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),r]:[e.substring(0,t),r]},Dh=()=>si()?.config,Vh=n=>si()?.[`_${n}`];class ag{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,r)=>{t?this.reject(t):this.resolve(r),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,r))}}}function vt(n){try{return(n.startsWith("http://")||n.startsWith("https://")?new URL(n).hostname:n).endsWith(".cloudworkstations.dev")}catch{return!1}}async function ii(n){return(await fetch(n,{credentials:"include"})).ok}function Oh(n,e){if(n.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const t={alg:"none",type:"JWT"},r=e||"demo-project",s=n.iat||0,i=n.sub||n.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const a={iss:`https://securetoken.google.com/${r}`,aud:r,iat:s,exp:s+3600,auth_time:s,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}},...n};return[Ss(JSON.stringify(t)),Ss(JSON.stringify(a)),""].join(".")}const _r={};function cg(){const n={prod:[],emulator:[]};for(const e of Object.keys(_r))_r[e]?n.emulator.push(e):n.prod.push(e);return n}function lg(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 Il=!1;function oi(n,e){if(typeof window>"u"||typeof document>"u"||!vt(window.location.host)||_r[n]===e||_r[n]||Il)return;_r[n]=e;function t(y){return`__firebase__banner__${y}`}const r="__firebase__banner",i=cg().prod.length>0;function a(){const y=document.getElementById(r);y&&y.remove()}function c(y){y.style.display="flex",y.style.background="#7faaf0",y.style.position="fixed",y.style.bottom="5px",y.style.left="5px",y.style.padding=".5em",y.style.borderRadius="5px",y.style.alignItems="center"}function u(y,S){y.setAttribute("width","24"),y.setAttribute("id",S),y.setAttribute("height","24"),y.setAttribute("viewBox","0 0 24 24"),y.setAttribute("fill","none"),y.style.marginLeft="-6px"}function h(){const y=document.createElement("span");return y.style.cursor="pointer",y.style.marginLeft="16px",y.style.fontSize="24px",y.innerHTML=" ×",y.onclick=()=>{Il=!0,a()},y}function f(y,S){y.setAttribute("id",S),y.innerText="Learn more",y.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",y.setAttribute("target","__blank"),y.style.paddingLeft="5px",y.style.textDecoration="underline"}function m(){const y=lg(r),S=t("text"),k=document.getElementById(S)||document.createElement("span"),V=t("learnmore"),N=document.getElementById(V)||document.createElement("a"),$=t("preprendIcon"),W=document.getElementById($)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(y.created){const Q=y.element;c(Q),f(N,V);const te=h();u(W,$),Q.append(W,k,N,te),document.body.appendChild(Q)}i?(k.innerText="Preview backend disconnected.",W.innerHTML=`<g clip-path="url(#clip0_6013_33858)">
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("vue"),mo=require("vue-router"),TE=["id"],wE={class:"accordion-item"},bE={class:"accordion-header"},AE=["data-bs-target","aria-controls","disabled"],IE=["id","data-bs-parent"],SE={class:"accordion-body"},CE={key:0},Cp=p.defineComponent({inheritAttrs:!1,__name:"Accordion",props:{id:{},title:{},defaultOpen:{type:Boolean},disabled:{type:Boolean}},emits:["open"],setup(n,{emit:e}){const t=n,r=e,s=p.useSlots(),i=p.useAttrs(),o=p.computed(()=>t.id??"accordionDefault"),c=p.computed(()=>!!t.disabled),l=p.computed(()=>!!s.default?.().length),h=p.computed(()=>!!s.header?.().length);function f(g){if(c.value){g.preventDefault(),g.stopPropagation();return}r("open",g)}return(g,_)=>(p.openBlock(),p.createElementBlock("div",p.mergeProps({class:"accordion",id:o.value},p.unref(i)),[p.createElementVNode("div",wE,[p.createElementVNode("h2",bE,[p.createElementVNode("button",{class:"accordion-button collapsed p-2",type:"button","data-bs-toggle":"collapse","data-bs-target":`#collapseOne-${o.value}`,"aria-expanded":"false","aria-controls":`collapseOne-${o.value}`,disabled:c.value,onClick:f},[h.value?p.renderSlot(g.$slots,"header",{key:0}):(p.openBlock(),p.createElementBlock(p.Fragment,{key:1},[p.createTextVNode(p.toDisplayString(t.title??"- default -"),1)],64))],8,AE)]),p.createElementVNode("div",{id:`collapseOne-${o.value}`,class:"accordion-collapse collapse","data-bs-parent":`#${o.value}`},[p.createElementVNode("div",SE,[l.value?p.createCommentVNode("",!0):(p.openBlock(),p.createElementBlock("p",CE,[..._[0]||(_[0]=[p.createTextVNode(" - ",-1),p.createElementVNode("span",{class:"material-symbols-outlined text-warning"}," warning ",-1),p.createTextVNode(" - ",-1)])])),p.renderSlot(g.$slots,"default")])],8,IE)])],16,TE))}});let RE=(n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),""),Rp=class{type;id;title;message;duration;timer;createdAt;logo;component;componentProps;actions;closeAction;constructor({type:e="info",title:t,message:r,logo:s,duration:i=3e3,component:o,componentProps:c,actions:l,closeAction:h}){if(this.type=e,this.id=RE(),this.title=t,this.message=r,this.duration=i,this.component=o,this.componentProps=c,this.actions=l,this.closeAction=h,this.timer=null,this.createdAt=null,this.logo=s,!this.logo)switch(e){case"info":this.logo='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960" fill="currentcolor"><path d="M480-80q-33 0-56.5-23.5T400-160h160q0 33-23.5 56.5T480-80ZM320-200v-80h320v80H320Zm10-120q-69-41-109.5-110T180-580q0-125 87.5-212.5T480-880q125 0 212.5 87.5T780-580q0 81-40.5 150T630-320H330Zm24-80h252q45-32 69.5-79T700-580q0-92-64-156t-156-64q-92 0-156 64t-64 156q0 54 24.5 101t69.5 79Zm126 0Z"/></svg>';break;case"error":this.logo='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960" fill="currentcolor"><path d="M480-280q17 0 28.5-11.5T520-320q0-17-11.5-28.5T480-360q-17 0-28.5 11.5T440-320q0 17 11.5 28.5T480-280Zm-40-160h80v-240h-80v240Zm40 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z" /></svg>';break;case"success":this.logo='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960" fill="currentcolor"><path d="M480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q65 0 123 19t107 53l-58 59q-38-24-81-37.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160q133 0 226.5-93.5T800-480q0-18-2-36t-6-35l65-65q11 32 17 66t6 70q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm-56-216L254-466l56-56 114 114 400-401 56 56-456 457Z" /></svg>';break;case"warning":this.logo='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960" fill="currentcolor"><path d="m40-120 440-760 440 760H40Zm138-80h604L480-720 178-200Zm302-40q17 0 28.5-11.5T520-280q0-17-11.5-28.5T480-320q-17 0-28.5 11.5T440-280q0 17 11.5 28.5T480-240Zm-40-120h80v-200h-80v200Zm40-100Z"/></svg>';break;case"primary":this.logo='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960" fill="currentcolor"><path d="M480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-80q-100 0-170-70t-70-170q0-100 70-170t170-70q100 0 170 70t70 170q0 100-70 170t-170 70Zm0-80q66 0 113-47t47-113q0-66-47-113t-113-47q-66 0-113 47t-47 113q0 66 47 113t113 47Zm0-80q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Z"/></svg>';break;case"log":this.logo='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#0400ffff"><path d="M480-200q66 0 113-47t47-113v-160q0-66-47-113t-113-47q-66 0-113 47t-47 113v160q0 66 47 113t113 47Zm-80-120h160v-80H400v80Zm0-160h160v-80H400v80Zm80 40Zm0 320q-65 0-120.5-32T272-240H160v-80h84q-3-20-3.5-40t-.5-40h-80v-80h80q0-20 .5-40t3.5-40h-84v-80h112q14-23 31.5-43t40.5-35l-64-66 56-56 86 86q28-9 57-9t57 9l88-86 56 56-66 66q23 15 41.5 34.5T688-640h112v80h-84q3 20 3.5 40t.5 40h80v80h-80q0 20-.5 40t-3.5 40h84v80H688q-32 56-87.5 88T480-120Z"/></svg>';break;case"logError":this.logo='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#ff0000ff"><path d="M480-200q66 0 113-47t47-113v-160q0-66-47-113t-113-47q-66 0-113 47t-47 113v160q0 66 47 113t113 47Zm-80-120h160v-80H400v80Zm0-160h160v-80H400v80Zm80 40Zm0 320q-65 0-120.5-32T272-240H160v-80h84q-3-20-3.5-40t-.5-40h-80v-80h80q0-20 .5-40t3.5-40h-84v-80h112q14-23 31.5-43t40.5-35l-64-66 56-56 86 86q28-9 57-9t57 9l88-86 56 56-66 66q23 15 41.5 34.5T688-640h112v80h-84q3 20 3.5 40t.5 40h80v80h-80q0 20-.5 40t-3.5 40h84v80H688q-32 56-87.5 88T480-120ZM40-720v-120q0-33 23.5-56.5T120-920h120v80H120v120H40ZM240-40H120q-33 0-56.5-23.5T40-120v-120h80v120h120v80Zm480 0v-80h120v-120h80v120q0 33-23.5 56.5T840-40H720Zm120-680v-120H720v-80h120q33 0 56.5 23.5T920-840v120h-80Z"/></svg>';break;default:this.logo='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960" fill="currentcolor"><path d="M160-200v-80h80v-280q0-83 50-147.5T420-792v-28q0-25 17.5-42.5T480-880q25 0 42.5 17.5T540-820v28q80 20 130 84.5T720-560v280h80v80H160Zm320-300Zm0 420q-33 0-56.5-23.5T400-160h160q0 33-23.5 56.5T480-80ZM320-280h320v-280q0-66-47-113t-113-47q-66 0-113 47t-47 113v280Z" /></svg>';break}}start(e){if(this.duration===null){this.createdAt=null,this.timer=null;return}this.createdAt=Date.now(),this.timer=e}stop(){if(this.timer){if(clearTimeout(this.timer),this.timer=null,this.duration===null){this.createdAt=null;return}const e=Date.now()-(this.createdAt??Date.now()),t=this.duration-e;this.duration=Math.max(t,0)}}};function kE(n,e){try{return JSON.parse(n)}catch{K.logError(`Errore${e?' "'+e+'"':""} nel JSON.parse`);return}}const Ve={defaultKey:{isDev:"isDev",debugMod:"debugMod",currentUser:"currentUser",appConfig:"appConfig",lastLoginCurrentUser:"lastLoginCurrentUser"},getStr(n){const e=localStorage.getItem(n);if(e)return e},getParsed(n){const e=this.getStr(n);return e&&kE(e,n)},set(n,e){try{const t=JSON.stringify(e);return localStorage.setItem(n,t),t}catch(t){const r=t?.name==="QuotaExceededError"?"Spazio di archiviazione locale esaurito":`Errore nel salvataggio di "${n}"`;return K.logError(r),null}},update(n,e){const t=this.getParsed(n);return Array.isArray(t)?(t.push(e),this.set(n,t)):t&&typeof t=="object"?this.set(n,{...t,...e}):(K.logError("Devi usare set. typeof existing non è un object o array"),t)},push(n,...e){const t=this.getParsed(n);return Array.isArray(t)?(t.push(...e),this.set(n,t)):(K.logError(`push fallito: "${n}" non è un array`),t)},remove(n){try{localStorage.removeItem(n)}catch{K.logError(`Errore nella rimozione di "${n}"`)}},delete(n){this.remove(n)},has(n){try{return localStorage.getItem(n)!==null}catch{return!1}},keys(){return Object.keys(localStorage)},clear(n){try{const e=new Set(n?Array.isArray(n)?n:[n]:[]);for(let t=localStorage.length-1;t>=0;t--){const r=localStorage.key(t);r&&(e.has(r)||localStorage.removeItem(r))}}catch{K.logError("Errore nel pulire lo storage")}},migrate(n,e){const t=this.getStr(n);t!==void 0&&(this.set(e,t),this.remove(n))}},rt=p.reactive({isDev:Ve.getParsed(Ve.defaultKey.isDev)!==void 0?Ve.getParsed(Ve.defaultKey.isDev):location.hostname==="localhost"||location.hostname==="127.0.0.1",debugMod:Ve.getParsed(Ve.defaultKey.debugMod),debugFirestore:!1}),K=p.reactive({queue:[],start(n){if(n.duration===null){n.start(null);return}n.start(setTimeout(()=>this.removeToastById(n.id),n.duration))},startAll(){for(const n of this.queue)this.start(n)},stop(n){if(n.timer){if(clearTimeout(n.timer),n.timer=null,n.duration===null){n.createdAt=null;return}const e=Date.now()-(n.createdAt??Date.now()),t=n.duration-e;n.duration=Math.max(t,0)}},stopAll(){for(const n of this.queue)n.stop()},removeToastByIndex(n){const e=this.queue[n];e?this.stop(e):console.error("toast to stop not found"),this.queue.splice(n,1)},removeToastById(n){for(const e in this.queue){const t=Number(e);if(this.queue[t]?.id===n){this.removeToastByIndex(t);break}}},_addToast(n,e,t){t=t===void 0?3e3:t;const r=new Rp({type:n,title:typeof e=="object"?e.title:e,message:typeof e=="object"?e.message:void 0,logo:typeof e=="object"?e.logo:void 0,component:typeof e=="object"?e.component:void 0,componentProps:typeof e=="object"?e.componentProps:void 0,actions:typeof e=="object"?e.actions:void 0,closeAction:typeof e=="object"?e.closeAction:void 0,duration:t});this.queue.push(r),this.start(r)},info(n,e){this._addToast("info",n,e)},error(n,e){if(rt.debugMod){const t=typeof n=="object"?`${n.title} ${n?.message??""} `:n;console.log("[ERROR]: "+t),console.error(t)}this._addToast("error",n,e)},danger(n,e){this.error(n,e)},success(n,e){this._addToast("success",n,e)},warning(n,e){if(rt.debugMod){const t=typeof n=="object"?`${n.title} ${n?.message??""} `:n;console.log("[WARNING]: "+t),console.warn(t)}this._addToast("warning",n,e)},primary(n,e){this._addToast("primary",n,e)},secondary(n,e){this._addToast("secondary",n,e)},log(n,e){rt.debugMod&&(console.log(typeof n=="object"?`${n.title} ${n?.message??""} `:n),this._addToast("log",n,e===void 0?5e3:e))},logError(n,e){if(!rt.debugMod)return;const t=typeof n=="object"?`${n.title} ${n?.message??""} `:n;console.log("[ERROR]: "+t),console.error(t),this._addToast("logError",n,e===void 0?5e3:e)}});async function kp({url:n,text:e,title:t}){if(navigator.share)try{await navigator.share({title:t??"Condividi",text:e??"",url:n})}catch{await navigator.clipboard.writeText(n),K.success("Link copiato negli appunti")}else await navigator.clipboard.writeText(n),K.success("Link copiato negli appunti")}const PE=["type","disabled","aria-busy"],NE={class:"material-symbols-outlined","aria-hidden":"true"},DE=p.defineComponent({inheritAttrs:!1,__name:"Btn",props:{variant:{},color:{},size:{},block:{type:Boolean},disabled:{type:Boolean},type:{},to:{},loading:{type:Boolean},icon:{},share:{}},emits:["click"],setup(n,{emit:e}){const t=n,r=e,s=p.useSlots(),i=p.useAttrs(),o=mo.useRouter(),c=p.computed(()=>!!t.disabled||!!t.loading),l=p.computed(()=>{const C=t.color??"dark",P=(t.variant??"solid")==="solid"?`btn-${C}`:`btn-outline-${C}`,k=t.variant==="ghost"?"border-0":"",L=t.size?`btn-${t.size}`:"",$=t.block?"w-100":"",U=t.variant==="link"?"btn-ms-link":"";return["btn",P,U,k,L,$].filter(Boolean).join(" ")}),h=p.computed(()=>!!s.default?.().length),f=p.computed(()=>{if(t.icon&&t.icon.trim().length>0)return t.icon.trim();if(!h.value)return"error"});function g(T){if(c.value){T.preventDefault(),T.stopPropagation();return}r("click",T),t.share&&kp(t.share),t.to&&(t.type==="submit"&&T.preventDefault(),T.stopPropagation(),o.push(t.to))}const _=p.computed(()=>t.to?"button":t.type??"button");return(T,C)=>(p.openBlock(),p.createElementBlock("button",p.mergeProps(p.unref(i),{class:[l.value,p.unref(i).class],type:_.value,disabled:c.value,"aria-busy":n.loading||void 0,onClick:g}),[n.loading&&f.value?(p.openBlock(),p.createElementBlock(p.Fragment,{key:0},[C[0]||(C[0]=p.createElementVNode("span",{class:"me-2 d-inline-flex align-middle"},[p.createElementVNode("span",{class:"spinner-border spinner-border-sm align-middle",role:"status","aria-hidden":"true"})],-1)),p.renderSlot(T.$slots,"default",{},void 0,!0)],64)):n.loading&&!f.value?(p.openBlock(),p.createElementBlock(p.Fragment,{key:1},[C[1]||(C[1]=p.createElementVNode("span",{class:"spinner-border spinner-border-sm align-middle",role:"status","aria-hidden":"true"},null,-1)),C[2]||(C[2]=p.createElementVNode("span",{class:"visually-hidden"},"Loading…",-1))],64)):(p.openBlock(),p.createElementBlock(p.Fragment,{key:2},[f.value?(p.openBlock(),p.createElementBlock("span",{key:0,class:p.normalizeClass(`${h.value?"me-2 ":""}d-inline-flex align-middle`)},[p.createElementVNode("span",NE,p.toDisplayString(f.value),1)],2)):p.createCommentVNode("",!0),p.renderSlot(T.$slots,"default",{},void 0,!0)],64))],16,PE))}}),ci=(n,e)=>{const t=n.__vccOpts||n;for(const[r,s]of e)t[r]=s;return t},ze=ci(DE,[["__scopeId","data-v-1caf3817"]]),OE=["onMouseenter"],VE=["innerHTML"],LE={class:"message-text-container text-dark"},ME={class:"message-text mb-0"},xE={class:"sub-content"},FE={key:0,class:"sub-text mb-0"},$E={key:2,class:"text-end"},UE=["onClick"],BE=p.defineComponent({__name:"ToastCmp",setup(n){const e=p.ref(null),t=p.computed(()=>K.queue||[]);function r(o){e.value=o,K.stopAll()}function s(){e.value=null,K.startAll()}function i(o){e.value=null,K.removeToastById(o)}return(o,c)=>(p.openBlock(),p.createBlock(p.TransitionGroup,{name:"toast-fade",tag:"div",class:"toast-wrapper"},{default:p.withCtx(()=>[(p.openBlock(!0),p.createElementBlock(p.Fragment,null,p.renderList(t.value,(l,h)=>(p.openBlock(),p.createElementBlock("div",{key:l.id,class:p.normalizeClass(["toast-card",[l.type,{expanded:e.value===null?h===t.value.length-1:e.value===l.id}]]),onMouseenter:f=>r(l.id),onMouseleave:s},[p.createElementVNode("div",{class:"icon-container",innerHTML:l.logo},null,8,VE),p.createElementVNode("div",LE,[p.createElementVNode("p",ME,p.toDisplayString(l.title),1),p.createElementVNode("div",xE,[l.message?(p.openBlock(),p.createElementBlock("p",FE,p.toDisplayString(l.message),1)):p.createCommentVNode("",!0),l.component?(p.openBlock(),p.createBlock(p.resolveDynamicComponent(l.component),p.mergeProps({key:1,ref_for:!0},l.componentProps,{class:"mt-2 me-2"}),p.createSlots({_:2},[l.componentProps?.children?{name:"default",fn:p.withCtx(()=>[p.createTextVNode(p.toDisplayString(typeof l.componentProps.children=="function"?l.componentProps.children():l.componentProps.children),1)]),key:"0"}:void 0]),1040)):p.createCommentVNode("",!0),l.actions?(p.openBlock(),p.createElementBlock("div",$E,[l.closeAction!==!1?(p.openBlock(),p.createBlock(ze,{key:0,variant:"link",class:"mt-2 me-1"},{default:p.withCtx(()=>[...c[0]||(c[0]=[p.createTextVNode("close",-1)])]),_:1})):p.createCommentVNode("",!0),(p.openBlock(!0),p.createElementBlock(p.Fragment,null,p.renderList(l.actions,(f,g)=>(p.openBlock(),p.createElementBlock(p.Fragment,{key:l.id+"-action-"+g},[f.content?(p.openBlock(),p.createBlock(ze,{key:0,onClick:()=>{f.onClick(),i(l.id)},icon:f.icon,variant:f.variant,color:f.color,disabled:typeof f.disabled=="function"?f.disabled():f.disabled,class:p.normalizeClass(["mt-2","me-2",f.class]),style:p.normalizeStyle(f.style)},{default:p.withCtx(()=>[p.createTextVNode(p.toDisplayString(f.content),1)]),_:2},1032,["onClick","icon","variant","color","disabled","class","style"])):(p.openBlock(),p.createBlock(ze,{key:1,onClick:()=>{f.onClick(),i(l.id)},icon:f.icon,variant:f.variant,color:f.color,disabled:typeof f.disabled=="function"?f.disabled():f.disabled,class:p.normalizeClass(["mt-2","me-2",f.class]),style:p.normalizeStyle(f.style)},null,8,["onClick","icon","variant","color","disabled","class","style"]))],64))),128))])):p.createCommentVNode("",!0)])]),(p.openBlock(),p.createElementBlock("svg",{class:"cross-icon",viewBox:"0 0 15 15",fill:"currentColor",onClick:f=>i(l.id)},[...c[1]||(c[1]=[p.createElementVNode("path",{d:"M11.78 4.03c.23-.23.23-.6 0-.83s-.6-.23-.83 0L7.5 6.69 4.03 3.2c-.23-.23-.6-.23-.83 0s-.23.6 0 .83L6.69 7.5 3.2 10.97c-.23.23-.23.6 0 .83s.6.23.83 0L7.5 8.31l3.47 3.47c.23.23.6.23.83 0s.23-.6 0-.83L8.31 7.5l3.47-3.47z"},null,-1)])],8,UE))],42,OE))),128))]),_:1}))}}),Pp=ci(BE,[["__scopeId","data-v-2cc28e46"]]),qE=["for"],jE={key:0,class:"text-danger"},HE=["disabled","readonly"],WE={value:""},zE=["id"],Np=p.defineComponent({__name:"FieldGender",props:{modelValue:{},field:{},fv:{},label:{type:[String,Boolean],default:!1},placeholder:{default:"—"},errors:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},required:{type:Boolean,default:!1},class:{},style:{},classLabel:{}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,r=e,s=p.computed({get(){return t.modelValue??""},set(o){r("update:modelValue",o??"")}}),i=p.computed(()=>typeof t.label!="string"&&t.label!==!0&&t.label!==!1);return(o,c)=>(p.openBlock(),p.createElementBlock(p.Fragment,null,[n.label&&!i.value?(p.openBlock(),p.createElementBlock("label",{key:0,class:p.normalizeClass(["form-label",t.classLabel]),for:n.fv.getFieldId(n.field)},[p.createTextVNode(p.toDisplayString(n.label===!0?n.field:n.label)+" ",1),n.required?(p.openBlock(),p.createElementBlock("span",jE," *")):p.createCommentVNode("",!0)],10,qE)):n.label&&i.value?(p.openBlock(),p.createBlock(p.resolveDynamicComponent(n.label),{key:1,for:n.fv.getFieldId(n.field)},null,8,["for"])):p.createCommentVNode("",!0),p.withDirectives(p.createElementVNode("select",p.mergeProps({class:"form-select","onUpdate:modelValue":c[0]||(c[0]=l=>s.value=l)},n.fv.getFieldProps(n.field),{class:t.class,style:t.style,disabled:n.disabled,readonly:n.readonly}),[p.createElementVNode("option",WE,p.toDisplayString(n.placeholder),1),c[1]||(c[1]=p.createElementVNode("option",{value:"m"},"Maschio",-1)),c[2]||(c[2]=p.createElementVNode("option",{value:"f"},"Femmina",-1)),c[3]||(c[3]=p.createElementVNode("option",{value:"o"},"Altro / Preferisco non dirlo",-1))],16,HE),[[p.vModelSelect,s.value]]),n.errors?(p.openBlock(),p.createElementBlock("div",{key:2,id:n.fv.getFieldIdError(n.field),class:"invalid-feedback"},p.toDisplayString(n.fv.showError(n.field)),9,zE)):p.createCommentVNode("",!0)],64))}}),KE=["for"],GE={class:"d-flex gap-2"},YE=["placeholder","disabled","readonly"],QE=["placeholder","disabled","readonly"],JE=["id"],XE=p.defineComponent({__name:"FieldPhoneNumber",props:{modelValue:{},field:{},fv:{},label:{type:[String,Boolean],default:!1},placeholder:{default:"333 1234567"},placeholderPrefix:{default:"+39"},errors:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},class:{},style:{},disabledPrefix:{type:Boolean},disabledNumber:{type:Boolean},readonlyPrefix:{type:Boolean},readonlyNumber:{type:Boolean},classPrefix:{},classNumber:{},stylePrefix:{},styleNumber:{}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,r=e,s=p.computed({get(){return t.modelValue?.[0]??t.placeholderPrefix??""},set(C){r("update:modelValue",[C,t.modelValue?.[1]??""])}}),i=p.computed({get(){return t.modelValue?.[1]??""},set(C){r("update:modelValue",[t.modelValue?.[0]??t.placeholderPrefix??"",C])}}),o=p.computed(()=>t.disabledPrefix??t.disabled),c=p.computed(()=>t.disabledNumber??t.disabled),l=p.computed(()=>t.readonlyPrefix??t.readonly),h=p.computed(()=>t.readonlyNumber??t.readonly),f=p.computed(()=>[t.class,t.classPrefix]),g=p.computed(()=>[t.class,t.classNumber]),_=p.computed(()=>[t.style,t.stylePrefix]),T=p.computed(()=>[t.style,t.styleNumber]);return(C,P)=>(p.openBlock(),p.createElementBlock(p.Fragment,null,[n.label?(p.openBlock(),p.createElementBlock("label",{key:0,class:"form-label",for:n.fv.getFieldId(n.field)},p.toDisplayString(n.label===!0?n.field:n.label),9,KE)):p.createCommentVNode("",!0),p.createElementVNode("div",GE,[p.withDirectives(p.createElementVNode("input",{type:"text","onUpdate:modelValue":P[0]||(P[0]=k=>s.value=k),class:p.normalizeClass(["form-control prefix-width",f.value]),style:p.normalizeStyle(_.value),placeholder:n.placeholderPrefix,disabled:o.value,readonly:l.value,autocomplete:"tel-country-code",inputmode:"tel"},null,14,YE),[[p.vModelText,s.value]]),p.withDirectives(p.createElementVNode("input",p.mergeProps({type:"text","onUpdate:modelValue":P[1]||(P[1]=k=>i.value=k)},n.fv.getFieldProps(n.field),{class:["form-control",g.value],style:T.value,placeholder:n.placeholder,disabled:c.value,readonly:h.value,autocomplete:"tel",inputmode:"tel"}),null,16,QE),[[p.vModelText,i.value]])]),n.errors?(p.openBlock(),p.createElementBlock("div",{key:1,id:n.fv.getFieldIdError(n.field),class:"invalid-feedback"},p.toDisplayString(n.fv.showError(n.field)),9,JE)):p.createCommentVNode("",!0)],64))}}),Dp=ci(XE,[["__scopeId","data-v-d70bf135"]]),ZE=["for"],ev={key:0,class:"text-danger"},tv=["type","placeholder","disabled","readonly","autocomplete","inputmode"],nv=["id"],Op=p.defineComponent({__name:"InputField",props:{modelValue:{},field:{},fv:{},label:{type:[String,Boolean],default:!1},placeholder:{default:""},errors:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},required:{type:Boolean,default:!1},class:{},style:{},classLabel:{},type:{default:"text"},autocomplete:{},inputmode:{}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,r=e,s=p.computed({get(){return t.modelValue??""},set(o){r("update:modelValue",o??"")}}),i=p.computed(()=>typeof t.label!="string"&&t.label!==!0&&t.label!==!1);return(o,c)=>(p.openBlock(),p.createElementBlock(p.Fragment,null,[n.label&&!i.value?(p.openBlock(),p.createElementBlock("label",{key:0,class:p.normalizeClass(["form-label",t.classLabel]),for:n.fv.getFieldId(n.field)},[p.createTextVNode(p.toDisplayString(n.label===!0?n.field:n.label)+" ",1),n.required?(p.openBlock(),p.createElementBlock("span",ev," *")):p.createCommentVNode("",!0)],10,ZE)):n.label&&i.value?(p.openBlock(),p.createBlock(p.resolveDynamicComponent(n.label),{key:1,for:n.fv.getFieldId(n.field)},null,8,["for"])):p.createCommentVNode("",!0),p.withDirectives(p.createElementVNode("input",p.mergeProps({type:n.type,"onUpdate:modelValue":c[0]||(c[0]=l=>s.value=l)},n.fv.getFieldProps(n.field),{class:["form-control",t.class],style:t.style,placeholder:n.placeholder,disabled:n.disabled,readonly:n.readonly,autocomplete:n.autocomplete,inputmode:n.inputmode}),null,16,tv),[[p.vModelDynamic,s.value]]),n.errors?(p.openBlock(),p.createElementBlock("div",{key:2,id:n.fv.getFieldIdError(n.field),class:"invalid-feedback"},p.toDisplayString(n.fv.showError(n.field)),9,nv)):p.createCommentVNode("",!0)],64))}});var Le="top",Je="bottom",Xe="right",Me="left",Xo="auto",ns=[Le,Je,Xe,Me],tr="start",Br="end",Vp="clippingParents",Sl="viewport",Cr="popper",Lp="reference",Mc=ns.reduce(function(n,e){return n.concat([e+"-"+tr,e+"-"+Br])},[]),Cl=[].concat(ns,[Xo]).reduce(function(n,e){return n.concat([e,e+"-"+tr,e+"-"+Br])},[]),Mp="beforeRead",xp="read",Fp="afterRead",$p="beforeMain",Up="main",Bp="afterMain",qp="beforeWrite",jp="write",Hp="afterWrite",Wp=[Mp,xp,Fp,$p,Up,Bp,qp,jp,Hp];function Pt(n){return n?(n.nodeName||"").toLowerCase():null}function Ze(n){if(n==null)return window;if(n.toString()!=="[object Window]"){var e=n.ownerDocument;return e&&e.defaultView||window}return n}function nr(n){var e=Ze(n).Element;return n instanceof e||n instanceof Element}function it(n){var e=Ze(n).HTMLElement;return n instanceof e||n instanceof HTMLElement}function Rl(n){if(typeof ShadowRoot>"u")return!1;var e=Ze(n).ShadowRoot;return n instanceof e||n instanceof ShadowRoot}function rv(n){var e=n.state;Object.keys(e.elements).forEach(function(t){var r=e.styles[t]||{},s=e.attributes[t]||{},i=e.elements[t];!it(i)||!Pt(i)||(Object.assign(i.style,r),Object.keys(s).forEach(function(o){var c=s[o];c===!1?i.removeAttribute(o):i.setAttribute(o,c===!0?"":c)}))})}function sv(n){var e=n.state,t={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,t.popper),e.styles=t,e.elements.arrow&&Object.assign(e.elements.arrow.style,t.arrow),function(){Object.keys(e.elements).forEach(function(r){var s=e.elements[r],i=e.attributes[r]||{},o=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:t[r]),c=o.reduce(function(l,h){return l[h]="",l},{});!it(s)||!Pt(s)||(Object.assign(s.style,c),Object.keys(i).forEach(function(l){s.removeAttribute(l)}))})}}const zp={name:"applyStyles",enabled:!0,phase:"write",fn:rv,effect:sv,requires:["computeStyles"]};function At(n){return n.split("-")[0]}var Qn=Math.max,go=Math.min,qr=Math.round;function xc(){var n=navigator.userAgentData;return n!=null&&n.brands&&Array.isArray(n.brands)?n.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function Kp(){return!/^((?!chrome|android).)*safari/i.test(xc())}function jr(n,e,t){e===void 0&&(e=!1),t===void 0&&(t=!1);var r=n.getBoundingClientRect(),s=1,i=1;e&&it(n)&&(s=n.offsetWidth>0&&qr(r.width)/n.offsetWidth||1,i=n.offsetHeight>0&&qr(r.height)/n.offsetHeight||1);var o=nr(n)?Ze(n):window,c=o.visualViewport,l=!Kp()&&t,h=(r.left+(l&&c?c.offsetLeft:0))/s,f=(r.top+(l&&c?c.offsetTop:0))/i,g=r.width/s,_=r.height/i;return{width:g,height:_,top:f,right:h+g,bottom:f+_,left:h,x:h,y:f}}function kl(n){var e=jr(n),t=n.offsetWidth,r=n.offsetHeight;return Math.abs(e.width-t)<=1&&(t=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:n.offsetLeft,y:n.offsetTop,width:t,height:r}}function Gp(n,e){var t=e.getRootNode&&e.getRootNode();if(n.contains(e))return!0;if(t&&Rl(t)){var r=e;do{if(r&&n.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Kt(n){return Ze(n).getComputedStyle(n)}function iv(n){return["table","td","th"].indexOf(Pt(n))>=0}function Dn(n){return((nr(n)?n.ownerDocument:n.document)||window.document).documentElement}function Zo(n){return Pt(n)==="html"?n:n.assignedSlot||n.parentNode||(Rl(n)?n.host:null)||Dn(n)}function Wh(n){return!it(n)||Kt(n).position==="fixed"?null:n.offsetParent}function ov(n){var e=/firefox/i.test(xc()),t=/Trident/i.test(xc());if(t&&it(n)){var r=Kt(n);if(r.position==="fixed")return null}var s=Zo(n);for(Rl(s)&&(s=s.host);it(s)&&["html","body"].indexOf(Pt(s))<0;){var i=Kt(s);if(i.transform!=="none"||i.perspective!=="none"||i.contain==="paint"||["transform","perspective"].indexOf(i.willChange)!==-1||e&&i.willChange==="filter"||e&&i.filter&&i.filter!=="none")return s;s=s.parentNode}return null}function li(n){for(var e=Ze(n),t=Wh(n);t&&iv(t)&&Kt(t).position==="static";)t=Wh(t);return t&&(Pt(t)==="html"||Pt(t)==="body"&&Kt(t).position==="static")?e:t||ov(n)||e}function Pl(n){return["top","bottom"].indexOf(n)>=0?"x":"y"}function Us(n,e,t){return Qn(n,go(e,t))}function av(n,e,t){var r=Us(n,e,t);return r>t?t:r}function Yp(){return{top:0,right:0,bottom:0,left:0}}function Qp(n){return Object.assign({},Yp(),n)}function Jp(n,e){return e.reduce(function(t,r){return t[r]=n,t},{})}var cv=function(e,t){return e=typeof e=="function"?e(Object.assign({},t.rects,{placement:t.placement})):e,Qp(typeof e!="number"?e:Jp(e,ns))};function lv(n){var e,t=n.state,r=n.name,s=n.options,i=t.elements.arrow,o=t.modifiersData.popperOffsets,c=At(t.placement),l=Pl(c),h=[Me,Xe].indexOf(c)>=0,f=h?"height":"width";if(!(!i||!o)){var g=cv(s.padding,t),_=kl(i),T=l==="y"?Le:Me,C=l==="y"?Je:Xe,P=t.rects.reference[f]+t.rects.reference[l]-o[l]-t.rects.popper[f],k=o[l]-t.rects.reference[l],L=li(i),$=L?l==="y"?L.clientHeight||0:L.clientWidth||0:0,U=P/2-k/2,F=g[T],j=$-_[f]-g[C],H=$/2-_[f]/2+U,w=Us(F,H,j),y=l;t.modifiersData[r]=(e={},e[y]=w,e.centerOffset=w-H,e)}}function uv(n){var e=n.state,t=n.options,r=t.element,s=r===void 0?"[data-popper-arrow]":r;s!=null&&(typeof s=="string"&&(s=e.elements.popper.querySelector(s),!s)||Gp(e.elements.popper,s)&&(e.elements.arrow=s))}const Xp={name:"arrow",enabled:!0,phase:"main",fn:lv,effect:uv,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Hr(n){return n.split("-")[1]}var hv={top:"auto",right:"auto",bottom:"auto",left:"auto"};function dv(n,e){var t=n.x,r=n.y,s=e.devicePixelRatio||1;return{x:qr(t*s)/s||0,y:qr(r*s)/s||0}}function zh(n){var e,t=n.popper,r=n.popperRect,s=n.placement,i=n.variation,o=n.offsets,c=n.position,l=n.gpuAcceleration,h=n.adaptive,f=n.roundOffsets,g=n.isFixed,_=o.x,T=_===void 0?0:_,C=o.y,P=C===void 0?0:C,k=typeof f=="function"?f({x:T,y:P}):{x:T,y:P};T=k.x,P=k.y;var L=o.hasOwnProperty("x"),$=o.hasOwnProperty("y"),U=Me,F=Le,j=window;if(h){var H=li(t),w="clientHeight",y="clientWidth";if(H===Ze(t)&&(H=Dn(t),Kt(H).position!=="static"&&c==="absolute"&&(w="scrollHeight",y="scrollWidth")),H=H,s===Le||(s===Me||s===Xe)&&i===Br){F=Je;var v=g&&H===j&&j.visualViewport?j.visualViewport.height:H[w];P-=v-r.height,P*=l?1:-1}if(s===Me||(s===Le||s===Je)&&i===Br){U=Xe;var A=g&&H===j&&j.visualViewport?j.visualViewport.width:H[y];T-=A-r.width,T*=l?1:-1}}var b=Object.assign({position:c},h&&hv),I=f===!0?dv({x:T,y:P},Ze(t)):{x:T,y:P};if(T=I.x,P=I.y,l){var E;return Object.assign({},b,(E={},E[F]=$?"0":"",E[U]=L?"0":"",E.transform=(j.devicePixelRatio||1)<=1?"translate("+T+"px, "+P+"px)":"translate3d("+T+"px, "+P+"px, 0)",E))}return Object.assign({},b,(e={},e[F]=$?P+"px":"",e[U]=L?T+"px":"",e.transform="",e))}function fv(n){var e=n.state,t=n.options,r=t.gpuAcceleration,s=r===void 0?!0:r,i=t.adaptive,o=i===void 0?!0:i,c=t.roundOffsets,l=c===void 0?!0:c,h={placement:At(e.placement),variation:Hr(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:s,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,zh(Object.assign({},h,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:o,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,zh(Object.assign({},h,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const Zp={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:fv,data:{}};var Ui={passive:!0};function pv(n){var e=n.state,t=n.instance,r=n.options,s=r.scroll,i=s===void 0?!0:s,o=r.resize,c=o===void 0?!0:o,l=Ze(e.elements.popper),h=[].concat(e.scrollParents.reference,e.scrollParents.popper);return i&&h.forEach(function(f){f.addEventListener("scroll",t.update,Ui)}),c&&l.addEventListener("resize",t.update,Ui),function(){i&&h.forEach(function(f){f.removeEventListener("scroll",t.update,Ui)}),c&&l.removeEventListener("resize",t.update,Ui)}}const em={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:pv,data:{}};var mv={left:"right",right:"left",bottom:"top",top:"bottom"};function eo(n){return n.replace(/left|right|bottom|top/g,function(e){return mv[e]})}var gv={start:"end",end:"start"};function Kh(n){return n.replace(/start|end/g,function(e){return gv[e]})}function Nl(n){var e=Ze(n),t=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:t,scrollTop:r}}function Dl(n){return jr(Dn(n)).left+Nl(n).scrollLeft}function _v(n,e){var t=Ze(n),r=Dn(n),s=t.visualViewport,i=r.clientWidth,o=r.clientHeight,c=0,l=0;if(s){i=s.width,o=s.height;var h=Kp();(h||!h&&e==="fixed")&&(c=s.offsetLeft,l=s.offsetTop)}return{width:i,height:o,x:c+Dl(n),y:l}}function yv(n){var e,t=Dn(n),r=Nl(n),s=(e=n.ownerDocument)==null?void 0:e.body,i=Qn(t.scrollWidth,t.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),o=Qn(t.scrollHeight,t.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0),c=-r.scrollLeft+Dl(n),l=-r.scrollTop;return Kt(s||t).direction==="rtl"&&(c+=Qn(t.clientWidth,s?s.clientWidth:0)-i),{width:i,height:o,x:c,y:l}}function Ol(n){var e=Kt(n),t=e.overflow,r=e.overflowX,s=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+s+r)}function tm(n){return["html","body","#document"].indexOf(Pt(n))>=0?n.ownerDocument.body:it(n)&&Ol(n)?n:tm(Zo(n))}function Bs(n,e){var t;e===void 0&&(e=[]);var r=tm(n),s=r===((t=n.ownerDocument)==null?void 0:t.body),i=Ze(r),o=s?[i].concat(i.visualViewport||[],Ol(r)?r:[]):r,c=e.concat(o);return s?c:c.concat(Bs(Zo(o)))}function Fc(n){return Object.assign({},n,{left:n.x,top:n.y,right:n.x+n.width,bottom:n.y+n.height})}function Ev(n,e){var t=jr(n,!1,e==="fixed");return t.top=t.top+n.clientTop,t.left=t.left+n.clientLeft,t.bottom=t.top+n.clientHeight,t.right=t.left+n.clientWidth,t.width=n.clientWidth,t.height=n.clientHeight,t.x=t.left,t.y=t.top,t}function Gh(n,e,t){return e===Sl?Fc(_v(n,t)):nr(e)?Ev(e,t):Fc(yv(Dn(n)))}function vv(n){var e=Bs(Zo(n)),t=["absolute","fixed"].indexOf(Kt(n).position)>=0,r=t&&it(n)?li(n):n;return nr(r)?e.filter(function(s){return nr(s)&&Gp(s,r)&&Pt(s)!=="body"}):[]}function Tv(n,e,t,r){var s=e==="clippingParents"?vv(n):[].concat(e),i=[].concat(s,[t]),o=i[0],c=i.reduce(function(l,h){var f=Gh(n,h,r);return l.top=Qn(f.top,l.top),l.right=go(f.right,l.right),l.bottom=go(f.bottom,l.bottom),l.left=Qn(f.left,l.left),l},Gh(n,o,r));return c.width=c.right-c.left,c.height=c.bottom-c.top,c.x=c.left,c.y=c.top,c}function nm(n){var e=n.reference,t=n.element,r=n.placement,s=r?At(r):null,i=r?Hr(r):null,o=e.x+e.width/2-t.width/2,c=e.y+e.height/2-t.height/2,l;switch(s){case Le:l={x:o,y:e.y-t.height};break;case Je:l={x:o,y:e.y+e.height};break;case Xe:l={x:e.x+e.width,y:c};break;case Me:l={x:e.x-t.width,y:c};break;default:l={x:e.x,y:e.y}}var h=s?Pl(s):null;if(h!=null){var f=h==="y"?"height":"width";switch(i){case tr:l[h]=l[h]-(e[f]/2-t[f]/2);break;case Br:l[h]=l[h]+(e[f]/2-t[f]/2);break}}return l}function Wr(n,e){e===void 0&&(e={});var t=e,r=t.placement,s=r===void 0?n.placement:r,i=t.strategy,o=i===void 0?n.strategy:i,c=t.boundary,l=c===void 0?Vp:c,h=t.rootBoundary,f=h===void 0?Sl:h,g=t.elementContext,_=g===void 0?Cr:g,T=t.altBoundary,C=T===void 0?!1:T,P=t.padding,k=P===void 0?0:P,L=Qp(typeof k!="number"?k:Jp(k,ns)),$=_===Cr?Lp:Cr,U=n.rects.popper,F=n.elements[C?$:_],j=Tv(nr(F)?F:F.contextElement||Dn(n.elements.popper),l,f,o),H=jr(n.elements.reference),w=nm({reference:H,element:U,placement:s}),y=Fc(Object.assign({},U,w)),v=_===Cr?y:H,A={top:j.top-v.top+L.top,bottom:v.bottom-j.bottom+L.bottom,left:j.left-v.left+L.left,right:v.right-j.right+L.right},b=n.modifiersData.offset;if(_===Cr&&b){var I=b[s];Object.keys(A).forEach(function(E){var le=[Xe,Je].indexOf(E)>=0?1:-1,Ne=[Le,Je].indexOf(E)>=0?"y":"x";A[E]+=I[Ne]*le})}return A}function wv(n,e){e===void 0&&(e={});var t=e,r=t.placement,s=t.boundary,i=t.rootBoundary,o=t.padding,c=t.flipVariations,l=t.allowedAutoPlacements,h=l===void 0?Cl:l,f=Hr(r),g=f?c?Mc:Mc.filter(function(C){return Hr(C)===f}):ns,_=g.filter(function(C){return h.indexOf(C)>=0});_.length===0&&(_=g);var T=_.reduce(function(C,P){return C[P]=Wr(n,{placement:P,boundary:s,rootBoundary:i,padding:o})[At(P)],C},{});return Object.keys(T).sort(function(C,P){return T[C]-T[P]})}function bv(n){if(At(n)===Xo)return[];var e=eo(n);return[Kh(n),e,Kh(e)]}function Av(n){var e=n.state,t=n.options,r=n.name;if(!e.modifiersData[r]._skip){for(var s=t.mainAxis,i=s===void 0?!0:s,o=t.altAxis,c=o===void 0?!0:o,l=t.fallbackPlacements,h=t.padding,f=t.boundary,g=t.rootBoundary,_=t.altBoundary,T=t.flipVariations,C=T===void 0?!0:T,P=t.allowedAutoPlacements,k=e.options.placement,L=At(k),$=L===k,U=l||($||!C?[eo(k)]:bv(k)),F=[k].concat(U).reduce(function(lt,nt){return lt.concat(At(nt)===Xo?wv(e,{placement:nt,boundary:f,rootBoundary:g,padding:h,flipVariations:C,allowedAutoPlacements:P}):nt)},[]),j=e.rects.reference,H=e.rects.popper,w=new Map,y=!0,v=F[0],A=0;A<F.length;A++){var b=F[A],I=At(b),E=Hr(b)===tr,le=[Le,Je].indexOf(I)>=0,Ne=le?"width":"height",De=Wr(e,{placement:b,boundary:f,rootBoundary:g,altBoundary:_,padding:h}),He=le?E?Xe:Me:E?Je:Le;j[Ne]>H[Ne]&&(He=eo(He));var Mt=eo(He),tt=[];if(i&&tt.push(De[I]<=0),c&&tt.push(De[He]<=0,De[Mt]<=0),tt.every(function(lt){return lt})){v=b,y=!1;break}w.set(b,tt)}if(y)for(var mr=C?3:1,gr=function(nt){var xt=F.find(function(rn){var ut=w.get(rn);if(ut)return ut.slice(0,nt).every(function(_r){return _r})});if(xt)return v=xt,"break"},nn=mr;nn>0;nn--){var Fn=gr(nn);if(Fn==="break")break}e.placement!==v&&(e.modifiersData[r]._skip=!0,e.placement=v,e.reset=!0)}}const rm={name:"flip",enabled:!0,phase:"main",fn:Av,requiresIfExists:["offset"],data:{_skip:!1}};function Yh(n,e,t){return t===void 0&&(t={x:0,y:0}),{top:n.top-e.height-t.y,right:n.right-e.width+t.x,bottom:n.bottom-e.height+t.y,left:n.left-e.width-t.x}}function Qh(n){return[Le,Xe,Je,Me].some(function(e){return n[e]>=0})}function Iv(n){var e=n.state,t=n.name,r=e.rects.reference,s=e.rects.popper,i=e.modifiersData.preventOverflow,o=Wr(e,{elementContext:"reference"}),c=Wr(e,{altBoundary:!0}),l=Yh(o,r),h=Yh(c,s,i),f=Qh(l),g=Qh(h);e.modifiersData[t]={referenceClippingOffsets:l,popperEscapeOffsets:h,isReferenceHidden:f,hasPopperEscaped:g},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":f,"data-popper-escaped":g})}const sm={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:Iv};function Sv(n,e,t){var r=At(n),s=[Me,Le].indexOf(r)>=0?-1:1,i=typeof t=="function"?t(Object.assign({},e,{placement:n})):t,o=i[0],c=i[1];return o=o||0,c=(c||0)*s,[Me,Xe].indexOf(r)>=0?{x:c,y:o}:{x:o,y:c}}function Cv(n){var e=n.state,t=n.options,r=n.name,s=t.offset,i=s===void 0?[0,0]:s,o=Cl.reduce(function(f,g){return f[g]=Sv(g,e.rects,i),f},{}),c=o[e.placement],l=c.x,h=c.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=h),e.modifiersData[r]=o}const im={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Cv};function Rv(n){var e=n.state,t=n.name;e.modifiersData[t]=nm({reference:e.rects.reference,element:e.rects.popper,placement:e.placement})}const om={name:"popperOffsets",enabled:!0,phase:"read",fn:Rv,data:{}};function kv(n){return n==="x"?"y":"x"}function Pv(n){var e=n.state,t=n.options,r=n.name,s=t.mainAxis,i=s===void 0?!0:s,o=t.altAxis,c=o===void 0?!1:o,l=t.boundary,h=t.rootBoundary,f=t.altBoundary,g=t.padding,_=t.tether,T=_===void 0?!0:_,C=t.tetherOffset,P=C===void 0?0:C,k=Wr(e,{boundary:l,rootBoundary:h,padding:g,altBoundary:f}),L=At(e.placement),$=Hr(e.placement),U=!$,F=Pl(L),j=kv(F),H=e.modifiersData.popperOffsets,w=e.rects.reference,y=e.rects.popper,v=typeof P=="function"?P(Object.assign({},e.rects,{placement:e.placement})):P,A=typeof v=="number"?{mainAxis:v,altAxis:v}:Object.assign({mainAxis:0,altAxis:0},v),b=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,I={x:0,y:0};if(H){if(i){var E,le=F==="y"?Le:Me,Ne=F==="y"?Je:Xe,De=F==="y"?"height":"width",He=H[F],Mt=He+k[le],tt=He-k[Ne],mr=T?-y[De]/2:0,gr=$===tr?w[De]:y[De],nn=$===tr?-y[De]:-w[De],Fn=e.elements.arrow,lt=T&&Fn?kl(Fn):{width:0,height:0},nt=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:Yp(),xt=nt[le],rn=nt[Ne],ut=Us(0,w[De],lt[De]),_r=U?w[De]/2-mr-ut-xt-A.mainAxis:gr-ut-xt-A.mainAxis,Oa=U?-w[De]/2+mr+ut+rn+A.mainAxis:nn+ut+rn+A.mainAxis,fs=e.elements.arrow&&li(e.elements.arrow),Ii=fs?F==="y"?fs.clientTop||0:fs.clientLeft||0:0,yr=(E=b?.[F])!=null?E:0,Si=He+_r-yr-Ii,Va=He+Oa-yr,Er=Us(T?go(Mt,Si):Mt,He,T?Qn(tt,Va):tt);H[F]=Er,I[F]=Er-He}if(c){var vr,Ci=F==="x"?Le:Me,ye=F==="x"?Je:Xe,ae=H[j],Ft=j==="y"?"height":"width",Ri=ae+k[Ci],ps=ae-k[ye],ms=[Le,Me].indexOf(L)!==-1,sn=(vr=b?.[j])!=null?vr:0,gs=ms?Ri:ae-w[Ft]-y[Ft]-sn+A.altAxis,_s=ms?ae+w[Ft]+y[Ft]-sn-A.altAxis:ps,Tr=T&&ms?av(gs,ae,_s):Us(T?gs:Ri,ae,T?_s:ps);H[j]=Tr,I[j]=Tr-ae}e.modifiersData[r]=I}}const am={name:"preventOverflow",enabled:!0,phase:"main",fn:Pv,requiresIfExists:["offset"]};function Nv(n){return{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}}function Dv(n){return n===Ze(n)||!it(n)?Nl(n):Nv(n)}function Ov(n){var e=n.getBoundingClientRect(),t=qr(e.width)/n.offsetWidth||1,r=qr(e.height)/n.offsetHeight||1;return t!==1||r!==1}function Vv(n,e,t){t===void 0&&(t=!1);var r=it(e),s=it(e)&&Ov(e),i=Dn(e),o=jr(n,s,t),c={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!t)&&((Pt(e)!=="body"||Ol(i))&&(c=Dv(e)),it(e)?(l=jr(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):i&&(l.x=Dl(i))),{x:o.left+c.scrollLeft-l.x,y:o.top+c.scrollTop-l.y,width:o.width,height:o.height}}function Lv(n){var e=new Map,t=new Set,r=[];n.forEach(function(i){e.set(i.name,i)});function s(i){t.add(i.name);var o=[].concat(i.requires||[],i.requiresIfExists||[]);o.forEach(function(c){if(!t.has(c)){var l=e.get(c);l&&s(l)}}),r.push(i)}return n.forEach(function(i){t.has(i.name)||s(i)}),r}function Mv(n){var e=Lv(n);return Wp.reduce(function(t,r){return t.concat(e.filter(function(s){return s.phase===r}))},[])}function xv(n){var e;return function(){return e||(e=new Promise(function(t){Promise.resolve().then(function(){e=void 0,t(n())})})),e}}function Fv(n){var e=n.reduce(function(t,r){var s=t[r.name];return t[r.name]=s?Object.assign({},s,r,{options:Object.assign({},s.options,r.options),data:Object.assign({},s.data,r.data)}):r,t},{});return Object.keys(e).map(function(t){return e[t]})}var Jh={placement:"bottom",modifiers:[],strategy:"absolute"};function Xh(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return!e.some(function(r){return!(r&&typeof r.getBoundingClientRect=="function")})}function cm(n){n===void 0&&(n={});var e=n,t=e.defaultModifiers,r=t===void 0?[]:t,s=e.defaultOptions,i=s===void 0?Jh:s;return function(c,l,h){h===void 0&&(h=i);var f={placement:"bottom",orderedModifiers:[],options:Object.assign({},Jh,i),modifiersData:{},elements:{reference:c,popper:l},attributes:{},styles:{}},g=[],_=!1,T={state:f,setOptions:function(L){var $=typeof L=="function"?L(f.options):L;P(),f.options=Object.assign({},i,f.options,$),f.scrollParents={reference:nr(c)?Bs(c):c.contextElement?Bs(c.contextElement):[],popper:Bs(l)};var U=Mv(Fv([].concat(r,f.options.modifiers)));return f.orderedModifiers=U.filter(function(F){return F.enabled}),C(),T.update()},forceUpdate:function(){if(!_){var L=f.elements,$=L.reference,U=L.popper;if(Xh($,U)){f.rects={reference:Vv($,li(U),f.options.strategy==="fixed"),popper:kl(U)},f.reset=!1,f.placement=f.options.placement,f.orderedModifiers.forEach(function(A){return f.modifiersData[A.name]=Object.assign({},A.data)});for(var F=0;F<f.orderedModifiers.length;F++){if(f.reset===!0){f.reset=!1,F=-1;continue}var j=f.orderedModifiers[F],H=j.fn,w=j.options,y=w===void 0?{}:w,v=j.name;typeof H=="function"&&(f=H({state:f,options:y,name:v,instance:T})||f)}}}},update:xv(function(){return new Promise(function(k){T.forceUpdate(),k(f)})}),destroy:function(){P(),_=!0}};if(!Xh(c,l))return T;T.setOptions(h).then(function(k){!_&&h.onFirstUpdate&&h.onFirstUpdate(k)});function C(){f.orderedModifiers.forEach(function(k){var L=k.name,$=k.options,U=$===void 0?{}:$,F=k.effect;if(typeof F=="function"){var j=F({state:f,name:L,instance:T,options:U}),H=function(){};g.push(j||H)}})}function P(){g.forEach(function(k){return k()}),g=[]}return T}}var $v=[em,om,Zp,zp,im,rm,am,Xp,sm],Vl=cm({defaultModifiers:$v});const lm=Object.freeze(Object.defineProperty({__proto__:null,afterMain:Bp,afterRead:Fp,afterWrite:Hp,applyStyles:zp,arrow:Xp,auto:Xo,basePlacements:ns,beforeMain:$p,beforeRead:Mp,beforeWrite:qp,bottom:Je,clippingParents:Vp,computeStyles:Zp,createPopper:Vl,detectOverflow:Wr,end:Br,eventListeners:em,flip:rm,hide:sm,left:Me,main:Up,modifierPhases:Wp,offset:im,placements:Cl,popper:Cr,popperGenerator:cm,popperOffsets:om,preventOverflow:am,read:xp,reference:Lp,right:Xe,start:tr,top:Le,variationPlacements:Mc,viewport:Sl,write:jp},Symbol.toStringTag,{value:"Module"}));const dn=new Map,Ja={set(n,e,t){dn.has(n)||dn.set(n,new Map);const r=dn.get(n);if(!r.has(e)&&r.size!==0){console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(r.keys())[0]}.`);return}r.set(e,t)},get(n,e){return dn.has(n)&&dn.get(n).get(e)||null},remove(n,e){if(!dn.has(n))return;const t=dn.get(n);t.delete(e),t.size===0&&dn.delete(n)}},Uv=1e6,Bv=1e3,$c="transitionend",um=n=>(n&&window.CSS&&window.CSS.escape&&(n=n.replace(/#([^\s"#']+)/g,(e,t)=>`#${CSS.escape(t)}`)),n),qv=n=>n==null?`${n}`:Object.prototype.toString.call(n).match(/\s([a-z]+)/i)[1].toLowerCase(),jv=n=>{do n+=Math.floor(Math.random()*Uv);while(document.getElementById(n));return n},Hv=n=>{if(!n)return 0;let{transitionDuration:e,transitionDelay:t}=window.getComputedStyle(n);const r=Number.parseFloat(e),s=Number.parseFloat(t);return!r&&!s?0:(e=e.split(",")[0],t=t.split(",")[0],(Number.parseFloat(e)+Number.parseFloat(t))*Bv)},hm=n=>{n.dispatchEvent(new Event($c))},jt=n=>!n||typeof n!="object"?!1:(typeof n.jquery<"u"&&(n=n[0]),typeof n.nodeType<"u"),wn=n=>jt(n)?n.jquery?n[0]:n:typeof n=="string"&&n.length>0?document.querySelector(um(n)):null,rs=n=>{if(!jt(n)||n.getClientRects().length===0)return!1;const e=getComputedStyle(n).getPropertyValue("visibility")==="visible",t=n.closest("details:not([open])");if(!t)return e;if(t!==n){const r=n.closest("summary");if(r&&r.parentNode!==t||r===null)return!1}return e},bn=n=>!n||n.nodeType!==Node.ELEMENT_NODE||n.classList.contains("disabled")?!0:typeof n.disabled<"u"?n.disabled:n.hasAttribute("disabled")&&n.getAttribute("disabled")!=="false",dm=n=>{if(!document.documentElement.attachShadow)return null;if(typeof n.getRootNode=="function"){const e=n.getRootNode();return e instanceof ShadowRoot?e:null}return n instanceof ShadowRoot?n:n.parentNode?dm(n.parentNode):null},_o=()=>{},ui=n=>{n.offsetHeight},fm=()=>window.jQuery&&!document.body.hasAttribute("data-bs-no-jquery")?window.jQuery:null,Xa=[],Wv=n=>{document.readyState==="loading"?(Xa.length||document.addEventListener("DOMContentLoaded",()=>{for(const e of Xa)e()}),Xa.push(n)):n()},ot=()=>document.documentElement.dir==="rtl",ct=n=>{Wv(()=>{const e=fm();if(e){const t=n.NAME,r=e.fn[t];e.fn[t]=n.jQueryInterface,e.fn[t].Constructor=n,e.fn[t].noConflict=()=>(e.fn[t]=r,n.jQueryInterface)}})},Ue=(n,e=[],t=n)=>typeof n=="function"?n.call(...e):t,pm=(n,e,t=!0)=>{if(!t){Ue(n);return}const s=Hv(e)+5;let i=!1;const o=({target:c})=>{c===e&&(i=!0,e.removeEventListener($c,o),Ue(n))};e.addEventListener($c,o),setTimeout(()=>{i||hm(e)},s)},Ll=(n,e,t,r)=>{const s=n.length;let i=n.indexOf(e);return i===-1?!t&&r?n[s-1]:n[0]:(i+=t?1:-1,r&&(i=(i+s)%s),n[Math.max(0,Math.min(i,s-1))])},zv=/[^.]*(?=\..*)\.|.*/,Kv=/\..*/,Gv=/::\d+$/,Za={};let Zh=1;const mm={mouseenter:"mouseover",mouseleave:"mouseout"},Yv=new Set(["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointerdown","pointermove","pointerup","pointerleave","pointercancel","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"]);function gm(n,e){return e&&`${e}::${Zh++}`||n.uidEvent||Zh++}function _m(n){const e=gm(n);return n.uidEvent=e,Za[e]=Za[e]||{},Za[e]}function Qv(n,e){return function t(r){return Ml(r,{delegateTarget:n}),t.oneOff&&O.off(n,r.type,e),e.apply(n,[r])}}function Jv(n,e,t){return function r(s){const i=n.querySelectorAll(e);for(let{target:o}=s;o&&o!==this;o=o.parentNode)for(const c of i)if(c===o)return Ml(s,{delegateTarget:o}),r.oneOff&&O.off(n,s.type,e,t),t.apply(o,[s])}}function ym(n,e,t=null){return Object.values(n).find(r=>r.callable===e&&r.delegationSelector===t)}function Em(n,e,t){const r=typeof e=="string",s=r?t:e||t;let i=vm(n);return Yv.has(i)||(i=n),[r,s,i]}function ed(n,e,t,r,s){if(typeof e!="string"||!n)return;let[i,o,c]=Em(e,t,r);e in mm&&(o=(C=>function(P){if(!P.relatedTarget||P.relatedTarget!==P.delegateTarget&&!P.delegateTarget.contains(P.relatedTarget))return C.call(this,P)})(o));const l=_m(n),h=l[c]||(l[c]={}),f=ym(h,o,i?t:null);if(f){f.oneOff=f.oneOff&&s;return}const g=gm(o,e.replace(zv,"")),_=i?Jv(n,t,o):Qv(n,o);_.delegationSelector=i?t:null,_.callable=o,_.oneOff=s,_.uidEvent=g,h[g]=_,n.addEventListener(c,_,i)}function Uc(n,e,t,r,s){const i=ym(e[t],r,s);i&&(n.removeEventListener(t,i,!!s),delete e[t][i.uidEvent])}function Xv(n,e,t,r){const s=e[t]||{};for(const[i,o]of Object.entries(s))i.includes(r)&&Uc(n,e,t,o.callable,o.delegationSelector)}function vm(n){return n=n.replace(Kv,""),mm[n]||n}const O={on(n,e,t,r){ed(n,e,t,r,!1)},one(n,e,t,r){ed(n,e,t,r,!0)},off(n,e,t,r){if(typeof e!="string"||!n)return;const[s,i,o]=Em(e,t,r),c=o!==e,l=_m(n),h=l[o]||{},f=e.startsWith(".");if(typeof i<"u"){if(!Object.keys(h).length)return;Uc(n,l,o,i,s?t:null);return}if(f)for(const g of Object.keys(l))Xv(n,l,g,e.slice(1));for(const[g,_]of Object.entries(h)){const T=g.replace(Gv,"");(!c||e.includes(T))&&Uc(n,l,o,_.callable,_.delegationSelector)}},trigger(n,e,t){if(typeof e!="string"||!n)return null;const r=fm(),s=vm(e),i=e!==s;let o=null,c=!0,l=!0,h=!1;i&&r&&(o=r.Event(e,t),r(n).trigger(o),c=!o.isPropagationStopped(),l=!o.isImmediatePropagationStopped(),h=o.isDefaultPrevented());const f=Ml(new Event(e,{bubbles:c,cancelable:!0}),t);return h&&f.preventDefault(),l&&n.dispatchEvent(f),f.defaultPrevented&&o&&o.preventDefault(),f}};function Ml(n,e={}){for(const[t,r]of Object.entries(e))try{n[t]=r}catch{Object.defineProperty(n,t,{configurable:!0,get(){return r}})}return n}function td(n){if(n==="true")return!0;if(n==="false")return!1;if(n===Number(n).toString())return Number(n);if(n===""||n==="null")return null;if(typeof n!="string")return n;try{return JSON.parse(decodeURIComponent(n))}catch{return n}}function ec(n){return n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}const Ht={setDataAttribute(n,e,t){n.setAttribute(`data-bs-${ec(e)}`,t)},removeDataAttribute(n,e){n.removeAttribute(`data-bs-${ec(e)}`)},getDataAttributes(n){if(!n)return{};const e={},t=Object.keys(n.dataset).filter(r=>r.startsWith("bs")&&!r.startsWith("bsConfig"));for(const r of t){let s=r.replace(/^bs/,"");s=s.charAt(0).toLowerCase()+s.slice(1),e[s]=td(n.dataset[r])}return e},getDataAttribute(n,e){return td(n.getAttribute(`data-bs-${ec(e)}`))}};class hi{static get Default(){return{}}static get DefaultType(){return{}}static get NAME(){throw new Error('You have to implement the static method "NAME", for each component!')}_getConfig(e){return e=this._mergeConfigObj(e),e=this._configAfterMerge(e),this._typeCheckConfig(e),e}_configAfterMerge(e){return e}_mergeConfigObj(e,t){const r=jt(t)?Ht.getDataAttribute(t,"config"):{};return{...this.constructor.Default,...typeof r=="object"?r:{},...jt(t)?Ht.getDataAttributes(t):{},...typeof e=="object"?e:{}}}_typeCheckConfig(e,t=this.constructor.DefaultType){for(const[r,s]of Object.entries(t)){const i=e[r],o=jt(i)?"element":qv(i);if(!new RegExp(s).test(o))throw new TypeError(`${this.constructor.NAME.toUpperCase()}: Option "${r}" provided type "${o}" but expected type "${s}".`)}}}const Zv="5.3.8";class Et extends hi{constructor(e,t){super(),e=wn(e),e&&(this._element=e,this._config=this._getConfig(t),Ja.set(this._element,this.constructor.DATA_KEY,this))}dispose(){Ja.remove(this._element,this.constructor.DATA_KEY),O.off(this._element,this.constructor.EVENT_KEY);for(const e of Object.getOwnPropertyNames(this))this[e]=null}_queueCallback(e,t,r=!0){pm(e,t,r)}_getConfig(e){return e=this._mergeConfigObj(e,this._element),e=this._configAfterMerge(e),this._typeCheckConfig(e),e}static getInstance(e){return Ja.get(wn(e),this.DATA_KEY)}static getOrCreateInstance(e,t={}){return this.getInstance(e)||new this(e,typeof t=="object"?t:null)}static get VERSION(){return Zv}static get DATA_KEY(){return`bs.${this.NAME}`}static get EVENT_KEY(){return`.${this.DATA_KEY}`}static eventName(e){return`${e}${this.EVENT_KEY}`}}const tc=n=>{let e=n.getAttribute("data-bs-target");if(!e||e==="#"){let t=n.getAttribute("href");if(!t||!t.includes("#")&&!t.startsWith("."))return null;t.includes("#")&&!t.startsWith("#")&&(t=`#${t.split("#")[1]}`),e=t&&t!=="#"?t.trim():null}return e?e.split(",").map(t=>um(t)).join(","):null},q={find(n,e=document.documentElement){return[].concat(...Element.prototype.querySelectorAll.call(e,n))},findOne(n,e=document.documentElement){return Element.prototype.querySelector.call(e,n)},children(n,e){return[].concat(...n.children).filter(t=>t.matches(e))},parents(n,e){const t=[];let r=n.parentNode.closest(e);for(;r;)t.push(r),r=r.parentNode.closest(e);return t},prev(n,e){let t=n.previousElementSibling;for(;t;){if(t.matches(e))return[t];t=t.previousElementSibling}return[]},next(n,e){let t=n.nextElementSibling;for(;t;){if(t.matches(e))return[t];t=t.nextElementSibling}return[]},focusableChildren(n){const e=["a","button","input","textarea","select","details","[tabindex]",'[contenteditable="true"]'].map(t=>`${t}:not([tabindex^="-"])`).join(",");return this.find(e,n).filter(t=>!bn(t)&&rs(t))},getSelectorFromElement(n){const e=tc(n);return e&&q.findOne(e)?e:null},getElementFromSelector(n){const e=tc(n);return e?q.findOne(e):null},getMultipleElementsFromSelector(n){const e=tc(n);return e?q.find(e):[]}},ea=(n,e="hide")=>{const t=`click.dismiss${n.EVENT_KEY}`,r=n.NAME;O.on(document,t,`[data-bs-dismiss="${r}"]`,function(s){if(["A","AREA"].includes(this.tagName)&&s.preventDefault(),bn(this))return;const i=q.getElementFromSelector(this)||this.closest(`.${r}`);n.getOrCreateInstance(i)[e]()})},eT="alert",tT="bs.alert",Tm=`.${tT}`,nT=`close${Tm}`,rT=`closed${Tm}`,sT="fade",iT="show";class ta extends Et{static get NAME(){return eT}close(){if(O.trigger(this._element,nT).defaultPrevented)return;this._element.classList.remove(iT);const t=this._element.classList.contains(sT);this._queueCallback(()=>this._destroyElement(),this._element,t)}_destroyElement(){this._element.remove(),O.trigger(this._element,rT),this.dispose()}static jQueryInterface(e){return this.each(function(){const t=ta.getOrCreateInstance(this);if(typeof e=="string"){if(t[e]===void 0||e.startsWith("_")||e==="constructor")throw new TypeError(`No method named "${e}"`);t[e](this)}})}}ea(ta,"close");ct(ta);const oT="button",aT="bs.button",cT=`.${aT}`,lT=".data-api",uT="active",nd='[data-bs-toggle="button"]',hT=`click${cT}${lT}`;class na extends Et{static get NAME(){return oT}toggle(){this._element.setAttribute("aria-pressed",this._element.classList.toggle(uT))}static jQueryInterface(e){return this.each(function(){const t=na.getOrCreateInstance(this);e==="toggle"&&t[e]()})}}O.on(document,hT,nd,n=>{n.preventDefault();const e=n.target.closest(nd);na.getOrCreateInstance(e).toggle()});ct(na);const dT="swipe",ss=".bs.swipe",fT=`touchstart${ss}`,pT=`touchmove${ss}`,mT=`touchend${ss}`,gT=`pointerdown${ss}`,_T=`pointerup${ss}`,yT="touch",ET="pen",vT="pointer-event",TT=40,wT={endCallback:null,leftCallback:null,rightCallback:null},bT={endCallback:"(function|null)",leftCallback:"(function|null)",rightCallback:"(function|null)"};class yo extends hi{constructor(e,t){super(),this._element=e,!(!e||!yo.isSupported())&&(this._config=this._getConfig(t),this._deltaX=0,this._supportPointerEvents=!!window.PointerEvent,this._initEvents())}static get Default(){return wT}static get DefaultType(){return bT}static get NAME(){return dT}dispose(){O.off(this._element,ss)}_start(e){if(!this._supportPointerEvents){this._deltaX=e.touches[0].clientX;return}this._eventIsPointerPenTouch(e)&&(this._deltaX=e.clientX)}_end(e){this._eventIsPointerPenTouch(e)&&(this._deltaX=e.clientX-this._deltaX),this._handleSwipe(),Ue(this._config.endCallback)}_move(e){this._deltaX=e.touches&&e.touches.length>1?0:e.touches[0].clientX-this._deltaX}_handleSwipe(){const e=Math.abs(this._deltaX);if(e<=TT)return;const t=e/this._deltaX;this._deltaX=0,t&&Ue(t>0?this._config.rightCallback:this._config.leftCallback)}_initEvents(){this._supportPointerEvents?(O.on(this._element,gT,e=>this._start(e)),O.on(this._element,_T,e=>this._end(e)),this._element.classList.add(vT)):(O.on(this._element,fT,e=>this._start(e)),O.on(this._element,pT,e=>this._move(e)),O.on(this._element,mT,e=>this._end(e)))}_eventIsPointerPenTouch(e){return this._supportPointerEvents&&(e.pointerType===ET||e.pointerType===yT)}static isSupported(){return"ontouchstart"in document.documentElement||navigator.maxTouchPoints>0}}const AT="carousel",IT="bs.carousel",On=`.${IT}`,wm=".data-api",ST="ArrowLeft",CT="ArrowRight",RT=500,Os="next",Ir="prev",Rr="left",to="right",kT=`slide${On}`,nc=`slid${On}`,PT=`keydown${On}`,NT=`mouseenter${On}`,DT=`mouseleave${On}`,OT=`dragstart${On}`,VT=`load${On}${wm}`,LT=`click${On}${wm}`,bm="carousel",Bi="active",MT="slide",xT="carousel-item-end",FT="carousel-item-start",$T="carousel-item-next",UT="carousel-item-prev",Am=".active",Im=".carousel-item",BT=Am+Im,qT=".carousel-item img",jT=".carousel-indicators",HT="[data-bs-slide], [data-bs-slide-to]",WT='[data-bs-ride="carousel"]',zT={[ST]:to,[CT]:Rr},KT={interval:5e3,keyboard:!0,pause:"hover",ride:!1,touch:!0,wrap:!0},GT={interval:"(number|boolean)",keyboard:"boolean",pause:"(string|boolean)",ride:"(boolean|string)",touch:"boolean",wrap:"boolean"};class di extends Et{constructor(e,t){super(e,t),this._interval=null,this._activeElement=null,this._isSliding=!1,this.touchTimeout=null,this._swipeHelper=null,this._indicatorsElement=q.findOne(jT,this._element),this._addEventListeners(),this._config.ride===bm&&this.cycle()}static get Default(){return KT}static get DefaultType(){return GT}static get NAME(){return AT}next(){this._slide(Os)}nextWhenVisible(){!document.hidden&&rs(this._element)&&this.next()}prev(){this._slide(Ir)}pause(){this._isSliding&&hm(this._element),this._clearInterval()}cycle(){this._clearInterval(),this._updateInterval(),this._interval=setInterval(()=>this.nextWhenVisible(),this._config.interval)}_maybeEnableCycle(){if(this._config.ride){if(this._isSliding){O.one(this._element,nc,()=>this.cycle());return}this.cycle()}}to(e){const t=this._getItems();if(e>t.length-1||e<0)return;if(this._isSliding){O.one(this._element,nc,()=>this.to(e));return}const r=this._getItemIndex(this._getActive());if(r===e)return;const s=e>r?Os:Ir;this._slide(s,t[e])}dispose(){this._swipeHelper&&this._swipeHelper.dispose(),super.dispose()}_configAfterMerge(e){return e.defaultInterval=e.interval,e}_addEventListeners(){this._config.keyboard&&O.on(this._element,PT,e=>this._keydown(e)),this._config.pause==="hover"&&(O.on(this._element,NT,()=>this.pause()),O.on(this._element,DT,()=>this._maybeEnableCycle())),this._config.touch&&yo.isSupported()&&this._addTouchEventListeners()}_addTouchEventListeners(){for(const r of q.find(qT,this._element))O.on(r,OT,s=>s.preventDefault());const t={leftCallback:()=>this._slide(this._directionToOrder(Rr)),rightCallback:()=>this._slide(this._directionToOrder(to)),endCallback:()=>{this._config.pause==="hover"&&(this.pause(),this.touchTimeout&&clearTimeout(this.touchTimeout),this.touchTimeout=setTimeout(()=>this._maybeEnableCycle(),RT+this._config.interval))}};this._swipeHelper=new yo(this._element,t)}_keydown(e){if(/input|textarea/i.test(e.target.tagName))return;const t=zT[e.key];t&&(e.preventDefault(),this._slide(this._directionToOrder(t)))}_getItemIndex(e){return this._getItems().indexOf(e)}_setActiveIndicatorElement(e){if(!this._indicatorsElement)return;const t=q.findOne(Am,this._indicatorsElement);t.classList.remove(Bi),t.removeAttribute("aria-current");const r=q.findOne(`[data-bs-slide-to="${e}"]`,this._indicatorsElement);r&&(r.classList.add(Bi),r.setAttribute("aria-current","true"))}_updateInterval(){const e=this._activeElement||this._getActive();if(!e)return;const t=Number.parseInt(e.getAttribute("data-bs-interval"),10);this._config.interval=t||this._config.defaultInterval}_slide(e,t=null){if(this._isSliding)return;const r=this._getActive(),s=e===Os,i=t||Ll(this._getItems(),r,s,this._config.wrap);if(i===r)return;const o=this._getItemIndex(i),c=T=>O.trigger(this._element,T,{relatedTarget:i,direction:this._orderToDirection(e),from:this._getItemIndex(r),to:o});if(c(kT).defaultPrevented||!r||!i)return;const h=!!this._interval;this.pause(),this._isSliding=!0,this._setActiveIndicatorElement(o),this._activeElement=i;const f=s?FT:xT,g=s?$T:UT;i.classList.add(g),ui(i),r.classList.add(f),i.classList.add(f);const _=()=>{i.classList.remove(f,g),i.classList.add(Bi),r.classList.remove(Bi,g,f),this._isSliding=!1,c(nc)};this._queueCallback(_,r,this._isAnimated()),h&&this.cycle()}_isAnimated(){return this._element.classList.contains(MT)}_getActive(){return q.findOne(BT,this._element)}_getItems(){return q.find(Im,this._element)}_clearInterval(){this._interval&&(clearInterval(this._interval),this._interval=null)}_directionToOrder(e){return ot()?e===Rr?Ir:Os:e===Rr?Os:Ir}_orderToDirection(e){return ot()?e===Ir?Rr:to:e===Ir?to:Rr}static jQueryInterface(e){return this.each(function(){const t=di.getOrCreateInstance(this,e);if(typeof e=="number"){t.to(e);return}if(typeof e=="string"){if(t[e]===void 0||e.startsWith("_")||e==="constructor")throw new TypeError(`No method named "${e}"`);t[e]()}})}}O.on(document,LT,HT,function(n){const e=q.getElementFromSelector(this);if(!e||!e.classList.contains(bm))return;n.preventDefault();const t=di.getOrCreateInstance(e),r=this.getAttribute("data-bs-slide-to");if(r){t.to(r),t._maybeEnableCycle();return}if(Ht.getDataAttribute(this,"slide")==="next"){t.next(),t._maybeEnableCycle();return}t.prev(),t._maybeEnableCycle()});O.on(window,VT,()=>{const n=q.find(WT);for(const e of n)di.getOrCreateInstance(e)});ct(di);const YT="collapse",QT="bs.collapse",fi=`.${QT}`,JT=".data-api",XT=`show${fi}`,ZT=`shown${fi}`,ew=`hide${fi}`,tw=`hidden${fi}`,nw=`click${fi}${JT}`,rc="show",Vr="collapse",qi="collapsing",rw="collapsed",sw=`:scope .${Vr} .${Vr}`,iw="collapse-horizontal",ow="width",aw="height",cw=".collapse.show, .collapse.collapsing",Bc='[data-bs-toggle="collapse"]',lw={parent:null,toggle:!0},uw={parent:"(null|element)",toggle:"boolean"};class Qs extends Et{constructor(e,t){super(e,t),this._isTransitioning=!1,this._triggerArray=[];const r=q.find(Bc);for(const s of r){const i=q.getSelectorFromElement(s),o=q.find(i).filter(c=>c===this._element);i!==null&&o.length&&this._triggerArray.push(s)}this._initializeChildren(),this._config.parent||this._addAriaAndCollapsedClass(this._triggerArray,this._isShown()),this._config.toggle&&this.toggle()}static get Default(){return lw}static get DefaultType(){return uw}static get NAME(){return YT}toggle(){this._isShown()?this.hide():this.show()}show(){if(this._isTransitioning||this._isShown())return;let e=[];if(this._config.parent&&(e=this._getFirstLevelChildren(cw).filter(c=>c!==this._element).map(c=>Qs.getOrCreateInstance(c,{toggle:!1}))),e.length&&e[0]._isTransitioning||O.trigger(this._element,XT).defaultPrevented)return;for(const c of e)c.hide();const r=this._getDimension();this._element.classList.remove(Vr),this._element.classList.add(qi),this._element.style[r]=0,this._addAriaAndCollapsedClass(this._triggerArray,!0),this._isTransitioning=!0;const s=()=>{this._isTransitioning=!1,this._element.classList.remove(qi),this._element.classList.add(Vr,rc),this._element.style[r]="",O.trigger(this._element,ZT)},o=`scroll${r[0].toUpperCase()+r.slice(1)}`;this._queueCallback(s,this._element,!0),this._element.style[r]=`${this._element[o]}px`}hide(){if(this._isTransitioning||!this._isShown()||O.trigger(this._element,ew).defaultPrevented)return;const t=this._getDimension();this._element.style[t]=`${this._element.getBoundingClientRect()[t]}px`,ui(this._element),this._element.classList.add(qi),this._element.classList.remove(Vr,rc);for(const s of this._triggerArray){const i=q.getElementFromSelector(s);i&&!this._isShown(i)&&this._addAriaAndCollapsedClass([s],!1)}this._isTransitioning=!0;const r=()=>{this._isTransitioning=!1,this._element.classList.remove(qi),this._element.classList.add(Vr),O.trigger(this._element,tw)};this._element.style[t]="",this._queueCallback(r,this._element,!0)}_isShown(e=this._element){return e.classList.contains(rc)}_configAfterMerge(e){return e.toggle=!!e.toggle,e.parent=wn(e.parent),e}_getDimension(){return this._element.classList.contains(iw)?ow:aw}_initializeChildren(){if(!this._config.parent)return;const e=this._getFirstLevelChildren(Bc);for(const t of e){const r=q.getElementFromSelector(t);r&&this._addAriaAndCollapsedClass([t],this._isShown(r))}}_getFirstLevelChildren(e){const t=q.find(sw,this._config.parent);return q.find(e,this._config.parent).filter(r=>!t.includes(r))}_addAriaAndCollapsedClass(e,t){if(e.length)for(const r of e)r.classList.toggle(rw,!t),r.setAttribute("aria-expanded",t)}static jQueryInterface(e){const t={};return typeof e=="string"&&/show|hide/.test(e)&&(t.toggle=!1),this.each(function(){const r=Qs.getOrCreateInstance(this,t);if(typeof e=="string"){if(typeof r[e]>"u")throw new TypeError(`No method named "${e}"`);r[e]()}})}}O.on(document,nw,Bc,function(n){(n.target.tagName==="A"||n.delegateTarget&&n.delegateTarget.tagName==="A")&&n.preventDefault();for(const e of q.getMultipleElementsFromSelector(this))Qs.getOrCreateInstance(e,{toggle:!1}).toggle()});ct(Qs);const rd="dropdown",hw="bs.dropdown",ur=`.${hw}`,xl=".data-api",dw="Escape",sd="Tab",fw="ArrowUp",id="ArrowDown",pw=2,mw=`hide${ur}`,gw=`hidden${ur}`,_w=`show${ur}`,yw=`shown${ur}`,Sm=`click${ur}${xl}`,Cm=`keydown${ur}${xl}`,Ew=`keyup${ur}${xl}`,kr="show",vw="dropup",Tw="dropend",ww="dropstart",bw="dropup-center",Aw="dropdown-center",Wn='[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)',Iw=`${Wn}.${kr}`,no=".dropdown-menu",Sw=".navbar",Cw=".navbar-nav",Rw=".dropdown-menu .dropdown-item:not(.disabled):not(:disabled)",kw=ot()?"top-end":"top-start",Pw=ot()?"top-start":"top-end",Nw=ot()?"bottom-end":"bottom-start",Dw=ot()?"bottom-start":"bottom-end",Ow=ot()?"left-start":"right-start",Vw=ot()?"right-start":"left-start",Lw="top",Mw="bottom",xw={autoClose:!0,boundary:"clippingParents",display:"dynamic",offset:[0,2],popperConfig:null,reference:"toggle"},Fw={autoClose:"(boolean|string)",boundary:"(string|element)",display:"string",offset:"(array|string|function)",popperConfig:"(null|object|function)",reference:"(string|element|object)"};class It extends Et{constructor(e,t){super(e,t),this._popper=null,this._parent=this._element.parentNode,this._menu=q.next(this._element,no)[0]||q.prev(this._element,no)[0]||q.findOne(no,this._parent),this._inNavbar=this._detectNavbar()}static get Default(){return xw}static get DefaultType(){return Fw}static get NAME(){return rd}toggle(){return this._isShown()?this.hide():this.show()}show(){if(bn(this._element)||this._isShown())return;const e={relatedTarget:this._element};if(!O.trigger(this._element,_w,e).defaultPrevented){if(this._createPopper(),"ontouchstart"in document.documentElement&&!this._parent.closest(Cw))for(const r of[].concat(...document.body.children))O.on(r,"mouseover",_o);this._element.focus(),this._element.setAttribute("aria-expanded",!0),this._menu.classList.add(kr),this._element.classList.add(kr),O.trigger(this._element,yw,e)}}hide(){if(bn(this._element)||!this._isShown())return;const e={relatedTarget:this._element};this._completeHide(e)}dispose(){this._popper&&this._popper.destroy(),super.dispose()}update(){this._inNavbar=this._detectNavbar(),this._popper&&this._popper.update()}_completeHide(e){if(!O.trigger(this._element,mw,e).defaultPrevented){if("ontouchstart"in document.documentElement)for(const r of[].concat(...document.body.children))O.off(r,"mouseover",_o);this._popper&&this._popper.destroy(),this._menu.classList.remove(kr),this._element.classList.remove(kr),this._element.setAttribute("aria-expanded","false"),Ht.removeDataAttribute(this._menu,"popper"),O.trigger(this._element,gw,e)}}_getConfig(e){if(e=super._getConfig(e),typeof e.reference=="object"&&!jt(e.reference)&&typeof e.reference.getBoundingClientRect!="function")throw new TypeError(`${rd.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);return e}_createPopper(){if(typeof lm>"u")throw new TypeError("Bootstrap's dropdowns require Popper (https://popper.js.org/docs/v2/)");let e=this._element;this._config.reference==="parent"?e=this._parent:jt(this._config.reference)?e=wn(this._config.reference):typeof this._config.reference=="object"&&(e=this._config.reference);const t=this._getPopperConfig();this._popper=Vl(e,this._menu,t)}_isShown(){return this._menu.classList.contains(kr)}_getPlacement(){const e=this._parent;if(e.classList.contains(Tw))return Ow;if(e.classList.contains(ww))return Vw;if(e.classList.contains(bw))return Lw;if(e.classList.contains(Aw))return Mw;const t=getComputedStyle(this._menu).getPropertyValue("--bs-position").trim()==="end";return e.classList.contains(vw)?t?Pw:kw:t?Dw:Nw}_detectNavbar(){return this._element.closest(Sw)!==null}_getOffset(){const{offset:e}=this._config;return typeof e=="string"?e.split(",").map(t=>Number.parseInt(t,10)):typeof e=="function"?t=>e(t,this._element):e}_getPopperConfig(){const e={placement:this._getPlacement(),modifiers:[{name:"preventOverflow",options:{boundary:this._config.boundary}},{name:"offset",options:{offset:this._getOffset()}}]};return(this._inNavbar||this._config.display==="static")&&(Ht.setDataAttribute(this._menu,"popper","static"),e.modifiers=[{name:"applyStyles",enabled:!1}]),{...e,...Ue(this._config.popperConfig,[void 0,e])}}_selectMenuItem({key:e,target:t}){const r=q.find(Rw,this._menu).filter(s=>rs(s));r.length&&Ll(r,t,e===id,!r.includes(t)).focus()}static jQueryInterface(e){return this.each(function(){const t=It.getOrCreateInstance(this,e);if(typeof e=="string"){if(typeof t[e]>"u")throw new TypeError(`No method named "${e}"`);t[e]()}})}static clearMenus(e){if(e.button===pw||e.type==="keyup"&&e.key!==sd)return;const t=q.find(Iw);for(const r of t){const s=It.getInstance(r);if(!s||s._config.autoClose===!1)continue;const i=e.composedPath(),o=i.includes(s._menu);if(i.includes(s._element)||s._config.autoClose==="inside"&&!o||s._config.autoClose==="outside"&&o||s._menu.contains(e.target)&&(e.type==="keyup"&&e.key===sd||/input|select|option|textarea|form/i.test(e.target.tagName)))continue;const c={relatedTarget:s._element};e.type==="click"&&(c.clickEvent=e),s._completeHide(c)}}static dataApiKeydownHandler(e){const t=/input|textarea/i.test(e.target.tagName),r=e.key===dw,s=[fw,id].includes(e.key);if(!s&&!r||t&&!r)return;e.preventDefault();const i=this.matches(Wn)?this:q.prev(this,Wn)[0]||q.next(this,Wn)[0]||q.findOne(Wn,e.delegateTarget.parentNode),o=It.getOrCreateInstance(i);if(s){e.stopPropagation(),o.show(),o._selectMenuItem(e);return}o._isShown()&&(e.stopPropagation(),o.hide(),i.focus())}}O.on(document,Cm,Wn,It.dataApiKeydownHandler);O.on(document,Cm,no,It.dataApiKeydownHandler);O.on(document,Sm,It.clearMenus);O.on(document,Ew,It.clearMenus);O.on(document,Sm,Wn,function(n){n.preventDefault(),It.getOrCreateInstance(this).toggle()});ct(It);const Rm="backdrop",$w="fade",od="show",ad=`mousedown.bs.${Rm}`,Uw={className:"modal-backdrop",clickCallback:null,isAnimated:!1,isVisible:!0,rootElement:"body"},Bw={className:"string",clickCallback:"(function|null)",isAnimated:"boolean",isVisible:"boolean",rootElement:"(element|string)"};class km extends hi{constructor(e){super(),this._config=this._getConfig(e),this._isAppended=!1,this._element=null}static get Default(){return Uw}static get DefaultType(){return Bw}static get NAME(){return Rm}show(e){if(!this._config.isVisible){Ue(e);return}this._append();const t=this._getElement();this._config.isAnimated&&ui(t),t.classList.add(od),this._emulateAnimation(()=>{Ue(e)})}hide(e){if(!this._config.isVisible){Ue(e);return}this._getElement().classList.remove(od),this._emulateAnimation(()=>{this.dispose(),Ue(e)})}dispose(){this._isAppended&&(O.off(this._element,ad),this._element.remove(),this._isAppended=!1)}_getElement(){if(!this._element){const e=document.createElement("div");e.className=this._config.className,this._config.isAnimated&&e.classList.add($w),this._element=e}return this._element}_configAfterMerge(e){return e.rootElement=wn(e.rootElement),e}_append(){if(this._isAppended)return;const e=this._getElement();this._config.rootElement.append(e),O.on(e,ad,()=>{Ue(this._config.clickCallback)}),this._isAppended=!0}_emulateAnimation(e){pm(e,this._getElement(),this._config.isAnimated)}}const qw="focustrap",jw="bs.focustrap",Eo=`.${jw}`,Hw=`focusin${Eo}`,Ww=`keydown.tab${Eo}`,zw="Tab",Kw="forward",cd="backward",Gw={autofocus:!0,trapElement:null},Yw={autofocus:"boolean",trapElement:"element"};class Pm extends hi{constructor(e){super(),this._config=this._getConfig(e),this._isActive=!1,this._lastTabNavDirection=null}static get Default(){return Gw}static get DefaultType(){return Yw}static get NAME(){return qw}activate(){this._isActive||(this._config.autofocus&&this._config.trapElement.focus(),O.off(document,Eo),O.on(document,Hw,e=>this._handleFocusin(e)),O.on(document,Ww,e=>this._handleKeydown(e)),this._isActive=!0)}deactivate(){this._isActive&&(this._isActive=!1,O.off(document,Eo))}_handleFocusin(e){const{trapElement:t}=this._config;if(e.target===document||e.target===t||t.contains(e.target))return;const r=q.focusableChildren(t);r.length===0?t.focus():this._lastTabNavDirection===cd?r[r.length-1].focus():r[0].focus()}_handleKeydown(e){e.key===zw&&(this._lastTabNavDirection=e.shiftKey?cd:Kw)}}const ld=".fixed-top, .fixed-bottom, .is-fixed, .sticky-top",ud=".sticky-top",ji="padding-right",hd="margin-right";class qc{constructor(){this._element=document.body}getWidth(){const e=document.documentElement.clientWidth;return Math.abs(window.innerWidth-e)}hide(){const e=this.getWidth();this._disableOverFlow(),this._setElementAttributes(this._element,ji,t=>t+e),this._setElementAttributes(ld,ji,t=>t+e),this._setElementAttributes(ud,hd,t=>t-e)}reset(){this._resetElementAttributes(this._element,"overflow"),this._resetElementAttributes(this._element,ji),this._resetElementAttributes(ld,ji),this._resetElementAttributes(ud,hd)}isOverflowing(){return this.getWidth()>0}_disableOverFlow(){this._saveInitialAttribute(this._element,"overflow"),this._element.style.overflow="hidden"}_setElementAttributes(e,t,r){const s=this.getWidth(),i=o=>{if(o!==this._element&&window.innerWidth>o.clientWidth+s)return;this._saveInitialAttribute(o,t);const c=window.getComputedStyle(o).getPropertyValue(t);o.style.setProperty(t,`${r(Number.parseFloat(c))}px`)};this._applyManipulationCallback(e,i)}_saveInitialAttribute(e,t){const r=e.style.getPropertyValue(t);r&&Ht.setDataAttribute(e,t,r)}_resetElementAttributes(e,t){const r=s=>{const i=Ht.getDataAttribute(s,t);if(i===null){s.style.removeProperty(t);return}Ht.removeDataAttribute(s,t),s.style.setProperty(t,i)};this._applyManipulationCallback(e,r)}_applyManipulationCallback(e,t){if(jt(e)){t(e);return}for(const r of q.find(e,this._element))t(r)}}const Qw="modal",Jw="bs.modal",at=`.${Jw}`,Xw=".data-api",Zw="Escape",eb=`hide${at}`,tb=`hidePrevented${at}`,Nm=`hidden${at}`,Dm=`show${at}`,nb=`shown${at}`,rb=`resize${at}`,sb=`click.dismiss${at}`,ib=`mousedown.dismiss${at}`,ob=`keydown.dismiss${at}`,ab=`click${at}${Xw}`,dd="modal-open",cb="fade",fd="show",sc="modal-static",lb=".modal.show",ub=".modal-dialog",hb=".modal-body",db='[data-bs-toggle="modal"]',fb={backdrop:!0,focus:!0,keyboard:!0},pb={backdrop:"(boolean|string)",focus:"boolean",keyboard:"boolean"};class zr extends Et{constructor(e,t){super(e,t),this._dialog=q.findOne(ub,this._element),this._backdrop=this._initializeBackDrop(),this._focustrap=this._initializeFocusTrap(),this._isShown=!1,this._isTransitioning=!1,this._scrollBar=new qc,this._addEventListeners()}static get Default(){return fb}static get DefaultType(){return pb}static get NAME(){return Qw}toggle(e){return this._isShown?this.hide():this.show(e)}show(e){this._isShown||this._isTransitioning||O.trigger(this._element,Dm,{relatedTarget:e}).defaultPrevented||(this._isShown=!0,this._isTransitioning=!0,this._scrollBar.hide(),document.body.classList.add(dd),this._adjustDialog(),this._backdrop.show(()=>this._showElement(e)))}hide(){!this._isShown||this._isTransitioning||O.trigger(this._element,eb).defaultPrevented||(this._isShown=!1,this._isTransitioning=!0,this._focustrap.deactivate(),this._element.classList.remove(fd),this._queueCallback(()=>this._hideModal(),this._element,this._isAnimated()))}dispose(){O.off(window,at),O.off(this._dialog,at),this._backdrop.dispose(),this._focustrap.deactivate(),super.dispose()}handleUpdate(){this._adjustDialog()}_initializeBackDrop(){return new km({isVisible:!!this._config.backdrop,isAnimated:this._isAnimated()})}_initializeFocusTrap(){return new Pm({trapElement:this._element})}_showElement(e){document.body.contains(this._element)||document.body.append(this._element),this._element.style.display="block",this._element.removeAttribute("aria-hidden"),this._element.setAttribute("aria-modal",!0),this._element.setAttribute("role","dialog"),this._element.scrollTop=0;const t=q.findOne(hb,this._dialog);t&&(t.scrollTop=0),ui(this._element),this._element.classList.add(fd);const r=()=>{this._config.focus&&this._focustrap.activate(),this._isTransitioning=!1,O.trigger(this._element,nb,{relatedTarget:e})};this._queueCallback(r,this._dialog,this._isAnimated())}_addEventListeners(){O.on(this._element,ob,e=>{if(e.key===Zw){if(this._config.keyboard){this.hide();return}this._triggerBackdropTransition()}}),O.on(window,rb,()=>{this._isShown&&!this._isTransitioning&&this._adjustDialog()}),O.on(this._element,ib,e=>{O.one(this._element,sb,t=>{if(!(this._element!==e.target||this._element!==t.target)){if(this._config.backdrop==="static"){this._triggerBackdropTransition();return}this._config.backdrop&&this.hide()}})})}_hideModal(){this._element.style.display="none",this._element.setAttribute("aria-hidden",!0),this._element.removeAttribute("aria-modal"),this._element.removeAttribute("role"),this._isTransitioning=!1,this._backdrop.hide(()=>{document.body.classList.remove(dd),this._resetAdjustments(),this._scrollBar.reset(),O.trigger(this._element,Nm)})}_isAnimated(){return this._element.classList.contains(cb)}_triggerBackdropTransition(){if(O.trigger(this._element,tb).defaultPrevented)return;const t=this._element.scrollHeight>document.documentElement.clientHeight,r=this._element.style.overflowY;r==="hidden"||this._element.classList.contains(sc)||(t||(this._element.style.overflowY="hidden"),this._element.classList.add(sc),this._queueCallback(()=>{this._element.classList.remove(sc),this._queueCallback(()=>{this._element.style.overflowY=r},this._dialog)},this._dialog),this._element.focus())}_adjustDialog(){const e=this._element.scrollHeight>document.documentElement.clientHeight,t=this._scrollBar.getWidth(),r=t>0;if(r&&!e){const s=ot()?"paddingLeft":"paddingRight";this._element.style[s]=`${t}px`}if(!r&&e){const s=ot()?"paddingRight":"paddingLeft";this._element.style[s]=`${t}px`}}_resetAdjustments(){this._element.style.paddingLeft="",this._element.style.paddingRight=""}static jQueryInterface(e,t){return this.each(function(){const r=zr.getOrCreateInstance(this,e);if(typeof e=="string"){if(typeof r[e]>"u")throw new TypeError(`No method named "${e}"`);r[e](t)}})}}O.on(document,ab,db,function(n){const e=q.getElementFromSelector(this);["A","AREA"].includes(this.tagName)&&n.preventDefault(),O.one(e,Dm,s=>{s.defaultPrevented||O.one(e,Nm,()=>{rs(this)&&this.focus()})});const t=q.findOne(lb);t&&zr.getInstance(t).hide(),zr.getOrCreateInstance(e).toggle(this)});ea(zr);ct(zr);const mb="offcanvas",gb="bs.offcanvas",Zt=`.${gb}`,Om=".data-api",_b=`load${Zt}${Om}`,yb="Escape",pd="show",md="showing",gd="hiding",Eb="offcanvas-backdrop",Vm=".offcanvas.show",vb=`show${Zt}`,Tb=`shown${Zt}`,wb=`hide${Zt}`,_d=`hidePrevented${Zt}`,Lm=`hidden${Zt}`,bb=`resize${Zt}`,Ab=`click${Zt}${Om}`,Ib=`keydown.dismiss${Zt}`,Sb='[data-bs-toggle="offcanvas"]',Cb={backdrop:!0,keyboard:!0,scroll:!1},Rb={backdrop:"(boolean|string)",keyboard:"boolean",scroll:"boolean"};class Gt extends Et{constructor(e,t){super(e,t),this._isShown=!1,this._backdrop=this._initializeBackDrop(),this._focustrap=this._initializeFocusTrap(),this._addEventListeners()}static get Default(){return Cb}static get DefaultType(){return Rb}static get NAME(){return mb}toggle(e){return this._isShown?this.hide():this.show(e)}show(e){if(this._isShown||O.trigger(this._element,vb,{relatedTarget:e}).defaultPrevented)return;this._isShown=!0,this._backdrop.show(),this._config.scroll||new qc().hide(),this._element.setAttribute("aria-modal",!0),this._element.setAttribute("role","dialog"),this._element.classList.add(md);const r=()=>{(!this._config.scroll||this._config.backdrop)&&this._focustrap.activate(),this._element.classList.add(pd),this._element.classList.remove(md),O.trigger(this._element,Tb,{relatedTarget:e})};this._queueCallback(r,this._element,!0)}hide(){if(!this._isShown||O.trigger(this._element,wb).defaultPrevented)return;this._focustrap.deactivate(),this._element.blur(),this._isShown=!1,this._element.classList.add(gd),this._backdrop.hide();const t=()=>{this._element.classList.remove(pd,gd),this._element.removeAttribute("aria-modal"),this._element.removeAttribute("role"),this._config.scroll||new qc().reset(),O.trigger(this._element,Lm)};this._queueCallback(t,this._element,!0)}dispose(){this._backdrop.dispose(),this._focustrap.deactivate(),super.dispose()}_initializeBackDrop(){const e=()=>{if(this._config.backdrop==="static"){O.trigger(this._element,_d);return}this.hide()},t=!!this._config.backdrop;return new km({className:Eb,isVisible:t,isAnimated:!0,rootElement:this._element.parentNode,clickCallback:t?e:null})}_initializeFocusTrap(){return new Pm({trapElement:this._element})}_addEventListeners(){O.on(this._element,Ib,e=>{if(e.key===yb){if(this._config.keyboard){this.hide();return}O.trigger(this._element,_d)}})}static jQueryInterface(e){return this.each(function(){const t=Gt.getOrCreateInstance(this,e);if(typeof e=="string"){if(t[e]===void 0||e.startsWith("_")||e==="constructor")throw new TypeError(`No method named "${e}"`);t[e](this)}})}}O.on(document,Ab,Sb,function(n){const e=q.getElementFromSelector(this);if(["A","AREA"].includes(this.tagName)&&n.preventDefault(),bn(this))return;O.one(e,Lm,()=>{rs(this)&&this.focus()});const t=q.findOne(Vm);t&&t!==e&&Gt.getInstance(t).hide(),Gt.getOrCreateInstance(e).toggle(this)});O.on(window,_b,()=>{for(const n of q.find(Vm))Gt.getOrCreateInstance(n).show()});O.on(window,bb,()=>{for(const n of q.find("[aria-modal][class*=show][class*=offcanvas-]"))getComputedStyle(n).position!=="fixed"&&Gt.getOrCreateInstance(n).hide()});ea(Gt);ct(Gt);const kb=/^aria-[\w-]*$/i,Mm={"*":["class","dir","id","lang","role",kb],a:["target","href","title","rel"],area:[],b:[],br:[],col:[],code:[],dd:[],div:[],dl:[],dt:[],em:[],hr:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],i:[],img:["src","srcset","alt","title","width","height"],li:[],ol:[],p:[],pre:[],s:[],small:[],span:[],sub:[],sup:[],strong:[],u:[],ul:[]},Pb=new Set(["background","cite","href","itemtype","longdesc","poster","src","xlink:href"]),Nb=/^(?!javascript:)(?:[a-z0-9+.-]+:|[^&:/?#]*(?:[/?#]|$))/i,Db=(n,e)=>{const t=n.nodeName.toLowerCase();return e.includes(t)?Pb.has(t)?!!Nb.test(n.nodeValue):!0:e.filter(r=>r instanceof RegExp).some(r=>r.test(t))};function Ob(n,e,t){if(!n.length)return n;if(t&&typeof t=="function")return t(n);const s=new window.DOMParser().parseFromString(n,"text/html"),i=[].concat(...s.body.querySelectorAll("*"));for(const o of i){const c=o.nodeName.toLowerCase();if(!Object.keys(e).includes(c)){o.remove();continue}const l=[].concat(...o.attributes),h=[].concat(e["*"]||[],e[c]||[]);for(const f of l)Db(f,h)||o.removeAttribute(f.nodeName)}return s.body.innerHTML}const Vb="TemplateFactory",Lb={allowList:Mm,content:{},extraClass:"",html:!1,sanitize:!0,sanitizeFn:null,template:"<div></div>"},Mb={allowList:"object",content:"object",extraClass:"(string|function)",html:"boolean",sanitize:"boolean",sanitizeFn:"(null|function)",template:"string"},xb={entry:"(string|element|function|null)",selector:"(string|element)"};class Fb extends hi{constructor(e){super(),this._config=this._getConfig(e)}static get Default(){return Lb}static get DefaultType(){return Mb}static get NAME(){return Vb}getContent(){return Object.values(this._config.content).map(e=>this._resolvePossibleFunction(e)).filter(Boolean)}hasContent(){return this.getContent().length>0}changeContent(e){return this._checkContent(e),this._config.content={...this._config.content,...e},this}toHtml(){const e=document.createElement("div");e.innerHTML=this._maybeSanitize(this._config.template);for(const[s,i]of Object.entries(this._config.content))this._setContent(e,i,s);const t=e.children[0],r=this._resolvePossibleFunction(this._config.extraClass);return r&&t.classList.add(...r.split(" ")),t}_typeCheckConfig(e){super._typeCheckConfig(e),this._checkContent(e.content)}_checkContent(e){for(const[t,r]of Object.entries(e))super._typeCheckConfig({selector:t,entry:r},xb)}_setContent(e,t,r){const s=q.findOne(r,e);if(s){if(t=this._resolvePossibleFunction(t),!t){s.remove();return}if(jt(t)){this._putElementInTemplate(wn(t),s);return}if(this._config.html){s.innerHTML=this._maybeSanitize(t);return}s.textContent=t}}_maybeSanitize(e){return this._config.sanitize?Ob(e,this._config.allowList,this._config.sanitizeFn):e}_resolvePossibleFunction(e){return Ue(e,[void 0,this])}_putElementInTemplate(e,t){if(this._config.html){t.innerHTML="",t.append(e);return}t.textContent=e.textContent}}const $b="tooltip",Ub=new Set(["sanitize","allowList","sanitizeFn"]),ic="fade",Bb="modal",Hi="show",qb=".tooltip-inner",yd=`.${Bb}`,Ed="hide.bs.modal",Vs="hover",oc="focus",ac="click",jb="manual",Hb="hide",Wb="hidden",zb="show",Kb="shown",Gb="inserted",Yb="click",Qb="focusin",Jb="focusout",Xb="mouseenter",Zb="mouseleave",eA={AUTO:"auto",TOP:"top",RIGHT:ot()?"left":"right",BOTTOM:"bottom",LEFT:ot()?"right":"left"},tA={allowList:Mm,animation:!0,boundary:"clippingParents",container:!1,customClass:"",delay:0,fallbackPlacements:["top","right","bottom","left"],html:!1,offset:[0,6],placement:"top",popperConfig:null,sanitize:!0,sanitizeFn:null,selector:!1,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',title:"",trigger:"hover focus"},nA={allowList:"object",animation:"boolean",boundary:"(string|element)",container:"(string|element|boolean)",customClass:"(string|function)",delay:"(number|object)",fallbackPlacements:"array",html:"boolean",offset:"(array|string|function)",placement:"(string|function)",popperConfig:"(null|object|function)",sanitize:"boolean",sanitizeFn:"(null|function)",selector:"(string|boolean)",template:"string",title:"(string|element|function)",trigger:"string"};class is extends Et{constructor(e,t){if(typeof lm>"u")throw new TypeError("Bootstrap's tooltips require Popper (https://popper.js.org/docs/v2/)");super(e,t),this._isEnabled=!0,this._timeout=0,this._isHovered=null,this._activeTrigger={},this._popper=null,this._templateFactory=null,this._newContent=null,this.tip=null,this._setListeners(),this._config.selector||this._fixTitle()}static get Default(){return tA}static get DefaultType(){return nA}static get NAME(){return $b}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}toggleEnabled(){this._isEnabled=!this._isEnabled}toggle(){if(this._isEnabled){if(this._isShown()){this._leave();return}this._enter()}}dispose(){clearTimeout(this._timeout),O.off(this._element.closest(yd),Ed,this._hideModalHandler),this._element.getAttribute("data-bs-original-title")&&this._element.setAttribute("title",this._element.getAttribute("data-bs-original-title")),this._disposePopper(),super.dispose()}show(){if(this._element.style.display==="none")throw new Error("Please use show on visible elements");if(!(this._isWithContent()&&this._isEnabled))return;const e=O.trigger(this._element,this.constructor.eventName(zb)),r=(dm(this._element)||this._element.ownerDocument.documentElement).contains(this._element);if(e.defaultPrevented||!r)return;this._disposePopper();const s=this._getTipElement();this._element.setAttribute("aria-describedby",s.getAttribute("id"));const{container:i}=this._config;if(this._element.ownerDocument.documentElement.contains(this.tip)||(i.append(s),O.trigger(this._element,this.constructor.eventName(Gb))),this._popper=this._createPopper(s),s.classList.add(Hi),"ontouchstart"in document.documentElement)for(const c of[].concat(...document.body.children))O.on(c,"mouseover",_o);const o=()=>{O.trigger(this._element,this.constructor.eventName(Kb)),this._isHovered===!1&&this._leave(),this._isHovered=!1};this._queueCallback(o,this.tip,this._isAnimated())}hide(){if(!this._isShown()||O.trigger(this._element,this.constructor.eventName(Hb)).defaultPrevented)return;if(this._getTipElement().classList.remove(Hi),"ontouchstart"in document.documentElement)for(const s of[].concat(...document.body.children))O.off(s,"mouseover",_o);this._activeTrigger[ac]=!1,this._activeTrigger[oc]=!1,this._activeTrigger[Vs]=!1,this._isHovered=null;const r=()=>{this._isWithActiveTrigger()||(this._isHovered||this._disposePopper(),this._element.removeAttribute("aria-describedby"),O.trigger(this._element,this.constructor.eventName(Wb)))};this._queueCallback(r,this.tip,this._isAnimated())}update(){this._popper&&this._popper.update()}_isWithContent(){return!!this._getTitle()}_getTipElement(){return this.tip||(this.tip=this._createTipElement(this._newContent||this._getContentForTemplate())),this.tip}_createTipElement(e){const t=this._getTemplateFactory(e).toHtml();if(!t)return null;t.classList.remove(ic,Hi),t.classList.add(`bs-${this.constructor.NAME}-auto`);const r=jv(this.constructor.NAME).toString();return t.setAttribute("id",r),this._isAnimated()&&t.classList.add(ic),t}setContent(e){this._newContent=e,this._isShown()&&(this._disposePopper(),this.show())}_getTemplateFactory(e){return this._templateFactory?this._templateFactory.changeContent(e):this._templateFactory=new Fb({...this._config,content:e,extraClass:this._resolvePossibleFunction(this._config.customClass)}),this._templateFactory}_getContentForTemplate(){return{[qb]:this._getTitle()}}_getTitle(){return this._resolvePossibleFunction(this._config.title)||this._element.getAttribute("data-bs-original-title")}_initializeOnDelegatedTarget(e){return this.constructor.getOrCreateInstance(e.delegateTarget,this._getDelegateConfig())}_isAnimated(){return this._config.animation||this.tip&&this.tip.classList.contains(ic)}_isShown(){return this.tip&&this.tip.classList.contains(Hi)}_createPopper(e){const t=Ue(this._config.placement,[this,e,this._element]),r=eA[t.toUpperCase()];return Vl(this._element,e,this._getPopperConfig(r))}_getOffset(){const{offset:e}=this._config;return typeof e=="string"?e.split(",").map(t=>Number.parseInt(t,10)):typeof e=="function"?t=>e(t,this._element):e}_resolvePossibleFunction(e){return Ue(e,[this._element,this._element])}_getPopperConfig(e){const t={placement:e,modifiers:[{name:"flip",options:{fallbackPlacements:this._config.fallbackPlacements}},{name:"offset",options:{offset:this._getOffset()}},{name:"preventOverflow",options:{boundary:this._config.boundary}},{name:"arrow",options:{element:`.${this.constructor.NAME}-arrow`}},{name:"preSetPlacement",enabled:!0,phase:"beforeMain",fn:r=>{this._getTipElement().setAttribute("data-popper-placement",r.state.placement)}}]};return{...t,...Ue(this._config.popperConfig,[void 0,t])}}_setListeners(){const e=this._config.trigger.split(" ");for(const t of e)if(t==="click")O.on(this._element,this.constructor.eventName(Yb),this._config.selector,r=>{const s=this._initializeOnDelegatedTarget(r);s._activeTrigger[ac]=!(s._isShown()&&s._activeTrigger[ac]),s.toggle()});else if(t!==jb){const r=t===Vs?this.constructor.eventName(Xb):this.constructor.eventName(Qb),s=t===Vs?this.constructor.eventName(Zb):this.constructor.eventName(Jb);O.on(this._element,r,this._config.selector,i=>{const o=this._initializeOnDelegatedTarget(i);o._activeTrigger[i.type==="focusin"?oc:Vs]=!0,o._enter()}),O.on(this._element,s,this._config.selector,i=>{const o=this._initializeOnDelegatedTarget(i);o._activeTrigger[i.type==="focusout"?oc:Vs]=o._element.contains(i.relatedTarget),o._leave()})}this._hideModalHandler=()=>{this._element&&this.hide()},O.on(this._element.closest(yd),Ed,this._hideModalHandler)}_fixTitle(){const e=this._element.getAttribute("title");e&&(!this._element.getAttribute("aria-label")&&!this._element.textContent.trim()&&this._element.setAttribute("aria-label",e),this._element.setAttribute("data-bs-original-title",e),this._element.removeAttribute("title"))}_enter(){if(this._isShown()||this._isHovered){this._isHovered=!0;return}this._isHovered=!0,this._setTimeout(()=>{this._isHovered&&this.show()},this._config.delay.show)}_leave(){this._isWithActiveTrigger()||(this._isHovered=!1,this._setTimeout(()=>{this._isHovered||this.hide()},this._config.delay.hide))}_setTimeout(e,t){clearTimeout(this._timeout),this._timeout=setTimeout(e,t)}_isWithActiveTrigger(){return Object.values(this._activeTrigger).includes(!0)}_getConfig(e){const t=Ht.getDataAttributes(this._element);for(const r of Object.keys(t))Ub.has(r)&&delete t[r];return e={...t,...typeof e=="object"&&e?e:{}},e=this._mergeConfigObj(e),e=this._configAfterMerge(e),this._typeCheckConfig(e),e}_configAfterMerge(e){return e.container=e.container===!1?document.body:wn(e.container),typeof e.delay=="number"&&(e.delay={show:e.delay,hide:e.delay}),typeof e.title=="number"&&(e.title=e.title.toString()),typeof e.content=="number"&&(e.content=e.content.toString()),e}_getDelegateConfig(){const e={};for(const[t,r]of Object.entries(this._config))this.constructor.Default[t]!==r&&(e[t]=r);return e.selector=!1,e.trigger="manual",e}_disposePopper(){this._popper&&(this._popper.destroy(),this._popper=null),this.tip&&(this.tip.remove(),this.tip=null)}static jQueryInterface(e){return this.each(function(){const t=is.getOrCreateInstance(this,e);if(typeof e=="string"){if(typeof t[e]>"u")throw new TypeError(`No method named "${e}"`);t[e]()}})}}ct(is);const rA="popover",sA=".popover-header",iA=".popover-body",oA={...is.Default,content:"",offset:[0,8],placement:"right",template:'<div class="popover" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>',trigger:"click"},aA={...is.DefaultType,content:"(null|string|element|function)"};class Fl extends is{static get Default(){return oA}static get DefaultType(){return aA}static get NAME(){return rA}_isWithContent(){return this._getTitle()||this._getContent()}_getContentForTemplate(){return{[sA]:this._getTitle(),[iA]:this._getContent()}}_getContent(){return this._resolvePossibleFunction(this._config.content)}static jQueryInterface(e){return this.each(function(){const t=Fl.getOrCreateInstance(this,e);if(typeof e=="string"){if(typeof t[e]>"u")throw new TypeError(`No method named "${e}"`);t[e]()}})}}ct(Fl);const cA="scrollspy",lA="bs.scrollspy",$l=`.${lA}`,uA=".data-api",hA=`activate${$l}`,vd=`click${$l}`,dA=`load${$l}${uA}`,fA="dropdown-item",Sr="active",pA='[data-bs-spy="scroll"]',cc="[href]",mA=".nav, .list-group",Td=".nav-link",gA=".nav-item",_A=".list-group-item",yA=`${Td}, ${gA} > ${Td}, ${_A}`,EA=".dropdown",vA=".dropdown-toggle",TA={offset:null,rootMargin:"0px 0px -25%",smoothScroll:!1,target:null,threshold:[.1,.5,1]},wA={offset:"(number|null)",rootMargin:"string",smoothScroll:"boolean",target:"element",threshold:"array"};class ra extends Et{constructor(e,t){super(e,t),this._targetLinks=new Map,this._observableSections=new Map,this._rootElement=getComputedStyle(this._element).overflowY==="visible"?null:this._element,this._activeTarget=null,this._observer=null,this._previousScrollData={visibleEntryTop:0,parentScrollTop:0},this.refresh()}static get Default(){return TA}static get DefaultType(){return wA}static get NAME(){return cA}refresh(){this._initializeTargetsAndObservables(),this._maybeEnableSmoothScroll(),this._observer?this._observer.disconnect():this._observer=this._getNewObserver();for(const e of this._observableSections.values())this._observer.observe(e)}dispose(){this._observer.disconnect(),super.dispose()}_configAfterMerge(e){return e.target=wn(e.target)||document.body,e.rootMargin=e.offset?`${e.offset}px 0px -30%`:e.rootMargin,typeof e.threshold=="string"&&(e.threshold=e.threshold.split(",").map(t=>Number.parseFloat(t))),e}_maybeEnableSmoothScroll(){this._config.smoothScroll&&(O.off(this._config.target,vd),O.on(this._config.target,vd,cc,e=>{const t=this._observableSections.get(e.target.hash);if(t){e.preventDefault();const r=this._rootElement||window,s=t.offsetTop-this._element.offsetTop;if(r.scrollTo){r.scrollTo({top:s,behavior:"smooth"});return}r.scrollTop=s}}))}_getNewObserver(){const e={root:this._rootElement,threshold:this._config.threshold,rootMargin:this._config.rootMargin};return new IntersectionObserver(t=>this._observerCallback(t),e)}_observerCallback(e){const t=o=>this._targetLinks.get(`#${o.target.id}`),r=o=>{this._previousScrollData.visibleEntryTop=o.target.offsetTop,this._process(t(o))},s=(this._rootElement||document.documentElement).scrollTop,i=s>=this._previousScrollData.parentScrollTop;this._previousScrollData.parentScrollTop=s;for(const o of e){if(!o.isIntersecting){this._activeTarget=null,this._clearActiveClass(t(o));continue}const c=o.target.offsetTop>=this._previousScrollData.visibleEntryTop;if(i&&c){if(r(o),!s)return;continue}!i&&!c&&r(o)}}_initializeTargetsAndObservables(){this._targetLinks=new Map,this._observableSections=new Map;const e=q.find(cc,this._config.target);for(const t of e){if(!t.hash||bn(t))continue;const r=q.findOne(decodeURI(t.hash),this._element);rs(r)&&(this._targetLinks.set(decodeURI(t.hash),t),this._observableSections.set(t.hash,r))}}_process(e){this._activeTarget!==e&&(this._clearActiveClass(this._config.target),this._activeTarget=e,e.classList.add(Sr),this._activateParents(e),O.trigger(this._element,hA,{relatedTarget:e}))}_activateParents(e){if(e.classList.contains(fA)){q.findOne(vA,e.closest(EA)).classList.add(Sr);return}for(const t of q.parents(e,mA))for(const r of q.prev(t,yA))r.classList.add(Sr)}_clearActiveClass(e){e.classList.remove(Sr);const t=q.find(`${cc}.${Sr}`,e);for(const r of t)r.classList.remove(Sr)}static jQueryInterface(e){return this.each(function(){const t=ra.getOrCreateInstance(this,e);if(typeof e=="string"){if(t[e]===void 0||e.startsWith("_")||e==="constructor")throw new TypeError(`No method named "${e}"`);t[e]()}})}}O.on(window,dA,()=>{for(const n of q.find(pA))ra.getOrCreateInstance(n)});ct(ra);const bA="tab",AA="bs.tab",hr=`.${AA}`,IA=`hide${hr}`,SA=`hidden${hr}`,CA=`show${hr}`,RA=`shown${hr}`,kA=`click${hr}`,PA=`keydown${hr}`,NA=`load${hr}`,DA="ArrowLeft",wd="ArrowRight",OA="ArrowUp",bd="ArrowDown",lc="Home",Ad="End",zn="active",Id="fade",uc="show",VA="dropdown",xm=".dropdown-toggle",LA=".dropdown-menu",hc=`:not(${xm})`,MA='.list-group, .nav, [role="tablist"]',xA=".nav-item, .list-group-item",FA=`.nav-link${hc}, .list-group-item${hc}, [role="tab"]${hc}`,Fm='[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]',dc=`${FA}, ${Fm}`,$A=`.${zn}[data-bs-toggle="tab"], .${zn}[data-bs-toggle="pill"], .${zn}[data-bs-toggle="list"]`;class Kr extends Et{constructor(e){super(e),this._parent=this._element.closest(MA),this._parent&&(this._setInitialAttributes(this._parent,this._getChildren()),O.on(this._element,PA,t=>this._keydown(t)))}static get NAME(){return bA}show(){const e=this._element;if(this._elemIsActive(e))return;const t=this._getActiveElem(),r=t?O.trigger(t,IA,{relatedTarget:e}):null;O.trigger(e,CA,{relatedTarget:t}).defaultPrevented||r&&r.defaultPrevented||(this._deactivate(t,e),this._activate(e,t))}_activate(e,t){if(!e)return;e.classList.add(zn),this._activate(q.getElementFromSelector(e));const r=()=>{if(e.getAttribute("role")!=="tab"){e.classList.add(uc);return}e.removeAttribute("tabindex"),e.setAttribute("aria-selected",!0),this._toggleDropDown(e,!0),O.trigger(e,RA,{relatedTarget:t})};this._queueCallback(r,e,e.classList.contains(Id))}_deactivate(e,t){if(!e)return;e.classList.remove(zn),e.blur(),this._deactivate(q.getElementFromSelector(e));const r=()=>{if(e.getAttribute("role")!=="tab"){e.classList.remove(uc);return}e.setAttribute("aria-selected",!1),e.setAttribute("tabindex","-1"),this._toggleDropDown(e,!1),O.trigger(e,SA,{relatedTarget:t})};this._queueCallback(r,e,e.classList.contains(Id))}_keydown(e){if(![DA,wd,OA,bd,lc,Ad].includes(e.key))return;e.stopPropagation(),e.preventDefault();const t=this._getChildren().filter(s=>!bn(s));let r;if([lc,Ad].includes(e.key))r=t[e.key===lc?0:t.length-1];else{const s=[wd,bd].includes(e.key);r=Ll(t,e.target,s,!0)}r&&(r.focus({preventScroll:!0}),Kr.getOrCreateInstance(r).show())}_getChildren(){return q.find(dc,this._parent)}_getActiveElem(){return this._getChildren().find(e=>this._elemIsActive(e))||null}_setInitialAttributes(e,t){this._setAttributeIfNotExists(e,"role","tablist");for(const r of t)this._setInitialAttributesOnChild(r)}_setInitialAttributesOnChild(e){e=this._getInnerElement(e);const t=this._elemIsActive(e),r=this._getOuterElement(e);e.setAttribute("aria-selected",t),r!==e&&this._setAttributeIfNotExists(r,"role","presentation"),t||e.setAttribute("tabindex","-1"),this._setAttributeIfNotExists(e,"role","tab"),this._setInitialAttributesOnTargetPanel(e)}_setInitialAttributesOnTargetPanel(e){const t=q.getElementFromSelector(e);t&&(this._setAttributeIfNotExists(t,"role","tabpanel"),e.id&&this._setAttributeIfNotExists(t,"aria-labelledby",`${e.id}`))}_toggleDropDown(e,t){const r=this._getOuterElement(e);if(!r.classList.contains(VA))return;const s=(i,o)=>{const c=q.findOne(i,r);c&&c.classList.toggle(o,t)};s(xm,zn),s(LA,uc),r.setAttribute("aria-expanded",t)}_setAttributeIfNotExists(e,t,r){e.hasAttribute(t)||e.setAttribute(t,r)}_elemIsActive(e){return e.classList.contains(zn)}_getInnerElement(e){return e.matches(dc)?e:q.findOne(dc,e)}_getOuterElement(e){return e.closest(xA)||e}static jQueryInterface(e){return this.each(function(){const t=Kr.getOrCreateInstance(this);if(typeof e=="string"){if(t[e]===void 0||e.startsWith("_")||e==="constructor")throw new TypeError(`No method named "${e}"`);t[e]()}})}}O.on(document,kA,Fm,function(n){["A","AREA"].includes(this.tagName)&&n.preventDefault(),!bn(this)&&Kr.getOrCreateInstance(this).show()});O.on(window,NA,()=>{for(const n of q.find($A))Kr.getOrCreateInstance(n)});ct(Kr);const UA="toast",BA="bs.toast",Vn=`.${BA}`,qA=`mouseover${Vn}`,jA=`mouseout${Vn}`,HA=`focusin${Vn}`,WA=`focusout${Vn}`,zA=`hide${Vn}`,KA=`hidden${Vn}`,GA=`show${Vn}`,YA=`shown${Vn}`,QA="fade",Sd="hide",Wi="show",zi="showing",JA={animation:"boolean",autohide:"boolean",delay:"number"},XA={animation:!0,autohide:!0,delay:5e3};class sa extends Et{constructor(e,t){super(e,t),this._timeout=null,this._hasMouseInteraction=!1,this._hasKeyboardInteraction=!1,this._setListeners()}static get Default(){return XA}static get DefaultType(){return JA}static get NAME(){return UA}show(){if(O.trigger(this._element,GA).defaultPrevented)return;this._clearTimeout(),this._config.animation&&this._element.classList.add(QA);const t=()=>{this._element.classList.remove(zi),O.trigger(this._element,YA),this._maybeScheduleHide()};this._element.classList.remove(Sd),ui(this._element),this._element.classList.add(Wi,zi),this._queueCallback(t,this._element,this._config.animation)}hide(){if(!this.isShown()||O.trigger(this._element,zA).defaultPrevented)return;const t=()=>{this._element.classList.add(Sd),this._element.classList.remove(zi,Wi),O.trigger(this._element,KA)};this._element.classList.add(zi),this._queueCallback(t,this._element,this._config.animation)}dispose(){this._clearTimeout(),this.isShown()&&this._element.classList.remove(Wi),super.dispose()}isShown(){return this._element.classList.contains(Wi)}_maybeScheduleHide(){this._config.autohide&&(this._hasMouseInteraction||this._hasKeyboardInteraction||(this._timeout=setTimeout(()=>{this.hide()},this._config.delay)))}_onInteraction(e,t){switch(e.type){case"mouseover":case"mouseout":{this._hasMouseInteraction=t;break}case"focusin":case"focusout":{this._hasKeyboardInteraction=t;break}}if(t){this._clearTimeout();return}const r=e.relatedTarget;this._element===r||this._element.contains(r)||this._maybeScheduleHide()}_setListeners(){O.on(this._element,qA,e=>this._onInteraction(e,!0)),O.on(this._element,jA,e=>this._onInteraction(e,!1)),O.on(this._element,HA,e=>this._onInteraction(e,!0)),O.on(this._element,WA,e=>this._onInteraction(e,!1))}_clearTimeout(){clearTimeout(this._timeout),this._timeout=null}static jQueryInterface(e){return this.each(function(){const t=sa.getOrCreateInstance(this,e);if(typeof e=="string"){if(typeof t[e]>"u")throw new TypeError(`No method named "${e}"`);t[e](this)}})}}ea(sa);ct(sa);const ZA=["id","aria-labelledby"],eI={class:"offcanvas-header"},tI=["id"],nI={key:1},rI={class:"offcanvas-body p-2"},Ul=p.defineComponent({__name:"Offcanvas",props:{modelValue:{type:Boolean,required:!0},header:{type:Object,required:!1},id:{type:String,requred:!1}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,r=e,s=p.ref(null);let i=null;const o=p.computed(()=>t.id??"offcanvas-wrapper"),c=p.computed(()=>`${o.value}-label`);function l(g){return typeof g=="function"||typeof g=="object"&&!("title"in g)}function h(){i&&i.show()}function f(){i&&i.hide()}return p.onMounted(()=>{s.value&&(i=Gt.getOrCreateInstance(s.value),s.value.addEventListener("hidden.bs.offcanvas",()=>{t.modelValue&&r("update:modelValue",!1)}))}),p.onBeforeUnmount(()=>{i?.dispose(),i=null}),p.watch(()=>t.modelValue,g=>{g?h():f()},{immediate:!0}),(g,_)=>(p.openBlock(),p.createElementBlock("div",{ref_key:"offcanvasEl",ref:s,id:o.value,class:"offcanvas offcanvas-start d-lg-none",tabindex:"-1","aria-labelledby":c.value},[p.createElementVNode("div",eI,[p.createElementVNode("h5",{class:"offcanvas-title",id:c.value},[l(n.header)?(p.openBlock(),p.createBlock(p.resolveDynamicComponent(n.header),{key:0})):(p.openBlock(),p.createElementBlock("span",nI,p.toDisplayString(n.header?.title),1))],8,tI),_[0]||(_[0]=p.createElementVNode("button",{type:"button",class:"btn-close","data-bs-dismiss":"offcanvas","aria-label":"Close"},null,-1))]),p.createElementVNode("div",rI,[p.renderSlot(g.$slots,"default")])],8,ZA))}}),sI={class:"container-fluid"},iI={class:"row justify-content-center g-3 my-3"},oI={class:"col-12 col-md-4 col-lg-3"},aI={class:"border rounded p-3 text-center shadow-sm h-100"},cI={class:"d-flex justify-content-center align-items-center gap-2"},lI={class:"fw-bold"},uI={class:"col-12 col-md-4 col-lg-3"},hI={class:"border rounded p-3 text-center shadow-sm h-100"},dI={class:"d-flex justify-content-center align-items-center gap-2"},fI={class:"fw-bold"},pI={class:"col-12 col-md-4 col-lg-3"},mI={class:"border rounded p-3 text-center shadow-sm h-100"},gI={class:"d-flex justify-content-center align-items-center gap-2"},_I={class:"fw-bold"},yI={class:"w-100"},$m=p.defineComponent({__name:"ObjectDataViewer",props:{obj:{}},setup(n){const e=p.ref(6),t=p.ref(80),r=p.ref(50);function s(c){return!!c&&typeof c=="object"&&(typeof c.path=="string"||typeof c.id=="string")&&("firestore"in c||"parent"in c)}function i(c){if(!c||typeof c!="object")return"[Ref]";const l=typeof c.path=="string"?c.path:void 0,h=typeof c.id=="string"?c.id:void 0;return`[Ref${l?` ${l}`:h?` ${h}`:""}]`}function o(c,l){const{maxDepth:h,maxKeys:f,maxArray:g}=l,_=new WeakSet;function T(C,P,k){if(C==null)return C;const L=typeof C;if(L==="string"||L==="number"||L==="boolean")return C;if(L==="bigint")return C.toString();if(L==="function")return"[Function]";if(L==="symbol")return C.toString();if(k&&k==="ref")return"[Ref]";if(s(C))return i(C);if(P>=h)return"[MaxDepth]";if(typeof C=="object"){if(_.has(C))return"[Circular]";_.add(C)}if(Array.isArray(C)){const j=C.slice(0,g).map(H=>T(H,P+1));return C.length>g&&j.push(`[... +${C.length-g} more]`),j}if(C instanceof Date)return C.toISOString();const $=Object.keys(C),U=$.slice(0,f),F={};for(const j of U)F[j]=T(C[j],P+1,j);return $.length>f&&(F.__truncatedKeys=`+${$.length-f} more keys`),F}try{return JSON.stringify(T(c,0),null,2)}catch{return"[unstringifiable]"}}return(c,l)=>(p.openBlock(),p.createElementBlock(p.Fragment,null,[p.createElementVNode("div",sI,[p.createElementVNode("div",iI,[p.createElementVNode("div",oI,[p.createElementVNode("div",aI,[l[6]||(l[6]=p.createElementVNode("div",{class:"fw-semibold mb-2"},"Max Depth",-1)),p.createElementVNode("div",cI,[p.createVNode(ze,{icon:"minimize",onClick:l[0]||(l[0]=()=>e.value--)}),p.createElementVNode("span",lI,p.toDisplayString(e.value),1),p.createVNode(ze,{icon:"add",onClick:l[1]||(l[1]=()=>e.value++)})])])]),p.createElementVNode("div",uI,[p.createElementVNode("div",hI,[l[7]||(l[7]=p.createElementVNode("div",{class:"fw-semibold mb-2"},"Max Keys",-1)),p.createElementVNode("div",dI,[p.createVNode(ze,{icon:"minimize",onClick:l[2]||(l[2]=()=>t.value--)}),p.createElementVNode("span",fI,p.toDisplayString(t.value),1),p.createVNode(ze,{icon:"add",onClick:l[3]||(l[3]=()=>t.value++)})])])]),p.createElementVNode("div",pI,[p.createElementVNode("div",mI,[l[8]||(l[8]=p.createElementVNode("div",{class:"fw-semibold mb-2"},"Max Array",-1)),p.createElementVNode("div",gI,[p.createVNode(ze,{icon:"minimize",onClick:l[4]||(l[4]=()=>r.value--)}),p.createElementVNode("span",_I,p.toDisplayString(r.value),1),p.createVNode(ze,{icon:"add",onClick:l[5]||(l[5]=()=>r.value++)})])])])])]),p.createElementVNode("pre",yI,p.toDisplayString(o(n.obj,{maxDepth:e.value,maxKeys:t.value,maxArray:r.value})),1)],64))}}),EI={class:"container pb-t overflow-auto h-100"},vI={class:"row justify-content-center"},TI={class:"col-6 col-md-5 col-lg-4"},wI={class:"col-6 col-md-5 col-lg-4 d-flex align-items-end justify-content-end"},bI={key:0,class:"mb--2 text-secondary"},AI={class:"col-12 col-md-10 col-lg-8 mt-2"},II={class:"card shadow-sm"},Um=p.defineComponent({__name:"ContainerSubSettings",props:{title:{},goBack:{type:Function}},setup(n){const e=p.useAttrs(),t=mo.useRouter(),r=n;function s(){window.history.length>1?t.back():t.push("/")}return(i,o)=>(p.openBlock(),p.createElementBlock("div",EI,[p.createElementVNode("div",vI,[p.createElementVNode("div",TI,[p.createVNode(ze,{onClick:o[0]||(o[0]=()=>r.goBack?r.goBack():s()),variant:"outline",color:"secondary",class:"shadow-sm mt-auto"},{default:p.withCtx(()=>[...o[1]||(o[1]=[p.createTextVNode(" ◀ indietro ",-1)])]),_:1})]),p.createElementVNode("div",wI,[r.title&&r.title!==""?(p.openBlock(),p.createElementBlock("p",bI,p.toDisplayString(r.title),1)):p.createCommentVNode("",!0)]),o[2]||(o[2]=p.createElementVNode("div",{class:"col-12"},null,-1)),p.createElementVNode("div",AI,[p.createElementVNode("div",II,[p.createElementVNode("div",p.mergeProps({class:"card-body"},p.unref(e)),[p.renderSlot(i.$slots,"default")],16)])])])]))}}),SI={key:2},CI=p.defineComponent({__name:"SideTabCmp",props:p.mergeModels({tab:{type:Object,required:!0},active:{type:Boolean,required:!0},color:{type:String,default:"#056864"},activeStyle:{type:Object,default:()=>({backgroundColor:"#00fff20d"})}},{hover:{type:Boolean,default:!1},hoverModifiers:{}}),emits:p.mergeModels(["select"],["update:hover"]),setup(n,{emit:e}){const t=e,r=p.useModel(n,"hover"),s=p.computed(()=>!n.active&&!r.value?null:n.activeStyle??{backgroundColor:" #00fff20d"});return(i,o)=>(p.openBlock(),p.createElementBlock("li",{class:p.normalizeClass(["ms_tab",{active:n.active}]),style:p.normalizeStyle(s.value),onMouseenter:o[0]||(o[0]=c=>r.value=!0),onMouseleave:o[1]||(o[1]=c=>r.value=!1),onClick:o[2]||(o[2]=c=>t("select",n.tab))},[n.tab.icon?(p.openBlock(),p.createElementBlock("span",{key:0,class:"material-symbols-outlined",style:p.normalizeStyle(n.active?{color:`${n.color}`}:null),"aria-hidden":"true"},p.toDisplayString(n.tab.icon),5)):p.createCommentVNode("",!0),typeof n.tab.label!="string"?(p.openBlock(),p.createBlock(p.resolveDynamicComponent(n.tab.label),{key:1})):(p.openBlock(),p.createElementBlock("span",SI,p.toDisplayString(n.tab.label??""),1))],38))}}),jc=ci(CI,[["__scopeId","data-v-5204c1f0"]]),RI={class:"list-unstyled m-0"},kI={key:0,class:"my-3"},PI={class:"fw-semibold d-flex align-items-center gap-2 mb-2 cursor-default"},NI={key:0,class:"material-symbols-outlined","aria-hidden":"true"},DI={key:2},OI={class:"list-unstyled m-0"},Cd=p.defineComponent({__name:"SideTabsList",props:{tabs:{type:Array,required:!0},modelValue:{type:String,default:""},color:{type:String,required:!1},tabStyle:{type:Object,default:null}},emits:["select"],setup(n,{emit:e}){const t=e;function r(o){return o.subTabs!==void 0}function s(o){return r(o)?String(o.label):o.name}function i(o){t("select",o)}return(o,c)=>(p.openBlock(),p.createElementBlock("ul",RI,[(p.openBlock(!0),p.createElementBlock(p.Fragment,null,p.renderList(n.tabs,l=>(p.openBlock(),p.createElementBlock(p.Fragment,{key:s(l)},[r(l)?(p.openBlock(),p.createElementBlock("li",kI,[p.createElementVNode("div",PI,[l.icon?(p.openBlock(),p.createElementBlock("span",NI,p.toDisplayString(l.icon),1)):p.createCommentVNode("",!0),typeof l.label!="string"?(p.openBlock(),p.createBlock(p.resolveDynamicComponent(l.label),{key:1})):(p.openBlock(),p.createElementBlock("span",DI,p.toDisplayString(l.label),1))]),p.createElementVNode("ul",OI,[(p.openBlock(!0),p.createElementBlock(p.Fragment,null,p.renderList(l.subTabs,h=>(p.openBlock(),p.createBlock(jc,{key:h.name,tab:h,active:h.name===n.modelValue,color:n.color,"active-style":n.tabStyle,onSelect:i},null,8,["tab","active","color","active-style"]))),128))])])):(p.openBlock(),p.createBlock(jc,{key:1,tab:l,active:l.name===n.modelValue,"active-style":n.tabStyle,color:n.color,onSelect:i},null,8,["tab","active","active-style","color"]))],64))),128))]))}}),VI={class:"h-100 w-100 d-flex"},LI={class:"d-lg-none d-flex align-items-center border-bottom p-2 position-sticky top-0 bg-glass"},MI={key:1,class:"d-flex flex-column align-items-center justify-content-center text-center h-100 text-muted"},xI=p.defineComponent({__name:"ContainerSideTabs",props:{tabs:{type:Array,required:!0},modelValue:{type:String,default:""},color:{type:String,required:!1},hoverBgOpacity:{type:Number,default:5},contentClass:{type:String,default:"px-3"},scrollToTopOnSelect:{type:Boolean,default:!0},scrollToTopSmooth:{type:Boolean,default:!0},trackRoute:{type:Boolean,default:!0},routeQueryKey:{type:String,default:"tab"},routeUseReplace:{type:Boolean,default:!1},sidebarMinWidth:{type:Number,required:!1}},emits:["update:modelValue","select"],setup(n,{emit:e}){const t=e,r=mo.useRouter(),s=mo.useRoute(),i=p.ref(null),o=p.ref(!1);function c(_){return _.subTabs!==void 0}function l(_=!0){const T=i.value;T&&T.scrollTo({top:0,left:0,behavior:_?"smooth":"auto"})}p.watch(()=>s.query[n.routeQueryKey],_=>{n.trackRoute&&typeof _=="string"&&_!==n.modelValue&&t("update:modelValue",_)},{immediate:!0});async function h(_){if(t("update:modelValue",_.name),t("select",_),n.trackRoute){const T={...s.query,[n.routeQueryKey]:_.name};n.routeUseReplace?await r.replace({query:T}):await r.push({query:T})}o.value=!1,n.scrollToTopOnSelect&&(await p.nextTick(),l(n.scrollToTopSmooth))}const f=p.computed(()=>n.color?{backgroundColor:`color-mix(in srgb, ${n.color} ${n.hoverBgOpacity}%, transparent)`}:null),g=p.computed(()=>{if(!n.modelValue)return null;for(const _ of n.tabs)if(c(_)){const T=_.subTabs.find(C=>C.name===n.modelValue);if(T)return T}else if(_.name===n.modelValue)return _;return null});return(_,T)=>(p.openBlock(),p.createElementBlock("div",VI,[p.createElementVNode("aside",{class:"d-none d-lg-block overflow-auto h-100 p-2 border-end",style:p.normalizeStyle(n.sidebarMinWidth?{minWidth:n.sidebarMinWidth+"px"}:null)},[p.createVNode(Cd,{tabs:n.tabs,"model-value":n.modelValue,color:n.color,"tab-style":f.value,onSelect:h},null,8,["tabs","model-value","color","tab-style"])],4),p.createElementVNode("section",{ref_key:"contentEl",ref:i,class:p.normalizeClass(["overflow-auto h-100 flex-grow-1 position-relative",n.contentClass])},[p.createElementVNode("div",LI,[p.createVNode(ze,{variant:"ghost",onClick:T[0]||(T[0]=()=>o.value=!0),icon:"menu",class:"me-2 border-end"}),g.value?(p.openBlock(),p.createBlock(jc,{key:0,tab:g.value,active:!0,color:n.color,"active-style":f.value,onSelect:h},null,8,["tab","color","active-style"])):p.createCommentVNode("",!0)]),p.renderSlot(_.$slots,"default",{},()=>[g.value?.component?(p.openBlock(),p.createBlock(p.resolveDynamicComponent(g.value.component),{key:0})):(p.openBlock(),p.createElementBlock("div",MI,[...T[2]||(T[2]=[p.createElementVNode("span",{class:"material-symbols-outlined fs-1 mb-2"}," widgets ",-1),p.createElementVNode("div",{class:"fw-semibold"}," Nessun componente disponibile ",-1),p.createElementVNode("small",{class:"opacity-75"}," Per questo tab non è stato passato alcun componente ",-1)])]))],!0)],2),p.createVNode(Ul,{modelValue:o.value,"onUpdate:modelValue":T[1]||(T[1]=C=>o.value=C),header:{title:"Menu"},id:"sideTabsOffcanvas"},{default:p.withCtx(()=>[p.createVNode(Cd,{tabs:n.tabs,"model-value":n.modelValue,color:n.color,"tab-style":f.value,onSelect:h},null,8,["tabs","model-value","color","tab-style"])]),_:1},8,["modelValue"])]))}}),Bm=ci(xI,[["__scopeId","data-v-9cb9fc53"]]),FI=()=>{};const qm=function(n){const e=[];let t=0;for(let r=0;r<n.length;r++){let s=n.charCodeAt(r);s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&r+1<n.length&&(n.charCodeAt(r+1)&64512)===56320?(s=65536+((s&1023)<<10)+(n.charCodeAt(++r)&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},$I=function(n){const e=[];let t=0,r=0;for(;t<n.length;){const s=n[t++];if(s<128)e[r++]=String.fromCharCode(s);else if(s>191&&s<224){const i=n[t++];e[r++]=String.fromCharCode((s&31)<<6|i&63)}else if(s>239&&s<365){const i=n[t++],o=n[t++],c=n[t++],l=((s&7)<<18|(i&63)<<12|(o&63)<<6|c&63)-65536;e[r++]=String.fromCharCode(55296+(l>>10)),e[r++]=String.fromCharCode(56320+(l&1023))}else{const i=n[t++],o=n[t++];e[r++]=String.fromCharCode((s&15)<<12|(i&63)<<6|o&63)}}return e.join("")},jm={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_,r=[];for(let s=0;s<n.length;s+=3){const i=n[s],o=s+1<n.length,c=o?n[s+1]:0,l=s+2<n.length,h=l?n[s+2]:0,f=i>>2,g=(i&3)<<4|c>>4;let _=(c&15)<<2|h>>6,T=h&63;l||(T=64,o||(_=64)),r.push(t[f],t[g],t[_],t[T])}return r.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray(qm(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):$I(this.decodeStringToByteArray(n,e))},decodeStringToByteArray(n,e){this.init_();const t=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let s=0;s<n.length;){const i=t[n.charAt(s++)],c=s<n.length?t[n.charAt(s)]:0;++s;const h=s<n.length?t[n.charAt(s)]:64;++s;const g=s<n.length?t[n.charAt(s)]:64;if(++s,i==null||c==null||h==null||g==null)throw new UI;const _=i<<2|c>>4;if(r.push(_),h!==64){const T=c<<4&240|h>>2;if(r.push(T),g!==64){const C=h<<6&192|g;r.push(C)}}}return r},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 UI extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const BI=function(n){const e=qm(n);return jm.encodeByteArray(e,!0)},vo=function(n){return BI(n).replace(/\./g,"")},Hm=function(n){try{return jm.decodeString(n,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function qI(){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 jI=()=>qI().__FIREBASE_DEFAULTS__,HI=()=>{if(typeof process>"u"||typeof process.env>"u")return;const n=process.env.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},WI=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=n&&Hm(n[1]);return e&&JSON.parse(e)},ia=()=>{try{return FI()||jI()||HI()||WI()}catch(n){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},Wm=n=>ia()?.emulatorHosts?.[n],Bl=n=>{const e=Wm(n);if(!e)return;const t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const r=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),r]:[e.substring(0,t),r]},zm=()=>ia()?.config,Km=n=>ia()?.[`_${n}`];class zI{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,r)=>{t?this.reject(t):this.resolve(r),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,r))}}}function en(n){try{return(n.startsWith("http://")||n.startsWith("https://")?new URL(n).hostname:n).endsWith(".cloudworkstations.dev")}catch{return!1}}async function oa(n){return(await fetch(n,{credentials:"include"})).ok}function Gm(n,e){if(n.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const t={alg:"none",type:"JWT"},r=e||"demo-project",s=n.iat||0,i=n.sub||n.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o={iss:`https://securetoken.google.com/${r}`,aud:r,iat:s,exp:s+3600,auth_time:s,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}},...n};return[vo(JSON.stringify(t)),vo(JSON.stringify(o)),""].join(".")}const qs={};function KI(){const n={prod:[],emulator:[]};for(const e of Object.keys(qs))qs[e]?n.emulator.push(e):n.prod.push(e);return n}function GI(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 Rd=!1;function aa(n,e){if(typeof window>"u"||typeof document>"u"||!en(window.location.host)||qs[n]===e||qs[n]||Rd)return;qs[n]=e;function t(_){return`__firebase__banner__${_}`}const r="__firebase__banner",i=KI().prod.length>0;function o(){const _=document.getElementById(r);_&&_.remove()}function c(_){_.style.display="flex",_.style.background="#7faaf0",_.style.position="fixed",_.style.bottom="5px",_.style.left="5px",_.style.padding=".5em",_.style.borderRadius="5px",_.style.alignItems="center"}function l(_,T){_.setAttribute("width","24"),_.setAttribute("id",T),_.setAttribute("height","24"),_.setAttribute("viewBox","0 0 24 24"),_.setAttribute("fill","none"),_.style.marginLeft="-6px"}function h(){const _=document.createElement("span");return _.style.cursor="pointer",_.style.marginLeft="16px",_.style.fontSize="24px",_.innerHTML=" ×",_.onclick=()=>{Rd=!0,o()},_}function f(_,T){_.setAttribute("id",T),_.innerText="Learn more",_.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",_.setAttribute("target","__blank"),_.style.paddingLeft="5px",_.style.textDecoration="underline"}function g(){const _=GI(r),T=t("text"),C=document.getElementById(T)||document.createElement("span"),P=t("learnmore"),k=document.getElementById(P)||document.createElement("a"),L=t("preprendIcon"),$=document.getElementById(L)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(_.created){const U=_.element;c(U),f(k,P);const F=h();l($,L),U.append($,C,k,F),document.body.appendChild(U)}i?(C.innerText="Preview backend disconnected.",$.innerHTML=`<g clip-path="url(#clip0_6013_33858)">
|
|
2
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
3
|
</g>
|
|
4
4
|
<defs>
|
|
5
5
|
<clipPath id="clip0_6013_33858">
|
|
6
6
|
<rect width="24" height="24" fill="white"/>
|
|
7
7
|
</clipPath>
|
|
8
|
-
</defs>`):(
|
|
8
|
+
</defs>`):($.innerHTML=`<g clip-path="url(#clip0_6083_34804)">
|
|
9
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
10
|
</g>
|
|
11
11
|
<defs>
|
|
12
12
|
<clipPath id="clip0_6083_34804">
|
|
13
13
|
<rect width="24" height="24" fill="white"/>
|
|
14
14
|
</clipPath>
|
|
15
|
-
</defs>`,k.innerText="Preview backend running in this workspace."),k.setAttribute("id",S)}document.readyState==="loading"?window.addEventListener("DOMContentLoaded",m):m()}function Se(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function ug(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(Se())}function hg(){const n=si()?.forceEnvironment;if(n==="node")return!0;if(n==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function dg(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function Lh(){const n=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof n=="object"&&n.id!==void 0}function fg(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function pg(){const n=Se();return n.indexOf("MSIE ")>=0||n.indexOf("Trident/")>=0}function mg(){return!hg()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function ua(){try{return typeof indexedDB=="object"}catch{return!1}}function ha(){return new Promise((n,e)=>{try{let t=!0;const r="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(r);s.onsuccess=()=>{s.result.close(),t||self.indexedDB.deleteDatabase(r),n(!0)},s.onupgradeneeded=()=>{t=!1},s.onerror=()=>{e(s.error?.message||"")}}catch(t){e(t)}})}function Mh(){return!(typeof navigator>"u"||!navigator.cookieEnabled)}const gg="FirebaseError";class $e extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name=gg,Object.setPrototypeOf(this,$e.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,Kt.prototype.create)}}class Kt{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){const r=t[0]||{},s=`${this.service}/${e}`,i=this.errors[e],a=i?_g(i,r):"Error",c=`${this.serviceName}: ${a} (${s}).`;return new $e(s,c,r)}}function _g(n,e){return n.replace(yg,(t,r)=>{const s=e[r];return s!=null?String(s):`<${r}?>`})}const yg=/\{\$([^}]+)}/g;function Tg(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function Ut(n,e){if(n===e)return!0;const t=Object.keys(n),r=Object.keys(e);for(const s of t){if(!r.includes(s))return!1;const i=n[s],a=e[s];if(Al(i)&&Al(a)){if(!Ut(i,a))return!1}else if(i!==a)return!1}for(const s of r)if(!t.includes(s))return!1;return!0}function Al(n){return n!==null&&typeof n=="object"}function Mr(n){const e=[];for(const[t,r]of Object.entries(n))Array.isArray(r)?r.forEach(s=>{e.push(encodeURIComponent(t)+"="+encodeURIComponent(s))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function wg(n,e){const t=new Eg(n,e);return t.subscribe.bind(t)}class Eg{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(r=>{this.error(r)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let s;if(e===void 0&&t===void 0&&r===void 0)throw new Error("Missing Observer.");vg(e,["next","error","complete"])?s=e:s={next:e,error:t,complete:r},s.next===void 0&&(s.next=no),s.error===void 0&&(s.error=no),s.complete===void 0&&(s.complete=no);const i=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),i}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(r){typeof console<"u"&&console.error&&console.error(r)}})}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 vg(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 no(){}const Ig=1e3,Ag=2,bg=14400*1e3,Sg=.5;function bl(n,e=Ig,t=Ag){const r=e*Math.pow(t,n),s=Math.round(Sg*r*(Math.random()-.5)*2);return Math.min(bg,r+s)}function ee(n){return n&&n._delegate?n._delegate:n}class Ne{constructor(e,t,r){this.name=e,this.instanceFactory=t,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}const nn="[DEFAULT]";class Rg{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 r=new ag;if(this.instancesDeferred.set(t,r),this.isInitialized(t)||this.shouldAutoInitialize())try{const s=this.getOrInitializeService({instanceIdentifier:t});s&&r.resolve(s)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){const t=this.normalizeInstanceIdentifier(e?.identifier),r=e?.optional??!1;if(this.isInitialized(t)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:t})}catch(s){if(r)return null;throw s}else{if(r)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(Cg(e))try{this.getOrInitializeService({instanceIdentifier:nn})}catch{}for(const[t,r]of this.instancesDeferred.entries()){const s=this.normalizeInstanceIdentifier(t);try{const i=this.getOrInitializeService({instanceIdentifier:s});r.resolve(i)}catch{}}}}clearInstance(e=nn){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=nn){return this.instances.has(e)}getOptions(e=nn){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,r=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const s=this.getOrInitializeService({instanceIdentifier:r,options:t});for(const[i,a]of this.instancesDeferred.entries()){const c=this.normalizeInstanceIdentifier(i);r===c&&a.resolve(s)}return s}onInit(e,t){const r=this.normalizeInstanceIdentifier(t),s=this.onInitCallbacks.get(r)??new Set;s.add(e),this.onInitCallbacks.set(r,s);const i=this.instances.get(r);return i&&e(i,r),()=>{s.delete(e)}}invokeOnInitCallbacks(e,t){const r=this.onInitCallbacks.get(t);if(r)for(const s of r)try{s(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let r=this.instances.get(e);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:Pg(e),options:t}),this.instances.set(e,r),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(r,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,r)}catch{}return r||null}normalizeInstanceIdentifier(e=nn){return this.component?this.component.multipleInstances?e:nn:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function Pg(n){return n===nn?void 0:n}function Cg(n){return n.instantiationMode==="EAGER"}class kg{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 Rg(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}var H;(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"})(H||(H={}));const Ng={debug:H.DEBUG,verbose:H.VERBOSE,info:H.INFO,warn:H.WARN,error:H.ERROR,silent:H.SILENT},Dg=H.INFO,Vg={[H.DEBUG]:"log",[H.VERBOSE]:"log",[H.INFO]:"info",[H.WARN]:"warn",[H.ERROR]:"error"},Og=(n,e,...t)=>{if(e<n.logLevel)return;const r=new Date().toISOString(),s=Vg[e];if(s)console[s](`[${r}] ${n.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class ai{constructor(e){this.name=e,this._logLevel=Dg,this._logHandler=Og,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in H))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?Ng[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,H.DEBUG,...e),this._logHandler(this,H.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,H.VERBOSE,...e),this._logHandler(this,H.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,H.INFO,...e),this._logHandler(this,H.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,H.WARN,...e),this._logHandler(this,H.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,H.ERROR,...e),this._logHandler(this,H.ERROR,...e)}}const Lg=(n,e)=>e.some(t=>n instanceof t);let Sl,Rl;function Mg(){return Sl||(Sl=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function xg(){return Rl||(Rl=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const xh=new WeakMap,So=new WeakMap,Fh=new WeakMap,ro=new WeakMap,da=new WeakMap;function Fg(n){const e=new Promise((t,r)=>{const s=()=>{n.removeEventListener("success",i),n.removeEventListener("error",a)},i=()=>{t(gt(n.result)),s()},a=()=>{r(n.error),s()};n.addEventListener("success",i),n.addEventListener("error",a)});return e.then(t=>{t instanceof IDBCursor&&xh.set(t,n)}).catch(()=>{}),da.set(e,n),e}function Ug(n){if(So.has(n))return;const e=new Promise((t,r)=>{const s=()=>{n.removeEventListener("complete",i),n.removeEventListener("error",a),n.removeEventListener("abort",a)},i=()=>{t(),s()},a=()=>{r(n.error||new DOMException("AbortError","AbortError")),s()};n.addEventListener("complete",i),n.addEventListener("error",a),n.addEventListener("abort",a)});So.set(n,e)}let Ro={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return So.get(n);if(e==="objectStoreNames")return n.objectStoreNames||Fh.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return gt(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 Bg(n){Ro=n(Ro)}function qg(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const r=n.call(so(this),e,...t);return Fh.set(r,e.sort?e.sort():[e]),gt(r)}:xg().includes(n)?function(...e){return n.apply(so(this),e),gt(xh.get(this))}:function(...e){return gt(n.apply(so(this),e))}}function $g(n){return typeof n=="function"?qg(n):(n instanceof IDBTransaction&&Ug(n),Lg(n,Mg())?new Proxy(n,Ro):n)}function gt(n){if(n instanceof IDBRequest)return Fg(n);if(ro.has(n))return ro.get(n);const e=$g(n);return e!==n&&(ro.set(n,e),da.set(e,n)),e}const so=n=>da.get(n);function ci(n,e,{blocked:t,upgrade:r,blocking:s,terminated:i}={}){const a=indexedDB.open(n,e),c=gt(a);return r&&a.addEventListener("upgradeneeded",u=>{r(gt(a.result),u.oldVersion,u.newVersion,gt(a.transaction),u)}),t&&a.addEventListener("blocked",u=>t(u.oldVersion,u.newVersion,u)),c.then(u=>{i&&u.addEventListener("close",()=>i()),s&&u.addEventListener("versionchange",h=>s(h.oldVersion,h.newVersion,h))}).catch(()=>{}),c}function io(n,{blocked:e}={}){const t=indexedDB.deleteDatabase(n);return e&&t.addEventListener("blocked",r=>e(r.oldVersion,r)),gt(t).then(()=>{})}const jg=["get","getKey","getAll","getAllKeys","count"],zg=["put","add","delete","clear"],oo=new Map;function Pl(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(oo.get(e))return oo.get(e);const t=e.replace(/FromIndex$/,""),r=e!==t,s=zg.includes(t);if(!(t in(r?IDBIndex:IDBObjectStore).prototype)||!(s||jg.includes(t)))return;const i=async function(a,...c){const u=this.transaction(a,s?"readwrite":"readonly");let h=u.store;return r&&(h=h.index(c.shift())),(await Promise.all([h[t](...c),s&&u.done]))[0]};return oo.set(e,i),i}Bg(n=>({...n,get:(e,t,r)=>Pl(e,t)||n.get(e,t,r),has:(e,t)=>!!Pl(e,t)||n.has(e,t)}));class Hg{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(Gg(t)){const r=t.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(t=>t).join(" ")}}function Gg(n){return n.getComponent()?.type==="VERSION"}const Po="@firebase/app",Cl="0.14.7";const yt=new ai("@firebase/app"),Kg="@firebase/app-compat",Wg="@firebase/analytics-compat",Qg="@firebase/analytics",Jg="@firebase/app-check-compat",Yg="@firebase/app-check",Xg="@firebase/auth",Zg="@firebase/auth-compat",e_="@firebase/database",t_="@firebase/data-connect",n_="@firebase/database-compat",r_="@firebase/functions",s_="@firebase/functions-compat",i_="@firebase/installations",o_="@firebase/installations-compat",a_="@firebase/messaging",c_="@firebase/messaging-compat",l_="@firebase/performance",u_="@firebase/performance-compat",h_="@firebase/remote-config",d_="@firebase/remote-config-compat",f_="@firebase/storage",p_="@firebase/storage-compat",m_="@firebase/firestore",g_="@firebase/ai",__="@firebase/firestore-compat",y_="firebase",T_="12.8.0";const Co="[DEFAULT]",w_={[Po]:"fire-core",[Kg]:"fire-core-compat",[Qg]:"fire-analytics",[Wg]:"fire-analytics-compat",[Yg]:"fire-app-check",[Jg]:"fire-app-check-compat",[Xg]:"fire-auth",[Zg]:"fire-auth-compat",[e_]:"fire-rtdb",[t_]:"fire-data-connect",[n_]:"fire-rtdb-compat",[r_]:"fire-fn",[s_]:"fire-fn-compat",[i_]:"fire-iid",[o_]:"fire-iid-compat",[a_]:"fire-fcm",[c_]:"fire-fcm-compat",[l_]:"fire-perf",[u_]:"fire-perf-compat",[h_]:"fire-rc",[d_]:"fire-rc-compat",[f_]:"fire-gcs",[p_]:"fire-gcs-compat",[m_]:"fire-fst",[__]:"fire-fst-compat",[g_]:"fire-vertex","fire-js":"fire-js",[y_]:"fire-js-all"};const Rs=new Map,E_=new Map,ko=new Map;function kl(n,e){try{n.container.addComponent(e)}catch(t){yt.debug(`Component ${e.name} failed to register with FirebaseApp ${n.name}`,t)}}function Me(n){const e=n.name;if(ko.has(e))return yt.debug(`There were multiple attempts to register component ${e}.`),!1;ko.set(e,n);for(const t of Rs.values())kl(t,n);for(const t of E_.values())kl(t,n);return!0}function ut(n,e){const t=n.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),n.container.getProvider(e)}function Fe(n){return n==null?!1:n.settings!==void 0}const v_={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","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."},Mt=new Kt("app","Firebase",v_);class I_{constructor(e,t,r){this._isDeleted=!1,this._options={...e},this._config={...t},this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new Ne("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 Mt.create("app-deleted",{appName:this._name})}}const yn=T_;function Uh(n,e={}){let t=n;typeof e!="object"&&(e={name:e});const r={name:Co,automaticDataCollectionEnabled:!0,...e},s=r.name;if(typeof s!="string"||!s)throw Mt.create("bad-app-name",{appName:String(s)});if(t||(t=Dh()),!t)throw Mt.create("no-options");const i=Rs.get(s);if(i){if(Ut(t,i.options)&&Ut(r,i.config))return i;throw Mt.create("duplicate-app",{appName:s})}const a=new kg(s);for(const u of ko.values())a.addComponent(u);const c=new I_(t,r,a);return Rs.set(s,c),c}function $n(n=Co){const e=Rs.get(n);if(!e&&n===Co&&Dh())return Uh();if(!e)throw Mt.create("no-app",{appName:n});return e}function me(n,e,t){let r=w_[n]??n;t&&(r+=`-${t}`);const s=r.match(/\s|\//),i=e.match(/\s|\//);if(s||i){const a=[`Unable to register library "${r}" with version "${e}":`];s&&a.push(`library name "${r}" contains illegal characters (whitespace or "/")`),s&&i&&a.push("and"),i&&a.push(`version name "${e}" contains illegal characters (whitespace or "/")`),yt.warn(a.join(" "));return}Me(new Ne(`${r}-version`,()=>({library:r,version:e}),"VERSION"))}const A_="firebase-heartbeat-database",b_=1,br="firebase-heartbeat-store";let ao=null;function Bh(){return ao||(ao=ci(A_,b_,{upgrade:(n,e)=>{switch(e){case 0:try{n.createObjectStore(br)}catch(t){console.warn(t)}}}}).catch(n=>{throw Mt.create("idb-open",{originalErrorMessage:n.message})})),ao}async function S_(n){try{const t=(await Bh()).transaction(br),r=await t.objectStore(br).get(qh(n));return await t.done,r}catch(e){if(e instanceof $e)yt.warn(e.message);else{const t=Mt.create("idb-get",{originalErrorMessage:e?.message});yt.warn(t.message)}}}async function Nl(n,e){try{const r=(await Bh()).transaction(br,"readwrite");await r.objectStore(br).put(e,qh(n)),await r.done}catch(t){if(t instanceof $e)yt.warn(t.message);else{const r=Mt.create("idb-set",{originalErrorMessage:t?.message});yt.warn(r.message)}}}function qh(n){return`${n.name}!${n.options.appId}`}const R_=1024,P_=30;class C_{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new N_(t),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){try{const t=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),r=Dl();if(this._heartbeatsCache?.heartbeats==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null)||this._heartbeatsCache.lastSentHeartbeatDate===r||this._heartbeatsCache.heartbeats.some(s=>s.date===r))return;if(this._heartbeatsCache.heartbeats.push({date:r,agent:t}),this._heartbeatsCache.heartbeats.length>P_){const s=D_(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(s,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){yt.warn(e)}}async getHeartbeatsHeader(){try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null||this._heartbeatsCache.heartbeats.length===0)return"";const e=Dl(),{heartbeatsToSend:t,unsentEntries:r}=k_(this._heartbeatsCache.heartbeats),s=Ss(JSON.stringify({version:2,heartbeats:t}));return this._heartbeatsCache.lastSentHeartbeatDate=e,r.length>0?(this._heartbeatsCache.heartbeats=r,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),s}catch(e){return yt.warn(e),""}}}function Dl(){return new Date().toISOString().substring(0,10)}function k_(n,e=R_){const t=[];let r=n.slice();for(const s of n){const i=t.find(a=>a.agent===s.agent);if(i){if(i.dates.push(s.date),Vl(t)>e){i.dates.pop();break}}else if(t.push({agent:s.agent,dates:[s.date]}),Vl(t)>e){t.pop();break}r=r.slice(1)}return{heartbeatsToSend:t,unsentEntries:r}}class N_{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return ua()?ha().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const t=await S_(this.app);return t?.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){const r=await this.read();return Nl(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){if(await this._canUseIndexedDBPromise){const r=await this.read();return Nl(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...e.heartbeats]})}else return}}function Vl(n){return Ss(JSON.stringify({version:2,heartbeats:n})).length}function D_(n){if(n.length===0)return-1;let e=0,t=n[0].date;for(let r=1;r<n.length;r++)n[r].date<t&&(t=n[r].date,e=r);return e}function V_(n){Me(new Ne("platform-logger",e=>new Hg(e),"PRIVATE")),Me(new Ne("heartbeat",e=>new C_(e),"PRIVATE")),me(Po,Cl,n),me(Po,Cl,"esm2020"),me("fire-js","")}V_("");var O_="firebase",L_="12.8.0";me(O_,L_,"app");const $h="@firebase/installations",fa="0.6.19";const jh=1e4,zh=`w:${fa}`,Hh="FIS_v2",M_="https://firebaseinstallations.googleapis.com/v1",x_=3600*1e3,F_="installations",U_="Installations";const B_={"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."},hn=new Kt(F_,U_,B_);function Gh(n){return n instanceof $e&&n.code.includes("request-failed")}function Kh({projectId:n}){return`${M_}/projects/${n}/installations`}function Wh(n){return{token:n.token,requestStatus:2,expiresIn:$_(n.expiresIn),creationTime:Date.now()}}async function Qh(n,e){const r=(await e.json()).error;return hn.create("request-failed",{requestName:n,serverCode:r.code,serverMessage:r.message,serverStatus:r.status})}function Jh({apiKey:n}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":n})}function q_(n,{refreshToken:e}){const t=Jh(n);return t.append("Authorization",j_(e)),t}async function Yh(n){const e=await n();return e.status>=500&&e.status<600?n():e}function $_(n){return Number(n.replace("s","000"))}function j_(n){return`${Hh} ${n}`}async function z_({appConfig:n,heartbeatServiceProvider:e},{fid:t}){const r=Kh(n),s=Jh(n),i=e.getImmediate({optional:!0});if(i){const h=await i.getHeartbeatsHeader();h&&s.append("x-firebase-client",h)}const a={fid:t,authVersion:Hh,appId:n.appId,sdkVersion:zh},c={method:"POST",headers:s,body:JSON.stringify(a)},u=await Yh(()=>fetch(r,c));if(u.ok){const h=await u.json();return{fid:h.fid||t,registrationStatus:2,refreshToken:h.refreshToken,authToken:Wh(h.authToken)}}else throw await Qh("Create Installation",u)}function Xh(n){return new Promise(e=>{setTimeout(e,n)})}function H_(n){return btoa(String.fromCharCode(...n)).replace(/\+/g,"-").replace(/\//g,"_")}const G_=/^[cdef][\w-]{21}$/,No="";function K_(){try{const n=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(n),n[0]=112+n[0]%16;const t=W_(n);return G_.test(t)?t:No}catch{return No}}function W_(n){return H_(n).substr(0,22)}function li(n){return`${n.appName}!${n.appId}`}const Zh=new Map;function ed(n,e){const t=li(n);td(t,e),Q_(t,e)}function td(n,e){const t=Zh.get(n);if(t)for(const r of t)r(e)}function Q_(n,e){const t=J_();t&&t.postMessage({key:n,fid:e}),Y_()}let rn=null;function J_(){return!rn&&"BroadcastChannel"in self&&(rn=new BroadcastChannel("[Firebase] FID Change"),rn.onmessage=n=>{td(n.data.key,n.data.fid)}),rn}function Y_(){Zh.size===0&&rn&&(rn.close(),rn=null)}const X_="firebase-installations-database",Z_=1,dn="firebase-installations-store";let co=null;function pa(){return co||(co=ci(X_,Z_,{upgrade:(n,e)=>{e===0&&n.createObjectStore(dn)}})),co}async function Ps(n,e){const t=li(n),s=(await pa()).transaction(dn,"readwrite"),i=s.objectStore(dn),a=await i.get(t);return await i.put(e,t),await s.done,(!a||a.fid!==e.fid)&&ed(n,e.fid),e}async function nd(n){const e=li(n),r=(await pa()).transaction(dn,"readwrite");await r.objectStore(dn).delete(e),await r.done}async function ui(n,e){const t=li(n),s=(await pa()).transaction(dn,"readwrite"),i=s.objectStore(dn),a=await i.get(t),c=e(a);return c===void 0?await i.delete(t):await i.put(c,t),await s.done,c&&(!a||a.fid!==c.fid)&&ed(n,c.fid),c}async function ma(n){let e;const t=await ui(n.appConfig,r=>{const s=ey(r),i=ty(n,s);return e=i.registrationPromise,i.installationEntry});return t.fid===No?{installationEntry:await e}:{installationEntry:t,registrationPromise:e}}function ey(n){const e=n||{fid:K_(),registrationStatus:0};return rd(e)}function ty(n,e){if(e.registrationStatus===0){if(!navigator.onLine){const s=Promise.reject(hn.create("app-offline"));return{installationEntry:e,registrationPromise:s}}const t={fid:e.fid,registrationStatus:1,registrationTime:Date.now()},r=ny(n,t);return{installationEntry:t,registrationPromise:r}}else return e.registrationStatus===1?{installationEntry:e,registrationPromise:ry(n)}:{installationEntry:e}}async function ny(n,e){try{const t=await z_(n,e);return Ps(n.appConfig,t)}catch(t){throw Gh(t)&&t.customData.serverCode===409?await nd(n.appConfig):await Ps(n.appConfig,{fid:e.fid,registrationStatus:0}),t}}async function ry(n){let e=await Ol(n.appConfig);for(;e.registrationStatus===1;)await Xh(100),e=await Ol(n.appConfig);if(e.registrationStatus===0){const{installationEntry:t,registrationPromise:r}=await ma(n);return r||t}return e}function Ol(n){return ui(n,e=>{if(!e)throw hn.create("installation-not-found");return rd(e)})}function rd(n){return sy(n)?{fid:n.fid,registrationStatus:0}:n}function sy(n){return n.registrationStatus===1&&n.registrationTime+jh<Date.now()}async function iy({appConfig:n,heartbeatServiceProvider:e},t){const r=oy(n,t),s=q_(n,t),i=e.getImmediate({optional:!0});if(i){const h=await i.getHeartbeatsHeader();h&&s.append("x-firebase-client",h)}const a={installation:{sdkVersion:zh,appId:n.appId}},c={method:"POST",headers:s,body:JSON.stringify(a)},u=await Yh(()=>fetch(r,c));if(u.ok){const h=await u.json();return Wh(h)}else throw await Qh("Generate Auth Token",u)}function oy(n,{fid:e}){return`${Kh(n)}/${e}/authTokens:generate`}async function ga(n,e=!1){let t;const r=await ui(n.appConfig,i=>{if(!sd(i))throw hn.create("not-registered");const a=i.authToken;if(!e&&ly(a))return i;if(a.requestStatus===1)return t=ay(n,e),i;{if(!navigator.onLine)throw hn.create("app-offline");const c=hy(i);return t=cy(n,c),c}});return t?await t:r.authToken}async function ay(n,e){let t=await Ll(n.appConfig);for(;t.authToken.requestStatus===1;)await Xh(100),t=await Ll(n.appConfig);const r=t.authToken;return r.requestStatus===0?ga(n,e):r}function Ll(n){return ui(n,e=>{if(!sd(e))throw hn.create("not-registered");const t=e.authToken;return dy(t)?{...e,authToken:{requestStatus:0}}:e})}async function cy(n,e){try{const t=await iy(n,e),r={...e,authToken:t};return await Ps(n.appConfig,r),t}catch(t){if(Gh(t)&&(t.customData.serverCode===401||t.customData.serverCode===404))await nd(n.appConfig);else{const r={...e,authToken:{requestStatus:0}};await Ps(n.appConfig,r)}throw t}}function sd(n){return n!==void 0&&n.registrationStatus===2}function ly(n){return n.requestStatus===2&&!uy(n)}function uy(n){const e=Date.now();return e<n.creationTime||n.creationTime+n.expiresIn<e+x_}function hy(n){const e={requestStatus:1,requestTime:Date.now()};return{...n,authToken:e}}function dy(n){return n.requestStatus===1&&n.requestTime+jh<Date.now()}async function fy(n){const e=n,{installationEntry:t,registrationPromise:r}=await ma(e);return r?r.catch(console.error):ga(e).catch(console.error),t.fid}async function py(n,e=!1){const t=n;return await my(t),(await ga(t,e)).token}async function my(n){const{registrationPromise:e}=await ma(n);e&&await e}function gy(n){if(!n||!n.options)throw lo("App Configuration");if(!n.name)throw lo("App Name");const e=["projectId","apiKey","appId"];for(const t of e)if(!n.options[t])throw lo(t);return{appName:n.name,projectId:n.options.projectId,apiKey:n.options.apiKey,appId:n.options.appId}}function lo(n){return hn.create("missing-app-config-values",{valueName:n})}const id="installations",_y="installations-internal",yy=n=>{const e=n.getProvider("app").getImmediate(),t=gy(e),r=ut(e,"heartbeat");return{app:e,appConfig:t,heartbeatServiceProvider:r,_delete:()=>Promise.resolve()}},Ty=n=>{const e=n.getProvider("app").getImmediate(),t=ut(e,id).getImmediate();return{getId:()=>fy(t),getToken:s=>py(t,s)}};function wy(){Me(new Ne(id,yy,"PUBLIC")),Me(new Ne(_y,Ty,"PRIVATE"))}wy();me($h,fa);me($h,fa,"esm2020");const Cs="analytics",Ey="firebase_id",vy="origin",Iy=60*1e3,Ay="https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig",_a="https://www.googletagmanager.com/gtag/js";const ke=new ai("@firebase/analytics");const by={"already-exists":"A Firebase Analytics instance with the appId {$id} already exists. Only one Firebase Analytics instance can be created for each appId.","already-initialized":"initializeAnalytics() cannot be called again with different options than those it was initially called with. It can be called again with the same options to return the existing instance, or getAnalytics() can be used to get a reference to the already-initialized instance.","already-initialized-settings":"Firebase Analytics has already been initialized.settings() must be called before initializing any Analytics instanceor it will have no effect.","interop-component-reg-failed":"Firebase Analytics Interop Component failed to instantiate: {$reason}","invalid-analytics-context":"Firebase Analytics is not supported in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","indexeddb-unavailable":"IndexedDB unavailable or restricted in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","fetch-throttle":"The config fetch request timed out while in an exponential backoff state. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.","config-fetch-failed":"Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}","no-api-key":'The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid API key.',"no-app-id":'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid app ID.',"no-client-id":'The "client_id" field is empty.',"invalid-gtag-resource":"Trusted Types detected an invalid gtag resource: {$gtagURL}."},Be=new Kt("analytics","Analytics",by);function Sy(n){if(!n.startsWith(_a)){const e=Be.create("invalid-gtag-resource",{gtagURL:n});return ke.warn(e.message),""}return n}function od(n){return Promise.all(n.map(e=>e.catch(t=>t)))}function Ry(n,e){let t;return window.trustedTypes&&(t=window.trustedTypes.createPolicy(n,e)),t}function Py(n,e){const t=Ry("firebase-js-sdk-policy",{createScriptURL:Sy}),r=document.createElement("script"),s=`${_a}?l=${n}&id=${e}`;r.src=t?t?.createScriptURL(s):s,r.async=!0,document.head.appendChild(r)}function Cy(n){let e=[];return Array.isArray(window[n])?e=window[n]:window[n]=e,e}async function ky(n,e,t,r,s,i){const a=r[s];try{if(a)await e[a];else{const u=(await od(t)).find(h=>h.measurementId===s);u&&await e[u.appId]}}catch(c){ke.error(c)}n("config",s,i)}async function Ny(n,e,t,r,s){try{let i=[];if(s&&s.send_to){let a=s.send_to;Array.isArray(a)||(a=[a]);const c=await od(t);for(const u of a){const h=c.find(m=>m.measurementId===u),f=h&&e[h.appId];if(f)i.push(f);else{i=[];break}}}i.length===0&&(i=Object.values(e)),await Promise.all(i),n("event",r,s||{})}catch(i){ke.error(i)}}function Dy(n,e,t,r){async function s(i,...a){try{if(i==="event"){const[c,u]=a;await Ny(n,e,t,c,u)}else if(i==="config"){const[c,u]=a;await ky(n,e,t,r,c,u)}else if(i==="consent"){const[c,u]=a;n("consent",c,u)}else if(i==="get"){const[c,u,h]=a;n("get",c,u,h)}else if(i==="set"){const[c]=a;n("set",c)}else n(i,...a)}catch(c){ke.error(c)}}return s}function Vy(n,e,t,r,s){let i=function(...a){window[r].push(arguments)};return window[s]&&typeof window[s]=="function"&&(i=window[s]),window[s]=Dy(i,n,e,t),{gtagCore:i,wrappedGtag:window[s]}}function Oy(n){const e=window.document.getElementsByTagName("script");for(const t of Object.values(e))if(t.src&&t.src.includes(_a)&&t.src.includes(n))return t;return null}const Ly=30,My=1e3;class xy{constructor(e={},t=My){this.throttleMetadata=e,this.intervalMillis=t}getThrottleMetadata(e){return this.throttleMetadata[e]}setThrottleMetadata(e,t){this.throttleMetadata[e]=t}deleteThrottleMetadata(e){delete this.throttleMetadata[e]}}const ad=new xy;function Fy(n){return new Headers({Accept:"application/json","x-goog-api-key":n})}async function Uy(n){const{appId:e,apiKey:t}=n,r={method:"GET",headers:Fy(t)},s=Ay.replace("{app-id}",e),i=await fetch(s,r);if(i.status!==200&&i.status!==304){let a="";try{const c=await i.json();c.error?.message&&(a=c.error.message)}catch{}throw Be.create("config-fetch-failed",{httpStatus:i.status,responseMessage:a})}return i.json()}async function By(n,e=ad,t){const{appId:r,apiKey:s,measurementId:i}=n.options;if(!r)throw Be.create("no-app-id");if(!s){if(i)return{measurementId:i,appId:r};throw Be.create("no-api-key")}const a=e.getThrottleMetadata(r)||{backoffCount:0,throttleEndTimeMillis:Date.now()},c=new jy;return setTimeout(async()=>{c.abort()},Iy),cd({appId:r,apiKey:s,measurementId:i},a,c,e)}async function cd(n,{throttleEndTimeMillis:e,backoffCount:t},r,s=ad){const{appId:i,measurementId:a}=n;try{await qy(r,e)}catch(c){if(a)return ke.warn(`Timed out fetching this Firebase app's measurement ID from the server. Falling back to the measurement ID ${a} provided in the "measurementId" field in the local Firebase config. [${c?.message}]`),{appId:i,measurementId:a};throw c}try{const c=await Uy(n);return s.deleteThrottleMetadata(i),c}catch(c){const u=c;if(!$y(u)){if(s.deleteThrottleMetadata(i),a)return ke.warn(`Failed to fetch this Firebase app's measurement ID from the server. Falling back to the measurement ID ${a} provided in the "measurementId" field in the local Firebase config. [${u?.message}]`),{appId:i,measurementId:a};throw c}const h=Number(u?.customData?.httpStatus)===503?bl(t,s.intervalMillis,Ly):bl(t,s.intervalMillis),f={throttleEndTimeMillis:Date.now()+h,backoffCount:t+1};return s.setThrottleMetadata(i,f),ke.debug(`Calling attemptFetch again in ${h} millis`),cd(n,f,r,s)}}function qy(n,e){return new Promise((t,r)=>{const s=Math.max(e-Date.now(),0),i=setTimeout(t,s);n.addEventListener(()=>{clearTimeout(i),r(Be.create("fetch-throttle",{throttleEndTimeMillis:e}))})})}function $y(n){if(!(n instanceof $e)||!n.customData)return!1;const e=Number(n.customData.httpStatus);return e===429||e===500||e===503||e===504}class jy{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}async function zy(n,e,t,r,s){if(s&&s.global){n("event",t,r);return}else{const i=await e,a={...r,send_to:i};n("event",t,a)}}async function Hy(n,e,t,r){if(r&&r.global){const s={};for(const i of Object.keys(t))s[`user_properties.${i}`]=t[i];return n("set",s),Promise.resolve()}else{const s=await e;n("config",s,{update:!0,user_properties:t})}}async function Gy(){if(ua())try{await ha()}catch(n){return ke.warn(Be.create("indexeddb-unavailable",{errorInfo:n?.toString()}).message),!1}else return ke.warn(Be.create("indexeddb-unavailable",{errorInfo:"IndexedDB is not available in this environment."}).message),!1;return!0}async function Ky(n,e,t,r,s,i,a){const c=By(n);c.then(y=>{t[y.measurementId]=y.appId,n.options.measurementId&&y.measurementId!==n.options.measurementId&&ke.warn(`The measurement ID in the local Firebase config (${n.options.measurementId}) does not match the measurement ID fetched from the server (${y.measurementId}). To ensure analytics events are always sent to the correct Analytics property, update the measurement ID field in the local config or remove it from the local config.`)}).catch(y=>ke.error(y)),e.push(c);const u=Gy().then(y=>{if(y)return r.getId()}),[h,f]=await Promise.all([c,u]);Oy(i)||Py(i,h.measurementId),s("js",new Date);const m=a?.config??{};return m[vy]="firebase",m.update=!0,f!=null&&(m[Ey]=f),s("config",h.measurementId,m),h.measurementId}class Wy{constructor(e){this.app=e}_delete(){return delete Pn[this.app.options.appId],Promise.resolve()}}let Pn={},Ml=[];const xl={};let uo="dataLayer",Qy="gtag",Fl,ya,Ul=!1;function Jy(){const n=[];if(Lh()&&n.push("This is a browser extension environment."),Mh()||n.push("Cookies are not available."),n.length>0){const e=n.map((r,s)=>`(${s+1}) ${r}`).join(" "),t=Be.create("invalid-analytics-context",{errorInfo:e});ke.warn(t.message)}}function Yy(n,e,t){Jy();const r=n.options.appId;if(!r)throw Be.create("no-app-id");if(!n.options.apiKey)if(n.options.measurementId)ke.warn(`The "apiKey" field is empty in the local Firebase config. This is needed to fetch the latest measurement ID for this Firebase app. Falling back to the measurement ID ${n.options.measurementId} provided in the "measurementId" field in the local Firebase config.`);else throw Be.create("no-api-key");if(Pn[r]!=null)throw Be.create("already-exists",{id:r});if(!Ul){Cy(uo);const{wrappedGtag:i,gtagCore:a}=Vy(Pn,Ml,xl,uo,Qy);ya=i,Fl=a,Ul=!0}return Pn[r]=Ky(n,Ml,xl,e,Fl,uo,t),new Wy(n)}function Xy(n=$n()){n=ee(n);const e=ut(n,Cs);return e.isInitialized()?e.getImmediate():Zy(n)}function Zy(n,e={}){const t=ut(n,Cs);if(t.isInitialized()){const s=t.getImmediate();if(Ut(e,t.getOptions()))return s;throw Be.create("already-initialized")}return t.initialize({options:e})}function eT(n,e,t){n=ee(n),Hy(ya,Pn[n.app.options.appId],e,t).catch(r=>ke.error(r))}function tT(n,e,t,r){n=ee(n),zy(ya,Pn[n.app.options.appId],e,t,r).catch(s=>ke.error(s))}const Bl="@firebase/analytics",ql="0.10.19";function nT(){Me(new Ne(Cs,(e,{options:t})=>{const r=e.getProvider("app").getImmediate(),s=e.getProvider("installations-internal").getImmediate();return Yy(r,s,t)},"PUBLIC")),Me(new Ne("analytics-internal",n,"PRIVATE")),me(Bl,ql),me(Bl,ql,"esm2020");function n(e){try{const t=e.getProvider(Cs).getImmediate();return{logEvent:(r,s,i)=>tT(t,r,s,i),setUserProperties:(r,s)=>eT(t,r,s)}}catch(t){throw Be.create("interop-component-reg-failed",{reason:t})}}}nT();function ld(){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 rT=ld,ud=new Kt("auth","Firebase",ld());const ks=new ai("@firebase/auth");function sT(n,...e){ks.logLevel<=H.WARN&&ks.warn(`Auth (${yn}): ${n}`,...e)}function ms(n,...e){ks.logLevel<=H.ERROR&&ks.error(`Auth (${yn}): ${n}`,...e)}function at(n,...e){throw wa(n,...e)}function Qe(n,...e){return wa(n,...e)}function Ta(n,e,t){const r={...rT(),[e]:t};return new Kt("auth","Firebase",r).create(e,{appName:n.name})}function an(n){return Ta(n,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function iT(n,e,t){const r=t;if(!(e instanceof r))throw r.name!==e.constructor.name&&at(n,"argument-error"),Ta(n,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function wa(n,...e){if(typeof n!="string"){const t=e[0],r=[...e.slice(1)];return r[0]&&(r[0].appName=n.name),n._errorFactory.create(t,...r)}return ud.create(n,...e)}function F(n,e,...t){if(!n)throw wa(e,...t)}function pt(n){const e="INTERNAL ASSERTION FAILED: "+n;throw ms(e),new Error(e)}function Tt(n,e){n||pt(e)}function Do(){return typeof self<"u"&&self.location?.href||""}function oT(){return $l()==="http:"||$l()==="https:"}function $l(){return typeof self<"u"&&self.location?.protocol||null}function aT(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(oT()||Lh()||"connection"in navigator)?navigator.onLine:!0}function cT(){if(typeof navigator>"u")return null;const n=navigator;return n.languages&&n.languages[0]||n.language||null}class xr{constructor(e,t){this.shortDelay=e,this.longDelay=t,Tt(t>e,"Short delay should be less than long delay!"),this.isMobile=ug()||fg()}get(){return aT()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}function Ea(n,e){Tt(n.emulator,"Emulator should always be set here");const{url:t}=n.emulator;return e?`${t}${e.startsWith("/")?e.slice(1):e}`:t}class hd{static initialize(e,t,r){this.fetchImpl=e,t&&(this.headersImpl=t),r&&(this.responseImpl=r)}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;pt("Could not find fetch implementation, make sure you call FetchProvider.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;pt("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;pt("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}const lT={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 uT=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],hT=new xr(3e4,6e4);function va(n,e){return n.tenantId&&!e.tenantId?{...e,tenantId:n.tenantId}:e}async function jn(n,e,t,r,s={}){return dd(n,s,async()=>{let i={},a={};r&&(e==="GET"?a=r:i={body:JSON.stringify(r)});const c=Mr({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 h={method:e,headers:u,...i};return dg()||(h.referrerPolicy="no-referrer"),n.emulatorConfig&&vt(n.emulatorConfig.host)&&(h.credentials="include"),hd.fetch()(await fd(n,n.config.apiHost,t,c),h)})}async function dd(n,e,t){n._canInitEmulator=!1;const r={...lT,...e};try{const s=new fT(n),i=await Promise.race([t(),s.promise]);s.clearNetworkTimeout();const a=await i.json();if("needConfirmation"in a)throw cs(n,"account-exists-with-different-credential",a);if(i.ok&&!("errorMessage"in a))return a;{const c=i.ok?a.errorMessage:a.error.message,[u,h]=c.split(" : ");if(u==="FEDERATED_USER_ID_ALREADY_LINKED")throw cs(n,"credential-already-in-use",a);if(u==="EMAIL_EXISTS")throw cs(n,"email-already-in-use",a);if(u==="USER_DISABLED")throw cs(n,"user-disabled",a);const f=r[u]||u.toLowerCase().replace(/[_\s]+/g,"-");if(h)throw Ta(n,f,h);at(n,f)}}catch(s){if(s instanceof $e)throw s;at(n,"network-request-failed",{message:String(s)})}}async function dT(n,e,t,r,s={}){const i=await jn(n,e,t,r,s);return"mfaPendingCredential"in i&&at(n,"multi-factor-auth-required",{_serverResponse:i}),i}async function fd(n,e,t,r){const s=`${e}${t}?${r}`,i=n,a=i.config.emulator?Ea(n.config,s):`${n.config.apiScheme}://${s}`;return uT.includes(t)&&(await i._persistenceManagerAvailable,i._getPersistenceType()==="COOKIE")?i._getPersistence()._getFinalTarget(a).toString():a}class fT{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((t,r)=>{this.timer=setTimeout(()=>r(Qe(this.auth,"network-request-failed")),hT.get())})}}function cs(n,e,t){const r={appName:n.name};t.email&&(r.email=t.email),t.phoneNumber&&(r.phoneNumber=t.phoneNumber);const s=Qe(n,e,r);return s.customData._tokenResponse=t,s}async function pT(n,e){return jn(n,"POST","/v1/accounts:delete",e)}async function Ns(n,e){return jn(n,"POST","/v1/accounts:lookup",e)}function yr(n){if(n)try{const e=new Date(Number(n));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function mT(n,e=!1){const t=ee(n),r=await t.getIdToken(e),s=Ia(r);F(s&&s.exp&&s.auth_time&&s.iat,t.auth,"internal-error");const i=typeof s.firebase=="object"?s.firebase:void 0,a=i?.sign_in_provider;return{claims:s,token:r,authTime:yr(ho(s.auth_time)),issuedAtTime:yr(ho(s.iat)),expirationTime:yr(ho(s.exp)),signInProvider:a||null,signInSecondFactor:i?.sign_in_second_factor||null}}function ho(n){return Number(n)*1e3}function Ia(n){const[e,t,r]=n.split(".");if(e===void 0||t===void 0||r===void 0)return ms("JWT malformed, contained fewer than 3 sections"),null;try{const s=kh(t);return s?JSON.parse(s):(ms("Failed to decode base64 JWT payload"),null)}catch(s){return ms("Caught error parsing JWT payload as JSON",s?.toString()),null}}function jl(n){const e=Ia(n);return F(e,"internal-error"),F(typeof e.exp<"u","internal-error"),F(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}async function Sr(n,e,t=!1){if(t)return e;try{return await e}catch(r){throw r instanceof $e&&gT(r)&&n.auth.currentUser===n&&await n.auth.signOut(),r}}function gT({code:n}){return n==="auth/user-disabled"||n==="auth/user-token-expired"}class _T{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 r=(this.user.stsTokenManager.expirationTime??0)-Date.now()-3e5;return Math.max(0,r)}}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 Vo{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=yr(this.lastLoginAt),this.creationTime=yr(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function Ds(n){const e=n.auth,t=await n.getIdToken(),r=await Sr(n,Ns(e,{idToken:t}));F(r?.users.length,e,"internal-error");const s=r.users[0];n._notifyReloadListener(s);const i=s.providerUserInfo?.length?pd(s.providerUserInfo):[],a=TT(n.providerData,i),c=n.isAnonymous,u=!(n.email&&s.passwordHash)&&!a?.length,h=c?u:!1,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:a,metadata:new Vo(s.createdAt,s.lastLoginAt),isAnonymous:h};Object.assign(n,f)}async function yT(n){const e=ee(n);await Ds(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function TT(n,e){return[...n.filter(r=>!e.some(s=>s.providerId===r.providerId)),...e]}function pd(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 wT(n,e){const t=await dd(n,{},async()=>{const r=Mr({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:s,apiKey:i}=n.config,a=await fd(n,s,"/v1/token",`key=${i}`),c=await n._getAdditionalHeaders();c["Content-Type"]="application/x-www-form-urlencoded";const u={method:"POST",headers:c,body:r};return n.emulatorConfig&&vt(n.emulatorConfig.host)&&(u.credentials="include"),hd.fetch()(a,u)});return{accessToken:t.access_token,expiresIn:t.expires_in,refreshToken:t.refresh_token}}async function ET(n,e){return jn(n,"POST","/v2/accounts:revokeToken",va(n,e))}class Cn{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){F(e.idToken,"internal-error"),F(typeof e.idToken<"u","internal-error"),F(typeof e.refreshToken<"u","internal-error");const t="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):jl(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){F(e.length!==0,"internal-error");const t=jl(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(F(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:r,refreshToken:s,expiresIn:i}=await wT(e,t);this.updateTokensAndExpiration(r,s,Number(i))}updateTokensAndExpiration(e,t,r){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+r*1e3}static fromJSON(e,t){const{refreshToken:r,accessToken:s,expirationTime:i}=t,a=new Cn;return r&&(F(typeof r=="string","internal-error",{appName:e}),a.refreshToken=r),s&&(F(typeof s=="string","internal-error",{appName:e}),a.accessToken=s),i&&(F(typeof i=="number","internal-error",{appName:e}),a.expirationTime=i),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 Cn,this.toJSON())}_performRefresh(){return pt("not implemented")}}function kt(n,e){F(typeof n=="string"||typeof n>"u","internal-error",{appName:e})}class Ke{constructor({uid:e,auth:t,stsTokenManager:r,...s}){this.providerId="firebase",this.proactiveRefresh=new _T(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=t,this.stsTokenManager=r,this.accessToken=r.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 Vo(s.createdAt||void 0,s.lastLoginAt||void 0)}async getIdToken(e){const t=await Sr(this,this.stsTokenManager.getToken(this.auth,e));return F(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return mT(this,e)}reload(){return yT(this)}_assign(e){this!==e&&(F(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 Ke({...this,auth:e,stsTokenManager:this.stsTokenManager._clone()});return t.metadata._copy(this.metadata),t}_onReload(e){F(!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 r=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),r=!0),t&&await Ds(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(Fe(this.auth.app))return Promise.reject(an(this.auth));const e=await this.getIdToken();return await Sr(this,pT(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 r=t.displayName??void 0,s=t.email??void 0,i=t.phoneNumber??void 0,a=t.photoURL??void 0,c=t.tenantId??void 0,u=t._redirectEventId??void 0,h=t.createdAt??void 0,f=t.lastLoginAt??void 0,{uid:m,emailVerified:y,isAnonymous:S,providerData:k,stsTokenManager:V}=t;F(m&&V,e,"internal-error");const N=Cn.fromJSON(this.name,V);F(typeof m=="string",e,"internal-error"),kt(r,e.name),kt(s,e.name),F(typeof y=="boolean",e,"internal-error"),F(typeof S=="boolean",e,"internal-error"),kt(i,e.name),kt(a,e.name),kt(c,e.name),kt(u,e.name),kt(h,e.name),kt(f,e.name);const $=new Ke({uid:m,auth:e,email:s,emailVerified:y,displayName:r,isAnonymous:S,photoURL:a,phoneNumber:i,tenantId:c,stsTokenManager:N,createdAt:h,lastLoginAt:f});return k&&Array.isArray(k)&&($.providerData=k.map(W=>({...W}))),u&&($._redirectEventId=u),$}static async _fromIdTokenResponse(e,t,r=!1){const s=new Cn;s.updateFromServerResponse(t);const i=new Ke({uid:t.localId,auth:e,stsTokenManager:s,isAnonymous:r});return await Ds(i),i}static async _fromGetAccountInfoResponse(e,t,r){const s=t.users[0];F(s.localId!==void 0,"internal-error");const i=s.providerUserInfo!==void 0?pd(s.providerUserInfo):[],a=!(s.email&&s.passwordHash)&&!i?.length,c=new Cn;c.updateFromIdToken(r);const u=new Ke({uid:s.localId,auth:e,stsTokenManager:c,isAnonymous:a}),h={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:i,metadata:new Vo(s.createdAt,s.lastLoginAt),isAnonymous:!(s.email&&s.passwordHash)&&!i?.length};return Object.assign(u,h),u}}const zl=new Map;function mt(n){Tt(n instanceof Function,"Expected a class definition");let e=zl.get(n);return e?(Tt(e instanceof n,"Instance stored in cache mismatched with class"),e):(e=new n,zl.set(n,e),e)}class md{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){}}md.type="NONE";const Hl=md;function gs(n,e,t){return`firebase:${n}:${e}:${t}`}class kn{constructor(e,t,r){this.persistence=e,this.auth=t,this.userKey=r;const{config:s,name:i}=this.auth;this.fullUserKey=gs(this.userKey,s.apiKey,i),this.fullPersistenceKey=gs("persistence",s.apiKey,i),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);if(!e)return null;if(typeof e=="string"){const t=await Ns(this.auth,{idToken:e}).catch(()=>{});return t?Ke._fromGetAccountInfoResponse(this.auth,t,e):null}return Ke._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,r="authUser"){if(!t.length)return new kn(mt(Hl),e,r);const s=(await Promise.all(t.map(async h=>{if(await h._isAvailable())return h}))).filter(h=>h);let i=s[0]||mt(Hl);const a=gs(r,e.config.apiKey,e.name);let c=null;for(const h of t)try{const f=await h._get(a);if(f){let m;if(typeof f=="string"){const y=await Ns(e,{idToken:f}).catch(()=>{});if(!y)break;m=await Ke._fromGetAccountInfoResponse(e,y,f)}else m=Ke._fromJSON(e,f);h!==i&&(c=m),i=h;break}}catch{}const u=s.filter(h=>h._shouldAllowMigration);return!i._shouldAllowMigration||!u.length?new kn(i,e,r):(i=u[0],c&&await i._set(a,c.toJSON()),await Promise.all(t.map(async h=>{if(h!==i)try{await h._remove(a)}catch{}})),new kn(i,e,r))}}function Gl(n){const e=n.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(Td(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(gd(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(Ed(e))return"Blackberry";if(vd(e))return"Webos";if(_d(e))return"Safari";if((e.includes("chrome/")||yd(e))&&!e.includes("edge/"))return"Chrome";if(wd(e))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,r=n.match(t);if(r?.length===2)return r[1]}return"Other"}function gd(n=Se()){return/firefox\//i.test(n)}function _d(n=Se()){const e=n.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function yd(n=Se()){return/crios\//i.test(n)}function Td(n=Se()){return/iemobile/i.test(n)}function wd(n=Se()){return/android/i.test(n)}function Ed(n=Se()){return/blackberry/i.test(n)}function vd(n=Se()){return/webos/i.test(n)}function Aa(n=Se()){return/iphone|ipad|ipod/i.test(n)||/macintosh/i.test(n)&&/mobile/i.test(n)}function vT(n=Se()){return Aa(n)&&!!window.navigator?.standalone}function IT(){return pg()&&document.documentMode===10}function Id(n=Se()){return Aa(n)||wd(n)||vd(n)||Ed(n)||/windows phone/i.test(n)||Td(n)}function Ad(n,e=[]){let t;switch(n){case"Browser":t=Gl(Se());break;case"Worker":t=`${Gl(Se())}-${n}`;break;default:t=n}const r=e.length?e.join(","):"FirebaseCore-web";return`${t}/JsCore/${yn}/${r}`}class AT{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const r=i=>new Promise((a,c)=>{try{const u=e(i);a(u)}catch(u){c(u)}});r.onAbort=t,this.queue.push(r);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 r of this.queue)await r(e),r.onAbort&&t.push(r.onAbort)}catch(r){t.reverse();for(const s of t)try{s()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:r?.message})}}}async function bT(n,e={}){return jn(n,"GET","/v2/passwordPolicy",va(n,e))}const ST=6;class RT{constructor(e){const t=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=t.minPasswordLength??ST,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&&(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 r=this.customStrengthOptions.minPasswordLength,s=this.customStrengthOptions.maxPasswordLength;r&&(t.meetsMinPasswordLength=e.length>=r),s&&(t.meetsMaxPasswordLength=e.length<=s)}validatePasswordCharacterOptions(e,t){this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);let r;for(let s=0;s<e.length;s++)r=e.charAt(s),this.updatePasswordCharacterOptionsStatuses(t,r>="a"&&r<="z",r>="A"&&r<="Z",r>="0"&&r<="9",this.allowedNonAlphanumericCharacters.includes(r))}updatePasswordCharacterOptionsStatuses(e,t,r,s,i){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=r)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=s)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=i))}}class PT{constructor(e,t,r,s){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=r,this.config=s,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new Kl(this),this.idTokenSubscription=new Kl(this),this.beforeStateQueue=new AT(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=ud,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(i=>this._resolvePersistenceManagerAvailable=i)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=mt(t)),this._initializationPromise=this.queue(async()=>{if(!this._deleted&&(this.persistenceManager=await kn.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 Ns(this,{idToken:e}),r=await Ke._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(r)}catch(t){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",t),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){if(Fe(this.app)){const i=this.app.settings.authIdToken;return i?new Promise(a=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(i).then(a,a))}):this.directlySetCurrentUser(null)}const t=await this.assertedPersistence.getCurrentUser();let r=t,s=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const i=this.redirectUser?._redirectEventId,a=r?._redirectEventId,c=await this.tryRedirectSignIn(e);(!i||i===a)&&c?.user&&(r=c.user,s=!0)}if(!r)return this.directlySetCurrentUser(null);if(!r._redirectEventId){if(s)try{await this.beforeStateQueue.runMiddleware(r)}catch(i){r=t,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(i))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return F(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===r._redirectEventId?this.directlySetCurrentUser(r):this.reloadAndSetCurrentUserOrClear(r)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await Ds(e)}catch(t){if(t?.code!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=cT()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(Fe(this.app))return Promise.reject(an(this));const t=e?ee(e):null;return t&&F(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&&F(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 Fe(this.app)?Promise.reject(an(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return Fe(this.app)?Promise.reject(an(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(mt(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 bT(this),t=new RT(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 Kt("auth","Firebase",e())}onAuthStateChanged(e,t,r){return this.registerStateListener(this.authStateSubscription,e,t,r)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,r){return this.registerStateListener(this.idTokenSubscription,e,t,r)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{const r=this.onAuthStateChanged(()=>{r(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){const t=await this.currentUser.getIdToken(),r={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:t};this.tenantId!=null&&(r.tenantId=this.tenantId),await ET(this,r)}}toJSON(){return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:this._currentUser?.toJSON()}}async _setRedirectUser(e,t){const r=await this.getOrInitRedirectPersistenceManager(t);return e===null?r.removeCurrentUser():r.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&mt(e)||this._popupRedirectResolver;F(t,this,"argument-error"),this.redirectPersistenceManager=await kn.create(this,[mt(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,r,s){if(this._deleted)return()=>{};const i=typeof t=="function"?t:t.next.bind(t);let a=!1;const c=this._isInitialized?Promise.resolve():this._initializationPromise;if(F(c,this,"internal-error"),c.then(()=>{a||i(this.currentUser)}),typeof t=="function"){const u=e.addObserver(t,r,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 F(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=Ad(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 r=await this._getAppCheckToken();return r&&(e["X-Firebase-AppCheck"]=r),e}async _getAppCheckToken(){if(Fe(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=await this.appCheckServiceProvider.getImmediate({optional:!0})?.getToken();return e?.error&&sT(`Error while retrieving App Check token: ${e.error}`),e?.token}}function hi(n){return ee(n)}class Kl{constructor(e){this.auth=e,this.observer=null,this.addObserver=wg(t=>this.observer=t)}get next(){return F(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}let ba={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function CT(n){ba=n}function kT(n){return ba.loadJS(n)}function NT(){return ba.gapiScript}function DT(n){return`__${n}${Math.floor(Math.random()*1e6)}`}function VT(n,e){const t=ut(n,"auth");if(t.isInitialized()){const s=t.getImmediate(),i=t.getOptions();if(Ut(i,e??{}))return s;at(s,"already-initialized")}return t.initialize({options:e})}function OT(n,e){const t=e?.persistence||[],r=(Array.isArray(t)?t:[t]).map(mt);e?.errorMap&&n._updateErrorMap(e.errorMap),n._initializeWithPersistence(r,e?.popupRedirectResolver)}function bd(n,e,t){const r=hi(n);F(/^https?:\/\//.test(e),r,"invalid-emulator-scheme");const s=!1,i=Sd(e),{host:a,port:c}=LT(e),u=c===null?"":`:${c}`,h={url:`${i}//${a}${u}/`},f=Object.freeze({host:a,port:c,protocol:i.replace(":",""),options:Object.freeze({disableWarnings:s})});if(!r._canInitEmulator){F(r.config.emulator&&r.emulatorConfig,r,"emulator-config-failed"),F(Ut(h,r.config.emulator)&&Ut(f,r.emulatorConfig),r,"emulator-config-failed");return}r.config.emulator=h,r.emulatorConfig=f,r.settings.appVerificationDisabledForTesting=!0,vt(a)?(ii(`${i}//${a}${u}`),oi("Auth",!0)):MT()}function Sd(n){const e=n.indexOf(":");return e<0?"":n.substr(0,e+1)}function LT(n){const e=Sd(n),t=/(\/\/)?([^?#/]+)/.exec(n.substr(e.length));if(!t)return{host:"",port:null};const r=t[2].split("@").pop()||"",s=/^(\[[^\]]+\])(:|$)/.exec(r);if(s){const i=s[1];return{host:i,port:Wl(r.substr(i.length+1))}}else{const[i,a]=r.split(":");return{host:i,port:Wl(a)}}}function Wl(n){if(!n)return null;const e=Number(n);return isNaN(e)?null:e}function MT(){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 Rd{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return pt("not implemented")}_getIdTokenResponse(e){return pt("not implemented")}_linkToIdToken(e,t){return pt("not implemented")}_getReauthenticationResolver(e){return pt("not implemented")}}async function Nn(n,e){return dT(n,"POST","/v1/accounts:signInWithIdp",va(n,e))}const xT="http://localhost";class fn extends Rd{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new fn(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):at("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:r,signInMethod:s,...i}=t;if(!r||!s)return null;const a=new fn(r,s);return a.idToken=i.idToken||void 0,a.accessToken=i.accessToken||void 0,a.secret=i.secret,a.nonce=i.nonce,a.pendingToken=i.pendingToken||null,a}_getIdTokenResponse(e){const t=this.buildRequest();return Nn(e,t)}_linkToIdToken(e,t){const r=this.buildRequest();return r.idToken=t,Nn(e,r)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,Nn(e,t)}buildRequest(){const e={requestUri:xT,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=Mr(t)}return e}}class Sa{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 Fr extends Sa{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class Dt extends Fr{constructor(){super("facebook.com")}static credential(e){return fn._fromParams({providerId:Dt.PROVIDER_ID,signInMethod:Dt.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Dt.credentialFromTaggedObject(e)}static credentialFromError(e){return Dt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Dt.credential(e.oauthAccessToken)}catch{return null}}}Dt.FACEBOOK_SIGN_IN_METHOD="facebook.com";Dt.PROVIDER_ID="facebook.com";class ft extends Fr{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return fn._fromParams({providerId:ft.PROVIDER_ID,signInMethod:ft.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return ft.credentialFromTaggedObject(e)}static credentialFromError(e){return ft.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:r}=e;if(!t&&!r)return null;try{return ft.credential(t,r)}catch{return null}}}ft.GOOGLE_SIGN_IN_METHOD="google.com";ft.PROVIDER_ID="google.com";class Vt extends Fr{constructor(){super("github.com")}static credential(e){return fn._fromParams({providerId:Vt.PROVIDER_ID,signInMethod:Vt.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Vt.credentialFromTaggedObject(e)}static credentialFromError(e){return Vt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Vt.credential(e.oauthAccessToken)}catch{return null}}}Vt.GITHUB_SIGN_IN_METHOD="github.com";Vt.PROVIDER_ID="github.com";class Ot extends Fr{constructor(){super("twitter.com")}static credential(e,t){return fn._fromParams({providerId:Ot.PROVIDER_ID,signInMethod:Ot.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return Ot.credentialFromTaggedObject(e)}static credentialFromError(e){return Ot.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:r}=e;if(!t||!r)return null;try{return Ot.credential(t,r)}catch{return null}}}Ot.TWITTER_SIGN_IN_METHOD="twitter.com";Ot.PROVIDER_ID="twitter.com";class On{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,r,s=!1){const i=await Ke._fromIdTokenResponse(e,r,s),a=Ql(r);return new On({user:i,providerId:a,_tokenResponse:r,operationType:t})}static async _forOperation(e,t,r){await e._updateTokensIfNecessary(r,!0);const s=Ql(r);return new On({user:e,providerId:s,_tokenResponse:r,operationType:t})}}function Ql(n){return n.providerId?n.providerId:"phoneNumber"in n?"phone":null}class Vs extends $e{constructor(e,t,r,s){super(t.code,t.message),this.operationType=r,this.user=s,Object.setPrototypeOf(this,Vs.prototype),this.customData={appName:e.name,tenantId:e.tenantId??void 0,_serverResponse:t.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(e,t,r,s){return new Vs(e,t,r,s)}}function Pd(n,e,t,r){return(e==="reauthenticate"?t._getReauthenticationResolver(n):t._getIdTokenResponse(n)).catch(i=>{throw i.code==="auth/multi-factor-auth-required"?Vs._fromErrorAndOperation(n,i,e,r):i})}async function FT(n,e,t=!1){const r=await Sr(n,e._linkToIdToken(n.auth,await n.getIdToken()),t);return On._forOperation(n,"link",r)}async function UT(n,e,t=!1){const{auth:r}=n;if(Fe(r.app))return Promise.reject(an(r));const s="reauthenticate";try{const i=await Sr(n,Pd(r,s,e,n),t);F(i.idToken,r,"internal-error");const a=Ia(i.idToken);F(a,r,"internal-error");const{sub:c}=a;return F(n.uid===c,r,"user-mismatch"),On._forOperation(n,s,i)}catch(i){throw i?.code==="auth/user-not-found"&&at(r,"user-mismatch"),i}}async function BT(n,e,t=!1){if(Fe(n.app))return Promise.reject(an(n));const r="signIn",s=await Pd(n,r,e),i=await On._fromIdTokenResponse(n,r,s);return t||await n._updateCurrentUser(i.user),i}function qT(n,e,t,r){return ee(n).onIdTokenChanged(e,t,r)}function $T(n,e,t){return ee(n).beforeAuthStateChanged(e,t)}const Os="__sak";class Cd{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Os,"1"),this.storage.removeItem(Os),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 jT=1e3,zT=10;class kd extends Cd{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=Id(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const r=this.storage.getItem(t),s=this.localCache[t];r!==s&&e(t,s,r)}}onStorageEvent(e,t=!1){if(!e.key){this.forAllChangedKeys((a,c,u)=>{this.notifyListeners(a,u)});return}const r=e.key;t?this.detachListener():this.stopPolling();const s=()=>{const a=this.storage.getItem(r);!t&&this.localCache[r]===a||this.notifyListeners(r,a)},i=this.storage.getItem(r);IT()&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(s,zT):s()}notifyListeners(e,t){this.localCache[e]=t;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(t&&JSON.parse(t))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,r)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:r}),!0)})},jT)}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]),Object.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]}}kd.type="LOCAL";const HT=kd;class Nd extends Cd{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}Nd.type="SESSION";const Dd=Nd;function GT(n){return Promise.all(n.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(t){return{fulfilled:!1,reason:t}}}))}class di{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 r=new di(e);return this.receivers.push(r),r}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:r,eventType:s,data:i}=t.data,a=this.handlersMap[s];if(!a?.size)return;t.ports[0].postMessage({status:"ack",eventId:r,eventType:s});const c=Array.from(a).map(async h=>h(t.origin,i)),u=await GT(c);t.ports[0].postMessage({status:"done",eventId:r,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)}}di.receivers=[];function Ra(n="",e=10){let t="";for(let r=0;r<e;r++)t+=Math.floor(Math.random()*10);return n+t}class KT{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,r=50){const s=typeof MessageChannel<"u"?new MessageChannel:null;if(!s)throw new Error("connection_unavailable");let i,a;return new Promise((c,u)=>{const h=Ra("",20);s.port1.start();const f=setTimeout(()=>{u(new Error("unsupported_event"))},r);a={messageChannel:s,onMessage(m){const y=m;if(y.data.eventId===h)switch(y.data.status){case"ack":clearTimeout(f),i=setTimeout(()=>{u(new Error("timeout"))},3e3);break;case"done":clearTimeout(i),c(y.data.response);break;default:clearTimeout(f),clearTimeout(i),u(new Error("invalid_response"));break}}},this.handlers.add(a),s.port1.addEventListener("message",a.onMessage),this.target.postMessage({eventType:e,eventId:h,data:t},[s.port2])}).finally(()=>{a&&this.removeMessageHandler(a)})}}function rt(){return window}function WT(n){rt().location.href=n}function Vd(){return typeof rt().WorkerGlobalScope<"u"&&typeof rt().importScripts=="function"}async function QT(){if(!navigator?.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function JT(){return navigator?.serviceWorker?.controller||null}function YT(){return Vd()?self:null}const Od="firebaseLocalStorageDb",XT=1,Ls="firebaseLocalStorage",Ld="fbase_key";class Ur{constructor(e){this.request=e}toPromise(){return new Promise((e,t)=>{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{t(this.request.error)})})}}function fi(n,e){return n.transaction([Ls],e?"readwrite":"readonly").objectStore(Ls)}function ZT(){const n=indexedDB.deleteDatabase(Od);return new Ur(n).toPromise()}function Oo(){const n=indexedDB.open(Od,XT);return new Promise((e,t)=>{n.addEventListener("error",()=>{t(n.error)}),n.addEventListener("upgradeneeded",()=>{const r=n.result;try{r.createObjectStore(Ls,{keyPath:Ld})}catch(s){t(s)}}),n.addEventListener("success",async()=>{const r=n.result;r.objectStoreNames.contains(Ls)?e(r):(r.close(),await ZT(),e(await Oo()))})})}async function Jl(n,e,t){const r=fi(n,!0).put({[Ld]:e,value:t});return new Ur(r).toPromise()}async function ew(n,e){const t=fi(n,!1).get(e),r=await new Ur(t).toPromise();return r===void 0?null:r.value}function Yl(n,e){const t=fi(n,!0).delete(e);return new Ur(t).toPromise()}const tw=800,nw=3;class Md{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 Oo(),this.db)}async _withRetries(e){let t=0;for(;;)try{const r=await this._openDb();return await e(r)}catch(r){if(t++>nw)throw r;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return Vd()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=di._getInstance(YT()),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 QT(),!this.activeServiceWorker)return;this.sender=new KT(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||JT()!==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 Oo();return await Jl(e,Os,"1"),await Yl(e,Os),!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(r=>Jl(r,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){const t=await this._withRetries(r=>ew(r,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>Yl(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(s=>{const i=fi(s,!1).getAll();return new Ur(i).toPromise()});if(!e)return[];if(this.pendingWrites!==0)return[];const t=[],r=new Set;if(e.length!==0)for(const{fbase_key:s,value:i}of e)r.add(s),JSON.stringify(this.localCache[s])!==JSON.stringify(i)&&(this.notifyListeners(s,i),t.push(s));for(const s of Object.keys(this.localCache))this.localCache[s]&&!r.has(s)&&(this.notifyListeners(s,null),t.push(s));return t}notifyListeners(e,t){this.localCache[e]=t;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),tw)}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]),Object.keys(this.listeners).length===0&&this.stopPolling()}}Md.type="LOCAL";const rw=Md;new xr(3e4,6e4);function xd(n,e){return e?mt(e):(F(n._popupRedirectResolver,n,"argument-error"),n._popupRedirectResolver)}class Pa extends Rd{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return Nn(e,this._buildIdpRequest())}_linkToIdToken(e,t){return Nn(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return Nn(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 sw(n){return BT(n.auth,new Pa(n),n.bypassAuthState)}function iw(n){const{auth:e,user:t}=n;return F(t,e,"internal-error"),UT(t,new Pa(n),n.bypassAuthState)}async function ow(n){const{auth:e,user:t}=n;return F(t,e,"internal-error"),FT(t,new Pa(n),n.bypassAuthState)}class Fd{constructor(e,t,r,s,i=!1){this.auth=e,this.resolver=r,this.user=s,this.bypassAuthState=i,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(r){this.reject(r)}})}async onAuthEvent(e){const{urlResponse:t,sessionId:r,postBody:s,tenantId:i,error:a,type:c}=e;if(a){this.reject(a);return}const u={auth:this.auth,requestUri:t,sessionId:r,tenantId:i||void 0,postBody:s||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(c)(u))}catch(h){this.reject(h)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return sw;case"linkViaPopup":case"linkViaRedirect":return ow;case"reauthViaPopup":case"reauthViaRedirect":return iw;default:at(this.auth,"internal-error")}}resolve(e){Tt(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){Tt(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 aw=new xr(2e3,1e4);async function cw(n,e,t){if(Fe(n.app))return Promise.reject(Qe(n,"operation-not-supported-in-this-environment"));const r=hi(n);iT(n,e,Sa);const s=xd(r,t);return new sn(r,"signInViaPopup",e,s).executeNotNull()}class sn extends Fd{constructor(e,t,r,s,i){super(e,t,s,i),this.provider=r,this.authWindow=null,this.pollId=null,sn.currentPopupAction&&sn.currentPopupAction.cancel(),sn.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return F(e,this.auth,"internal-error"),e}async onExecution(){Tt(this.filter.length===1,"Popup operations only handle one event");const e=Ra();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(Qe(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){return this.authWindow?.associatedEvent||null}cancel(){this.reject(Qe(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,sn.currentPopupAction=null}pollUserCancellation(){const e=()=>{if(this.authWindow?.window?.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(Qe(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,aw.get())};e()}}sn.currentPopupAction=null;const lw="pendingRedirect",_s=new Map;class uw extends Fd{constructor(e,t,r=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,r),this.eventId=null}async execute(){let e=_s.get(this.auth._key());if(!e){try{const r=await hw(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(r)}catch(t){e=()=>Promise.reject(t)}_s.set(this.auth._key(),e)}return this.bypassAuthState||_s.set(this.auth._key(),()=>Promise.resolve(null)),e()}async 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 hw(n,e){const t=pw(e),r=fw(n);if(!await r._isAvailable())return!1;const s=await r._get(t)==="true";return await r._remove(t),s}function dw(n,e){_s.set(n._key(),e)}function fw(n){return mt(n._redirectPersistence)}function pw(n){return gs(lw,n.config.apiKey,n.name)}async function mw(n,e,t=!1){if(Fe(n.app))return Promise.reject(an(n));const r=hi(n),s=xd(r,e),a=await new uw(r,s,t).execute();return a&&!t&&(delete a.user._redirectEventId,await r._persistUserIfCurrent(a.user),await r._setRedirectUser(null,e)),a}const gw=600*1e3;class _w{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(r=>{this.isEventForConsumer(e,r)&&(t=!0,this.sendToConsumer(e,r),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!yw(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){if(e.error&&!Ud(e)){const r=e.error.code?.split("auth/")[1]||"internal-error";t.onError(Qe(this.auth,r))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const r=t.eventId===null||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&r}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=gw&&this.cachedEventUids.clear(),this.cachedEventUids.has(Xl(e))}saveEventToCache(e){this.cachedEventUids.add(Xl(e)),this.lastProcessedEventTime=Date.now()}}function Xl(n){return[n.type,n.eventId,n.sessionId,n.tenantId].filter(e=>e).join("-")}function Ud({type:n,error:e}){return n==="unknown"&&e?.code==="auth/no-auth-event"}function yw(n){switch(n.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return Ud(n);default:return!1}}async function Tw(n,e={}){return jn(n,"GET","/v1/projects",e)}const ww=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,Ew=/^https?/;async function vw(n){if(n.config.emulator)return;const{authorizedDomains:e}=await Tw(n);for(const t of e)try{if(Iw(t))return}catch{}at(n,"unauthorized-domain")}function Iw(n){const e=Do(),{protocol:t,hostname:r}=new URL(e);if(n.startsWith("chrome-extension://")){const a=new URL(n);return a.hostname===""&&r===""?t==="chrome-extension:"&&n.replace("chrome-extension://","")===e.replace("chrome-extension://",""):t==="chrome-extension:"&&a.hostname===r}if(!Ew.test(t))return!1;if(ww.test(n))return r===n;const s=n.replace(/\./g,"\\.");return new RegExp("^(.+\\."+s+"|"+s+")$","i").test(r)}const Aw=new xr(3e4,6e4);function Zl(){const n=rt().___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 bw(n){return new Promise((e,t)=>{function r(){Zl(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{Zl(),t(Qe(n,"network-request-failed"))},timeout:Aw.get()})}if(rt().gapi?.iframes?.Iframe)e(gapi.iframes.getContext());else if(rt().gapi?.load)r();else{const s=DT("iframefcb");return rt()[s]=()=>{gapi.load?r():t(Qe(n,"network-request-failed"))},kT(`${NT()}?onload=${s}`).catch(i=>t(i))}}).catch(e=>{throw ys=null,e})}let ys=null;function Sw(n){return ys=ys||bw(n),ys}const Rw=new xr(5e3,15e3),Pw="__/auth/iframe",Cw="emulator/auth/iframe",kw={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},Nw=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function Dw(n){const e=n.config;F(e.authDomain,n,"auth-domain-config-required");const t=e.emulator?Ea(e,Cw):`https://${n.config.authDomain}/${Pw}`,r={apiKey:e.apiKey,appName:n.name,v:yn},s=Nw.get(n.config.apiHost);s&&(r.eid=s);const i=n._getFrameworks();return i.length&&(r.fw=i.join(",")),`${t}?${Mr(r).slice(1)}`}async function Vw(n){const e=await Sw(n),t=rt().gapi;return F(t,n,"internal-error"),e.open({where:document.body,url:Dw(n),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:kw,dontclear:!0},r=>new Promise(async(s,i)=>{await r.restyle({setHideOnLeave:!1});const a=Qe(n,"network-request-failed"),c=rt().setTimeout(()=>{i(a)},Rw.get());function u(){rt().clearTimeout(c),s(r)}r.ping(u).then(u,()=>{i(a)})}))}const Ow={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},Lw=500,Mw=600,xw="_blank",Fw="http://localhost";class eu{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function Uw(n,e,t,r=Lw,s=Mw){const i=Math.max((window.screen.availHeight-s)/2,0).toString(),a=Math.max((window.screen.availWidth-r)/2,0).toString();let c="";const u={...Ow,width:r.toString(),height:s.toString(),top:i,left:a},h=Se().toLowerCase();t&&(c=yd(h)?xw:t),gd(h)&&(e=e||Fw,u.scrollbars="yes");const f=Object.entries(u).reduce((y,[S,k])=>`${y}${S}=${k},`,"");if(vT(h)&&c!=="_self")return Bw(e||"",c),new eu(null);const m=window.open(e||"",c,f);F(m,n,"popup-blocked");try{m.focus()}catch{}return new eu(m)}function Bw(n,e){const t=document.createElement("a");t.href=n,t.target=e;const r=document.createEvent("MouseEvent");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),t.dispatchEvent(r)}const qw="__/auth/handler",$w="emulator/auth/handler",jw=encodeURIComponent("fac");async function tu(n,e,t,r,s,i){F(n.config.authDomain,n,"auth-domain-config-required"),F(n.config.apiKey,n,"invalid-api-key");const a={apiKey:n.config.apiKey,appName:n.name,authType:t,redirectUrl:r,v:yn,eventId:s};if(e instanceof Sa){e.setDefaultLanguage(n.languageCode),a.providerId=e.providerId||"",Tg(e.getCustomParameters())||(a.customParameters=JSON.stringify(e.getCustomParameters()));for(const[f,m]of Object.entries({}))a[f]=m}if(e instanceof Fr){const f=e.getScopes().filter(m=>m!=="");f.length>0&&(a.scopes=f.join(","))}n.tenantId&&(a.tid=n.tenantId);const c=a;for(const f of Object.keys(c))c[f]===void 0&&delete c[f];const u=await n._getAppCheckToken(),h=u?`#${jw}=${encodeURIComponent(u)}`:"";return`${zw(n)}?${Mr(c).slice(1)}${h}`}function zw({config:n}){return n.emulator?Ea(n,$w):`https://${n.authDomain}/${qw}`}const fo="webStorageSupport";class Hw{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Dd,this._completeRedirectFn=mw,this._overrideRedirectResult=dw}async _openPopup(e,t,r,s){Tt(this.eventManagers[e._key()]?.manager,"_initialize() not called before _openPopup()");const i=await tu(e,t,r,Do(),s);return Uw(e,i,Ra())}async _openRedirect(e,t,r,s){await this._originValidation(e);const i=await tu(e,t,r,Do(),s);return WT(i),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:s,promise:i}=this.eventManagers[t];return s?Promise.resolve(s):(Tt(i,"If manager is not set, promise should be"),i)}const r=this.initAndGetManager(e);return this.eventManagers[t]={promise:r},r.catch(()=>{delete this.eventManagers[t]}),r}async initAndGetManager(e){const t=await Vw(e),r=new _w(e);return t.register("authEvent",s=>(F(s?.authEvent,e,"invalid-auth-event"),{status:r.onEvent(s.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:r},this.iframes[e._key()]=t,r}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(fo,{type:fo},s=>{const i=s?.[0]?.[fo];i!==void 0&&t(!!i),at(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=vw(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return Id()||_d()||Aa()}}const Gw=Hw;var nu="@firebase/auth",ru="1.12.0";class Kw{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(r=>{e(r?.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(){F(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}function Ww(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 Qw(n){Me(new Ne("auth",(e,{options:t})=>{const r=e.getProvider("app").getImmediate(),s=e.getProvider("heartbeat"),i=e.getProvider("app-check-internal"),{apiKey:a,authDomain:c}=r.options;F(a&&!a.includes(":"),"invalid-api-key",{appName:r.name});const u={apiKey:a,authDomain:c,clientPlatform:n,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:Ad(n)},h=new PT(r,s,i,u);return OT(h,t),h},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,r)=>{e.getProvider("auth-internal").initialize()})),Me(new Ne("auth-internal",e=>{const t=hi(e.getProvider("auth").getImmediate());return(r=>new Kw(r))(t)},"PRIVATE").setInstantiationMode("EXPLICIT")),me(nu,ru,Ww(n)),me(nu,ru,"esm2020")}const Jw=300,Yw=Vh("authIdTokenMaxAge")||Jw;let su=null;const Xw=n=>async e=>{const t=e&&await e.getIdTokenResult(),r=t&&(new Date().getTime()-Date.parse(t.issuedAtTime))/1e3;if(r&&r>Yw)return;const s=t?.token;su!==s&&(su=s,await fetch(n,{method:s?"POST":"DELETE",headers:s?{Authorization:`Bearer ${s}`}:{}}))};function Zw(n=$n()){const e=ut(n,"auth");if(e.isInitialized())return e.getImmediate();const t=VT(n,{popupRedirectResolver:Gw,persistence:[rw,HT,Dd]}),r=Vh("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){const i=new URL(r,location.origin);if(location.origin===i.origin){const a=Xw(i.toString());$T(t,a,()=>a(t.currentUser)),qT(t,c=>a(c))}}const s=Nh("auth");return s&&bd(t,`http://${s}`),t}function eE(){return document.getElementsByTagName("head")?.[0]??document}CT({loadJS(n){return new Promise((e,t)=>{const r=document.createElement("script");r.setAttribute("src",n),r.onload=e,r.onerror=s=>{const i=Qe("internal-error");i.customData=s,t(i)},r.type="text/javascript",r.charset="UTF-8",eE().appendChild(r)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});Qw("Browser");var iu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};var xt,Bd;(function(){var n;function e(v,g){function w(){}w.prototype=g.prototype,v.F=g.prototype,v.prototype=new w,v.prototype.constructor=v,v.D=function(I,E,b){for(var T=Array(arguments.length-2),De=2;De<arguments.length;De++)T[De-2]=arguments[De];return g.prototype[E].apply(I,T)}}function t(){this.blockSize=-1}function r(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.C=Array(this.blockSize),this.o=this.h=0,this.u()}e(r,t),r.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function s(v,g,w){w||(w=0);const I=Array(16);if(typeof g=="string")for(var E=0;E<16;++E)I[E]=g.charCodeAt(w++)|g.charCodeAt(w++)<<8|g.charCodeAt(w++)<<16|g.charCodeAt(w++)<<24;else for(E=0;E<16;++E)I[E]=g[w++]|g[w++]<<8|g[w++]<<16|g[w++]<<24;g=v.g[0],w=v.g[1],E=v.g[2];let b=v.g[3],T;T=g+(b^w&(E^b))+I[0]+3614090360&4294967295,g=w+(T<<7&4294967295|T>>>25),T=b+(E^g&(w^E))+I[1]+3905402710&4294967295,b=g+(T<<12&4294967295|T>>>20),T=E+(w^b&(g^w))+I[2]+606105819&4294967295,E=b+(T<<17&4294967295|T>>>15),T=w+(g^E&(b^g))+I[3]+3250441966&4294967295,w=E+(T<<22&4294967295|T>>>10),T=g+(b^w&(E^b))+I[4]+4118548399&4294967295,g=w+(T<<7&4294967295|T>>>25),T=b+(E^g&(w^E))+I[5]+1200080426&4294967295,b=g+(T<<12&4294967295|T>>>20),T=E+(w^b&(g^w))+I[6]+2821735955&4294967295,E=b+(T<<17&4294967295|T>>>15),T=w+(g^E&(b^g))+I[7]+4249261313&4294967295,w=E+(T<<22&4294967295|T>>>10),T=g+(b^w&(E^b))+I[8]+1770035416&4294967295,g=w+(T<<7&4294967295|T>>>25),T=b+(E^g&(w^E))+I[9]+2336552879&4294967295,b=g+(T<<12&4294967295|T>>>20),T=E+(w^b&(g^w))+I[10]+4294925233&4294967295,E=b+(T<<17&4294967295|T>>>15),T=w+(g^E&(b^g))+I[11]+2304563134&4294967295,w=E+(T<<22&4294967295|T>>>10),T=g+(b^w&(E^b))+I[12]+1804603682&4294967295,g=w+(T<<7&4294967295|T>>>25),T=b+(E^g&(w^E))+I[13]+4254626195&4294967295,b=g+(T<<12&4294967295|T>>>20),T=E+(w^b&(g^w))+I[14]+2792965006&4294967295,E=b+(T<<17&4294967295|T>>>15),T=w+(g^E&(b^g))+I[15]+1236535329&4294967295,w=E+(T<<22&4294967295|T>>>10),T=g+(E^b&(w^E))+I[1]+4129170786&4294967295,g=w+(T<<5&4294967295|T>>>27),T=b+(w^E&(g^w))+I[6]+3225465664&4294967295,b=g+(T<<9&4294967295|T>>>23),T=E+(g^w&(b^g))+I[11]+643717713&4294967295,E=b+(T<<14&4294967295|T>>>18),T=w+(b^g&(E^b))+I[0]+3921069994&4294967295,w=E+(T<<20&4294967295|T>>>12),T=g+(E^b&(w^E))+I[5]+3593408605&4294967295,g=w+(T<<5&4294967295|T>>>27),T=b+(w^E&(g^w))+I[10]+38016083&4294967295,b=g+(T<<9&4294967295|T>>>23),T=E+(g^w&(b^g))+I[15]+3634488961&4294967295,E=b+(T<<14&4294967295|T>>>18),T=w+(b^g&(E^b))+I[4]+3889429448&4294967295,w=E+(T<<20&4294967295|T>>>12),T=g+(E^b&(w^E))+I[9]+568446438&4294967295,g=w+(T<<5&4294967295|T>>>27),T=b+(w^E&(g^w))+I[14]+3275163606&4294967295,b=g+(T<<9&4294967295|T>>>23),T=E+(g^w&(b^g))+I[3]+4107603335&4294967295,E=b+(T<<14&4294967295|T>>>18),T=w+(b^g&(E^b))+I[8]+1163531501&4294967295,w=E+(T<<20&4294967295|T>>>12),T=g+(E^b&(w^E))+I[13]+2850285829&4294967295,g=w+(T<<5&4294967295|T>>>27),T=b+(w^E&(g^w))+I[2]+4243563512&4294967295,b=g+(T<<9&4294967295|T>>>23),T=E+(g^w&(b^g))+I[7]+1735328473&4294967295,E=b+(T<<14&4294967295|T>>>18),T=w+(b^g&(E^b))+I[12]+2368359562&4294967295,w=E+(T<<20&4294967295|T>>>12),T=g+(w^E^b)+I[5]+4294588738&4294967295,g=w+(T<<4&4294967295|T>>>28),T=b+(g^w^E)+I[8]+2272392833&4294967295,b=g+(T<<11&4294967295|T>>>21),T=E+(b^g^w)+I[11]+1839030562&4294967295,E=b+(T<<16&4294967295|T>>>16),T=w+(E^b^g)+I[14]+4259657740&4294967295,w=E+(T<<23&4294967295|T>>>9),T=g+(w^E^b)+I[1]+2763975236&4294967295,g=w+(T<<4&4294967295|T>>>28),T=b+(g^w^E)+I[4]+1272893353&4294967295,b=g+(T<<11&4294967295|T>>>21),T=E+(b^g^w)+I[7]+4139469664&4294967295,E=b+(T<<16&4294967295|T>>>16),T=w+(E^b^g)+I[10]+3200236656&4294967295,w=E+(T<<23&4294967295|T>>>9),T=g+(w^E^b)+I[13]+681279174&4294967295,g=w+(T<<4&4294967295|T>>>28),T=b+(g^w^E)+I[0]+3936430074&4294967295,b=g+(T<<11&4294967295|T>>>21),T=E+(b^g^w)+I[3]+3572445317&4294967295,E=b+(T<<16&4294967295|T>>>16),T=w+(E^b^g)+I[6]+76029189&4294967295,w=E+(T<<23&4294967295|T>>>9),T=g+(w^E^b)+I[9]+3654602809&4294967295,g=w+(T<<4&4294967295|T>>>28),T=b+(g^w^E)+I[12]+3873151461&4294967295,b=g+(T<<11&4294967295|T>>>21),T=E+(b^g^w)+I[15]+530742520&4294967295,E=b+(T<<16&4294967295|T>>>16),T=w+(E^b^g)+I[2]+3299628645&4294967295,w=E+(T<<23&4294967295|T>>>9),T=g+(E^(w|~b))+I[0]+4096336452&4294967295,g=w+(T<<6&4294967295|T>>>26),T=b+(w^(g|~E))+I[7]+1126891415&4294967295,b=g+(T<<10&4294967295|T>>>22),T=E+(g^(b|~w))+I[14]+2878612391&4294967295,E=b+(T<<15&4294967295|T>>>17),T=w+(b^(E|~g))+I[5]+4237533241&4294967295,w=E+(T<<21&4294967295|T>>>11),T=g+(E^(w|~b))+I[12]+1700485571&4294967295,g=w+(T<<6&4294967295|T>>>26),T=b+(w^(g|~E))+I[3]+2399980690&4294967295,b=g+(T<<10&4294967295|T>>>22),T=E+(g^(b|~w))+I[10]+4293915773&4294967295,E=b+(T<<15&4294967295|T>>>17),T=w+(b^(E|~g))+I[1]+2240044497&4294967295,w=E+(T<<21&4294967295|T>>>11),T=g+(E^(w|~b))+I[8]+1873313359&4294967295,g=w+(T<<6&4294967295|T>>>26),T=b+(w^(g|~E))+I[15]+4264355552&4294967295,b=g+(T<<10&4294967295|T>>>22),T=E+(g^(b|~w))+I[6]+2734768916&4294967295,E=b+(T<<15&4294967295|T>>>17),T=w+(b^(E|~g))+I[13]+1309151649&4294967295,w=E+(T<<21&4294967295|T>>>11),T=g+(E^(w|~b))+I[4]+4149444226&4294967295,g=w+(T<<6&4294967295|T>>>26),T=b+(w^(g|~E))+I[11]+3174756917&4294967295,b=g+(T<<10&4294967295|T>>>22),T=E+(g^(b|~w))+I[2]+718787259&4294967295,E=b+(T<<15&4294967295|T>>>17),T=w+(b^(E|~g))+I[9]+3951481745&4294967295,v.g[0]=v.g[0]+g&4294967295,v.g[1]=v.g[1]+(E+(T<<21&4294967295|T>>>11))&4294967295,v.g[2]=v.g[2]+E&4294967295,v.g[3]=v.g[3]+b&4294967295}r.prototype.v=function(v,g){g===void 0&&(g=v.length);const w=g-this.blockSize,I=this.C;let E=this.h,b=0;for(;b<g;){if(E==0)for(;b<=w;)s(this,v,b),b+=this.blockSize;if(typeof v=="string"){for(;b<g;)if(I[E++]=v.charCodeAt(b++),E==this.blockSize){s(this,I),E=0;break}}else for(;b<g;)if(I[E++]=v[b++],E==this.blockSize){s(this,I),E=0;break}}this.h=E,this.o+=g},r.prototype.A=function(){var v=Array((this.h<56?this.blockSize:this.blockSize*2)-this.h);v[0]=128;for(var g=1;g<v.length-8;++g)v[g]=0;g=this.o*8;for(var w=v.length-8;w<v.length;++w)v[w]=g&255,g/=256;for(this.v(v),v=Array(16),g=0,w=0;w<4;++w)for(let I=0;I<32;I+=8)v[g++]=this.g[w]>>>I&255;return v};function i(v,g){var w=c;return Object.prototype.hasOwnProperty.call(w,v)?w[v]:w[v]=g(v)}function a(v,g){this.h=g;const w=[];let I=!0;for(let E=v.length-1;E>=0;E--){const b=v[E]|0;I&&b==g||(w[E]=b,I=!1)}this.g=w}var c={};function u(v){return-128<=v&&v<128?i(v,function(g){return new a([g|0],g<0?-1:0)}):new a([v|0],v<0?-1:0)}function h(v){if(isNaN(v)||!isFinite(v))return m;if(v<0)return N(h(-v));const g=[];let w=1;for(let I=0;v>=w;I++)g[I]=v/w|0,w*=4294967296;return new a(g,0)}function f(v,g){if(v.length==0)throw Error("number format error: empty string");if(g=g||10,g<2||36<g)throw Error("radix out of range: "+g);if(v.charAt(0)=="-")return N(f(v.substring(1),g));if(v.indexOf("-")>=0)throw Error('number format error: interior "-" character');const w=h(Math.pow(g,8));let I=m;for(let b=0;b<v.length;b+=8){var E=Math.min(8,v.length-b);const T=parseInt(v.substring(b,b+E),g);E<8?(E=h(Math.pow(g,E)),I=I.j(E).add(h(T))):(I=I.j(w),I=I.add(h(T)))}return I}var m=u(0),y=u(1),S=u(16777216);n=a.prototype,n.m=function(){if(V(this))return-N(this).m();let v=0,g=1;for(let w=0;w<this.g.length;w++){const I=this.i(w);v+=(I>=0?I:4294967296+I)*g,g*=4294967296}return v},n.toString=function(v){if(v=v||10,v<2||36<v)throw Error("radix out of range: "+v);if(k(this))return"0";if(V(this))return"-"+N(this).toString(v);const g=h(Math.pow(v,6));var w=this;let I="";for(;;){const E=te(w,g).g;w=$(w,E.j(g));let b=((w.g.length>0?w.g[0]:w.h)>>>0).toString(v);if(w=E,k(w))return b+I;for(;b.length<6;)b="0"+b;I=b+I}},n.i=function(v){return v<0?0:v<this.g.length?this.g[v]:this.h};function k(v){if(v.h!=0)return!1;for(let g=0;g<v.g.length;g++)if(v.g[g]!=0)return!1;return!0}function V(v){return v.h==-1}n.l=function(v){return v=$(this,v),V(v)?-1:k(v)?0:1};function N(v){const g=v.g.length,w=[];for(let I=0;I<g;I++)w[I]=~v.g[I];return new a(w,~v.h).add(y)}n.abs=function(){return V(this)?N(this):this},n.add=function(v){const g=Math.max(this.g.length,v.g.length),w=[];let I=0;for(let E=0;E<=g;E++){let b=I+(this.i(E)&65535)+(v.i(E)&65535),T=(b>>>16)+(this.i(E)>>>16)+(v.i(E)>>>16);I=T>>>16,b&=65535,T&=65535,w[E]=T<<16|b}return new a(w,w[w.length-1]&-2147483648?-1:0)};function $(v,g){return v.add(N(g))}n.j=function(v){if(k(this)||k(v))return m;if(V(this))return V(v)?N(this).j(N(v)):N(N(this).j(v));if(V(v))return N(this.j(N(v)));if(this.l(S)<0&&v.l(S)<0)return h(this.m()*v.m());const g=this.g.length+v.g.length,w=[];for(var I=0;I<2*g;I++)w[I]=0;for(I=0;I<this.g.length;I++)for(let E=0;E<v.g.length;E++){const b=this.i(I)>>>16,T=this.i(I)&65535,De=v.i(E)>>>16,Jt=v.i(E)&65535;w[2*I+2*E]+=T*Jt,W(w,2*I+2*E),w[2*I+2*E+1]+=b*Jt,W(w,2*I+2*E+1),w[2*I+2*E+1]+=T*De,W(w,2*I+2*E+1),w[2*I+2*E+2]+=b*De,W(w,2*I+2*E+2)}for(v=0;v<g;v++)w[v]=w[2*v+1]<<16|w[2*v];for(v=g;v<2*g;v++)w[v]=0;return new a(w,0)};function W(v,g){for(;(v[g]&65535)!=v[g];)v[g+1]+=v[g]>>>16,v[g]&=65535,g++}function Q(v,g){this.g=v,this.h=g}function te(v,g){if(k(g))throw Error("division by zero");if(k(v))return new Q(m,m);if(V(v))return g=te(N(v),g),new Q(N(g.g),N(g.h));if(V(g))return g=te(v,N(g)),new Q(N(g.g),g.h);if(v.g.length>30){if(V(v)||V(g))throw Error("slowDivide_ only works with positive integers.");for(var w=y,I=g;I.l(v)<=0;)w=we(w),I=we(I);var E=oe(w,1),b=oe(I,1);for(I=oe(I,2),w=oe(w,2);!k(I);){var T=b.add(I);T.l(v)<=0&&(E=E.add(w),b=T),I=oe(I,1),w=oe(w,1)}return g=$(v,E.j(g)),new Q(E,g)}for(E=m;v.l(g)>=0;){for(w=Math.max(1,Math.floor(v.m()/g.m())),I=Math.ceil(Math.log(w)/Math.LN2),I=I<=48?1:Math.pow(2,I-48),b=h(w),T=b.j(g);V(T)||T.l(v)>0;)w-=I,b=h(w),T=b.j(g);k(b)&&(b=y),E=E.add(b),v=$(v,T)}return new Q(E,v)}n.B=function(v){return te(this,v).h},n.and=function(v){const g=Math.max(this.g.length,v.g.length),w=[];for(let I=0;I<g;I++)w[I]=this.i(I)&v.i(I);return new a(w,this.h&v.h)},n.or=function(v){const g=Math.max(this.g.length,v.g.length),w=[];for(let I=0;I<g;I++)w[I]=this.i(I)|v.i(I);return new a(w,this.h|v.h)},n.xor=function(v){const g=Math.max(this.g.length,v.g.length),w=[];for(let I=0;I<g;I++)w[I]=this.i(I)^v.i(I);return new a(w,this.h^v.h)};function we(v){const g=v.g.length+1,w=[];for(let I=0;I<g;I++)w[I]=v.i(I)<<1|v.i(I-1)>>>31;return new a(w,v.h)}function oe(v,g){const w=g>>5;g%=32;const I=v.g.length-w,E=[];for(let b=0;b<I;b++)E[b]=g>0?v.i(b+w)>>>g|v.i(b+w+1)<<32-g:v.i(b+w);return new a(E,v.h)}r.prototype.digest=r.prototype.A,r.prototype.reset=r.prototype.u,r.prototype.update=r.prototype.v,Bd=r,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=h,a.fromString=f,xt=a}).apply(typeof iu<"u"?iu:typeof self<"u"?self:typeof window<"u"?window:{});var ls=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};var qd,dr,$d,Ts,Lo,jd,zd,Hd;(function(){var n,e=Object.defineProperty;function t(o){o=[typeof globalThis=="object"&&globalThis,o,typeof window=="object"&&window,typeof self=="object"&&self,typeof ls=="object"&&ls];for(var l=0;l<o.length;++l){var d=o[l];if(d&&d.Math==Math)return d}throw Error("Cannot find global object")}var r=t(this);function s(o,l){if(l)e:{var d=r;o=o.split(".");for(var p=0;p<o.length-1;p++){var A=o[p];if(!(A in d))break e;d=d[A]}o=o[o.length-1],p=d[o],l=l(p),l!=p&&l!=null&&e(d,o,{configurable:!0,writable:!0,value:l})}}s("Symbol.dispose",function(o){return o||Symbol("Symbol.dispose")}),s("Array.prototype.values",function(o){return o||function(){return this[Symbol.iterator]()}}),s("Object.entries",function(o){return o||function(l){var d=[],p;for(p in l)Object.prototype.hasOwnProperty.call(l,p)&&d.push([p,l[p]]);return d}});var i=i||{},a=this||self;function c(o){var l=typeof o;return l=="object"&&o!=null||l=="function"}function u(o,l,d){return o.call.apply(o.bind,arguments)}function h(o,l,d){return h=u,h.apply(null,arguments)}function f(o,l){var d=Array.prototype.slice.call(arguments,1);return function(){var p=d.slice();return p.push.apply(p,arguments),o.apply(this,p)}}function m(o,l){function d(){}d.prototype=l.prototype,o.Z=l.prototype,o.prototype=new d,o.prototype.constructor=o,o.Ob=function(p,A,R){for(var D=Array(arguments.length-2),j=2;j<arguments.length;j++)D[j-2]=arguments[j];return l.prototype[A].apply(p,D)}}var y=typeof AsyncContext<"u"&&typeof AsyncContext.Snapshot=="function"?o=>o&&AsyncContext.Snapshot.wrap(o):o=>o;function S(o){const l=o.length;if(l>0){const d=Array(l);for(let p=0;p<l;p++)d[p]=o[p];return d}return[]}function k(o,l){for(let p=1;p<arguments.length;p++){const A=arguments[p];var d=typeof A;if(d=d!="object"?d:A?Array.isArray(A)?"array":d:"null",d=="array"||d=="object"&&typeof A.length=="number"){d=o.length||0;const R=A.length||0;o.length=d+R;for(let D=0;D<R;D++)o[d+D]=A[D]}else o.push(A)}}class V{constructor(l,d){this.i=l,this.j=d,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(o){a.setTimeout(()=>{throw o},0)}function $(){var o=v;let l=null;return o.g&&(l=o.g,o.g=o.g.next,o.g||(o.h=null),l.next=null),l}class W{constructor(){this.h=this.g=null}add(l,d){const p=Q.get();p.set(l,d),this.h?this.h.next=p:this.g=p,this.h=p}}var Q=new V(()=>new te,o=>o.reset());class te{constructor(){this.next=this.g=this.h=null}set(l,d){this.h=l,this.g=d,this.next=null}reset(){this.next=this.g=this.h=null}}let we,oe=!1,v=new W,g=()=>{const o=Promise.resolve(void 0);we=()=>{o.then(w)}};function w(){for(var o;o=$();){try{o.h.call(o.g)}catch(d){N(d)}var l=Q;l.j(o),l.h<100&&(l.h++,o.next=l.g,l.g=o)}oe=!1}function I(){this.u=this.u,this.C=this.C}I.prototype.u=!1,I.prototype.dispose=function(){this.u||(this.u=!0,this.N())},I.prototype[Symbol.dispose]=function(){this.dispose()},I.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function E(o,l){this.type=o,this.g=this.target=l,this.defaultPrevented=!1}E.prototype.h=function(){this.defaultPrevented=!0};var b=(function(){if(!a.addEventListener||!Object.defineProperty)return!1;var o=!1,l=Object.defineProperty({},"passive",{get:function(){o=!0}});try{const d=()=>{};a.addEventListener("test",d,l),a.removeEventListener("test",d,l)}catch{}return o})();function T(o){return/^[\s\xa0]*$/.test(o)}function De(o,l){E.call(this,o?o.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,o&&this.init(o,l)}m(De,E),De.prototype.init=function(o,l){const d=this.type=o.type,p=o.changedTouches&&o.changedTouches.length?o.changedTouches[0]:null;this.target=o.target||o.srcElement,this.g=l,l=o.relatedTarget,l||(d=="mouseover"?l=o.fromElement:d=="mouseout"&&(l=o.toElement)),this.relatedTarget=l,p?(this.clientX=p.clientX!==void 0?p.clientX:p.pageX,this.clientY=p.clientY!==void 0?p.clientY:p.pageY,this.screenX=p.screenX||0,this.screenY=p.screenY||0):(this.clientX=o.clientX!==void 0?o.clientX:o.pageX,this.clientY=o.clientY!==void 0?o.clientY:o.pageY,this.screenX=o.screenX||0,this.screenY=o.screenY||0),this.button=o.button,this.key=o.key||"",this.ctrlKey=o.ctrlKey,this.altKey=o.altKey,this.shiftKey=o.shiftKey,this.metaKey=o.metaKey,this.pointerId=o.pointerId||0,this.pointerType=o.pointerType,this.state=o.state,this.i=o,o.defaultPrevented&&De.Z.h.call(this)},De.prototype.h=function(){De.Z.h.call(this);const o=this.i;o.preventDefault?o.preventDefault():o.returnValue=!1};var Jt="closure_listenable_"+(Math.random()*1e6|0),Fp=0;function Up(o,l,d,p,A){this.listener=o,this.proxy=null,this.src=l,this.type=d,this.capture=!!p,this.ha=A,this.key=++Fp,this.da=this.fa=!1}function Kr(o){o.da=!0,o.listener=null,o.proxy=null,o.src=null,o.ha=null}function Wr(o,l,d){for(const p in o)l.call(d,o[p],p,o)}function Bp(o,l){for(const d in o)l.call(void 0,o[d],d,o)}function vc(o){const l={};for(const d in o)l[d]=o[d];return l}const Ic="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function Ac(o,l){let d,p;for(let A=1;A<arguments.length;A++){p=arguments[A];for(d in p)o[d]=p[d];for(let R=0;R<Ic.length;R++)d=Ic[R],Object.prototype.hasOwnProperty.call(p,d)&&(o[d]=p[d])}}function Qr(o){this.src=o,this.g={},this.h=0}Qr.prototype.add=function(o,l,d,p,A){const R=o.toString();o=this.g[R],o||(o=this.g[R]=[],this.h++);const D=Vi(o,l,p,A);return D>-1?(l=o[D],d||(l.fa=!1)):(l=new Up(l,this.src,R,!!p,A),l.fa=d,o.push(l)),l};function Di(o,l){const d=l.type;if(d in o.g){var p=o.g[d],A=Array.prototype.indexOf.call(p,l,void 0),R;(R=A>=0)&&Array.prototype.splice.call(p,A,1),R&&(Kr(l),o.g[d].length==0&&(delete o.g[d],o.h--))}}function Vi(o,l,d,p){for(let A=0;A<o.length;++A){const R=o[A];if(!R.da&&R.listener==l&&R.capture==!!d&&R.ha==p)return A}return-1}var Oi="closure_lm_"+(Math.random()*1e6|0),Li={};function bc(o,l,d,p,A){if(Array.isArray(l)){for(let R=0;R<l.length;R++)bc(o,l[R],d,p,A);return null}return d=Pc(d),o&&o[Jt]?o.J(l,d,c(p)?!!p.capture:!1,A):qp(o,l,d,!1,p,A)}function qp(o,l,d,p,A,R){if(!l)throw Error("Invalid event type");const D=c(A)?!!A.capture:!!A;let j=xi(o);if(j||(o[Oi]=j=new Qr(o)),d=j.add(l,d,p,D,R),d.proxy)return d;if(p=$p(),d.proxy=p,p.src=o,p.listener=d,o.addEventListener)b||(A=D),A===void 0&&(A=!1),o.addEventListener(l.toString(),p,A);else if(o.attachEvent)o.attachEvent(Rc(l.toString()),p);else if(o.addListener&&o.removeListener)o.addListener(p);else throw Error("addEventListener and attachEvent are unavailable.");return d}function $p(){function o(d){return l.call(o.src,o.listener,d)}const l=jp;return o}function Sc(o,l,d,p,A){if(Array.isArray(l))for(var R=0;R<l.length;R++)Sc(o,l[R],d,p,A);else p=c(p)?!!p.capture:!!p,d=Pc(d),o&&o[Jt]?(o=o.i,R=String(l).toString(),R in o.g&&(l=o.g[R],d=Vi(l,d,p,A),d>-1&&(Kr(l[d]),Array.prototype.splice.call(l,d,1),l.length==0&&(delete o.g[R],o.h--)))):o&&(o=xi(o))&&(l=o.g[l.toString()],o=-1,l&&(o=Vi(l,d,p,A)),(d=o>-1?l[o]:null)&&Mi(d))}function Mi(o){if(typeof o!="number"&&o&&!o.da){var l=o.src;if(l&&l[Jt])Di(l.i,o);else{var d=o.type,p=o.proxy;l.removeEventListener?l.removeEventListener(d,p,o.capture):l.detachEvent?l.detachEvent(Rc(d),p):l.addListener&&l.removeListener&&l.removeListener(p),(d=xi(l))?(Di(d,o),d.h==0&&(d.src=null,l[Oi]=null)):Kr(o)}}}function Rc(o){return o in Li?Li[o]:Li[o]="on"+o}function jp(o,l){if(o.da)o=!0;else{l=new De(l,this);const d=o.listener,p=o.ha||o.src;o.fa&&Mi(o),o=d.call(p,l)}return o}function xi(o){return o=o[Oi],o instanceof Qr?o:null}var Fi="__closure_events_fn_"+(Math.random()*1e9>>>0);function Pc(o){return typeof o=="function"?o:(o[Fi]||(o[Fi]=function(l){return o.handleEvent(l)}),o[Fi])}function Ee(){I.call(this),this.i=new Qr(this),this.M=this,this.G=null}m(Ee,I),Ee.prototype[Jt]=!0,Ee.prototype.removeEventListener=function(o,l,d,p){Sc(this,o,l,d,p)};function Re(o,l){var d,p=o.G;if(p)for(d=[];p;p=p.G)d.push(p);if(o=o.M,p=l.type||l,typeof l=="string")l=new E(l,o);else if(l instanceof E)l.target=l.target||o;else{var A=l;l=new E(p,o),Ac(l,A)}A=!0;let R,D;if(d)for(D=d.length-1;D>=0;D--)R=l.g=d[D],A=Jr(R,p,!0,l)&&A;if(R=l.g=o,A=Jr(R,p,!0,l)&&A,A=Jr(R,p,!1,l)&&A,d)for(D=0;D<d.length;D++)R=l.g=d[D],A=Jr(R,p,!1,l)&&A}Ee.prototype.N=function(){if(Ee.Z.N.call(this),this.i){var o=this.i;for(const l in o.g){const d=o.g[l];for(let p=0;p<d.length;p++)Kr(d[p]);delete o.g[l],o.h--}}this.G=null},Ee.prototype.J=function(o,l,d,p){return this.i.add(String(o),l,!1,d,p)},Ee.prototype.K=function(o,l,d,p){return this.i.add(String(o),l,!0,d,p)};function Jr(o,l,d,p){if(l=o.i.g[String(l)],!l)return!0;l=l.concat();let A=!0;for(let R=0;R<l.length;++R){const D=l[R];if(D&&!D.da&&D.capture==d){const j=D.listener,he=D.ha||D.src;D.fa&&Di(o.i,D),A=j.call(he,p)!==!1&&A}}return A&&!p.defaultPrevented}function zp(o,l){if(typeof o!="function")if(o&&typeof o.handleEvent=="function")o=h(o.handleEvent,o);else throw Error("Invalid listener argument");return Number(l)>2147483647?-1:a.setTimeout(o,l||0)}function Cc(o){o.g=zp(()=>{o.g=null,o.i&&(o.i=!1,Cc(o))},o.l);const l=o.h;o.h=null,o.m.apply(null,l)}class Hp extends I{constructor(l,d){super(),this.m=l,this.l=d,this.h=null,this.i=!1,this.g=null}j(l){this.h=arguments,this.g?this.i=!0:Cc(this)}N(){super.N(),this.g&&(a.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function Qn(o){I.call(this),this.h=o,this.g={}}m(Qn,I);var kc=[];function Nc(o){Wr(o.g,function(l,d){this.g.hasOwnProperty(d)&&Mi(l)},o),o.g={}}Qn.prototype.N=function(){Qn.Z.N.call(this),Nc(this)},Qn.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var Ui=a.JSON.stringify,Gp=a.JSON.parse,Kp=class{stringify(o){return a.JSON.stringify(o,void 0)}parse(o){return a.JSON.parse(o,void 0)}};function Dc(){}function Vc(){}var Jn={OPEN:"a",hb:"b",ERROR:"c",tb:"d"};function Bi(){E.call(this,"d")}m(Bi,E);function qi(){E.call(this,"c")}m(qi,E);var Yt={},Oc=null;function Yr(){return Oc=Oc||new Ee}Yt.Ia="serverreachability";function Lc(o){E.call(this,Yt.Ia,o)}m(Lc,E);function Yn(o){const l=Yr();Re(l,new Lc(l))}Yt.STAT_EVENT="statevent";function Mc(o,l){E.call(this,Yt.STAT_EVENT,o),this.stat=l}m(Mc,E);function Pe(o){const l=Yr();Re(l,new Mc(l,o))}Yt.Ja="timingevent";function xc(o,l){E.call(this,Yt.Ja,o),this.size=l}m(xc,E);function Xn(o,l){if(typeof o!="function")throw Error("Fn must not be null and must be a function");return a.setTimeout(function(){o()},l)}function Zn(){this.g=!0}Zn.prototype.ua=function(){this.g=!1};function Wp(o,l,d,p,A,R){o.info(function(){if(o.g)if(R){var D="",j=R.split("&");for(let X=0;X<j.length;X++){var he=j[X].split("=");if(he.length>1){const fe=he[0];he=he[1];const et=fe.split("_");D=et.length>=2&&et[1]=="type"?D+(fe+"="+he+"&"):D+(fe+"=redacted&")}}}else D=null;else D=R;return"XMLHTTP REQ ("+p+") [attempt "+A+"]: "+l+`
|
|
15
|
+
</defs>`,C.innerText="Preview backend running in this workspace."),C.setAttribute("id",T)}document.readyState==="loading"?window.addEventListener("DOMContentLoaded",g):g()}function Pe(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function YI(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(Pe())}function QI(){const n=ia()?.forceEnvironment;if(n==="node")return!0;if(n==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function JI(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function Ym(){const n=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof n=="object"&&n.id!==void 0}function XI(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function ZI(){const n=Pe();return n.indexOf("MSIE ")>=0||n.indexOf("Trident/")>=0}function e0(){return!QI()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function ql(){try{return typeof indexedDB=="object"}catch{return!1}}function jl(){return new Promise((n,e)=>{try{let t=!0;const r="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(r);s.onsuccess=()=>{s.result.close(),t||self.indexedDB.deleteDatabase(r),n(!0)},s.onupgradeneeded=()=>{t=!1},s.onerror=()=>{e(s.error?.message||"")}}catch(t){e(t)}})}function Qm(){return!(typeof navigator>"u"||!navigator.cookieEnabled)}const t0="FirebaseError";class et extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name=t0,Object.setPrototypeOf(this,et.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,Ln.prototype.create)}}class Ln{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){const r=t[0]||{},s=`${this.service}/${e}`,i=this.errors[e],o=i?n0(i,r):"Error",c=`${this.serviceName}: ${o} (${s}).`;return new et(s,c,r)}}function n0(n,e){return n.replace(r0,(t,r)=>{const s=e[r];return s!=null?String(s):`<${r}?>`})}const r0=/\{\$([^}]+)}/g;function s0(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function An(n,e){if(n===e)return!0;const t=Object.keys(n),r=Object.keys(e);for(const s of t){if(!r.includes(s))return!1;const i=n[s],o=e[s];if(kd(i)&&kd(o)){if(!An(i,o))return!1}else if(i!==o)return!1}for(const s of r)if(!t.includes(s))return!1;return!0}function kd(n){return n!==null&&typeof n=="object"}function pi(n){const e=[];for(const[t,r]of Object.entries(n))Array.isArray(r)?r.forEach(s=>{e.push(encodeURIComponent(t)+"="+encodeURIComponent(s))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function i0(n,e){const t=new o0(n,e);return t.subscribe.bind(t)}class o0{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(r=>{this.error(r)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let s;if(e===void 0&&t===void 0&&r===void 0)throw new Error("Missing Observer.");a0(e,["next","error","complete"])?s=e:s={next:e,error:t,complete:r},s.next===void 0&&(s.next=fc),s.error===void 0&&(s.error=fc),s.complete===void 0&&(s.complete=fc);const i=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),i}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(r){typeof console<"u"&&console.error&&console.error(r)}})}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 a0(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 fc(){}const c0=1e3,l0=2,u0=14400*1e3,h0=.5;function Pd(n,e=c0,t=l0){const r=e*Math.pow(t,n),s=Math.round(h0*r*(Math.random()-.5)*2);return Math.min(u0,r+s)}function ie(n){return n&&n._delegate?n._delegate:n}class Fe{constructor(e,t,r){this.name=e,this.instanceFactory=t,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}const Hn="[DEFAULT]";class d0{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 r=new zI;if(this.instancesDeferred.set(t,r),this.isInitialized(t)||this.shouldAutoInitialize())try{const s=this.getOrInitializeService({instanceIdentifier:t});s&&r.resolve(s)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){const t=this.normalizeInstanceIdentifier(e?.identifier),r=e?.optional??!1;if(this.isInitialized(t)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:t})}catch(s){if(r)return null;throw s}else{if(r)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(p0(e))try{this.getOrInitializeService({instanceIdentifier:Hn})}catch{}for(const[t,r]of this.instancesDeferred.entries()){const s=this.normalizeInstanceIdentifier(t);try{const i=this.getOrInitializeService({instanceIdentifier:s});r.resolve(i)}catch{}}}}clearInstance(e=Hn){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=Hn){return this.instances.has(e)}getOptions(e=Hn){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,r=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const s=this.getOrInitializeService({instanceIdentifier:r,options:t});for(const[i,o]of this.instancesDeferred.entries()){const c=this.normalizeInstanceIdentifier(i);r===c&&o.resolve(s)}return s}onInit(e,t){const r=this.normalizeInstanceIdentifier(t),s=this.onInitCallbacks.get(r)??new Set;s.add(e),this.onInitCallbacks.set(r,s);const i=this.instances.get(r);return i&&e(i,r),()=>{s.delete(e)}}invokeOnInitCallbacks(e,t){const r=this.onInitCallbacks.get(t);if(r)for(const s of r)try{s(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let r=this.instances.get(e);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:f0(e),options:t}),this.instances.set(e,r),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(r,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,r)}catch{}return r||null}normalizeInstanceIdentifier(e=Hn){return this.component?this.component.multipleInstances?e:Hn:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function f0(n){return n===Hn?void 0:n}function p0(n){return n.instantiationMode==="EAGER"}class m0{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 d0(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}var X;(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"})(X||(X={}));const g0={debug:X.DEBUG,verbose:X.VERBOSE,info:X.INFO,warn:X.WARN,error:X.ERROR,silent:X.SILENT},_0=X.INFO,y0={[X.DEBUG]:"log",[X.VERBOSE]:"log",[X.INFO]:"info",[X.WARN]:"warn",[X.ERROR]:"error"},E0=(n,e,...t)=>{if(e<n.logLevel)return;const r=new Date().toISOString(),s=y0[e];if(s)console[s](`[${r}] ${n.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class ca{constructor(e){this.name=e,this._logLevel=_0,this._logHandler=E0,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in X))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?g0[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,X.DEBUG,...e),this._logHandler(this,X.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,X.VERBOSE,...e),this._logHandler(this,X.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,X.INFO,...e),this._logHandler(this,X.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,X.WARN,...e),this._logHandler(this,X.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,X.ERROR,...e),this._logHandler(this,X.ERROR,...e)}}const v0=(n,e)=>e.some(t=>n instanceof t);let Nd,Dd;function T0(){return Nd||(Nd=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function w0(){return Dd||(Dd=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Jm=new WeakMap,Hc=new WeakMap,Xm=new WeakMap,pc=new WeakMap,Hl=new WeakMap;function b0(n){const e=new Promise((t,r)=>{const s=()=>{n.removeEventListener("success",i),n.removeEventListener("error",o)},i=()=>{t(Wt(n.result)),s()},o=()=>{r(n.error),s()};n.addEventListener("success",i),n.addEventListener("error",o)});return e.then(t=>{t instanceof IDBCursor&&Jm.set(t,n)}).catch(()=>{}),Hl.set(e,n),e}function A0(n){if(Hc.has(n))return;const e=new Promise((t,r)=>{const s=()=>{n.removeEventListener("complete",i),n.removeEventListener("error",o),n.removeEventListener("abort",o)},i=()=>{t(),s()},o=()=>{r(n.error||new DOMException("AbortError","AbortError")),s()};n.addEventListener("complete",i),n.addEventListener("error",o),n.addEventListener("abort",o)});Hc.set(n,e)}let Wc={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return Hc.get(n);if(e==="objectStoreNames")return n.objectStoreNames||Xm.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return Wt(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 I0(n){Wc=n(Wc)}function S0(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const r=n.call(mc(this),e,...t);return Xm.set(r,e.sort?e.sort():[e]),Wt(r)}:w0().includes(n)?function(...e){return n.apply(mc(this),e),Wt(Jm.get(this))}:function(...e){return Wt(n.apply(mc(this),e))}}function C0(n){return typeof n=="function"?S0(n):(n instanceof IDBTransaction&&A0(n),v0(n,T0())?new Proxy(n,Wc):n)}function Wt(n){if(n instanceof IDBRequest)return b0(n);if(pc.has(n))return pc.get(n);const e=C0(n);return e!==n&&(pc.set(n,e),Hl.set(e,n)),e}const mc=n=>Hl.get(n);function la(n,e,{blocked:t,upgrade:r,blocking:s,terminated:i}={}){const o=indexedDB.open(n,e),c=Wt(o);return r&&o.addEventListener("upgradeneeded",l=>{r(Wt(o.result),l.oldVersion,l.newVersion,Wt(o.transaction),l)}),t&&o.addEventListener("blocked",l=>t(l.oldVersion,l.newVersion,l)),c.then(l=>{i&&l.addEventListener("close",()=>i()),s&&l.addEventListener("versionchange",h=>s(h.oldVersion,h.newVersion,h))}).catch(()=>{}),c}function gc(n,{blocked:e}={}){const t=indexedDB.deleteDatabase(n);return e&&t.addEventListener("blocked",r=>e(r.oldVersion,r)),Wt(t).then(()=>{})}const R0=["get","getKey","getAll","getAllKeys","count"],k0=["put","add","delete","clear"],_c=new Map;function Od(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(_c.get(e))return _c.get(e);const t=e.replace(/FromIndex$/,""),r=e!==t,s=k0.includes(t);if(!(t in(r?IDBIndex:IDBObjectStore).prototype)||!(s||R0.includes(t)))return;const i=async function(o,...c){const l=this.transaction(o,s?"readwrite":"readonly");let h=l.store;return r&&(h=h.index(c.shift())),(await Promise.all([h[t](...c),s&&l.done]))[0]};return _c.set(e,i),i}I0(n=>({...n,get:(e,t,r)=>Od(e,t)||n.get(e,t,r),has:(e,t)=>!!Od(e,t)||n.has(e,t)}));class P0{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(N0(t)){const r=t.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(t=>t).join(" ")}}function N0(n){return n.getComponent()?.type==="VERSION"}const zc="@firebase/app",Vd="0.14.7";const Yt=new ca("@firebase/app"),D0="@firebase/app-compat",O0="@firebase/analytics-compat",V0="@firebase/analytics",L0="@firebase/app-check-compat",M0="@firebase/app-check",x0="@firebase/auth",F0="@firebase/auth-compat",$0="@firebase/database",U0="@firebase/data-connect",B0="@firebase/database-compat",q0="@firebase/functions",j0="@firebase/functions-compat",H0="@firebase/installations",W0="@firebase/installations-compat",z0="@firebase/messaging",K0="@firebase/messaging-compat",G0="@firebase/performance",Y0="@firebase/performance-compat",Q0="@firebase/remote-config",J0="@firebase/remote-config-compat",X0="@firebase/storage",Z0="@firebase/storage-compat",eS="@firebase/firestore",tS="@firebase/ai",nS="@firebase/firestore-compat",rS="firebase",sS="12.8.0";const Kc="[DEFAULT]",iS={[zc]:"fire-core",[D0]:"fire-core-compat",[V0]:"fire-analytics",[O0]:"fire-analytics-compat",[M0]:"fire-app-check",[L0]:"fire-app-check-compat",[x0]:"fire-auth",[F0]:"fire-auth-compat",[$0]:"fire-rtdb",[U0]:"fire-data-connect",[B0]:"fire-rtdb-compat",[q0]:"fire-fn",[j0]:"fire-fn-compat",[H0]:"fire-iid",[W0]:"fire-iid-compat",[z0]:"fire-fcm",[K0]:"fire-fcm-compat",[G0]:"fire-perf",[Y0]:"fire-perf-compat",[Q0]:"fire-rc",[J0]:"fire-rc-compat",[X0]:"fire-gcs",[Z0]:"fire-gcs-compat",[eS]:"fire-fst",[nS]:"fire-fst-compat",[tS]:"fire-vertex","fire-js":"fire-js",[rS]:"fire-js-all"};const To=new Map,oS=new Map,Gc=new Map;function Ld(n,e){try{n.container.addComponent(e)}catch(t){Yt.debug(`Component ${e.name} failed to register with FirebaseApp ${n.name}`,t)}}function je(n){const e=n.name;if(Gc.has(e))return Yt.debug(`There were multiple attempts to register component ${e}.`),!1;Gc.set(e,n);for(const t of To.values())Ld(t,n);for(const t of oS.values())Ld(t,n);return!0}function Vt(n,e){const t=n.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),n.container.getProvider(e)}function Ke(n){return n==null?!1:n.settings!==void 0}const aS={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","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."},En=new Ln("app","Firebase",aS);class cS{constructor(e,t,r){this._isDeleted=!1,this._options={...e},this._config={...t},this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new Fe("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 En.create("app-deleted",{appName:this._name})}}const dr=sS;function Zm(n,e={}){let t=n;typeof e!="object"&&(e={name:e});const r={name:Kc,automaticDataCollectionEnabled:!0,...e},s=r.name;if(typeof s!="string"||!s)throw En.create("bad-app-name",{appName:String(s)});if(t||(t=zm()),!t)throw En.create("no-options");const i=To.get(s);if(i){if(An(t,i.options)&&An(r,i.config))return i;throw En.create("duplicate-app",{appName:s})}const o=new m0(s);for(const l of Gc.values())o.addComponent(l);const c=new cS(t,r,o);return To.set(s,c),c}function os(n=Kc){const e=To.get(n);if(!e&&n===Kc&&zm())return Zm();if(!e)throw En.create("no-app",{appName:n});return e}function Te(n,e,t){let r=iS[n]??n;t&&(r+=`-${t}`);const s=r.match(/\s|\//),i=e.match(/\s|\//);if(s||i){const o=[`Unable to register library "${r}" with version "${e}":`];s&&o.push(`library name "${r}" contains illegal characters (whitespace or "/")`),s&&i&&o.push("and"),i&&o.push(`version name "${e}" contains illegal characters (whitespace or "/")`),Yt.warn(o.join(" "));return}je(new Fe(`${r}-version`,()=>({library:r,version:e}),"VERSION"))}const lS="firebase-heartbeat-database",uS=1,Js="firebase-heartbeat-store";let yc=null;function eg(){return yc||(yc=la(lS,uS,{upgrade:(n,e)=>{switch(e){case 0:try{n.createObjectStore(Js)}catch(t){console.warn(t)}}}}).catch(n=>{throw En.create("idb-open",{originalErrorMessage:n.message})})),yc}async function hS(n){try{const t=(await eg()).transaction(Js),r=await t.objectStore(Js).get(tg(n));return await t.done,r}catch(e){if(e instanceof et)Yt.warn(e.message);else{const t=En.create("idb-get",{originalErrorMessage:e?.message});Yt.warn(t.message)}}}async function Md(n,e){try{const r=(await eg()).transaction(Js,"readwrite");await r.objectStore(Js).put(e,tg(n)),await r.done}catch(t){if(t instanceof et)Yt.warn(t.message);else{const r=En.create("idb-set",{originalErrorMessage:t?.message});Yt.warn(r.message)}}}function tg(n){return`${n.name}!${n.options.appId}`}const dS=1024,fS=30;class pS{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new gS(t),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){try{const t=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),r=xd();if(this._heartbeatsCache?.heartbeats==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null)||this._heartbeatsCache.lastSentHeartbeatDate===r||this._heartbeatsCache.heartbeats.some(s=>s.date===r))return;if(this._heartbeatsCache.heartbeats.push({date:r,agent:t}),this._heartbeatsCache.heartbeats.length>fS){const s=_S(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(s,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){Yt.warn(e)}}async getHeartbeatsHeader(){try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null||this._heartbeatsCache.heartbeats.length===0)return"";const e=xd(),{heartbeatsToSend:t,unsentEntries:r}=mS(this._heartbeatsCache.heartbeats),s=vo(JSON.stringify({version:2,heartbeats:t}));return this._heartbeatsCache.lastSentHeartbeatDate=e,r.length>0?(this._heartbeatsCache.heartbeats=r,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),s}catch(e){return Yt.warn(e),""}}}function xd(){return new Date().toISOString().substring(0,10)}function mS(n,e=dS){const t=[];let r=n.slice();for(const s of n){const i=t.find(o=>o.agent===s.agent);if(i){if(i.dates.push(s.date),Fd(t)>e){i.dates.pop();break}}else if(t.push({agent:s.agent,dates:[s.date]}),Fd(t)>e){t.pop();break}r=r.slice(1)}return{heartbeatsToSend:t,unsentEntries:r}}class gS{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return ql()?jl().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const t=await hS(this.app);return t?.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){const r=await this.read();return Md(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){if(await this._canUseIndexedDBPromise){const r=await this.read();return Md(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...e.heartbeats]})}else return}}function Fd(n){return vo(JSON.stringify({version:2,heartbeats:n})).length}function _S(n){if(n.length===0)return-1;let e=0,t=n[0].date;for(let r=1;r<n.length;r++)n[r].date<t&&(t=n[r].date,e=r);return e}function yS(n){je(new Fe("platform-logger",e=>new P0(e),"PRIVATE")),je(new Fe("heartbeat",e=>new pS(e),"PRIVATE")),Te(zc,Vd,n),Te(zc,Vd,"esm2020"),Te("fire-js","")}yS("");var ES="firebase",vS="12.8.0";Te(ES,vS,"app");const ng="@firebase/installations",Wl="0.6.19";const rg=1e4,sg=`w:${Wl}`,ig="FIS_v2",TS="https://firebaseinstallations.googleapis.com/v1",wS=3600*1e3,bS="installations",AS="Installations";const IS={"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."},rr=new Ln(bS,AS,IS);function og(n){return n instanceof et&&n.code.includes("request-failed")}function ag({projectId:n}){return`${TS}/projects/${n}/installations`}function cg(n){return{token:n.token,requestStatus:2,expiresIn:CS(n.expiresIn),creationTime:Date.now()}}async function lg(n,e){const r=(await e.json()).error;return rr.create("request-failed",{requestName:n,serverCode:r.code,serverMessage:r.message,serverStatus:r.status})}function ug({apiKey:n}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":n})}function SS(n,{refreshToken:e}){const t=ug(n);return t.append("Authorization",RS(e)),t}async function hg(n){const e=await n();return e.status>=500&&e.status<600?n():e}function CS(n){return Number(n.replace("s","000"))}function RS(n){return`${ig} ${n}`}async function kS({appConfig:n,heartbeatServiceProvider:e},{fid:t}){const r=ag(n),s=ug(n),i=e.getImmediate({optional:!0});if(i){const h=await i.getHeartbeatsHeader();h&&s.append("x-firebase-client",h)}const o={fid:t,authVersion:ig,appId:n.appId,sdkVersion:sg},c={method:"POST",headers:s,body:JSON.stringify(o)},l=await hg(()=>fetch(r,c));if(l.ok){const h=await l.json();return{fid:h.fid||t,registrationStatus:2,refreshToken:h.refreshToken,authToken:cg(h.authToken)}}else throw await lg("Create Installation",l)}function dg(n){return new Promise(e=>{setTimeout(e,n)})}function PS(n){return btoa(String.fromCharCode(...n)).replace(/\+/g,"-").replace(/\//g,"_")}const NS=/^[cdef][\w-]{21}$/,Yc="";function DS(){try{const n=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(n),n[0]=112+n[0]%16;const t=OS(n);return NS.test(t)?t:Yc}catch{return Yc}}function OS(n){return PS(n).substr(0,22)}function ua(n){return`${n.appName}!${n.appId}`}const fg=new Map;function pg(n,e){const t=ua(n);mg(t,e),VS(t,e)}function mg(n,e){const t=fg.get(n);if(t)for(const r of t)r(e)}function VS(n,e){const t=LS();t&&t.postMessage({key:n,fid:e}),MS()}let Kn=null;function LS(){return!Kn&&"BroadcastChannel"in self&&(Kn=new BroadcastChannel("[Firebase] FID Change"),Kn.onmessage=n=>{mg(n.data.key,n.data.fid)}),Kn}function MS(){fg.size===0&&Kn&&(Kn.close(),Kn=null)}const xS="firebase-installations-database",FS=1,sr="firebase-installations-store";let Ec=null;function zl(){return Ec||(Ec=la(xS,FS,{upgrade:(n,e)=>{e===0&&n.createObjectStore(sr)}})),Ec}async function wo(n,e){const t=ua(n),s=(await zl()).transaction(sr,"readwrite"),i=s.objectStore(sr),o=await i.get(t);return await i.put(e,t),await s.done,(!o||o.fid!==e.fid)&&pg(n,e.fid),e}async function gg(n){const e=ua(n),r=(await zl()).transaction(sr,"readwrite");await r.objectStore(sr).delete(e),await r.done}async function ha(n,e){const t=ua(n),s=(await zl()).transaction(sr,"readwrite"),i=s.objectStore(sr),o=await i.get(t),c=e(o);return c===void 0?await i.delete(t):await i.put(c,t),await s.done,c&&(!o||o.fid!==c.fid)&&pg(n,c.fid),c}async function Kl(n){let e;const t=await ha(n.appConfig,r=>{const s=$S(r),i=US(n,s);return e=i.registrationPromise,i.installationEntry});return t.fid===Yc?{installationEntry:await e}:{installationEntry:t,registrationPromise:e}}function $S(n){const e=n||{fid:DS(),registrationStatus:0};return _g(e)}function US(n,e){if(e.registrationStatus===0){if(!navigator.onLine){const s=Promise.reject(rr.create("app-offline"));return{installationEntry:e,registrationPromise:s}}const t={fid:e.fid,registrationStatus:1,registrationTime:Date.now()},r=BS(n,t);return{installationEntry:t,registrationPromise:r}}else return e.registrationStatus===1?{installationEntry:e,registrationPromise:qS(n)}:{installationEntry:e}}async function BS(n,e){try{const t=await kS(n,e);return wo(n.appConfig,t)}catch(t){throw og(t)&&t.customData.serverCode===409?await gg(n.appConfig):await wo(n.appConfig,{fid:e.fid,registrationStatus:0}),t}}async function qS(n){let e=await $d(n.appConfig);for(;e.registrationStatus===1;)await dg(100),e=await $d(n.appConfig);if(e.registrationStatus===0){const{installationEntry:t,registrationPromise:r}=await Kl(n);return r||t}return e}function $d(n){return ha(n,e=>{if(!e)throw rr.create("installation-not-found");return _g(e)})}function _g(n){return jS(n)?{fid:n.fid,registrationStatus:0}:n}function jS(n){return n.registrationStatus===1&&n.registrationTime+rg<Date.now()}async function HS({appConfig:n,heartbeatServiceProvider:e},t){const r=WS(n,t),s=SS(n,t),i=e.getImmediate({optional:!0});if(i){const h=await i.getHeartbeatsHeader();h&&s.append("x-firebase-client",h)}const o={installation:{sdkVersion:sg,appId:n.appId}},c={method:"POST",headers:s,body:JSON.stringify(o)},l=await hg(()=>fetch(r,c));if(l.ok){const h=await l.json();return cg(h)}else throw await lg("Generate Auth Token",l)}function WS(n,{fid:e}){return`${ag(n)}/${e}/authTokens:generate`}async function Gl(n,e=!1){let t;const r=await ha(n.appConfig,i=>{if(!yg(i))throw rr.create("not-registered");const o=i.authToken;if(!e&&GS(o))return i;if(o.requestStatus===1)return t=zS(n,e),i;{if(!navigator.onLine)throw rr.create("app-offline");const c=QS(i);return t=KS(n,c),c}});return t?await t:r.authToken}async function zS(n,e){let t=await Ud(n.appConfig);for(;t.authToken.requestStatus===1;)await dg(100),t=await Ud(n.appConfig);const r=t.authToken;return r.requestStatus===0?Gl(n,e):r}function Ud(n){return ha(n,e=>{if(!yg(e))throw rr.create("not-registered");const t=e.authToken;return JS(t)?{...e,authToken:{requestStatus:0}}:e})}async function KS(n,e){try{const t=await HS(n,e),r={...e,authToken:t};return await wo(n.appConfig,r),t}catch(t){if(og(t)&&(t.customData.serverCode===401||t.customData.serverCode===404))await gg(n.appConfig);else{const r={...e,authToken:{requestStatus:0}};await wo(n.appConfig,r)}throw t}}function yg(n){return n!==void 0&&n.registrationStatus===2}function GS(n){return n.requestStatus===2&&!YS(n)}function YS(n){const e=Date.now();return e<n.creationTime||n.creationTime+n.expiresIn<e+wS}function QS(n){const e={requestStatus:1,requestTime:Date.now()};return{...n,authToken:e}}function JS(n){return n.requestStatus===1&&n.requestTime+rg<Date.now()}async function XS(n){const e=n,{installationEntry:t,registrationPromise:r}=await Kl(e);return r?r.catch(console.error):Gl(e).catch(console.error),t.fid}async function ZS(n,e=!1){const t=n;return await eC(t),(await Gl(t,e)).token}async function eC(n){const{registrationPromise:e}=await Kl(n);e&&await e}function tC(n){if(!n||!n.options)throw vc("App Configuration");if(!n.name)throw vc("App Name");const e=["projectId","apiKey","appId"];for(const t of e)if(!n.options[t])throw vc(t);return{appName:n.name,projectId:n.options.projectId,apiKey:n.options.apiKey,appId:n.options.appId}}function vc(n){return rr.create("missing-app-config-values",{valueName:n})}const Eg="installations",nC="installations-internal",rC=n=>{const e=n.getProvider("app").getImmediate(),t=tC(e),r=Vt(e,"heartbeat");return{app:e,appConfig:t,heartbeatServiceProvider:r,_delete:()=>Promise.resolve()}},sC=n=>{const e=n.getProvider("app").getImmediate(),t=Vt(e,Eg).getImmediate();return{getId:()=>XS(t),getToken:s=>ZS(t,s)}};function iC(){je(new Fe(Eg,rC,"PUBLIC")),je(new Fe(nC,sC,"PRIVATE"))}iC();Te(ng,Wl);Te(ng,Wl,"esm2020");const bo="analytics",oC="firebase_id",aC="origin",cC=60*1e3,lC="https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig",Yl="https://www.googletagmanager.com/gtag/js";const xe=new ca("@firebase/analytics");const uC={"already-exists":"A Firebase Analytics instance with the appId {$id} already exists. Only one Firebase Analytics instance can be created for each appId.","already-initialized":"initializeAnalytics() cannot be called again with different options than those it was initially called with. It can be called again with the same options to return the existing instance, or getAnalytics() can be used to get a reference to the already-initialized instance.","already-initialized-settings":"Firebase Analytics has already been initialized.settings() must be called before initializing any Analytics instanceor it will have no effect.","interop-component-reg-failed":"Firebase Analytics Interop Component failed to instantiate: {$reason}","invalid-analytics-context":"Firebase Analytics is not supported in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","indexeddb-unavailable":"IndexedDB unavailable or restricted in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","fetch-throttle":"The config fetch request timed out while in an exponential backoff state. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.","config-fetch-failed":"Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}","no-api-key":'The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid API key.',"no-app-id":'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid app ID.',"no-client-id":'The "client_id" field is empty.',"invalid-gtag-resource":"Trusted Types detected an invalid gtag resource: {$gtagURL}."},Ye=new Ln("analytics","Analytics",uC);function hC(n){if(!n.startsWith(Yl)){const e=Ye.create("invalid-gtag-resource",{gtagURL:n});return xe.warn(e.message),""}return n}function vg(n){return Promise.all(n.map(e=>e.catch(t=>t)))}function dC(n,e){let t;return window.trustedTypes&&(t=window.trustedTypes.createPolicy(n,e)),t}function fC(n,e){const t=dC("firebase-js-sdk-policy",{createScriptURL:hC}),r=document.createElement("script"),s=`${Yl}?l=${n}&id=${e}`;r.src=t?t?.createScriptURL(s):s,r.async=!0,document.head.appendChild(r)}function pC(n){let e=[];return Array.isArray(window[n])?e=window[n]:window[n]=e,e}async function mC(n,e,t,r,s,i){const o=r[s];try{if(o)await e[o];else{const l=(await vg(t)).find(h=>h.measurementId===s);l&&await e[l.appId]}}catch(c){xe.error(c)}n("config",s,i)}async function gC(n,e,t,r,s){try{let i=[];if(s&&s.send_to){let o=s.send_to;Array.isArray(o)||(o=[o]);const c=await vg(t);for(const l of o){const h=c.find(g=>g.measurementId===l),f=h&&e[h.appId];if(f)i.push(f);else{i=[];break}}}i.length===0&&(i=Object.values(e)),await Promise.all(i),n("event",r,s||{})}catch(i){xe.error(i)}}function _C(n,e,t,r){async function s(i,...o){try{if(i==="event"){const[c,l]=o;await gC(n,e,t,c,l)}else if(i==="config"){const[c,l]=o;await mC(n,e,t,r,c,l)}else if(i==="consent"){const[c,l]=o;n("consent",c,l)}else if(i==="get"){const[c,l,h]=o;n("get",c,l,h)}else if(i==="set"){const[c]=o;n("set",c)}else n(i,...o)}catch(c){xe.error(c)}}return s}function yC(n,e,t,r,s){let i=function(...o){window[r].push(arguments)};return window[s]&&typeof window[s]=="function"&&(i=window[s]),window[s]=_C(i,n,e,t),{gtagCore:i,wrappedGtag:window[s]}}function EC(n){const e=window.document.getElementsByTagName("script");for(const t of Object.values(e))if(t.src&&t.src.includes(Yl)&&t.src.includes(n))return t;return null}const vC=30,TC=1e3;class wC{constructor(e={},t=TC){this.throttleMetadata=e,this.intervalMillis=t}getThrottleMetadata(e){return this.throttleMetadata[e]}setThrottleMetadata(e,t){this.throttleMetadata[e]=t}deleteThrottleMetadata(e){delete this.throttleMetadata[e]}}const Tg=new wC;function bC(n){return new Headers({Accept:"application/json","x-goog-api-key":n})}async function AC(n){const{appId:e,apiKey:t}=n,r={method:"GET",headers:bC(t)},s=lC.replace("{app-id}",e),i=await fetch(s,r);if(i.status!==200&&i.status!==304){let o="";try{const c=await i.json();c.error?.message&&(o=c.error.message)}catch{}throw Ye.create("config-fetch-failed",{httpStatus:i.status,responseMessage:o})}return i.json()}async function IC(n,e=Tg,t){const{appId:r,apiKey:s,measurementId:i}=n.options;if(!r)throw Ye.create("no-app-id");if(!s){if(i)return{measurementId:i,appId:r};throw Ye.create("no-api-key")}const o=e.getThrottleMetadata(r)||{backoffCount:0,throttleEndTimeMillis:Date.now()},c=new RC;return setTimeout(async()=>{c.abort()},cC),wg({appId:r,apiKey:s,measurementId:i},o,c,e)}async function wg(n,{throttleEndTimeMillis:e,backoffCount:t},r,s=Tg){const{appId:i,measurementId:o}=n;try{await SC(r,e)}catch(c){if(o)return xe.warn(`Timed out fetching this Firebase app's measurement ID from the server. Falling back to the measurement ID ${o} provided in the "measurementId" field in the local Firebase config. [${c?.message}]`),{appId:i,measurementId:o};throw c}try{const c=await AC(n);return s.deleteThrottleMetadata(i),c}catch(c){const l=c;if(!CC(l)){if(s.deleteThrottleMetadata(i),o)return xe.warn(`Failed to fetch this Firebase app's measurement ID from the server. Falling back to the measurement ID ${o} provided in the "measurementId" field in the local Firebase config. [${l?.message}]`),{appId:i,measurementId:o};throw c}const h=Number(l?.customData?.httpStatus)===503?Pd(t,s.intervalMillis,vC):Pd(t,s.intervalMillis),f={throttleEndTimeMillis:Date.now()+h,backoffCount:t+1};return s.setThrottleMetadata(i,f),xe.debug(`Calling attemptFetch again in ${h} millis`),wg(n,f,r,s)}}function SC(n,e){return new Promise((t,r)=>{const s=Math.max(e-Date.now(),0),i=setTimeout(t,s);n.addEventListener(()=>{clearTimeout(i),r(Ye.create("fetch-throttle",{throttleEndTimeMillis:e}))})})}function CC(n){if(!(n instanceof et)||!n.customData)return!1;const e=Number(n.customData.httpStatus);return e===429||e===500||e===503||e===504}class RC{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}async function kC(n,e,t,r,s){if(s&&s.global){n("event",t,r);return}else{const i=await e,o={...r,send_to:i};n("event",t,o)}}async function PC(n,e,t,r){if(r&&r.global){const s={};for(const i of Object.keys(t))s[`user_properties.${i}`]=t[i];return n("set",s),Promise.resolve()}else{const s=await e;n("config",s,{update:!0,user_properties:t})}}async function NC(){if(ql())try{await jl()}catch(n){return xe.warn(Ye.create("indexeddb-unavailable",{errorInfo:n?.toString()}).message),!1}else return xe.warn(Ye.create("indexeddb-unavailable",{errorInfo:"IndexedDB is not available in this environment."}).message),!1;return!0}async function DC(n,e,t,r,s,i,o){const c=IC(n);c.then(_=>{t[_.measurementId]=_.appId,n.options.measurementId&&_.measurementId!==n.options.measurementId&&xe.warn(`The measurement ID in the local Firebase config (${n.options.measurementId}) does not match the measurement ID fetched from the server (${_.measurementId}). To ensure analytics events are always sent to the correct Analytics property, update the measurement ID field in the local config or remove it from the local config.`)}).catch(_=>xe.error(_)),e.push(c);const l=NC().then(_=>{if(_)return r.getId()}),[h,f]=await Promise.all([c,l]);EC(i)||fC(i,h.measurementId),s("js",new Date);const g=o?.config??{};return g[aC]="firebase",g.update=!0,f!=null&&(g[oC]=f),s("config",h.measurementId,g),h.measurementId}class OC{constructor(e){this.app=e}_delete(){return delete Lr[this.app.options.appId],Promise.resolve()}}let Lr={},Bd=[];const qd={};let Tc="dataLayer",VC="gtag",jd,Ql,Hd=!1;function LC(){const n=[];if(Ym()&&n.push("This is a browser extension environment."),Qm()||n.push("Cookies are not available."),n.length>0){const e=n.map((r,s)=>`(${s+1}) ${r}`).join(" "),t=Ye.create("invalid-analytics-context",{errorInfo:e});xe.warn(t.message)}}function MC(n,e,t){LC();const r=n.options.appId;if(!r)throw Ye.create("no-app-id");if(!n.options.apiKey)if(n.options.measurementId)xe.warn(`The "apiKey" field is empty in the local Firebase config. This is needed to fetch the latest measurement ID for this Firebase app. Falling back to the measurement ID ${n.options.measurementId} provided in the "measurementId" field in the local Firebase config.`);else throw Ye.create("no-api-key");if(Lr[r]!=null)throw Ye.create("already-exists",{id:r});if(!Hd){pC(Tc);const{wrappedGtag:i,gtagCore:o}=yC(Lr,Bd,qd,Tc,VC);Ql=i,jd=o,Hd=!0}return Lr[r]=DC(n,Bd,qd,e,jd,Tc,t),new OC(n)}function xC(n=os()){n=ie(n);const e=Vt(n,bo);return e.isInitialized()?e.getImmediate():FC(n)}function FC(n,e={}){const t=Vt(n,bo);if(t.isInitialized()){const s=t.getImmediate();if(An(e,t.getOptions()))return s;throw Ye.create("already-initialized")}return t.initialize({options:e})}function $C(n,e,t){n=ie(n),PC(Ql,Lr[n.app.options.appId],e,t).catch(r=>xe.error(r))}function UC(n,e,t,r){n=ie(n),kC(Ql,Lr[n.app.options.appId],e,t,r).catch(s=>xe.error(s))}const Wd="@firebase/analytics",zd="0.10.19";function BC(){je(new Fe(bo,(e,{options:t})=>{const r=e.getProvider("app").getImmediate(),s=e.getProvider("installations-internal").getImmediate();return MC(r,s,t)},"PUBLIC")),je(new Fe("analytics-internal",n,"PRIVATE")),Te(Wd,zd),Te(Wd,zd,"esm2020");function n(e){try{const t=e.getProvider(bo).getImmediate();return{logEvent:(r,s,i)=>UC(t,r,s,i),setUserProperties:(r,s)=>$C(t,r,s)}}catch(t){throw Ye.create("interop-component-reg-failed",{reason:t})}}}BC();function bg(){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 qC=bg,Ag=new Ln("auth","Firebase",bg());const Ao=new ca("@firebase/auth");function jC(n,...e){Ao.logLevel<=X.WARN&&Ao.warn(`Auth (${dr}): ${n}`,...e)}function ro(n,...e){Ao.logLevel<=X.ERROR&&Ao.error(`Auth (${dr}): ${n}`,...e)}function Nt(n,...e){throw Xl(n,...e)}function mt(n,...e){return Xl(n,...e)}function Jl(n,e,t){const r={...qC(),[e]:t};return new Ln("auth","Firebase",r).create(e,{appName:n.name})}function Jn(n){return Jl(n,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function HC(n,e,t){const r=t;if(!(e instanceof r))throw r.name!==e.constructor.name&&Nt(n,"argument-error"),Jl(n,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function Xl(n,...e){if(typeof n!="string"){const t=e[0],r=[...e.slice(1)];return r[0]&&(r[0].appName=n.name),n._errorFactory.create(t,...r)}return Ag.create(n,...e)}function z(n,e,...t){if(!n)throw Xl(e,...t)}function Bt(n){const e="INTERNAL ASSERTION FAILED: "+n;throw ro(e),new Error(e)}function Qt(n,e){n||Bt(e)}function Qc(){return typeof self<"u"&&self.location?.href||""}function WC(){return Kd()==="http:"||Kd()==="https:"}function Kd(){return typeof self<"u"&&self.location?.protocol||null}function zC(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(WC()||Ym()||"connection"in navigator)?navigator.onLine:!0}function KC(){if(typeof navigator>"u")return null;const n=navigator;return n.languages&&n.languages[0]||n.language||null}class mi{constructor(e,t){this.shortDelay=e,this.longDelay=t,Qt(t>e,"Short delay should be less than long delay!"),this.isMobile=YI()||XI()}get(){return zC()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}function Zl(n,e){Qt(n.emulator,"Emulator should always be set here");const{url:t}=n.emulator;return e?`${t}${e.startsWith("/")?e.slice(1):e}`:t}class Ig{static initialize(e,t,r){this.fetchImpl=e,t&&(this.headersImpl=t),r&&(this.responseImpl=r)}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;Bt("Could not find fetch implementation, make sure you call FetchProvider.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;Bt("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;Bt("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}const GC={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 YC=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],QC=new mi(3e4,6e4);function eu(n,e){return n.tenantId&&!e.tenantId?{...e,tenantId:n.tenantId}:e}async function as(n,e,t,r,s={}){return Sg(n,s,async()=>{let i={},o={};r&&(e==="GET"?o=r:i={body:JSON.stringify(r)});const c=pi({key:n.config.apiKey,...o}).slice(1),l=await n._getAdditionalHeaders();l["Content-Type"]="application/json",n.languageCode&&(l["X-Firebase-Locale"]=n.languageCode);const h={method:e,headers:l,...i};return JI()||(h.referrerPolicy="no-referrer"),n.emulatorConfig&&en(n.emulatorConfig.host)&&(h.credentials="include"),Ig.fetch()(await Cg(n,n.config.apiHost,t,c),h)})}async function Sg(n,e,t){n._canInitEmulator=!1;const r={...GC,...e};try{const s=new XC(n),i=await Promise.race([t(),s.promise]);s.clearNetworkTimeout();const o=await i.json();if("needConfirmation"in o)throw Ki(n,"account-exists-with-different-credential",o);if(i.ok&&!("errorMessage"in o))return o;{const c=i.ok?o.errorMessage:o.error.message,[l,h]=c.split(" : ");if(l==="FEDERATED_USER_ID_ALREADY_LINKED")throw Ki(n,"credential-already-in-use",o);if(l==="EMAIL_EXISTS")throw Ki(n,"email-already-in-use",o);if(l==="USER_DISABLED")throw Ki(n,"user-disabled",o);const f=r[l]||l.toLowerCase().replace(/[_\s]+/g,"-");if(h)throw Jl(n,f,h);Nt(n,f)}}catch(s){if(s instanceof et)throw s;Nt(n,"network-request-failed",{message:String(s)})}}async function JC(n,e,t,r,s={}){const i=await as(n,e,t,r,s);return"mfaPendingCredential"in i&&Nt(n,"multi-factor-auth-required",{_serverResponse:i}),i}async function Cg(n,e,t,r){const s=`${e}${t}?${r}`,i=n,o=i.config.emulator?Zl(n.config,s):`${n.config.apiScheme}://${s}`;return YC.includes(t)&&(await i._persistenceManagerAvailable,i._getPersistenceType()==="COOKIE")?i._getPersistence()._getFinalTarget(o).toString():o}class XC{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((t,r)=>{this.timer=setTimeout(()=>r(mt(this.auth,"network-request-failed")),QC.get())})}}function Ki(n,e,t){const r={appName:n.name};t.email&&(r.email=t.email),t.phoneNumber&&(r.phoneNumber=t.phoneNumber);const s=mt(n,e,r);return s.customData._tokenResponse=t,s}async function ZC(n,e){return as(n,"POST","/v1/accounts:delete",e)}async function Io(n,e){return as(n,"POST","/v1/accounts:lookup",e)}function js(n){if(n)try{const e=new Date(Number(n));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function eR(n,e=!1){const t=ie(n),r=await t.getIdToken(e),s=tu(r);z(s&&s.exp&&s.auth_time&&s.iat,t.auth,"internal-error");const i=typeof s.firebase=="object"?s.firebase:void 0,o=i?.sign_in_provider;return{claims:s,token:r,authTime:js(wc(s.auth_time)),issuedAtTime:js(wc(s.iat)),expirationTime:js(wc(s.exp)),signInProvider:o||null,signInSecondFactor:i?.sign_in_second_factor||null}}function wc(n){return Number(n)*1e3}function tu(n){const[e,t,r]=n.split(".");if(e===void 0||t===void 0||r===void 0)return ro("JWT malformed, contained fewer than 3 sections"),null;try{const s=Hm(t);return s?JSON.parse(s):(ro("Failed to decode base64 JWT payload"),null)}catch(s){return ro("Caught error parsing JWT payload as JSON",s?.toString()),null}}function Gd(n){const e=tu(n);return z(e,"internal-error"),z(typeof e.exp<"u","internal-error"),z(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}async function Xs(n,e,t=!1){if(t)return e;try{return await e}catch(r){throw r instanceof et&&tR(r)&&n.auth.currentUser===n&&await n.auth.signOut(),r}}function tR({code:n}){return n==="auth/user-disabled"||n==="auth/user-token-expired"}class nR{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 r=(this.user.stsTokenManager.expirationTime??0)-Date.now()-3e5;return Math.max(0,r)}}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 Jc{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=js(this.lastLoginAt),this.creationTime=js(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function So(n){const e=n.auth,t=await n.getIdToken(),r=await Xs(n,Io(e,{idToken:t}));z(r?.users.length,e,"internal-error");const s=r.users[0];n._notifyReloadListener(s);const i=s.providerUserInfo?.length?Rg(s.providerUserInfo):[],o=sR(n.providerData,i),c=n.isAnonymous,l=!(n.email&&s.passwordHash)&&!o?.length,h=c?l:!1,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 Jc(s.createdAt,s.lastLoginAt),isAnonymous:h};Object.assign(n,f)}async function rR(n){const e=ie(n);await So(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function sR(n,e){return[...n.filter(r=>!e.some(s=>s.providerId===r.providerId)),...e]}function Rg(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 iR(n,e){const t=await Sg(n,{},async()=>{const r=pi({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:s,apiKey:i}=n.config,o=await Cg(n,s,"/v1/token",`key=${i}`),c=await n._getAdditionalHeaders();c["Content-Type"]="application/x-www-form-urlencoded";const l={method:"POST",headers:c,body:r};return n.emulatorConfig&&en(n.emulatorConfig.host)&&(l.credentials="include"),Ig.fetch()(o,l)});return{accessToken:t.access_token,expiresIn:t.expires_in,refreshToken:t.refresh_token}}async function oR(n,e){return as(n,"POST","/v2/accounts:revokeToken",eu(n,e))}class Mr{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){z(e.idToken,"internal-error"),z(typeof e.idToken<"u","internal-error"),z(typeof e.refreshToken<"u","internal-error");const t="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):Gd(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){z(e.length!==0,"internal-error");const t=Gd(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(z(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:r,refreshToken:s,expiresIn:i}=await iR(e,t);this.updateTokensAndExpiration(r,s,Number(i))}updateTokensAndExpiration(e,t,r){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+r*1e3}static fromJSON(e,t){const{refreshToken:r,accessToken:s,expirationTime:i}=t,o=new Mr;return r&&(z(typeof r=="string","internal-error",{appName:e}),o.refreshToken=r),s&&(z(typeof s=="string","internal-error",{appName:e}),o.accessToken=s),i&&(z(typeof i=="number","internal-error",{appName:e}),o.expirationTime=i),o}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 Mr,this.toJSON())}_performRefresh(){return Bt("not implemented")}}function fn(n,e){z(typeof n=="string"||typeof n>"u","internal-error",{appName:e})}class ft{constructor({uid:e,auth:t,stsTokenManager:r,...s}){this.providerId="firebase",this.proactiveRefresh=new nR(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=t,this.stsTokenManager=r,this.accessToken=r.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 Jc(s.createdAt||void 0,s.lastLoginAt||void 0)}async getIdToken(e){const t=await Xs(this,this.stsTokenManager.getToken(this.auth,e));return z(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return eR(this,e)}reload(){return rR(this)}_assign(e){this!==e&&(z(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 ft({...this,auth:e,stsTokenManager:this.stsTokenManager._clone()});return t.metadata._copy(this.metadata),t}_onReload(e){z(!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 r=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),r=!0),t&&await So(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(Ke(this.auth.app))return Promise.reject(Jn(this.auth));const e=await this.getIdToken();return await Xs(this,ZC(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 r=t.displayName??void 0,s=t.email??void 0,i=t.phoneNumber??void 0,o=t.photoURL??void 0,c=t.tenantId??void 0,l=t._redirectEventId??void 0,h=t.createdAt??void 0,f=t.lastLoginAt??void 0,{uid:g,emailVerified:_,isAnonymous:T,providerData:C,stsTokenManager:P}=t;z(g&&P,e,"internal-error");const k=Mr.fromJSON(this.name,P);z(typeof g=="string",e,"internal-error"),fn(r,e.name),fn(s,e.name),z(typeof _=="boolean",e,"internal-error"),z(typeof T=="boolean",e,"internal-error"),fn(i,e.name),fn(o,e.name),fn(c,e.name),fn(l,e.name),fn(h,e.name),fn(f,e.name);const L=new ft({uid:g,auth:e,email:s,emailVerified:_,displayName:r,isAnonymous:T,photoURL:o,phoneNumber:i,tenantId:c,stsTokenManager:k,createdAt:h,lastLoginAt:f});return C&&Array.isArray(C)&&(L.providerData=C.map($=>({...$}))),l&&(L._redirectEventId=l),L}static async _fromIdTokenResponse(e,t,r=!1){const s=new Mr;s.updateFromServerResponse(t);const i=new ft({uid:t.localId,auth:e,stsTokenManager:s,isAnonymous:r});return await So(i),i}static async _fromGetAccountInfoResponse(e,t,r){const s=t.users[0];z(s.localId!==void 0,"internal-error");const i=s.providerUserInfo!==void 0?Rg(s.providerUserInfo):[],o=!(s.email&&s.passwordHash)&&!i?.length,c=new Mr;c.updateFromIdToken(r);const l=new ft({uid:s.localId,auth:e,stsTokenManager:c,isAnonymous:o}),h={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:i,metadata:new Jc(s.createdAt,s.lastLoginAt),isAnonymous:!(s.email&&s.passwordHash)&&!i?.length};return Object.assign(l,h),l}}const Yd=new Map;function qt(n){Qt(n instanceof Function,"Expected a class definition");let e=Yd.get(n);return e?(Qt(e instanceof n,"Instance stored in cache mismatched with class"),e):(e=new n,Yd.set(n,e),e)}class kg{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){}}kg.type="NONE";const Qd=kg;function so(n,e,t){return`firebase:${n}:${e}:${t}`}class xr{constructor(e,t,r){this.persistence=e,this.auth=t,this.userKey=r;const{config:s,name:i}=this.auth;this.fullUserKey=so(this.userKey,s.apiKey,i),this.fullPersistenceKey=so("persistence",s.apiKey,i),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);if(!e)return null;if(typeof e=="string"){const t=await Io(this.auth,{idToken:e}).catch(()=>{});return t?ft._fromGetAccountInfoResponse(this.auth,t,e):null}return ft._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,r="authUser"){if(!t.length)return new xr(qt(Qd),e,r);const s=(await Promise.all(t.map(async h=>{if(await h._isAvailable())return h}))).filter(h=>h);let i=s[0]||qt(Qd);const o=so(r,e.config.apiKey,e.name);let c=null;for(const h of t)try{const f=await h._get(o);if(f){let g;if(typeof f=="string"){const _=await Io(e,{idToken:f}).catch(()=>{});if(!_)break;g=await ft._fromGetAccountInfoResponse(e,_,f)}else g=ft._fromJSON(e,f);h!==i&&(c=g),i=h;break}}catch{}const l=s.filter(h=>h._shouldAllowMigration);return!i._shouldAllowMigration||!l.length?new xr(i,e,r):(i=l[0],c&&await i._set(o,c.toJSON()),await Promise.all(t.map(async h=>{if(h!==i)try{await h._remove(o)}catch{}})),new xr(i,e,r))}}function Jd(n){const e=n.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(Og(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(Pg(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(Lg(e))return"Blackberry";if(Mg(e))return"Webos";if(Ng(e))return"Safari";if((e.includes("chrome/")||Dg(e))&&!e.includes("edge/"))return"Chrome";if(Vg(e))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,r=n.match(t);if(r?.length===2)return r[1]}return"Other"}function Pg(n=Pe()){return/firefox\//i.test(n)}function Ng(n=Pe()){const e=n.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function Dg(n=Pe()){return/crios\//i.test(n)}function Og(n=Pe()){return/iemobile/i.test(n)}function Vg(n=Pe()){return/android/i.test(n)}function Lg(n=Pe()){return/blackberry/i.test(n)}function Mg(n=Pe()){return/webos/i.test(n)}function nu(n=Pe()){return/iphone|ipad|ipod/i.test(n)||/macintosh/i.test(n)&&/mobile/i.test(n)}function aR(n=Pe()){return nu(n)&&!!window.navigator?.standalone}function cR(){return ZI()&&document.documentMode===10}function xg(n=Pe()){return nu(n)||Vg(n)||Mg(n)||Lg(n)||/windows phone/i.test(n)||Og(n)}function Fg(n,e=[]){let t;switch(n){case"Browser":t=Jd(Pe());break;case"Worker":t=`${Jd(Pe())}-${n}`;break;default:t=n}const r=e.length?e.join(","):"FirebaseCore-web";return`${t}/JsCore/${dr}/${r}`}class lR{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const r=i=>new Promise((o,c)=>{try{const l=e(i);o(l)}catch(l){c(l)}});r.onAbort=t,this.queue.push(r);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 r of this.queue)await r(e),r.onAbort&&t.push(r.onAbort)}catch(r){t.reverse();for(const s of t)try{s()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:r?.message})}}}async function uR(n,e={}){return as(n,"GET","/v2/passwordPolicy",eu(n,e))}const hR=6;class dR{constructor(e){const t=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=t.minPasswordLength??hR,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&&(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 r=this.customStrengthOptions.minPasswordLength,s=this.customStrengthOptions.maxPasswordLength;r&&(t.meetsMinPasswordLength=e.length>=r),s&&(t.meetsMaxPasswordLength=e.length<=s)}validatePasswordCharacterOptions(e,t){this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);let r;for(let s=0;s<e.length;s++)r=e.charAt(s),this.updatePasswordCharacterOptionsStatuses(t,r>="a"&&r<="z",r>="A"&&r<="Z",r>="0"&&r<="9",this.allowedNonAlphanumericCharacters.includes(r))}updatePasswordCharacterOptionsStatuses(e,t,r,s,i){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=r)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=s)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=i))}}class fR{constructor(e,t,r,s){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=r,this.config=s,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new Xd(this),this.idTokenSubscription=new Xd(this),this.beforeStateQueue=new lR(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=Ag,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(i=>this._resolvePersistenceManagerAvailable=i)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=qt(t)),this._initializationPromise=this.queue(async()=>{if(!this._deleted&&(this.persistenceManager=await xr.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 Io(this,{idToken:e}),r=await ft._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(r)}catch(t){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",t),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){if(Ke(this.app)){const i=this.app.settings.authIdToken;return i?new Promise(o=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(i).then(o,o))}):this.directlySetCurrentUser(null)}const t=await this.assertedPersistence.getCurrentUser();let r=t,s=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const i=this.redirectUser?._redirectEventId,o=r?._redirectEventId,c=await this.tryRedirectSignIn(e);(!i||i===o)&&c?.user&&(r=c.user,s=!0)}if(!r)return this.directlySetCurrentUser(null);if(!r._redirectEventId){if(s)try{await this.beforeStateQueue.runMiddleware(r)}catch(i){r=t,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(i))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return z(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===r._redirectEventId?this.directlySetCurrentUser(r):this.reloadAndSetCurrentUserOrClear(r)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await So(e)}catch(t){if(t?.code!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=KC()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(Ke(this.app))return Promise.reject(Jn(this));const t=e?ie(e):null;return t&&z(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&&z(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 Ke(this.app)?Promise.reject(Jn(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return Ke(this.app)?Promise.reject(Jn(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(qt(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 uR(this),t=new dR(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 Ln("auth","Firebase",e())}onAuthStateChanged(e,t,r){return this.registerStateListener(this.authStateSubscription,e,t,r)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,r){return this.registerStateListener(this.idTokenSubscription,e,t,r)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{const r=this.onAuthStateChanged(()=>{r(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){const t=await this.currentUser.getIdToken(),r={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:t};this.tenantId!=null&&(r.tenantId=this.tenantId),await oR(this,r)}}toJSON(){return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:this._currentUser?.toJSON()}}async _setRedirectUser(e,t){const r=await this.getOrInitRedirectPersistenceManager(t);return e===null?r.removeCurrentUser():r.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&qt(e)||this._popupRedirectResolver;z(t,this,"argument-error"),this.redirectPersistenceManager=await xr.create(this,[qt(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,r,s){if(this._deleted)return()=>{};const i=typeof t=="function"?t:t.next.bind(t);let o=!1;const c=this._isInitialized?Promise.resolve():this._initializationPromise;if(z(c,this,"internal-error"),c.then(()=>{o||i(this.currentUser)}),typeof t=="function"){const l=e.addObserver(t,r,s);return()=>{o=!0,l()}}else{const l=e.addObserver(t);return()=>{o=!0,l()}}}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 z(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=Fg(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 r=await this._getAppCheckToken();return r&&(e["X-Firebase-AppCheck"]=r),e}async _getAppCheckToken(){if(Ke(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=await this.appCheckServiceProvider.getImmediate({optional:!0})?.getToken();return e?.error&&jC(`Error while retrieving App Check token: ${e.error}`),e?.token}}function da(n){return ie(n)}class Xd{constructor(e){this.auth=e,this.observer=null,this.addObserver=i0(t=>this.observer=t)}get next(){return z(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}let ru={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function pR(n){ru=n}function mR(n){return ru.loadJS(n)}function gR(){return ru.gapiScript}function _R(n){return`__${n}${Math.floor(Math.random()*1e6)}`}function yR(n,e){const t=Vt(n,"auth");if(t.isInitialized()){const s=t.getImmediate(),i=t.getOptions();if(An(i,e??{}))return s;Nt(s,"already-initialized")}return t.initialize({options:e})}function ER(n,e){const t=e?.persistence||[],r=(Array.isArray(t)?t:[t]).map(qt);e?.errorMap&&n._updateErrorMap(e.errorMap),n._initializeWithPersistence(r,e?.popupRedirectResolver)}function $g(n,e,t){const r=da(n);z(/^https?:\/\//.test(e),r,"invalid-emulator-scheme");const s=!1,i=Ug(e),{host:o,port:c}=vR(e),l=c===null?"":`:${c}`,h={url:`${i}//${o}${l}/`},f=Object.freeze({host:o,port:c,protocol:i.replace(":",""),options:Object.freeze({disableWarnings:s})});if(!r._canInitEmulator){z(r.config.emulator&&r.emulatorConfig,r,"emulator-config-failed"),z(An(h,r.config.emulator)&&An(f,r.emulatorConfig),r,"emulator-config-failed");return}r.config.emulator=h,r.emulatorConfig=f,r.settings.appVerificationDisabledForTesting=!0,en(o)?(oa(`${i}//${o}${l}`),aa("Auth",!0)):TR()}function Ug(n){const e=n.indexOf(":");return e<0?"":n.substr(0,e+1)}function vR(n){const e=Ug(n),t=/(\/\/)?([^?#/]+)/.exec(n.substr(e.length));if(!t)return{host:"",port:null};const r=t[2].split("@").pop()||"",s=/^(\[[^\]]+\])(:|$)/.exec(r);if(s){const i=s[1];return{host:i,port:Zd(r.substr(i.length+1))}}else{const[i,o]=r.split(":");return{host:i,port:Zd(o)}}}function Zd(n){if(!n)return null;const e=Number(n);return isNaN(e)?null:e}function TR(){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 Bg{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return Bt("not implemented")}_getIdTokenResponse(e){return Bt("not implemented")}_linkToIdToken(e,t){return Bt("not implemented")}_getReauthenticationResolver(e){return Bt("not implemented")}}async function Fr(n,e){return JC(n,"POST","/v1/accounts:signInWithIdp",eu(n,e))}const wR="http://localhost";class ir extends Bg{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new ir(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):Nt("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:r,signInMethod:s,...i}=t;if(!r||!s)return null;const o=new ir(r,s);return o.idToken=i.idToken||void 0,o.accessToken=i.accessToken||void 0,o.secret=i.secret,o.nonce=i.nonce,o.pendingToken=i.pendingToken||null,o}_getIdTokenResponse(e){const t=this.buildRequest();return Fr(e,t)}_linkToIdToken(e,t){const r=this.buildRequest();return r.idToken=t,Fr(e,r)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,Fr(e,t)}buildRequest(){const e={requestUri:wR,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=pi(t)}return e}}class su{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 gi extends su{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class mn extends gi{constructor(){super("facebook.com")}static credential(e){return ir._fromParams({providerId:mn.PROVIDER_ID,signInMethod:mn.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return mn.credentialFromTaggedObject(e)}static credentialFromError(e){return mn.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return mn.credential(e.oauthAccessToken)}catch{return null}}}mn.FACEBOOK_SIGN_IN_METHOD="facebook.com";mn.PROVIDER_ID="facebook.com";class Ut extends gi{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return ir._fromParams({providerId:Ut.PROVIDER_ID,signInMethod:Ut.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken: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{oauthIdToken:t,oauthAccessToken:r}=e;if(!t&&!r)return null;try{return Ut.credential(t,r)}catch{return null}}}Ut.GOOGLE_SIGN_IN_METHOD="google.com";Ut.PROVIDER_ID="google.com";class gn extends gi{constructor(){super("github.com")}static credential(e){return ir._fromParams({providerId:gn.PROVIDER_ID,signInMethod:gn.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return gn.credentialFromTaggedObject(e)}static credentialFromError(e){return gn.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return gn.credential(e.oauthAccessToken)}catch{return null}}}gn.GITHUB_SIGN_IN_METHOD="github.com";gn.PROVIDER_ID="github.com";class _n extends gi{constructor(){super("twitter.com")}static credential(e,t){return ir._fromParams({providerId:_n.PROVIDER_ID,signInMethod:_n.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return _n.credentialFromTaggedObject(e)}static credentialFromError(e){return _n.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:r}=e;if(!t||!r)return null;try{return _n.credential(t,r)}catch{return null}}}_n.TWITTER_SIGN_IN_METHOD="twitter.com";_n.PROVIDER_ID="twitter.com";class Gr{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,r,s=!1){const i=await ft._fromIdTokenResponse(e,r,s),o=ef(r);return new Gr({user:i,providerId:o,_tokenResponse:r,operationType:t})}static async _forOperation(e,t,r){await e._updateTokensIfNecessary(r,!0);const s=ef(r);return new Gr({user:e,providerId:s,_tokenResponse:r,operationType:t})}}function ef(n){return n.providerId?n.providerId:"phoneNumber"in n?"phone":null}class Co extends et{constructor(e,t,r,s){super(t.code,t.message),this.operationType=r,this.user=s,Object.setPrototypeOf(this,Co.prototype),this.customData={appName:e.name,tenantId:e.tenantId??void 0,_serverResponse:t.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(e,t,r,s){return new Co(e,t,r,s)}}function qg(n,e,t,r){return(e==="reauthenticate"?t._getReauthenticationResolver(n):t._getIdTokenResponse(n)).catch(i=>{throw i.code==="auth/multi-factor-auth-required"?Co._fromErrorAndOperation(n,i,e,r):i})}async function bR(n,e,t=!1){const r=await Xs(n,e._linkToIdToken(n.auth,await n.getIdToken()),t);return Gr._forOperation(n,"link",r)}async function AR(n,e,t=!1){const{auth:r}=n;if(Ke(r.app))return Promise.reject(Jn(r));const s="reauthenticate";try{const i=await Xs(n,qg(r,s,e,n),t);z(i.idToken,r,"internal-error");const o=tu(i.idToken);z(o,r,"internal-error");const{sub:c}=o;return z(n.uid===c,r,"user-mismatch"),Gr._forOperation(n,s,i)}catch(i){throw i?.code==="auth/user-not-found"&&Nt(r,"user-mismatch"),i}}async function IR(n,e,t=!1){if(Ke(n.app))return Promise.reject(Jn(n));const r="signIn",s=await qg(n,r,e),i=await Gr._fromIdTokenResponse(n,r,s);return t||await n._updateCurrentUser(i.user),i}function SR(n,e,t,r){return ie(n).onIdTokenChanged(e,t,r)}function CR(n,e,t){return ie(n).beforeAuthStateChanged(e,t)}const Ro="__sak";class jg{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Ro,"1"),this.storage.removeItem(Ro),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 RR=1e3,kR=10;class Hg extends jg{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=xg(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const r=this.storage.getItem(t),s=this.localCache[t];r!==s&&e(t,s,r)}}onStorageEvent(e,t=!1){if(!e.key){this.forAllChangedKeys((o,c,l)=>{this.notifyListeners(o,l)});return}const r=e.key;t?this.detachListener():this.stopPolling();const s=()=>{const o=this.storage.getItem(r);!t&&this.localCache[r]===o||this.notifyListeners(r,o)},i=this.storage.getItem(r);cR()&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(s,kR):s()}notifyListeners(e,t){this.localCache[e]=t;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(t&&JSON.parse(t))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,r)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:r}),!0)})},RR)}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]),Object.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]}}Hg.type="LOCAL";const PR=Hg;class Wg extends jg{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}Wg.type="SESSION";const zg=Wg;function NR(n){return Promise.all(n.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(t){return{fulfilled:!1,reason:t}}}))}class fa{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 r=new fa(e);return this.receivers.push(r),r}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:r,eventType:s,data:i}=t.data,o=this.handlersMap[s];if(!o?.size)return;t.ports[0].postMessage({status:"ack",eventId:r,eventType:s});const c=Array.from(o).map(async h=>h(t.origin,i)),l=await NR(c);t.ports[0].postMessage({status:"done",eventId:r,eventType:s,response:l})}_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)}}fa.receivers=[];function iu(n="",e=10){let t="";for(let r=0;r<e;r++)t+=Math.floor(Math.random()*10);return n+t}class DR{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,r=50){const s=typeof MessageChannel<"u"?new MessageChannel:null;if(!s)throw new Error("connection_unavailable");let i,o;return new Promise((c,l)=>{const h=iu("",20);s.port1.start();const f=setTimeout(()=>{l(new Error("unsupported_event"))},r);o={messageChannel:s,onMessage(g){const _=g;if(_.data.eventId===h)switch(_.data.status){case"ack":clearTimeout(f),i=setTimeout(()=>{l(new Error("timeout"))},3e3);break;case"done":clearTimeout(i),c(_.data.response);break;default:clearTimeout(f),clearTimeout(i),l(new Error("invalid_response"));break}}},this.handlers.add(o),s.port1.addEventListener("message",o.onMessage),this.target.postMessage({eventType:e,eventId:h,data:t},[s.port2])}).finally(()=>{o&&this.removeMessageHandler(o)})}}function St(){return window}function OR(n){St().location.href=n}function Kg(){return typeof St().WorkerGlobalScope<"u"&&typeof St().importScripts=="function"}async function VR(){if(!navigator?.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function LR(){return navigator?.serviceWorker?.controller||null}function MR(){return Kg()?self:null}const Gg="firebaseLocalStorageDb",xR=1,ko="firebaseLocalStorage",Yg="fbase_key";class _i{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 pa(n,e){return n.transaction([ko],e?"readwrite":"readonly").objectStore(ko)}function FR(){const n=indexedDB.deleteDatabase(Gg);return new _i(n).toPromise()}function Xc(){const n=indexedDB.open(Gg,xR);return new Promise((e,t)=>{n.addEventListener("error",()=>{t(n.error)}),n.addEventListener("upgradeneeded",()=>{const r=n.result;try{r.createObjectStore(ko,{keyPath:Yg})}catch(s){t(s)}}),n.addEventListener("success",async()=>{const r=n.result;r.objectStoreNames.contains(ko)?e(r):(r.close(),await FR(),e(await Xc()))})})}async function tf(n,e,t){const r=pa(n,!0).put({[Yg]:e,value:t});return new _i(r).toPromise()}async function $R(n,e){const t=pa(n,!1).get(e),r=await new _i(t).toPromise();return r===void 0?null:r.value}function nf(n,e){const t=pa(n,!0).delete(e);return new _i(t).toPromise()}const UR=800,BR=3;class Qg{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 Xc(),this.db)}async _withRetries(e){let t=0;for(;;)try{const r=await this._openDb();return await e(r)}catch(r){if(t++>BR)throw r;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return Kg()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=fa._getInstance(MR()),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 VR(),!this.activeServiceWorker)return;this.sender=new DR(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||LR()!==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 Xc();return await tf(e,Ro,"1"),await nf(e,Ro),!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(r=>tf(r,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){const t=await this._withRetries(r=>$R(r,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>nf(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(s=>{const i=pa(s,!1).getAll();return new _i(i).toPromise()});if(!e)return[];if(this.pendingWrites!==0)return[];const t=[],r=new Set;if(e.length!==0)for(const{fbase_key:s,value:i}of e)r.add(s),JSON.stringify(this.localCache[s])!==JSON.stringify(i)&&(this.notifyListeners(s,i),t.push(s));for(const s of Object.keys(this.localCache))this.localCache[s]&&!r.has(s)&&(this.notifyListeners(s,null),t.push(s));return t}notifyListeners(e,t){this.localCache[e]=t;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),UR)}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]),Object.keys(this.listeners).length===0&&this.stopPolling()}}Qg.type="LOCAL";const qR=Qg;new mi(3e4,6e4);function Jg(n,e){return e?qt(e):(z(n._popupRedirectResolver,n,"argument-error"),n._popupRedirectResolver)}class ou extends Bg{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return Fr(e,this._buildIdpRequest())}_linkToIdToken(e,t){return Fr(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return Fr(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 jR(n){return IR(n.auth,new ou(n),n.bypassAuthState)}function HR(n){const{auth:e,user:t}=n;return z(t,e,"internal-error"),AR(t,new ou(n),n.bypassAuthState)}async function WR(n){const{auth:e,user:t}=n;return z(t,e,"internal-error"),bR(t,new ou(n),n.bypassAuthState)}class Xg{constructor(e,t,r,s,i=!1){this.auth=e,this.resolver=r,this.user=s,this.bypassAuthState=i,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(r){this.reject(r)}})}async onAuthEvent(e){const{urlResponse:t,sessionId:r,postBody:s,tenantId:i,error:o,type:c}=e;if(o){this.reject(o);return}const l={auth:this.auth,requestUri:t,sessionId:r,tenantId:i||void 0,postBody:s||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(c)(l))}catch(h){this.reject(h)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return jR;case"linkViaPopup":case"linkViaRedirect":return WR;case"reauthViaPopup":case"reauthViaRedirect":return HR;default:Nt(this.auth,"internal-error")}}resolve(e){Qt(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){Qt(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 zR=new mi(2e3,1e4);async function KR(n,e,t){if(Ke(n.app))return Promise.reject(mt(n,"operation-not-supported-in-this-environment"));const r=da(n);HC(n,e,su);const s=Jg(r,t);return new Gn(r,"signInViaPopup",e,s).executeNotNull()}class Gn extends Xg{constructor(e,t,r,s,i){super(e,t,s,i),this.provider=r,this.authWindow=null,this.pollId=null,Gn.currentPopupAction&&Gn.currentPopupAction.cancel(),Gn.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return z(e,this.auth,"internal-error"),e}async onExecution(){Qt(this.filter.length===1,"Popup operations only handle one event");const e=iu();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(mt(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){return this.authWindow?.associatedEvent||null}cancel(){this.reject(mt(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,Gn.currentPopupAction=null}pollUserCancellation(){const e=()=>{if(this.authWindow?.window?.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(mt(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,zR.get())};e()}}Gn.currentPopupAction=null;const GR="pendingRedirect",io=new Map;class YR extends Xg{constructor(e,t,r=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,r),this.eventId=null}async execute(){let e=io.get(this.auth._key());if(!e){try{const r=await QR(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(r)}catch(t){e=()=>Promise.reject(t)}io.set(this.auth._key(),e)}return this.bypassAuthState||io.set(this.auth._key(),()=>Promise.resolve(null)),e()}async 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 QR(n,e){const t=ZR(e),r=XR(n);if(!await r._isAvailable())return!1;const s=await r._get(t)==="true";return await r._remove(t),s}function JR(n,e){io.set(n._key(),e)}function XR(n){return qt(n._redirectPersistence)}function ZR(n){return so(GR,n.config.apiKey,n.name)}async function ek(n,e,t=!1){if(Ke(n.app))return Promise.reject(Jn(n));const r=da(n),s=Jg(r,e),o=await new YR(r,s,t).execute();return o&&!t&&(delete o.user._redirectEventId,await r._persistUserIfCurrent(o.user),await r._setRedirectUser(null,e)),o}const tk=600*1e3;class nk{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(r=>{this.isEventForConsumer(e,r)&&(t=!0,this.sendToConsumer(e,r),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!rk(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){if(e.error&&!Zg(e)){const r=e.error.code?.split("auth/")[1]||"internal-error";t.onError(mt(this.auth,r))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const r=t.eventId===null||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&r}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=tk&&this.cachedEventUids.clear(),this.cachedEventUids.has(rf(e))}saveEventToCache(e){this.cachedEventUids.add(rf(e)),this.lastProcessedEventTime=Date.now()}}function rf(n){return[n.type,n.eventId,n.sessionId,n.tenantId].filter(e=>e).join("-")}function Zg({type:n,error:e}){return n==="unknown"&&e?.code==="auth/no-auth-event"}function rk(n){switch(n.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return Zg(n);default:return!1}}async function sk(n,e={}){return as(n,"GET","/v1/projects",e)}const ik=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,ok=/^https?/;async function ak(n){if(n.config.emulator)return;const{authorizedDomains:e}=await sk(n);for(const t of e)try{if(ck(t))return}catch{}Nt(n,"unauthorized-domain")}function ck(n){const e=Qc(),{protocol:t,hostname:r}=new URL(e);if(n.startsWith("chrome-extension://")){const o=new URL(n);return o.hostname===""&&r===""?t==="chrome-extension:"&&n.replace("chrome-extension://","")===e.replace("chrome-extension://",""):t==="chrome-extension:"&&o.hostname===r}if(!ok.test(t))return!1;if(ik.test(n))return r===n;const s=n.replace(/\./g,"\\.");return new RegExp("^(.+\\."+s+"|"+s+")$","i").test(r)}const lk=new mi(3e4,6e4);function sf(){const n=St().___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 uk(n){return new Promise((e,t)=>{function r(){sf(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{sf(),t(mt(n,"network-request-failed"))},timeout:lk.get()})}if(St().gapi?.iframes?.Iframe)e(gapi.iframes.getContext());else if(St().gapi?.load)r();else{const s=_R("iframefcb");return St()[s]=()=>{gapi.load?r():t(mt(n,"network-request-failed"))},mR(`${gR()}?onload=${s}`).catch(i=>t(i))}}).catch(e=>{throw oo=null,e})}let oo=null;function hk(n){return oo=oo||uk(n),oo}const dk=new mi(5e3,15e3),fk="__/auth/iframe",pk="emulator/auth/iframe",mk={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},gk=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function _k(n){const e=n.config;z(e.authDomain,n,"auth-domain-config-required");const t=e.emulator?Zl(e,pk):`https://${n.config.authDomain}/${fk}`,r={apiKey:e.apiKey,appName:n.name,v:dr},s=gk.get(n.config.apiHost);s&&(r.eid=s);const i=n._getFrameworks();return i.length&&(r.fw=i.join(",")),`${t}?${pi(r).slice(1)}`}async function yk(n){const e=await hk(n),t=St().gapi;return z(t,n,"internal-error"),e.open({where:document.body,url:_k(n),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:mk,dontclear:!0},r=>new Promise(async(s,i)=>{await r.restyle({setHideOnLeave:!1});const o=mt(n,"network-request-failed"),c=St().setTimeout(()=>{i(o)},dk.get());function l(){St().clearTimeout(c),s(r)}r.ping(l).then(l,()=>{i(o)})}))}const Ek={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},vk=500,Tk=600,wk="_blank",bk="http://localhost";class of{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function Ak(n,e,t,r=vk,s=Tk){const i=Math.max((window.screen.availHeight-s)/2,0).toString(),o=Math.max((window.screen.availWidth-r)/2,0).toString();let c="";const l={...Ek,width:r.toString(),height:s.toString(),top:i,left:o},h=Pe().toLowerCase();t&&(c=Dg(h)?wk:t),Pg(h)&&(e=e||bk,l.scrollbars="yes");const f=Object.entries(l).reduce((_,[T,C])=>`${_}${T}=${C},`,"");if(aR(h)&&c!=="_self")return Ik(e||"",c),new of(null);const g=window.open(e||"",c,f);z(g,n,"popup-blocked");try{g.focus()}catch{}return new of(g)}function Ik(n,e){const t=document.createElement("a");t.href=n,t.target=e;const r=document.createEvent("MouseEvent");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),t.dispatchEvent(r)}const Sk="__/auth/handler",Ck="emulator/auth/handler",Rk=encodeURIComponent("fac");async function af(n,e,t,r,s,i){z(n.config.authDomain,n,"auth-domain-config-required"),z(n.config.apiKey,n,"invalid-api-key");const o={apiKey:n.config.apiKey,appName:n.name,authType:t,redirectUrl:r,v:dr,eventId:s};if(e instanceof su){e.setDefaultLanguage(n.languageCode),o.providerId=e.providerId||"",s0(e.getCustomParameters())||(o.customParameters=JSON.stringify(e.getCustomParameters()));for(const[f,g]of Object.entries({}))o[f]=g}if(e instanceof gi){const f=e.getScopes().filter(g=>g!=="");f.length>0&&(o.scopes=f.join(","))}n.tenantId&&(o.tid=n.tenantId);const c=o;for(const f of Object.keys(c))c[f]===void 0&&delete c[f];const l=await n._getAppCheckToken(),h=l?`#${Rk}=${encodeURIComponent(l)}`:"";return`${kk(n)}?${pi(c).slice(1)}${h}`}function kk({config:n}){return n.emulator?Zl(n,Ck):`https://${n.authDomain}/${Sk}`}const bc="webStorageSupport";class Pk{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=zg,this._completeRedirectFn=ek,this._overrideRedirectResult=JR}async _openPopup(e,t,r,s){Qt(this.eventManagers[e._key()]?.manager,"_initialize() not called before _openPopup()");const i=await af(e,t,r,Qc(),s);return Ak(e,i,iu())}async _openRedirect(e,t,r,s){await this._originValidation(e);const i=await af(e,t,r,Qc(),s);return OR(i),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:s,promise:i}=this.eventManagers[t];return s?Promise.resolve(s):(Qt(i,"If manager is not set, promise should be"),i)}const r=this.initAndGetManager(e);return this.eventManagers[t]={promise:r},r.catch(()=>{delete this.eventManagers[t]}),r}async initAndGetManager(e){const t=await yk(e),r=new nk(e);return t.register("authEvent",s=>(z(s?.authEvent,e,"invalid-auth-event"),{status:r.onEvent(s.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:r},this.iframes[e._key()]=t,r}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(bc,{type:bc},s=>{const i=s?.[0]?.[bc];i!==void 0&&t(!!i),Nt(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=ak(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return xg()||Ng()||nu()}}const Nk=Pk;var cf="@firebase/auth",lf="1.12.0";class Dk{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(r=>{e(r?.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(){z(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}function Ok(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 Vk(n){je(new Fe("auth",(e,{options:t})=>{const r=e.getProvider("app").getImmediate(),s=e.getProvider("heartbeat"),i=e.getProvider("app-check-internal"),{apiKey:o,authDomain:c}=r.options;z(o&&!o.includes(":"),"invalid-api-key",{appName:r.name});const l={apiKey:o,authDomain:c,clientPlatform:n,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:Fg(n)},h=new fR(r,s,i,l);return ER(h,t),h},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,r)=>{e.getProvider("auth-internal").initialize()})),je(new Fe("auth-internal",e=>{const t=da(e.getProvider("auth").getImmediate());return(r=>new Dk(r))(t)},"PRIVATE").setInstantiationMode("EXPLICIT")),Te(cf,lf,Ok(n)),Te(cf,lf,"esm2020")}const Lk=300,Mk=Km("authIdTokenMaxAge")||Lk;let uf=null;const xk=n=>async e=>{const t=e&&await e.getIdTokenResult(),r=t&&(new Date().getTime()-Date.parse(t.issuedAtTime))/1e3;if(r&&r>Mk)return;const s=t?.token;uf!==s&&(uf=s,await fetch(n,{method:s?"POST":"DELETE",headers:s?{Authorization:`Bearer ${s}`}:{}}))};function Fk(n=os()){const e=Vt(n,"auth");if(e.isInitialized())return e.getImmediate();const t=yR(n,{popupRedirectResolver:Nk,persistence:[qR,PR,zg]}),r=Km("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){const i=new URL(r,location.origin);if(location.origin===i.origin){const o=xk(i.toString());CR(t,o,()=>o(t.currentUser)),SR(t,c=>o(c))}}const s=Wm("auth");return s&&$g(t,`http://${s}`),t}function $k(){return document.getElementsByTagName("head")?.[0]??document}pR({loadJS(n){return new Promise((e,t)=>{const r=document.createElement("script");r.setAttribute("src",n),r.onload=e,r.onerror=s=>{const i=mt("internal-error");i.customData=s,t(i)},r.type="text/javascript",r.charset="UTF-8",$k().appendChild(r)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});Vk("Browser");var hf=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};var vn,e_;(function(){var n;function e(w,y){function v(){}v.prototype=y.prototype,w.F=y.prototype,w.prototype=new v,w.prototype.constructor=w,w.D=function(A,b,I){for(var E=Array(arguments.length-2),le=2;le<arguments.length;le++)E[le-2]=arguments[le];return y.prototype[b].apply(A,E)}}function t(){this.blockSize=-1}function r(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.C=Array(this.blockSize),this.o=this.h=0,this.u()}e(r,t),r.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function s(w,y,v){v||(v=0);const A=Array(16);if(typeof y=="string")for(var b=0;b<16;++b)A[b]=y.charCodeAt(v++)|y.charCodeAt(v++)<<8|y.charCodeAt(v++)<<16|y.charCodeAt(v++)<<24;else for(b=0;b<16;++b)A[b]=y[v++]|y[v++]<<8|y[v++]<<16|y[v++]<<24;y=w.g[0],v=w.g[1],b=w.g[2];let I=w.g[3],E;E=y+(I^v&(b^I))+A[0]+3614090360&4294967295,y=v+(E<<7&4294967295|E>>>25),E=I+(b^y&(v^b))+A[1]+3905402710&4294967295,I=y+(E<<12&4294967295|E>>>20),E=b+(v^I&(y^v))+A[2]+606105819&4294967295,b=I+(E<<17&4294967295|E>>>15),E=v+(y^b&(I^y))+A[3]+3250441966&4294967295,v=b+(E<<22&4294967295|E>>>10),E=y+(I^v&(b^I))+A[4]+4118548399&4294967295,y=v+(E<<7&4294967295|E>>>25),E=I+(b^y&(v^b))+A[5]+1200080426&4294967295,I=y+(E<<12&4294967295|E>>>20),E=b+(v^I&(y^v))+A[6]+2821735955&4294967295,b=I+(E<<17&4294967295|E>>>15),E=v+(y^b&(I^y))+A[7]+4249261313&4294967295,v=b+(E<<22&4294967295|E>>>10),E=y+(I^v&(b^I))+A[8]+1770035416&4294967295,y=v+(E<<7&4294967295|E>>>25),E=I+(b^y&(v^b))+A[9]+2336552879&4294967295,I=y+(E<<12&4294967295|E>>>20),E=b+(v^I&(y^v))+A[10]+4294925233&4294967295,b=I+(E<<17&4294967295|E>>>15),E=v+(y^b&(I^y))+A[11]+2304563134&4294967295,v=b+(E<<22&4294967295|E>>>10),E=y+(I^v&(b^I))+A[12]+1804603682&4294967295,y=v+(E<<7&4294967295|E>>>25),E=I+(b^y&(v^b))+A[13]+4254626195&4294967295,I=y+(E<<12&4294967295|E>>>20),E=b+(v^I&(y^v))+A[14]+2792965006&4294967295,b=I+(E<<17&4294967295|E>>>15),E=v+(y^b&(I^y))+A[15]+1236535329&4294967295,v=b+(E<<22&4294967295|E>>>10),E=y+(b^I&(v^b))+A[1]+4129170786&4294967295,y=v+(E<<5&4294967295|E>>>27),E=I+(v^b&(y^v))+A[6]+3225465664&4294967295,I=y+(E<<9&4294967295|E>>>23),E=b+(y^v&(I^y))+A[11]+643717713&4294967295,b=I+(E<<14&4294967295|E>>>18),E=v+(I^y&(b^I))+A[0]+3921069994&4294967295,v=b+(E<<20&4294967295|E>>>12),E=y+(b^I&(v^b))+A[5]+3593408605&4294967295,y=v+(E<<5&4294967295|E>>>27),E=I+(v^b&(y^v))+A[10]+38016083&4294967295,I=y+(E<<9&4294967295|E>>>23),E=b+(y^v&(I^y))+A[15]+3634488961&4294967295,b=I+(E<<14&4294967295|E>>>18),E=v+(I^y&(b^I))+A[4]+3889429448&4294967295,v=b+(E<<20&4294967295|E>>>12),E=y+(b^I&(v^b))+A[9]+568446438&4294967295,y=v+(E<<5&4294967295|E>>>27),E=I+(v^b&(y^v))+A[14]+3275163606&4294967295,I=y+(E<<9&4294967295|E>>>23),E=b+(y^v&(I^y))+A[3]+4107603335&4294967295,b=I+(E<<14&4294967295|E>>>18),E=v+(I^y&(b^I))+A[8]+1163531501&4294967295,v=b+(E<<20&4294967295|E>>>12),E=y+(b^I&(v^b))+A[13]+2850285829&4294967295,y=v+(E<<5&4294967295|E>>>27),E=I+(v^b&(y^v))+A[2]+4243563512&4294967295,I=y+(E<<9&4294967295|E>>>23),E=b+(y^v&(I^y))+A[7]+1735328473&4294967295,b=I+(E<<14&4294967295|E>>>18),E=v+(I^y&(b^I))+A[12]+2368359562&4294967295,v=b+(E<<20&4294967295|E>>>12),E=y+(v^b^I)+A[5]+4294588738&4294967295,y=v+(E<<4&4294967295|E>>>28),E=I+(y^v^b)+A[8]+2272392833&4294967295,I=y+(E<<11&4294967295|E>>>21),E=b+(I^y^v)+A[11]+1839030562&4294967295,b=I+(E<<16&4294967295|E>>>16),E=v+(b^I^y)+A[14]+4259657740&4294967295,v=b+(E<<23&4294967295|E>>>9),E=y+(v^b^I)+A[1]+2763975236&4294967295,y=v+(E<<4&4294967295|E>>>28),E=I+(y^v^b)+A[4]+1272893353&4294967295,I=y+(E<<11&4294967295|E>>>21),E=b+(I^y^v)+A[7]+4139469664&4294967295,b=I+(E<<16&4294967295|E>>>16),E=v+(b^I^y)+A[10]+3200236656&4294967295,v=b+(E<<23&4294967295|E>>>9),E=y+(v^b^I)+A[13]+681279174&4294967295,y=v+(E<<4&4294967295|E>>>28),E=I+(y^v^b)+A[0]+3936430074&4294967295,I=y+(E<<11&4294967295|E>>>21),E=b+(I^y^v)+A[3]+3572445317&4294967295,b=I+(E<<16&4294967295|E>>>16),E=v+(b^I^y)+A[6]+76029189&4294967295,v=b+(E<<23&4294967295|E>>>9),E=y+(v^b^I)+A[9]+3654602809&4294967295,y=v+(E<<4&4294967295|E>>>28),E=I+(y^v^b)+A[12]+3873151461&4294967295,I=y+(E<<11&4294967295|E>>>21),E=b+(I^y^v)+A[15]+530742520&4294967295,b=I+(E<<16&4294967295|E>>>16),E=v+(b^I^y)+A[2]+3299628645&4294967295,v=b+(E<<23&4294967295|E>>>9),E=y+(b^(v|~I))+A[0]+4096336452&4294967295,y=v+(E<<6&4294967295|E>>>26),E=I+(v^(y|~b))+A[7]+1126891415&4294967295,I=y+(E<<10&4294967295|E>>>22),E=b+(y^(I|~v))+A[14]+2878612391&4294967295,b=I+(E<<15&4294967295|E>>>17),E=v+(I^(b|~y))+A[5]+4237533241&4294967295,v=b+(E<<21&4294967295|E>>>11),E=y+(b^(v|~I))+A[12]+1700485571&4294967295,y=v+(E<<6&4294967295|E>>>26),E=I+(v^(y|~b))+A[3]+2399980690&4294967295,I=y+(E<<10&4294967295|E>>>22),E=b+(y^(I|~v))+A[10]+4293915773&4294967295,b=I+(E<<15&4294967295|E>>>17),E=v+(I^(b|~y))+A[1]+2240044497&4294967295,v=b+(E<<21&4294967295|E>>>11),E=y+(b^(v|~I))+A[8]+1873313359&4294967295,y=v+(E<<6&4294967295|E>>>26),E=I+(v^(y|~b))+A[15]+4264355552&4294967295,I=y+(E<<10&4294967295|E>>>22),E=b+(y^(I|~v))+A[6]+2734768916&4294967295,b=I+(E<<15&4294967295|E>>>17),E=v+(I^(b|~y))+A[13]+1309151649&4294967295,v=b+(E<<21&4294967295|E>>>11),E=y+(b^(v|~I))+A[4]+4149444226&4294967295,y=v+(E<<6&4294967295|E>>>26),E=I+(v^(y|~b))+A[11]+3174756917&4294967295,I=y+(E<<10&4294967295|E>>>22),E=b+(y^(I|~v))+A[2]+718787259&4294967295,b=I+(E<<15&4294967295|E>>>17),E=v+(I^(b|~y))+A[9]+3951481745&4294967295,w.g[0]=w.g[0]+y&4294967295,w.g[1]=w.g[1]+(b+(E<<21&4294967295|E>>>11))&4294967295,w.g[2]=w.g[2]+b&4294967295,w.g[3]=w.g[3]+I&4294967295}r.prototype.v=function(w,y){y===void 0&&(y=w.length);const v=y-this.blockSize,A=this.C;let b=this.h,I=0;for(;I<y;){if(b==0)for(;I<=v;)s(this,w,I),I+=this.blockSize;if(typeof w=="string"){for(;I<y;)if(A[b++]=w.charCodeAt(I++),b==this.blockSize){s(this,A),b=0;break}}else for(;I<y;)if(A[b++]=w[I++],b==this.blockSize){s(this,A),b=0;break}}this.h=b,this.o+=y},r.prototype.A=function(){var w=Array((this.h<56?this.blockSize:this.blockSize*2)-this.h);w[0]=128;for(var y=1;y<w.length-8;++y)w[y]=0;y=this.o*8;for(var v=w.length-8;v<w.length;++v)w[v]=y&255,y/=256;for(this.v(w),w=Array(16),y=0,v=0;v<4;++v)for(let A=0;A<32;A+=8)w[y++]=this.g[v]>>>A&255;return w};function i(w,y){var v=c;return Object.prototype.hasOwnProperty.call(v,w)?v[w]:v[w]=y(w)}function o(w,y){this.h=y;const v=[];let A=!0;for(let b=w.length-1;b>=0;b--){const I=w[b]|0;A&&I==y||(v[b]=I,A=!1)}this.g=v}var c={};function l(w){return-128<=w&&w<128?i(w,function(y){return new o([y|0],y<0?-1:0)}):new o([w|0],w<0?-1:0)}function h(w){if(isNaN(w)||!isFinite(w))return g;if(w<0)return k(h(-w));const y=[];let v=1;for(let A=0;w>=v;A++)y[A]=w/v|0,v*=4294967296;return new o(y,0)}function f(w,y){if(w.length==0)throw Error("number format error: empty string");if(y=y||10,y<2||36<y)throw Error("radix out of range: "+y);if(w.charAt(0)=="-")return k(f(w.substring(1),y));if(w.indexOf("-")>=0)throw Error('number format error: interior "-" character');const v=h(Math.pow(y,8));let A=g;for(let I=0;I<w.length;I+=8){var b=Math.min(8,w.length-I);const E=parseInt(w.substring(I,I+b),y);b<8?(b=h(Math.pow(y,b)),A=A.j(b).add(h(E))):(A=A.j(v),A=A.add(h(E)))}return A}var g=l(0),_=l(1),T=l(16777216);n=o.prototype,n.m=function(){if(P(this))return-k(this).m();let w=0,y=1;for(let v=0;v<this.g.length;v++){const A=this.i(v);w+=(A>=0?A:4294967296+A)*y,y*=4294967296}return w},n.toString=function(w){if(w=w||10,w<2||36<w)throw Error("radix out of range: "+w);if(C(this))return"0";if(P(this))return"-"+k(this).toString(w);const y=h(Math.pow(w,6));var v=this;let A="";for(;;){const b=F(v,y).g;v=L(v,b.j(y));let I=((v.g.length>0?v.g[0]:v.h)>>>0).toString(w);if(v=b,C(v))return I+A;for(;I.length<6;)I="0"+I;A=I+A}},n.i=function(w){return w<0?0:w<this.g.length?this.g[w]:this.h};function C(w){if(w.h!=0)return!1;for(let y=0;y<w.g.length;y++)if(w.g[y]!=0)return!1;return!0}function P(w){return w.h==-1}n.l=function(w){return w=L(this,w),P(w)?-1:C(w)?0:1};function k(w){const y=w.g.length,v=[];for(let A=0;A<y;A++)v[A]=~w.g[A];return new o(v,~w.h).add(_)}n.abs=function(){return P(this)?k(this):this},n.add=function(w){const y=Math.max(this.g.length,w.g.length),v=[];let A=0;for(let b=0;b<=y;b++){let I=A+(this.i(b)&65535)+(w.i(b)&65535),E=(I>>>16)+(this.i(b)>>>16)+(w.i(b)>>>16);A=E>>>16,I&=65535,E&=65535,v[b]=E<<16|I}return new o(v,v[v.length-1]&-2147483648?-1:0)};function L(w,y){return w.add(k(y))}n.j=function(w){if(C(this)||C(w))return g;if(P(this))return P(w)?k(this).j(k(w)):k(k(this).j(w));if(P(w))return k(this.j(k(w)));if(this.l(T)<0&&w.l(T)<0)return h(this.m()*w.m());const y=this.g.length+w.g.length,v=[];for(var A=0;A<2*y;A++)v[A]=0;for(A=0;A<this.g.length;A++)for(let b=0;b<w.g.length;b++){const I=this.i(A)>>>16,E=this.i(A)&65535,le=w.i(b)>>>16,Ne=w.i(b)&65535;v[2*A+2*b]+=E*Ne,$(v,2*A+2*b),v[2*A+2*b+1]+=I*Ne,$(v,2*A+2*b+1),v[2*A+2*b+1]+=E*le,$(v,2*A+2*b+1),v[2*A+2*b+2]+=I*le,$(v,2*A+2*b+2)}for(w=0;w<y;w++)v[w]=v[2*w+1]<<16|v[2*w];for(w=y;w<2*y;w++)v[w]=0;return new o(v,0)};function $(w,y){for(;(w[y]&65535)!=w[y];)w[y+1]+=w[y]>>>16,w[y]&=65535,y++}function U(w,y){this.g=w,this.h=y}function F(w,y){if(C(y))throw Error("division by zero");if(C(w))return new U(g,g);if(P(w))return y=F(k(w),y),new U(k(y.g),k(y.h));if(P(y))return y=F(w,k(y)),new U(k(y.g),y.h);if(w.g.length>30){if(P(w)||P(y))throw Error("slowDivide_ only works with positive integers.");for(var v=_,A=y;A.l(w)<=0;)v=j(v),A=j(A);var b=H(v,1),I=H(A,1);for(A=H(A,2),v=H(v,2);!C(A);){var E=I.add(A);E.l(w)<=0&&(b=b.add(v),I=E),A=H(A,1),v=H(v,1)}return y=L(w,b.j(y)),new U(b,y)}for(b=g;w.l(y)>=0;){for(v=Math.max(1,Math.floor(w.m()/y.m())),A=Math.ceil(Math.log(v)/Math.LN2),A=A<=48?1:Math.pow(2,A-48),I=h(v),E=I.j(y);P(E)||E.l(w)>0;)v-=A,I=h(v),E=I.j(y);C(I)&&(I=_),b=b.add(I),w=L(w,E)}return new U(b,w)}n.B=function(w){return F(this,w).h},n.and=function(w){const y=Math.max(this.g.length,w.g.length),v=[];for(let A=0;A<y;A++)v[A]=this.i(A)&w.i(A);return new o(v,this.h&w.h)},n.or=function(w){const y=Math.max(this.g.length,w.g.length),v=[];for(let A=0;A<y;A++)v[A]=this.i(A)|w.i(A);return new o(v,this.h|w.h)},n.xor=function(w){const y=Math.max(this.g.length,w.g.length),v=[];for(let A=0;A<y;A++)v[A]=this.i(A)^w.i(A);return new o(v,this.h^w.h)};function j(w){const y=w.g.length+1,v=[];for(let A=0;A<y;A++)v[A]=w.i(A)<<1|w.i(A-1)>>>31;return new o(v,w.h)}function H(w,y){const v=y>>5;y%=32;const A=w.g.length-v,b=[];for(let I=0;I<A;I++)b[I]=y>0?w.i(I+v)>>>y|w.i(I+v+1)<<32-y:w.i(I+v);return new o(b,w.h)}r.prototype.digest=r.prototype.A,r.prototype.reset=r.prototype.u,r.prototype.update=r.prototype.v,e_=r,o.prototype.add=o.prototype.add,o.prototype.multiply=o.prototype.j,o.prototype.modulo=o.prototype.B,o.prototype.compare=o.prototype.l,o.prototype.toNumber=o.prototype.m,o.prototype.toString=o.prototype.toString,o.prototype.getBits=o.prototype.i,o.fromNumber=h,o.fromString=f,vn=o}).apply(typeof hf<"u"?hf:typeof self<"u"?self:typeof window<"u"?window:{});var Gi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};var t_,Ms,n_,ao,Zc,r_,s_,i_;(function(){var n,e=Object.defineProperty;function t(a){a=[typeof globalThis=="object"&&globalThis,a,typeof window=="object"&&window,typeof self=="object"&&self,typeof Gi=="object"&&Gi];for(var u=0;u<a.length;++u){var d=a[u];if(d&&d.Math==Math)return d}throw Error("Cannot find global object")}var r=t(this);function s(a,u){if(u)e:{var d=r;a=a.split(".");for(var m=0;m<a.length-1;m++){var S=a[m];if(!(S in d))break e;d=d[S]}a=a[a.length-1],m=d[a],u=u(m),u!=m&&u!=null&&e(d,a,{configurable:!0,writable:!0,value:u})}}s("Symbol.dispose",function(a){return a||Symbol("Symbol.dispose")}),s("Array.prototype.values",function(a){return a||function(){return this[Symbol.iterator]()}}),s("Object.entries",function(a){return a||function(u){var d=[],m;for(m in u)Object.prototype.hasOwnProperty.call(u,m)&&d.push([m,u[m]]);return d}});var i=i||{},o=this||self;function c(a){var u=typeof a;return u=="object"&&a!=null||u=="function"}function l(a,u,d){return a.call.apply(a.bind,arguments)}function h(a,u,d){return h=l,h.apply(null,arguments)}function f(a,u){var d=Array.prototype.slice.call(arguments,1);return function(){var m=d.slice();return m.push.apply(m,arguments),a.apply(this,m)}}function g(a,u){function d(){}d.prototype=u.prototype,a.Z=u.prototype,a.prototype=new d,a.prototype.constructor=a,a.Ob=function(m,S,R){for(var V=Array(arguments.length-2),Q=2;Q<arguments.length;Q++)V[Q-2]=arguments[Q];return u.prototype[S].apply(m,V)}}var _=typeof AsyncContext<"u"&&typeof AsyncContext.Snapshot=="function"?a=>a&&AsyncContext.Snapshot.wrap(a):a=>a;function T(a){const u=a.length;if(u>0){const d=Array(u);for(let m=0;m<u;m++)d[m]=a[m];return d}return[]}function C(a,u){for(let m=1;m<arguments.length;m++){const S=arguments[m];var d=typeof S;if(d=d!="object"?d:S?Array.isArray(S)?"array":d:"null",d=="array"||d=="object"&&typeof S.length=="number"){d=a.length||0;const R=S.length||0;a.length=d+R;for(let V=0;V<R;V++)a[d+V]=S[V]}else a.push(S)}}class P{constructor(u,d){this.i=u,this.j=d,this.h=0,this.g=null}get(){let u;return this.h>0?(this.h--,u=this.g,this.g=u.next,u.next=null):u=this.i(),u}}function k(a){o.setTimeout(()=>{throw a},0)}function L(){var a=w;let u=null;return a.g&&(u=a.g,a.g=a.g.next,a.g||(a.h=null),u.next=null),u}class ${constructor(){this.h=this.g=null}add(u,d){const m=U.get();m.set(u,d),this.h?this.h.next=m:this.g=m,this.h=m}}var U=new P(()=>new F,a=>a.reset());class F{constructor(){this.next=this.g=this.h=null}set(u,d){this.h=u,this.g=d,this.next=null}reset(){this.next=this.g=this.h=null}}let j,H=!1,w=new $,y=()=>{const a=Promise.resolve(void 0);j=()=>{a.then(v)}};function v(){for(var a;a=L();){try{a.h.call(a.g)}catch(d){k(d)}var u=U;u.j(a),u.h<100&&(u.h++,a.next=u.g,u.g=a)}H=!1}function A(){this.u=this.u,this.C=this.C}A.prototype.u=!1,A.prototype.dispose=function(){this.u||(this.u=!0,this.N())},A.prototype[Symbol.dispose]=function(){this.dispose()},A.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function b(a,u){this.type=a,this.g=this.target=u,this.defaultPrevented=!1}b.prototype.h=function(){this.defaultPrevented=!0};var I=(function(){if(!o.addEventListener||!Object.defineProperty)return!1;var a=!1,u=Object.defineProperty({},"passive",{get:function(){a=!0}});try{const d=()=>{};o.addEventListener("test",d,u),o.removeEventListener("test",d,u)}catch{}return a})();function E(a){return/^[\s\xa0]*$/.test(a)}function le(a,u){b.call(this,a?a.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,a&&this.init(a,u)}g(le,b),le.prototype.init=function(a,u){const d=this.type=a.type,m=a.changedTouches&&a.changedTouches.length?a.changedTouches[0]:null;this.target=a.target||a.srcElement,this.g=u,u=a.relatedTarget,u||(d=="mouseover"?u=a.fromElement:d=="mouseout"&&(u=a.toElement)),this.relatedTarget=u,m?(this.clientX=m.clientX!==void 0?m.clientX:m.pageX,this.clientY=m.clientY!==void 0?m.clientY:m.pageY,this.screenX=m.screenX||0,this.screenY=m.screenY||0):(this.clientX=a.clientX!==void 0?a.clientX:a.pageX,this.clientY=a.clientY!==void 0?a.clientY:a.pageY,this.screenX=a.screenX||0,this.screenY=a.screenY||0),this.button=a.button,this.key=a.key||"",this.ctrlKey=a.ctrlKey,this.altKey=a.altKey,this.shiftKey=a.shiftKey,this.metaKey=a.metaKey,this.pointerId=a.pointerId||0,this.pointerType=a.pointerType,this.state=a.state,this.i=a,a.defaultPrevented&&le.Z.h.call(this)},le.prototype.h=function(){le.Z.h.call(this);const a=this.i;a.preventDefault?a.preventDefault():a.returnValue=!1};var Ne="closure_listenable_"+(Math.random()*1e6|0),De=0;function He(a,u,d,m,S){this.listener=a,this.proxy=null,this.src=u,this.type=d,this.capture=!!m,this.ha=S,this.key=++De,this.da=this.fa=!1}function Mt(a){a.da=!0,a.listener=null,a.proxy=null,a.src=null,a.ha=null}function tt(a,u,d){for(const m in a)u.call(d,a[m],m,a)}function mr(a,u){for(const d in a)u.call(void 0,a[d],d,a)}function gr(a){const u={};for(const d in a)u[d]=a[d];return u}const nn="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function Fn(a,u){let d,m;for(let S=1;S<arguments.length;S++){m=arguments[S];for(d in m)a[d]=m[d];for(let R=0;R<nn.length;R++)d=nn[R],Object.prototype.hasOwnProperty.call(m,d)&&(a[d]=m[d])}}function lt(a){this.src=a,this.g={},this.h=0}lt.prototype.add=function(a,u,d,m,S){const R=a.toString();a=this.g[R],a||(a=this.g[R]=[],this.h++);const V=xt(a,u,m,S);return V>-1?(u=a[V],d||(u.fa=!1)):(u=new He(u,this.src,R,!!m,S),u.fa=d,a.push(u)),u};function nt(a,u){const d=u.type;if(d in a.g){var m=a.g[d],S=Array.prototype.indexOf.call(m,u,void 0),R;(R=S>=0)&&Array.prototype.splice.call(m,S,1),R&&(Mt(u),a.g[d].length==0&&(delete a.g[d],a.h--))}}function xt(a,u,d,m){for(let S=0;S<a.length;++S){const R=a[S];if(!R.da&&R.listener==u&&R.capture==!!d&&R.ha==m)return S}return-1}var rn="closure_lm_"+(Math.random()*1e6|0),ut={};function _r(a,u,d,m,S){if(Array.isArray(u)){for(let R=0;R<u.length;R++)_r(a,u[R],d,m,S);return null}return d=Ci(d),a&&a[Ne]?a.J(u,d,c(m)?!!m.capture:!1,S):Oa(a,u,d,!1,m,S)}function Oa(a,u,d,m,S,R){if(!u)throw Error("Invalid event type");const V=c(S)?!!S.capture:!!S;let Q=Er(a);if(Q||(a[rn]=Q=new lt(a)),d=Q.add(u,d,m,V,R),d.proxy)return d;if(m=fs(),d.proxy=m,m.src=a,m.listener=d,a.addEventListener)I||(S=V),S===void 0&&(S=!1),a.addEventListener(u.toString(),m,S);else if(a.attachEvent)a.attachEvent(Si(u.toString()),m);else if(a.addListener&&a.removeListener)a.addListener(m);else throw Error("addEventListener and attachEvent are unavailable.");return d}function fs(){function a(d){return u.call(a.src,a.listener,d)}const u=Va;return a}function Ii(a,u,d,m,S){if(Array.isArray(u))for(var R=0;R<u.length;R++)Ii(a,u[R],d,m,S);else m=c(m)?!!m.capture:!!m,d=Ci(d),a&&a[Ne]?(a=a.i,R=String(u).toString(),R in a.g&&(u=a.g[R],d=xt(u,d,m,S),d>-1&&(Mt(u[d]),Array.prototype.splice.call(u,d,1),u.length==0&&(delete a.g[R],a.h--)))):a&&(a=Er(a))&&(u=a.g[u.toString()],a=-1,u&&(a=xt(u,d,m,S)),(d=a>-1?u[a]:null)&&yr(d))}function yr(a){if(typeof a!="number"&&a&&!a.da){var u=a.src;if(u&&u[Ne])nt(u.i,a);else{var d=a.type,m=a.proxy;u.removeEventListener?u.removeEventListener(d,m,a.capture):u.detachEvent?u.detachEvent(Si(d),m):u.addListener&&u.removeListener&&u.removeListener(m),(d=Er(u))?(nt(d,a),d.h==0&&(d.src=null,u[rn]=null)):Mt(a)}}}function Si(a){return a in ut?ut[a]:ut[a]="on"+a}function Va(a,u){if(a.da)a=!0;else{u=new le(u,this);const d=a.listener,m=a.ha||a.src;a.fa&&yr(a),a=d.call(m,u)}return a}function Er(a){return a=a[rn],a instanceof lt?a:null}var vr="__closure_events_fn_"+(Math.random()*1e9>>>0);function Ci(a){return typeof a=="function"?a:(a[vr]||(a[vr]=function(u){return a.handleEvent(u)}),a[vr])}function ye(){A.call(this),this.i=new lt(this),this.M=this,this.G=null}g(ye,A),ye.prototype[Ne]=!0,ye.prototype.removeEventListener=function(a,u,d,m){Ii(this,a,u,d,m)};function ae(a,u){var d,m=a.G;if(m)for(d=[];m;m=m.G)d.push(m);if(a=a.M,m=u.type||u,typeof u=="string")u=new b(u,a);else if(u instanceof b)u.target=u.target||a;else{var S=u;u=new b(m,a),Fn(u,S)}S=!0;let R,V;if(d)for(V=d.length-1;V>=0;V--)R=u.g=d[V],S=Ft(R,m,!0,u)&&S;if(R=u.g=a,S=Ft(R,m,!0,u)&&S,S=Ft(R,m,!1,u)&&S,d)for(V=0;V<d.length;V++)R=u.g=d[V],S=Ft(R,m,!1,u)&&S}ye.prototype.N=function(){if(ye.Z.N.call(this),this.i){var a=this.i;for(const u in a.g){const d=a.g[u];for(let m=0;m<d.length;m++)Mt(d[m]);delete a.g[u],a.h--}}this.G=null},ye.prototype.J=function(a,u,d,m){return this.i.add(String(a),u,!1,d,m)},ye.prototype.K=function(a,u,d,m){return this.i.add(String(a),u,!0,d,m)};function Ft(a,u,d,m){if(u=a.i.g[String(u)],!u)return!0;u=u.concat();let S=!0;for(let R=0;R<u.length;++R){const V=u[R];if(V&&!V.da&&V.capture==d){const Q=V.listener,ge=V.ha||V.src;V.fa&&nt(a.i,V),S=Q.call(ge,m)!==!1&&S}}return S&&!m.defaultPrevented}function Ri(a,u){if(typeof a!="function")if(a&&typeof a.handleEvent=="function")a=h(a.handleEvent,a);else throw Error("Invalid listener argument");return Number(u)>2147483647?-1:o.setTimeout(a,u||0)}function ps(a){a.g=Ri(()=>{a.g=null,a.i&&(a.i=!1,ps(a))},a.l);const u=a.h;a.h=null,a.m.apply(null,u)}class ms extends A{constructor(u,d){super(),this.m=u,this.l=d,this.h=null,this.i=!1,this.g=null}j(u){this.h=arguments,this.g?this.i=!0:ps(this)}N(){super.N(),this.g&&(o.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function sn(a){A.call(this),this.h=a,this.g={}}g(sn,A);var gs=[];function _s(a){tt(a.g,function(u,d){this.g.hasOwnProperty(d)&&yr(u)},a),a.g={}}sn.prototype.N=function(){sn.Z.N.call(this),_s(this)},sn.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var Tr=o.JSON.stringify,Jy=o.JSON.parse,Xy=class{stringify(a){return o.JSON.stringify(a,void 0)}parse(a){return o.JSON.parse(a,void 0)}};function eh(){}function th(){}var ys={OPEN:"a",hb:"b",ERROR:"c",tb:"d"};function La(){b.call(this,"d")}g(La,b);function Ma(){b.call(this,"c")}g(Ma,b);var $n={},nh=null;function ki(){return nh=nh||new ye}$n.Ia="serverreachability";function rh(a){b.call(this,$n.Ia,a)}g(rh,b);function Es(a){const u=ki();ae(u,new rh(u))}$n.STAT_EVENT="statevent";function sh(a,u){b.call(this,$n.STAT_EVENT,a),this.stat=u}g(sh,b);function Oe(a){const u=ki();ae(u,new sh(u,a))}$n.Ja="timingevent";function ih(a,u){b.call(this,$n.Ja,a),this.size=u}g(ih,b);function vs(a,u){if(typeof a!="function")throw Error("Fn must not be null and must be a function");return o.setTimeout(function(){a()},u)}function Ts(){this.g=!0}Ts.prototype.ua=function(){this.g=!1};function Zy(a,u,d,m,S,R){a.info(function(){if(a.g)if(R){var V="",Q=R.split("&");for(let re=0;re<Q.length;re++){var ge=Q[re].split("=");if(ge.length>1){const Ee=ge[0];ge=ge[1];const Tt=Ee.split("_");V=Tt.length>=2&&Tt[1]=="type"?V+(Ee+"="+ge+"&"):V+(Ee+"=redacted&")}}}else V=null;else V=R;return"XMLHTTP REQ ("+m+") [attempt "+S+"]: "+u+`
|
|
16
16
|
`+d+`
|
|
17
|
-
`+
|
|
17
|
+
`+V})}function eE(a,u,d,m,S,R,V){a.info(function(){return"XMLHTTP RESP ("+m+") [ attempt "+S+"]: "+u+`
|
|
18
18
|
`+d+`
|
|
19
|
-
`+R+" "+
|
|
20
|
-
`,d);return p==-1?ji:(d=Number(l.substring(d,p)),isNaN(d)?qc:(p+=1,p+d>l.length?ji:(l=l.slice(p,p+d),o.C=p+d,l)))}At.prototype.cancel=function(){this.K=!0,Xt(this)};function Zr(o){o.T=Date.now()+o.H,zc(o,o.H)}function zc(o,l){if(o.D!=null)throw Error("WatchDog timer not null");o.D=Xn(h(o.aa,o),l)}function Hi(o){o.D&&(a.clearTimeout(o.D),o.D=null)}At.prototype.aa=function(){this.D=null;const o=Date.now();o-this.T>=0?(Jp(this.i,this.B),this.M!=2&&(Yn(),Pe(17)),Xt(this),this.m=2,tr(this)):zc(this,this.T-o)};function tr(o){o.j.I==0||o.K||ml(o.j,o)}function Xt(o){Hi(o);var l=o.O;l&&typeof l.dispose=="function"&&l.dispose(),o.O=null,Nc(o.V),o.g&&(l=o.g,o.g=null,l.abort(),l.dispose())}function Gi(o,l){try{var d=o.j;if(d.I!=0&&(d.g==o||Ki(d.h,o))){if(!o.L&&Ki(d.h,o)&&d.I==3){try{var p=d.Ba.g.parse(l)}catch{p=null}if(Array.isArray(p)&&p.length==3){var A=p;if(A[0]==0){e:if(!d.v){if(d.g)if(d.g.F+3e3<o.F)is(d),rs(d);else break e;Zi(d),Pe(18)}}else d.xa=A[1],0<d.xa-d.K&&A[2]<37500&&d.F&&d.A==0&&!d.C&&(d.C=Xn(h(d.Va,d),6e3));Kc(d.h)<=1&&d.ta&&(d.ta=void 0)}else en(d,11)}else if((o.L||d.g==o)&&is(d),!T(l))for(A=d.Ba.g.parse(l),l=0;l<A.length;l++){let X=A[l];const fe=X[0];if(!(fe<=d.K))if(d.K=fe,X=X[1],d.I==2)if(X[0]=="c"){d.M=X[1],d.ba=X[2];const et=X[3];et!=null&&(d.ka=et,d.j.info("VER="+d.ka));const tn=X[4];tn!=null&&(d.za=tn,d.j.info("SVER="+d.za));const Pt=X[5];Pt!=null&&typeof Pt=="number"&&Pt>0&&(p=1.5*Pt,d.O=p,d.j.info("backChannelRequestTimeoutMs_="+p)),p=d;const Ct=o.g;if(Ct){const as=Ct.g?Ct.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(as){var R=p.h;R.g||as.indexOf("spdy")==-1&&as.indexOf("quic")==-1&&as.indexOf("h2")==-1||(R.j=R.l,R.g=new Set,R.h&&(Wi(R,R.h),R.h=null))}if(p.G){const to=Ct.g?Ct.g.getResponseHeader("X-HTTP-Session-Id"):null;to&&(p.wa=to,ne(p.J,p.G,to))}}d.I=3,d.l&&d.l.ra(),d.aa&&(d.T=Date.now()-o.F,d.j.info("Handshake RTT: "+d.T+"ms")),p=d;var D=o;if(p.na=yl(p,p.L?p.ba:null,p.W),D.L){Wc(p.h,D);var j=D,he=p.O;he&&(j.H=he),j.D&&(Hi(j),Zr(j)),p.g=D}else fl(p);d.i.length>0&&ss(d)}else X[0]!="stop"&&X[0]!="close"||en(d,7);else d.I==3&&(X[0]=="stop"||X[0]=="close"?X[0]=="stop"?en(d,7):Xi(d):X[0]!="noop"&&d.l&&d.l.qa(X),d.A=0)}}Yn(4)}catch{}}var tm=class{constructor(o,l){this.g=o,this.map=l}};function Hc(o){this.l=o||10,a.PerformanceNavigationTiming?(o=a.performance.getEntriesByType("navigation"),o=o.length>0&&(o[0].nextHopProtocol=="hq"||o[0].nextHopProtocol=="h2")):o=!!(a.chrome&&a.chrome.loadTimes&&a.chrome.loadTimes()&&a.chrome.loadTimes().wasFetchedViaSpdy),this.j=o?this.l:1,this.g=null,this.j>1&&(this.g=new Set),this.h=null,this.i=[]}function Gc(o){return o.h?!0:o.g?o.g.size>=o.j:!1}function Kc(o){return o.h?1:o.g?o.g.size:0}function Ki(o,l){return o.h?o.h==l:o.g?o.g.has(l):!1}function Wi(o,l){o.g?o.g.add(l):o.h=l}function Wc(o,l){o.h&&o.h==l?o.h=null:o.g&&o.g.has(l)&&o.g.delete(l)}Hc.prototype.cancel=function(){if(this.i=Qc(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const o of this.g.values())o.cancel();this.g.clear()}};function Qc(o){if(o.h!=null)return o.i.concat(o.h.G);if(o.g!=null&&o.g.size!==0){let l=o.i;for(const d of o.g.values())l=l.concat(d.G);return l}return S(o.i)}var Jc=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function nm(o,l){if(o){o=o.split("&");for(let d=0;d<o.length;d++){const p=o[d].indexOf("=");let A,R=null;p>=0?(A=o[d].substring(0,p),R=o[d].substring(p+1)):A=o[d],l(A,R?decodeURIComponent(R.replace(/\+/g," ")):"")}}}function bt(o){this.g=this.o=this.j="",this.u=null,this.m=this.h="",this.l=!1;let l;o instanceof bt?(this.l=o.l,nr(this,o.j),this.o=o.o,this.g=o.g,rr(this,o.u),this.h=o.h,Qi(this,nl(o.i)),this.m=o.m):o&&(l=String(o).match(Jc))?(this.l=!1,nr(this,l[1]||"",!0),this.o=sr(l[2]||""),this.g=sr(l[3]||"",!0),rr(this,l[4]),this.h=sr(l[5]||"",!0),Qi(this,l[6]||"",!0),this.m=sr(l[7]||"")):(this.l=!1,this.i=new or(null,this.l))}bt.prototype.toString=function(){const o=[];var l=this.j;l&&o.push(ir(l,Yc,!0),":");var d=this.g;return(d||l=="file")&&(o.push("//"),(l=this.o)&&o.push(ir(l,Yc,!0),"@"),o.push(er(d).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),d=this.u,d!=null&&o.push(":",String(d))),(d=this.h)&&(this.g&&d.charAt(0)!="/"&&o.push("/"),o.push(ir(d,d.charAt(0)=="/"?im:sm,!0))),(d=this.i.toString())&&o.push("?",d),(d=this.m)&&o.push("#",ir(d,am)),o.join("")},bt.prototype.resolve=function(o){const l=Ze(this);let d=!!o.j;d?nr(l,o.j):d=!!o.o,d?l.o=o.o:d=!!o.g,d?l.g=o.g:d=o.u!=null;var p=o.h;if(d)rr(l,o.u);else if(d=!!o.h){if(p.charAt(0)!="/")if(this.g&&!this.h)p="/"+p;else{var A=l.h.lastIndexOf("/");A!=-1&&(p=l.h.slice(0,A+1)+p)}if(A=p,A==".."||A==".")p="";else if(A.indexOf("./")!=-1||A.indexOf("/.")!=-1){p=A.lastIndexOf("/",0)==0,A=A.split("/");const R=[];for(let D=0;D<A.length;){const j=A[D++];j=="."?p&&D==A.length&&R.push(""):j==".."?((R.length>1||R.length==1&&R[0]!="")&&R.pop(),p&&D==A.length&&R.push("")):(R.push(j),p=!0)}p=R.join("/")}else p=A}return d?l.h=p:d=o.i.toString()!=="",d?Qi(l,nl(o.i)):d=!!o.m,d&&(l.m=o.m),l};function Ze(o){return new bt(o)}function nr(o,l,d){o.j=d?sr(l,!0):l,o.j&&(o.j=o.j.replace(/:$/,""))}function rr(o,l){if(l){if(l=Number(l),isNaN(l)||l<0)throw Error("Bad port number "+l);o.u=l}else o.u=null}function Qi(o,l,d){l instanceof or?(o.i=l,cm(o.i,o.l)):(d||(l=ir(l,om)),o.i=new or(l,o.l))}function ne(o,l,d){o.i.set(l,d)}function es(o){return ne(o,"zx",Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^Date.now()).toString(36)),o}function sr(o,l){return o?l?decodeURI(o.replace(/%25/g,"%2525")):decodeURIComponent(o):""}function ir(o,l,d){return typeof o=="string"?(o=encodeURI(o).replace(l,rm),d&&(o=o.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),o):null}function rm(o){return o=o.charCodeAt(0),"%"+(o>>4&15).toString(16)+(o&15).toString(16)}var Yc=/[#\/\?@]/g,sm=/[#\?:]/g,im=/[#\?]/g,om=/[#\?@]/g,am=/#/g;function or(o,l){this.h=this.g=null,this.i=o||null,this.j=!!l}function Zt(o){o.g||(o.g=new Map,o.h=0,o.i&&nm(o.i,function(l,d){o.add(decodeURIComponent(l.replace(/\+/g," ")),d)}))}n=or.prototype,n.add=function(o,l){Zt(this),this.i=null,o=vn(this,o);let d=this.g.get(o);return d||this.g.set(o,d=[]),d.push(l),this.h+=1,this};function Xc(o,l){Zt(o),l=vn(o,l),o.g.has(l)&&(o.i=null,o.h-=o.g.get(l).length,o.g.delete(l))}function Zc(o,l){return Zt(o),l=vn(o,l),o.g.has(l)}n.forEach=function(o,l){Zt(this),this.g.forEach(function(d,p){d.forEach(function(A){o.call(l,A,p,this)},this)},this)};function el(o,l){Zt(o);let d=[];if(typeof l=="string")Zc(o,l)&&(d=d.concat(o.g.get(vn(o,l))));else for(o=Array.from(o.g.values()),l=0;l<o.length;l++)d=d.concat(o[l]);return d}n.set=function(o,l){return Zt(this),this.i=null,o=vn(this,o),Zc(this,o)&&(this.h-=this.g.get(o).length),this.g.set(o,[l]),this.h+=1,this},n.get=function(o,l){return o?(o=el(this,o),o.length>0?String(o[0]):l):l};function tl(o,l,d){Xc(o,l),d.length>0&&(o.i=null,o.g.set(vn(o,l),S(d)),o.h+=d.length)}n.toString=function(){if(this.i)return this.i;if(!this.g)return"";const o=[],l=Array.from(this.g.keys());for(let p=0;p<l.length;p++){var d=l[p];const A=er(d);d=el(this,d);for(let R=0;R<d.length;R++){let D=A;d[R]!==""&&(D+="="+er(d[R])),o.push(D)}}return this.i=o.join("&")};function nl(o){const l=new or;return l.i=o.i,o.g&&(l.g=new Map(o.g),l.h=o.h),l}function vn(o,l){return l=String(l),o.j&&(l=l.toLowerCase()),l}function cm(o,l){l&&!o.j&&(Zt(o),o.i=null,o.g.forEach(function(d,p){const A=p.toLowerCase();p!=A&&(Xc(this,p),tl(this,A,d))},o)),o.j=l}function lm(o,l){const d=new Zn;if(a.Image){const p=new Image;p.onload=f(St,d,"TestLoadImage: loaded",!0,l,p),p.onerror=f(St,d,"TestLoadImage: error",!1,l,p),p.onabort=f(St,d,"TestLoadImage: abort",!1,l,p),p.ontimeout=f(St,d,"TestLoadImage: timeout",!1,l,p),a.setTimeout(function(){p.ontimeout&&p.ontimeout()},1e4),p.src=o}else l(!1)}function um(o,l){const d=new Zn,p=new AbortController,A=setTimeout(()=>{p.abort(),St(d,"TestPingServer: timeout",!1,l)},1e4);fetch(o,{signal:p.signal}).then(R=>{clearTimeout(A),R.ok?St(d,"TestPingServer: ok",!0,l):St(d,"TestPingServer: server error",!1,l)}).catch(()=>{clearTimeout(A),St(d,"TestPingServer: error",!1,l)})}function St(o,l,d,p,A){try{A&&(A.onload=null,A.onerror=null,A.onabort=null,A.ontimeout=null),p(d)}catch{}}function hm(){this.g=new Kp}function Ji(o){this.i=o.Sb||null,this.h=o.ab||!1}m(Ji,Dc),Ji.prototype.g=function(){return new ts(this.i,this.h)};function ts(o,l){Ee.call(this),this.H=o,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}m(ts,Ee),n=ts.prototype,n.open=function(o,l){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.F=o,this.D=l,this.readyState=1,cr(this)},n.send=function(o){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};o&&(l.body=o),(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,ar(this)),this.readyState=0},n.Pa=function(o){if(this.g&&(this.l=o,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=o.headers,this.readyState=2,cr(this)),this.g&&(this.readyState=3,cr(this),this.g)))if(this.responseType==="arraybuffer")o.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(typeof a.ReadableStream<"u"&&"body"in o){if(this.j=o.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;rl(this)}else o.text().then(this.Oa.bind(this),this.ga.bind(this))};function rl(o){o.j.read().then(o.Ma.bind(o)).catch(o.ga.bind(o))}n.Ma=function(o){if(this.g){if(this.o&&o.value)this.response.push(o.value);else if(!this.o){var l=o.value?o.value:new Uint8Array(0);(l=this.B.decode(l,{stream:!o.done}))&&(this.response=this.responseText+=l)}o.done?ar(this):cr(this),this.readyState==3&&rl(this)}},n.Oa=function(o){this.g&&(this.response=this.responseText=o,ar(this))},n.Na=function(o){this.g&&(this.response=o,ar(this))},n.ga=function(){this.g&&ar(this)};function ar(o){o.readyState=4,o.l=null,o.j=null,o.B=null,cr(o)}n.setRequestHeader=function(o,l){this.A.append(o,l)},n.getResponseHeader=function(o){return this.h&&this.h.get(o.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";const o=[],l=this.h.entries();for(var d=l.next();!d.done;)d=d.value,o.push(d[0]+": "+d[1]),d=l.next();return o.join(`\r
|
|
21
|
-
`)};function
|
|
22
|
-
`}),
|
|
23
|
-
`);for(let p=0;p<o.length;p++){if(T(o[p]))continue;var d=Xp(o[p]);const A=d[0];if(d=d[1],typeof d!="string")continue;d=d.trim();const R=l[A]||[];l[A]=R,R.push(d)}Bp(l,function(p){return p.join(", ")})}n.ya=function(){return this.o},n.Ha=function(){return typeof this.l=="string"?this.l:String(this.l)};function lr(o,l,d){return d&&d.internalChannelParams&&d.internalChannelParams[o]||l}function ll(o){this.za=0,this.i=[],this.j=new Zn,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=lr("failFast",!1,o),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=lr("baseRetryDelayMs",5e3,o),this.Za=lr("retryDelaySeedMs",1e4,o),this.Ta=lr("forwardChannelMaxRetries",2,o),this.va=lr("forwardChannelRequestTimeoutMs",2e4,o),this.ma=o&&o.xmlHttpFactory||void 0,this.Ua=o&&o.Rb||void 0,this.Aa=o&&o.useFetchStreams||!1,this.O=void 0,this.L=o&&o.supportsCrossDomainXhr||!1,this.M="",this.h=new Hc(o&&o.concurrentRequestLimit),this.Ba=new hm,this.S=o&&o.fastHandshake||!1,this.R=o&&o.encodeInitMessageHeaders||!1,this.S&&this.R&&(this.R=!1),this.Ra=o&&o.Pb||!1,o&&o.ua&&this.j.ua(),o&&o.forceLongPolling&&(this.X=!1),this.aa=!this.S&&this.X&&o&&o.detectBufferingProxy||!1,this.ia=void 0,o&&o.longPollingTimeout&&o.longPollingTimeout>0&&(this.ia=o.longPollingTimeout),this.ta=void 0,this.T=0,this.P=!1,this.ja=this.B=null}n=ll.prototype,n.ka=8,n.I=1,n.connect=function(o,l,d,p){Pe(0),this.W=o,this.H=l||{},d&&p!==void 0&&(this.H.OSID=d,this.H.OAID=p),this.F=this.X,this.J=yl(this,null,this.W),ss(this)};function Xi(o){if(ul(o),o.I==3){var l=o.V++,d=Ze(o.J);if(ne(d,"SID",o.M),ne(d,"RID",l),ne(d,"TYPE","terminate"),ur(o,d),l=new At(o,o.j,l),l.M=2,l.A=es(Ze(d)),d=!1,a.navigator&&a.navigator.sendBeacon)try{d=a.navigator.sendBeacon(l.A.toString(),"")}catch{}!d&&a.Image&&(new Image().src=l.A,d=!0),d||(l.g=Tl(l.j,null),l.g.ea(l.A)),l.F=Date.now(),Zr(l)}_l(o)}function rs(o){o.g&&(eo(o),o.g.cancel(),o.g=null)}function ul(o){rs(o),o.v&&(a.clearTimeout(o.v),o.v=null),is(o),o.h.cancel(),o.m&&(typeof o.m=="number"&&a.clearTimeout(o.m),o.m=null)}function ss(o){if(!Gc(o.h)&&!o.m){o.m=!0;var l=o.Ea;we||g(),oe||(we(),oe=!0),v.add(l,o),o.D=0}}function mm(o,l){return Kc(o.h)>=o.h.j-(o.m?1:0)?!1:o.m?(o.i=l.G.concat(o.i),!0):o.I==1||o.I==2||o.D>=(o.Sa?0:o.Ta)?!1:(o.m=Xn(h(o.Ea,o,l),gl(o,o.D)),o.D++,!0)}n.Ea=function(o){if(this.m)if(this.m=null,this.I==1){if(!o){this.V=Math.floor(Math.random()*1e5),o=this.V++;const A=new At(this,this.j,o);let R=this.o;if(this.U&&(R?(R=vc(R),Ac(R,this.U)):R=this.U),this.u!==null||this.R||(A.J=R,R=null),this.S)e:{for(var l=0,d=0;d<this.i.length;d++){t:{var p=this.i[d];if("__data__"in p.map&&(p=p.map.__data__,typeof p=="string")){p=p.length;break t}p=void 0}if(p===void 0)break;if(l+=p,l>4096){l=d;break e}if(l===4096||d===this.i.length-1){l=d+1;break e}}l=1e3}else l=1e3;l=dl(this,A,l),d=Ze(this.J),ne(d,"RID",o),ne(d,"CVER",22),this.G&&ne(d,"X-HTTP-Session-Id",this.G),ur(this,d),R&&(this.R?l="headers="+er(sl(R))+"&"+l:this.u&&Yi(d,this.u,R)),Wi(this.h,A),this.Ra&&ne(d,"TYPE","init"),this.S?(ne(d,"$req",l),ne(d,"SID","null"),A.U=!0,zi(A,d,null)):zi(A,d,l),this.I=2}}else this.I==3&&(o?hl(this,o):this.i.length==0||Gc(this.h)||hl(this))};function hl(o,l){var d;l?d=l.l:d=o.V++;const p=Ze(o.J);ne(p,"SID",o.M),ne(p,"RID",d),ne(p,"AID",o.K),ur(o,p),o.u&&o.o&&Yi(p,o.u,o.o),d=new At(o,o.j,d,o.D+1),o.u===null&&(d.J=o.o),l&&(o.i=l.G.concat(o.i)),l=dl(o,d,1e3),d.H=Math.round(o.va*.5)+Math.round(o.va*.5*Math.random()),Wi(o.h,d),zi(d,p,l)}function ur(o,l){o.H&&Wr(o.H,function(d,p){ne(l,p,d)}),o.l&&Wr({},function(d,p){ne(l,p,d)})}function dl(o,l,d){d=Math.min(o.i.length,d);const p=o.l?h(o.l.Ka,o.l,o):null;e:{var A=o.i;let j=-1;for(;;){const he=["count="+d];j==-1?d>0?(j=A[0].g,he.push("ofs="+j)):j=0:he.push("ofs="+j);let X=!0;for(let fe=0;fe<d;fe++){var R=A[fe].g;const et=A[fe].map;if(R-=j,R<0)j=Math.max(0,A[fe].g-100),X=!1;else try{R="req"+R+"_"||"";try{var D=et instanceof Map?et:Object.entries(et);for(const[tn,Pt]of D){let Ct=Pt;c(Pt)&&(Ct=Ui(Pt)),he.push(R+tn+"="+encodeURIComponent(Ct))}}catch(tn){throw he.push(R+"type="+encodeURIComponent("_badmap")),tn}}catch{p&&p(et)}}if(X){D=he.join("&");break e}}D=void 0}return o=o.i.splice(0,d),l.G=o,D}function fl(o){if(!o.g&&!o.v){o.Y=1;var l=o.Da;we||g(),oe||(we(),oe=!0),v.add(l,o),o.A=0}}function Zi(o){return o.g||o.v||o.A>=3?!1:(o.Y++,o.v=Xn(h(o.Da,o),gl(o,o.A)),o.A++,!0)}n.Da=function(){if(this.v=null,pl(this),this.aa&&!(this.P||this.g==null||this.T<=0)){var o=4*this.T;this.j.info("BP detection timer enabled: "+o),this.B=Xn(h(this.Wa,this),o)}},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,Pe(10),rs(this),pl(this))};function eo(o){o.B!=null&&(a.clearTimeout(o.B),o.B=null)}function pl(o){o.g=new At(o,o.j,"rpc",o.Y),o.u===null&&(o.g.J=o.o),o.g.P=0;var l=Ze(o.na);ne(l,"RID","rpc"),ne(l,"SID",o.M),ne(l,"AID",o.K),ne(l,"CI",o.F?"0":"1"),!o.F&&o.ia&&ne(l,"TO",o.ia),ne(l,"TYPE","xmlhttp"),ur(o,l),o.u&&o.o&&Yi(l,o.u,o.o),o.O&&(o.g.H=o.O);var d=o.g;o=o.ba,d.M=1,d.A=es(Ze(l)),d.u=null,d.R=!0,$c(d,o)}n.Va=function(){this.C!=null&&(this.C=null,rs(this),Zi(this),Pe(19))};function is(o){o.C!=null&&(a.clearTimeout(o.C),o.C=null)}function ml(o,l){var d=null;if(o.g==l){is(o),eo(o),o.g=null;var p=2}else if(Ki(o.h,l))d=l.G,Wc(o.h,l),p=1;else return;if(o.I!=0){if(l.o)if(p==1){d=l.u?l.u.length:0,l=Date.now()-l.F;var A=o.D;p=Yr(),Re(p,new xc(p,d)),ss(o)}else fl(o);else if(A=l.m,A==3||A==0&&l.X>0||!(p==1&&mm(o,l)||p==2&&Zi(o)))switch(d&&d.length>0&&(l=o.h,l.i=l.i.concat(d)),A){case 1:en(o,5);break;case 4:en(o,10);break;case 3:en(o,6);break;default:en(o,2)}}}function gl(o,l){let d=o.Qa+Math.floor(Math.random()*o.Za);return o.isActive()||(d*=2),d*l}function en(o,l){if(o.j.info("Error code "+l),l==2){var d=h(o.bb,o),p=o.Ua;const A=!p;p=new bt(p||"//www.google.com/images/cleardot.gif"),a.location&&a.location.protocol=="http"||nr(p,"https"),es(p),A?lm(p.toString(),d):um(p.toString(),d)}else Pe(2);o.I=0,o.l&&o.l.pa(l),_l(o),ul(o)}n.bb=function(o){o?(this.j.info("Successfully pinged google.com"),Pe(2)):(this.j.info("Failed to ping google.com"),Pe(1))};function _l(o){if(o.I=0,o.ja=[],o.l){const l=Qc(o.h);(l.length!=0||o.i.length!=0)&&(k(o.ja,l),k(o.ja,o.i),o.h.i.length=0,S(o.i),o.i.length=0),o.l.oa()}}function yl(o,l,d){var p=d instanceof bt?Ze(d):new bt(d);if(p.g!="")l&&(p.g=l+"."+p.g),rr(p,p.u);else{var A=a.location;p=A.protocol,l=l?l+"."+A.hostname:A.hostname,A=+A.port;const R=new bt(null);p&&nr(R,p),l&&(R.g=l),A&&rr(R,A),d&&(R.h=d),p=R}return d=o.G,l=o.wa,d&&l&&ne(p,d,l),ne(p,"VER",o.ka),ur(o,p),p}function Tl(o,l,d){if(l&&!o.L)throw Error("Can't create secondary domain capable XhrIo object.");return l=o.Aa&&!o.ma?new se(new Ji({ab:d})):new se(o.ma),l.Fa(o.L),l}n.isActive=function(){return!!this.l&&this.l.isActive(this)};function wl(){}n=wl.prototype,n.ra=function(){},n.qa=function(){},n.pa=function(){},n.oa=function(){},n.isActive=function(){return!0},n.Ka=function(){};function os(){}os.prototype.g=function(o,l){return new xe(o,l)};function xe(o,l){Ee.call(this),this.g=new ll(l),this.l=o,this.h=l&&l.messageUrlParams||null,o=l&&l.messageHeaders||null,l&&l.clientProtocolHeaderRequired&&(o?o["X-Client-Protocol"]="webchannel":o={"X-Client-Protocol":"webchannel"}),this.g.o=o,o=l&&l.initMessageHeaders||null,l&&l.messageContentType&&(o?o["X-WebChannel-Content-Type"]=l.messageContentType:o={"X-WebChannel-Content-Type":l.messageContentType}),l&&l.sa&&(o?o["X-WebChannel-Client-Profile"]=l.sa:o={"X-WebChannel-Client-Profile":l.sa}),this.g.U=o,(o=l&&l.Qb)&&!T(o)&&(this.g.u=o),this.A=l&&l.supportsCrossDomainXhr||!1,this.v=l&&l.sendRawJson||!1,(l=l&&l.httpSessionIdParam)&&!T(l)&&(this.g.G=l,o=this.h,o!==null&&l in o&&(o=this.h,l in o&&delete o[l])),this.j=new In(this)}m(xe,Ee),xe.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},xe.prototype.close=function(){Xi(this.g)},xe.prototype.o=function(o){var l=this.g;if(typeof o=="string"){var d={};d.__data__=o,o=d}else this.v&&(d={},d.__data__=Ui(o),o=d);l.i.push(new tm(l.Ya++,o)),l.I==3&&ss(l)},xe.prototype.N=function(){this.g.l=null,delete this.j,Xi(this.g),delete this.g,xe.Z.N.call(this)};function El(o){Bi.call(this),o.__headers__&&(this.headers=o.__headers__,this.statusCode=o.__status__,delete o.__headers__,delete o.__status__);var l=o.__sm__;if(l){e:{for(const d in l){o=d;break e}o=void 0}(this.i=o)&&(o=this.i,l=l!==null&&o in l?l[o]:void 0),this.data=l}else this.data=o}m(El,Bi);function vl(){qi.call(this),this.status=1}m(vl,qi);function In(o){this.g=o}m(In,wl),In.prototype.ra=function(){Re(this.g,"a")},In.prototype.qa=function(o){Re(this.g,new El(o))},In.prototype.pa=function(o){Re(this.g,new vl)},In.prototype.oa=function(){Re(this.g,"b")},os.prototype.createWebChannel=os.prototype.g,xe.prototype.send=xe.prototype.o,xe.prototype.open=xe.prototype.m,xe.prototype.close=xe.prototype.close,Hd=function(){return new os},zd=function(){return Yr()},jd=Yt,Lo={jb:0,mb:1,nb:2,Hb:3,Mb:4,Jb:5,Kb:6,Ib:7,Gb:8,Lb:9,PROXY:10,NOPROXY:11,Eb:12,Ab:13,Bb:14,zb:15,Cb:16,Db:17,fb:18,eb:19,gb:20},Xr.NO_ERROR=0,Xr.TIMEOUT=8,Xr.HTTP_ERROR=6,Ts=Xr,Fc.COMPLETE="complete",$d=Fc,Vc.EventType=Jn,Jn.OPEN="a",Jn.CLOSE="b",Jn.ERROR="c",Jn.MESSAGE="d",Ee.prototype.listen=Ee.prototype.J,dr=Vc,se.prototype.listenOnce=se.prototype.K,se.prototype.getLastError=se.prototype.Ha,se.prototype.getLastErrorCode=se.prototype.ya,se.prototype.getStatus=se.prototype.ca,se.prototype.getResponseJson=se.prototype.La,se.prototype.getResponseText=se.prototype.la,se.prototype.send=se.prototype.ea,se.prototype.setWithCredentials=se.prototype.Fa,qd=se}).apply(typeof ls<"u"?ls:typeof self<"u"?self:typeof window<"u"?window:{});let Ie=class{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}};Ie.UNAUTHENTICATED=new Ie(null),Ie.GOOGLE_CREDENTIALS=new Ie("google-credentials-uid"),Ie.FIRST_PARTY=new Ie("first-party-uid"),Ie.MOCK_USER=new Ie("mock-user");let zn="12.8.0";function tE(n){zn=n}const pn=new ai("@firebase/firestore");function An(){return pn.logLevel}function L(n,...e){if(pn.logLevel<=H.DEBUG){const t=e.map(Ca);pn.debug(`Firestore (${zn}): ${n}`,...t)}}function wt(n,...e){if(pn.logLevel<=H.ERROR){const t=e.map(Ca);pn.error(`Firestore (${zn}): ${n}`,...t)}}function Ln(n,...e){if(pn.logLevel<=H.WARN){const t=e.map(Ca);pn.warn(`Firestore (${zn}): ${n}`,...t)}}function Ca(n){if(typeof n=="string")return n;try{return(function(t){return JSON.stringify(t)})(n)}catch{return n}}function x(n,e,t){let r="Unexpected state";typeof e=="string"?r=e:t=e,Gd(n,r,t)}function Gd(n,e,t){let r=`FIRESTORE (${zn}) INTERNAL ASSERTION FAILED: ${e} (ID: ${n.toString(16)})`;if(t!==void 0)try{r+=" CONTEXT: "+JSON.stringify(t)}catch{r+=" CONTEXT: "+t}throw wt(r),new Error(r)}function Y(n,e,t,r){let s="Unexpected state";typeof t=="string"?s=t:r=t,n||Gd(e,s,r)}function q(n,e){return n}const P={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class O extends $e{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class _t{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class Kd{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class nE{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(Ie.UNAUTHENTICATED)))}shutdown(){}}class rE{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable((()=>t(this.token.user)))}shutdown(){this.changeListener=null}}class sE{constructor(e){this.t=e,this.currentUser=Ie.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){Y(this.o===void 0,42304);let r=this.i;const s=u=>this.i!==r?(r=this.i,t(u)):Promise.resolve();let i=new _t;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new _t,e.enqueueRetryable((()=>s(this.currentUser)))};const a=()=>{const u=i;e.enqueueRetryable((async()=>{await u.promise,await s(this.currentUser)}))},c=u=>{L("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=u,this.o&&(this.auth.addAuthTokenListener(this.o),a())};this.t.onInit((u=>c(u))),setTimeout((()=>{if(!this.auth){const u=this.t.getImmediate({optional:!0});u?c(u):(L("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new _t)}}),0),a()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then((r=>this.i!==e?(L("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):r?(Y(typeof r.accessToken=="string",31837,{l:r}),new Kd(r.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 Y(e===null||typeof e=="string",2055,{h:e}),new Ie(e)}}class iE{constructor(e,t,r){this.P=e,this.T=t,this.I=r,this.type="FirstParty",this.user=Ie.FIRST_PARTY,this.R=new Map}A(){return this.I?this.I():null}get headers(){this.R.set("X-Goog-AuthUser",this.P);const e=this.A();return e&&this.R.set("Authorization",e),this.T&&this.R.set("X-Goog-Iam-Authorization-Token",this.T),this.R}}class oE{constructor(e,t,r){this.P=e,this.T=t,this.I=r}getToken(){return Promise.resolve(new iE(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable((()=>t(Ie.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class ou{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 aE{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,Fe(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){Y(this.o===void 0,3512);const r=i=>{i.error!=null&&L("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${i.error.message}`);const a=i.token!==this.m;return this.m=i.token,L("FirebaseAppCheckTokenProvider",`Received ${a?"new":"existing"} token.`),a?t(i.token):Promise.resolve()};this.o=i=>{e.enqueueRetryable((()=>r(i)))};const s=i=>{L("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=i,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit((i=>s(i))),setTimeout((()=>{if(!this.appCheck){const i=this.V.getImmediate({optional:!0});i?s(i):L("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){if(this.p)return Promise.resolve(new ou(this.p));const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((t=>t?(Y(typeof t.token=="string",44558,{tokenResult:t}),this.m=t.token,new ou(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 cE(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 r=0;r<n;r++)t[r]=Math.floor(256*Math.random());return t}class ka{static newId(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=62*Math.floor(4.129032258064516);let r="";for(;r.length<20;){const s=cE(40);for(let i=0;i<s.length;++i)r.length<20&&s[i]<t&&(r+=e.charAt(s[i]%62))}return r}}function G(n,e){return n<e?-1:n>e?1:0}function Mo(n,e){const t=Math.min(n.length,e.length);for(let r=0;r<t;r++){const s=n.charAt(r),i=e.charAt(r);if(s!==i)return po(s)===po(i)?G(s,i):po(s)?1:-1}return G(n.length,e.length)}const lE=55296,uE=57343;function po(n){const e=n.charCodeAt(0);return e>=lE&&e<=uE}function Mn(n,e,t){return n.length===e.length&&n.every(((r,s)=>t(r,e[s])))}const xo="__name__";class tt{constructor(e,t,r){t===void 0?t=0:t>e.length&&x(637,{offset:t,range:e.length}),r===void 0?r=e.length-t:r>e.length-t&&x(1746,{length:r,range:e.length-t}),this.segments=e,this.offset=t,this.len=r}get length(){return this.len}isEqual(e){return tt.comparator(this,e)===0}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof tt?e.forEach((r=>{t.push(r)})):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,r=this.limit();t<r;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const r=Math.min(e.length,t.length);for(let s=0;s<r;s++){const i=tt.compareSegments(e.get(s),t.get(s));if(i!==0)return i}return G(e.length,t.length)}static compareSegments(e,t){const r=tt.isNumericId(e),s=tt.isNumericId(t);return r&&!s?-1:!r&&s?1:r&&s?tt.extractNumericId(e).compare(tt.extractNumericId(t)):Mo(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return xt.fromString(e.substring(4,e.length-2))}}class Z extends tt{construct(e,t,r){return new Z(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const r of e){if(r.indexOf("//")>=0)throw new O(P.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);t.push(...r.split("/").filter((s=>s.length>0)))}return new Z(t)}static emptyPath(){return new Z([])}}const hE=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class ye extends tt{construct(e,t,r){return new ye(e,t,r)}static isValidIdentifier(e){return hE.test(e)}canonicalString(){return this.toArray().map((e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),ye.isValidIdentifier(e)||(e="`"+e+"`"),e))).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===xo}static keyField(){return new ye([xo])}static fromServerFormat(e){const t=[];let r="",s=0;const i=()=>{if(r.length===0)throw new O(P.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(r),r=""};let a=!1;for(;s<e.length;){const c=e[s];if(c==="\\"){if(s+1===e.length)throw new O(P.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const u=e[s+1];if(u!=="\\"&&u!=="."&&u!=="`")throw new O(P.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=u,s+=2}else c==="`"?(a=!a,s++):c!=="."||a?(r+=c,s++):(i(),s++)}if(i(),a)throw new O(P.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new ye(t)}static emptyPath(){return new ye([])}}class M{constructor(e){this.path=e}static fromPath(e){return new M(Z.fromString(e))}static fromName(e){return new M(Z.fromString(e).popFirst(5))}static empty(){return new M(Z.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&&Z.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return Z.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new M(new Z(e.slice()))}}function Wd(n,e,t){if(!t)throw new O(P.INVALID_ARGUMENT,`Function ${n}() cannot be called with an empty ${e}.`)}function dE(n,e,t,r){if(e===!0&&r===!0)throw new O(P.INVALID_ARGUMENT,`${n} and ${t} cannot be used together.`)}function au(n){if(!M.isDocumentKey(n))throw new O(P.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${n} has ${n.length}.`)}function cu(n){if(M.isDocumentKey(n))throw new O(P.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${n} has ${n.length}.`)}function Qd(n){return typeof n=="object"&&n!==null&&(Object.getPrototypeOf(n)===Object.prototype||Object.getPrototypeOf(n)===null)}function pi(n){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n.length>20&&(n=`${n.substring(0,20)}...`),JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return""+n;if(typeof n=="object"){if(n instanceof Array)return"an array";{const e=(function(r){return r.constructor?r.constructor.name:null})(n);return e?`a custom ${e} object`:"an object"}}return typeof n=="function"?"a function":x(12329,{type:typeof n})}function qe(n,e){if("_delegate"in n&&(n=n._delegate),!(n instanceof e)){if(e.name===n.constructor.name)throw new O(P.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const t=pi(n);throw new O(P.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return n}function fE(n,e){if(e<=0)throw new O(P.INVALID_ARGUMENT,`Function ${n}() requires a positive number, but it was: ${e}.`)}function ue(n,e){const t={typeString:n};return e&&(t.value=e),t}function Br(n,e){if(!Qd(n))throw new O(P.INVALID_ARGUMENT,"JSON must be an object");let t;for(const r in e)if(e[r]){const s=e[r].typeString,i="value"in e[r]?{value:e[r].value}:void 0;if(!(r in n)){t=`JSON missing required field: '${r}'`;break}const a=n[r];if(s&&typeof a!==s){t=`JSON field '${r}' must be a ${s}.`;break}if(i!==void 0&&a!==i.value){t=`Expected '${r}' field to equal '${i.value}'`;break}}if(t)throw new O(P.INVALID_ARGUMENT,t);return!0}const lu=-62135596800,uu=1e6;class z{static now(){return z.fromMillis(Date.now())}static fromDate(e){return z.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),r=Math.floor((e-1e3*t)*uu);return new z(t,r)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new O(P.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new O(P.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<lu)throw new O(P.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new O(P.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/uu}_compareTo(e){return this.seconds===e.seconds?G(this.nanoseconds,e.nanoseconds):G(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:z._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(Br(e,z._jsonSchema))return new z(e.seconds,e.nanoseconds)}valueOf(){const e=this.seconds-lu;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}z._jsonSchemaVersion="firestore/timestamp/1.0",z._jsonSchema={type:ue("string",z._jsonSchemaVersion),seconds:ue("number"),nanoseconds:ue("number")};class B{static fromTimestamp(e){return new B(e)}static min(){return new B(new z(0,0))}static max(){return new B(new z(253402300799,999999999))}constructor(e){this.timestamp=e}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}const Rr=-1;function pE(n,e){const t=n.toTimestamp().seconds,r=n.toTimestamp().nanoseconds+1,s=B.fromTimestamp(r===1e9?new z(t+1,0):new z(t,r));return new Bt(s,M.empty(),e)}function mE(n){return new Bt(n.readTime,n.key,Rr)}class Bt{constructor(e,t,r){this.readTime=e,this.documentKey=t,this.largestBatchId=r}static min(){return new Bt(B.min(),M.empty(),Rr)}static max(){return new Bt(B.max(),M.empty(),Rr)}}function gE(n,e){let t=n.readTime.compareTo(e.readTime);return t!==0?t:(t=M.comparator(n.documentKey,e.documentKey),t!==0?t:G(n.largestBatchId,e.largestBatchId))}const _E="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class yE{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((e=>e()))}}async function Hn(n){if(n.code!==P.FAILED_PRECONDITION||n.message!==_E)throw n;L("LocalStore","Unexpectedly lost primary lease")}class C{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e((t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)}),(t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)}))}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&x(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new C(((r,s)=>{this.nextCallback=i=>{this.wrapSuccess(e,i).next(r,s)},this.catchCallback=i=>{this.wrapFailure(t,i).next(r,s)}}))}toPromise(){return new Promise(((e,t)=>{this.next(e,t)}))}wrapUserFunction(e){try{const t=e();return t instanceof C?t:C.resolve(t)}catch(t){return C.reject(t)}}wrapSuccess(e,t){return e?this.wrapUserFunction((()=>e(t))):C.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction((()=>e(t))):C.reject(t)}static resolve(e){return new C(((t,r)=>{t(e)}))}static reject(e){return new C(((t,r)=>{r(e)}))}static waitFor(e){return new C(((t,r)=>{let s=0,i=0,a=!1;e.forEach((c=>{++s,c.next((()=>{++i,a&&i===s&&t()}),(u=>r(u)))})),a=!0,i===s&&t()}))}static or(e){let t=C.resolve(!1);for(const r of e)t=t.next((s=>s?C.resolve(s):r()));return t}static forEach(e,t){const r=[];return e.forEach(((s,i)=>{r.push(t.call(this,s,i))})),this.waitFor(r)}static mapArray(e,t){return new C(((r,s)=>{const i=e.length,a=new Array(i);let c=0;for(let u=0;u<i;u++){const h=u;t(e[h]).next((f=>{a[h]=f,++c,c===i&&r(a)}),(f=>s(f)))}}))}static doWhile(e,t){return new C(((r,s)=>{const i=()=>{e()===!0?t().next((()=>{i()}),s):r()};i()}))}}function TE(n){const e=n.match(/Android ([\d.]+)/i),t=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(t)}function Gn(n){return n.name==="IndexedDbTransactionError"}class mi{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=r=>this.ae(r),this.ue=r=>t.writeSequenceNumber(r))}ae(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.ue&&this.ue(e),e}}mi.ce=-1;const Na=-1;function gi(n){return n==null}function Ms(n){return n===0&&1/n==-1/0}function wE(n){return typeof n=="number"&&Number.isInteger(n)&&!Ms(n)&&n<=Number.MAX_SAFE_INTEGER&&n>=Number.MIN_SAFE_INTEGER}const Jd="";function EE(n){let e="";for(let t=0;t<n.length;t++)e.length>0&&(e=hu(e)),e=vE(n.get(t),e);return hu(e)}function vE(n,e){let t=e;const r=n.length;for(let s=0;s<r;s++){const i=n.charAt(s);switch(i){case"\0":t+="";break;case Jd:t+="";break;default:t+=i}}return t}function hu(n){return n+Jd+""}function du(n){let e=0;for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e++;return e}function Wt(n,e){for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e(t,n[t])}function Yd(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}class re{constructor(e,t){this.comparator=e,this.root=t||_e.EMPTY}insert(e,t){return new re(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,_e.BLACK,null,null))}remove(e){return new re(this.comparator,this.root.remove(e,this.comparator).copy(null,null,_e.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){const r=this.comparator(e,t.key);if(r===0)return t.value;r<0?t=t.left:r>0&&(t=t.right)}return null}indexOf(e){let t=0,r=this.root;for(;!r.isEmpty();){const s=this.comparator(e,r.key);if(s===0)return t+r.left.size;s<0?r=r.left:(t+=r.left.size+1,r=r.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal(((t,r)=>(e(t,r),!1)))}toString(){const e=[];return this.inorderTraversal(((t,r)=>(e.push(`${t}:${r}`),!1))),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new us(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new us(this.root,e,this.comparator,!1)}getReverseIterator(){return new us(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new us(this.root,e,this.comparator,!0)}}class us{constructor(e,t,r,s){this.isReverse=s,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?r(e.key,t):1,t&&s&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(i===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class _e{constructor(e,t,r,s,i){this.key=e,this.value=t,this.color=r??_e.RED,this.left=s??_e.EMPTY,this.right=i??_e.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,r,s,i){return new _e(e??this.key,t??this.value,r??this.color,s??this.left,i??this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,r){let s=this;const i=r(e,s.key);return s=i<0?s.copy(null,null,null,s.left.insert(e,t,r),null):i===0?s.copy(null,t,null,null,null):s.copy(null,null,null,null,s.right.insert(e,t,r)),s.fixUp()}removeMin(){if(this.left.isEmpty())return _e.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let r,s=this;if(t(e,s.key)<0)s.left.isEmpty()||s.left.isRed()||s.left.left.isRed()||(s=s.moveRedLeft()),s=s.copy(null,null,null,s.left.remove(e,t),null);else{if(s.left.isRed()&&(s=s.rotateRight()),s.right.isEmpty()||s.right.isRed()||s.right.left.isRed()||(s=s.moveRedRight()),t(e,s.key)===0){if(s.right.isEmpty())return _e.EMPTY;r=s.right.min(),s=s.copy(r.key,r.value,null,null,s.right.removeMin())}s=s.copy(null,null,null,null,s.right.remove(e,t))}return s.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,_e.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,_e.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw x(43730,{key:this.key,value:this.value});if(this.right.isRed())throw x(14113,{key:this.key,value:this.value});const e=this.left.check();if(e!==this.right.check())throw x(27949);return e+(this.isRed()?0:1)}}_e.EMPTY=null,_e.RED=!0,_e.BLACK=!1;_e.EMPTY=new class{constructor(){this.size=0}get key(){throw x(57766)}get value(){throw x(16141)}get color(){throw x(16727)}get left(){throw x(29726)}get right(){throw x(36894)}copy(e,t,r,s,i){return this}insert(e,t,r){return new _e(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class de{constructor(e){this.comparator=e,this.data=new re(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal(((t,r)=>(e(t),!1)))}forEachInRange(e,t){const r=this.data.getIteratorFrom(e[0]);for(;r.hasNext();){const s=r.getNext();if(this.comparator(s.key,e[1])>=0)return;t(s.key)}}forEachWhile(e,t){let r;for(r=t!==void 0?this.data.getIteratorFrom(t):this.data.getIterator();r.hasNext();)if(!e(r.getNext().key))return}firstAfterOrEqual(e){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new fu(this.data.getIterator())}getIteratorFrom(e){return new fu(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach((r=>{t=t.add(r)})),t}isEqual(e){if(!(e instanceof de)||this.size!==e.size)return!1;const t=this.data.getIterator(),r=e.data.getIterator();for(;t.hasNext();){const s=t.getNext().key,i=r.getNext().key;if(this.comparator(s,i)!==0)return!1}return!0}toArray(){const e=[];return this.forEach((t=>{e.push(t)})),e}toString(){const e=[];return this.forEach((t=>e.push(t))),"SortedSet("+e.toString()+")"}copy(e){const t=new de(this.comparator);return t.data=e,t}}class fu{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}class Ue{constructor(e){this.fields=e,e.sort(ye.comparator)}static empty(){return new Ue([])}unionWith(e){let t=new de(ye.comparator);for(const r of this.fields)t=t.add(r);for(const r of e)t=t.add(r);return new Ue(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return Mn(this.fields,e.fields,((t,r)=>t.isEqual(r)))}}class Xd extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class Te{constructor(e){this.binaryString=e}static fromBase64String(e){const t=(function(s){try{return atob(s)}catch(i){throw typeof DOMException<"u"&&i instanceof DOMException?new Xd("Invalid base64 string: "+i):i}})(e);return new Te(t)}static fromUint8Array(e){const t=(function(s){let i="";for(let a=0;a<s.length;++a)i+=String.fromCharCode(s[a]);return i})(e);return new Te(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 r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r})(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return G(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}Te.EMPTY_BYTE_STRING=new Te("");const IE=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function qt(n){if(Y(!!n,39018),typeof n=="string"){let e=0;const t=IE.exec(n);if(Y(!!t,46558,{timestamp:n}),t[1]){let s=t[1];s=(s+"000000000").substr(0,9),e=Number(s)}const r=new Date(n);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:ae(n.seconds),nanos:ae(n.nanos)}}function ae(n){return typeof n=="number"?n:typeof n=="string"?Number(n):0}function $t(n){return typeof n=="string"?Te.fromBase64String(n):Te.fromUint8Array(n)}const Zd="server_timestamp",ef="__type__",tf="__previous_value__",nf="__local_write_time__";function Da(n){return(n?.mapValue?.fields||{})[ef]?.stringValue===Zd}function _i(n){const e=n.mapValue.fields[tf];return Da(e)?_i(e):e}function Pr(n){const e=qt(n.mapValue.fields[nf].timestampValue);return new z(e.seconds,e.nanos)}class AE{constructor(e,t,r,s,i,a,c,u,h,f,m){this.databaseId=e,this.appId=t,this.persistenceKey=r,this.host=s,this.ssl=i,this.forceLongPolling=a,this.autoDetectLongPolling=c,this.longPollingOptions=u,this.useFetchStreams=h,this.isUsingEmulator=f,this.apiKey=m}}const xs="(default)";class Cr{constructor(e,t){this.projectId=e,this.database=t||xs}static empty(){return new Cr("","")}get isDefaultDatabase(){return this.database===xs}isEqual(e){return e instanceof Cr&&e.projectId===this.projectId&&e.database===this.database}}function bE(n,e){if(!Object.prototype.hasOwnProperty.apply(n.options,["projectId"]))throw new O(P.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new Cr(n.options.projectId,e)}const rf="__type__",SE="__max__",hs={mapValue:{}},sf="__vector__",Fs="value";function jt(n){return"nullValue"in n?0:"booleanValue"in n?1:"integerValue"in n||"doubleValue"in n?2:"timestampValue"in n?3:"stringValue"in n?5:"bytesValue"in n?6:"referenceValue"in n?7:"geoPointValue"in n?8:"arrayValue"in n?9:"mapValue"in n?Da(n)?4:PE(n)?9007199254740991:RE(n)?10:11:x(28295,{value:n})}function ct(n,e){if(n===e)return!0;const t=jt(n);if(t!==jt(e))return!1;switch(t){case 0:case 9007199254740991:return!0;case 1:return n.booleanValue===e.booleanValue;case 4:return Pr(n).isEqual(Pr(e));case 3:return(function(s,i){if(typeof s.timestampValue=="string"&&typeof i.timestampValue=="string"&&s.timestampValue.length===i.timestampValue.length)return s.timestampValue===i.timestampValue;const a=qt(s.timestampValue),c=qt(i.timestampValue);return a.seconds===c.seconds&&a.nanos===c.nanos})(n,e);case 5:return n.stringValue===e.stringValue;case 6:return(function(s,i){return $t(s.bytesValue).isEqual($t(i.bytesValue))})(n,e);case 7:return n.referenceValue===e.referenceValue;case 8:return(function(s,i){return ae(s.geoPointValue.latitude)===ae(i.geoPointValue.latitude)&&ae(s.geoPointValue.longitude)===ae(i.geoPointValue.longitude)})(n,e);case 2:return(function(s,i){if("integerValue"in s&&"integerValue"in i)return ae(s.integerValue)===ae(i.integerValue);if("doubleValue"in s&&"doubleValue"in i){const a=ae(s.doubleValue),c=ae(i.doubleValue);return a===c?Ms(a)===Ms(c):isNaN(a)&&isNaN(c)}return!1})(n,e);case 9:return Mn(n.arrayValue.values||[],e.arrayValue.values||[],ct);case 10:case 11:return(function(s,i){const a=s.mapValue.fields||{},c=i.mapValue.fields||{};if(du(a)!==du(c))return!1;for(const u in a)if(a.hasOwnProperty(u)&&(c[u]===void 0||!ct(a[u],c[u])))return!1;return!0})(n,e);default:return x(52216,{left:n})}}function kr(n,e){return(n.values||[]).find((t=>ct(t,e)))!==void 0}function xn(n,e){if(n===e)return 0;const t=jt(n),r=jt(e);if(t!==r)return G(t,r);switch(t){case 0:case 9007199254740991:return 0;case 1:return G(n.booleanValue,e.booleanValue);case 2:return(function(i,a){const c=ae(i.integerValue||i.doubleValue),u=ae(a.integerValue||a.doubleValue);return c<u?-1:c>u?1:c===u?0:isNaN(c)?isNaN(u)?0:-1:1})(n,e);case 3:return pu(n.timestampValue,e.timestampValue);case 4:return pu(Pr(n),Pr(e));case 5:return Mo(n.stringValue,e.stringValue);case 6:return(function(i,a){const c=$t(i),u=$t(a);return c.compareTo(u)})(n.bytesValue,e.bytesValue);case 7:return(function(i,a){const c=i.split("/"),u=a.split("/");for(let h=0;h<c.length&&h<u.length;h++){const f=G(c[h],u[h]);if(f!==0)return f}return G(c.length,u.length)})(n.referenceValue,e.referenceValue);case 8:return(function(i,a){const c=G(ae(i.latitude),ae(a.latitude));return c!==0?c:G(ae(i.longitude),ae(a.longitude))})(n.geoPointValue,e.geoPointValue);case 9:return mu(n.arrayValue,e.arrayValue);case 10:return(function(i,a){const c=i.fields||{},u=a.fields||{},h=c[Fs]?.arrayValue,f=u[Fs]?.arrayValue,m=G(h?.values?.length||0,f?.values?.length||0);return m!==0?m:mu(h,f)})(n.mapValue,e.mapValue);case 11:return(function(i,a){if(i===hs.mapValue&&a===hs.mapValue)return 0;if(i===hs.mapValue)return 1;if(a===hs.mapValue)return-1;const c=i.fields||{},u=Object.keys(c),h=a.fields||{},f=Object.keys(h);u.sort(),f.sort();for(let m=0;m<u.length&&m<f.length;++m){const y=Mo(u[m],f[m]);if(y!==0)return y;const S=xn(c[u[m]],h[f[m]]);if(S!==0)return S}return G(u.length,f.length)})(n.mapValue,e.mapValue);default:throw x(23264,{he:t})}}function pu(n,e){if(typeof n=="string"&&typeof e=="string"&&n.length===e.length)return G(n,e);const t=qt(n),r=qt(e),s=G(t.seconds,r.seconds);return s!==0?s:G(t.nanos,r.nanos)}function mu(n,e){const t=n.values||[],r=e.values||[];for(let s=0;s<t.length&&s<r.length;++s){const i=xn(t[s],r[s]);if(i)return i}return G(t.length,r.length)}function Fn(n){return Fo(n)}function Fo(n){return"nullValue"in n?"null":"booleanValue"in n?""+n.booleanValue:"integerValue"in n?""+n.integerValue:"doubleValue"in n?""+n.doubleValue:"timestampValue"in n?(function(t){const r=qt(t);return`time(${r.seconds},${r.nanos})`})(n.timestampValue):"stringValue"in n?n.stringValue:"bytesValue"in n?(function(t){return $t(t).toBase64()})(n.bytesValue):"referenceValue"in n?(function(t){return M.fromName(t).toString()})(n.referenceValue):"geoPointValue"in n?(function(t){return`geo(${t.latitude},${t.longitude})`})(n.geoPointValue):"arrayValue"in n?(function(t){let r="[",s=!0;for(const i of t.values||[])s?s=!1:r+=",",r+=Fo(i);return r+"]"})(n.arrayValue):"mapValue"in n?(function(t){const r=Object.keys(t.fields||{}).sort();let s="{",i=!0;for(const a of r)i?i=!1:s+=",",s+=`${a}:${Fo(t.fields[a])}`;return s+"}"})(n.mapValue):x(61005,{value:n})}function ws(n){switch(jt(n)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const e=_i(n);return e?16+ws(e):16;case 5:return 2*n.stringValue.length;case 6:return $t(n.bytesValue).approximateByteSize();case 7:return n.referenceValue.length;case 9:return(function(r){return(r.values||[]).reduce(((s,i)=>s+ws(i)),0)})(n.arrayValue);case 10:case 11:return(function(r){let s=0;return Wt(r.fields,((i,a)=>{s+=i.length+ws(a)})),s})(n.mapValue);default:throw x(13486,{value:n})}}function gu(n,e){return{referenceValue:`projects/${n.projectId}/databases/${n.database}/documents/${e.path.canonicalString()}`}}function Uo(n){return!!n&&"integerValue"in n}function Va(n){return!!n&&"arrayValue"in n}function _u(n){return!!n&&"nullValue"in n}function yu(n){return!!n&&"doubleValue"in n&&isNaN(Number(n.doubleValue))}function Es(n){return!!n&&"mapValue"in n}function RE(n){return(n?.mapValue?.fields||{})[rf]?.stringValue===sf}function Tr(n){if(n.geoPointValue)return{geoPointValue:{...n.geoPointValue}};if(n.timestampValue&&typeof n.timestampValue=="object")return{timestampValue:{...n.timestampValue}};if(n.mapValue){const e={mapValue:{fields:{}}};return Wt(n.mapValue.fields,((t,r)=>e.mapValue.fields[t]=Tr(r))),e}if(n.arrayValue){const e={arrayValue:{values:[]}};for(let t=0;t<(n.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=Tr(n.arrayValue.values[t]);return e}return{...n}}function PE(n){return(((n.mapValue||{}).fields||{}).__type__||{}).stringValue===SE}class Oe{constructor(e){this.value=e}static empty(){return new Oe({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let r=0;r<e.length-1;++r)if(t=(t.mapValue.fields||{})[e.get(r)],!Es(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=Tr(t)}setAll(e){let t=ye.emptyPath(),r={},s=[];e.forEach(((a,c)=>{if(!t.isImmediateParentOf(c)){const u=this.getFieldsMap(t);this.applyChanges(u,r,s),r={},s=[],t=c.popLast()}a?r[c.lastSegment()]=Tr(a):s.push(c.lastSegment())}));const i=this.getFieldsMap(t);this.applyChanges(i,r,s)}delete(e){const t=this.field(e.popLast());Es(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return ct(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let r=0;r<e.length;++r){let s=t.mapValue.fields[e.get(r)];Es(s)&&s.mapValue.fields||(s={mapValue:{fields:{}}},t.mapValue.fields[e.get(r)]=s),t=s}return t.mapValue.fields}applyChanges(e,t,r){Wt(t,((s,i)=>e[s]=i));for(const s of r)delete e[s]}clone(){return new Oe(Tr(this.value))}}function of(n){const e=[];return Wt(n.fields,((t,r)=>{const s=new ye([t]);if(Es(r)){const i=of(r.mapValue).fields;if(i.length===0)e.push(s);else for(const a of i)e.push(s.child(a))}else e.push(s)})),new Ue(e)}class Ae{constructor(e,t,r,s,i,a,c){this.key=e,this.documentType=t,this.version=r,this.readTime=s,this.createTime=i,this.data=a,this.documentState=c}static newInvalidDocument(e){return new Ae(e,0,B.min(),B.min(),B.min(),Oe.empty(),0)}static newFoundDocument(e,t,r,s){return new Ae(e,1,t,B.min(),r,s,0)}static newNoDocument(e,t){return new Ae(e,2,t,B.min(),B.min(),Oe.empty(),0)}static newUnknownDocument(e,t){return new Ae(e,3,t,B.min(),B.min(),Oe.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(B.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=Oe.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Oe.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=B.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(e){return e instanceof Ae&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new Ae(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}class Us{constructor(e,t){this.position=e,this.inclusive=t}}function Tu(n,e,t){let r=0;for(let s=0;s<n.position.length;s++){const i=e[s],a=n.position[s];if(i.field.isKeyField()?r=M.comparator(M.fromName(a.referenceValue),t.key):r=xn(a,t.data.field(i.field)),i.dir==="desc"&&(r*=-1),r!==0)break}return r}function wu(n,e){if(n===null)return e===null;if(e===null||n.inclusive!==e.inclusive||n.position.length!==e.position.length)return!1;for(let t=0;t<n.position.length;t++)if(!ct(n.position[t],e.position[t]))return!1;return!0}class Nr{constructor(e,t="asc"){this.field=e,this.dir=t}}function CE(n,e){return n.dir===e.dir&&n.field.isEqual(e.field)}class af{}class le extends af{constructor(e,t,r){super(),this.field=e,this.op=t,this.value=r}static create(e,t,r){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,r):new NE(e,t,r):t==="array-contains"?new OE(e,r):t==="in"?new LE(e,r):t==="not-in"?new ME(e,r):t==="array-contains-any"?new xE(e,r):new le(e,t,r)}static createKeyFieldInFilter(e,t,r){return t==="in"?new DE(e,r):new VE(e,r)}matches(e){const t=e.data.field(this.field);return this.op==="!="?t!==null&&t.nullValue===void 0&&this.matchesComparison(xn(t,this.value)):t!==null&&jt(this.value)===jt(t)&&this.matchesComparison(xn(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return x(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class Xe extends af{constructor(e,t){super(),this.filters=e,this.op=t,this.Pe=null}static create(e,t){return new Xe(e,t)}matches(e){return cf(this)?this.filters.find((t=>!t.matches(e)))===void 0:this.filters.find((t=>t.matches(e)))!==void 0}getFlattenedFilters(){return this.Pe!==null||(this.Pe=this.filters.reduce(((e,t)=>e.concat(t.getFlattenedFilters())),[])),this.Pe}getFilters(){return Object.assign([],this.filters)}}function cf(n){return n.op==="and"}function lf(n){return kE(n)&&cf(n)}function kE(n){for(const e of n.filters)if(e instanceof Xe)return!1;return!0}function Bo(n){if(n instanceof le)return n.field.canonicalString()+n.op.toString()+Fn(n.value);if(lf(n))return n.filters.map((e=>Bo(e))).join(",");{const e=n.filters.map((t=>Bo(t))).join(",");return`${n.op}(${e})`}}function uf(n,e){return n instanceof le?(function(r,s){return s instanceof le&&r.op===s.op&&r.field.isEqual(s.field)&&ct(r.value,s.value)})(n,e):n instanceof Xe?(function(r,s){return s instanceof Xe&&r.op===s.op&&r.filters.length===s.filters.length?r.filters.reduce(((i,a,c)=>i&&uf(a,s.filters[c])),!0):!1})(n,e):void x(19439)}function hf(n){return n instanceof le?(function(t){return`${t.field.canonicalString()} ${t.op} ${Fn(t.value)}`})(n):n instanceof Xe?(function(t){return t.op.toString()+" {"+t.getFilters().map(hf).join(" ,")+"}"})(n):"Filter"}class NE extends le{constructor(e,t,r){super(e,t,r),this.key=M.fromName(r.referenceValue)}matches(e){const t=M.comparator(e.key,this.key);return this.matchesComparison(t)}}class DE extends le{constructor(e,t){super(e,"in",t),this.keys=df("in",t)}matches(e){return this.keys.some((t=>t.isEqual(e.key)))}}class VE extends le{constructor(e,t){super(e,"not-in",t),this.keys=df("not-in",t)}matches(e){return!this.keys.some((t=>t.isEqual(e.key)))}}function df(n,e){return(e.arrayValue?.values||[]).map((t=>M.fromName(t.referenceValue)))}class OE extends le{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return Va(t)&&kr(t.arrayValue,this.value)}}class LE extends le{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return t!==null&&kr(this.value.arrayValue,t)}}class ME extends le{constructor(e,t){super(e,"not-in",t)}matches(e){if(kr(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return t!==null&&t.nullValue===void 0&&!kr(this.value.arrayValue,t)}}class xE extends le{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!Va(t)||!t.arrayValue.values)&&t.arrayValue.values.some((r=>kr(this.value.arrayValue,r)))}}class FE{constructor(e,t=null,r=[],s=[],i=null,a=null,c=null){this.path=e,this.collectionGroup=t,this.orderBy=r,this.filters=s,this.limit=i,this.startAt=a,this.endAt=c,this.Te=null}}function Eu(n,e=null,t=[],r=[],s=null,i=null,a=null){return new FE(n,e,t,r,s,i,a)}function Oa(n){const e=q(n);if(e.Te===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map((r=>Bo(r))).join(","),t+="|ob:",t+=e.orderBy.map((r=>(function(i){return i.field.canonicalString()+i.dir})(r))).join(","),gi(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map((r=>Fn(r))).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map((r=>Fn(r))).join(",")),e.Te=t}return e.Te}function La(n,e){if(n.limit!==e.limit||n.orderBy.length!==e.orderBy.length)return!1;for(let t=0;t<n.orderBy.length;t++)if(!CE(n.orderBy[t],e.orderBy[t]))return!1;if(n.filters.length!==e.filters.length)return!1;for(let t=0;t<n.filters.length;t++)if(!uf(n.filters[t],e.filters[t]))return!1;return n.collectionGroup===e.collectionGroup&&!!n.path.isEqual(e.path)&&!!wu(n.startAt,e.startAt)&&wu(n.endAt,e.endAt)}function qo(n){return M.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}class Kn{constructor(e,t=null,r=[],s=[],i=null,a="F",c=null,u=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=s,this.limit=i,this.limitType=a,this.startAt=c,this.endAt=u,this.Ie=null,this.Ee=null,this.Re=null,this.startAt,this.endAt}}function UE(n,e,t,r,s,i,a,c){return new Kn(n,e,t,r,s,i,a,c)}function yi(n){return new Kn(n)}function vu(n){return n.filters.length===0&&n.limit===null&&n.startAt==null&&n.endAt==null&&(n.explicitOrderBy.length===0||n.explicitOrderBy.length===1&&n.explicitOrderBy[0].field.isKeyField())}function BE(n){return M.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}function ff(n){return n.collectionGroup!==null}function wr(n){const e=q(n);if(e.Ie===null){e.Ie=[];const t=new Set;for(const i of e.explicitOrderBy)e.Ie.push(i),t.add(i.field.canonicalString());const r=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(a){let c=new de(ye.comparator);return a.filters.forEach((u=>{u.getFlattenedFilters().forEach((h=>{h.isInequality()&&(c=c.add(h.field))}))})),c})(e).forEach((i=>{t.has(i.canonicalString())||i.isKeyField()||e.Ie.push(new Nr(i,r))})),t.has(ye.keyField().canonicalString())||e.Ie.push(new Nr(ye.keyField(),r))}return e.Ie}function st(n){const e=q(n);return e.Ee||(e.Ee=qE(e,wr(n))),e.Ee}function qE(n,e){if(n.limitType==="F")return Eu(n.path,n.collectionGroup,e,n.filters,n.limit,n.startAt,n.endAt);{e=e.map((s=>{const i=s.dir==="desc"?"asc":"desc";return new Nr(s.field,i)}));const t=n.endAt?new Us(n.endAt.position,n.endAt.inclusive):null,r=n.startAt?new Us(n.startAt.position,n.startAt.inclusive):null;return Eu(n.path,n.collectionGroup,e,n.filters,n.limit,t,r)}}function $o(n,e){const t=n.filters.concat([e]);return new Kn(n.path,n.collectionGroup,n.explicitOrderBy.slice(),t,n.limit,n.limitType,n.startAt,n.endAt)}function $E(n,e){const t=n.explicitOrderBy.concat([e]);return new Kn(n.path,n.collectionGroup,t,n.filters.slice(),n.limit,n.limitType,n.startAt,n.endAt)}function Bs(n,e,t){return new Kn(n.path,n.collectionGroup,n.explicitOrderBy.slice(),n.filters.slice(),e,t,n.startAt,n.endAt)}function Ti(n,e){return La(st(n),st(e))&&n.limitType===e.limitType}function pf(n){return`${Oa(st(n))}|lt:${n.limitType}`}function bn(n){return`Query(target=${(function(t){let r=t.path.canonicalString();return t.collectionGroup!==null&&(r+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(r+=`, filters: [${t.filters.map((s=>hf(s))).join(", ")}]`),gi(t.limit)||(r+=", limit: "+t.limit),t.orderBy.length>0&&(r+=`, orderBy: [${t.orderBy.map((s=>(function(a){return`${a.field.canonicalString()} (${a.dir})`})(s))).join(", ")}]`),t.startAt&&(r+=", startAt: ",r+=t.startAt.inclusive?"b:":"a:",r+=t.startAt.position.map((s=>Fn(s))).join(",")),t.endAt&&(r+=", endAt: ",r+=t.endAt.inclusive?"a:":"b:",r+=t.endAt.position.map((s=>Fn(s))).join(",")),`Target(${r})`})(st(n))}; limitType=${n.limitType})`}function wi(n,e){return e.isFoundDocument()&&(function(r,s){const i=s.key.path;return r.collectionGroup!==null?s.key.hasCollectionId(r.collectionGroup)&&r.path.isPrefixOf(i):M.isDocumentKey(r.path)?r.path.isEqual(i):r.path.isImmediateParentOf(i)})(n,e)&&(function(r,s){for(const i of wr(r))if(!i.field.isKeyField()&&s.data.field(i.field)===null)return!1;return!0})(n,e)&&(function(r,s){for(const i of r.filters)if(!i.matches(s))return!1;return!0})(n,e)&&(function(r,s){return!(r.startAt&&!(function(a,c,u){const h=Tu(a,c,u);return a.inclusive?h<=0:h<0})(r.startAt,wr(r),s)||r.endAt&&!(function(a,c,u){const h=Tu(a,c,u);return a.inclusive?h>=0:h>0})(r.endAt,wr(r),s))})(n,e)}function jE(n){return n.collectionGroup||(n.path.length%2==1?n.path.lastSegment():n.path.get(n.path.length-2))}function mf(n){return(e,t)=>{let r=!1;for(const s of wr(n)){const i=zE(s,e,t);if(i!==0)return i;r=r||s.field.isKeyField()}return 0}}function zE(n,e,t){const r=n.field.isKeyField()?M.comparator(e.key,t.key):(function(i,a,c){const u=a.data.field(i),h=c.data.field(i);return u!==null&&h!==null?xn(u,h):x(42886)})(n.field,e,t);switch(n.dir){case"asc":return r;case"desc":return-1*r;default:return x(19790,{direction:n.dir})}}class Tn{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){const t=this.mapKeyFn(e),r=this.inner[t];if(r!==void 0){for(const[s,i]of r)if(this.equalsFn(s,e))return i}}has(e){return this.get(e)!==void 0}set(e,t){const r=this.mapKeyFn(e),s=this.inner[r];if(s===void 0)return this.inner[r]=[[e,t]],void this.innerSize++;for(let i=0;i<s.length;i++)if(this.equalsFn(s[i][0],e))return void(s[i]=[e,t]);s.push([e,t]),this.innerSize++}delete(e){const t=this.mapKeyFn(e),r=this.inner[t];if(r===void 0)return!1;for(let s=0;s<r.length;s++)if(this.equalsFn(r[s][0],e))return r.length===1?delete this.inner[t]:r.splice(s,1),this.innerSize--,!0;return!1}forEach(e){Wt(this.inner,((t,r)=>{for(const[s,i]of r)e(s,i)}))}isEmpty(){return Yd(this.inner)}size(){return this.innerSize}}const HE=new re(M.comparator);function Et(){return HE}const gf=new re(M.comparator);function fr(...n){let e=gf;for(const t of n)e=e.insert(t.key,t);return e}function _f(n){let e=gf;return n.forEach(((t,r)=>e=e.insert(t,r.overlayedDocument))),e}function on(){return Er()}function yf(){return Er()}function Er(){return new Tn((n=>n.toString()),((n,e)=>n.isEqual(e)))}const GE=new re(M.comparator),KE=new de(M.comparator);function K(...n){let e=KE;for(const t of n)e=e.add(t);return e}const WE=new de(G);function QE(){return WE}function Ma(n,e){if(n.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:Ms(e)?"-0":e}}function Tf(n){return{integerValue:""+n}}function JE(n,e){return wE(e)?Tf(e):Ma(n,e)}class Ei{constructor(){this._=void 0}}function YE(n,e,t){return n instanceof qs?(function(s,i){const a={fields:{[ef]:{stringValue:Zd},[nf]:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}};return i&&Da(i)&&(i=_i(i)),i&&(a.fields[tf]=i),{mapValue:a}})(t,e):n instanceof Dr?Ef(n,e):n instanceof Vr?vf(n,e):(function(s,i){const a=wf(s,i),c=Iu(a)+Iu(s.Ae);return Uo(a)&&Uo(s.Ae)?Tf(c):Ma(s.serializer,c)})(n,e)}function XE(n,e,t){return n instanceof Dr?Ef(n,e):n instanceof Vr?vf(n,e):t}function wf(n,e){return n instanceof $s?(function(r){return Uo(r)||(function(i){return!!i&&"doubleValue"in i})(r)})(e)?e:{integerValue:0}:null}class qs extends Ei{}class Dr extends Ei{constructor(e){super(),this.elements=e}}function Ef(n,e){const t=If(e);for(const r of n.elements)t.some((s=>ct(s,r)))||t.push(r);return{arrayValue:{values:t}}}class Vr extends Ei{constructor(e){super(),this.elements=e}}function vf(n,e){let t=If(e);for(const r of n.elements)t=t.filter((s=>!ct(s,r)));return{arrayValue:{values:t}}}class $s extends Ei{constructor(e,t){super(),this.serializer=e,this.Ae=t}}function Iu(n){return ae(n.integerValue||n.doubleValue)}function If(n){return Va(n)&&n.arrayValue.values?n.arrayValue.values.slice():[]}function ZE(n,e){return n.field.isEqual(e.field)&&(function(r,s){return r instanceof Dr&&s instanceof Dr||r instanceof Vr&&s instanceof Vr?Mn(r.elements,s.elements,ct):r instanceof $s&&s instanceof $s?ct(r.Ae,s.Ae):r instanceof qs&&s instanceof qs})(n.transform,e.transform)}class ev{constructor(e,t){this.version=e,this.transformResults=t}}class Je{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new Je}static exists(e){return new Je(void 0,e)}static updateTime(e){return new Je(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function vs(n,e){return n.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(n.updateTime):n.exists===void 0||n.exists===e.isFoundDocument()}class vi{}function Af(n,e){if(!n.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return n.isNoDocument()?new xa(n.key,Je.none()):new qr(n.key,n.data,Je.none());{const t=n.data,r=Oe.empty();let s=new de(ye.comparator);for(let i of e.fields)if(!s.has(i)){let a=t.field(i);a===null&&i.length>1&&(i=i.popLast(),a=t.field(i)),a===null?r.delete(i):r.set(i,a),s=s.add(i)}return new Qt(n.key,r,new Ue(s.toArray()),Je.none())}}function tv(n,e,t){n instanceof qr?(function(s,i,a){const c=s.value.clone(),u=bu(s.fieldTransforms,i,a.transformResults);c.setAll(u),i.convertToFoundDocument(a.version,c).setHasCommittedMutations()})(n,e,t):n instanceof Qt?(function(s,i,a){if(!vs(s.precondition,i))return void i.convertToUnknownDocument(a.version);const c=bu(s.fieldTransforms,i,a.transformResults),u=i.data;u.setAll(bf(s)),u.setAll(c),i.convertToFoundDocument(a.version,u).setHasCommittedMutations()})(n,e,t):(function(s,i,a){i.convertToNoDocument(a.version).setHasCommittedMutations()})(0,e,t)}function vr(n,e,t,r){return n instanceof qr?(function(i,a,c,u){if(!vs(i.precondition,a))return c;const h=i.value.clone(),f=Su(i.fieldTransforms,u,a);return h.setAll(f),a.convertToFoundDocument(a.version,h).setHasLocalMutations(),null})(n,e,t,r):n instanceof Qt?(function(i,a,c,u){if(!vs(i.precondition,a))return c;const h=Su(i.fieldTransforms,u,a),f=a.data;return f.setAll(bf(i)),f.setAll(h),a.convertToFoundDocument(a.version,f).setHasLocalMutations(),c===null?null:c.unionWith(i.fieldMask.fields).unionWith(i.fieldTransforms.map((m=>m.field)))})(n,e,t,r):(function(i,a,c){return vs(i.precondition,a)?(a.convertToNoDocument(a.version).setHasLocalMutations(),null):c})(n,e,t)}function nv(n,e){let t=null;for(const r of n.fieldTransforms){const s=e.data.field(r.field),i=wf(r.transform,s||null);i!=null&&(t===null&&(t=Oe.empty()),t.set(r.field,i))}return t||null}function Au(n,e){return n.type===e.type&&!!n.key.isEqual(e.key)&&!!n.precondition.isEqual(e.precondition)&&!!(function(r,s){return r===void 0&&s===void 0||!(!r||!s)&&Mn(r,s,((i,a)=>ZE(i,a)))})(n.fieldTransforms,e.fieldTransforms)&&(n.type===0?n.value.isEqual(e.value):n.type!==1||n.data.isEqual(e.data)&&n.fieldMask.isEqual(e.fieldMask))}class qr extends vi{constructor(e,t,r,s=[]){super(),this.key=e,this.value=t,this.precondition=r,this.fieldTransforms=s,this.type=0}getFieldMask(){return null}}class Qt extends vi{constructor(e,t,r,s,i=[]){super(),this.key=e,this.data=t,this.fieldMask=r,this.precondition=s,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function bf(n){const e=new Map;return n.fieldMask.fields.forEach((t=>{if(!t.isEmpty()){const r=n.data.field(t);e.set(t,r)}})),e}function bu(n,e,t){const r=new Map;Y(n.length===t.length,32656,{Ve:t.length,de:n.length});for(let s=0;s<t.length;s++){const i=n[s],a=i.transform,c=e.data.field(i.field);r.set(i.field,XE(a,c,t[s]))}return r}function Su(n,e,t){const r=new Map;for(const s of n){const i=s.transform,a=t.data.field(s.field);r.set(s.field,YE(i,a,e))}return r}class xa extends vi{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class rv extends vi{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}class sv{constructor(e,t,r,s){this.batchId=e,this.localWriteTime=t,this.baseMutations=r,this.mutations=s}applyToRemoteDocument(e,t){const r=t.mutationResults;for(let s=0;s<this.mutations.length;s++){const i=this.mutations[s];i.key.isEqual(e.key)&&tv(i,e,r[s])}}applyToLocalView(e,t){for(const r of this.baseMutations)r.key.isEqual(e.key)&&(t=vr(r,e,t,this.localWriteTime));for(const r of this.mutations)r.key.isEqual(e.key)&&(t=vr(r,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const r=yf();return this.mutations.forEach((s=>{const i=e.get(s.key),a=i.overlayedDocument;let c=this.applyToLocalView(a,i.mutatedFields);c=t.has(s.key)?null:c;const u=Af(a,c);u!==null&&r.set(s.key,u),a.isValidDocument()||a.convertToNoDocument(B.min())})),r}keys(){return this.mutations.reduce(((e,t)=>e.add(t.key)),K())}isEqual(e){return this.batchId===e.batchId&&Mn(this.mutations,e.mutations,((t,r)=>Au(t,r)))&&Mn(this.baseMutations,e.baseMutations,((t,r)=>Au(t,r)))}}class Fa{constructor(e,t,r,s){this.batch=e,this.commitVersion=t,this.mutationResults=r,this.docVersions=s}static from(e,t,r){Y(e.mutations.length===r.length,58842,{me:e.mutations.length,fe:r.length});let s=(function(){return GE})();const i=e.mutations;for(let a=0;a<i.length;a++)s=s.insert(i[a].key,r[a].version);return new Fa(e,t,r,s)}}class iv{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{
|
|
19
|
+
`+R+" "+V})}function wr(a,u,d,m){a.info(function(){return"XMLHTTP TEXT ("+u+"): "+nE(a,d)+(m?" "+m:"")})}function tE(a,u){a.info(function(){return"TIMEOUT: "+u})}Ts.prototype.info=function(){};function nE(a,u){if(!a.g)return u;if(!u)return null;try{const R=JSON.parse(u);if(R){for(a=0;a<R.length;a++)if(Array.isArray(R[a])){var d=R[a];if(!(d.length<2)){var m=d[1];if(Array.isArray(m)&&!(m.length<1)){var S=m[0];if(S!="noop"&&S!="stop"&&S!="close")for(let V=1;V<m.length;V++)m[V]=""}}}}return Tr(R)}catch{return u}}var Pi={NO_ERROR:0,cb:1,qb:2,pb:3,kb:4,ob:5,rb:6,Ga:7,TIMEOUT:8,ub:9},oh={ib:"complete",Fb:"success",ERROR:"error",Ga:"abort",xb:"ready",yb:"readystatechange",TIMEOUT:"timeout",sb:"incrementaldata",wb:"progress",lb:"downloadprogress",Nb:"uploadprogress"},ah;function xa(){}g(xa,eh),xa.prototype.g=function(){return new XMLHttpRequest},ah=new xa;function ws(a){return encodeURIComponent(String(a))}function rE(a){var u=1;a=a.split(":");const d=[];for(;u>0&&a.length;)d.push(a.shift()),u--;return a.length&&d.push(a.join(":")),d}function on(a,u,d,m){this.j=a,this.i=u,this.l=d,this.S=m||1,this.V=new sn(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 ch}function ch(){this.i=null,this.g="",this.h=!1}var lh={},Fa={};function $a(a,u,d){a.M=1,a.A=Di(vt(u)),a.u=d,a.R=!0,uh(a,null)}function uh(a,u){a.F=Date.now(),Ni(a),a.B=vt(a.A);var d=a.B,m=a.S;Array.isArray(m)||(m=[String(m)]),bh(d.i,"t",m),a.C=0,d=a.j.L,a.h=new ch,a.g=Bh(a.j,d?u:null,!a.u),a.P>0&&(a.O=new ms(h(a.Y,a,a.g),a.P)),u=a.V,d=a.g,m=a.ba;var S="readystatechange";Array.isArray(S)||(S&&(gs[0]=S.toString()),S=gs);for(let R=0;R<S.length;R++){const V=_r(d,S[R],m||u.handleEvent,!1,u.h||u);if(!V)break;u.g[V.key]=V}u=a.J?gr(a.J):{},a.u?(a.v||(a.v="POST"),u["Content-Type"]="application/x-www-form-urlencoded",a.g.ea(a.B,a.v,a.u,u)):(a.v="GET",a.g.ea(a.B,a.v,null,u)),Es(),Zy(a.i,a.v,a.B,a.l,a.S,a.u)}on.prototype.ba=function(a){a=a.target;const u=this.O;u&&ln(a)==3?u.j():this.Y(a)},on.prototype.Y=function(a){try{if(a==this.g)e:{const Q=ln(this.g),ge=this.g.ya(),re=this.g.ca();if(!(Q<3)&&(Q!=3||this.g&&(this.h.h||this.g.la()||Ph(this.g)))){this.K||Q!=4||ge==7||(ge==8||re<=0?Es(3):Es(2)),Ua(this);var u=this.g.ca();this.X=u;var d=sE(this);if(this.o=u==200,eE(this.i,this.v,this.B,this.l,this.S,Q,u),this.o){if(this.U&&!this.L){t:{if(this.g){var m,S=this.g;if((m=S.g?S.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!E(m)){var R=m;break t}}R=null}if(a=R)wr(this.i,this.l,a,"Initial handshake response via X-HTTP-Initial-Response"),this.L=!0,Ba(this,a);else{this.o=!1,this.m=3,Oe(12),Un(this),bs(this);break e}}if(this.R){a=!0;let Ee;for(;!this.K&&this.C<d.length;)if(Ee=iE(this,d),Ee==Fa){Q==4&&(this.m=4,Oe(14),a=!1),wr(this.i,this.l,null,"[Incomplete Response]");break}else if(Ee==lh){this.m=4,Oe(15),wr(this.i,this.l,d,"[Invalid Chunk]"),a=!1;break}else wr(this.i,this.l,Ee,null),Ba(this,Ee);if(hh(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),Q!=4||d.length!=0||this.h.h||(this.m=1,Oe(16),a=!1),this.o=this.o&&a,!a)wr(this.i,this.l,d,"[Invalid Chunked Response]"),Un(this),bs(this);else if(d.length>0&&!this.W){this.W=!0;var V=this.j;V.g==this&&V.aa&&!V.P&&(V.j.info("Great, no buffering proxy detected. Bytes received: "+d.length),Ya(V),V.P=!0,Oe(11))}}else wr(this.i,this.l,d,null),Ba(this,d);Q==4&&Un(this),this.o&&!this.K&&(Q==4?xh(this.j,this):(this.o=!1,Ni(this)))}else EE(this.g),u==400&&d.indexOf("Unknown SID")>0?(this.m=3,Oe(12)):(this.m=0,Oe(13)),Un(this),bs(this)}}}catch{}};function sE(a){if(!hh(a))return a.g.la();const u=Ph(a.g);if(u==="")return"";let d="";const m=u.length,S=ln(a.g)==4;if(!a.h.i){if(typeof TextDecoder>"u")return Un(a),bs(a),"";a.h.i=new o.TextDecoder}for(let R=0;R<m;R++)a.h.h=!0,d+=a.h.i.decode(u[R],{stream:!(S&&R==m-1)});return u.length=0,a.h.g+=d,a.C=0,a.h.g}function hh(a){return a.g?a.v=="GET"&&a.M!=2&&a.j.Aa:!1}function iE(a,u){var d=a.C,m=u.indexOf(`
|
|
20
|
+
`,d);return m==-1?Fa:(d=Number(u.substring(d,m)),isNaN(d)?lh:(m+=1,m+d>u.length?Fa:(u=u.slice(m,m+d),a.C=m+d,u)))}on.prototype.cancel=function(){this.K=!0,Un(this)};function Ni(a){a.T=Date.now()+a.H,dh(a,a.H)}function dh(a,u){if(a.D!=null)throw Error("WatchDog timer not null");a.D=vs(h(a.aa,a),u)}function Ua(a){a.D&&(o.clearTimeout(a.D),a.D=null)}on.prototype.aa=function(){this.D=null;const a=Date.now();a-this.T>=0?(tE(this.i,this.B),this.M!=2&&(Es(),Oe(17)),Un(this),this.m=2,bs(this)):dh(this,this.T-a)};function bs(a){a.j.I==0||a.K||xh(a.j,a)}function Un(a){Ua(a);var u=a.O;u&&typeof u.dispose=="function"&&u.dispose(),a.O=null,_s(a.V),a.g&&(u=a.g,a.g=null,u.abort(),u.dispose())}function Ba(a,u){try{var d=a.j;if(d.I!=0&&(d.g==a||qa(d.h,a))){if(!a.L&&qa(d.h,a)&&d.I==3){try{var m=d.Ba.g.parse(u)}catch{m=null}if(Array.isArray(m)&&m.length==3){var S=m;if(S[0]==0){e:if(!d.v){if(d.g)if(d.g.F+3e3<a.F)xi(d),Li(d);else break e;Ga(d),Oe(18)}}else d.xa=S[1],0<d.xa-d.K&&S[2]<37500&&d.F&&d.A==0&&!d.C&&(d.C=vs(h(d.Va,d),6e3));mh(d.h)<=1&&d.ta&&(d.ta=void 0)}else qn(d,11)}else if((a.L||d.g==a)&&xi(d),!E(u))for(S=d.Ba.g.parse(u),u=0;u<S.length;u++){let re=S[u];const Ee=re[0];if(!(Ee<=d.K))if(d.K=Ee,re=re[1],d.I==2)if(re[0]=="c"){d.M=re[1],d.ba=re[2];const Tt=re[3];Tt!=null&&(d.ka=Tt,d.j.info("VER="+d.ka));const jn=re[4];jn!=null&&(d.za=jn,d.j.info("SVER="+d.za));const un=re[5];un!=null&&typeof un=="number"&&un>0&&(m=1.5*un,d.O=m,d.j.info("backChannelRequestTimeoutMs_="+m)),m=d;const hn=a.g;if(hn){const $i=hn.g?hn.g.getResponseHeader("X-Client-Wire-Protocol"):null;if($i){var R=m.h;R.g||$i.indexOf("spdy")==-1&&$i.indexOf("quic")==-1&&$i.indexOf("h2")==-1||(R.j=R.l,R.g=new Set,R.h&&(ja(R,R.h),R.h=null))}if(m.G){const Qa=hn.g?hn.g.getResponseHeader("X-HTTP-Session-Id"):null;Qa&&(m.wa=Qa,oe(m.J,m.G,Qa))}}d.I=3,d.l&&d.l.ra(),d.aa&&(d.T=Date.now()-a.F,d.j.info("Handshake RTT: "+d.T+"ms")),m=d;var V=a;if(m.na=Uh(m,m.L?m.ba:null,m.W),V.L){gh(m.h,V);var Q=V,ge=m.O;ge&&(Q.H=ge),Q.D&&(Ua(Q),Ni(Q)),m.g=V}else Lh(m);d.i.length>0&&Mi(d)}else re[0]!="stop"&&re[0]!="close"||qn(d,7);else d.I==3&&(re[0]=="stop"||re[0]=="close"?re[0]=="stop"?qn(d,7):Ka(d):re[0]!="noop"&&d.l&&d.l.qa(re),d.A=0)}}Es(4)}catch{}}var oE=class{constructor(a,u){this.g=a,this.map=u}};function fh(a){this.l=a||10,o.PerformanceNavigationTiming?(a=o.performance.getEntriesByType("navigation"),a=a.length>0&&(a[0].nextHopProtocol=="hq"||a[0].nextHopProtocol=="h2")):a=!!(o.chrome&&o.chrome.loadTimes&&o.chrome.loadTimes()&&o.chrome.loadTimes().wasFetchedViaSpdy),this.j=a?this.l:1,this.g=null,this.j>1&&(this.g=new Set),this.h=null,this.i=[]}function ph(a){return a.h?!0:a.g?a.g.size>=a.j:!1}function mh(a){return a.h?1:a.g?a.g.size:0}function qa(a,u){return a.h?a.h==u:a.g?a.g.has(u):!1}function ja(a,u){a.g?a.g.add(u):a.h=u}function gh(a,u){a.h&&a.h==u?a.h=null:a.g&&a.g.has(u)&&a.g.delete(u)}fh.prototype.cancel=function(){if(this.i=_h(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const a of this.g.values())a.cancel();this.g.clear()}};function _h(a){if(a.h!=null)return a.i.concat(a.h.G);if(a.g!=null&&a.g.size!==0){let u=a.i;for(const d of a.g.values())u=u.concat(d.G);return u}return T(a.i)}var yh=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function aE(a,u){if(a){a=a.split("&");for(let d=0;d<a.length;d++){const m=a[d].indexOf("=");let S,R=null;m>=0?(S=a[d].substring(0,m),R=a[d].substring(m+1)):S=a[d],u(S,R?decodeURIComponent(R.replace(/\+/g," ")):"")}}}function an(a){this.g=this.o=this.j="",this.u=null,this.m=this.h="",this.l=!1;let u;a instanceof an?(this.l=a.l,As(this,a.j),this.o=a.o,this.g=a.g,Is(this,a.u),this.h=a.h,Ha(this,Ah(a.i)),this.m=a.m):a&&(u=String(a).match(yh))?(this.l=!1,As(this,u[1]||"",!0),this.o=Ss(u[2]||""),this.g=Ss(u[3]||"",!0),Is(this,u[4]),this.h=Ss(u[5]||"",!0),Ha(this,u[6]||"",!0),this.m=Ss(u[7]||"")):(this.l=!1,this.i=new Rs(null,this.l))}an.prototype.toString=function(){const a=[];var u=this.j;u&&a.push(Cs(u,Eh,!0),":");var d=this.g;return(d||u=="file")&&(a.push("//"),(u=this.o)&&a.push(Cs(u,Eh,!0),"@"),a.push(ws(d).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),d=this.u,d!=null&&a.push(":",String(d))),(d=this.h)&&(this.g&&d.charAt(0)!="/"&&a.push("/"),a.push(Cs(d,d.charAt(0)=="/"?uE:lE,!0))),(d=this.i.toString())&&a.push("?",d),(d=this.m)&&a.push("#",Cs(d,dE)),a.join("")},an.prototype.resolve=function(a){const u=vt(this);let d=!!a.j;d?As(u,a.j):d=!!a.o,d?u.o=a.o:d=!!a.g,d?u.g=a.g:d=a.u!=null;var m=a.h;if(d)Is(u,a.u);else if(d=!!a.h){if(m.charAt(0)!="/")if(this.g&&!this.h)m="/"+m;else{var S=u.h.lastIndexOf("/");S!=-1&&(m=u.h.slice(0,S+1)+m)}if(S=m,S==".."||S==".")m="";else if(S.indexOf("./")!=-1||S.indexOf("/.")!=-1){m=S.lastIndexOf("/",0)==0,S=S.split("/");const R=[];for(let V=0;V<S.length;){const Q=S[V++];Q=="."?m&&V==S.length&&R.push(""):Q==".."?((R.length>1||R.length==1&&R[0]!="")&&R.pop(),m&&V==S.length&&R.push("")):(R.push(Q),m=!0)}m=R.join("/")}else m=S}return d?u.h=m:d=a.i.toString()!=="",d?Ha(u,Ah(a.i)):d=!!a.m,d&&(u.m=a.m),u};function vt(a){return new an(a)}function As(a,u,d){a.j=d?Ss(u,!0):u,a.j&&(a.j=a.j.replace(/:$/,""))}function Is(a,u){if(u){if(u=Number(u),isNaN(u)||u<0)throw Error("Bad port number "+u);a.u=u}else a.u=null}function Ha(a,u,d){u instanceof Rs?(a.i=u,fE(a.i,a.l)):(d||(u=Cs(u,hE)),a.i=new Rs(u,a.l))}function oe(a,u,d){a.i.set(u,d)}function Di(a){return oe(a,"zx",Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^Date.now()).toString(36)),a}function Ss(a,u){return a?u?decodeURI(a.replace(/%25/g,"%2525")):decodeURIComponent(a):""}function Cs(a,u,d){return typeof a=="string"?(a=encodeURI(a).replace(u,cE),d&&(a=a.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),a):null}function cE(a){return a=a.charCodeAt(0),"%"+(a>>4&15).toString(16)+(a&15).toString(16)}var Eh=/[#\/\?@]/g,lE=/[#\?:]/g,uE=/[#\?]/g,hE=/[#\?@]/g,dE=/#/g;function Rs(a,u){this.h=this.g=null,this.i=a||null,this.j=!!u}function Bn(a){a.g||(a.g=new Map,a.h=0,a.i&&aE(a.i,function(u,d){a.add(decodeURIComponent(u.replace(/\+/g," ")),d)}))}n=Rs.prototype,n.add=function(a,u){Bn(this),this.i=null,a=br(this,a);let d=this.g.get(a);return d||this.g.set(a,d=[]),d.push(u),this.h+=1,this};function vh(a,u){Bn(a),u=br(a,u),a.g.has(u)&&(a.i=null,a.h-=a.g.get(u).length,a.g.delete(u))}function Th(a,u){return Bn(a),u=br(a,u),a.g.has(u)}n.forEach=function(a,u){Bn(this),this.g.forEach(function(d,m){d.forEach(function(S){a.call(u,S,m,this)},this)},this)};function wh(a,u){Bn(a);let d=[];if(typeof u=="string")Th(a,u)&&(d=d.concat(a.g.get(br(a,u))));else for(a=Array.from(a.g.values()),u=0;u<a.length;u++)d=d.concat(a[u]);return d}n.set=function(a,u){return Bn(this),this.i=null,a=br(this,a),Th(this,a)&&(this.h-=this.g.get(a).length),this.g.set(a,[u]),this.h+=1,this},n.get=function(a,u){return a?(a=wh(this,a),a.length>0?String(a[0]):u):u};function bh(a,u,d){vh(a,u),d.length>0&&(a.i=null,a.g.set(br(a,u),T(d)),a.h+=d.length)}n.toString=function(){if(this.i)return this.i;if(!this.g)return"";const a=[],u=Array.from(this.g.keys());for(let m=0;m<u.length;m++){var d=u[m];const S=ws(d);d=wh(this,d);for(let R=0;R<d.length;R++){let V=S;d[R]!==""&&(V+="="+ws(d[R])),a.push(V)}}return this.i=a.join("&")};function Ah(a){const u=new Rs;return u.i=a.i,a.g&&(u.g=new Map(a.g),u.h=a.h),u}function br(a,u){return u=String(u),a.j&&(u=u.toLowerCase()),u}function fE(a,u){u&&!a.j&&(Bn(a),a.i=null,a.g.forEach(function(d,m){const S=m.toLowerCase();m!=S&&(vh(this,m),bh(this,S,d))},a)),a.j=u}function pE(a,u){const d=new Ts;if(o.Image){const m=new Image;m.onload=f(cn,d,"TestLoadImage: loaded",!0,u,m),m.onerror=f(cn,d,"TestLoadImage: error",!1,u,m),m.onabort=f(cn,d,"TestLoadImage: abort",!1,u,m),m.ontimeout=f(cn,d,"TestLoadImage: timeout",!1,u,m),o.setTimeout(function(){m.ontimeout&&m.ontimeout()},1e4),m.src=a}else u(!1)}function mE(a,u){const d=new Ts,m=new AbortController,S=setTimeout(()=>{m.abort(),cn(d,"TestPingServer: timeout",!1,u)},1e4);fetch(a,{signal:m.signal}).then(R=>{clearTimeout(S),R.ok?cn(d,"TestPingServer: ok",!0,u):cn(d,"TestPingServer: server error",!1,u)}).catch(()=>{clearTimeout(S),cn(d,"TestPingServer: error",!1,u)})}function cn(a,u,d,m,S){try{S&&(S.onload=null,S.onerror=null,S.onabort=null,S.ontimeout=null),m(d)}catch{}}function gE(){this.g=new Xy}function Wa(a){this.i=a.Sb||null,this.h=a.ab||!1}g(Wa,eh),Wa.prototype.g=function(){return new Oi(this.i,this.h)};function Oi(a,u){ye.call(this),this.H=a,this.o=u,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}g(Oi,ye),n=Oi.prototype,n.open=function(a,u){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.F=a,this.D=u,this.readyState=1,Ps(this)},n.send=function(a){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 u={headers:this.A,method:this.F,credentials:this.m,cache:void 0,signal:this.v.signal};a&&(u.body=a),(this.H||o).fetch(new Request(this.D,u)).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,ks(this)),this.readyState=0},n.Pa=function(a){if(this.g&&(this.l=a,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=a.headers,this.readyState=2,Ps(this)),this.g&&(this.readyState=3,Ps(this),this.g)))if(this.responseType==="arraybuffer")a.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(typeof o.ReadableStream<"u"&&"body"in a){if(this.j=a.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;Ih(this)}else a.text().then(this.Oa.bind(this),this.ga.bind(this))};function Ih(a){a.j.read().then(a.Ma.bind(a)).catch(a.ga.bind(a))}n.Ma=function(a){if(this.g){if(this.o&&a.value)this.response.push(a.value);else if(!this.o){var u=a.value?a.value:new Uint8Array(0);(u=this.B.decode(u,{stream:!a.done}))&&(this.response=this.responseText+=u)}a.done?ks(this):Ps(this),this.readyState==3&&Ih(this)}},n.Oa=function(a){this.g&&(this.response=this.responseText=a,ks(this))},n.Na=function(a){this.g&&(this.response=a,ks(this))},n.ga=function(){this.g&&ks(this)};function ks(a){a.readyState=4,a.l=null,a.j=null,a.B=null,Ps(a)}n.setRequestHeader=function(a,u){this.A.append(a,u)},n.getResponseHeader=function(a){return this.h&&this.h.get(a.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";const a=[],u=this.h.entries();for(var d=u.next();!d.done;)d=d.value,a.push(d[0]+": "+d[1]),d=u.next();return a.join(`\r
|
|
21
|
+
`)};function Ps(a){a.onreadystatechange&&a.onreadystatechange.call(a)}Object.defineProperty(Oi.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(a){this.m=a?"include":"same-origin"}});function Sh(a){let u="";return tt(a,function(d,m){u+=m,u+=":",u+=d,u+=`\r
|
|
22
|
+
`}),u}function za(a,u,d){e:{for(m in d){var m=!1;break e}m=!0}m||(d=Sh(d),typeof a=="string"?d!=null&&ws(d):oe(a,u,d))}function ue(a){ye.call(this),this.headers=new Map,this.L=a||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}g(ue,ye);var _E=/^https?$/i,yE=["POST","PUT"];n=ue.prototype,n.Fa=function(a){this.H=a},n.ea=function(a,u,d,m){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+a);u=u?u.toUpperCase():"GET",this.D=a,this.l="",this.o=0,this.A=!1,this.h=!0,this.g=this.L?this.L.g():ah.g(),this.g.onreadystatechange=_(h(this.Ca,this));try{this.B=!0,this.g.open(u,String(a),!0),this.B=!1}catch(R){Ch(this,R);return}if(a=d||"",d=new Map(this.headers),m)if(Object.getPrototypeOf(m)===Object.prototype)for(var S in m)d.set(S,m[S]);else if(typeof m.keys=="function"&&typeof m.get=="function")for(const R of m.keys())d.set(R,m.get(R));else throw Error("Unknown input type for opt_headers: "+String(m));m=Array.from(d.keys()).find(R=>R.toLowerCase()=="content-type"),S=o.FormData&&a instanceof o.FormData,!(Array.prototype.indexOf.call(yE,u,void 0)>=0)||m||S||d.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[R,V]of d)this.g.setRequestHeader(R,V);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(a),this.v=!1}catch(R){Ch(this,R)}};function Ch(a,u){a.h=!1,a.g&&(a.j=!0,a.g.abort(),a.j=!1),a.l=u,a.o=5,Rh(a),Vi(a)}function Rh(a){a.A||(a.A=!0,ae(a,"complete"),ae(a,"error"))}n.abort=function(a){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.o=a||7,ae(this,"complete"),ae(this,"abort"),Vi(this))},n.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Vi(this,!0)),ue.Z.N.call(this)},n.Ca=function(){this.u||(this.B||this.v||this.j?kh(this):this.Xa())},n.Xa=function(){kh(this)};function kh(a){if(a.h&&typeof i<"u"){if(a.v&&ln(a)==4)setTimeout(a.Ca.bind(a),0);else if(ae(a,"readystatechange"),ln(a)==4){a.h=!1;try{const R=a.ca();e:switch(R){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var u=!0;break e;default:u=!1}var d;if(!(d=u)){var m;if(m=R===0){let V=String(a.D).match(yh)[1]||null;!V&&o.self&&o.self.location&&(V=o.self.location.protocol.slice(0,-1)),m=!_E.test(V?V.toLowerCase():"")}d=m}if(d)ae(a,"complete"),ae(a,"success");else{a.o=6;try{var S=ln(a)>2?a.g.statusText:""}catch{S=""}a.l=S+" ["+a.ca()+"]",Rh(a)}}finally{Vi(a)}}}}function Vi(a,u){if(a.g){a.m&&(clearTimeout(a.m),a.m=null);const d=a.g;a.g=null,u||ae(a,"ready");try{d.onreadystatechange=null}catch{}}}n.isActive=function(){return!!this.g};function ln(a){return a.g?a.g.readyState:0}n.ca=function(){try{return ln(this)>2?this.g.status:-1}catch{return-1}},n.la=function(){try{return this.g?this.g.responseText:""}catch{return""}},n.La=function(a){if(this.g){var u=this.g.responseText;return a&&u.indexOf(a)==0&&(u=u.substring(a.length)),Jy(u)}};function Ph(a){try{if(!a.g)return null;if("response"in a.g)return a.g.response;switch(a.F){case"":case"text":return a.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in a.g)return a.g.mozResponseArrayBuffer}return null}catch{return null}}function EE(a){const u={};a=(a.g&&ln(a)>=2&&a.g.getAllResponseHeaders()||"").split(`\r
|
|
23
|
+
`);for(let m=0;m<a.length;m++){if(E(a[m]))continue;var d=rE(a[m]);const S=d[0];if(d=d[1],typeof d!="string")continue;d=d.trim();const R=u[S]||[];u[S]=R,R.push(d)}mr(u,function(m){return m.join(", ")})}n.ya=function(){return this.o},n.Ha=function(){return typeof this.l=="string"?this.l:String(this.l)};function Ns(a,u,d){return d&&d.internalChannelParams&&d.internalChannelParams[a]||u}function Nh(a){this.za=0,this.i=[],this.j=new Ts,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=Ns("failFast",!1,a),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=Ns("baseRetryDelayMs",5e3,a),this.Za=Ns("retryDelaySeedMs",1e4,a),this.Ta=Ns("forwardChannelMaxRetries",2,a),this.va=Ns("forwardChannelRequestTimeoutMs",2e4,a),this.ma=a&&a.xmlHttpFactory||void 0,this.Ua=a&&a.Rb||void 0,this.Aa=a&&a.useFetchStreams||!1,this.O=void 0,this.L=a&&a.supportsCrossDomainXhr||!1,this.M="",this.h=new fh(a&&a.concurrentRequestLimit),this.Ba=new gE,this.S=a&&a.fastHandshake||!1,this.R=a&&a.encodeInitMessageHeaders||!1,this.S&&this.R&&(this.R=!1),this.Ra=a&&a.Pb||!1,a&&a.ua&&this.j.ua(),a&&a.forceLongPolling&&(this.X=!1),this.aa=!this.S&&this.X&&a&&a.detectBufferingProxy||!1,this.ia=void 0,a&&a.longPollingTimeout&&a.longPollingTimeout>0&&(this.ia=a.longPollingTimeout),this.ta=void 0,this.T=0,this.P=!1,this.ja=this.B=null}n=Nh.prototype,n.ka=8,n.I=1,n.connect=function(a,u,d,m){Oe(0),this.W=a,this.H=u||{},d&&m!==void 0&&(this.H.OSID=d,this.H.OAID=m),this.F=this.X,this.J=Uh(this,null,this.W),Mi(this)};function Ka(a){if(Dh(a),a.I==3){var u=a.V++,d=vt(a.J);if(oe(d,"SID",a.M),oe(d,"RID",u),oe(d,"TYPE","terminate"),Ds(a,d),u=new on(a,a.j,u),u.M=2,u.A=Di(vt(d)),d=!1,o.navigator&&o.navigator.sendBeacon)try{d=o.navigator.sendBeacon(u.A.toString(),"")}catch{}!d&&o.Image&&(new Image().src=u.A,d=!0),d||(u.g=Bh(u.j,null),u.g.ea(u.A)),u.F=Date.now(),Ni(u)}$h(a)}function Li(a){a.g&&(Ya(a),a.g.cancel(),a.g=null)}function Dh(a){Li(a),a.v&&(o.clearTimeout(a.v),a.v=null),xi(a),a.h.cancel(),a.m&&(typeof a.m=="number"&&o.clearTimeout(a.m),a.m=null)}function Mi(a){if(!ph(a.h)&&!a.m){a.m=!0;var u=a.Ea;j||y(),H||(j(),H=!0),w.add(u,a),a.D=0}}function vE(a,u){return mh(a.h)>=a.h.j-(a.m?1:0)?!1:a.m?(a.i=u.G.concat(a.i),!0):a.I==1||a.I==2||a.D>=(a.Sa?0:a.Ta)?!1:(a.m=vs(h(a.Ea,a,u),Fh(a,a.D)),a.D++,!0)}n.Ea=function(a){if(this.m)if(this.m=null,this.I==1){if(!a){this.V=Math.floor(Math.random()*1e5),a=this.V++;const S=new on(this,this.j,a);let R=this.o;if(this.U&&(R?(R=gr(R),Fn(R,this.U)):R=this.U),this.u!==null||this.R||(S.J=R,R=null),this.S)e:{for(var u=0,d=0;d<this.i.length;d++){t:{var m=this.i[d];if("__data__"in m.map&&(m=m.map.__data__,typeof m=="string")){m=m.length;break t}m=void 0}if(m===void 0)break;if(u+=m,u>4096){u=d;break e}if(u===4096||d===this.i.length-1){u=d+1;break e}}u=1e3}else u=1e3;u=Vh(this,S,u),d=vt(this.J),oe(d,"RID",a),oe(d,"CVER",22),this.G&&oe(d,"X-HTTP-Session-Id",this.G),Ds(this,d),R&&(this.R?u="headers="+ws(Sh(R))+"&"+u:this.u&&za(d,this.u,R)),ja(this.h,S),this.Ra&&oe(d,"TYPE","init"),this.S?(oe(d,"$req",u),oe(d,"SID","null"),S.U=!0,$a(S,d,null)):$a(S,d,u),this.I=2}}else this.I==3&&(a?Oh(this,a):this.i.length==0||ph(this.h)||Oh(this))};function Oh(a,u){var d;u?d=u.l:d=a.V++;const m=vt(a.J);oe(m,"SID",a.M),oe(m,"RID",d),oe(m,"AID",a.K),Ds(a,m),a.u&&a.o&&za(m,a.u,a.o),d=new on(a,a.j,d,a.D+1),a.u===null&&(d.J=a.o),u&&(a.i=u.G.concat(a.i)),u=Vh(a,d,1e3),d.H=Math.round(a.va*.5)+Math.round(a.va*.5*Math.random()),ja(a.h,d),$a(d,m,u)}function Ds(a,u){a.H&&tt(a.H,function(d,m){oe(u,m,d)}),a.l&&tt({},function(d,m){oe(u,m,d)})}function Vh(a,u,d){d=Math.min(a.i.length,d);const m=a.l?h(a.l.Ka,a.l,a):null;e:{var S=a.i;let Q=-1;for(;;){const ge=["count="+d];Q==-1?d>0?(Q=S[0].g,ge.push("ofs="+Q)):Q=0:ge.push("ofs="+Q);let re=!0;for(let Ee=0;Ee<d;Ee++){var R=S[Ee].g;const Tt=S[Ee].map;if(R-=Q,R<0)Q=Math.max(0,S[Ee].g-100),re=!1;else try{R="req"+R+"_"||"";try{var V=Tt instanceof Map?Tt:Object.entries(Tt);for(const[jn,un]of V){let hn=un;c(un)&&(hn=Tr(un)),ge.push(R+jn+"="+encodeURIComponent(hn))}}catch(jn){throw ge.push(R+"type="+encodeURIComponent("_badmap")),jn}}catch{m&&m(Tt)}}if(re){V=ge.join("&");break e}}V=void 0}return a=a.i.splice(0,d),u.G=a,V}function Lh(a){if(!a.g&&!a.v){a.Y=1;var u=a.Da;j||y(),H||(j(),H=!0),w.add(u,a),a.A=0}}function Ga(a){return a.g||a.v||a.A>=3?!1:(a.Y++,a.v=vs(h(a.Da,a),Fh(a,a.A)),a.A++,!0)}n.Da=function(){if(this.v=null,Mh(this),this.aa&&!(this.P||this.g==null||this.T<=0)){var a=4*this.T;this.j.info("BP detection timer enabled: "+a),this.B=vs(h(this.Wa,this),a)}},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,Oe(10),Li(this),Mh(this))};function Ya(a){a.B!=null&&(o.clearTimeout(a.B),a.B=null)}function Mh(a){a.g=new on(a,a.j,"rpc",a.Y),a.u===null&&(a.g.J=a.o),a.g.P=0;var u=vt(a.na);oe(u,"RID","rpc"),oe(u,"SID",a.M),oe(u,"AID",a.K),oe(u,"CI",a.F?"0":"1"),!a.F&&a.ia&&oe(u,"TO",a.ia),oe(u,"TYPE","xmlhttp"),Ds(a,u),a.u&&a.o&&za(u,a.u,a.o),a.O&&(a.g.H=a.O);var d=a.g;a=a.ba,d.M=1,d.A=Di(vt(u)),d.u=null,d.R=!0,uh(d,a)}n.Va=function(){this.C!=null&&(this.C=null,Li(this),Ga(this),Oe(19))};function xi(a){a.C!=null&&(o.clearTimeout(a.C),a.C=null)}function xh(a,u){var d=null;if(a.g==u){xi(a),Ya(a),a.g=null;var m=2}else if(qa(a.h,u))d=u.G,gh(a.h,u),m=1;else return;if(a.I!=0){if(u.o)if(m==1){d=u.u?u.u.length:0,u=Date.now()-u.F;var S=a.D;m=ki(),ae(m,new ih(m,d)),Mi(a)}else Lh(a);else if(S=u.m,S==3||S==0&&u.X>0||!(m==1&&vE(a,u)||m==2&&Ga(a)))switch(d&&d.length>0&&(u=a.h,u.i=u.i.concat(d)),S){case 1:qn(a,5);break;case 4:qn(a,10);break;case 3:qn(a,6);break;default:qn(a,2)}}}function Fh(a,u){let d=a.Qa+Math.floor(Math.random()*a.Za);return a.isActive()||(d*=2),d*u}function qn(a,u){if(a.j.info("Error code "+u),u==2){var d=h(a.bb,a),m=a.Ua;const S=!m;m=new an(m||"//www.google.com/images/cleardot.gif"),o.location&&o.location.protocol=="http"||As(m,"https"),Di(m),S?pE(m.toString(),d):mE(m.toString(),d)}else Oe(2);a.I=0,a.l&&a.l.pa(u),$h(a),Dh(a)}n.bb=function(a){a?(this.j.info("Successfully pinged google.com"),Oe(2)):(this.j.info("Failed to ping google.com"),Oe(1))};function $h(a){if(a.I=0,a.ja=[],a.l){const u=_h(a.h);(u.length!=0||a.i.length!=0)&&(C(a.ja,u),C(a.ja,a.i),a.h.i.length=0,T(a.i),a.i.length=0),a.l.oa()}}function Uh(a,u,d){var m=d instanceof an?vt(d):new an(d);if(m.g!="")u&&(m.g=u+"."+m.g),Is(m,m.u);else{var S=o.location;m=S.protocol,u=u?u+"."+S.hostname:S.hostname,S=+S.port;const R=new an(null);m&&As(R,m),u&&(R.g=u),S&&Is(R,S),d&&(R.h=d),m=R}return d=a.G,u=a.wa,d&&u&&oe(m,d,u),oe(m,"VER",a.ka),Ds(a,m),m}function Bh(a,u,d){if(u&&!a.L)throw Error("Can't create secondary domain capable XhrIo object.");return u=a.Aa&&!a.ma?new ue(new Wa({ab:d})):new ue(a.ma),u.Fa(a.L),u}n.isActive=function(){return!!this.l&&this.l.isActive(this)};function qh(){}n=qh.prototype,n.ra=function(){},n.qa=function(){},n.pa=function(){},n.oa=function(){},n.isActive=function(){return!0},n.Ka=function(){};function Fi(){}Fi.prototype.g=function(a,u){return new We(a,u)};function We(a,u){ye.call(this),this.g=new Nh(u),this.l=a,this.h=u&&u.messageUrlParams||null,a=u&&u.messageHeaders||null,u&&u.clientProtocolHeaderRequired&&(a?a["X-Client-Protocol"]="webchannel":a={"X-Client-Protocol":"webchannel"}),this.g.o=a,a=u&&u.initMessageHeaders||null,u&&u.messageContentType&&(a?a["X-WebChannel-Content-Type"]=u.messageContentType:a={"X-WebChannel-Content-Type":u.messageContentType}),u&&u.sa&&(a?a["X-WebChannel-Client-Profile"]=u.sa:a={"X-WebChannel-Client-Profile":u.sa}),this.g.U=a,(a=u&&u.Qb)&&!E(a)&&(this.g.u=a),this.A=u&&u.supportsCrossDomainXhr||!1,this.v=u&&u.sendRawJson||!1,(u=u&&u.httpSessionIdParam)&&!E(u)&&(this.g.G=u,a=this.h,a!==null&&u in a&&(a=this.h,u in a&&delete a[u])),this.j=new Ar(this)}g(We,ye),We.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},We.prototype.close=function(){Ka(this.g)},We.prototype.o=function(a){var u=this.g;if(typeof a=="string"){var d={};d.__data__=a,a=d}else this.v&&(d={},d.__data__=Tr(a),a=d);u.i.push(new oE(u.Ya++,a)),u.I==3&&Mi(u)},We.prototype.N=function(){this.g.l=null,delete this.j,Ka(this.g),delete this.g,We.Z.N.call(this)};function jh(a){La.call(this),a.__headers__&&(this.headers=a.__headers__,this.statusCode=a.__status__,delete a.__headers__,delete a.__status__);var u=a.__sm__;if(u){e:{for(const d in u){a=d;break e}a=void 0}(this.i=a)&&(a=this.i,u=u!==null&&a in u?u[a]:void 0),this.data=u}else this.data=a}g(jh,La);function Hh(){Ma.call(this),this.status=1}g(Hh,Ma);function Ar(a){this.g=a}g(Ar,qh),Ar.prototype.ra=function(){ae(this.g,"a")},Ar.prototype.qa=function(a){ae(this.g,new jh(a))},Ar.prototype.pa=function(a){ae(this.g,new Hh)},Ar.prototype.oa=function(){ae(this.g,"b")},Fi.prototype.createWebChannel=Fi.prototype.g,We.prototype.send=We.prototype.o,We.prototype.open=We.prototype.m,We.prototype.close=We.prototype.close,i_=function(){return new Fi},s_=function(){return ki()},r_=$n,Zc={jb:0,mb:1,nb:2,Hb:3,Mb:4,Jb:5,Kb:6,Ib:7,Gb:8,Lb:9,PROXY:10,NOPROXY:11,Eb:12,Ab:13,Bb:14,zb:15,Cb:16,Db:17,fb:18,eb:19,gb:20},Pi.NO_ERROR=0,Pi.TIMEOUT=8,Pi.HTTP_ERROR=6,ao=Pi,oh.COMPLETE="complete",n_=oh,th.EventType=ys,ys.OPEN="a",ys.CLOSE="b",ys.ERROR="c",ys.MESSAGE="d",ye.prototype.listen=ye.prototype.J,Ms=th,ue.prototype.listenOnce=ue.prototype.K,ue.prototype.getLastError=ue.prototype.Ha,ue.prototype.getLastErrorCode=ue.prototype.ya,ue.prototype.getStatus=ue.prototype.ca,ue.prototype.getResponseJson=ue.prototype.La,ue.prototype.getResponseText=ue.prototype.la,ue.prototype.send=ue.prototype.ea,ue.prototype.setWithCredentials=ue.prototype.Fa,t_=ue}).apply(typeof Gi<"u"?Gi:typeof self<"u"?self:typeof window<"u"?window:{});let Ce=class{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}};Ce.UNAUTHENTICATED=new Ce(null),Ce.GOOGLE_CREDENTIALS=new Ce("google-credentials-uid"),Ce.FIRST_PARTY=new Ce("first-party-uid"),Ce.MOCK_USER=new Ce("mock-user");let cs="12.8.0";function Uk(n){cs=n}const or=new ca("@firebase/firestore");function Pr(){return or.logLevel}function x(n,...e){if(or.logLevel<=X.DEBUG){const t=e.map(au);or.debug(`Firestore (${cs}): ${n}`,...t)}}function Jt(n,...e){if(or.logLevel<=X.ERROR){const t=e.map(au);or.error(`Firestore (${cs}): ${n}`,...t)}}function Yr(n,...e){if(or.logLevel<=X.WARN){const t=e.map(au);or.warn(`Firestore (${cs}): ${n}`,...t)}}function au(n){if(typeof n=="string")return n;try{return(function(t){return JSON.stringify(t)})(n)}catch{return n}}function W(n,e,t){let r="Unexpected state";typeof e=="string"?r=e:t=e,o_(n,r,t)}function o_(n,e,t){let r=`FIRESTORE (${cs}) INTERNAL ASSERTION FAILED: ${e} (ID: ${n.toString(16)})`;if(t!==void 0)try{r+=" CONTEXT: "+JSON.stringify(t)}catch{r+=" CONTEXT: "+t}throw Jt(r),new Error(r)}function ne(n,e,t,r){let s="Unexpected state";typeof t=="string"?s=t:r=t,n||o_(e,s,r)}function Y(n,e){return n}const N={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class M extends et{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class zt{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class a_{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class Bk{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(Ce.UNAUTHENTICATED)))}shutdown(){}}class qk{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable((()=>t(this.token.user)))}shutdown(){this.changeListener=null}}class jk{constructor(e){this.t=e,this.currentUser=Ce.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){ne(this.o===void 0,42304);let r=this.i;const s=l=>this.i!==r?(r=this.i,t(l)):Promise.resolve();let i=new zt;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new zt,e.enqueueRetryable((()=>s(this.currentUser)))};const o=()=>{const l=i;e.enqueueRetryable((async()=>{await l.promise,await s(this.currentUser)}))},c=l=>{x("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=l,this.o&&(this.auth.addAuthTokenListener(this.o),o())};this.t.onInit((l=>c(l))),setTimeout((()=>{if(!this.auth){const l=this.t.getImmediate({optional:!0});l?c(l):(x("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new zt)}}),0),o()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then((r=>this.i!==e?(x("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):r?(ne(typeof r.accessToken=="string",31837,{l:r}),new a_(r.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 ne(e===null||typeof e=="string",2055,{h:e}),new Ce(e)}}class Hk{constructor(e,t,r){this.P=e,this.T=t,this.I=r,this.type="FirstParty",this.user=Ce.FIRST_PARTY,this.R=new Map}A(){return this.I?this.I():null}get headers(){this.R.set("X-Goog-AuthUser",this.P);const e=this.A();return e&&this.R.set("Authorization",e),this.T&&this.R.set("X-Goog-Iam-Authorization-Token",this.T),this.R}}class Wk{constructor(e,t,r){this.P=e,this.T=t,this.I=r}getToken(){return Promise.resolve(new Hk(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable((()=>t(Ce.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class df{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 zk{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,Ke(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){ne(this.o===void 0,3512);const r=i=>{i.error!=null&&x("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${i.error.message}`);const o=i.token!==this.m;return this.m=i.token,x("FirebaseAppCheckTokenProvider",`Received ${o?"new":"existing"} token.`),o?t(i.token):Promise.resolve()};this.o=i=>{e.enqueueRetryable((()=>r(i)))};const s=i=>{x("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=i,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit((i=>s(i))),setTimeout((()=>{if(!this.appCheck){const i=this.V.getImmediate({optional:!0});i?s(i):x("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){if(this.p)return Promise.resolve(new df(this.p));const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((t=>t?(ne(typeof t.token=="string",44558,{tokenResult:t}),this.m=t.token,new df(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 Kk(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 r=0;r<n;r++)t[r]=Math.floor(256*Math.random());return t}class cu{static newId(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=62*Math.floor(4.129032258064516);let r="";for(;r.length<20;){const s=Kk(40);for(let i=0;i<s.length;++i)r.length<20&&s[i]<t&&(r+=e.charAt(s[i]%62))}return r}}function Z(n,e){return n<e?-1:n>e?1:0}function el(n,e){const t=Math.min(n.length,e.length);for(let r=0;r<t;r++){const s=n.charAt(r),i=e.charAt(r);if(s!==i)return Ac(s)===Ac(i)?Z(s,i):Ac(s)?1:-1}return Z(n.length,e.length)}const Gk=55296,Yk=57343;function Ac(n){const e=n.charCodeAt(0);return e>=Gk&&e<=Yk}function Qr(n,e,t){return n.length===e.length&&n.every(((r,s)=>t(r,e[s])))}const tl="__name__";class wt{constructor(e,t,r){t===void 0?t=0:t>e.length&&W(637,{offset:t,range:e.length}),r===void 0?r=e.length-t:r>e.length-t&&W(1746,{length:r,range:e.length-t}),this.segments=e,this.offset=t,this.len=r}get length(){return this.len}isEqual(e){return wt.comparator(this,e)===0}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof wt?e.forEach((r=>{t.push(r)})):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,r=this.limit();t<r;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const r=Math.min(e.length,t.length);for(let s=0;s<r;s++){const i=wt.compareSegments(e.get(s),t.get(s));if(i!==0)return i}return Z(e.length,t.length)}static compareSegments(e,t){const r=wt.isNumericId(e),s=wt.isNumericId(t);return r&&!s?-1:!r&&s?1:r&&s?wt.extractNumericId(e).compare(wt.extractNumericId(t)):el(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return vn.fromString(e.substring(4,e.length-2))}}class se extends wt{construct(e,t,r){return new se(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const r of e){if(r.indexOf("//")>=0)throw new M(N.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);t.push(...r.split("/").filter((s=>s.length>0)))}return new se(t)}static emptyPath(){return new se([])}}const Qk=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class Ae extends wt{construct(e,t,r){return new Ae(e,t,r)}static isValidIdentifier(e){return Qk.test(e)}canonicalString(){return this.toArray().map((e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),Ae.isValidIdentifier(e)||(e="`"+e+"`"),e))).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===tl}static keyField(){return new Ae([tl])}static fromServerFormat(e){const t=[];let r="",s=0;const i=()=>{if(r.length===0)throw new M(N.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(r),r=""};let o=!1;for(;s<e.length;){const c=e[s];if(c==="\\"){if(s+1===e.length)throw new M(N.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const l=e[s+1];if(l!=="\\"&&l!=="."&&l!=="`")throw new M(N.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=l,s+=2}else c==="`"?(o=!o,s++):c!=="."||o?(r+=c,s++):(i(),s++)}if(i(),o)throw new M(N.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new Ae(t)}static emptyPath(){return new Ae([])}}class B{constructor(e){this.path=e}static fromPath(e){return new B(se.fromString(e))}static fromName(e){return new B(se.fromString(e).popFirst(5))}static empty(){return new B(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 B(new se(e.slice()))}}function c_(n,e,t){if(!t)throw new M(N.INVALID_ARGUMENT,`Function ${n}() cannot be called with an empty ${e}.`)}function Jk(n,e,t,r){if(e===!0&&r===!0)throw new M(N.INVALID_ARGUMENT,`${n} and ${t} cannot be used together.`)}function ff(n){if(!B.isDocumentKey(n))throw new M(N.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${n} has ${n.length}.`)}function pf(n){if(B.isDocumentKey(n))throw new M(N.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${n} has ${n.length}.`)}function l_(n){return typeof n=="object"&&n!==null&&(Object.getPrototypeOf(n)===Object.prototype||Object.getPrototypeOf(n)===null)}function ma(n){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n.length>20&&(n=`${n.substring(0,20)}...`),JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return""+n;if(typeof n=="object"){if(n instanceof Array)return"an array";{const e=(function(r){return r.constructor?r.constructor.name:null})(n);return e?`a custom ${e} object`:"an object"}}return typeof n=="function"?"a function":W(12329,{type:typeof n})}function Qe(n,e){if("_delegate"in n&&(n=n._delegate),!(n instanceof e)){if(e.name===n.constructor.name)throw new M(N.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const t=ma(n);throw new M(N.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return n}function Xk(n,e){if(e<=0)throw new M(N.INVALID_ARGUMENT,`Function ${n}() requires a positive number, but it was: ${e}.`)}function me(n,e){const t={typeString:n};return e&&(t.value=e),t}function yi(n,e){if(!l_(n))throw new M(N.INVALID_ARGUMENT,"JSON must be an object");let t;for(const r in e)if(e[r]){const s=e[r].typeString,i="value"in e[r]?{value:e[r].value}:void 0;if(!(r in n)){t=`JSON missing required field: '${r}'`;break}const o=n[r];if(s&&typeof o!==s){t=`JSON field '${r}' must be a ${s}.`;break}if(i!==void 0&&o!==i.value){t=`Expected '${r}' field to equal '${i.value}'`;break}}if(t)throw new M(N.INVALID_ARGUMENT,t);return!0}const mf=-62135596800,gf=1e6;class J{static now(){return J.fromMillis(Date.now())}static fromDate(e){return J.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),r=Math.floor((e-1e3*t)*gf);return new J(t,r)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new M(N.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new M(N.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<mf)throw new M(N.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new M(N.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/gf}_compareTo(e){return this.seconds===e.seconds?Z(this.nanoseconds,e.nanoseconds):Z(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:J._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(yi(e,J._jsonSchema))return new J(e.seconds,e.nanoseconds)}valueOf(){const e=this.seconds-mf;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}J._jsonSchemaVersion="firestore/timestamp/1.0",J._jsonSchema={type:me("string",J._jsonSchemaVersion),seconds:me("number"),nanoseconds:me("number")};class G{static fromTimestamp(e){return new G(e)}static min(){return new G(new J(0,0))}static max(){return new G(new J(253402300799,999999999))}constructor(e){this.timestamp=e}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}const Zs=-1;function Zk(n,e){const t=n.toTimestamp().seconds,r=n.toTimestamp().nanoseconds+1,s=G.fromTimestamp(r===1e9?new J(t+1,0):new J(t,r));return new In(s,B.empty(),e)}function eP(n){return new In(n.readTime,n.key,Zs)}class In{constructor(e,t,r){this.readTime=e,this.documentKey=t,this.largestBatchId=r}static min(){return new In(G.min(),B.empty(),Zs)}static max(){return new In(G.max(),B.empty(),Zs)}}function tP(n,e){let t=n.readTime.compareTo(e.readTime);return t!==0?t:(t=B.comparator(n.documentKey,e.documentKey),t!==0?t:Z(n.largestBatchId,e.largestBatchId))}const nP="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class rP{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((e=>e()))}}async function ls(n){if(n.code!==N.FAILED_PRECONDITION||n.message!==nP)throw n;x("LocalStore","Unexpectedly lost primary lease")}class D{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e((t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)}),(t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)}))}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&W(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new D(((r,s)=>{this.nextCallback=i=>{this.wrapSuccess(e,i).next(r,s)},this.catchCallback=i=>{this.wrapFailure(t,i).next(r,s)}}))}toPromise(){return new Promise(((e,t)=>{this.next(e,t)}))}wrapUserFunction(e){try{const t=e();return t instanceof D?t:D.resolve(t)}catch(t){return D.reject(t)}}wrapSuccess(e,t){return e?this.wrapUserFunction((()=>e(t))):D.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction((()=>e(t))):D.reject(t)}static resolve(e){return new D(((t,r)=>{t(e)}))}static reject(e){return new D(((t,r)=>{r(e)}))}static waitFor(e){return new D(((t,r)=>{let s=0,i=0,o=!1;e.forEach((c=>{++s,c.next((()=>{++i,o&&i===s&&t()}),(l=>r(l)))})),o=!0,i===s&&t()}))}static or(e){let t=D.resolve(!1);for(const r of e)t=t.next((s=>s?D.resolve(s):r()));return t}static forEach(e,t){const r=[];return e.forEach(((s,i)=>{r.push(t.call(this,s,i))})),this.waitFor(r)}static mapArray(e,t){return new D(((r,s)=>{const i=e.length,o=new Array(i);let c=0;for(let l=0;l<i;l++){const h=l;t(e[h]).next((f=>{o[h]=f,++c,c===i&&r(o)}),(f=>s(f)))}}))}static doWhile(e,t){return new D(((r,s)=>{const i=()=>{e()===!0?t().next((()=>{i()}),s):r()};i()}))}}function sP(n){const e=n.match(/Android ([\d.]+)/i),t=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(t)}function us(n){return n.name==="IndexedDbTransactionError"}class ga{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=r=>this.ae(r),this.ue=r=>t.writeSequenceNumber(r))}ae(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.ue&&this.ue(e),e}}ga.ce=-1;const lu=-1;function _a(n){return n==null}function Po(n){return n===0&&1/n==-1/0}function iP(n){return typeof n=="number"&&Number.isInteger(n)&&!Po(n)&&n<=Number.MAX_SAFE_INTEGER&&n>=Number.MIN_SAFE_INTEGER}const u_="";function oP(n){let e="";for(let t=0;t<n.length;t++)e.length>0&&(e=_f(e)),e=aP(n.get(t),e);return _f(e)}function aP(n,e){let t=e;const r=n.length;for(let s=0;s<r;s++){const i=n.charAt(s);switch(i){case"\0":t+="";break;case u_:t+="";break;default:t+=i}}return t}function _f(n){return n+u_+""}function yf(n){let e=0;for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e++;return e}function Mn(n,e){for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e(t,n[t])}function h_(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}class ce{constructor(e,t){this.comparator=e,this.root=t||be.EMPTY}insert(e,t){return new ce(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,be.BLACK,null,null))}remove(e){return new ce(this.comparator,this.root.remove(e,this.comparator).copy(null,null,be.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){const r=this.comparator(e,t.key);if(r===0)return t.value;r<0?t=t.left:r>0&&(t=t.right)}return null}indexOf(e){let t=0,r=this.root;for(;!r.isEmpty();){const s=this.comparator(e,r.key);if(s===0)return t+r.left.size;s<0?r=r.left:(t+=r.left.size+1,r=r.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal(((t,r)=>(e(t,r),!1)))}toString(){const e=[];return this.inorderTraversal(((t,r)=>(e.push(`${t}:${r}`),!1))),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new Yi(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Yi(this.root,e,this.comparator,!1)}getReverseIterator(){return new Yi(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Yi(this.root,e,this.comparator,!0)}}class Yi{constructor(e,t,r,s){this.isReverse=s,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?r(e.key,t):1,t&&s&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(i===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class be{constructor(e,t,r,s,i){this.key=e,this.value=t,this.color=r??be.RED,this.left=s??be.EMPTY,this.right=i??be.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,r,s,i){return new be(e??this.key,t??this.value,r??this.color,s??this.left,i??this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,r){let s=this;const i=r(e,s.key);return s=i<0?s.copy(null,null,null,s.left.insert(e,t,r),null):i===0?s.copy(null,t,null,null,null):s.copy(null,null,null,null,s.right.insert(e,t,r)),s.fixUp()}removeMin(){if(this.left.isEmpty())return be.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let r,s=this;if(t(e,s.key)<0)s.left.isEmpty()||s.left.isRed()||s.left.left.isRed()||(s=s.moveRedLeft()),s=s.copy(null,null,null,s.left.remove(e,t),null);else{if(s.left.isRed()&&(s=s.rotateRight()),s.right.isEmpty()||s.right.isRed()||s.right.left.isRed()||(s=s.moveRedRight()),t(e,s.key)===0){if(s.right.isEmpty())return be.EMPTY;r=s.right.min(),s=s.copy(r.key,r.value,null,null,s.right.removeMin())}s=s.copy(null,null,null,null,s.right.remove(e,t))}return s.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,be.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,be.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw W(43730,{key:this.key,value:this.value});if(this.right.isRed())throw W(14113,{key:this.key,value:this.value});const e=this.left.check();if(e!==this.right.check())throw W(27949);return e+(this.isRed()?0:1)}}be.EMPTY=null,be.RED=!0,be.BLACK=!1;be.EMPTY=new class{constructor(){this.size=0}get key(){throw W(57766)}get value(){throw W(16141)}get color(){throw W(16727)}get left(){throw W(29726)}get right(){throw W(36894)}copy(e,t,r,s,i){return this}insert(e,t,r){return new be(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class _e{constructor(e){this.comparator=e,this.data=new ce(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal(((t,r)=>(e(t),!1)))}forEachInRange(e,t){const r=this.data.getIteratorFrom(e[0]);for(;r.hasNext();){const s=r.getNext();if(this.comparator(s.key,e[1])>=0)return;t(s.key)}}forEachWhile(e,t){let r;for(r=t!==void 0?this.data.getIteratorFrom(t):this.data.getIterator();r.hasNext();)if(!e(r.getNext().key))return}firstAfterOrEqual(e){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new Ef(this.data.getIterator())}getIteratorFrom(e){return new Ef(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach((r=>{t=t.add(r)})),t}isEqual(e){if(!(e instanceof _e)||this.size!==e.size)return!1;const t=this.data.getIterator(),r=e.data.getIterator();for(;t.hasNext();){const s=t.getNext().key,i=r.getNext().key;if(this.comparator(s,i)!==0)return!1}return!0}toArray(){const e=[];return this.forEach((t=>{e.push(t)})),e}toString(){const e=[];return this.forEach((t=>e.push(t))),"SortedSet("+e.toString()+")"}copy(e){const t=new _e(this.comparator);return t.data=e,t}}class Ef{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}class Ge{constructor(e){this.fields=e,e.sort(Ae.comparator)}static empty(){return new Ge([])}unionWith(e){let t=new _e(Ae.comparator);for(const r of this.fields)t=t.add(r);for(const r of e)t=t.add(r);return new Ge(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return Qr(this.fields,e.fields,((t,r)=>t.isEqual(r)))}}class d_ extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class Ie{constructor(e){this.binaryString=e}static fromBase64String(e){const t=(function(s){try{return atob(s)}catch(i){throw typeof DOMException<"u"&&i instanceof DOMException?new d_("Invalid base64 string: "+i):i}})(e);return new Ie(t)}static fromUint8Array(e){const t=(function(s){let i="";for(let o=0;o<s.length;++o)i+=String.fromCharCode(s[o]);return i})(e);return new Ie(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 r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r})(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return Z(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}Ie.EMPTY_BYTE_STRING=new Ie("");const cP=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Sn(n){if(ne(!!n,39018),typeof n=="string"){let e=0;const t=cP.exec(n);if(ne(!!t,46558,{timestamp:n}),t[1]){let s=t[1];s=(s+"000000000").substr(0,9),e=Number(s)}const r=new Date(n);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:de(n.seconds),nanos:de(n.nanos)}}function de(n){return typeof n=="number"?n:typeof n=="string"?Number(n):0}function Cn(n){return typeof n=="string"?Ie.fromBase64String(n):Ie.fromUint8Array(n)}const f_="server_timestamp",p_="__type__",m_="__previous_value__",g_="__local_write_time__";function uu(n){return(n?.mapValue?.fields||{})[p_]?.stringValue===f_}function ya(n){const e=n.mapValue.fields[m_];return uu(e)?ya(e):e}function ei(n){const e=Sn(n.mapValue.fields[g_].timestampValue);return new J(e.seconds,e.nanos)}class lP{constructor(e,t,r,s,i,o,c,l,h,f,g){this.databaseId=e,this.appId=t,this.persistenceKey=r,this.host=s,this.ssl=i,this.forceLongPolling=o,this.autoDetectLongPolling=c,this.longPollingOptions=l,this.useFetchStreams=h,this.isUsingEmulator=f,this.apiKey=g}}const No="(default)";class ti{constructor(e,t){this.projectId=e,this.database=t||No}static empty(){return new ti("","")}get isDefaultDatabase(){return this.database===No}isEqual(e){return e instanceof ti&&e.projectId===this.projectId&&e.database===this.database}}function uP(n,e){if(!Object.prototype.hasOwnProperty.apply(n.options,["projectId"]))throw new M(N.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new ti(n.options.projectId,e)}const __="__type__",hP="__max__",Qi={mapValue:{}},y_="__vector__",Do="value";function Rn(n){return"nullValue"in n?0:"booleanValue"in n?1:"integerValue"in n||"doubleValue"in n?2:"timestampValue"in n?3:"stringValue"in n?5:"bytesValue"in n?6:"referenceValue"in n?7:"geoPointValue"in n?8:"arrayValue"in n?9:"mapValue"in n?uu(n)?4:fP(n)?9007199254740991:dP(n)?10:11:W(28295,{value:n})}function Dt(n,e){if(n===e)return!0;const t=Rn(n);if(t!==Rn(e))return!1;switch(t){case 0:case 9007199254740991:return!0;case 1:return n.booleanValue===e.booleanValue;case 4:return ei(n).isEqual(ei(e));case 3:return(function(s,i){if(typeof s.timestampValue=="string"&&typeof i.timestampValue=="string"&&s.timestampValue.length===i.timestampValue.length)return s.timestampValue===i.timestampValue;const o=Sn(s.timestampValue),c=Sn(i.timestampValue);return o.seconds===c.seconds&&o.nanos===c.nanos})(n,e);case 5:return n.stringValue===e.stringValue;case 6:return(function(s,i){return Cn(s.bytesValue).isEqual(Cn(i.bytesValue))})(n,e);case 7:return n.referenceValue===e.referenceValue;case 8:return(function(s,i){return de(s.geoPointValue.latitude)===de(i.geoPointValue.latitude)&&de(s.geoPointValue.longitude)===de(i.geoPointValue.longitude)})(n,e);case 2:return(function(s,i){if("integerValue"in s&&"integerValue"in i)return de(s.integerValue)===de(i.integerValue);if("doubleValue"in s&&"doubleValue"in i){const o=de(s.doubleValue),c=de(i.doubleValue);return o===c?Po(o)===Po(c):isNaN(o)&&isNaN(c)}return!1})(n,e);case 9:return Qr(n.arrayValue.values||[],e.arrayValue.values||[],Dt);case 10:case 11:return(function(s,i){const o=s.mapValue.fields||{},c=i.mapValue.fields||{};if(yf(o)!==yf(c))return!1;for(const l in o)if(o.hasOwnProperty(l)&&(c[l]===void 0||!Dt(o[l],c[l])))return!1;return!0})(n,e);default:return W(52216,{left:n})}}function ni(n,e){return(n.values||[]).find((t=>Dt(t,e)))!==void 0}function Jr(n,e){if(n===e)return 0;const t=Rn(n),r=Rn(e);if(t!==r)return Z(t,r);switch(t){case 0:case 9007199254740991:return 0;case 1:return Z(n.booleanValue,e.booleanValue);case 2:return(function(i,o){const c=de(i.integerValue||i.doubleValue),l=de(o.integerValue||o.doubleValue);return c<l?-1:c>l?1:c===l?0:isNaN(c)?isNaN(l)?0:-1:1})(n,e);case 3:return vf(n.timestampValue,e.timestampValue);case 4:return vf(ei(n),ei(e));case 5:return el(n.stringValue,e.stringValue);case 6:return(function(i,o){const c=Cn(i),l=Cn(o);return c.compareTo(l)})(n.bytesValue,e.bytesValue);case 7:return(function(i,o){const c=i.split("/"),l=o.split("/");for(let h=0;h<c.length&&h<l.length;h++){const f=Z(c[h],l[h]);if(f!==0)return f}return Z(c.length,l.length)})(n.referenceValue,e.referenceValue);case 8:return(function(i,o){const c=Z(de(i.latitude),de(o.latitude));return c!==0?c:Z(de(i.longitude),de(o.longitude))})(n.geoPointValue,e.geoPointValue);case 9:return Tf(n.arrayValue,e.arrayValue);case 10:return(function(i,o){const c=i.fields||{},l=o.fields||{},h=c[Do]?.arrayValue,f=l[Do]?.arrayValue,g=Z(h?.values?.length||0,f?.values?.length||0);return g!==0?g:Tf(h,f)})(n.mapValue,e.mapValue);case 11:return(function(i,o){if(i===Qi.mapValue&&o===Qi.mapValue)return 0;if(i===Qi.mapValue)return 1;if(o===Qi.mapValue)return-1;const c=i.fields||{},l=Object.keys(c),h=o.fields||{},f=Object.keys(h);l.sort(),f.sort();for(let g=0;g<l.length&&g<f.length;++g){const _=el(l[g],f[g]);if(_!==0)return _;const T=Jr(c[l[g]],h[f[g]]);if(T!==0)return T}return Z(l.length,f.length)})(n.mapValue,e.mapValue);default:throw W(23264,{he:t})}}function vf(n,e){if(typeof n=="string"&&typeof e=="string"&&n.length===e.length)return Z(n,e);const t=Sn(n),r=Sn(e),s=Z(t.seconds,r.seconds);return s!==0?s:Z(t.nanos,r.nanos)}function Tf(n,e){const t=n.values||[],r=e.values||[];for(let s=0;s<t.length&&s<r.length;++s){const i=Jr(t[s],r[s]);if(i)return i}return Z(t.length,r.length)}function Xr(n){return nl(n)}function nl(n){return"nullValue"in n?"null":"booleanValue"in n?""+n.booleanValue:"integerValue"in n?""+n.integerValue:"doubleValue"in n?""+n.doubleValue:"timestampValue"in n?(function(t){const r=Sn(t);return`time(${r.seconds},${r.nanos})`})(n.timestampValue):"stringValue"in n?n.stringValue:"bytesValue"in n?(function(t){return Cn(t).toBase64()})(n.bytesValue):"referenceValue"in n?(function(t){return B.fromName(t).toString()})(n.referenceValue):"geoPointValue"in n?(function(t){return`geo(${t.latitude},${t.longitude})`})(n.geoPointValue):"arrayValue"in n?(function(t){let r="[",s=!0;for(const i of t.values||[])s?s=!1:r+=",",r+=nl(i);return r+"]"})(n.arrayValue):"mapValue"in n?(function(t){const r=Object.keys(t.fields||{}).sort();let s="{",i=!0;for(const o of r)i?i=!1:s+=",",s+=`${o}:${nl(t.fields[o])}`;return s+"}"})(n.mapValue):W(61005,{value:n})}function co(n){switch(Rn(n)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const e=ya(n);return e?16+co(e):16;case 5:return 2*n.stringValue.length;case 6:return Cn(n.bytesValue).approximateByteSize();case 7:return n.referenceValue.length;case 9:return(function(r){return(r.values||[]).reduce(((s,i)=>s+co(i)),0)})(n.arrayValue);case 10:case 11:return(function(r){let s=0;return Mn(r.fields,((i,o)=>{s+=i.length+co(o)})),s})(n.mapValue);default:throw W(13486,{value:n})}}function wf(n,e){return{referenceValue:`projects/${n.projectId}/databases/${n.database}/documents/${e.path.canonicalString()}`}}function rl(n){return!!n&&"integerValue"in n}function hu(n){return!!n&&"arrayValue"in n}function bf(n){return!!n&&"nullValue"in n}function Af(n){return!!n&&"doubleValue"in n&&isNaN(Number(n.doubleValue))}function lo(n){return!!n&&"mapValue"in n}function dP(n){return(n?.mapValue?.fields||{})[__]?.stringValue===y_}function Hs(n){if(n.geoPointValue)return{geoPointValue:{...n.geoPointValue}};if(n.timestampValue&&typeof n.timestampValue=="object")return{timestampValue:{...n.timestampValue}};if(n.mapValue){const e={mapValue:{fields:{}}};return Mn(n.mapValue.fields,((t,r)=>e.mapValue.fields[t]=Hs(r))),e}if(n.arrayValue){const e={arrayValue:{values:[]}};for(let t=0;t<(n.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=Hs(n.arrayValue.values[t]);return e}return{...n}}function fP(n){return(((n.mapValue||{}).fields||{}).__type__||{}).stringValue===hP}class Be{constructor(e){this.value=e}static empty(){return new Be({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let r=0;r<e.length-1;++r)if(t=(t.mapValue.fields||{})[e.get(r)],!lo(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=Hs(t)}setAll(e){let t=Ae.emptyPath(),r={},s=[];e.forEach(((o,c)=>{if(!t.isImmediateParentOf(c)){const l=this.getFieldsMap(t);this.applyChanges(l,r,s),r={},s=[],t=c.popLast()}o?r[c.lastSegment()]=Hs(o):s.push(c.lastSegment())}));const i=this.getFieldsMap(t);this.applyChanges(i,r,s)}delete(e){const t=this.field(e.popLast());lo(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return Dt(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let r=0;r<e.length;++r){let s=t.mapValue.fields[e.get(r)];lo(s)&&s.mapValue.fields||(s={mapValue:{fields:{}}},t.mapValue.fields[e.get(r)]=s),t=s}return t.mapValue.fields}applyChanges(e,t,r){Mn(t,((s,i)=>e[s]=i));for(const s of r)delete e[s]}clone(){return new Be(Hs(this.value))}}function E_(n){const e=[];return Mn(n.fields,((t,r)=>{const s=new Ae([t]);if(lo(r)){const i=E_(r.mapValue).fields;if(i.length===0)e.push(s);else for(const o of i)e.push(s.child(o))}else e.push(s)})),new Ge(e)}class Re{constructor(e,t,r,s,i,o,c){this.key=e,this.documentType=t,this.version=r,this.readTime=s,this.createTime=i,this.data=o,this.documentState=c}static newInvalidDocument(e){return new Re(e,0,G.min(),G.min(),G.min(),Be.empty(),0)}static newFoundDocument(e,t,r,s){return new Re(e,1,t,G.min(),r,s,0)}static newNoDocument(e,t){return new Re(e,2,t,G.min(),G.min(),Be.empty(),0)}static newUnknownDocument(e,t){return new Re(e,3,t,G.min(),G.min(),Be.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(G.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=Be.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Be.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=G.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(e){return e instanceof Re&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new Re(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}class Oo{constructor(e,t){this.position=e,this.inclusive=t}}function If(n,e,t){let r=0;for(let s=0;s<n.position.length;s++){const i=e[s],o=n.position[s];if(i.field.isKeyField()?r=B.comparator(B.fromName(o.referenceValue),t.key):r=Jr(o,t.data.field(i.field)),i.dir==="desc"&&(r*=-1),r!==0)break}return r}function Sf(n,e){if(n===null)return e===null;if(e===null||n.inclusive!==e.inclusive||n.position.length!==e.position.length)return!1;for(let t=0;t<n.position.length;t++)if(!Dt(n.position[t],e.position[t]))return!1;return!0}class ri{constructor(e,t="asc"){this.field=e,this.dir=t}}function pP(n,e){return n.dir===e.dir&&n.field.isEqual(e.field)}class v_{}class pe extends v_{constructor(e,t,r){super(),this.field=e,this.op=t,this.value=r}static create(e,t,r){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,r):new gP(e,t,r):t==="array-contains"?new EP(e,r):t==="in"?new vP(e,r):t==="not-in"?new TP(e,r):t==="array-contains-any"?new wP(e,r):new pe(e,t,r)}static createKeyFieldInFilter(e,t,r){return t==="in"?new _P(e,r):new yP(e,r)}matches(e){const t=e.data.field(this.field);return this.op==="!="?t!==null&&t.nullValue===void 0&&this.matchesComparison(Jr(t,this.value)):t!==null&&Rn(this.value)===Rn(t)&&this.matchesComparison(Jr(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return W(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class yt extends v_{constructor(e,t){super(),this.filters=e,this.op=t,this.Pe=null}static create(e,t){return new yt(e,t)}matches(e){return T_(this)?this.filters.find((t=>!t.matches(e)))===void 0:this.filters.find((t=>t.matches(e)))!==void 0}getFlattenedFilters(){return this.Pe!==null||(this.Pe=this.filters.reduce(((e,t)=>e.concat(t.getFlattenedFilters())),[])),this.Pe}getFilters(){return Object.assign([],this.filters)}}function T_(n){return n.op==="and"}function w_(n){return mP(n)&&T_(n)}function mP(n){for(const e of n.filters)if(e instanceof yt)return!1;return!0}function sl(n){if(n instanceof pe)return n.field.canonicalString()+n.op.toString()+Xr(n.value);if(w_(n))return n.filters.map((e=>sl(e))).join(",");{const e=n.filters.map((t=>sl(t))).join(",");return`${n.op}(${e})`}}function b_(n,e){return n instanceof pe?(function(r,s){return s instanceof pe&&r.op===s.op&&r.field.isEqual(s.field)&&Dt(r.value,s.value)})(n,e):n instanceof yt?(function(r,s){return s instanceof yt&&r.op===s.op&&r.filters.length===s.filters.length?r.filters.reduce(((i,o,c)=>i&&b_(o,s.filters[c])),!0):!1})(n,e):void W(19439)}function A_(n){return n instanceof pe?(function(t){return`${t.field.canonicalString()} ${t.op} ${Xr(t.value)}`})(n):n instanceof yt?(function(t){return t.op.toString()+" {"+t.getFilters().map(A_).join(" ,")+"}"})(n):"Filter"}class gP extends pe{constructor(e,t,r){super(e,t,r),this.key=B.fromName(r.referenceValue)}matches(e){const t=B.comparator(e.key,this.key);return this.matchesComparison(t)}}class _P extends pe{constructor(e,t){super(e,"in",t),this.keys=I_("in",t)}matches(e){return this.keys.some((t=>t.isEqual(e.key)))}}class yP extends pe{constructor(e,t){super(e,"not-in",t),this.keys=I_("not-in",t)}matches(e){return!this.keys.some((t=>t.isEqual(e.key)))}}function I_(n,e){return(e.arrayValue?.values||[]).map((t=>B.fromName(t.referenceValue)))}class EP extends pe{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return hu(t)&&ni(t.arrayValue,this.value)}}class vP extends pe{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return t!==null&&ni(this.value.arrayValue,t)}}class TP extends pe{constructor(e,t){super(e,"not-in",t)}matches(e){if(ni(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return t!==null&&t.nullValue===void 0&&!ni(this.value.arrayValue,t)}}class wP extends pe{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!hu(t)||!t.arrayValue.values)&&t.arrayValue.values.some((r=>ni(this.value.arrayValue,r)))}}class bP{constructor(e,t=null,r=[],s=[],i=null,o=null,c=null){this.path=e,this.collectionGroup=t,this.orderBy=r,this.filters=s,this.limit=i,this.startAt=o,this.endAt=c,this.Te=null}}function Cf(n,e=null,t=[],r=[],s=null,i=null,o=null){return new bP(n,e,t,r,s,i,o)}function du(n){const e=Y(n);if(e.Te===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map((r=>sl(r))).join(","),t+="|ob:",t+=e.orderBy.map((r=>(function(i){return i.field.canonicalString()+i.dir})(r))).join(","),_a(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map((r=>Xr(r))).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map((r=>Xr(r))).join(",")),e.Te=t}return e.Te}function fu(n,e){if(n.limit!==e.limit||n.orderBy.length!==e.orderBy.length)return!1;for(let t=0;t<n.orderBy.length;t++)if(!pP(n.orderBy[t],e.orderBy[t]))return!1;if(n.filters.length!==e.filters.length)return!1;for(let t=0;t<n.filters.length;t++)if(!b_(n.filters[t],e.filters[t]))return!1;return n.collectionGroup===e.collectionGroup&&!!n.path.isEqual(e.path)&&!!Sf(n.startAt,e.startAt)&&Sf(n.endAt,e.endAt)}function il(n){return B.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}class hs{constructor(e,t=null,r=[],s=[],i=null,o="F",c=null,l=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=s,this.limit=i,this.limitType=o,this.startAt=c,this.endAt=l,this.Ie=null,this.Ee=null,this.Re=null,this.startAt,this.endAt}}function AP(n,e,t,r,s,i,o,c){return new hs(n,e,t,r,s,i,o,c)}function Ea(n){return new hs(n)}function Rf(n){return n.filters.length===0&&n.limit===null&&n.startAt==null&&n.endAt==null&&(n.explicitOrderBy.length===0||n.explicitOrderBy.length===1&&n.explicitOrderBy[0].field.isKeyField())}function IP(n){return B.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}function S_(n){return n.collectionGroup!==null}function Ws(n){const e=Y(n);if(e.Ie===null){e.Ie=[];const t=new Set;for(const i of e.explicitOrderBy)e.Ie.push(i),t.add(i.field.canonicalString());const r=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(o){let c=new _e(Ae.comparator);return o.filters.forEach((l=>{l.getFlattenedFilters().forEach((h=>{h.isInequality()&&(c=c.add(h.field))}))})),c})(e).forEach((i=>{t.has(i.canonicalString())||i.isKeyField()||e.Ie.push(new ri(i,r))})),t.has(Ae.keyField().canonicalString())||e.Ie.push(new ri(Ae.keyField(),r))}return e.Ie}function Ct(n){const e=Y(n);return e.Ee||(e.Ee=SP(e,Ws(n))),e.Ee}function SP(n,e){if(n.limitType==="F")return Cf(n.path,n.collectionGroup,e,n.filters,n.limit,n.startAt,n.endAt);{e=e.map((s=>{const i=s.dir==="desc"?"asc":"desc";return new ri(s.field,i)}));const t=n.endAt?new Oo(n.endAt.position,n.endAt.inclusive):null,r=n.startAt?new Oo(n.startAt.position,n.startAt.inclusive):null;return Cf(n.path,n.collectionGroup,e,n.filters,n.limit,t,r)}}function ol(n,e){const t=n.filters.concat([e]);return new hs(n.path,n.collectionGroup,n.explicitOrderBy.slice(),t,n.limit,n.limitType,n.startAt,n.endAt)}function CP(n,e){const t=n.explicitOrderBy.concat([e]);return new hs(n.path,n.collectionGroup,t,n.filters.slice(),n.limit,n.limitType,n.startAt,n.endAt)}function Vo(n,e,t){return new hs(n.path,n.collectionGroup,n.explicitOrderBy.slice(),n.filters.slice(),e,t,n.startAt,n.endAt)}function va(n,e){return fu(Ct(n),Ct(e))&&n.limitType===e.limitType}function C_(n){return`${du(Ct(n))}|lt:${n.limitType}`}function Nr(n){return`Query(target=${(function(t){let r=t.path.canonicalString();return t.collectionGroup!==null&&(r+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(r+=`, filters: [${t.filters.map((s=>A_(s))).join(", ")}]`),_a(t.limit)||(r+=", limit: "+t.limit),t.orderBy.length>0&&(r+=`, orderBy: [${t.orderBy.map((s=>(function(o){return`${o.field.canonicalString()} (${o.dir})`})(s))).join(", ")}]`),t.startAt&&(r+=", startAt: ",r+=t.startAt.inclusive?"b:":"a:",r+=t.startAt.position.map((s=>Xr(s))).join(",")),t.endAt&&(r+=", endAt: ",r+=t.endAt.inclusive?"a:":"b:",r+=t.endAt.position.map((s=>Xr(s))).join(",")),`Target(${r})`})(Ct(n))}; limitType=${n.limitType})`}function Ta(n,e){return e.isFoundDocument()&&(function(r,s){const i=s.key.path;return r.collectionGroup!==null?s.key.hasCollectionId(r.collectionGroup)&&r.path.isPrefixOf(i):B.isDocumentKey(r.path)?r.path.isEqual(i):r.path.isImmediateParentOf(i)})(n,e)&&(function(r,s){for(const i of Ws(r))if(!i.field.isKeyField()&&s.data.field(i.field)===null)return!1;return!0})(n,e)&&(function(r,s){for(const i of r.filters)if(!i.matches(s))return!1;return!0})(n,e)&&(function(r,s){return!(r.startAt&&!(function(o,c,l){const h=If(o,c,l);return o.inclusive?h<=0:h<0})(r.startAt,Ws(r),s)||r.endAt&&!(function(o,c,l){const h=If(o,c,l);return o.inclusive?h>=0:h>0})(r.endAt,Ws(r),s))})(n,e)}function RP(n){return n.collectionGroup||(n.path.length%2==1?n.path.lastSegment():n.path.get(n.path.length-2))}function R_(n){return(e,t)=>{let r=!1;for(const s of Ws(n)){const i=kP(s,e,t);if(i!==0)return i;r=r||s.field.isKeyField()}return 0}}function kP(n,e,t){const r=n.field.isKeyField()?B.comparator(e.key,t.key):(function(i,o,c){const l=o.data.field(i),h=c.data.field(i);return l!==null&&h!==null?Jr(l,h):W(42886)})(n.field,e,t);switch(n.dir){case"asc":return r;case"desc":return-1*r;default:return W(19790,{direction:n.dir})}}class fr{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){const t=this.mapKeyFn(e),r=this.inner[t];if(r!==void 0){for(const[s,i]of r)if(this.equalsFn(s,e))return i}}has(e){return this.get(e)!==void 0}set(e,t){const r=this.mapKeyFn(e),s=this.inner[r];if(s===void 0)return this.inner[r]=[[e,t]],void this.innerSize++;for(let i=0;i<s.length;i++)if(this.equalsFn(s[i][0],e))return void(s[i]=[e,t]);s.push([e,t]),this.innerSize++}delete(e){const t=this.mapKeyFn(e),r=this.inner[t];if(r===void 0)return!1;for(let s=0;s<r.length;s++)if(this.equalsFn(r[s][0],e))return r.length===1?delete this.inner[t]:r.splice(s,1),this.innerSize--,!0;return!1}forEach(e){Mn(this.inner,((t,r)=>{for(const[s,i]of r)e(s,i)}))}isEmpty(){return h_(this.inner)}size(){return this.innerSize}}const PP=new ce(B.comparator);function Xt(){return PP}const k_=new ce(B.comparator);function xs(...n){let e=k_;for(const t of n)e=e.insert(t.key,t);return e}function P_(n){let e=k_;return n.forEach(((t,r)=>e=e.insert(t,r.overlayedDocument))),e}function Yn(){return zs()}function N_(){return zs()}function zs(){return new fr((n=>n.toString()),((n,e)=>n.isEqual(e)))}const NP=new ce(B.comparator),DP=new _e(B.comparator);function ee(...n){let e=DP;for(const t of n)e=e.add(t);return e}const OP=new _e(Z);function VP(){return OP}function pu(n,e){if(n.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:Po(e)?"-0":e}}function D_(n){return{integerValue:""+n}}function LP(n,e){return iP(e)?D_(e):pu(n,e)}class wa{constructor(){this._=void 0}}function MP(n,e,t){return n instanceof Lo?(function(s,i){const o={fields:{[p_]:{stringValue:f_},[g_]:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}};return i&&uu(i)&&(i=ya(i)),i&&(o.fields[m_]=i),{mapValue:o}})(t,e):n instanceof si?V_(n,e):n instanceof ii?L_(n,e):(function(s,i){const o=O_(s,i),c=kf(o)+kf(s.Ae);return rl(o)&&rl(s.Ae)?D_(c):pu(s.serializer,c)})(n,e)}function xP(n,e,t){return n instanceof si?V_(n,e):n instanceof ii?L_(n,e):t}function O_(n,e){return n instanceof Mo?(function(r){return rl(r)||(function(i){return!!i&&"doubleValue"in i})(r)})(e)?e:{integerValue:0}:null}class Lo extends wa{}class si extends wa{constructor(e){super(),this.elements=e}}function V_(n,e){const t=M_(e);for(const r of n.elements)t.some((s=>Dt(s,r)))||t.push(r);return{arrayValue:{values:t}}}class ii extends wa{constructor(e){super(),this.elements=e}}function L_(n,e){let t=M_(e);for(const r of n.elements)t=t.filter((s=>!Dt(s,r)));return{arrayValue:{values:t}}}class Mo extends wa{constructor(e,t){super(),this.serializer=e,this.Ae=t}}function kf(n){return de(n.integerValue||n.doubleValue)}function M_(n){return hu(n)&&n.arrayValue.values?n.arrayValue.values.slice():[]}function FP(n,e){return n.field.isEqual(e.field)&&(function(r,s){return r instanceof si&&s instanceof si||r instanceof ii&&s instanceof ii?Qr(r.elements,s.elements,Dt):r instanceof Mo&&s instanceof Mo?Dt(r.Ae,s.Ae):r instanceof Lo&&s instanceof Lo})(n.transform,e.transform)}class $P{constructor(e,t){this.version=e,this.transformResults=t}}class gt{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new gt}static exists(e){return new gt(void 0,e)}static updateTime(e){return new gt(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function uo(n,e){return n.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(n.updateTime):n.exists===void 0||n.exists===e.isFoundDocument()}class ba{}function x_(n,e){if(!n.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return n.isNoDocument()?new mu(n.key,gt.none()):new Ei(n.key,n.data,gt.none());{const t=n.data,r=Be.empty();let s=new _e(Ae.comparator);for(let i of e.fields)if(!s.has(i)){let o=t.field(i);o===null&&i.length>1&&(i=i.popLast(),o=t.field(i)),o===null?r.delete(i):r.set(i,o),s=s.add(i)}return new xn(n.key,r,new Ge(s.toArray()),gt.none())}}function UP(n,e,t){n instanceof Ei?(function(s,i,o){const c=s.value.clone(),l=Nf(s.fieldTransforms,i,o.transformResults);c.setAll(l),i.convertToFoundDocument(o.version,c).setHasCommittedMutations()})(n,e,t):n instanceof xn?(function(s,i,o){if(!uo(s.precondition,i))return void i.convertToUnknownDocument(o.version);const c=Nf(s.fieldTransforms,i,o.transformResults),l=i.data;l.setAll(F_(s)),l.setAll(c),i.convertToFoundDocument(o.version,l).setHasCommittedMutations()})(n,e,t):(function(s,i,o){i.convertToNoDocument(o.version).setHasCommittedMutations()})(0,e,t)}function Ks(n,e,t,r){return n instanceof Ei?(function(i,o,c,l){if(!uo(i.precondition,o))return c;const h=i.value.clone(),f=Df(i.fieldTransforms,l,o);return h.setAll(f),o.convertToFoundDocument(o.version,h).setHasLocalMutations(),null})(n,e,t,r):n instanceof xn?(function(i,o,c,l){if(!uo(i.precondition,o))return c;const h=Df(i.fieldTransforms,l,o),f=o.data;return f.setAll(F_(i)),f.setAll(h),o.convertToFoundDocument(o.version,f).setHasLocalMutations(),c===null?null:c.unionWith(i.fieldMask.fields).unionWith(i.fieldTransforms.map((g=>g.field)))})(n,e,t,r):(function(i,o,c){return uo(i.precondition,o)?(o.convertToNoDocument(o.version).setHasLocalMutations(),null):c})(n,e,t)}function BP(n,e){let t=null;for(const r of n.fieldTransforms){const s=e.data.field(r.field),i=O_(r.transform,s||null);i!=null&&(t===null&&(t=Be.empty()),t.set(r.field,i))}return t||null}function Pf(n,e){return n.type===e.type&&!!n.key.isEqual(e.key)&&!!n.precondition.isEqual(e.precondition)&&!!(function(r,s){return r===void 0&&s===void 0||!(!r||!s)&&Qr(r,s,((i,o)=>FP(i,o)))})(n.fieldTransforms,e.fieldTransforms)&&(n.type===0?n.value.isEqual(e.value):n.type!==1||n.data.isEqual(e.data)&&n.fieldMask.isEqual(e.fieldMask))}class Ei extends ba{constructor(e,t,r,s=[]){super(),this.key=e,this.value=t,this.precondition=r,this.fieldTransforms=s,this.type=0}getFieldMask(){return null}}class xn extends ba{constructor(e,t,r,s,i=[]){super(),this.key=e,this.data=t,this.fieldMask=r,this.precondition=s,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function F_(n){const e=new Map;return n.fieldMask.fields.forEach((t=>{if(!t.isEmpty()){const r=n.data.field(t);e.set(t,r)}})),e}function Nf(n,e,t){const r=new Map;ne(n.length===t.length,32656,{Ve:t.length,de:n.length});for(let s=0;s<t.length;s++){const i=n[s],o=i.transform,c=e.data.field(i.field);r.set(i.field,xP(o,c,t[s]))}return r}function Df(n,e,t){const r=new Map;for(const s of n){const i=s.transform,o=t.data.field(s.field);r.set(s.field,MP(i,o,e))}return r}class mu extends ba{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class qP extends ba{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}class jP{constructor(e,t,r,s){this.batchId=e,this.localWriteTime=t,this.baseMutations=r,this.mutations=s}applyToRemoteDocument(e,t){const r=t.mutationResults;for(let s=0;s<this.mutations.length;s++){const i=this.mutations[s];i.key.isEqual(e.key)&&UP(i,e,r[s])}}applyToLocalView(e,t){for(const r of this.baseMutations)r.key.isEqual(e.key)&&(t=Ks(r,e,t,this.localWriteTime));for(const r of this.mutations)r.key.isEqual(e.key)&&(t=Ks(r,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const r=N_();return this.mutations.forEach((s=>{const i=e.get(s.key),o=i.overlayedDocument;let c=this.applyToLocalView(o,i.mutatedFields);c=t.has(s.key)?null:c;const l=x_(o,c);l!==null&&r.set(s.key,l),o.isValidDocument()||o.convertToNoDocument(G.min())})),r}keys(){return this.mutations.reduce(((e,t)=>e.add(t.key)),ee())}isEqual(e){return this.batchId===e.batchId&&Qr(this.mutations,e.mutations,((t,r)=>Pf(t,r)))&&Qr(this.baseMutations,e.baseMutations,((t,r)=>Pf(t,r)))}}class gu{constructor(e,t,r,s){this.batch=e,this.commitVersion=t,this.mutationResults=r,this.docVersions=s}static from(e,t,r){ne(e.mutations.length===r.length,58842,{me:e.mutations.length,fe:r.length});let s=(function(){return NP})();const i=e.mutations;for(let o=0;o<i.length;o++)s=s.insert(i[o].key,r[o].version);return new gu(e,t,r,s)}}class HP{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{
|
|
24
24
|
largestBatchId: ${this.largestBatchId},
|
|
25
25
|
mutation: ${this.mutation.toString()}
|
|
26
|
-
}`}}class ov{constructor(e,t){this.count=e,this.unchangedNames=t}}var ce,J;function av(n){switch(n){case P.OK:return x(64938);case P.CANCELLED:case P.UNKNOWN:case P.DEADLINE_EXCEEDED:case P.RESOURCE_EXHAUSTED:case P.INTERNAL:case P.UNAVAILABLE:case P.UNAUTHENTICATED:return!1;case P.INVALID_ARGUMENT:case P.NOT_FOUND:case P.ALREADY_EXISTS:case P.PERMISSION_DENIED:case P.FAILED_PRECONDITION:case P.ABORTED:case P.OUT_OF_RANGE:case P.UNIMPLEMENTED:case P.DATA_LOSS:return!0;default:return x(15467,{code:n})}}function Sf(n){if(n===void 0)return wt("GRPC error has no .code"),P.UNKNOWN;switch(n){case ce.OK:return P.OK;case ce.CANCELLED:return P.CANCELLED;case ce.UNKNOWN:return P.UNKNOWN;case ce.DEADLINE_EXCEEDED:return P.DEADLINE_EXCEEDED;case ce.RESOURCE_EXHAUSTED:return P.RESOURCE_EXHAUSTED;case ce.INTERNAL:return P.INTERNAL;case ce.UNAVAILABLE:return P.UNAVAILABLE;case ce.UNAUTHENTICATED:return P.UNAUTHENTICATED;case ce.INVALID_ARGUMENT:return P.INVALID_ARGUMENT;case ce.NOT_FOUND:return P.NOT_FOUND;case ce.ALREADY_EXISTS:return P.ALREADY_EXISTS;case ce.PERMISSION_DENIED:return P.PERMISSION_DENIED;case ce.FAILED_PRECONDITION:return P.FAILED_PRECONDITION;case ce.ABORTED:return P.ABORTED;case ce.OUT_OF_RANGE:return P.OUT_OF_RANGE;case ce.UNIMPLEMENTED:return P.UNIMPLEMENTED;case ce.DATA_LOSS:return P.DATA_LOSS;default:return x(39323,{code:n})}}(J=ce||(ce={}))[J.OK=0]="OK",J[J.CANCELLED=1]="CANCELLED",J[J.UNKNOWN=2]="UNKNOWN",J[J.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",J[J.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",J[J.NOT_FOUND=5]="NOT_FOUND",J[J.ALREADY_EXISTS=6]="ALREADY_EXISTS",J[J.PERMISSION_DENIED=7]="PERMISSION_DENIED",J[J.UNAUTHENTICATED=16]="UNAUTHENTICATED",J[J.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",J[J.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",J[J.ABORTED=10]="ABORTED",J[J.OUT_OF_RANGE=11]="OUT_OF_RANGE",J[J.UNIMPLEMENTED=12]="UNIMPLEMENTED",J[J.INTERNAL=13]="INTERNAL",J[J.UNAVAILABLE=14]="UNAVAILABLE",J[J.DATA_LOSS=15]="DATA_LOSS";function cv(){return new TextEncoder}const lv=new xt([4294967295,4294967295],0);function Ru(n){const e=cv().encode(n),t=new Bd;return t.update(e),new Uint8Array(t.digest())}function Pu(n){const e=new DataView(n.buffer),t=e.getUint32(0,!0),r=e.getUint32(4,!0),s=e.getUint32(8,!0),i=e.getUint32(12,!0);return[new xt([t,r],0),new xt([s,i],0)]}class Ua{constructor(e,t,r){if(this.bitmap=e,this.padding=t,this.hashCount=r,t<0||t>=8)throw new pr(`Invalid padding: ${t}`);if(r<0)throw new pr(`Invalid hash count: ${r}`);if(e.length>0&&this.hashCount===0)throw new pr(`Invalid hash count: ${r}`);if(e.length===0&&t!==0)throw new pr(`Invalid padding when bitmap length is 0: ${t}`);this.ge=8*e.length-t,this.pe=xt.fromNumber(this.ge)}ye(e,t,r){let s=e.add(t.multiply(xt.fromNumber(r)));return s.compare(lv)===1&&(s=new xt([s.getBits(0),s.getBits(1)],0)),s.modulo(this.pe).toNumber()}we(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(this.ge===0)return!1;const t=Ru(e),[r,s]=Pu(t);for(let i=0;i<this.hashCount;i++){const a=this.ye(r,s,i);if(!this.we(a))return!1}return!0}static create(e,t,r){const s=e%8==0?0:8-e%8,i=new Uint8Array(Math.ceil(e/8)),a=new Ua(i,s,t);return r.forEach((c=>a.insert(c))),a}insert(e){if(this.ge===0)return;const t=Ru(e),[r,s]=Pu(t);for(let i=0;i<this.hashCount;i++){const a=this.ye(r,s,i);this.be(a)}}be(e){const t=Math.floor(e/8),r=e%8;this.bitmap[t]|=1<<r}}class pr extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class Ii{constructor(e,t,r,s,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=r,this.documentUpdates=s,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(e,t,r){const s=new Map;return s.set(e,$r.createSynthesizedTargetChangeForCurrentChange(e,t,r)),new Ii(B.min(),s,new re(G),Et(),K())}}class $r{constructor(e,t,r,s,i){this.resumeToken=e,this.current=t,this.addedDocuments=r,this.modifiedDocuments=s,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,t,r){return new $r(r,t,K(),K(),K())}}class Is{constructor(e,t,r,s){this.Se=e,this.removedTargetIds=t,this.key=r,this.De=s}}class Rf{constructor(e,t){this.targetId=e,this.Ce=t}}class Pf{constructor(e,t,r=Te.EMPTY_BYTE_STRING,s=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=s}}class Cu{constructor(){this.ve=0,this.Fe=ku(),this.Me=Te.EMPTY_BYTE_STRING,this.xe=!1,this.Oe=!0}get current(){return this.xe}get resumeToken(){return this.Me}get Ne(){return this.ve!==0}get Be(){return this.Oe}Le(e){e.approximateByteSize()>0&&(this.Oe=!0,this.Me=e)}ke(){let e=K(),t=K(),r=K();return this.Fe.forEach(((s,i)=>{switch(i){case 0:e=e.add(s);break;case 2:t=t.add(s);break;case 1:r=r.add(s);break;default:x(38017,{changeType:i})}})),new $r(this.Me,this.xe,e,t,r)}Ke(){this.Oe=!1,this.Fe=ku()}qe(e,t){this.Oe=!0,this.Fe=this.Fe.insert(e,t)}Ue(e){this.Oe=!0,this.Fe=this.Fe.remove(e)}$e(){this.ve+=1}We(){this.ve-=1,Y(this.ve>=0,3241,{ve:this.ve})}Qe(){this.Oe=!0,this.xe=!0}}class uv{constructor(e){this.Ge=e,this.ze=new Map,this.je=Et(),this.He=ds(),this.Je=ds(),this.Ze=new re(G)}Xe(e){for(const t of e.Se)e.De&&e.De.isFoundDocument()?this.Ye(t,e.De):this.et(t,e.key,e.De);for(const t of e.removedTargetIds)this.et(t,e.key,e.De)}tt(e){this.forEachTarget(e,(t=>{const r=this.nt(t);switch(e.state){case 0:this.rt(t)&&r.Le(e.resumeToken);break;case 1:r.We(),r.Ne||r.Ke(),r.Le(e.resumeToken);break;case 2:r.We(),r.Ne||this.removeTarget(t);break;case 3:this.rt(t)&&(r.Qe(),r.Le(e.resumeToken));break;case 4:this.rt(t)&&(this.it(t),r.Le(e.resumeToken));break;default:x(56790,{state:e.state})}}))}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.ze.forEach(((r,s)=>{this.rt(s)&&t(s)}))}st(e){const t=e.targetId,r=e.Ce.count,s=this.ot(t);if(s){const i=s.target;if(qo(i))if(r===0){const a=new M(i.path);this.et(t,a,Ae.newNoDocument(a,B.min()))}else Y(r===1,20013,{expectedCount:r});else{const a=this._t(t);if(a!==r){const c=this.ut(e),u=c?this.ct(c,e,a):1;if(u!==0){this.it(t);const h=u===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Ze=this.Ze.insert(t,h)}}}}}ut(e){const t=e.Ce.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:r="",padding:s=0},hashCount:i=0}=t;let a,c;try{a=$t(r).toUint8Array()}catch(u){if(u instanceof Xd)return Ln("Decoding the base64 bloom filter in existence filter failed ("+u.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw u}try{c=new Ua(a,s,i)}catch(u){return Ln(u instanceof pr?"BloomFilter error: ":"Applying bloom filter failed: ",u),null}return c.ge===0?null:c}ct(e,t,r){return t.Ce.count===r-this.Pt(e,t.targetId)?0:2}Pt(e,t){const r=this.Ge.getRemoteKeysForTarget(t);let s=0;return r.forEach((i=>{const a=this.Ge.ht(),c=`projects/${a.projectId}/databases/${a.database}/documents/${i.path.canonicalString()}`;e.mightContain(c)||(this.et(t,i,null),s++)})),s}Tt(e){const t=new Map;this.ze.forEach(((i,a)=>{const c=this.ot(a);if(c){if(i.current&&qo(c.target)){const u=new M(c.target.path);this.It(u).has(a)||this.Et(a,u)||this.et(a,u,Ae.newNoDocument(u,e))}i.Be&&(t.set(a,i.ke()),i.Ke())}}));let r=K();this.Je.forEach(((i,a)=>{let c=!0;a.forEachWhile((u=>{const h=this.ot(u);return!h||h.purpose==="TargetPurposeLimboResolution"||(c=!1,!1)})),c&&(r=r.add(i))})),this.je.forEach(((i,a)=>a.setReadTime(e)));const s=new Ii(e,t,this.Ze,this.je,r);return this.je=Et(),this.He=ds(),this.Je=ds(),this.Ze=new re(G),s}Ye(e,t){if(!this.rt(e))return;const r=this.Et(e,t.key)?2:0;this.nt(e).qe(t.key,r),this.je=this.je.insert(t.key,t),this.He=this.He.insert(t.key,this.It(t.key).add(e)),this.Je=this.Je.insert(t.key,this.Rt(t.key).add(e))}et(e,t,r){if(!this.rt(e))return;const s=this.nt(e);this.Et(e,t)?s.qe(t,1):s.Ue(t),this.Je=this.Je.insert(t,this.Rt(t).delete(e)),this.Je=this.Je.insert(t,this.Rt(t).add(e)),r&&(this.je=this.je.insert(t,r))}removeTarget(e){this.ze.delete(e)}_t(e){const t=this.nt(e).ke();return this.Ge.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}$e(e){this.nt(e).$e()}nt(e){let t=this.ze.get(e);return t||(t=new Cu,this.ze.set(e,t)),t}Rt(e){let t=this.Je.get(e);return t||(t=new de(G),this.Je=this.Je.insert(e,t)),t}It(e){let t=this.He.get(e);return t||(t=new de(G),this.He=this.He.insert(e,t)),t}rt(e){const t=this.ot(e)!==null;return t||L("WatchChangeAggregator","Detected inactive target",e),t}ot(e){const t=this.ze.get(e);return t&&t.Ne?null:this.Ge.At(e)}it(e){this.ze.set(e,new Cu),this.Ge.getRemoteKeysForTarget(e).forEach((t=>{this.et(e,t,null)}))}Et(e,t){return this.Ge.getRemoteKeysForTarget(e).has(t)}}function ds(){return new re(M.comparator)}function ku(){return new re(M.comparator)}const hv={asc:"ASCENDING",desc:"DESCENDING"},dv={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},fv={and:"AND",or:"OR"};class pv{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function jo(n,e){return n.useProto3Json||gi(e)?e:{value:e}}function js(n,e){return n.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function Cf(n,e){return n.useProto3Json?e.toBase64():e.toUint8Array()}function mv(n,e){return js(n,e.toTimestamp())}function it(n){return Y(!!n,49232),B.fromTimestamp((function(t){const r=qt(t);return new z(r.seconds,r.nanos)})(n))}function Ba(n,e){return zo(n,e).canonicalString()}function zo(n,e){const t=(function(s){return new Z(["projects",s.projectId,"databases",s.database])})(n).child("documents");return e===void 0?t:t.child(e)}function kf(n){const e=Z.fromString(n);return Y(Lf(e),10190,{key:e.toString()}),e}function Ho(n,e){return Ba(n.databaseId,e.path)}function mo(n,e){const t=kf(e);if(t.get(1)!==n.databaseId.projectId)throw new O(P.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+n.databaseId.projectId);if(t.get(3)!==n.databaseId.database)throw new O(P.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+n.databaseId.database);return new M(Df(t))}function Nf(n,e){return Ba(n.databaseId,e)}function gv(n){const e=kf(n);return e.length===4?Z.emptyPath():Df(e)}function Go(n){return new Z(["projects",n.databaseId.projectId,"databases",n.databaseId.database]).canonicalString()}function Df(n){return Y(n.length>4&&n.get(4)==="documents",29091,{key:n.toString()}),n.popFirst(5)}function Nu(n,e,t){return{name:Ho(n,e),fields:t.value.mapValue.fields}}function _v(n,e){let t;if("targetChange"in e){e.targetChange;const r=(function(h){return h==="NO_CHANGE"?0:h==="ADD"?1:h==="REMOVE"?2:h==="CURRENT"?3:h==="RESET"?4:x(39313,{state:h})})(e.targetChange.targetChangeType||"NO_CHANGE"),s=e.targetChange.targetIds||[],i=(function(h,f){return h.useProto3Json?(Y(f===void 0||typeof f=="string",58123),Te.fromBase64String(f||"")):(Y(f===void 0||f instanceof Buffer||f instanceof Uint8Array,16193),Te.fromUint8Array(f||new Uint8Array))})(n,e.targetChange.resumeToken),a=e.targetChange.cause,c=a&&(function(h){const f=h.code===void 0?P.UNKNOWN:Sf(h.code);return new O(f,h.message||"")})(a);t=new Pf(r,s,i,c||null)}else if("documentChange"in e){e.documentChange;const r=e.documentChange;r.document,r.document.name,r.document.updateTime;const s=mo(n,r.document.name),i=it(r.document.updateTime),a=r.document.createTime?it(r.document.createTime):B.min(),c=new Oe({mapValue:{fields:r.document.fields}}),u=Ae.newFoundDocument(s,i,a,c),h=r.targetIds||[],f=r.removedTargetIds||[];t=new Is(h,f,u.key,u)}else if("documentDelete"in e){e.documentDelete;const r=e.documentDelete;r.document;const s=mo(n,r.document),i=r.readTime?it(r.readTime):B.min(),a=Ae.newNoDocument(s,i),c=r.removedTargetIds||[];t=new Is([],c,a.key,a)}else if("documentRemove"in e){e.documentRemove;const r=e.documentRemove;r.document;const s=mo(n,r.document),i=r.removedTargetIds||[];t=new Is([],i,s,null)}else{if(!("filter"in e))return x(11601,{Vt:e});{e.filter;const r=e.filter;r.targetId;const{count:s=0,unchangedNames:i}=r,a=new ov(s,i),c=r.targetId;t=new Rf(c,a)}}return t}function yv(n,e){let t;if(e instanceof qr)t={update:Nu(n,e.key,e.value)};else if(e instanceof xa)t={delete:Ho(n,e.key)};else if(e instanceof Qt)t={update:Nu(n,e.key,e.data),updateMask:Rv(e.fieldMask)};else{if(!(e instanceof rv))return x(16599,{dt:e.type});t={verify:Ho(n,e.key)}}return e.fieldTransforms.length>0&&(t.updateTransforms=e.fieldTransforms.map((r=>(function(i,a){const c=a.transform;if(c instanceof qs)return{fieldPath:a.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(c instanceof Dr)return{fieldPath:a.field.canonicalString(),appendMissingElements:{values:c.elements}};if(c instanceof Vr)return{fieldPath:a.field.canonicalString(),removeAllFromArray:{values:c.elements}};if(c instanceof $s)return{fieldPath:a.field.canonicalString(),increment:c.Ae};throw x(20930,{transform:a.transform})})(0,r)))),e.precondition.isNone||(t.currentDocument=(function(s,i){return i.updateTime!==void 0?{updateTime:mv(s,i.updateTime)}:i.exists!==void 0?{exists:i.exists}:x(27497)})(n,e.precondition)),t}function Tv(n,e){return n&&n.length>0?(Y(e!==void 0,14353),n.map((t=>(function(s,i){let a=s.updateTime?it(s.updateTime):it(i);return a.isEqual(B.min())&&(a=it(i)),new ev(a,s.transformResults||[])})(t,e)))):[]}function wv(n,e){return{documents:[Nf(n,e.path)]}}function Ev(n,e){const t={structuredQuery:{}},r=e.path;let s;e.collectionGroup!==null?(s=r,t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(s=r.popLast(),t.structuredQuery.from=[{collectionId:r.lastSegment()}]),t.parent=Nf(n,s);const i=(function(h){if(h.length!==0)return Of(Xe.create(h,"and"))})(e.filters);i&&(t.structuredQuery.where=i);const a=(function(h){if(h.length!==0)return h.map((f=>(function(y){return{field:Sn(y.field),direction:Av(y.dir)}})(f)))})(e.orderBy);a&&(t.structuredQuery.orderBy=a);const c=jo(n,e.limit);return c!==null&&(t.structuredQuery.limit=c),e.startAt&&(t.structuredQuery.startAt=(function(h){return{before:h.inclusive,values:h.position}})(e.startAt)),e.endAt&&(t.structuredQuery.endAt=(function(h){return{before:!h.inclusive,values:h.position}})(e.endAt)),{ft:t,parent:s}}function vv(n){let e=gv(n.parent);const t=n.structuredQuery,r=t.from?t.from.length:0;let s=null;if(r>0){Y(r===1,65062);const f=t.from[0];f.allDescendants?s=f.collectionId:e=e.child(f.collectionId)}let i=[];t.where&&(i=(function(m){const y=Vf(m);return y instanceof Xe&&lf(y)?y.getFilters():[y]})(t.where));let a=[];t.orderBy&&(a=(function(m){return m.map((y=>(function(k){return new Nr(Rn(k.field),(function(N){switch(N){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}})(k.direction))})(y)))})(t.orderBy));let c=null;t.limit&&(c=(function(m){let y;return y=typeof m=="object"?m.value:m,gi(y)?null:y})(t.limit));let u=null;t.startAt&&(u=(function(m){const y=!!m.before,S=m.values||[];return new Us(S,y)})(t.startAt));let h=null;return t.endAt&&(h=(function(m){const y=!m.before,S=m.values||[];return new Us(S,y)})(t.endAt)),UE(e,s,a,i,c,"F",u,h)}function Iv(n,e){const t=(function(s){switch(s){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return x(28987,{purpose:s})}})(e.purpose);return t==null?null:{"goog-listen-tags":t}}function Vf(n){return n.unaryFilter!==void 0?(function(t){switch(t.unaryFilter.op){case"IS_NAN":const r=Rn(t.unaryFilter.field);return le.create(r,"==",{doubleValue:NaN});case"IS_NULL":const s=Rn(t.unaryFilter.field);return le.create(s,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const i=Rn(t.unaryFilter.field);return le.create(i,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const a=Rn(t.unaryFilter.field);return le.create(a,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return x(61313);default:return x(60726)}})(n):n.fieldFilter!==void 0?(function(t){return le.create(Rn(t.fieldFilter.field),(function(s){switch(s){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":return x(58110);default:return x(50506)}})(t.fieldFilter.op),t.fieldFilter.value)})(n):n.compositeFilter!==void 0?(function(t){return Xe.create(t.compositeFilter.filters.map((r=>Vf(r))),(function(s){switch(s){case"AND":return"and";case"OR":return"or";default:return x(1026)}})(t.compositeFilter.op))})(n):x(30097,{filter:n})}function Av(n){return hv[n]}function bv(n){return dv[n]}function Sv(n){return fv[n]}function Sn(n){return{fieldPath:n.canonicalString()}}function Rn(n){return ye.fromServerFormat(n.fieldPath)}function Of(n){return n instanceof le?(function(t){if(t.op==="=="){if(yu(t.value))return{unaryFilter:{field:Sn(t.field),op:"IS_NAN"}};if(_u(t.value))return{unaryFilter:{field:Sn(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(yu(t.value))return{unaryFilter:{field:Sn(t.field),op:"IS_NOT_NAN"}};if(_u(t.value))return{unaryFilter:{field:Sn(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Sn(t.field),op:bv(t.op),value:t.value}}})(n):n instanceof Xe?(function(t){const r=t.getFilters().map((s=>Of(s)));return r.length===1?r[0]:{compositeFilter:{op:Sv(t.op),filters:r}}})(n):x(54877,{filter:n})}function Rv(n){const e=[];return n.fields.forEach((t=>e.push(t.canonicalString()))),{fieldPaths:e}}function Lf(n){return n.length>=4&&n.get(0)==="projects"&&n.get(2)==="databases"}function Mf(n){return!!n&&typeof n._toProto=="function"&&n._protoValueType==="ProtoValue"}class Lt{constructor(e,t,r,s,i=B.min(),a=B.min(),c=Te.EMPTY_BYTE_STRING,u=null){this.target=e,this.targetId=t,this.purpose=r,this.sequenceNumber=s,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=a,this.resumeToken=c,this.expectedCount=u}withSequenceNumber(e){return new Lt(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new Lt(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new Lt(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new Lt(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class Pv{constructor(e){this.yt=e}}function Cv(n){const e=vv({parent:n.parent,structuredQuery:n.structuredQuery});return n.limitType==="LAST"?Bs(e,e.limit,"L"):e}class kv{constructor(){this.Sn=new Nv}addToCollectionParentIndex(e,t){return this.Sn.add(t),C.resolve()}getCollectionParents(e,t){return C.resolve(this.Sn.getEntries(t))}addFieldIndex(e,t){return C.resolve()}deleteFieldIndex(e,t){return C.resolve()}deleteAllFieldIndexes(e){return C.resolve()}createTargetIndexes(e,t){return C.resolve()}getDocumentsMatchingTarget(e,t){return C.resolve(null)}getIndexType(e,t){return C.resolve(0)}getFieldIndexes(e,t){return C.resolve([])}getNextCollectionGroupToUpdate(e){return C.resolve(null)}getMinOffset(e,t){return C.resolve(Bt.min())}getMinOffsetFromCollectionGroup(e,t){return C.resolve(Bt.min())}updateCollectionGroup(e,t,r){return C.resolve()}updateIndexEntries(e,t){return C.resolve()}}class Nv{constructor(){this.index={}}add(e){const t=e.lastSegment(),r=e.popLast(),s=this.index[t]||new de(Z.comparator),i=!s.has(r);return this.index[t]=s.add(r),i}has(e){const t=e.lastSegment(),r=e.popLast(),s=this.index[t];return s&&s.has(r)}getEntries(e){return(this.index[e]||new de(Z.comparator)).toArray()}}const Du={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},xf=41943040;class Ve{static withCacheSize(e){return new Ve(e,Ve.DEFAULT_COLLECTION_PERCENTILE,Ve.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,r){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=r}}Ve.DEFAULT_COLLECTION_PERCENTILE=10,Ve.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,Ve.DEFAULT=new Ve(xf,Ve.DEFAULT_COLLECTION_PERCENTILE,Ve.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),Ve.DISABLED=new Ve(-1,0,0);class Un{constructor(e){this.sr=e}next(){return this.sr+=2,this.sr}static _r(){return new Un(0)}static ar(){return new Un(-1)}}const Vu="LruGarbageCollector",Dv=1048576;function Ou([n,e],[t,r]){const s=G(n,t);return s===0?G(e,r):s}class Vv{constructor(e){this.Pr=e,this.buffer=new de(Ou),this.Tr=0}Ir(){return++this.Tr}Er(e){const t=[e,this.Ir()];if(this.buffer.size<this.Pr)this.buffer=this.buffer.add(t);else{const r=this.buffer.last();Ou(t,r)<0&&(this.buffer=this.buffer.delete(r).add(t))}}get maxValue(){return this.buffer.last()[0]}}class Ov{constructor(e,t,r){this.garbageCollector=e,this.asyncQueue=t,this.localStore=r,this.Rr=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.Ar(6e4)}stop(){this.Rr&&(this.Rr.cancel(),this.Rr=null)}get started(){return this.Rr!==null}Ar(e){L(Vu,`Garbage collection scheduled in ${e}ms`),this.Rr=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,(async()=>{this.Rr=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(t){Gn(t)?L(Vu,"Ignoring IndexedDB error during garbage collection: ",t):await Hn(t)}await this.Ar(3e5)}))}}class Lv{constructor(e,t){this.Vr=e,this.params=t}calculateTargetCount(e,t){return this.Vr.dr(e).next((r=>Math.floor(t/100*r)))}nthSequenceNumber(e,t){if(t===0)return C.resolve(mi.ce);const r=new Vv(t);return this.Vr.forEachTarget(e,(s=>r.Er(s.sequenceNumber))).next((()=>this.Vr.mr(e,(s=>r.Er(s))))).next((()=>r.maxValue))}removeTargets(e,t,r){return this.Vr.removeTargets(e,t,r)}removeOrphanedDocuments(e,t){return this.Vr.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(L("LruGarbageCollector","Garbage collection skipped; disabled"),C.resolve(Du)):this.getCacheSize(e).next((r=>r<this.params.cacheSizeCollectionThreshold?(L("LruGarbageCollector",`Garbage collection skipped; Cache size ${r} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Du):this.gr(e,t)))}getCacheSize(e){return this.Vr.getCacheSize(e)}gr(e,t){let r,s,i,a,c,u,h;const f=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next((m=>(m>this.params.maximumSequenceNumbersToCollect?(L("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${m}`),s=this.params.maximumSequenceNumbersToCollect):s=m,a=Date.now(),this.nthSequenceNumber(e,s)))).next((m=>(r=m,c=Date.now(),this.removeTargets(e,r,t)))).next((m=>(i=m,u=Date.now(),this.removeOrphanedDocuments(e,r)))).next((m=>(h=Date.now(),An()<=H.DEBUG&&L("LruGarbageCollector",`LRU Garbage Collection
|
|
27
|
-
Counted targets in ${
|
|
28
|
-
Determined least recently used ${s} in `+(c-
|
|
29
|
-
Removed ${i} targets in `+(
|
|
30
|
-
Removed ${
|
|
31
|
-
Total Duration: ${h-f}ms`),C.resolve({didRun:!0,sequenceNumbersCollected:s,targetsRemoved:i,documentsRemoved:m}))))}}function Mv(n,e){return new Lv(n,e)}class xv{constructor(){this.changes=new Tn((e=>e.toString()),((e,t)=>e.isEqual(t))),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,Ae.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const r=this.changes.get(t);return r!==void 0?C.resolve(r):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}class Fv{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}class Uv{constructor(e,t,r,s){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=r,this.indexManager=s}getDocument(e,t){let r=null;return this.documentOverlayCache.getOverlay(e,t).next((s=>(r=s,this.remoteDocumentCache.getEntry(e,t)))).next((s=>(r!==null&&vr(r.mutation,s,Ue.empty(),z.now()),s)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((r=>this.getLocalViewOfDocuments(e,r,K()).next((()=>r))))}getLocalViewOfDocuments(e,t,r=K()){const s=on();return this.populateOverlays(e,s,t).next((()=>this.computeViews(e,t,s,r).next((i=>{let a=fr();return i.forEach(((c,u)=>{a=a.insert(c,u.overlayedDocument)})),a}))))}getOverlayedDocuments(e,t){const r=on();return this.populateOverlays(e,r,t).next((()=>this.computeViews(e,t,r,K())))}populateOverlays(e,t,r){const s=[];return r.forEach((i=>{t.has(i)||s.push(i)})),this.documentOverlayCache.getOverlays(e,s).next((i=>{i.forEach(((a,c)=>{t.set(a,c)}))}))}computeViews(e,t,r,s){let i=Et();const a=Er(),c=(function(){return Er()})();return t.forEach(((u,h)=>{const f=r.get(h.key);s.has(h.key)&&(f===void 0||f.mutation instanceof Qt)?i=i.insert(h.key,h):f!==void 0?(a.set(h.key,f.mutation.getFieldMask()),vr(f.mutation,h,f.mutation.getFieldMask(),z.now())):a.set(h.key,Ue.empty())})),this.recalculateAndSaveOverlays(e,i).next((u=>(u.forEach(((h,f)=>a.set(h,f))),t.forEach(((h,f)=>c.set(h,new Fv(f,a.get(h)??null)))),c)))}recalculateAndSaveOverlays(e,t){const r=Er();let s=new re(((a,c)=>a-c)),i=K();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next((a=>{for(const c of a)c.keys().forEach((u=>{const h=t.get(u);if(h===null)return;let f=r.get(u)||Ue.empty();f=c.applyToLocalView(h,f),r.set(u,f);const m=(s.get(c.batchId)||K()).add(u);s=s.insert(c.batchId,m)}))})).next((()=>{const a=[],c=s.getReverseIterator();for(;c.hasNext();){const u=c.getNext(),h=u.key,f=u.value,m=yf();f.forEach((y=>{if(!i.has(y)){const S=Af(t.get(y),r.get(y));S!==null&&m.set(y,S),i=i.add(y)}})),a.push(this.documentOverlayCache.saveOverlays(e,h,m))}return C.waitFor(a)})).next((()=>r))}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next((r=>this.recalculateAndSaveOverlays(e,r)))}getDocumentsMatchingQuery(e,t,r,s){return BE(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):ff(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,r,s):this.getDocumentsMatchingCollectionQuery(e,t,r,s)}getNextDocuments(e,t,r,s){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,r,s).next((i=>{const a=s-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,r.largestBatchId,s-i.size):C.resolve(on());let c=Rr,u=i;return a.next((h=>C.forEach(h,((f,m)=>(c<m.largestBatchId&&(c=m.largestBatchId),i.get(f)?C.resolve():this.remoteDocumentCache.getEntry(e,f).next((y=>{u=u.insert(f,y)}))))).next((()=>this.populateOverlays(e,h,i))).next((()=>this.computeViews(e,u,h,K()))).next((f=>({batchId:c,changes:_f(f)})))))}))}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new M(t)).next((r=>{let s=fr();return r.isFoundDocument()&&(s=s.insert(r.key,r)),s}))}getDocumentsMatchingCollectionGroupQuery(e,t,r,s){const i=t.collectionGroup;let a=fr();return this.indexManager.getCollectionParents(e,i).next((c=>C.forEach(c,(u=>{const h=(function(m,y){return new Kn(y,null,m.explicitOrderBy.slice(),m.filters.slice(),m.limit,m.limitType,m.startAt,m.endAt)})(t,u.child(i));return this.getDocumentsMatchingCollectionQuery(e,h,r,s).next((f=>{f.forEach(((m,y)=>{a=a.insert(m,y)}))}))})).next((()=>a))))}getDocumentsMatchingCollectionQuery(e,t,r,s){let i;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,r.largestBatchId).next((a=>(i=a,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,r,i,s)))).next((a=>{i.forEach(((u,h)=>{const f=h.getKey();a.get(f)===null&&(a=a.insert(f,Ae.newInvalidDocument(f)))}));let c=fr();return a.forEach(((u,h)=>{const f=i.get(u);f!==void 0&&vr(f.mutation,h,Ue.empty(),z.now()),wi(t,h)&&(c=c.insert(u,h))})),c}))}}class Bv{constructor(e){this.serializer=e,this.Nr=new Map,this.Br=new Map}getBundleMetadata(e,t){return C.resolve(this.Nr.get(t))}saveBundleMetadata(e,t){return this.Nr.set(t.id,(function(s){return{id:s.id,version:s.version,createTime:it(s.createTime)}})(t)),C.resolve()}getNamedQuery(e,t){return C.resolve(this.Br.get(t))}saveNamedQuery(e,t){return this.Br.set(t.name,(function(s){return{name:s.name,query:Cv(s.bundledQuery),readTime:it(s.readTime)}})(t)),C.resolve()}}class qv{constructor(){this.overlays=new re(M.comparator),this.Lr=new Map}getOverlay(e,t){return C.resolve(this.overlays.get(t))}getOverlays(e,t){const r=on();return C.forEach(t,(s=>this.getOverlay(e,s).next((i=>{i!==null&&r.set(s,i)})))).next((()=>r))}saveOverlays(e,t,r){return r.forEach(((s,i)=>{this.bt(e,t,i)})),C.resolve()}removeOverlaysForBatchId(e,t,r){const s=this.Lr.get(r);return s!==void 0&&(s.forEach((i=>this.overlays=this.overlays.remove(i))),this.Lr.delete(r)),C.resolve()}getOverlaysForCollection(e,t,r){const s=on(),i=t.length+1,a=new M(t.child("")),c=this.overlays.getIteratorFrom(a);for(;c.hasNext();){const u=c.getNext().value,h=u.getKey();if(!t.isPrefixOf(h.path))break;h.path.length===i&&u.largestBatchId>r&&s.set(u.getKey(),u)}return C.resolve(s)}getOverlaysForCollectionGroup(e,t,r,s){let i=new re(((h,f)=>h-f));const a=this.overlays.getIterator();for(;a.hasNext();){const h=a.getNext().value;if(h.getKey().getCollectionGroup()===t&&h.largestBatchId>r){let f=i.get(h.largestBatchId);f===null&&(f=on(),i=i.insert(h.largestBatchId,f)),f.set(h.getKey(),h)}}const c=on(),u=i.getIterator();for(;u.hasNext()&&(u.getNext().value.forEach(((h,f)=>c.set(h,f))),!(c.size()>=s)););return C.resolve(c)}bt(e,t,r){const s=this.overlays.get(r.key);if(s!==null){const a=this.Lr.get(s.largestBatchId).delete(r.key);this.Lr.set(s.largestBatchId,a)}this.overlays=this.overlays.insert(r.key,new iv(t,r));let i=this.Lr.get(t);i===void 0&&(i=K(),this.Lr.set(t,i)),this.Lr.set(t,i.add(r.key))}}class $v{constructor(){this.sessionToken=Te.EMPTY_BYTE_STRING}getSessionToken(e){return C.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,C.resolve()}}class qa{constructor(){this.kr=new de(pe.Kr),this.qr=new de(pe.Ur)}isEmpty(){return this.kr.isEmpty()}addReference(e,t){const r=new pe(e,t);this.kr=this.kr.add(r),this.qr=this.qr.add(r)}$r(e,t){e.forEach((r=>this.addReference(r,t)))}removeReference(e,t){this.Wr(new pe(e,t))}Qr(e,t){e.forEach((r=>this.removeReference(r,t)))}Gr(e){const t=new M(new Z([])),r=new pe(t,e),s=new pe(t,e+1),i=[];return this.qr.forEachInRange([r,s],(a=>{this.Wr(a),i.push(a.key)})),i}zr(){this.kr.forEach((e=>this.Wr(e)))}Wr(e){this.kr=this.kr.delete(e),this.qr=this.qr.delete(e)}jr(e){const t=new M(new Z([])),r=new pe(t,e),s=new pe(t,e+1);let i=K();return this.qr.forEachInRange([r,s],(a=>{i=i.add(a.key)})),i}containsKey(e){const t=new pe(e,0),r=this.kr.firstAfterOrEqual(t);return r!==null&&e.isEqual(r.key)}}class pe{constructor(e,t){this.key=e,this.Hr=t}static Kr(e,t){return M.comparator(e.key,t.key)||G(e.Hr,t.Hr)}static Ur(e,t){return G(e.Hr,t.Hr)||M.comparator(e.key,t.key)}}class jv{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Yn=1,this.Jr=new de(pe.Kr)}checkEmpty(e){return C.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,r,s){const i=this.Yn;this.Yn++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const a=new sv(i,t,r,s);this.mutationQueue.push(a);for(const c of s)this.Jr=this.Jr.add(new pe(c.key,i)),this.indexManager.addToCollectionParentIndex(e,c.key.path.popLast());return C.resolve(a)}lookupMutationBatch(e,t){return C.resolve(this.Zr(t))}getNextMutationBatchAfterBatchId(e,t){const r=t+1,s=this.Xr(r),i=s<0?0:s;return C.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return C.resolve(this.mutationQueue.length===0?Na:this.Yn-1)}getAllMutationBatches(e){return C.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const r=new pe(t,0),s=new pe(t,Number.POSITIVE_INFINITY),i=[];return this.Jr.forEachInRange([r,s],(a=>{const c=this.Zr(a.Hr);i.push(c)})),C.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new de(G);return t.forEach((s=>{const i=new pe(s,0),a=new pe(s,Number.POSITIVE_INFINITY);this.Jr.forEachInRange([i,a],(c=>{r=r.add(c.Hr)}))})),C.resolve(this.Yr(r))}getAllMutationBatchesAffectingQuery(e,t){const r=t.path,s=r.length+1;let i=r;M.isDocumentKey(i)||(i=i.child(""));const a=new pe(new M(i),0);let c=new de(G);return this.Jr.forEachWhile((u=>{const h=u.key.path;return!!r.isPrefixOf(h)&&(h.length===s&&(c=c.add(u.Hr)),!0)}),a),C.resolve(this.Yr(c))}Yr(e){const t=[];return e.forEach((r=>{const s=this.Zr(r);s!==null&&t.push(s)})),t}removeMutationBatch(e,t){Y(this.ei(t.batchId,"removed")===0,55003),this.mutationQueue.shift();let r=this.Jr;return C.forEach(t.mutations,(s=>{const i=new pe(s.key,t.batchId);return r=r.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,s.key)})).next((()=>{this.Jr=r}))}nr(e){}containsKey(e,t){const r=new pe(t,0),s=this.Jr.firstAfterOrEqual(r);return C.resolve(t.isEqual(s&&s.key))}performConsistencyCheck(e){return this.mutationQueue.length,C.resolve()}ei(e,t){return this.Xr(e)}Xr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Zr(e){const t=this.Xr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}class zv{constructor(e){this.ti=e,this.docs=(function(){return new re(M.comparator)})(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const r=t.key,s=this.docs.get(r),i=s?s.size:0,a=this.ti(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:a}),this.size+=a-i,this.indexManager.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const r=this.docs.get(t);return C.resolve(r?r.document.mutableCopy():Ae.newInvalidDocument(t))}getEntries(e,t){let r=Et();return t.forEach((s=>{const i=this.docs.get(s);r=r.insert(s,i?i.document.mutableCopy():Ae.newInvalidDocument(s))})),C.resolve(r)}getDocumentsMatchingQuery(e,t,r,s){let i=Et();const a=t.path,c=new M(a.child("__id-9223372036854775808__")),u=this.docs.getIteratorFrom(c);for(;u.hasNext();){const{key:h,value:{document:f}}=u.getNext();if(!a.isPrefixOf(h.path))break;h.path.length>a.length+1||gE(mE(f),r)<=0||(s.has(f.key)||wi(t,f))&&(i=i.insert(f.key,f.mutableCopy()))}return C.resolve(i)}getAllFromCollectionGroup(e,t,r,s){x(9500)}ni(e,t){return C.forEach(this.docs,(r=>t(r)))}newChangeBuffer(e){return new Hv(this)}getSize(e){return C.resolve(this.size)}}class Hv extends xv{constructor(e){super(),this.Mr=e}applyChanges(e){const t=[];return this.changes.forEach(((r,s)=>{s.isValidDocument()?t.push(this.Mr.addEntry(e,s)):this.Mr.removeEntry(r)})),C.waitFor(t)}getFromCache(e,t){return this.Mr.getEntry(e,t)}getAllFromCache(e,t){return this.Mr.getEntries(e,t)}}class Gv{constructor(e){this.persistence=e,this.ri=new Tn((t=>Oa(t)),La),this.lastRemoteSnapshotVersion=B.min(),this.highestTargetId=0,this.ii=0,this.si=new qa,this.targetCount=0,this.oi=Un._r()}forEachTarget(e,t){return this.ri.forEach(((r,s)=>t(s))),C.resolve()}getLastRemoteSnapshotVersion(e){return C.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return C.resolve(this.ii)}allocateTargetId(e){return this.highestTargetId=this.oi.next(),C.resolve(this.highestTargetId)}setTargetsMetadata(e,t,r){return r&&(this.lastRemoteSnapshotVersion=r),t>this.ii&&(this.ii=t),C.resolve()}lr(e){this.ri.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this.oi=new Un(t),this.highestTargetId=t),e.sequenceNumber>this.ii&&(this.ii=e.sequenceNumber)}addTargetData(e,t){return this.lr(t),this.targetCount+=1,C.resolve()}updateTargetData(e,t){return this.lr(t),C.resolve()}removeTargetData(e,t){return this.ri.delete(t.target),this.si.Gr(t.targetId),this.targetCount-=1,C.resolve()}removeTargets(e,t,r){let s=0;const i=[];return this.ri.forEach(((a,c)=>{c.sequenceNumber<=t&&r.get(c.targetId)===null&&(this.ri.delete(a),i.push(this.removeMatchingKeysForTargetId(e,c.targetId)),s++)})),C.waitFor(i).next((()=>s))}getTargetCount(e){return C.resolve(this.targetCount)}getTargetData(e,t){const r=this.ri.get(t)||null;return C.resolve(r)}addMatchingKeys(e,t,r){return this.si.$r(t,r),C.resolve()}removeMatchingKeys(e,t,r){this.si.Qr(t,r);const s=this.persistence.referenceDelegate,i=[];return s&&t.forEach((a=>{i.push(s.markPotentiallyOrphaned(e,a))})),C.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.si.Gr(t),C.resolve()}getMatchingKeysForTargetId(e,t){const r=this.si.jr(t);return C.resolve(r)}containsKey(e,t){return C.resolve(this.si.containsKey(t))}}class Ff{constructor(e,t){this._i={},this.overlays={},this.ai=new mi(0),this.ui=!1,this.ui=!0,this.ci=new $v,this.referenceDelegate=e(this),this.li=new Gv(this),this.indexManager=new kv,this.remoteDocumentCache=(function(s){return new zv(s)})((r=>this.referenceDelegate.hi(r))),this.serializer=new Pv(t),this.Pi=new Bv(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ui=!1,Promise.resolve()}get started(){return this.ui}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new qv,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let r=this._i[e.toKey()];return r||(r=new jv(t,this.referenceDelegate),this._i[e.toKey()]=r),r}getGlobalsCache(){return this.ci}getTargetCache(){return this.li}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Pi}runTransaction(e,t,r){L("MemoryPersistence","Starting transaction:",e);const s=new Kv(this.ai.next());return this.referenceDelegate.Ti(),r(s).next((i=>this.referenceDelegate.Ii(s).next((()=>i)))).toPromise().then((i=>(s.raiseOnCommittedEvent(),i)))}Ei(e,t){return C.or(Object.values(this._i).map((r=>()=>r.containsKey(e,t))))}}class Kv extends yE{constructor(e){super(),this.currentSequenceNumber=e}}class $a{constructor(e){this.persistence=e,this.Ri=new qa,this.Ai=null}static Vi(e){return new $a(e)}get di(){if(this.Ai)return this.Ai;throw x(60996)}addReference(e,t,r){return this.Ri.addReference(r,t),this.di.delete(r.toString()),C.resolve()}removeReference(e,t,r){return this.Ri.removeReference(r,t),this.di.add(r.toString()),C.resolve()}markPotentiallyOrphaned(e,t){return this.di.add(t.toString()),C.resolve()}removeTarget(e,t){this.Ri.Gr(t.targetId).forEach((s=>this.di.add(s.toString())));const r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next((s=>{s.forEach((i=>this.di.add(i.toString())))})).next((()=>r.removeTargetData(e,t)))}Ti(){this.Ai=new Set}Ii(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return C.forEach(this.di,(r=>{const s=M.fromPath(r);return this.mi(e,s).next((i=>{i||t.removeEntry(s,B.min())}))})).next((()=>(this.Ai=null,t.apply(e))))}updateLimboDocument(e,t){return this.mi(e,t).next((r=>{r?this.di.delete(t.toString()):this.di.add(t.toString())}))}hi(e){return 0}mi(e,t){return C.or([()=>C.resolve(this.Ri.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ei(e,t)])}}class zs{constructor(e,t){this.persistence=e,this.fi=new Tn((r=>EE(r.path)),((r,s)=>r.isEqual(s))),this.garbageCollector=Mv(this,t)}static Vi(e,t){return new zs(e,t)}Ti(){}Ii(e){return C.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}dr(e){const t=this.pr(e);return this.persistence.getTargetCache().getTargetCount(e).next((r=>t.next((s=>r+s))))}pr(e){let t=0;return this.mr(e,(r=>{t++})).next((()=>t))}mr(e,t){return C.forEach(this.fi,((r,s)=>this.wr(e,r,s).next((i=>i?C.resolve():t(s)))))}removeTargets(e,t,r){return this.persistence.getTargetCache().removeTargets(e,t,r)}removeOrphanedDocuments(e,t){let r=0;const s=this.persistence.getRemoteDocumentCache(),i=s.newChangeBuffer();return s.ni(e,(a=>this.wr(e,a,t).next((c=>{c||(r++,i.removeEntry(a,B.min()))})))).next((()=>i.apply(e))).next((()=>r))}markPotentiallyOrphaned(e,t){return this.fi.set(t,e.currentSequenceNumber),C.resolve()}removeTarget(e,t){const r=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,r)}addReference(e,t,r){return this.fi.set(r,e.currentSequenceNumber),C.resolve()}removeReference(e,t,r){return this.fi.set(r,e.currentSequenceNumber),C.resolve()}updateLimboDocument(e,t){return this.fi.set(t,e.currentSequenceNumber),C.resolve()}hi(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=ws(e.data.value)),t}wr(e,t,r){return C.or([()=>this.persistence.Ei(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{const s=this.fi.get(t);return C.resolve(s!==void 0&&s>r)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}class ja{constructor(e,t,r,s){this.targetId=e,this.fromCache=t,this.Ts=r,this.Is=s}static Es(e,t){let r=K(),s=K();for(const i of t.docChanges)switch(i.type){case 0:r=r.add(i.doc.key);break;case 1:s=s.add(i.doc.key)}return new ja(e,t.fromCache,r,s)}}class Wv{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}class Qv{constructor(){this.Rs=!1,this.As=!1,this.Vs=100,this.ds=(function(){return mg()?8:TE(Se())>0?6:4})()}initialize(e,t){this.fs=e,this.indexManager=t,this.Rs=!0}getDocumentsMatchingQuery(e,t,r,s){const i={result:null};return this.gs(e,t).next((a=>{i.result=a})).next((()=>{if(!i.result)return this.ps(e,t,s,r).next((a=>{i.result=a}))})).next((()=>{if(i.result)return;const a=new Wv;return this.ys(e,t,a).next((c=>{if(i.result=c,this.As)return this.ws(e,t,a,c.size)}))})).next((()=>i.result))}ws(e,t,r,s){return r.documentReadCount<this.Vs?(An()<=H.DEBUG&&L("QueryEngine","SDK will not create cache indexes for query:",bn(t),"since it only creates cache indexes for collection contains","more than or equal to",this.Vs,"documents"),C.resolve()):(An()<=H.DEBUG&&L("QueryEngine","Query:",bn(t),"scans",r.documentReadCount,"local documents and returns",s,"documents as results."),r.documentReadCount>this.ds*s?(An()<=H.DEBUG&&L("QueryEngine","The SDK decides to create cache indexes for query:",bn(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,st(t))):C.resolve())}gs(e,t){if(vu(t))return C.resolve(null);let r=st(t);return this.indexManager.getIndexType(e,r).next((s=>s===0?null:(t.limit!==null&&s===1&&(t=Bs(t,null,"F"),r=st(t)),this.indexManager.getDocumentsMatchingTarget(e,r).next((i=>{const a=K(...i);return this.fs.getDocuments(e,a).next((c=>this.indexManager.getMinOffset(e,r).next((u=>{const h=this.bs(t,c);return this.Ss(t,h,a,u.readTime)?this.gs(e,Bs(t,null,"F")):this.Ds(e,h,t,u)}))))})))))}ps(e,t,r,s){return vu(t)||s.isEqual(B.min())?C.resolve(null):this.fs.getDocuments(e,r).next((i=>{const a=this.bs(t,i);return this.Ss(t,a,r,s)?C.resolve(null):(An()<=H.DEBUG&&L("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),bn(t)),this.Ds(e,a,t,pE(s,Rr)).next((c=>c)))}))}bs(e,t){let r=new de(mf(e));return t.forEach(((s,i)=>{wi(e,i)&&(r=r.add(i))})),r}Ss(e,t,r,s){if(e.limit===null)return!1;if(r.size!==t.size)return!0;const i=e.limitType==="F"?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(s)>0)}ys(e,t,r){return An()<=H.DEBUG&&L("QueryEngine","Using full collection scan to execute query:",bn(t)),this.fs.getDocumentsMatchingQuery(e,t,Bt.min(),r)}Ds(e,t,r,s){return this.fs.getDocumentsMatchingQuery(e,r,s).next((i=>(t.forEach((a=>{i=i.insert(a.key,a)})),i)))}}const za="LocalStore",Jv=3e8;class Yv{constructor(e,t,r,s){this.persistence=e,this.Cs=t,this.serializer=s,this.vs=new re(G),this.Fs=new Tn((i=>Oa(i)),La),this.Ms=new Map,this.xs=e.getRemoteDocumentCache(),this.li=e.getTargetCache(),this.Pi=e.getBundleCache(),this.Os(r)}Os(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new Uv(this.xs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.xs.setIndexManager(this.indexManager),this.Cs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(t=>e.collect(t,this.vs)))}}function Xv(n,e,t,r){return new Yv(n,e,t,r)}async function Uf(n,e){const t=q(n);return await t.persistence.runTransaction("Handle user change","readonly",(r=>{let s;return t.mutationQueue.getAllMutationBatches(r).next((i=>(s=i,t.Os(e),t.mutationQueue.getAllMutationBatches(r)))).next((i=>{const a=[],c=[];let u=K();for(const h of s){a.push(h.batchId);for(const f of h.mutations)u=u.add(f.key)}for(const h of i){c.push(h.batchId);for(const f of h.mutations)u=u.add(f.key)}return t.localDocuments.getDocuments(r,u).next((h=>({Ns:h,removedBatchIds:a,addedBatchIds:c})))}))}))}function Zv(n,e){const t=q(n);return t.persistence.runTransaction("Acknowledge batch","readwrite-primary",(r=>{const s=e.batch.keys(),i=t.xs.newChangeBuffer({trackRemovals:!0});return(function(c,u,h,f){const m=h.batch,y=m.keys();let S=C.resolve();return y.forEach((k=>{S=S.next((()=>f.getEntry(u,k))).next((V=>{const N=h.docVersions.get(k);Y(N!==null,48541),V.version.compareTo(N)<0&&(m.applyToRemoteDocument(V,h),V.isValidDocument()&&(V.setReadTime(h.commitVersion),f.addEntry(V)))}))})),S.next((()=>c.mutationQueue.removeMutationBatch(u,m)))})(t,r,e,i).next((()=>i.apply(r))).next((()=>t.mutationQueue.performConsistencyCheck(r))).next((()=>t.documentOverlayCache.removeOverlaysForBatchId(r,s,e.batch.batchId))).next((()=>t.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(r,(function(c){let u=K();for(let h=0;h<c.mutationResults.length;++h)c.mutationResults[h].transformResults.length>0&&(u=u.add(c.batch.mutations[h].key));return u})(e)))).next((()=>t.localDocuments.getDocuments(r,s)))}))}function Bf(n){const e=q(n);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(t=>e.li.getLastRemoteSnapshotVersion(t)))}function eI(n,e){const t=q(n),r=e.snapshotVersion;let s=t.vs;return t.persistence.runTransaction("Apply remote event","readwrite-primary",(i=>{const a=t.xs.newChangeBuffer({trackRemovals:!0});s=t.vs;const c=[];e.targetChanges.forEach(((f,m)=>{const y=s.get(m);if(!y)return;c.push(t.li.removeMatchingKeys(i,f.removedDocuments,m).next((()=>t.li.addMatchingKeys(i,f.addedDocuments,m))));let S=y.withSequenceNumber(i.currentSequenceNumber);e.targetMismatches.get(m)!==null?S=S.withResumeToken(Te.EMPTY_BYTE_STRING,B.min()).withLastLimboFreeSnapshotVersion(B.min()):f.resumeToken.approximateByteSize()>0&&(S=S.withResumeToken(f.resumeToken,r)),s=s.insert(m,S),(function(V,N,$){return V.resumeToken.approximateByteSize()===0||N.snapshotVersion.toMicroseconds()-V.snapshotVersion.toMicroseconds()>=Jv?!0:$.addedDocuments.size+$.modifiedDocuments.size+$.removedDocuments.size>0})(y,S,f)&&c.push(t.li.updateTargetData(i,S))}));let u=Et(),h=K();if(e.documentUpdates.forEach((f=>{e.resolvedLimboDocuments.has(f)&&c.push(t.persistence.referenceDelegate.updateLimboDocument(i,f))})),c.push(tI(i,a,e.documentUpdates).next((f=>{u=f.Bs,h=f.Ls}))),!r.isEqual(B.min())){const f=t.li.getLastRemoteSnapshotVersion(i).next((m=>t.li.setTargetsMetadata(i,i.currentSequenceNumber,r)));c.push(f)}return C.waitFor(c).next((()=>a.apply(i))).next((()=>t.localDocuments.getLocalViewOfDocuments(i,u,h))).next((()=>u))})).then((i=>(t.vs=s,i)))}function tI(n,e,t){let r=K(),s=K();return t.forEach((i=>r=r.add(i))),e.getEntries(n,r).next((i=>{let a=Et();return t.forEach(((c,u)=>{const h=i.get(c);u.isFoundDocument()!==h.isFoundDocument()&&(s=s.add(c)),u.isNoDocument()&&u.version.isEqual(B.min())?(e.removeEntry(c,u.readTime),a=a.insert(c,u)):!h.isValidDocument()||u.version.compareTo(h.version)>0||u.version.compareTo(h.version)===0&&h.hasPendingWrites?(e.addEntry(u),a=a.insert(c,u)):L(za,"Ignoring outdated watch update for ",c,". Current version:",h.version," Watch version:",u.version)})),{Bs:a,Ls:s}}))}function nI(n,e){const t=q(n);return t.persistence.runTransaction("Get next mutation batch","readonly",(r=>(e===void 0&&(e=Na),t.mutationQueue.getNextMutationBatchAfterBatchId(r,e))))}function rI(n,e){const t=q(n);return t.persistence.runTransaction("Allocate target","readwrite",(r=>{let s;return t.li.getTargetData(r,e).next((i=>i?(s=i,C.resolve(s)):t.li.allocateTargetId(r).next((a=>(s=new Lt(e,a,"TargetPurposeListen",r.currentSequenceNumber),t.li.addTargetData(r,s).next((()=>s)))))))})).then((r=>{const s=t.vs.get(r.targetId);return(s===null||r.snapshotVersion.compareTo(s.snapshotVersion)>0)&&(t.vs=t.vs.insert(r.targetId,r),t.Fs.set(e,r.targetId)),r}))}async function Ko(n,e,t){const r=q(n),s=r.vs.get(e),i=t?"readwrite":"readwrite-primary";try{t||await r.persistence.runTransaction("Release target",i,(a=>r.persistence.referenceDelegate.removeTarget(a,s)))}catch(a){if(!Gn(a))throw a;L(za,`Failed to update sequence numbers for target ${e}: ${a}`)}r.vs=r.vs.remove(e),r.Fs.delete(s.target)}function Lu(n,e,t){const r=q(n);let s=B.min(),i=K();return r.persistence.runTransaction("Execute query","readwrite",(a=>(function(u,h,f){const m=q(u),y=m.Fs.get(f);return y!==void 0?C.resolve(m.vs.get(y)):m.li.getTargetData(h,f)})(r,a,st(e)).next((c=>{if(c)return s=c.lastLimboFreeSnapshotVersion,r.li.getMatchingKeysForTargetId(a,c.targetId).next((u=>{i=u}))})).next((()=>r.Cs.getDocumentsMatchingQuery(a,e,t?s:B.min(),t?i:K()))).next((c=>(sI(r,jE(e),c),{documents:c,ks:i})))))}function sI(n,e,t){let r=n.Ms.get(e)||B.min();t.forEach(((s,i)=>{i.readTime.compareTo(r)>0&&(r=i.readTime)})),n.Ms.set(e,r)}class Mu{constructor(){this.activeTargetIds=QE()}Qs(e){this.activeTargetIds=this.activeTargetIds.add(e)}Gs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Ws(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class iI{constructor(){this.vo=new Mu,this.Fo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,r){}addLocalQueryTarget(e,t=!0){return t&&this.vo.Qs(e),this.Fo[e]||"not-current"}updateQueryState(e,t,r){this.Fo[e]=t}removeLocalQueryTarget(e){this.vo.Gs(e)}isLocalQueryTarget(e){return this.vo.activeTargetIds.has(e)}clearQueryState(e){delete this.Fo[e]}getAllActiveQueryTargets(){return this.vo.activeTargetIds}isActiveQueryTarget(e){return this.vo.activeTargetIds.has(e)}start(){return this.vo=new Mu,Promise.resolve()}handleUserChange(e,t,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}class oI{Mo(e){}shutdown(){}}const xu="ConnectivityMonitor";class Fu{constructor(){this.xo=()=>this.Oo(),this.No=()=>this.Bo(),this.Lo=[],this.ko()}Mo(e){this.Lo.push(e)}shutdown(){window.removeEventListener("online",this.xo),window.removeEventListener("offline",this.No)}ko(){window.addEventListener("online",this.xo),window.addEventListener("offline",this.No)}Oo(){L(xu,"Network connectivity changed: AVAILABLE");for(const e of this.Lo)e(0)}Bo(){L(xu,"Network connectivity changed: UNAVAILABLE");for(const e of this.Lo)e(1)}static v(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}let fs=null;function Wo(){return fs===null?fs=(function(){return 268435456+Math.round(2147483648*Math.random())})():fs++,"0x"+fs.toString(16)}const go="RestConnection",aI={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery",ExecutePipeline:"executePipeline"};class cI{get Ko(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.qo=t+"://"+e.host,this.Uo=`projects/${r}/databases/${s}`,this.$o=this.databaseId.database===xs?`project_id=${r}`:`project_id=${r}&database_id=${s}`}Wo(e,t,r,s,i){const a=Wo(),c=this.Qo(e,t.toUriEncodedString());L(go,`Sending RPC '${e}' ${a}:`,c,r);const u={"google-cloud-resource-prefix":this.Uo,"x-goog-request-params":this.$o};this.Go(u,s,i);const{host:h}=new URL(c),f=vt(h);return this.zo(e,c,u,r,f).then((m=>(L(go,`Received RPC '${e}' ${a}: `,m),m)),(m=>{throw Ln(go,`RPC '${e}' ${a} failed with error: `,m,"url: ",c,"request:",r),m}))}jo(e,t,r,s,i,a){return this.Wo(e,t,r,s,i)}Go(e,t,r){e["X-Goog-Api-Client"]=(function(){return"gl-js/ fire/"+zn})(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach(((s,i)=>e[i]=s)),r&&r.headers.forEach(((s,i)=>e[i]=s))}Qo(e,t){const r=aI[e];let s=`${this.qo}/v1/${t}:${r}`;return this.databaseInfo.apiKey&&(s=`${s}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),s}terminate(){}}class lI{constructor(e){this.Ho=e.Ho,this.Jo=e.Jo}Zo(e){this.Xo=e}Yo(e){this.e_=e}t_(e){this.n_=e}onMessage(e){this.r_=e}close(){this.Jo()}send(e){this.Ho(e)}i_(){this.Xo()}s_(){this.e_()}o_(e){this.n_(e)}__(e){this.r_(e)}}const ve="WebChannelConnection",hr=(n,e,t)=>{n.listen(e,(r=>{try{t(r)}catch(s){setTimeout((()=>{throw s}),0)}}))};class Dn extends cI{constructor(e){super(e),this.a_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}static u_(){if(!Dn.c_){const e=zd();hr(e,jd.STAT_EVENT,(t=>{t.stat===Lo.PROXY?L(ve,"STAT_EVENT: detected buffering proxy"):t.stat===Lo.NOPROXY&&L(ve,"STAT_EVENT: detected no buffering proxy")})),Dn.c_=!0}}zo(e,t,r,s,i){const a=Wo();return new Promise(((c,u)=>{const h=new qd;h.setWithCredentials(!0),h.listenOnce($d.COMPLETE,(()=>{try{switch(h.getLastErrorCode()){case Ts.NO_ERROR:const m=h.getResponseJson();L(ve,`XHR for RPC '${e}' ${a} received:`,JSON.stringify(m)),c(m);break;case Ts.TIMEOUT:L(ve,`RPC '${e}' ${a} timed out`),u(new O(P.DEADLINE_EXCEEDED,"Request time out"));break;case Ts.HTTP_ERROR:const y=h.getStatus();if(L(ve,`RPC '${e}' ${a} failed with status:`,y,"response text:",h.getResponseText()),y>0){let S=h.getResponseJson();Array.isArray(S)&&(S=S[0]);const k=S?.error;if(k&&k.status&&k.message){const V=(function($){const W=$.toLowerCase().replace(/_/g,"-");return Object.values(P).indexOf(W)>=0?W:P.UNKNOWN})(k.status);u(new O(V,k.message))}else u(new O(P.UNKNOWN,"Server responded with status "+h.getStatus()))}else u(new O(P.UNAVAILABLE,"Connection failed."));break;default:x(9055,{l_:e,streamId:a,h_:h.getLastErrorCode(),P_:h.getLastError()})}}finally{L(ve,`RPC '${e}' ${a} completed.`)}}));const f=JSON.stringify(s);L(ve,`RPC '${e}' ${a} sending request:`,s),h.send(t,"POST",f,r,15)}))}T_(e,t,r){const s=Wo(),i=[this.qo,"/","google.firestore.v1.Firestore","/",e,"/channel"],a=this.createWebChannelTransport(),c={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},u=this.longPollingOptions.timeoutSeconds;u!==void 0&&(c.longPollingTimeout=Math.round(1e3*u)),this.useFetchStreams&&(c.useFetchStreams=!0),this.Go(c.initMessageHeaders,t,r),c.encodeInitMessageHeaders=!0;const h=i.join("");L(ve,`Creating RPC '${e}' stream ${s}: ${h}`,c);const f=a.createWebChannel(h,c);this.I_(f);let m=!1,y=!1;const S=new lI({Ho:k=>{y?L(ve,`Not sending because RPC '${e}' stream ${s} is closed:`,k):(m||(L(ve,`Opening RPC '${e}' stream ${s} transport.`),f.open(),m=!0),L(ve,`RPC '${e}' stream ${s} sending:`,k),f.send(k))},Jo:()=>f.close()});return hr(f,dr.EventType.OPEN,(()=>{y||(L(ve,`RPC '${e}' stream ${s} transport opened.`),S.i_())})),hr(f,dr.EventType.CLOSE,(()=>{y||(y=!0,L(ve,`RPC '${e}' stream ${s} transport closed`),S.o_(),this.E_(f))})),hr(f,dr.EventType.ERROR,(k=>{y||(y=!0,Ln(ve,`RPC '${e}' stream ${s} transport errored. Name:`,k.name,"Message:",k.message),S.o_(new O(P.UNAVAILABLE,"The operation could not be completed")))})),hr(f,dr.EventType.MESSAGE,(k=>{if(!y){const V=k.data[0];Y(!!V,16349);const N=V,$=N?.error||N[0]?.error;if($){L(ve,`RPC '${e}' stream ${s} received error:`,$);const W=$.status;let Q=(function(oe){const v=ce[oe];if(v!==void 0)return Sf(v)})(W),te=$.message;Q===void 0&&(Q=P.INTERNAL,te="Unknown error status: "+W+" with message "+$.message),y=!0,S.o_(new O(Q,te)),f.close()}else L(ve,`RPC '${e}' stream ${s} received:`,V),S.__(V)}})),Dn.u_(),setTimeout((()=>{S.s_()}),0),S}terminate(){this.a_.forEach((e=>e.close())),this.a_=[]}I_(e){this.a_.push(e)}E_(e){this.a_=this.a_.filter((t=>t===e))}Go(e,t,r){super.Go(e,t,r),this.databaseInfo.apiKey&&(e["x-goog-api-key"]=this.databaseInfo.apiKey)}createWebChannelTransport(){return Hd()}}function uI(n){return new Dn(n)}function _o(){return typeof document<"u"?document:null}function Ai(n){return new pv(n,!0)}Dn.c_=!1;class qf{constructor(e,t,r=1e3,s=1.5,i=6e4){this.Ci=e,this.timerId=t,this.R_=r,this.A_=s,this.V_=i,this.d_=0,this.m_=null,this.f_=Date.now(),this.reset()}reset(){this.d_=0}g_(){this.d_=this.V_}p_(e){this.cancel();const t=Math.floor(this.d_+this.y_()),r=Math.max(0,Date.now()-this.f_),s=Math.max(0,t-r);s>0&&L("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.d_} ms, delay with jitter: ${t} ms, last attempt: ${r} ms ago)`),this.m_=this.Ci.enqueueAfterDelay(this.timerId,s,(()=>(this.f_=Date.now(),e()))),this.d_*=this.A_,this.d_<this.R_&&(this.d_=this.R_),this.d_>this.V_&&(this.d_=this.V_)}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.d_}}const Uu="PersistentStream";class $f{constructor(e,t,r,s,i,a,c,u){this.Ci=e,this.b_=r,this.S_=s,this.connection=i,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=c,this.listener=u,this.state=0,this.D_=0,this.C_=null,this.v_=null,this.stream=null,this.F_=0,this.M_=new qf(e,t)}x_(){return this.state===1||this.state===5||this.O_()}O_(){return this.state===2||this.state===3}start(){this.F_=0,this.state!==4?this.auth():this.N_()}async stop(){this.x_()&&await this.close(0)}B_(){this.state=0,this.M_.reset()}L_(){this.O_()&&this.C_===null&&(this.C_=this.Ci.enqueueAfterDelay(this.b_,6e4,(()=>this.k_())))}K_(e){this.q_(),this.stream.send(e)}async k_(){if(this.O_())return this.close(0)}q_(){this.C_&&(this.C_.cancel(),this.C_=null)}U_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(e,t){this.q_(),this.U_(),this.M_.cancel(),this.D_++,e!==4?this.M_.reset():t&&t.code===P.RESOURCE_EXHAUSTED?(wt(t.toString()),wt("Using maximum backoff delay to prevent overloading the backend."),this.M_.g_()):t&&t.code===P.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.W_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.t_(t)}W_(){}auth(){this.state=1;const e=this.Q_(this.D_),t=this.D_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([r,s])=>{this.D_===t&&this.G_(r,s)}),(r=>{e((()=>{const s=new O(P.UNKNOWN,"Fetching auth token failed: "+r.message);return this.z_(s)}))}))}G_(e,t){const r=this.Q_(this.D_);this.stream=this.j_(e,t),this.stream.Zo((()=>{r((()=>this.listener.Zo()))})),this.stream.Yo((()=>{r((()=>(this.state=2,this.v_=this.Ci.enqueueAfterDelay(this.S_,1e4,(()=>(this.O_()&&(this.state=3),Promise.resolve()))),this.listener.Yo())))})),this.stream.t_((s=>{r((()=>this.z_(s)))})),this.stream.onMessage((s=>{r((()=>++this.F_==1?this.H_(s):this.onNext(s)))}))}N_(){this.state=5,this.M_.p_((async()=>{this.state=0,this.start()}))}z_(e){return L(Uu,`close with error: ${e}`),this.stream=null,this.close(4,e)}Q_(e){return t=>{this.Ci.enqueueAndForget((()=>this.D_===e?t():(L(Uu,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class hI extends $f{constructor(e,t,r,s,i,a){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,r,s,a),this.serializer=i}j_(e,t){return this.connection.T_("Listen",e,t)}H_(e){return this.onNext(e)}onNext(e){this.M_.reset();const t=_v(this.serializer,e),r=(function(i){if(!("targetChange"in i))return B.min();const a=i.targetChange;return a.targetIds&&a.targetIds.length?B.min():a.readTime?it(a.readTime):B.min()})(e);return this.listener.J_(t,r)}Z_(e){const t={};t.database=Go(this.serializer),t.addTarget=(function(i,a){let c;const u=a.target;if(c=qo(u)?{documents:wv(i,u)}:{query:Ev(i,u).ft},c.targetId=a.targetId,a.resumeToken.approximateByteSize()>0){c.resumeToken=Cf(i,a.resumeToken);const h=jo(i,a.expectedCount);h!==null&&(c.expectedCount=h)}else if(a.snapshotVersion.compareTo(B.min())>0){c.readTime=js(i,a.snapshotVersion.toTimestamp());const h=jo(i,a.expectedCount);h!==null&&(c.expectedCount=h)}return c})(this.serializer,e);const r=Iv(this.serializer,e);r&&(t.labels=r),this.K_(t)}X_(e){const t={};t.database=Go(this.serializer),t.removeTarget=e,this.K_(t)}}class dI extends $f{constructor(e,t,r,s,i,a){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,r,s,a),this.serializer=i}get Y_(){return this.F_>0}start(){this.lastStreamToken=void 0,super.start()}W_(){this.Y_&&this.ea([])}j_(e,t){return this.connection.T_("Write",e,t)}H_(e){return Y(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,Y(!e.writeResults||e.writeResults.length===0,55816),this.listener.ta()}onNext(e){Y(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.M_.reset();const t=Tv(e.writeResults,e.commitTime),r=it(e.commitTime);return this.listener.na(r,t)}ra(){const e={};e.database=Go(this.serializer),this.K_(e)}ea(e){const t={streamToken:this.lastStreamToken,writes:e.map((r=>yv(this.serializer,r)))};this.K_(t)}}class fI{}class pI extends fI{constructor(e,t,r,s){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer=s,this.ia=!1}sa(){if(this.ia)throw new O(P.FAILED_PRECONDITION,"The client has already been terminated.")}Wo(e,t,r,s){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([i,a])=>this.connection.Wo(e,zo(t,r),s,i,a))).catch((i=>{throw i.name==="FirebaseError"?(i.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),i):new O(P.UNKNOWN,i.toString())}))}jo(e,t,r,s,i){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([a,c])=>this.connection.jo(e,zo(t,r),s,a,c,i))).catch((a=>{throw a.name==="FirebaseError"?(a.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new O(P.UNKNOWN,a.toString())}))}terminate(){this.ia=!0,this.connection.terminate()}}function mI(n,e,t,r){return new pI(n,e,t,r)}class gI{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.oa=0,this._a=null,this.aa=!0}ua(){this.oa===0&&(this.ca("Unknown"),this._a=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=>(this._a=null,this.la("Backend didn't respond within 10 seconds."),this.ca("Offline"),Promise.resolve()))))}ha(e){this.state==="Online"?this.ca("Unknown"):(this.oa++,this.oa>=1&&(this.Pa(),this.la(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ca("Offline")))}set(e){this.Pa(),this.oa=0,e==="Online"&&(this.aa=!1),this.ca(e)}ca(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}la(e){const t=`Could not reach Cloud Firestore backend. ${e}
|
|
32
|
-
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.aa?(
|
|
26
|
+
}`}}class WP{constructor(e,t){this.count=e,this.unchangedNames=t}}var fe,te;function zP(n){switch(n){case N.OK:return W(64938);case N.CANCELLED:case N.UNKNOWN:case N.DEADLINE_EXCEEDED:case N.RESOURCE_EXHAUSTED:case N.INTERNAL:case N.UNAVAILABLE:case N.UNAUTHENTICATED:return!1;case N.INVALID_ARGUMENT:case N.NOT_FOUND:case N.ALREADY_EXISTS:case N.PERMISSION_DENIED:case N.FAILED_PRECONDITION:case N.ABORTED:case N.OUT_OF_RANGE:case N.UNIMPLEMENTED:case N.DATA_LOSS:return!0;default:return W(15467,{code:n})}}function $_(n){if(n===void 0)return Jt("GRPC error has no .code"),N.UNKNOWN;switch(n){case fe.OK:return N.OK;case fe.CANCELLED:return N.CANCELLED;case fe.UNKNOWN:return N.UNKNOWN;case fe.DEADLINE_EXCEEDED:return N.DEADLINE_EXCEEDED;case fe.RESOURCE_EXHAUSTED:return N.RESOURCE_EXHAUSTED;case fe.INTERNAL:return N.INTERNAL;case fe.UNAVAILABLE:return N.UNAVAILABLE;case fe.UNAUTHENTICATED:return N.UNAUTHENTICATED;case fe.INVALID_ARGUMENT:return N.INVALID_ARGUMENT;case fe.NOT_FOUND:return N.NOT_FOUND;case fe.ALREADY_EXISTS:return N.ALREADY_EXISTS;case fe.PERMISSION_DENIED:return N.PERMISSION_DENIED;case fe.FAILED_PRECONDITION:return N.FAILED_PRECONDITION;case fe.ABORTED:return N.ABORTED;case fe.OUT_OF_RANGE:return N.OUT_OF_RANGE;case fe.UNIMPLEMENTED:return N.UNIMPLEMENTED;case fe.DATA_LOSS:return N.DATA_LOSS;default:return W(39323,{code:n})}}(te=fe||(fe={}))[te.OK=0]="OK",te[te.CANCELLED=1]="CANCELLED",te[te.UNKNOWN=2]="UNKNOWN",te[te.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",te[te.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",te[te.NOT_FOUND=5]="NOT_FOUND",te[te.ALREADY_EXISTS=6]="ALREADY_EXISTS",te[te.PERMISSION_DENIED=7]="PERMISSION_DENIED",te[te.UNAUTHENTICATED=16]="UNAUTHENTICATED",te[te.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",te[te.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",te[te.ABORTED=10]="ABORTED",te[te.OUT_OF_RANGE=11]="OUT_OF_RANGE",te[te.UNIMPLEMENTED=12]="UNIMPLEMENTED",te[te.INTERNAL=13]="INTERNAL",te[te.UNAVAILABLE=14]="UNAVAILABLE",te[te.DATA_LOSS=15]="DATA_LOSS";function KP(){return new TextEncoder}const GP=new vn([4294967295,4294967295],0);function Of(n){const e=KP().encode(n),t=new e_;return t.update(e),new Uint8Array(t.digest())}function Vf(n){const e=new DataView(n.buffer),t=e.getUint32(0,!0),r=e.getUint32(4,!0),s=e.getUint32(8,!0),i=e.getUint32(12,!0);return[new vn([t,r],0),new vn([s,i],0)]}class _u{constructor(e,t,r){if(this.bitmap=e,this.padding=t,this.hashCount=r,t<0||t>=8)throw new Fs(`Invalid padding: ${t}`);if(r<0)throw new Fs(`Invalid hash count: ${r}`);if(e.length>0&&this.hashCount===0)throw new Fs(`Invalid hash count: ${r}`);if(e.length===0&&t!==0)throw new Fs(`Invalid padding when bitmap length is 0: ${t}`);this.ge=8*e.length-t,this.pe=vn.fromNumber(this.ge)}ye(e,t,r){let s=e.add(t.multiply(vn.fromNumber(r)));return s.compare(GP)===1&&(s=new vn([s.getBits(0),s.getBits(1)],0)),s.modulo(this.pe).toNumber()}we(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(this.ge===0)return!1;const t=Of(e),[r,s]=Vf(t);for(let i=0;i<this.hashCount;i++){const o=this.ye(r,s,i);if(!this.we(o))return!1}return!0}static create(e,t,r){const s=e%8==0?0:8-e%8,i=new Uint8Array(Math.ceil(e/8)),o=new _u(i,s,t);return r.forEach((c=>o.insert(c))),o}insert(e){if(this.ge===0)return;const t=Of(e),[r,s]=Vf(t);for(let i=0;i<this.hashCount;i++){const o=this.ye(r,s,i);this.be(o)}}be(e){const t=Math.floor(e/8),r=e%8;this.bitmap[t]|=1<<r}}class Fs extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class Aa{constructor(e,t,r,s,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=r,this.documentUpdates=s,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(e,t,r){const s=new Map;return s.set(e,vi.createSynthesizedTargetChangeForCurrentChange(e,t,r)),new Aa(G.min(),s,new ce(Z),Xt(),ee())}}class vi{constructor(e,t,r,s,i){this.resumeToken=e,this.current=t,this.addedDocuments=r,this.modifiedDocuments=s,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,t,r){return new vi(r,t,ee(),ee(),ee())}}class ho{constructor(e,t,r,s){this.Se=e,this.removedTargetIds=t,this.key=r,this.De=s}}class U_{constructor(e,t){this.targetId=e,this.Ce=t}}class B_{constructor(e,t,r=Ie.EMPTY_BYTE_STRING,s=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=s}}class Lf{constructor(){this.ve=0,this.Fe=Mf(),this.Me=Ie.EMPTY_BYTE_STRING,this.xe=!1,this.Oe=!0}get current(){return this.xe}get resumeToken(){return this.Me}get Ne(){return this.ve!==0}get Be(){return this.Oe}Le(e){e.approximateByteSize()>0&&(this.Oe=!0,this.Me=e)}ke(){let e=ee(),t=ee(),r=ee();return this.Fe.forEach(((s,i)=>{switch(i){case 0:e=e.add(s);break;case 2:t=t.add(s);break;case 1:r=r.add(s);break;default:W(38017,{changeType:i})}})),new vi(this.Me,this.xe,e,t,r)}Ke(){this.Oe=!1,this.Fe=Mf()}qe(e,t){this.Oe=!0,this.Fe=this.Fe.insert(e,t)}Ue(e){this.Oe=!0,this.Fe=this.Fe.remove(e)}$e(){this.ve+=1}We(){this.ve-=1,ne(this.ve>=0,3241,{ve:this.ve})}Qe(){this.Oe=!0,this.xe=!0}}class YP{constructor(e){this.Ge=e,this.ze=new Map,this.je=Xt(),this.He=Ji(),this.Je=Ji(),this.Ze=new ce(Z)}Xe(e){for(const t of e.Se)e.De&&e.De.isFoundDocument()?this.Ye(t,e.De):this.et(t,e.key,e.De);for(const t of e.removedTargetIds)this.et(t,e.key,e.De)}tt(e){this.forEachTarget(e,(t=>{const r=this.nt(t);switch(e.state){case 0:this.rt(t)&&r.Le(e.resumeToken);break;case 1:r.We(),r.Ne||r.Ke(),r.Le(e.resumeToken);break;case 2:r.We(),r.Ne||this.removeTarget(t);break;case 3:this.rt(t)&&(r.Qe(),r.Le(e.resumeToken));break;case 4:this.rt(t)&&(this.it(t),r.Le(e.resumeToken));break;default:W(56790,{state:e.state})}}))}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.ze.forEach(((r,s)=>{this.rt(s)&&t(s)}))}st(e){const t=e.targetId,r=e.Ce.count,s=this.ot(t);if(s){const i=s.target;if(il(i))if(r===0){const o=new B(i.path);this.et(t,o,Re.newNoDocument(o,G.min()))}else ne(r===1,20013,{expectedCount:r});else{const o=this._t(t);if(o!==r){const c=this.ut(e),l=c?this.ct(c,e,o):1;if(l!==0){this.it(t);const h=l===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Ze=this.Ze.insert(t,h)}}}}}ut(e){const t=e.Ce.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:r="",padding:s=0},hashCount:i=0}=t;let o,c;try{o=Cn(r).toUint8Array()}catch(l){if(l instanceof d_)return Yr("Decoding the base64 bloom filter in existence filter failed ("+l.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw l}try{c=new _u(o,s,i)}catch(l){return Yr(l instanceof Fs?"BloomFilter error: ":"Applying bloom filter failed: ",l),null}return c.ge===0?null:c}ct(e,t,r){return t.Ce.count===r-this.Pt(e,t.targetId)?0:2}Pt(e,t){const r=this.Ge.getRemoteKeysForTarget(t);let s=0;return r.forEach((i=>{const o=this.Ge.ht(),c=`projects/${o.projectId}/databases/${o.database}/documents/${i.path.canonicalString()}`;e.mightContain(c)||(this.et(t,i,null),s++)})),s}Tt(e){const t=new Map;this.ze.forEach(((i,o)=>{const c=this.ot(o);if(c){if(i.current&&il(c.target)){const l=new B(c.target.path);this.It(l).has(o)||this.Et(o,l)||this.et(o,l,Re.newNoDocument(l,e))}i.Be&&(t.set(o,i.ke()),i.Ke())}}));let r=ee();this.Je.forEach(((i,o)=>{let c=!0;o.forEachWhile((l=>{const h=this.ot(l);return!h||h.purpose==="TargetPurposeLimboResolution"||(c=!1,!1)})),c&&(r=r.add(i))})),this.je.forEach(((i,o)=>o.setReadTime(e)));const s=new Aa(e,t,this.Ze,this.je,r);return this.je=Xt(),this.He=Ji(),this.Je=Ji(),this.Ze=new ce(Z),s}Ye(e,t){if(!this.rt(e))return;const r=this.Et(e,t.key)?2:0;this.nt(e).qe(t.key,r),this.je=this.je.insert(t.key,t),this.He=this.He.insert(t.key,this.It(t.key).add(e)),this.Je=this.Je.insert(t.key,this.Rt(t.key).add(e))}et(e,t,r){if(!this.rt(e))return;const s=this.nt(e);this.Et(e,t)?s.qe(t,1):s.Ue(t),this.Je=this.Je.insert(t,this.Rt(t).delete(e)),this.Je=this.Je.insert(t,this.Rt(t).add(e)),r&&(this.je=this.je.insert(t,r))}removeTarget(e){this.ze.delete(e)}_t(e){const t=this.nt(e).ke();return this.Ge.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}$e(e){this.nt(e).$e()}nt(e){let t=this.ze.get(e);return t||(t=new Lf,this.ze.set(e,t)),t}Rt(e){let t=this.Je.get(e);return t||(t=new _e(Z),this.Je=this.Je.insert(e,t)),t}It(e){let t=this.He.get(e);return t||(t=new _e(Z),this.He=this.He.insert(e,t)),t}rt(e){const t=this.ot(e)!==null;return t||x("WatchChangeAggregator","Detected inactive target",e),t}ot(e){const t=this.ze.get(e);return t&&t.Ne?null:this.Ge.At(e)}it(e){this.ze.set(e,new Lf),this.Ge.getRemoteKeysForTarget(e).forEach((t=>{this.et(e,t,null)}))}Et(e,t){return this.Ge.getRemoteKeysForTarget(e).has(t)}}function Ji(){return new ce(B.comparator)}function Mf(){return new ce(B.comparator)}const QP={asc:"ASCENDING",desc:"DESCENDING"},JP={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},XP={and:"AND",or:"OR"};class ZP{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function al(n,e){return n.useProto3Json||_a(e)?e:{value:e}}function xo(n,e){return n.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function q_(n,e){return n.useProto3Json?e.toBase64():e.toUint8Array()}function eN(n,e){return xo(n,e.toTimestamp())}function Rt(n){return ne(!!n,49232),G.fromTimestamp((function(t){const r=Sn(t);return new J(r.seconds,r.nanos)})(n))}function yu(n,e){return cl(n,e).canonicalString()}function cl(n,e){const t=(function(s){return new se(["projects",s.projectId,"databases",s.database])})(n).child("documents");return e===void 0?t:t.child(e)}function j_(n){const e=se.fromString(n);return ne(G_(e),10190,{key:e.toString()}),e}function ll(n,e){return yu(n.databaseId,e.path)}function Ic(n,e){const t=j_(e);if(t.get(1)!==n.databaseId.projectId)throw new M(N.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+n.databaseId.projectId);if(t.get(3)!==n.databaseId.database)throw new M(N.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+n.databaseId.database);return new B(W_(t))}function H_(n,e){return yu(n.databaseId,e)}function tN(n){const e=j_(n);return e.length===4?se.emptyPath():W_(e)}function ul(n){return new se(["projects",n.databaseId.projectId,"databases",n.databaseId.database]).canonicalString()}function W_(n){return ne(n.length>4&&n.get(4)==="documents",29091,{key:n.toString()}),n.popFirst(5)}function xf(n,e,t){return{name:ll(n,e),fields:t.value.mapValue.fields}}function nN(n,e){let t;if("targetChange"in e){e.targetChange;const r=(function(h){return h==="NO_CHANGE"?0:h==="ADD"?1:h==="REMOVE"?2:h==="CURRENT"?3:h==="RESET"?4:W(39313,{state:h})})(e.targetChange.targetChangeType||"NO_CHANGE"),s=e.targetChange.targetIds||[],i=(function(h,f){return h.useProto3Json?(ne(f===void 0||typeof f=="string",58123),Ie.fromBase64String(f||"")):(ne(f===void 0||f instanceof Buffer||f instanceof Uint8Array,16193),Ie.fromUint8Array(f||new Uint8Array))})(n,e.targetChange.resumeToken),o=e.targetChange.cause,c=o&&(function(h){const f=h.code===void 0?N.UNKNOWN:$_(h.code);return new M(f,h.message||"")})(o);t=new B_(r,s,i,c||null)}else if("documentChange"in e){e.documentChange;const r=e.documentChange;r.document,r.document.name,r.document.updateTime;const s=Ic(n,r.document.name),i=Rt(r.document.updateTime),o=r.document.createTime?Rt(r.document.createTime):G.min(),c=new Be({mapValue:{fields:r.document.fields}}),l=Re.newFoundDocument(s,i,o,c),h=r.targetIds||[],f=r.removedTargetIds||[];t=new ho(h,f,l.key,l)}else if("documentDelete"in e){e.documentDelete;const r=e.documentDelete;r.document;const s=Ic(n,r.document),i=r.readTime?Rt(r.readTime):G.min(),o=Re.newNoDocument(s,i),c=r.removedTargetIds||[];t=new ho([],c,o.key,o)}else if("documentRemove"in e){e.documentRemove;const r=e.documentRemove;r.document;const s=Ic(n,r.document),i=r.removedTargetIds||[];t=new ho([],i,s,null)}else{if(!("filter"in e))return W(11601,{Vt:e});{e.filter;const r=e.filter;r.targetId;const{count:s=0,unchangedNames:i}=r,o=new WP(s,i),c=r.targetId;t=new U_(c,o)}}return t}function rN(n,e){let t;if(e instanceof Ei)t={update:xf(n,e.key,e.value)};else if(e instanceof mu)t={delete:ll(n,e.key)};else if(e instanceof xn)t={update:xf(n,e.key,e.data),updateMask:dN(e.fieldMask)};else{if(!(e instanceof qP))return W(16599,{dt:e.type});t={verify:ll(n,e.key)}}return e.fieldTransforms.length>0&&(t.updateTransforms=e.fieldTransforms.map((r=>(function(i,o){const c=o.transform;if(c instanceof Lo)return{fieldPath:o.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(c instanceof si)return{fieldPath:o.field.canonicalString(),appendMissingElements:{values:c.elements}};if(c instanceof ii)return{fieldPath:o.field.canonicalString(),removeAllFromArray:{values:c.elements}};if(c instanceof Mo)return{fieldPath:o.field.canonicalString(),increment:c.Ae};throw W(20930,{transform:o.transform})})(0,r)))),e.precondition.isNone||(t.currentDocument=(function(s,i){return i.updateTime!==void 0?{updateTime:eN(s,i.updateTime)}:i.exists!==void 0?{exists:i.exists}:W(27497)})(n,e.precondition)),t}function sN(n,e){return n&&n.length>0?(ne(e!==void 0,14353),n.map((t=>(function(s,i){let o=s.updateTime?Rt(s.updateTime):Rt(i);return o.isEqual(G.min())&&(o=Rt(i)),new $P(o,s.transformResults||[])})(t,e)))):[]}function iN(n,e){return{documents:[H_(n,e.path)]}}function oN(n,e){const t={structuredQuery:{}},r=e.path;let s;e.collectionGroup!==null?(s=r,t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(s=r.popLast(),t.structuredQuery.from=[{collectionId:r.lastSegment()}]),t.parent=H_(n,s);const i=(function(h){if(h.length!==0)return K_(yt.create(h,"and"))})(e.filters);i&&(t.structuredQuery.where=i);const o=(function(h){if(h.length!==0)return h.map((f=>(function(_){return{field:Dr(_.field),direction:lN(_.dir)}})(f)))})(e.orderBy);o&&(t.structuredQuery.orderBy=o);const c=al(n,e.limit);return c!==null&&(t.structuredQuery.limit=c),e.startAt&&(t.structuredQuery.startAt=(function(h){return{before:h.inclusive,values:h.position}})(e.startAt)),e.endAt&&(t.structuredQuery.endAt=(function(h){return{before:!h.inclusive,values:h.position}})(e.endAt)),{ft:t,parent:s}}function aN(n){let e=tN(n.parent);const t=n.structuredQuery,r=t.from?t.from.length:0;let s=null;if(r>0){ne(r===1,65062);const f=t.from[0];f.allDescendants?s=f.collectionId:e=e.child(f.collectionId)}let i=[];t.where&&(i=(function(g){const _=z_(g);return _ instanceof yt&&w_(_)?_.getFilters():[_]})(t.where));let o=[];t.orderBy&&(o=(function(g){return g.map((_=>(function(C){return new ri(Or(C.field),(function(k){switch(k){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}})(C.direction))})(_)))})(t.orderBy));let c=null;t.limit&&(c=(function(g){let _;return _=typeof g=="object"?g.value:g,_a(_)?null:_})(t.limit));let l=null;t.startAt&&(l=(function(g){const _=!!g.before,T=g.values||[];return new Oo(T,_)})(t.startAt));let h=null;return t.endAt&&(h=(function(g){const _=!g.before,T=g.values||[];return new Oo(T,_)})(t.endAt)),AP(e,s,o,i,c,"F",l,h)}function cN(n,e){const t=(function(s){switch(s){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return W(28987,{purpose:s})}})(e.purpose);return t==null?null:{"goog-listen-tags":t}}function z_(n){return n.unaryFilter!==void 0?(function(t){switch(t.unaryFilter.op){case"IS_NAN":const r=Or(t.unaryFilter.field);return pe.create(r,"==",{doubleValue:NaN});case"IS_NULL":const s=Or(t.unaryFilter.field);return pe.create(s,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const i=Or(t.unaryFilter.field);return pe.create(i,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const o=Or(t.unaryFilter.field);return pe.create(o,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return W(61313);default:return W(60726)}})(n):n.fieldFilter!==void 0?(function(t){return pe.create(Or(t.fieldFilter.field),(function(s){switch(s){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":return W(58110);default:return W(50506)}})(t.fieldFilter.op),t.fieldFilter.value)})(n):n.compositeFilter!==void 0?(function(t){return yt.create(t.compositeFilter.filters.map((r=>z_(r))),(function(s){switch(s){case"AND":return"and";case"OR":return"or";default:return W(1026)}})(t.compositeFilter.op))})(n):W(30097,{filter:n})}function lN(n){return QP[n]}function uN(n){return JP[n]}function hN(n){return XP[n]}function Dr(n){return{fieldPath:n.canonicalString()}}function Or(n){return Ae.fromServerFormat(n.fieldPath)}function K_(n){return n instanceof pe?(function(t){if(t.op==="=="){if(Af(t.value))return{unaryFilter:{field:Dr(t.field),op:"IS_NAN"}};if(bf(t.value))return{unaryFilter:{field:Dr(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(Af(t.value))return{unaryFilter:{field:Dr(t.field),op:"IS_NOT_NAN"}};if(bf(t.value))return{unaryFilter:{field:Dr(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Dr(t.field),op:uN(t.op),value:t.value}}})(n):n instanceof yt?(function(t){const r=t.getFilters().map((s=>K_(s)));return r.length===1?r[0]:{compositeFilter:{op:hN(t.op),filters:r}}})(n):W(54877,{filter:n})}function dN(n){const e=[];return n.fields.forEach((t=>e.push(t.canonicalString()))),{fieldPaths:e}}function G_(n){return n.length>=4&&n.get(0)==="projects"&&n.get(2)==="databases"}function Y_(n){return!!n&&typeof n._toProto=="function"&&n._protoValueType==="ProtoValue"}class yn{constructor(e,t,r,s,i=G.min(),o=G.min(),c=Ie.EMPTY_BYTE_STRING,l=null){this.target=e,this.targetId=t,this.purpose=r,this.sequenceNumber=s,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=c,this.expectedCount=l}withSequenceNumber(e){return new yn(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new yn(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new yn(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new yn(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class fN{constructor(e){this.yt=e}}function pN(n){const e=aN({parent:n.parent,structuredQuery:n.structuredQuery});return n.limitType==="LAST"?Vo(e,e.limit,"L"):e}class mN{constructor(){this.Sn=new gN}addToCollectionParentIndex(e,t){return this.Sn.add(t),D.resolve()}getCollectionParents(e,t){return D.resolve(this.Sn.getEntries(t))}addFieldIndex(e,t){return D.resolve()}deleteFieldIndex(e,t){return D.resolve()}deleteAllFieldIndexes(e){return D.resolve()}createTargetIndexes(e,t){return D.resolve()}getDocumentsMatchingTarget(e,t){return D.resolve(null)}getIndexType(e,t){return D.resolve(0)}getFieldIndexes(e,t){return D.resolve([])}getNextCollectionGroupToUpdate(e){return D.resolve(null)}getMinOffset(e,t){return D.resolve(In.min())}getMinOffsetFromCollectionGroup(e,t){return D.resolve(In.min())}updateCollectionGroup(e,t,r){return D.resolve()}updateIndexEntries(e,t){return D.resolve()}}class gN{constructor(){this.index={}}add(e){const t=e.lastSegment(),r=e.popLast(),s=this.index[t]||new _e(se.comparator),i=!s.has(r);return this.index[t]=s.add(r),i}has(e){const t=e.lastSegment(),r=e.popLast(),s=this.index[t];return s&&s.has(r)}getEntries(e){return(this.index[e]||new _e(se.comparator)).toArray()}}const Ff={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},Q_=41943040;class $e{static withCacheSize(e){return new $e(e,$e.DEFAULT_COLLECTION_PERCENTILE,$e.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,r){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=r}}$e.DEFAULT_COLLECTION_PERCENTILE=10,$e.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,$e.DEFAULT=new $e(Q_,$e.DEFAULT_COLLECTION_PERCENTILE,$e.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),$e.DISABLED=new $e(-1,0,0);class Zr{constructor(e){this.sr=e}next(){return this.sr+=2,this.sr}static _r(){return new Zr(0)}static ar(){return new Zr(-1)}}const $f="LruGarbageCollector",_N=1048576;function Uf([n,e],[t,r]){const s=Z(n,t);return s===0?Z(e,r):s}class yN{constructor(e){this.Pr=e,this.buffer=new _e(Uf),this.Tr=0}Ir(){return++this.Tr}Er(e){const t=[e,this.Ir()];if(this.buffer.size<this.Pr)this.buffer=this.buffer.add(t);else{const r=this.buffer.last();Uf(t,r)<0&&(this.buffer=this.buffer.delete(r).add(t))}}get maxValue(){return this.buffer.last()[0]}}class EN{constructor(e,t,r){this.garbageCollector=e,this.asyncQueue=t,this.localStore=r,this.Rr=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.Ar(6e4)}stop(){this.Rr&&(this.Rr.cancel(),this.Rr=null)}get started(){return this.Rr!==null}Ar(e){x($f,`Garbage collection scheduled in ${e}ms`),this.Rr=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,(async()=>{this.Rr=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(t){us(t)?x($f,"Ignoring IndexedDB error during garbage collection: ",t):await ls(t)}await this.Ar(3e5)}))}}class vN{constructor(e,t){this.Vr=e,this.params=t}calculateTargetCount(e,t){return this.Vr.dr(e).next((r=>Math.floor(t/100*r)))}nthSequenceNumber(e,t){if(t===0)return D.resolve(ga.ce);const r=new yN(t);return this.Vr.forEachTarget(e,(s=>r.Er(s.sequenceNumber))).next((()=>this.Vr.mr(e,(s=>r.Er(s))))).next((()=>r.maxValue))}removeTargets(e,t,r){return this.Vr.removeTargets(e,t,r)}removeOrphanedDocuments(e,t){return this.Vr.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(x("LruGarbageCollector","Garbage collection skipped; disabled"),D.resolve(Ff)):this.getCacheSize(e).next((r=>r<this.params.cacheSizeCollectionThreshold?(x("LruGarbageCollector",`Garbage collection skipped; Cache size ${r} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Ff):this.gr(e,t)))}getCacheSize(e){return this.Vr.getCacheSize(e)}gr(e,t){let r,s,i,o,c,l,h;const f=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next((g=>(g>this.params.maximumSequenceNumbersToCollect?(x("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${g}`),s=this.params.maximumSequenceNumbersToCollect):s=g,o=Date.now(),this.nthSequenceNumber(e,s)))).next((g=>(r=g,c=Date.now(),this.removeTargets(e,r,t)))).next((g=>(i=g,l=Date.now(),this.removeOrphanedDocuments(e,r)))).next((g=>(h=Date.now(),Pr()<=X.DEBUG&&x("LruGarbageCollector",`LRU Garbage Collection
|
|
27
|
+
Counted targets in ${o-f}ms
|
|
28
|
+
Determined least recently used ${s} in `+(c-o)+`ms
|
|
29
|
+
Removed ${i} targets in `+(l-c)+`ms
|
|
30
|
+
Removed ${g} documents in `+(h-l)+`ms
|
|
31
|
+
Total Duration: ${h-f}ms`),D.resolve({didRun:!0,sequenceNumbersCollected:s,targetsRemoved:i,documentsRemoved:g}))))}}function TN(n,e){return new vN(n,e)}class wN{constructor(){this.changes=new fr((e=>e.toString()),((e,t)=>e.isEqual(t))),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,Re.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const r=this.changes.get(t);return r!==void 0?D.resolve(r):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}class bN{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}class AN{constructor(e,t,r,s){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=r,this.indexManager=s}getDocument(e,t){let r=null;return this.documentOverlayCache.getOverlay(e,t).next((s=>(r=s,this.remoteDocumentCache.getEntry(e,t)))).next((s=>(r!==null&&Ks(r.mutation,s,Ge.empty(),J.now()),s)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((r=>this.getLocalViewOfDocuments(e,r,ee()).next((()=>r))))}getLocalViewOfDocuments(e,t,r=ee()){const s=Yn();return this.populateOverlays(e,s,t).next((()=>this.computeViews(e,t,s,r).next((i=>{let o=xs();return i.forEach(((c,l)=>{o=o.insert(c,l.overlayedDocument)})),o}))))}getOverlayedDocuments(e,t){const r=Yn();return this.populateOverlays(e,r,t).next((()=>this.computeViews(e,t,r,ee())))}populateOverlays(e,t,r){const s=[];return r.forEach((i=>{t.has(i)||s.push(i)})),this.documentOverlayCache.getOverlays(e,s).next((i=>{i.forEach(((o,c)=>{t.set(o,c)}))}))}computeViews(e,t,r,s){let i=Xt();const o=zs(),c=(function(){return zs()})();return t.forEach(((l,h)=>{const f=r.get(h.key);s.has(h.key)&&(f===void 0||f.mutation instanceof xn)?i=i.insert(h.key,h):f!==void 0?(o.set(h.key,f.mutation.getFieldMask()),Ks(f.mutation,h,f.mutation.getFieldMask(),J.now())):o.set(h.key,Ge.empty())})),this.recalculateAndSaveOverlays(e,i).next((l=>(l.forEach(((h,f)=>o.set(h,f))),t.forEach(((h,f)=>c.set(h,new bN(f,o.get(h)??null)))),c)))}recalculateAndSaveOverlays(e,t){const r=zs();let s=new ce(((o,c)=>o-c)),i=ee();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next((o=>{for(const c of o)c.keys().forEach((l=>{const h=t.get(l);if(h===null)return;let f=r.get(l)||Ge.empty();f=c.applyToLocalView(h,f),r.set(l,f);const g=(s.get(c.batchId)||ee()).add(l);s=s.insert(c.batchId,g)}))})).next((()=>{const o=[],c=s.getReverseIterator();for(;c.hasNext();){const l=c.getNext(),h=l.key,f=l.value,g=N_();f.forEach((_=>{if(!i.has(_)){const T=x_(t.get(_),r.get(_));T!==null&&g.set(_,T),i=i.add(_)}})),o.push(this.documentOverlayCache.saveOverlays(e,h,g))}return D.waitFor(o)})).next((()=>r))}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next((r=>this.recalculateAndSaveOverlays(e,r)))}getDocumentsMatchingQuery(e,t,r,s){return IP(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):S_(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,r,s):this.getDocumentsMatchingCollectionQuery(e,t,r,s)}getNextDocuments(e,t,r,s){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,r,s).next((i=>{const o=s-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,r.largestBatchId,s-i.size):D.resolve(Yn());let c=Zs,l=i;return o.next((h=>D.forEach(h,((f,g)=>(c<g.largestBatchId&&(c=g.largestBatchId),i.get(f)?D.resolve():this.remoteDocumentCache.getEntry(e,f).next((_=>{l=l.insert(f,_)}))))).next((()=>this.populateOverlays(e,h,i))).next((()=>this.computeViews(e,l,h,ee()))).next((f=>({batchId:c,changes:P_(f)})))))}))}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new B(t)).next((r=>{let s=xs();return r.isFoundDocument()&&(s=s.insert(r.key,r)),s}))}getDocumentsMatchingCollectionGroupQuery(e,t,r,s){const i=t.collectionGroup;let o=xs();return this.indexManager.getCollectionParents(e,i).next((c=>D.forEach(c,(l=>{const h=(function(g,_){return new hs(_,null,g.explicitOrderBy.slice(),g.filters.slice(),g.limit,g.limitType,g.startAt,g.endAt)})(t,l.child(i));return this.getDocumentsMatchingCollectionQuery(e,h,r,s).next((f=>{f.forEach(((g,_)=>{o=o.insert(g,_)}))}))})).next((()=>o))))}getDocumentsMatchingCollectionQuery(e,t,r,s){let i;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,r.largestBatchId).next((o=>(i=o,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,r,i,s)))).next((o=>{i.forEach(((l,h)=>{const f=h.getKey();o.get(f)===null&&(o=o.insert(f,Re.newInvalidDocument(f)))}));let c=xs();return o.forEach(((l,h)=>{const f=i.get(l);f!==void 0&&Ks(f.mutation,h,Ge.empty(),J.now()),Ta(t,h)&&(c=c.insert(l,h))})),c}))}}class IN{constructor(e){this.serializer=e,this.Nr=new Map,this.Br=new Map}getBundleMetadata(e,t){return D.resolve(this.Nr.get(t))}saveBundleMetadata(e,t){return this.Nr.set(t.id,(function(s){return{id:s.id,version:s.version,createTime:Rt(s.createTime)}})(t)),D.resolve()}getNamedQuery(e,t){return D.resolve(this.Br.get(t))}saveNamedQuery(e,t){return this.Br.set(t.name,(function(s){return{name:s.name,query:pN(s.bundledQuery),readTime:Rt(s.readTime)}})(t)),D.resolve()}}class SN{constructor(){this.overlays=new ce(B.comparator),this.Lr=new Map}getOverlay(e,t){return D.resolve(this.overlays.get(t))}getOverlays(e,t){const r=Yn();return D.forEach(t,(s=>this.getOverlay(e,s).next((i=>{i!==null&&r.set(s,i)})))).next((()=>r))}saveOverlays(e,t,r){return r.forEach(((s,i)=>{this.bt(e,t,i)})),D.resolve()}removeOverlaysForBatchId(e,t,r){const s=this.Lr.get(r);return s!==void 0&&(s.forEach((i=>this.overlays=this.overlays.remove(i))),this.Lr.delete(r)),D.resolve()}getOverlaysForCollection(e,t,r){const s=Yn(),i=t.length+1,o=new B(t.child("")),c=this.overlays.getIteratorFrom(o);for(;c.hasNext();){const l=c.getNext().value,h=l.getKey();if(!t.isPrefixOf(h.path))break;h.path.length===i&&l.largestBatchId>r&&s.set(l.getKey(),l)}return D.resolve(s)}getOverlaysForCollectionGroup(e,t,r,s){let i=new ce(((h,f)=>h-f));const o=this.overlays.getIterator();for(;o.hasNext();){const h=o.getNext().value;if(h.getKey().getCollectionGroup()===t&&h.largestBatchId>r){let f=i.get(h.largestBatchId);f===null&&(f=Yn(),i=i.insert(h.largestBatchId,f)),f.set(h.getKey(),h)}}const c=Yn(),l=i.getIterator();for(;l.hasNext()&&(l.getNext().value.forEach(((h,f)=>c.set(h,f))),!(c.size()>=s)););return D.resolve(c)}bt(e,t,r){const s=this.overlays.get(r.key);if(s!==null){const o=this.Lr.get(s.largestBatchId).delete(r.key);this.Lr.set(s.largestBatchId,o)}this.overlays=this.overlays.insert(r.key,new HP(t,r));let i=this.Lr.get(t);i===void 0&&(i=ee(),this.Lr.set(t,i)),this.Lr.set(t,i.add(r.key))}}class CN{constructor(){this.sessionToken=Ie.EMPTY_BYTE_STRING}getSessionToken(e){return D.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,D.resolve()}}class Eu{constructor(){this.kr=new _e(ve.Kr),this.qr=new _e(ve.Ur)}isEmpty(){return this.kr.isEmpty()}addReference(e,t){const r=new ve(e,t);this.kr=this.kr.add(r),this.qr=this.qr.add(r)}$r(e,t){e.forEach((r=>this.addReference(r,t)))}removeReference(e,t){this.Wr(new ve(e,t))}Qr(e,t){e.forEach((r=>this.removeReference(r,t)))}Gr(e){const t=new B(new se([])),r=new ve(t,e),s=new ve(t,e+1),i=[];return this.qr.forEachInRange([r,s],(o=>{this.Wr(o),i.push(o.key)})),i}zr(){this.kr.forEach((e=>this.Wr(e)))}Wr(e){this.kr=this.kr.delete(e),this.qr=this.qr.delete(e)}jr(e){const t=new B(new se([])),r=new ve(t,e),s=new ve(t,e+1);let i=ee();return this.qr.forEachInRange([r,s],(o=>{i=i.add(o.key)})),i}containsKey(e){const t=new ve(e,0),r=this.kr.firstAfterOrEqual(t);return r!==null&&e.isEqual(r.key)}}class ve{constructor(e,t){this.key=e,this.Hr=t}static Kr(e,t){return B.comparator(e.key,t.key)||Z(e.Hr,t.Hr)}static Ur(e,t){return Z(e.Hr,t.Hr)||B.comparator(e.key,t.key)}}class RN{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Yn=1,this.Jr=new _e(ve.Kr)}checkEmpty(e){return D.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,r,s){const i=this.Yn;this.Yn++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const o=new jP(i,t,r,s);this.mutationQueue.push(o);for(const c of s)this.Jr=this.Jr.add(new ve(c.key,i)),this.indexManager.addToCollectionParentIndex(e,c.key.path.popLast());return D.resolve(o)}lookupMutationBatch(e,t){return D.resolve(this.Zr(t))}getNextMutationBatchAfterBatchId(e,t){const r=t+1,s=this.Xr(r),i=s<0?0:s;return D.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return D.resolve(this.mutationQueue.length===0?lu:this.Yn-1)}getAllMutationBatches(e){return D.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const r=new ve(t,0),s=new ve(t,Number.POSITIVE_INFINITY),i=[];return this.Jr.forEachInRange([r,s],(o=>{const c=this.Zr(o.Hr);i.push(c)})),D.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new _e(Z);return t.forEach((s=>{const i=new ve(s,0),o=new ve(s,Number.POSITIVE_INFINITY);this.Jr.forEachInRange([i,o],(c=>{r=r.add(c.Hr)}))})),D.resolve(this.Yr(r))}getAllMutationBatchesAffectingQuery(e,t){const r=t.path,s=r.length+1;let i=r;B.isDocumentKey(i)||(i=i.child(""));const o=new ve(new B(i),0);let c=new _e(Z);return this.Jr.forEachWhile((l=>{const h=l.key.path;return!!r.isPrefixOf(h)&&(h.length===s&&(c=c.add(l.Hr)),!0)}),o),D.resolve(this.Yr(c))}Yr(e){const t=[];return e.forEach((r=>{const s=this.Zr(r);s!==null&&t.push(s)})),t}removeMutationBatch(e,t){ne(this.ei(t.batchId,"removed")===0,55003),this.mutationQueue.shift();let r=this.Jr;return D.forEach(t.mutations,(s=>{const i=new ve(s.key,t.batchId);return r=r.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,s.key)})).next((()=>{this.Jr=r}))}nr(e){}containsKey(e,t){const r=new ve(t,0),s=this.Jr.firstAfterOrEqual(r);return D.resolve(t.isEqual(s&&s.key))}performConsistencyCheck(e){return this.mutationQueue.length,D.resolve()}ei(e,t){return this.Xr(e)}Xr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Zr(e){const t=this.Xr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}class kN{constructor(e){this.ti=e,this.docs=(function(){return new ce(B.comparator)})(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const r=t.key,s=this.docs.get(r),i=s?s.size:0,o=this.ti(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:o}),this.size+=o-i,this.indexManager.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const r=this.docs.get(t);return D.resolve(r?r.document.mutableCopy():Re.newInvalidDocument(t))}getEntries(e,t){let r=Xt();return t.forEach((s=>{const i=this.docs.get(s);r=r.insert(s,i?i.document.mutableCopy():Re.newInvalidDocument(s))})),D.resolve(r)}getDocumentsMatchingQuery(e,t,r,s){let i=Xt();const o=t.path,c=new B(o.child("__id-9223372036854775808__")),l=this.docs.getIteratorFrom(c);for(;l.hasNext();){const{key:h,value:{document:f}}=l.getNext();if(!o.isPrefixOf(h.path))break;h.path.length>o.length+1||tP(eP(f),r)<=0||(s.has(f.key)||Ta(t,f))&&(i=i.insert(f.key,f.mutableCopy()))}return D.resolve(i)}getAllFromCollectionGroup(e,t,r,s){W(9500)}ni(e,t){return D.forEach(this.docs,(r=>t(r)))}newChangeBuffer(e){return new PN(this)}getSize(e){return D.resolve(this.size)}}class PN extends wN{constructor(e){super(),this.Mr=e}applyChanges(e){const t=[];return this.changes.forEach(((r,s)=>{s.isValidDocument()?t.push(this.Mr.addEntry(e,s)):this.Mr.removeEntry(r)})),D.waitFor(t)}getFromCache(e,t){return this.Mr.getEntry(e,t)}getAllFromCache(e,t){return this.Mr.getEntries(e,t)}}class NN{constructor(e){this.persistence=e,this.ri=new fr((t=>du(t)),fu),this.lastRemoteSnapshotVersion=G.min(),this.highestTargetId=0,this.ii=0,this.si=new Eu,this.targetCount=0,this.oi=Zr._r()}forEachTarget(e,t){return this.ri.forEach(((r,s)=>t(s))),D.resolve()}getLastRemoteSnapshotVersion(e){return D.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return D.resolve(this.ii)}allocateTargetId(e){return this.highestTargetId=this.oi.next(),D.resolve(this.highestTargetId)}setTargetsMetadata(e,t,r){return r&&(this.lastRemoteSnapshotVersion=r),t>this.ii&&(this.ii=t),D.resolve()}lr(e){this.ri.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this.oi=new Zr(t),this.highestTargetId=t),e.sequenceNumber>this.ii&&(this.ii=e.sequenceNumber)}addTargetData(e,t){return this.lr(t),this.targetCount+=1,D.resolve()}updateTargetData(e,t){return this.lr(t),D.resolve()}removeTargetData(e,t){return this.ri.delete(t.target),this.si.Gr(t.targetId),this.targetCount-=1,D.resolve()}removeTargets(e,t,r){let s=0;const i=[];return this.ri.forEach(((o,c)=>{c.sequenceNumber<=t&&r.get(c.targetId)===null&&(this.ri.delete(o),i.push(this.removeMatchingKeysForTargetId(e,c.targetId)),s++)})),D.waitFor(i).next((()=>s))}getTargetCount(e){return D.resolve(this.targetCount)}getTargetData(e,t){const r=this.ri.get(t)||null;return D.resolve(r)}addMatchingKeys(e,t,r){return this.si.$r(t,r),D.resolve()}removeMatchingKeys(e,t,r){this.si.Qr(t,r);const s=this.persistence.referenceDelegate,i=[];return s&&t.forEach((o=>{i.push(s.markPotentiallyOrphaned(e,o))})),D.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.si.Gr(t),D.resolve()}getMatchingKeysForTargetId(e,t){const r=this.si.jr(t);return D.resolve(r)}containsKey(e,t){return D.resolve(this.si.containsKey(t))}}class J_{constructor(e,t){this._i={},this.overlays={},this.ai=new ga(0),this.ui=!1,this.ui=!0,this.ci=new CN,this.referenceDelegate=e(this),this.li=new NN(this),this.indexManager=new mN,this.remoteDocumentCache=(function(s){return new kN(s)})((r=>this.referenceDelegate.hi(r))),this.serializer=new fN(t),this.Pi=new IN(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ui=!1,Promise.resolve()}get started(){return this.ui}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new SN,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let r=this._i[e.toKey()];return r||(r=new RN(t,this.referenceDelegate),this._i[e.toKey()]=r),r}getGlobalsCache(){return this.ci}getTargetCache(){return this.li}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Pi}runTransaction(e,t,r){x("MemoryPersistence","Starting transaction:",e);const s=new DN(this.ai.next());return this.referenceDelegate.Ti(),r(s).next((i=>this.referenceDelegate.Ii(s).next((()=>i)))).toPromise().then((i=>(s.raiseOnCommittedEvent(),i)))}Ei(e,t){return D.or(Object.values(this._i).map((r=>()=>r.containsKey(e,t))))}}class DN extends rP{constructor(e){super(),this.currentSequenceNumber=e}}class vu{constructor(e){this.persistence=e,this.Ri=new Eu,this.Ai=null}static Vi(e){return new vu(e)}get di(){if(this.Ai)return this.Ai;throw W(60996)}addReference(e,t,r){return this.Ri.addReference(r,t),this.di.delete(r.toString()),D.resolve()}removeReference(e,t,r){return this.Ri.removeReference(r,t),this.di.add(r.toString()),D.resolve()}markPotentiallyOrphaned(e,t){return this.di.add(t.toString()),D.resolve()}removeTarget(e,t){this.Ri.Gr(t.targetId).forEach((s=>this.di.add(s.toString())));const r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next((s=>{s.forEach((i=>this.di.add(i.toString())))})).next((()=>r.removeTargetData(e,t)))}Ti(){this.Ai=new Set}Ii(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return D.forEach(this.di,(r=>{const s=B.fromPath(r);return this.mi(e,s).next((i=>{i||t.removeEntry(s,G.min())}))})).next((()=>(this.Ai=null,t.apply(e))))}updateLimboDocument(e,t){return this.mi(e,t).next((r=>{r?this.di.delete(t.toString()):this.di.add(t.toString())}))}hi(e){return 0}mi(e,t){return D.or([()=>D.resolve(this.Ri.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ei(e,t)])}}class Fo{constructor(e,t){this.persistence=e,this.fi=new fr((r=>oP(r.path)),((r,s)=>r.isEqual(s))),this.garbageCollector=TN(this,t)}static Vi(e,t){return new Fo(e,t)}Ti(){}Ii(e){return D.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}dr(e){const t=this.pr(e);return this.persistence.getTargetCache().getTargetCount(e).next((r=>t.next((s=>r+s))))}pr(e){let t=0;return this.mr(e,(r=>{t++})).next((()=>t))}mr(e,t){return D.forEach(this.fi,((r,s)=>this.wr(e,r,s).next((i=>i?D.resolve():t(s)))))}removeTargets(e,t,r){return this.persistence.getTargetCache().removeTargets(e,t,r)}removeOrphanedDocuments(e,t){let r=0;const s=this.persistence.getRemoteDocumentCache(),i=s.newChangeBuffer();return s.ni(e,(o=>this.wr(e,o,t).next((c=>{c||(r++,i.removeEntry(o,G.min()))})))).next((()=>i.apply(e))).next((()=>r))}markPotentiallyOrphaned(e,t){return this.fi.set(t,e.currentSequenceNumber),D.resolve()}removeTarget(e,t){const r=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,r)}addReference(e,t,r){return this.fi.set(r,e.currentSequenceNumber),D.resolve()}removeReference(e,t,r){return this.fi.set(r,e.currentSequenceNumber),D.resolve()}updateLimboDocument(e,t){return this.fi.set(t,e.currentSequenceNumber),D.resolve()}hi(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=co(e.data.value)),t}wr(e,t,r){return D.or([()=>this.persistence.Ei(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{const s=this.fi.get(t);return D.resolve(s!==void 0&&s>r)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}class Tu{constructor(e,t,r,s){this.targetId=e,this.fromCache=t,this.Ts=r,this.Is=s}static Es(e,t){let r=ee(),s=ee();for(const i of t.docChanges)switch(i.type){case 0:r=r.add(i.doc.key);break;case 1:s=s.add(i.doc.key)}return new Tu(e,t.fromCache,r,s)}}class ON{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}class VN{constructor(){this.Rs=!1,this.As=!1,this.Vs=100,this.ds=(function(){return e0()?8:sP(Pe())>0?6:4})()}initialize(e,t){this.fs=e,this.indexManager=t,this.Rs=!0}getDocumentsMatchingQuery(e,t,r,s){const i={result:null};return this.gs(e,t).next((o=>{i.result=o})).next((()=>{if(!i.result)return this.ps(e,t,s,r).next((o=>{i.result=o}))})).next((()=>{if(i.result)return;const o=new ON;return this.ys(e,t,o).next((c=>{if(i.result=c,this.As)return this.ws(e,t,o,c.size)}))})).next((()=>i.result))}ws(e,t,r,s){return r.documentReadCount<this.Vs?(Pr()<=X.DEBUG&&x("QueryEngine","SDK will not create cache indexes for query:",Nr(t),"since it only creates cache indexes for collection contains","more than or equal to",this.Vs,"documents"),D.resolve()):(Pr()<=X.DEBUG&&x("QueryEngine","Query:",Nr(t),"scans",r.documentReadCount,"local documents and returns",s,"documents as results."),r.documentReadCount>this.ds*s?(Pr()<=X.DEBUG&&x("QueryEngine","The SDK decides to create cache indexes for query:",Nr(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,Ct(t))):D.resolve())}gs(e,t){if(Rf(t))return D.resolve(null);let r=Ct(t);return this.indexManager.getIndexType(e,r).next((s=>s===0?null:(t.limit!==null&&s===1&&(t=Vo(t,null,"F"),r=Ct(t)),this.indexManager.getDocumentsMatchingTarget(e,r).next((i=>{const o=ee(...i);return this.fs.getDocuments(e,o).next((c=>this.indexManager.getMinOffset(e,r).next((l=>{const h=this.bs(t,c);return this.Ss(t,h,o,l.readTime)?this.gs(e,Vo(t,null,"F")):this.Ds(e,h,t,l)}))))})))))}ps(e,t,r,s){return Rf(t)||s.isEqual(G.min())?D.resolve(null):this.fs.getDocuments(e,r).next((i=>{const o=this.bs(t,i);return this.Ss(t,o,r,s)?D.resolve(null):(Pr()<=X.DEBUG&&x("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),Nr(t)),this.Ds(e,o,t,Zk(s,Zs)).next((c=>c)))}))}bs(e,t){let r=new _e(R_(e));return t.forEach(((s,i)=>{Ta(e,i)&&(r=r.add(i))})),r}Ss(e,t,r,s){if(e.limit===null)return!1;if(r.size!==t.size)return!0;const i=e.limitType==="F"?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(s)>0)}ys(e,t,r){return Pr()<=X.DEBUG&&x("QueryEngine","Using full collection scan to execute query:",Nr(t)),this.fs.getDocumentsMatchingQuery(e,t,In.min(),r)}Ds(e,t,r,s){return this.fs.getDocumentsMatchingQuery(e,r,s).next((i=>(t.forEach((o=>{i=i.insert(o.key,o)})),i)))}}const wu="LocalStore",LN=3e8;class MN{constructor(e,t,r,s){this.persistence=e,this.Cs=t,this.serializer=s,this.vs=new ce(Z),this.Fs=new fr((i=>du(i)),fu),this.Ms=new Map,this.xs=e.getRemoteDocumentCache(),this.li=e.getTargetCache(),this.Pi=e.getBundleCache(),this.Os(r)}Os(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new AN(this.xs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.xs.setIndexManager(this.indexManager),this.Cs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(t=>e.collect(t,this.vs)))}}function xN(n,e,t,r){return new MN(n,e,t,r)}async function X_(n,e){const t=Y(n);return await t.persistence.runTransaction("Handle user change","readonly",(r=>{let s;return t.mutationQueue.getAllMutationBatches(r).next((i=>(s=i,t.Os(e),t.mutationQueue.getAllMutationBatches(r)))).next((i=>{const o=[],c=[];let l=ee();for(const h of s){o.push(h.batchId);for(const f of h.mutations)l=l.add(f.key)}for(const h of i){c.push(h.batchId);for(const f of h.mutations)l=l.add(f.key)}return t.localDocuments.getDocuments(r,l).next((h=>({Ns:h,removedBatchIds:o,addedBatchIds:c})))}))}))}function FN(n,e){const t=Y(n);return t.persistence.runTransaction("Acknowledge batch","readwrite-primary",(r=>{const s=e.batch.keys(),i=t.xs.newChangeBuffer({trackRemovals:!0});return(function(c,l,h,f){const g=h.batch,_=g.keys();let T=D.resolve();return _.forEach((C=>{T=T.next((()=>f.getEntry(l,C))).next((P=>{const k=h.docVersions.get(C);ne(k!==null,48541),P.version.compareTo(k)<0&&(g.applyToRemoteDocument(P,h),P.isValidDocument()&&(P.setReadTime(h.commitVersion),f.addEntry(P)))}))})),T.next((()=>c.mutationQueue.removeMutationBatch(l,g)))})(t,r,e,i).next((()=>i.apply(r))).next((()=>t.mutationQueue.performConsistencyCheck(r))).next((()=>t.documentOverlayCache.removeOverlaysForBatchId(r,s,e.batch.batchId))).next((()=>t.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(r,(function(c){let l=ee();for(let h=0;h<c.mutationResults.length;++h)c.mutationResults[h].transformResults.length>0&&(l=l.add(c.batch.mutations[h].key));return l})(e)))).next((()=>t.localDocuments.getDocuments(r,s)))}))}function Z_(n){const e=Y(n);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(t=>e.li.getLastRemoteSnapshotVersion(t)))}function $N(n,e){const t=Y(n),r=e.snapshotVersion;let s=t.vs;return t.persistence.runTransaction("Apply remote event","readwrite-primary",(i=>{const o=t.xs.newChangeBuffer({trackRemovals:!0});s=t.vs;const c=[];e.targetChanges.forEach(((f,g)=>{const _=s.get(g);if(!_)return;c.push(t.li.removeMatchingKeys(i,f.removedDocuments,g).next((()=>t.li.addMatchingKeys(i,f.addedDocuments,g))));let T=_.withSequenceNumber(i.currentSequenceNumber);e.targetMismatches.get(g)!==null?T=T.withResumeToken(Ie.EMPTY_BYTE_STRING,G.min()).withLastLimboFreeSnapshotVersion(G.min()):f.resumeToken.approximateByteSize()>0&&(T=T.withResumeToken(f.resumeToken,r)),s=s.insert(g,T),(function(P,k,L){return P.resumeToken.approximateByteSize()===0||k.snapshotVersion.toMicroseconds()-P.snapshotVersion.toMicroseconds()>=LN?!0:L.addedDocuments.size+L.modifiedDocuments.size+L.removedDocuments.size>0})(_,T,f)&&c.push(t.li.updateTargetData(i,T))}));let l=Xt(),h=ee();if(e.documentUpdates.forEach((f=>{e.resolvedLimboDocuments.has(f)&&c.push(t.persistence.referenceDelegate.updateLimboDocument(i,f))})),c.push(UN(i,o,e.documentUpdates).next((f=>{l=f.Bs,h=f.Ls}))),!r.isEqual(G.min())){const f=t.li.getLastRemoteSnapshotVersion(i).next((g=>t.li.setTargetsMetadata(i,i.currentSequenceNumber,r)));c.push(f)}return D.waitFor(c).next((()=>o.apply(i))).next((()=>t.localDocuments.getLocalViewOfDocuments(i,l,h))).next((()=>l))})).then((i=>(t.vs=s,i)))}function UN(n,e,t){let r=ee(),s=ee();return t.forEach((i=>r=r.add(i))),e.getEntries(n,r).next((i=>{let o=Xt();return t.forEach(((c,l)=>{const h=i.get(c);l.isFoundDocument()!==h.isFoundDocument()&&(s=s.add(c)),l.isNoDocument()&&l.version.isEqual(G.min())?(e.removeEntry(c,l.readTime),o=o.insert(c,l)):!h.isValidDocument()||l.version.compareTo(h.version)>0||l.version.compareTo(h.version)===0&&h.hasPendingWrites?(e.addEntry(l),o=o.insert(c,l)):x(wu,"Ignoring outdated watch update for ",c,". Current version:",h.version," Watch version:",l.version)})),{Bs:o,Ls:s}}))}function BN(n,e){const t=Y(n);return t.persistence.runTransaction("Get next mutation batch","readonly",(r=>(e===void 0&&(e=lu),t.mutationQueue.getNextMutationBatchAfterBatchId(r,e))))}function qN(n,e){const t=Y(n);return t.persistence.runTransaction("Allocate target","readwrite",(r=>{let s;return t.li.getTargetData(r,e).next((i=>i?(s=i,D.resolve(s)):t.li.allocateTargetId(r).next((o=>(s=new yn(e,o,"TargetPurposeListen",r.currentSequenceNumber),t.li.addTargetData(r,s).next((()=>s)))))))})).then((r=>{const s=t.vs.get(r.targetId);return(s===null||r.snapshotVersion.compareTo(s.snapshotVersion)>0)&&(t.vs=t.vs.insert(r.targetId,r),t.Fs.set(e,r.targetId)),r}))}async function hl(n,e,t){const r=Y(n),s=r.vs.get(e),i=t?"readwrite":"readwrite-primary";try{t||await r.persistence.runTransaction("Release target",i,(o=>r.persistence.referenceDelegate.removeTarget(o,s)))}catch(o){if(!us(o))throw o;x(wu,`Failed to update sequence numbers for target ${e}: ${o}`)}r.vs=r.vs.remove(e),r.Fs.delete(s.target)}function Bf(n,e,t){const r=Y(n);let s=G.min(),i=ee();return r.persistence.runTransaction("Execute query","readwrite",(o=>(function(l,h,f){const g=Y(l),_=g.Fs.get(f);return _!==void 0?D.resolve(g.vs.get(_)):g.li.getTargetData(h,f)})(r,o,Ct(e)).next((c=>{if(c)return s=c.lastLimboFreeSnapshotVersion,r.li.getMatchingKeysForTargetId(o,c.targetId).next((l=>{i=l}))})).next((()=>r.Cs.getDocumentsMatchingQuery(o,e,t?s:G.min(),t?i:ee()))).next((c=>(jN(r,RP(e),c),{documents:c,ks:i})))))}function jN(n,e,t){let r=n.Ms.get(e)||G.min();t.forEach(((s,i)=>{i.readTime.compareTo(r)>0&&(r=i.readTime)})),n.Ms.set(e,r)}class qf{constructor(){this.activeTargetIds=VP()}Qs(e){this.activeTargetIds=this.activeTargetIds.add(e)}Gs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Ws(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class HN{constructor(){this.vo=new qf,this.Fo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,r){}addLocalQueryTarget(e,t=!0){return t&&this.vo.Qs(e),this.Fo[e]||"not-current"}updateQueryState(e,t,r){this.Fo[e]=t}removeLocalQueryTarget(e){this.vo.Gs(e)}isLocalQueryTarget(e){return this.vo.activeTargetIds.has(e)}clearQueryState(e){delete this.Fo[e]}getAllActiveQueryTargets(){return this.vo.activeTargetIds}isActiveQueryTarget(e){return this.vo.activeTargetIds.has(e)}start(){return this.vo=new qf,Promise.resolve()}handleUserChange(e,t,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}class WN{Mo(e){}shutdown(){}}const jf="ConnectivityMonitor";class Hf{constructor(){this.xo=()=>this.Oo(),this.No=()=>this.Bo(),this.Lo=[],this.ko()}Mo(e){this.Lo.push(e)}shutdown(){window.removeEventListener("online",this.xo),window.removeEventListener("offline",this.No)}ko(){window.addEventListener("online",this.xo),window.addEventListener("offline",this.No)}Oo(){x(jf,"Network connectivity changed: AVAILABLE");for(const e of this.Lo)e(0)}Bo(){x(jf,"Network connectivity changed: UNAVAILABLE");for(const e of this.Lo)e(1)}static v(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}let Xi=null;function dl(){return Xi===null?Xi=(function(){return 268435456+Math.round(2147483648*Math.random())})():Xi++,"0x"+Xi.toString(16)}const Sc="RestConnection",zN={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery",ExecutePipeline:"executePipeline"};class KN{get Ko(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.qo=t+"://"+e.host,this.Uo=`projects/${r}/databases/${s}`,this.$o=this.databaseId.database===No?`project_id=${r}`:`project_id=${r}&database_id=${s}`}Wo(e,t,r,s,i){const o=dl(),c=this.Qo(e,t.toUriEncodedString());x(Sc,`Sending RPC '${e}' ${o}:`,c,r);const l={"google-cloud-resource-prefix":this.Uo,"x-goog-request-params":this.$o};this.Go(l,s,i);const{host:h}=new URL(c),f=en(h);return this.zo(e,c,l,r,f).then((g=>(x(Sc,`Received RPC '${e}' ${o}: `,g),g)),(g=>{throw Yr(Sc,`RPC '${e}' ${o} failed with error: `,g,"url: ",c,"request:",r),g}))}jo(e,t,r,s,i,o){return this.Wo(e,t,r,s,i)}Go(e,t,r){e["X-Goog-Api-Client"]=(function(){return"gl-js/ fire/"+cs})(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach(((s,i)=>e[i]=s)),r&&r.headers.forEach(((s,i)=>e[i]=s))}Qo(e,t){const r=zN[e];let s=`${this.qo}/v1/${t}:${r}`;return this.databaseInfo.apiKey&&(s=`${s}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),s}terminate(){}}class GN{constructor(e){this.Ho=e.Ho,this.Jo=e.Jo}Zo(e){this.Xo=e}Yo(e){this.e_=e}t_(e){this.n_=e}onMessage(e){this.r_=e}close(){this.Jo()}send(e){this.Ho(e)}i_(){this.Xo()}s_(){this.e_()}o_(e){this.n_(e)}__(e){this.r_(e)}}const Se="WebChannelConnection",Ls=(n,e,t)=>{n.listen(e,(r=>{try{t(r)}catch(s){setTimeout((()=>{throw s}),0)}}))};class $r extends KN{constructor(e){super(e),this.a_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}static u_(){if(!$r.c_){const e=s_();Ls(e,r_.STAT_EVENT,(t=>{t.stat===Zc.PROXY?x(Se,"STAT_EVENT: detected buffering proxy"):t.stat===Zc.NOPROXY&&x(Se,"STAT_EVENT: detected no buffering proxy")})),$r.c_=!0}}zo(e,t,r,s,i){const o=dl();return new Promise(((c,l)=>{const h=new t_;h.setWithCredentials(!0),h.listenOnce(n_.COMPLETE,(()=>{try{switch(h.getLastErrorCode()){case ao.NO_ERROR:const g=h.getResponseJson();x(Se,`XHR for RPC '${e}' ${o} received:`,JSON.stringify(g)),c(g);break;case ao.TIMEOUT:x(Se,`RPC '${e}' ${o} timed out`),l(new M(N.DEADLINE_EXCEEDED,"Request time out"));break;case ao.HTTP_ERROR:const _=h.getStatus();if(x(Se,`RPC '${e}' ${o} failed with status:`,_,"response text:",h.getResponseText()),_>0){let T=h.getResponseJson();Array.isArray(T)&&(T=T[0]);const C=T?.error;if(C&&C.status&&C.message){const P=(function(L){const $=L.toLowerCase().replace(/_/g,"-");return Object.values(N).indexOf($)>=0?$:N.UNKNOWN})(C.status);l(new M(P,C.message))}else l(new M(N.UNKNOWN,"Server responded with status "+h.getStatus()))}else l(new M(N.UNAVAILABLE,"Connection failed."));break;default:W(9055,{l_:e,streamId:o,h_:h.getLastErrorCode(),P_:h.getLastError()})}}finally{x(Se,`RPC '${e}' ${o} completed.`)}}));const f=JSON.stringify(s);x(Se,`RPC '${e}' ${o} sending request:`,s),h.send(t,"POST",f,r,15)}))}T_(e,t,r){const s=dl(),i=[this.qo,"/","google.firestore.v1.Firestore","/",e,"/channel"],o=this.createWebChannelTransport(),c={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},l=this.longPollingOptions.timeoutSeconds;l!==void 0&&(c.longPollingTimeout=Math.round(1e3*l)),this.useFetchStreams&&(c.useFetchStreams=!0),this.Go(c.initMessageHeaders,t,r),c.encodeInitMessageHeaders=!0;const h=i.join("");x(Se,`Creating RPC '${e}' stream ${s}: ${h}`,c);const f=o.createWebChannel(h,c);this.I_(f);let g=!1,_=!1;const T=new GN({Ho:C=>{_?x(Se,`Not sending because RPC '${e}' stream ${s} is closed:`,C):(g||(x(Se,`Opening RPC '${e}' stream ${s} transport.`),f.open(),g=!0),x(Se,`RPC '${e}' stream ${s} sending:`,C),f.send(C))},Jo:()=>f.close()});return Ls(f,Ms.EventType.OPEN,(()=>{_||(x(Se,`RPC '${e}' stream ${s} transport opened.`),T.i_())})),Ls(f,Ms.EventType.CLOSE,(()=>{_||(_=!0,x(Se,`RPC '${e}' stream ${s} transport closed`),T.o_(),this.E_(f))})),Ls(f,Ms.EventType.ERROR,(C=>{_||(_=!0,Yr(Se,`RPC '${e}' stream ${s} transport errored. Name:`,C.name,"Message:",C.message),T.o_(new M(N.UNAVAILABLE,"The operation could not be completed")))})),Ls(f,Ms.EventType.MESSAGE,(C=>{if(!_){const P=C.data[0];ne(!!P,16349);const k=P,L=k?.error||k[0]?.error;if(L){x(Se,`RPC '${e}' stream ${s} received error:`,L);const $=L.status;let U=(function(H){const w=fe[H];if(w!==void 0)return $_(w)})($),F=L.message;U===void 0&&(U=N.INTERNAL,F="Unknown error status: "+$+" with message "+L.message),_=!0,T.o_(new M(U,F)),f.close()}else x(Se,`RPC '${e}' stream ${s} received:`,P),T.__(P)}})),$r.u_(),setTimeout((()=>{T.s_()}),0),T}terminate(){this.a_.forEach((e=>e.close())),this.a_=[]}I_(e){this.a_.push(e)}E_(e){this.a_=this.a_.filter((t=>t===e))}Go(e,t,r){super.Go(e,t,r),this.databaseInfo.apiKey&&(e["x-goog-api-key"]=this.databaseInfo.apiKey)}createWebChannelTransport(){return i_()}}function YN(n){return new $r(n)}function Cc(){return typeof document<"u"?document:null}function Ia(n){return new ZP(n,!0)}$r.c_=!1;class ey{constructor(e,t,r=1e3,s=1.5,i=6e4){this.Ci=e,this.timerId=t,this.R_=r,this.A_=s,this.V_=i,this.d_=0,this.m_=null,this.f_=Date.now(),this.reset()}reset(){this.d_=0}g_(){this.d_=this.V_}p_(e){this.cancel();const t=Math.floor(this.d_+this.y_()),r=Math.max(0,Date.now()-this.f_),s=Math.max(0,t-r);s>0&&x("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.d_} ms, delay with jitter: ${t} ms, last attempt: ${r} ms ago)`),this.m_=this.Ci.enqueueAfterDelay(this.timerId,s,(()=>(this.f_=Date.now(),e()))),this.d_*=this.A_,this.d_<this.R_&&(this.d_=this.R_),this.d_>this.V_&&(this.d_=this.V_)}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.d_}}const Wf="PersistentStream";class ty{constructor(e,t,r,s,i,o,c,l){this.Ci=e,this.b_=r,this.S_=s,this.connection=i,this.authCredentialsProvider=o,this.appCheckCredentialsProvider=c,this.listener=l,this.state=0,this.D_=0,this.C_=null,this.v_=null,this.stream=null,this.F_=0,this.M_=new ey(e,t)}x_(){return this.state===1||this.state===5||this.O_()}O_(){return this.state===2||this.state===3}start(){this.F_=0,this.state!==4?this.auth():this.N_()}async stop(){this.x_()&&await this.close(0)}B_(){this.state=0,this.M_.reset()}L_(){this.O_()&&this.C_===null&&(this.C_=this.Ci.enqueueAfterDelay(this.b_,6e4,(()=>this.k_())))}K_(e){this.q_(),this.stream.send(e)}async k_(){if(this.O_())return this.close(0)}q_(){this.C_&&(this.C_.cancel(),this.C_=null)}U_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(e,t){this.q_(),this.U_(),this.M_.cancel(),this.D_++,e!==4?this.M_.reset():t&&t.code===N.RESOURCE_EXHAUSTED?(Jt(t.toString()),Jt("Using maximum backoff delay to prevent overloading the backend."),this.M_.g_()):t&&t.code===N.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.W_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.t_(t)}W_(){}auth(){this.state=1;const e=this.Q_(this.D_),t=this.D_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([r,s])=>{this.D_===t&&this.G_(r,s)}),(r=>{e((()=>{const s=new M(N.UNKNOWN,"Fetching auth token failed: "+r.message);return this.z_(s)}))}))}G_(e,t){const r=this.Q_(this.D_);this.stream=this.j_(e,t),this.stream.Zo((()=>{r((()=>this.listener.Zo()))})),this.stream.Yo((()=>{r((()=>(this.state=2,this.v_=this.Ci.enqueueAfterDelay(this.S_,1e4,(()=>(this.O_()&&(this.state=3),Promise.resolve()))),this.listener.Yo())))})),this.stream.t_((s=>{r((()=>this.z_(s)))})),this.stream.onMessage((s=>{r((()=>++this.F_==1?this.H_(s):this.onNext(s)))}))}N_(){this.state=5,this.M_.p_((async()=>{this.state=0,this.start()}))}z_(e){return x(Wf,`close with error: ${e}`),this.stream=null,this.close(4,e)}Q_(e){return t=>{this.Ci.enqueueAndForget((()=>this.D_===e?t():(x(Wf,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class QN extends ty{constructor(e,t,r,s,i,o){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,r,s,o),this.serializer=i}j_(e,t){return this.connection.T_("Listen",e,t)}H_(e){return this.onNext(e)}onNext(e){this.M_.reset();const t=nN(this.serializer,e),r=(function(i){if(!("targetChange"in i))return G.min();const o=i.targetChange;return o.targetIds&&o.targetIds.length?G.min():o.readTime?Rt(o.readTime):G.min()})(e);return this.listener.J_(t,r)}Z_(e){const t={};t.database=ul(this.serializer),t.addTarget=(function(i,o){let c;const l=o.target;if(c=il(l)?{documents:iN(i,l)}:{query:oN(i,l).ft},c.targetId=o.targetId,o.resumeToken.approximateByteSize()>0){c.resumeToken=q_(i,o.resumeToken);const h=al(i,o.expectedCount);h!==null&&(c.expectedCount=h)}else if(o.snapshotVersion.compareTo(G.min())>0){c.readTime=xo(i,o.snapshotVersion.toTimestamp());const h=al(i,o.expectedCount);h!==null&&(c.expectedCount=h)}return c})(this.serializer,e);const r=cN(this.serializer,e);r&&(t.labels=r),this.K_(t)}X_(e){const t={};t.database=ul(this.serializer),t.removeTarget=e,this.K_(t)}}class JN extends ty{constructor(e,t,r,s,i,o){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,r,s,o),this.serializer=i}get Y_(){return this.F_>0}start(){this.lastStreamToken=void 0,super.start()}W_(){this.Y_&&this.ea([])}j_(e,t){return this.connection.T_("Write",e,t)}H_(e){return ne(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,ne(!e.writeResults||e.writeResults.length===0,55816),this.listener.ta()}onNext(e){ne(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.M_.reset();const t=sN(e.writeResults,e.commitTime),r=Rt(e.commitTime);return this.listener.na(r,t)}ra(){const e={};e.database=ul(this.serializer),this.K_(e)}ea(e){const t={streamToken:this.lastStreamToken,writes:e.map((r=>rN(this.serializer,r)))};this.K_(t)}}class XN{}class ZN extends XN{constructor(e,t,r,s){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer=s,this.ia=!1}sa(){if(this.ia)throw new M(N.FAILED_PRECONDITION,"The client has already been terminated.")}Wo(e,t,r,s){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([i,o])=>this.connection.Wo(e,cl(t,r),s,i,o))).catch((i=>{throw i.name==="FirebaseError"?(i.code===N.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),i):new M(N.UNKNOWN,i.toString())}))}jo(e,t,r,s,i){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([o,c])=>this.connection.jo(e,cl(t,r),s,o,c,i))).catch((o=>{throw o.name==="FirebaseError"?(o.code===N.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),o):new M(N.UNKNOWN,o.toString())}))}terminate(){this.ia=!0,this.connection.terminate()}}function eD(n,e,t,r){return new ZN(n,e,t,r)}class tD{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.oa=0,this._a=null,this.aa=!0}ua(){this.oa===0&&(this.ca("Unknown"),this._a=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=>(this._a=null,this.la("Backend didn't respond within 10 seconds."),this.ca("Offline"),Promise.resolve()))))}ha(e){this.state==="Online"?this.ca("Unknown"):(this.oa++,this.oa>=1&&(this.Pa(),this.la(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ca("Offline")))}set(e){this.Pa(),this.oa=0,e==="Online"&&(this.aa=!1),this.ca(e)}ca(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}la(e){const t=`Could not reach Cloud Firestore backend. ${e}
|
|
32
|
+
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.aa?(Jt(t),this.aa=!1):x("OnlineStateTracker",t)}Pa(){this._a!==null&&(this._a.cancel(),this._a=null)}}const ar="RemoteStore";class nD{constructor(e,t,r,s,i){this.localStore=e,this.datastore=t,this.asyncQueue=r,this.remoteSyncer={},this.Ta=[],this.Ia=new Map,this.Ea=new Set,this.Ra=[],this.Aa=i,this.Aa.Mo((o=>{r.enqueueAndForget((async()=>{pr(this)&&(x(ar,"Restarting streams for network reachability change."),await(async function(l){const h=Y(l);h.Ea.add(4),await Ti(h),h.Va.set("Unknown"),h.Ea.delete(4),await Sa(h)})(this))}))})),this.Va=new tD(r,s)}}async function Sa(n){if(pr(n))for(const e of n.Ra)await e(!0)}async function Ti(n){for(const e of n.Ra)await e(!1)}function ny(n,e){const t=Y(n);t.Ia.has(e.targetId)||(t.Ia.set(e.targetId,e),Su(t)?Iu(t):ds(t).O_()&&Au(t,e))}function bu(n,e){const t=Y(n),r=ds(t);t.Ia.delete(e),r.O_()&&ry(t,e),t.Ia.size===0&&(r.O_()?r.L_():pr(t)&&t.Va.set("Unknown"))}function Au(n,e){if(n.da.$e(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo(G.min())>0){const t=n.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;e=e.withExpectedCount(t)}ds(n).Z_(e)}function ry(n,e){n.da.$e(e),ds(n).X_(e)}function Iu(n){n.da=new YP({getRemoteKeysForTarget:e=>n.remoteSyncer.getRemoteKeysForTarget(e),At:e=>n.Ia.get(e)||null,ht:()=>n.datastore.serializer.databaseId}),ds(n).start(),n.Va.ua()}function Su(n){return pr(n)&&!ds(n).x_()&&n.Ia.size>0}function pr(n){return Y(n).Ea.size===0}function sy(n){n.da=void 0}async function rD(n){n.Va.set("Online")}async function sD(n){n.Ia.forEach(((e,t)=>{Au(n,e)}))}async function iD(n,e){sy(n),Su(n)?(n.Va.ha(e),Iu(n)):n.Va.set("Unknown")}async function oD(n,e,t){if(n.Va.set("Online"),e instanceof B_&&e.state===2&&e.cause)try{await(async function(s,i){const o=i.cause;for(const c of i.targetIds)s.Ia.has(c)&&(await s.remoteSyncer.rejectListen(c,o),s.Ia.delete(c),s.da.removeTarget(c))})(n,e)}catch(r){x(ar,"Failed to remove targets %s: %s ",e.targetIds.join(","),r),await $o(n,r)}else if(e instanceof ho?n.da.Xe(e):e instanceof U_?n.da.st(e):n.da.tt(e),!t.isEqual(G.min()))try{const r=await Z_(n.localStore);t.compareTo(r)>=0&&await(function(i,o){const c=i.da.Tt(o);return c.targetChanges.forEach(((l,h)=>{if(l.resumeToken.approximateByteSize()>0){const f=i.Ia.get(h);f&&i.Ia.set(h,f.withResumeToken(l.resumeToken,o))}})),c.targetMismatches.forEach(((l,h)=>{const f=i.Ia.get(l);if(!f)return;i.Ia.set(l,f.withResumeToken(Ie.EMPTY_BYTE_STRING,f.snapshotVersion)),ry(i,l);const g=new yn(f.target,l,h,f.sequenceNumber);Au(i,g)})),i.remoteSyncer.applyRemoteEvent(c)})(n,t)}catch(r){x(ar,"Failed to raise snapshot:",r),await $o(n,r)}}async function $o(n,e,t){if(!us(e))throw e;n.Ea.add(1),await Ti(n),n.Va.set("Offline"),t||(t=()=>Z_(n.localStore)),n.asyncQueue.enqueueRetryable((async()=>{x(ar,"Retrying IndexedDB access"),await t(),n.Ea.delete(1),await Sa(n)}))}function iy(n,e){return e().catch((t=>$o(n,t,e)))}async function Ca(n){const e=Y(n),t=kn(e);let r=e.Ta.length>0?e.Ta[e.Ta.length-1].batchId:lu;for(;aD(e);)try{const s=await BN(e.localStore,r);if(s===null){e.Ta.length===0&&t.L_();break}r=s.batchId,cD(e,s)}catch(s){await $o(e,s)}oy(e)&&ay(e)}function aD(n){return pr(n)&&n.Ta.length<10}function cD(n,e){n.Ta.push(e);const t=kn(n);t.O_()&&t.Y_&&t.ea(e.mutations)}function oy(n){return pr(n)&&!kn(n).x_()&&n.Ta.length>0}function ay(n){kn(n).start()}async function lD(n){kn(n).ra()}async function uD(n){const e=kn(n);for(const t of n.Ta)e.ea(t.mutations)}async function hD(n,e,t){const r=n.Ta.shift(),s=gu.from(r,e,t);await iy(n,(()=>n.remoteSyncer.applySuccessfulWrite(s))),await Ca(n)}async function dD(n,e){e&&kn(n).Y_&&await(async function(r,s){if((function(o){return zP(o)&&o!==N.ABORTED})(s.code)){const i=r.Ta.shift();kn(r).B_(),await iy(r,(()=>r.remoteSyncer.rejectFailedWrite(i.batchId,s))),await Ca(r)}})(n,e),oy(n)&&ay(n)}async function zf(n,e){const t=Y(n);t.asyncQueue.verifyOperationInProgress(),x(ar,"RemoteStore received new credentials");const r=pr(t);t.Ea.add(3),await Ti(t),r&&t.Va.set("Unknown"),await t.remoteSyncer.handleCredentialChange(e),t.Ea.delete(3),await Sa(t)}async function fD(n,e){const t=Y(n);e?(t.Ea.delete(2),await Sa(t)):e||(t.Ea.add(2),await Ti(t),t.Va.set("Unknown"))}function ds(n){return n.ma||(n.ma=(function(t,r,s){const i=Y(t);return i.sa(),new QN(r,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,s)})(n.datastore,n.asyncQueue,{Zo:rD.bind(null,n),Yo:sD.bind(null,n),t_:iD.bind(null,n),J_:oD.bind(null,n)}),n.Ra.push((async e=>{e?(n.ma.B_(),Su(n)?Iu(n):n.Va.set("Unknown")):(await n.ma.stop(),sy(n))}))),n.ma}function kn(n){return n.fa||(n.fa=(function(t,r,s){const i=Y(t);return i.sa(),new JN(r,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,s)})(n.datastore,n.asyncQueue,{Zo:()=>Promise.resolve(),Yo:lD.bind(null,n),t_:dD.bind(null,n),ta:uD.bind(null,n),na:hD.bind(null,n)}),n.Ra.push((async e=>{e?(n.fa.B_(),await Ca(n)):(await n.fa.stop(),n.Ta.length>0&&(x(ar,`Stopping write stream with ${n.Ta.length} pending writes`),n.Ta=[]))}))),n.fa}class Cu{constructor(e,t,r,s,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=r,this.op=s,this.removalCallback=i,this.deferred=new zt,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((o=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(e,t,r,s,i){const o=Date.now()+r,c=new Cu(e,t,o,s,i);return c.start(r),c}start(e){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new M(N.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)}}function Ru(n,e){if(Jt("AsyncQueue",`${e}: ${n}`),us(n))return new M(N.UNAVAILABLE,`${e}: ${n}`);throw n}class Ur{static emptySet(e){return new Ur(e.comparator)}constructor(e){this.comparator=e?(t,r)=>e(t,r)||B.comparator(t.key,r.key):(t,r)=>B.comparator(t.key,r.key),this.keyedMap=xs(),this.sortedSet=new ce(this.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal(((t,r)=>(e(t),!1)))}add(e){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){const t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof Ur)||this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();for(;t.hasNext();){const s=t.getNext().key,i=r.getNext().key;if(!s.isEqual(i))return!1}return!0}toString(){const e=[];return this.forEach((t=>{e.push(t.toString())})),e.length===0?"DocumentSet ()":`DocumentSet (
|
|
33
33
|
`+e.join(`
|
|
34
34
|
`)+`
|
|
35
|
-
)`}copy(e,t){const r=new Vn;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=t,r}}class qu{constructor(){this.ga=new re(M.comparator)}track(e){const t=e.doc.key,r=this.ga.get(t);r?e.type!==0&&r.type===3?this.ga=this.ga.insert(t,e):e.type===3&&r.type!==1?this.ga=this.ga.insert(t,{type:r.type,doc:e.doc}):e.type===2&&r.type===2?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):e.type===2&&r.type===0?this.ga=this.ga.insert(t,{type:0,doc:e.doc}):e.type===1&&r.type===0?this.ga=this.ga.remove(t):e.type===1&&r.type===2?this.ga=this.ga.insert(t,{type:1,doc:r.doc}):e.type===0&&r.type===1?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):x(63341,{Vt:e,pa:r}):this.ga=this.ga.insert(t,e)}ya(){const e=[];return this.ga.inorderTraversal(((t,r)=>{e.push(r)})),e}}class Bn{constructor(e,t,r,s,i,a,c,u,h){this.query=e,this.docs=t,this.oldDocs=r,this.docChanges=s,this.mutatedKeys=i,this.fromCache=a,this.syncStateChanged=c,this.excludesMetadataChanges=u,this.hasCachedResults=h}static fromInitialDocuments(e,t,r,s,i){const a=[];return t.forEach((c=>{a.push({type:0,doc:c})})),new Bn(e,t,Vn.emptySet(t),a,r,s,!0,!1,i)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&Ti(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,r=e.docChanges;if(t.length!==r.length)return!1;for(let s=0;s<t.length;s++)if(t[s].type!==r[s].type||!t[s].doc.isEqual(r[s].doc))return!1;return!0}}class CI{constructor(){this.wa=void 0,this.ba=[]}Sa(){return this.ba.some((e=>e.Da()))}}class kI{constructor(){this.queries=$u(),this.onlineState="Unknown",this.Ca=new Set}terminate(){(function(t,r){const s=q(t),i=s.queries;s.queries=$u(),i.forEach(((a,c)=>{for(const u of c.ba)u.onError(r)}))})(this,new O(P.ABORTED,"Firestore shutting down"))}}function $u(){return new Tn((n=>pf(n)),Ti)}async function Ya(n,e){const t=q(n);let r=3;const s=e.query;let i=t.queries.get(s);i?!i.Sa()&&e.Da()&&(r=2):(i=new CI,r=e.Da()?0:1);try{switch(r){case 0:i.wa=await t.onListen(s,!0);break;case 1:i.wa=await t.onListen(s,!1);break;case 2:await t.onFirstRemoteStoreListen(s)}}catch(a){const c=Ja(a,`Initialization of query '${bn(e.query)}' failed`);return void e.onError(c)}t.queries.set(s,i),i.ba.push(e),e.va(t.onlineState),i.wa&&e.Fa(i.wa)&&Za(t)}async function Xa(n,e){const t=q(n),r=e.query;let s=3;const i=t.queries.get(r);if(i){const a=i.ba.indexOf(e);a>=0&&(i.ba.splice(a,1),i.ba.length===0?s=e.Da()?0:1:!i.Sa()&&e.Da()&&(s=2))}switch(s){case 0:return t.queries.delete(r),t.onUnlisten(r,!0);case 1:return t.queries.delete(r),t.onUnlisten(r,!1);case 2:return t.onLastRemoteStoreUnlisten(r);default:return}}function NI(n,e){const t=q(n);let r=!1;for(const s of e){const i=s.query,a=t.queries.get(i);if(a){for(const c of a.ba)c.Fa(s)&&(r=!0);a.wa=s}}r&&Za(t)}function DI(n,e,t){const r=q(n),s=r.queries.get(e);if(s)for(const i of s.ba)i.onError(t);r.queries.delete(e)}function Za(n){n.Ca.forEach((e=>{e.next()}))}var Qo,ju;(ju=Qo||(Qo={})).Ma="default",ju.Cache="cache";class ec{constructor(e,t,r){this.query=e,this.xa=t,this.Oa=!1,this.Na=null,this.onlineState="Unknown",this.options=r||{}}Fa(e){if(!this.options.includeMetadataChanges){const r=[];for(const s of e.docChanges)s.type!==3&&r.push(s);e=new Bn(e.query,e.docs,e.oldDocs,r,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Oa?this.Ba(e)&&(this.xa.next(e),t=!0):this.La(e,this.onlineState)&&(this.ka(e),t=!0),this.Na=e,t}onError(e){this.xa.error(e)}va(e){this.onlineState=e;let t=!1;return this.Na&&!this.Oa&&this.La(this.Na,e)&&(this.ka(this.Na),t=!0),t}La(e,t){if(!e.fromCache||!this.Da())return!0;const r=t!=="Offline";return(!this.options.Ka||!r)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}Ba(e){if(e.docChanges.length>0)return!0;const t=this.Na&&this.Na.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}ka(e){e=Bn.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Oa=!0,this.xa.next(e)}Da(){return this.options.source!==Qo.Cache}}class Qf{constructor(e){this.key=e}}class Jf{constructor(e){this.key=e}}class VI{constructor(e,t){this.query=e,this.Za=t,this.Xa=null,this.hasCachedResults=!1,this.current=!1,this.Ya=K(),this.mutatedKeys=K(),this.eu=mf(e),this.tu=new Vn(this.eu)}get nu(){return this.Za}ru(e,t){const r=t?t.iu:new qu,s=t?t.tu:this.tu;let i=t?t.mutatedKeys:this.mutatedKeys,a=s,c=!1;const u=this.query.limitType==="F"&&s.size===this.query.limit?s.last():null,h=this.query.limitType==="L"&&s.size===this.query.limit?s.first():null;if(e.inorderTraversal(((f,m)=>{const y=s.get(f),S=wi(this.query,m)?m:null,k=!!y&&this.mutatedKeys.has(y.key),V=!!S&&(S.hasLocalMutations||this.mutatedKeys.has(S.key)&&S.hasCommittedMutations);let N=!1;y&&S?y.data.isEqual(S.data)?k!==V&&(r.track({type:3,doc:S}),N=!0):this.su(y,S)||(r.track({type:2,doc:S}),N=!0,(u&&this.eu(S,u)>0||h&&this.eu(S,h)<0)&&(c=!0)):!y&&S?(r.track({type:0,doc:S}),N=!0):y&&!S&&(r.track({type:1,doc:y}),N=!0,(u||h)&&(c=!0)),N&&(S?(a=a.add(S),i=V?i.add(f):i.delete(f)):(a=a.delete(f),i=i.delete(f)))})),this.query.limit!==null)for(;a.size>this.query.limit;){const f=this.query.limitType==="F"?a.last():a.first();a=a.delete(f.key),i=i.delete(f.key),r.track({type:1,doc:f})}return{tu:a,iu:r,Ss:c,mutatedKeys:i}}su(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,r,s){const i=this.tu;this.tu=e.tu,this.mutatedKeys=e.mutatedKeys;const a=e.iu.ya();a.sort(((f,m)=>(function(S,k){const V=N=>{switch(N){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return x(20277,{Vt:N})}};return V(S)-V(k)})(f.type,m.type)||this.eu(f.doc,m.doc))),this.ou(r),s=s??!1;const c=t&&!s?this._u():[],u=this.Ya.size===0&&this.current&&!s?1:0,h=u!==this.Xa;return this.Xa=u,a.length!==0||h?{snapshot:new Bn(this.query,e.tu,i,a,e.mutatedKeys,u===0,h,!1,!!r&&r.resumeToken.approximateByteSize()>0),au:c}:{au:c}}va(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({tu:this.tu,iu:new qu,mutatedKeys:this.mutatedKeys,Ss:!1},!1)):{au:[]}}uu(e){return!this.Za.has(e)&&!!this.tu.has(e)&&!this.tu.get(e).hasLocalMutations}ou(e){e&&(e.addedDocuments.forEach((t=>this.Za=this.Za.add(t))),e.modifiedDocuments.forEach((t=>{})),e.removedDocuments.forEach((t=>this.Za=this.Za.delete(t))),this.current=e.current)}_u(){if(!this.current)return[];const e=this.Ya;this.Ya=K(),this.tu.forEach((r=>{this.uu(r.key)&&(this.Ya=this.Ya.add(r.key))}));const t=[];return e.forEach((r=>{this.Ya.has(r)||t.push(new Jf(r))})),this.Ya.forEach((r=>{e.has(r)||t.push(new Qf(r))})),t}cu(e){this.Za=e.ks,this.Ya=K();const t=this.ru(e.documents);return this.applyChanges(t,!0)}lu(){return Bn.fromInitialDocuments(this.query,this.tu,this.mutatedKeys,this.Xa===0,this.hasCachedResults)}}const tc="SyncEngine";class OI{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}}class LI{constructor(e){this.key=e,this.hu=!1}}class MI{constructor(e,t,r,s,i,a){this.localStore=e,this.remoteStore=t,this.eventManager=r,this.sharedClientState=s,this.currentUser=i,this.maxConcurrentLimboResolutions=a,this.Pu={},this.Tu=new Tn((c=>pf(c)),Ti),this.Iu=new Map,this.Eu=new Set,this.Ru=new re(M.comparator),this.Au=new Map,this.Vu=new qa,this.du={},this.mu=new Map,this.fu=Un.ar(),this.onlineState="Unknown",this.gu=void 0}get isPrimaryClient(){return this.gu===!0}}async function xI(n,e,t=!0){const r=np(n);let s;const i=r.Tu.get(e);return i?(r.sharedClientState.addLocalQueryTarget(i.targetId),s=i.view.lu()):s=await Yf(r,e,t,!0),s}async function FI(n,e){const t=np(n);await Yf(t,e,!0,!1)}async function Yf(n,e,t,r){const s=await rI(n.localStore,st(e)),i=s.targetId,a=n.sharedClientState.addLocalQueryTarget(i,t);let c;return r&&(c=await UI(n,e,i,a==="current",s.resumeToken)),n.isPrimaryClient&&t&&jf(n.remoteStore,s),c}async function UI(n,e,t,r,s){n.pu=(m,y,S)=>(async function(V,N,$,W){let Q=N.view.ru($);Q.Ss&&(Q=await Lu(V.localStore,N.query,!1).then((({documents:v})=>N.view.ru(v,Q))));const te=W&&W.targetChanges.get(N.targetId),we=W&&W.targetMismatches.get(N.targetId)!=null,oe=N.view.applyChanges(Q,V.isPrimaryClient,te,we);return Hu(V,N.targetId,oe.au),oe.snapshot})(n,m,y,S);const i=await Lu(n.localStore,e,!0),a=new VI(e,i.ks),c=a.ru(i.documents),u=$r.createSynthesizedTargetChangeForCurrentChange(t,r&&n.onlineState!=="Offline",s),h=a.applyChanges(c,n.isPrimaryClient,u);Hu(n,t,h.au);const f=new OI(e,t,a);return n.Tu.set(e,f),n.Iu.has(t)?n.Iu.get(t).push(e):n.Iu.set(t,[e]),h.snapshot}async function BI(n,e,t){const r=q(n),s=r.Tu.get(e),i=r.Iu.get(s.targetId);if(i.length>1)return r.Iu.set(s.targetId,i.filter((a=>!Ti(a,e)))),void r.Tu.delete(e);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(s.targetId),r.sharedClientState.isActiveQueryTarget(s.targetId)||await Ko(r.localStore,s.targetId,!1).then((()=>{r.sharedClientState.clearQueryState(s.targetId),t&&Ha(r.remoteStore,s.targetId),Jo(r,s.targetId)})).catch(Hn)):(Jo(r,s.targetId),await Ko(r.localStore,s.targetId,!0))}async function qI(n,e){const t=q(n),r=t.Tu.get(e),s=t.Iu.get(r.targetId);t.isPrimaryClient&&s.length===1&&(t.sharedClientState.removeLocalQueryTarget(r.targetId),Ha(t.remoteStore,r.targetId))}async function $I(n,e,t){const r=QI(n);try{const s=await(function(a,c){const u=q(a),h=z.now(),f=c.reduce(((S,k)=>S.add(k.key)),K());let m,y;return u.persistence.runTransaction("Locally write mutations","readwrite",(S=>{let k=Et(),V=K();return u.xs.getEntries(S,f).next((N=>{k=N,k.forEach((($,W)=>{W.isValidDocument()||(V=V.add($))}))})).next((()=>u.localDocuments.getOverlayedDocuments(S,k))).next((N=>{m=N;const $=[];for(const W of c){const Q=nv(W,m.get(W.key).overlayedDocument);Q!=null&&$.push(new Qt(W.key,Q,of(Q.value.mapValue),Je.exists(!0)))}return u.mutationQueue.addMutationBatch(S,h,$,c)})).next((N=>{y=N;const $=N.applyToLocalDocumentSet(m,V);return u.documentOverlayCache.saveOverlays(S,N.batchId,$)}))})).then((()=>({batchId:y.batchId,changes:_f(m)})))})(r.localStore,e);r.sharedClientState.addPendingMutation(s.batchId),(function(a,c,u){let h=a.du[a.currentUser.toKey()];h||(h=new re(G)),h=h.insert(c,u),a.du[a.currentUser.toKey()]=h})(r,s.batchId,t),await zr(r,s.changes),await Si(r.remoteStore)}catch(s){const i=Ja(s,"Failed to persist write");t.reject(i)}}async function Xf(n,e){const t=q(n);try{const r=await eI(t.localStore,e);e.targetChanges.forEach(((s,i)=>{const a=t.Au.get(i);a&&(Y(s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size<=1,22616),s.addedDocuments.size>0?a.hu=!0:s.modifiedDocuments.size>0?Y(a.hu,14607):s.removedDocuments.size>0&&(Y(a.hu,42227),a.hu=!1))})),await zr(t,r,e)}catch(r){await Hn(r)}}function zu(n,e,t){const r=q(n);if(r.isPrimaryClient&&t===0||!r.isPrimaryClient&&t===1){const s=[];r.Tu.forEach(((i,a)=>{const c=a.view.va(e);c.snapshot&&s.push(c.snapshot)})),(function(a,c){const u=q(a);u.onlineState=c;let h=!1;u.queries.forEach(((f,m)=>{for(const y of m.ba)y.va(c)&&(h=!0)})),h&&Za(u)})(r.eventManager,e),s.length&&r.Pu.J_(s),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}async function jI(n,e,t){const r=q(n);r.sharedClientState.updateQueryState(e,"rejected",t);const s=r.Au.get(e),i=s&&s.key;if(i){let a=new re(M.comparator);a=a.insert(i,Ae.newNoDocument(i,B.min()));const c=K().add(i),u=new Ii(B.min(),new Map,new re(G),a,c);await Xf(r,u),r.Ru=r.Ru.remove(i),r.Au.delete(e),nc(r)}else await Ko(r.localStore,e,!1).then((()=>Jo(r,e,t))).catch(Hn)}async function zI(n,e){const t=q(n),r=e.batch.batchId;try{const s=await Zv(t.localStore,e);ep(t,r,null),Zf(t,r),t.sharedClientState.updateMutationState(r,"acknowledged"),await zr(t,s)}catch(s){await Hn(s)}}async function HI(n,e,t){const r=q(n);try{const s=await(function(a,c){const u=q(a);return u.persistence.runTransaction("Reject batch","readwrite-primary",(h=>{let f;return u.mutationQueue.lookupMutationBatch(h,c).next((m=>(Y(m!==null,37113),f=m.keys(),u.mutationQueue.removeMutationBatch(h,m)))).next((()=>u.mutationQueue.performConsistencyCheck(h))).next((()=>u.documentOverlayCache.removeOverlaysForBatchId(h,f,c))).next((()=>u.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(h,f))).next((()=>u.localDocuments.getDocuments(h,f)))}))})(r.localStore,e);ep(r,e,t),Zf(r,e),r.sharedClientState.updateMutationState(e,"rejected",t),await zr(r,s)}catch(s){await Hn(s)}}function Zf(n,e){(n.mu.get(e)||[]).forEach((t=>{t.resolve()})),n.mu.delete(e)}function ep(n,e,t){const r=q(n);let s=r.du[r.currentUser.toKey()];if(s){const i=s.get(e);i&&(t?i.reject(t):i.resolve(),s=s.remove(e)),r.du[r.currentUser.toKey()]=s}}function Jo(n,e,t=null){n.sharedClientState.removeLocalQueryTarget(e);for(const r of n.Iu.get(e))n.Tu.delete(r),t&&n.Pu.yu(r,t);n.Iu.delete(e),n.isPrimaryClient&&n.Vu.Gr(e).forEach((r=>{n.Vu.containsKey(r)||tp(n,r)}))}function tp(n,e){n.Eu.delete(e.path.canonicalString());const t=n.Ru.get(e);t!==null&&(Ha(n.remoteStore,t),n.Ru=n.Ru.remove(e),n.Au.delete(t),nc(n))}function Hu(n,e,t){for(const r of t)r instanceof Qf?(n.Vu.addReference(r.key,e),GI(n,r)):r instanceof Jf?(L(tc,"Document no longer in limbo: "+r.key),n.Vu.removeReference(r.key,e),n.Vu.containsKey(r.key)||tp(n,r.key)):x(19791,{wu:r})}function GI(n,e){const t=e.key,r=t.path.canonicalString();n.Ru.get(t)||n.Eu.has(r)||(L(tc,"New document in limbo: "+t),n.Eu.add(r),nc(n))}function nc(n){for(;n.Eu.size>0&&n.Ru.size<n.maxConcurrentLimboResolutions;){const e=n.Eu.values().next().value;n.Eu.delete(e);const t=new M(Z.fromString(e)),r=n.fu.next();n.Au.set(r,new LI(t)),n.Ru=n.Ru.insert(t,r),jf(n.remoteStore,new Lt(st(yi(t.path)),r,"TargetPurposeLimboResolution",mi.ce))}}async function zr(n,e,t){const r=q(n),s=[],i=[],a=[];r.Tu.isEmpty()||(r.Tu.forEach(((c,u)=>{a.push(r.pu(u,e,t).then((h=>{if((h||t)&&r.isPrimaryClient){const f=h?!h.fromCache:t?.targetChanges.get(u.targetId)?.current;r.sharedClientState.updateQueryState(u.targetId,f?"current":"not-current")}if(h){s.push(h);const f=ja.Es(u.targetId,h);i.push(f)}})))})),await Promise.all(a),r.Pu.J_(s),await(async function(u,h){const f=q(u);try{await f.persistence.runTransaction("notifyLocalViewChanges","readwrite",(m=>C.forEach(h,(y=>C.forEach(y.Ts,(S=>f.persistence.referenceDelegate.addReference(m,y.targetId,S))).next((()=>C.forEach(y.Is,(S=>f.persistence.referenceDelegate.removeReference(m,y.targetId,S)))))))))}catch(m){if(!Gn(m))throw m;L(za,"Failed to update sequence numbers: "+m)}for(const m of h){const y=m.targetId;if(!m.fromCache){const S=f.vs.get(y),k=S.snapshotVersion,V=S.withLastLimboFreeSnapshotVersion(k);f.vs=f.vs.insert(y,V)}}})(r.localStore,i))}async function KI(n,e){const t=q(n);if(!t.currentUser.isEqual(e)){L(tc,"User change. New user:",e.toKey());const r=await Uf(t.localStore,e);t.currentUser=e,(function(i,a){i.mu.forEach((c=>{c.forEach((u=>{u.reject(new O(P.CANCELLED,a))}))})),i.mu.clear()})(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,r.removedBatchIds,r.addedBatchIds),await zr(t,r.Ns)}}function WI(n,e){const t=q(n),r=t.Au.get(e);if(r&&r.hu)return K().add(r.key);{let s=K();const i=t.Iu.get(e);if(!i)return s;for(const a of i){const c=t.Tu.get(a);s=s.unionWith(c.view.nu)}return s}}function np(n){const e=q(n);return e.remoteStore.remoteSyncer.applyRemoteEvent=Xf.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=WI.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=jI.bind(null,e),e.Pu.J_=NI.bind(null,e.eventManager),e.Pu.yu=DI.bind(null,e.eventManager),e}function QI(n){const e=q(n);return e.remoteStore.remoteSyncer.applySuccessfulWrite=zI.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=HI.bind(null,e),e}class Gs{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=Ai(e.databaseInfo.databaseId),this.sharedClientState=this.Du(e),this.persistence=this.Cu(e),await this.persistence.start(),this.localStore=this.vu(e),this.gcScheduler=this.Fu(e,this.localStore),this.indexBackfillerScheduler=this.Mu(e,this.localStore)}Fu(e,t){return null}Mu(e,t){return null}vu(e){return Xv(this.persistence,new Qv,e.initialUser,this.serializer)}Cu(e){return new Ff($a.Vi,this.serializer)}Du(e){return new iI}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}Gs.provider={build:()=>new Gs};class JI extends Gs{constructor(e){super(),this.cacheSizeBytes=e}Fu(e,t){Y(this.persistence.referenceDelegate instanceof zs,46915);const r=this.persistence.referenceDelegate.garbageCollector;return new Ov(r,e.asyncQueue,t)}Cu(e){const t=this.cacheSizeBytes!==void 0?Ve.withCacheSize(this.cacheSizeBytes):Ve.DEFAULT;return new Ff((r=>zs.Vi(r,t)),this.serializer)}}class Yo{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=r=>zu(this.syncEngine,r,1),this.remoteStore.remoteSyncer.handleCredentialChange=KI.bind(null,this.syncEngine),await PI(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return(function(){return new kI})()}createDatastore(e){const t=Ai(e.databaseInfo.databaseId),r=uI(e.databaseInfo);return mI(e.authCredentials,e.appCheckCredentials,r,t)}createRemoteStore(e){return(function(r,s,i,a,c){return new _I(r,s,i,a,c)})(this.localStore,this.datastore,e.asyncQueue,(t=>zu(this.syncEngine,t,0)),(function(){return Fu.v()?new Fu:new oI})())}createSyncEngine(e,t){return(function(s,i,a,c,u,h,f){const m=new MI(s,i,a,c,u,h);return f&&(m.gu=!0),m})(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){await(async function(t){const r=q(t);L(mn,"RemoteStore shutting down."),r.Ea.add(5),await jr(r),r.Aa.shutdown(),r.Va.set("Unknown")})(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}}Yo.provider={build:()=>new Yo};class rc{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ou(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ou(this.observer.error,e):wt("Uncaught Error in snapshot listener:",e.toString()))}Nu(){this.muted=!0}Ou(e,t){setTimeout((()=>{this.muted||e(t)}),0)}}const Ht="FirestoreClient";class YI{constructor(e,t,r,s,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=r,this._databaseInfo=s,this.user=Ie.UNAUTHENTICATED,this.clientId=ka.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(r,(async a=>{L(Ht,"Received user=",a.uid),await this.authCredentialListener(a),this.user=a})),this.appCheckCredentials.start(r,(a=>(L(Ht,"Received new app check token=",a),this.appCheckCredentialListener(a,this.user))))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this._databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();const e=new _t;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){const r=Ja(t,"Failed to shutdown persistence");e.reject(r)}})),e.promise}}async function yo(n,e){n.asyncQueue.verifyOperationInProgress(),L(Ht,"Initializing OfflineComponentProvider");const t=n.configuration;await e.initialize(t);let r=t.initialUser;n.setCredentialChangeListener((async s=>{r.isEqual(s)||(await Uf(e.localStore,s),r=s)})),e.persistence.setDatabaseDeletedListener((()=>n.terminate())),n._offlineComponents=e}async function Gu(n,e){n.asyncQueue.verifyOperationInProgress();const t=await XI(n);L(Ht,"Initializing OnlineComponentProvider"),await e.initialize(t,n.configuration),n.setCredentialChangeListener((r=>Bu(e.remoteStore,r))),n.setAppCheckTokenChangeListener(((r,s)=>Bu(e.remoteStore,s))),n._onlineComponents=e}async function XI(n){if(!n._offlineComponents)if(n._uninitializedComponentsProvider){L(Ht,"Using user provided OfflineComponentProvider");try{await yo(n,n._uninitializedComponentsProvider._offline)}catch(e){const t=e;if(!(function(s){return s.name==="FirebaseError"?s.code===P.FAILED_PRECONDITION||s.code===P.UNIMPLEMENTED:!(typeof DOMException<"u"&&s instanceof DOMException)||s.code===22||s.code===20||s.code===11})(t))throw t;Ln("Error using user provided cache. Falling back to memory cache: "+t),await yo(n,new Gs)}}else L(Ht,"Using default OfflineComponentProvider"),await yo(n,new JI(void 0));return n._offlineComponents}async function rp(n){return n._onlineComponents||(n._uninitializedComponentsProvider?(L(Ht,"Using user provided OnlineComponentProvider"),await Gu(n,n._uninitializedComponentsProvider._online)):(L(Ht,"Using default OnlineComponentProvider"),await Gu(n,new Yo))),n._onlineComponents}function ZI(n){return rp(n).then((e=>e.syncEngine))}async function Ks(n){const e=await rp(n),t=e.eventManager;return t.onListen=xI.bind(null,e.syncEngine),t.onUnlisten=BI.bind(null,e.syncEngine),t.onFirstRemoteStoreListen=FI.bind(null,e.syncEngine),t.onLastRemoteStoreUnlisten=qI.bind(null,e.syncEngine),t}function eA(n,e,t,r){const s=new rc(r),i=new ec(e,s,t);return n.asyncQueue.enqueueAndForget((async()=>Ya(await Ks(n),i))),()=>{s.Nu(),n.asyncQueue.enqueueAndForget((async()=>Xa(await Ks(n),i)))}}function tA(n,e,t={}){const r=new _t;return n.asyncQueue.enqueueAndForget((async()=>(function(i,a,c,u,h){const f=new rc({next:y=>{f.Nu(),a.enqueueAndForget((()=>Xa(i,m)));const S=y.docs.has(c);!S&&y.fromCache?h.reject(new O(P.UNAVAILABLE,"Failed to get document because the client is offline.")):S&&y.fromCache&&u&&u.source==="server"?h.reject(new O(P.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):h.resolve(y)},error:y=>h.reject(y)}),m=new ec(yi(c.path),f,{includeMetadataChanges:!0,Ka:!0});return Ya(i,m)})(await Ks(n),n.asyncQueue,e,t,r))),r.promise}function nA(n,e,t={}){const r=new _t;return n.asyncQueue.enqueueAndForget((async()=>(function(i,a,c,u,h){const f=new rc({next:y=>{f.Nu(),a.enqueueAndForget((()=>Xa(i,m))),y.fromCache&&u.source==="server"?h.reject(new O(P.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):h.resolve(y)},error:y=>h.reject(y)}),m=new ec(c,f,{includeMetadataChanges:!0,Ka:!0});return Ya(i,m)})(await Ks(n),n.asyncQueue,e,t,r))),r.promise}function rA(n,e){const t=new _t;return n.asyncQueue.enqueueAndForget((async()=>$I(await ZI(n),e,t))),t.promise}function sp(n){const e={};return n.timeoutSeconds!==void 0&&(e.timeoutSeconds=n.timeoutSeconds),e}const sA="ComponentProvider",Ku=new Map;function iA(n,e,t,r,s){return new AE(n,e,t,s.host,s.ssl,s.experimentalForceLongPolling,s.experimentalAutoDetectLongPolling,sp(s.experimentalLongPollingOptions),s.useFetchStreams,s.isUsingEmulator,r)}const ip="firestore.googleapis.com",Wu=!0;class Qu{constructor(e){if(e.host===void 0){if(e.ssl!==void 0)throw new O(P.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=ip,this.ssl=Wu}else this.host=e.host,this.ssl=e.ssl??Wu;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=xf;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<Dv)throw new O(P.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}dE("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=sp(e.experimentalLongPollingOptions??{}),(function(r){if(r.timeoutSeconds!==void 0){if(isNaN(r.timeoutSeconds))throw new O(P.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (must not be NaN)`);if(r.timeoutSeconds<5)throw new O(P.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (minimum allowed value is 5)`);if(r.timeoutSeconds>30)throw new O(P.INVALID_ARGUMENT,`invalid long polling timeout: ${r.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(r,s){return r.timeoutSeconds===s.timeoutSeconds})(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class Ri{constructor(e,t,r,s){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=r,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Qu({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new O(P.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 O(P.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 Qu(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=(function(r){if(!r)return new nE;switch(r.type){case"firstParty":return new oE(r.sessionIndex||"0",r.iamToken||null,r.authTokenFactory||null);case"provider":return r.client;default:throw new O(P.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}})(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return(function(t){const r=Ku.get(t);r&&(L(sA,"Removing Datastore"),Ku.delete(t),r.terminate())})(this),Promise.resolve()}}function op(n,e,t,r={}){n=qe(n,Ri);const s=vt(e),i=n._getSettings(),a={...i,emulatorOptions:n._getEmulatorOptions()},c=`${e}:${t}`;s&&(ii(`https://${c}`),oi("Firestore",!0)),i.host!==ip&&i.host!==c&&Ln("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");const u={...i,host:c,ssl:s,emulatorOptions:r};if(!Ut(u,a)&&(n._setSettings(u),r.mockUserToken)){let h,f;if(typeof r.mockUserToken=="string")h=r.mockUserToken,f=Ie.MOCK_USER;else{h=Oh(r.mockUserToken,n._app?.options.projectId);const m=r.mockUserToken.sub||r.mockUserToken.user_id;if(!m)throw new O(P.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");f=new Ie(m)}n._authCredentials=new rE(new Kd(h,f))}}class It{constructor(e,t,r){this.converter=t,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new It(this.firestore,e,this._query)}}class ie{constructor(e,t,r){this.converter=t,this._key=r,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new Ft(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new ie(this.firestore,e,this._key)}toJSON(){return{type:ie._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,r){if(Br(t,ie._jsonSchema))return new ie(e,r||null,new M(Z.fromString(t.referencePath)))}}ie._jsonSchemaVersion="firestore/documentReference/1.0",ie._jsonSchema={type:ue("string",ie._jsonSchemaVersion),referencePath:ue("string")};class Ft extends It{constructor(e,t,r){super(e,t,yi(r)),this._path=r,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 ie(this.firestore,null,new M(e))}withConverter(e){return new Ft(this.firestore,e,this._path)}}function oA(n,e,...t){if(n=ee(n),Wd("collection","path",e),n instanceof Ri){const r=Z.fromString(e,...t);return cu(r),new Ft(n,null,r)}{if(!(n instanceof ie||n instanceof Ft))throw new O(P.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(Z.fromString(e,...t));return cu(r),new Ft(n.firestore,null,r)}}function Ir(n,e,...t){if(n=ee(n),arguments.length===1&&(e=ka.newId()),Wd("doc","path",e),n instanceof Ri){const r=Z.fromString(e,...t);return au(r),new ie(n,null,new M(r))}{if(!(n instanceof ie||n instanceof Ft))throw new O(P.INVALID_ARGUMENT,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(Z.fromString(e,...t));return au(r),new ie(n.firestore,n instanceof Ft?n.converter:null,new M(r))}}const Ju="AsyncQueue";class Yu{constructor(e=Promise.resolve()){this.Yu=[],this.ec=!1,this.tc=[],this.nc=null,this.rc=!1,this.sc=!1,this.oc=[],this.M_=new qf(this,"async_queue_retry"),this._c=()=>{const r=_o();r&&L(Ju,"Visibility state changed to "+r.visibilityState),this.M_.w_()},this.ac=e;const t=_o();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=_o();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this._c)}}enqueue(e){if(this.uc(),this.ec)return new Promise((()=>{}));const t=new _t;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.Yu.push(e),this.lc())))}async lc(){if(this.Yu.length!==0){try{await this.Yu[0](),this.Yu.shift(),this.M_.reset()}catch(e){if(!Gn(e))throw e;L(Ju,"Operation failed with retryable error: "+e)}this.Yu.length>0&&this.M_.p_((()=>this.lc()))}}cc(e){const t=this.ac.then((()=>(this.rc=!0,e().catch((r=>{throw this.nc=r,this.rc=!1,wt("INTERNAL UNHANDLED ERROR: ",Xu(r)),r})).then((r=>(this.rc=!1,r))))));return this.ac=t,t}enqueueAfterDelay(e,t,r){this.uc(),this.oc.indexOf(e)>-1&&(t=0);const s=Qa.createAndSchedule(this,e,t,r,(i=>this.hc(i)));return this.tc.push(s),s}uc(){this.nc&&x(47125,{Pc:Xu(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,r)=>t.targetTimeMs-r.targetTimeMs));for(const t of this.tc)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.Tc()}))}Rc(e){this.oc.push(e)}hc(e){const t=this.tc.indexOf(e);this.tc.splice(t,1)}}function Xu(n){let e=n.message||"";return n.stack&&(e=n.stack.includes(n.message)?n.stack:n.message+`
|
|
36
|
-
`+n.stack),e}class Gt extends Ri{constructor(e,t,r,s){super(e,t,r,s),this.type="firestore",this._queue=new Yu,this._persistenceKey=s?.name||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new Yu(e),this._firestoreClient=void 0,await e}}}function aA(n,e){const t=typeof n=="object"?n:$n(),r=typeof n=="string"?n:xs,s=ut(t,"firestore").getImmediate({identifier:r});if(!s._initialized){const i=la("firestore");i&&op(s,...i)}return s}function Pi(n){if(n._terminated)throw new O(P.FAILED_PRECONDITION,"The client has already been terminated.");return n._firestoreClient||cA(n),n._firestoreClient}function cA(n){const e=n._freezeSettings(),t=iA(n._databaseId,n._app?.options.appId||"",n._persistenceKey,n._app?.options.apiKey,e);n._componentsProvider||e.localCache?._offlineComponentProvider&&e.localCache?._onlineComponentProvider&&(n._componentsProvider={_offline:e.localCache._offlineComponentProvider,_online:e.localCache._onlineComponentProvider}),n._firestoreClient=new YI(n._authCredentials,n._appCheckCredentials,n._queue,t,n._componentsProvider&&(function(s){const i=s?._online.build();return{_offline:s?._offline.build(i),_online:i}})(n._componentsProvider))}class ze{constructor(e){this._byteString=e}static fromBase64String(e){try{return new ze(Te.fromBase64String(e))}catch(t){throw new O(P.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new ze(Te.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:ze._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(Br(e,ze._jsonSchema))return ze.fromBase64String(e.bytes)}}ze._jsonSchemaVersion="firestore/bytes/1.0",ze._jsonSchema={type:ue("string",ze._jsonSchemaVersion),bytes:ue("string")};class Ci{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new O(P.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new ye(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}function Xo(){return new Ci(xo)}class Or{constructor(e){this._methodName=e}}class ot{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new O(P.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new O(P.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 G(this._lat,e._lat)||G(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:ot._jsonSchemaVersion}}static fromJSON(e){if(Br(e,ot._jsonSchema))return new ot(e.latitude,e.longitude)}}ot._jsonSchemaVersion="firestore/geoPoint/1.0",ot._jsonSchema={type:ue("string",ot._jsonSchemaVersion),latitude:ue("number"),longitude:ue("number")};class Ye{constructor(e){this._values=(e||[]).map((t=>t))}toArray(){return this._values.map((e=>e))}isEqual(e){return(function(r,s){if(r.length!==s.length)return!1;for(let i=0;i<r.length;++i)if(r[i]!==s[i])return!1;return!0})(this._values,e._values)}toJSON(){return{type:Ye._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(Br(e,Ye._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every((t=>typeof t=="number")))return new Ye(e.vectorValues);throw new O(P.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}Ye._jsonSchemaVersion="firestore/vectorValue/1.0",Ye._jsonSchema={type:ue("string",Ye._jsonSchemaVersion),vectorValues:ue("object")};const lA=/^__.*__$/;class uA{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return this.fieldMask!==null?new Qt(e,this.data,this.fieldMask,t,this.fieldTransforms):new qr(e,this.data,t,this.fieldTransforms)}}class ap{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return new Qt(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function cp(n){switch(n){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw x(40011,{dataSource:n})}}class sc{constructor(e,t,r,s,i,a){this.settings=e,this.databaseId=t,this.serializer=r,this.ignoreUndefinedProperties=s,i===void 0&&this.validatePath(),this.fieldTransforms=i||[],this.fieldMask=a||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}contextWith(e){return new sc({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}childContextForField(e){const t=this.path?.child(e),r=this.contextWith({path:t,arrayElement:!1});return r.validatePathSegment(e),r}childContextForFieldPath(e){const t=this.path?.child(e),r=this.contextWith({path:t,arrayElement:!1});return r.validatePath(),r}childContextForArray(e){return this.contextWith({path:void 0,arrayElement:!0})}createError(e){return Ws(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return this.fieldMask.find((t=>e.isPrefixOf(t)))!==void 0||this.fieldTransforms.find((t=>e.isPrefixOf(t.field)))!==void 0}validatePath(){if(this.path)for(let e=0;e<this.path.length;e++)this.validatePathSegment(this.path.get(e))}validatePathSegment(e){if(e.length===0)throw this.createError("Document fields must not be empty");if(cp(this.dataSource)&&lA.test(e))throw this.createError('Document fields cannot begin and end with "__"')}}class hA{constructor(e,t,r){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=r||Ai(e)}createContext(e,t,r,s=!1){return new sc({dataSource:e,methodName:t,targetDoc:r,path:ye.emptyPath(),arrayElement:!1,hasConverter:s},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function ic(n){const e=n._freezeSettings(),t=Ai(n._databaseId);return new hA(n._databaseId,!!e.ignoreUndefinedProperties,t)}function dA(n,e,t,r,s,i={}){const a=n.createContext(i.merge||i.mergeFields?2:0,e,t,s);oc("Data must be an object, but it was:",a,r);const c=lp(r,a);let u,h;if(i.merge)u=new Ue(a.fieldMask),h=a.fieldTransforms;else if(i.mergeFields){const f=[];for(const m of i.mergeFields){const y=gn(e,m,t);if(!a.contains(y))throw new O(P.INVALID_ARGUMENT,`Field '${y}' is specified in your field mask but missing from your input data.`);dp(f,y)||f.push(y)}u=new Ue(f),h=a.fieldTransforms.filter((m=>u.covers(m.field)))}else u=null,h=a.fieldTransforms;return new uA(new Oe(c),u,h)}class Hr extends Or{_toFieldTransform(e){if(e.dataSource!==2)throw e.dataSource===1?e.createError(`${this._methodName}() can only appear at the top level of your update data`):e.createError(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof Hr}}function fA(n,e,t,r){const s=n.createContext(1,e,t);oc("Data must be an object, but it was:",s,r);const i=[],a=Oe.empty();Wt(r,((u,h)=>{const f=hp(e,u,t);h=ee(h);const m=s.childContextForFieldPath(f);if(h instanceof Hr)i.push(f);else{const y=Gr(h,m);y!=null&&(i.push(f),a.set(f,y))}}));const c=new Ue(i);return new ap(a,c,s.fieldTransforms)}function pA(n,e,t,r,s,i){const a=n.createContext(1,e,t),c=[gn(e,r,t)],u=[s];if(i.length%2!=0)throw new O(P.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let y=0;y<i.length;y+=2)c.push(gn(e,i[y])),u.push(i[y+1]);const h=[],f=Oe.empty();for(let y=c.length-1;y>=0;--y)if(!dp(h,c[y])){const S=c[y];let k=u[y];k=ee(k);const V=a.childContextForFieldPath(S);if(k instanceof Hr)h.push(S);else{const N=Gr(k,V);N!=null&&(h.push(S),f.set(S,N))}}const m=new Ue(h);return new ap(f,m,a.fieldTransforms)}function mA(n,e,t,r=!1){return Gr(t,n.createContext(r?4:3,e))}function Gr(n,e){if(up(n=ee(n)))return oc("Unsupported field value:",e,n),lp(n,e);if(n instanceof Or)return(function(r,s){if(!cp(s.dataSource))throw s.createError(`${r._methodName}() can only be used with update() and set()`);if(!s.path)throw s.createError(`${r._methodName}() is not currently supported inside arrays`);const i=r._toFieldTransform(s);i&&s.fieldTransforms.push(i)})(n,e),null;if(n===void 0&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),n instanceof Array){if(e.settings.arrayElement&&e.dataSource!==4)throw e.createError("Nested arrays are not supported");return(function(r,s){const i=[];let a=0;for(const c of r){let u=Gr(c,s.childContextForArray(a));u==null&&(u={nullValue:"NULL_VALUE"}),i.push(u),a++}return{arrayValue:{values:i}}})(n,e)}return(function(r,s){if((r=ee(r))===null)return{nullValue:"NULL_VALUE"};if(typeof r=="number")return JE(s.serializer,r);if(typeof r=="boolean")return{booleanValue:r};if(typeof r=="string")return{stringValue:r};if(r instanceof Date){const i=z.fromDate(r);return{timestampValue:js(s.serializer,i)}}if(r instanceof z){const i=new z(r.seconds,1e3*Math.floor(r.nanoseconds/1e3));return{timestampValue:js(s.serializer,i)}}if(r instanceof ot)return{geoPointValue:{latitude:r.latitude,longitude:r.longitude}};if(r instanceof ze)return{bytesValue:Cf(s.serializer,r._byteString)};if(r instanceof ie){const i=s.databaseId,a=r.firestore._databaseId;if(!a.isEqual(i))throw s.createError(`Document reference is for database ${a.projectId}/${a.database} but should be for database ${i.projectId}/${i.database}`);return{referenceValue:Ba(r.firestore._databaseId||s.databaseId,r._key.path)}}if(r instanceof Ye)return(function(a,c){const u=a instanceof Ye?a.toArray():a;return{mapValue:{fields:{[rf]:{stringValue:sf},[Fs]:{arrayValue:{values:u.map((f=>{if(typeof f!="number")throw c.createError("VectorValues must only contain numeric values.");return Ma(c.serializer,f)}))}}}}}})(r,s);if(Mf(r))return r._toProto(s.serializer);throw s.createError(`Unsupported field value: ${pi(r)}`)})(n,e)}function lp(n,e){const t={};return Yd(n)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):Wt(n,((r,s)=>{const i=Gr(s,e.childContextForField(r));i!=null&&(t[r]=i)})),{mapValue:{fields:t}}}function up(n){return!(typeof n!="object"||n===null||n instanceof Array||n instanceof Date||n instanceof z||n instanceof ot||n instanceof ze||n instanceof ie||n instanceof Or||n instanceof Ye||Mf(n))}function oc(n,e,t){if(!up(t)||!Qd(t)){const r=pi(t);throw r==="an object"?e.createError(n+" a custom object"):e.createError(n+" "+r)}}function gn(n,e,t){if((e=ee(e))instanceof Ci)return e._internalPath;if(typeof e=="string")return hp(n,e);throw Ws("Field path arguments must be of type string or ",n,!1,void 0,t)}const gA=new RegExp("[~\\*/\\[\\]]");function hp(n,e,t){if(e.search(gA)>=0)throw Ws(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,n,!1,void 0,t);try{return new Ci(...e.split("."))._internalPath}catch{throw Ws(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,n,!1,void 0,t)}}function Ws(n,e,t,r,s){const i=r&&!r.isEmpty(),a=s!==void 0;let c=`Function ${e}() called with invalid data`;t&&(c+=" (via `toFirestore()`)"),c+=". ";let u="";return(i||a)&&(u+=" (found",i&&(u+=` in field ${r}`),a&&(u+=` in document ${s}`),u+=")"),new O(P.INVALID_ARGUMENT,c+n+u)}function dp(n,e){return n.some((t=>t.isEqual(e)))}class _A{convertValue(e,t="none"){switch(jt(e)){case 0:return null;case 1:return e.booleanValue;case 2:return ae(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes($t(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw x(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const r={};return Wt(e,((s,i)=>{r[s]=this.convertValue(i,t)})),r}convertVectorValue(e){const t=e.fields?.[Fs].arrayValue?.values?.map((r=>ae(r.doubleValue)));return new Ye(t)}convertGeoPoint(e){return new ot(ae(e.latitude),ae(e.longitude))}convertArray(e,t){return(e.values||[]).map((r=>this.convertValue(r,t)))}convertServerTimestamp(e,t){switch(t){case"previous":const r=_i(e);return r==null?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(Pr(e));default:return null}}convertTimestamp(e){const t=qt(e);return new z(t.seconds,t.nanos)}convertDocumentKey(e,t){const r=Z.fromString(e);Y(Lf(r),9688,{name:e});const s=new Cr(r.get(1),r.get(3)),i=new M(r.popFirst(5));return s.isEqual(t)||wt(`Document ${i} contains a document reference within a different database (${s.projectId}/${s.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),i}}class ac extends _A{constructor(e){super(),this.firestore=e}convertBytes(e){return new ze(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new ie(this.firestore,null,t)}}function Zo(){return new Hr("deleteField")}const Zu="@firebase/firestore",eh="4.10.0";function th(n){return(function(t,r){if(typeof t!="object"||t===null)return!1;const s=t;for(const i of r)if(i in s&&typeof s[i]=="function")return!0;return!1})(n,["next","error","complete"])}class fp{constructor(e,t,r,s,i){this._firestore=e,this._userDataWriter=t,this._key=r,this._document=s,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new ie(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new yA(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){return this._document?.data.clone().value.mapValue.fields??void 0}get(e){if(this._document){const t=this._document.data.field(gn("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}}class yA extends fp{data(){return super.data()}}function pp(n){if(n.limitType==="L"&&n.explicitOrderBy.length===0)throw new O(P.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class cc{}class lc extends cc{}function nh(n,e,...t){let r=[];e instanceof cc&&r.push(e),r=r.concat(t),(function(i){const a=i.filter((u=>u instanceof uc)).length,c=i.filter((u=>u instanceof ki)).length;if(a>1||a>0&&c>0)throw new O(P.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")})(r);for(const s of r)n=s._apply(n);return n}class ki extends lc{constructor(e,t,r){super(),this._field=e,this._op=t,this._value=r,this.type="where"}static _create(e,t,r){return new ki(e,t,r)}_apply(e){const t=this._parse(e);return mp(e._query,t),new It(e.firestore,e.converter,$o(e._query,t))}_parse(e){const t=ic(e.firestore);return(function(i,a,c,u,h,f,m){let y;if(h.isKeyField()){if(f==="array-contains"||f==="array-contains-any")throw new O(P.INVALID_ARGUMENT,`Invalid Query. You can't perform '${f}' queries on documentId().`);if(f==="in"||f==="not-in"){sh(m,f);const k=[];for(const V of m)k.push(rh(u,i,V));y={arrayValue:{values:k}}}else y=rh(u,i,m)}else f!=="in"&&f!=="not-in"&&f!=="array-contains-any"||sh(m,f),y=mA(c,a,m,f==="in"||f==="not-in");return le.create(h,f,y)})(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value)}}function ea(n,e,t){const r=e,s=gn("where",n);return ki._create(s,r,t)}class uc extends cc{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new uc(e,t)}_parse(e){const t=this._queryConstraints.map((r=>r._parse(e))).filter((r=>r.getFilters().length>0));return t.length===1?t[0]:Xe.create(t,this._getOperator())}_apply(e){const t=this._parse(e);return t.getFilters().length===0?e:((function(s,i){let a=s;const c=i.getFlattenedFilters();for(const u of c)mp(a,u),a=$o(a,u)})(e._query,t),new It(e.firestore,e.converter,$o(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}class hc extends lc{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new hc(e,t)}_apply(e){const t=(function(s,i,a){if(s.startAt!==null)throw new O(P.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(s.endAt!==null)throw new O(P.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new Nr(i,a)})(e._query,this._field,this._direction);return new It(e.firestore,e.converter,$E(e._query,t))}}function To(n,e="asc"){const t=e,r=gn("orderBy",n);return hc._create(r,t)}class dc extends lc{constructor(e,t,r){super(),this.type=e,this._limit=t,this._limitType=r}static _create(e,t,r){return new dc(e,t,r)}_apply(e){return new It(e.firestore,e.converter,Bs(e._query,this._limit,this._limitType))}}function wo(n){return fE("limit",n),dc._create("limit",n,"F")}function rh(n,e,t){if(typeof(t=ee(t))=="string"){if(t==="")throw new O(P.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!ff(e)&&t.indexOf("/")!==-1)throw new O(P.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${t}' contains a '/' character.`);const r=e.path.child(Z.fromString(t));if(!M.isDocumentKey(r))throw new O(P.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return gu(n,new M(r))}if(t instanceof ie)return gu(n,t._key);throw new O(P.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${pi(t)}.`)}function sh(n,e){if(!Array.isArray(n)||n.length===0)throw new O(P.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`)}function mp(n,e){const t=(function(s,i){for(const a of s)for(const c of a.getFlattenedFilters())if(i.indexOf(c.op)>=0)return c.op;return null})(n.filters,(function(s){switch(s){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}})(e.op));if(t!==null)throw t===e.op?new O(P.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new O(P.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${t.toString()}' filters.`)}function TA(n,e,t){let r;return r=n?t&&(t.merge||t.mergeFields)?n.toFirestore(e,t):n.toFirestore(e):e,r}class mr{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class cn extends fp{constructor(e,t,r,s,i,a){super(e,t,r,s,a),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new As(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 r=this._document.data.field(gn("DocumentSnapshot.get",e));if(r!==null)return this._userDataWriter.convertValue(r,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new O(P.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=cn._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)}}cn._jsonSchemaVersion="firestore/documentSnapshot/1.0",cn._jsonSchema={type:ue("string",cn._jsonSchemaVersion),bundleSource:ue("string","DocumentSnapshot"),bundleName:ue("string"),bundle:ue("string")};class As extends cn{data(e={}){return super.data(e)}}class ln{constructor(e,t,r,s){this._firestore=e,this._userDataWriter=t,this._snapshot=s,this.metadata=new mr(s.hasPendingWrites,s.fromCache),this.query=r}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((r=>{e.call(t,new As(this._firestore,this._userDataWriter,r.key,r,new mr(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new O(P.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,i){if(s._snapshot.oldDocs.isEmpty()){let a=0;return s._snapshot.docChanges.map((c=>{const u=new As(s._firestore,s._userDataWriter,c.doc.key,c.doc,new mr(s._snapshot.mutatedKeys.has(c.doc.key),s._snapshot.fromCache),s.query.converter);return c.doc,{type:"added",doc:u,oldIndex:-1,newIndex:a++}}))}{let a=s._snapshot.oldDocs;return s._snapshot.docChanges.filter((c=>i||c.type!==3)).map((c=>{const u=new As(s._firestore,s._userDataWriter,c.doc.key,c.doc,new mr(s._snapshot.mutatedKeys.has(c.doc.key),s._snapshot.fromCache),s.query.converter);let h=-1,f=-1;return c.type!==0&&(h=a.indexOf(c.doc.key),a=a.delete(c.doc.key)),c.type!==1&&(a=a.add(c.doc),f=a.indexOf(c.doc.key)),{type:wA(c.type),doc:u,oldIndex:h,newIndex:f}}))}})(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new O(P.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e={};e.type=ln._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=ka.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const t=[],r=[],s=[];return this.docs.forEach((i=>{i._document!==null&&(t.push(i._document),r.push(this._userDataWriter.convertObjectMap(i._document.data.value.mapValue.fields,"previous")),s.push(i.ref.path))})),e.bundle=(this._firestore,this.query._query,e.bundleName,"NOT SUPPORTED"),e}}function wA(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return x(61501,{type:n})}}ln._jsonSchemaVersion="firestore/querySnapshot/1.0",ln._jsonSchema={type:ue("string",ln._jsonSchemaVersion),bundleSource:ue("string","QuerySnapshot"),bundleName:ue("string"),bundle:ue("string")};function ta(n){n=qe(n,ie);const e=qe(n.firestore,Gt),t=Pi(e);return tA(t,n._key).then((r=>_p(e,n,r)))}function EA(n){n=qe(n,It);const e=qe(n.firestore,Gt),t=Pi(e),r=new ac(e);return pp(n._query),nA(t,n._query).then((s=>new ln(e,r,n,s)))}function gp(n,e,t){n=qe(n,ie);const r=qe(n.firestore,Gt),s=TA(n.converter,e,t),i=ic(r);return fc(r,[dA(i,"setDoc",n._key,s,n.converter!==null,t).toMutation(n._key,Je.none())])}function vA(n,e,t,...r){n=qe(n,ie);const s=qe(n.firestore,Gt),i=ic(s);let a;return a=typeof(e=ee(e))=="string"||e instanceof Ci?pA(i,"updateDoc",n._key,e,t,r):fA(i,"updateDoc",n._key,e),fc(s,[a.toMutation(n._key,Je.exists(!0))])}function IA(n){return fc(qe(n.firestore,Gt),[new xa(n._key,Je.none())])}function AA(n,...e){n=ee(n);let t={includeMetadataChanges:!1,source:"default"},r=0;typeof e[r]!="object"||th(e[r])||(t=e[r++]);const s={includeMetadataChanges:t.includeMetadataChanges,source:t.source};if(th(e[r])){const h=e[r];e[r]=h.next?.bind(h),e[r+1]=h.error?.bind(h),e[r+2]=h.complete?.bind(h)}let i,a,c;if(n instanceof ie)a=qe(n.firestore,Gt),c=yi(n._key.path),i={next:h=>{e[r]&&e[r](_p(a,n,h))},error:e[r+1],complete:e[r+2]};else{const h=qe(n,It);a=qe(h.firestore,Gt),c=h._query;const f=new ac(a);i={next:m=>{e[r]&&e[r](new ln(a,f,h,m))},error:e[r+1],complete:e[r+2]},pp(n._query)}const u=Pi(a);return eA(u,c,s,i)}function fc(n,e){const t=Pi(n);return rA(t,e)}function _p(n,e,t){const r=t.docs.get(e._key),s=new ac(n);return new cn(n,s,e._key,r,new mr(t.hasPendingWrites,t.fromCache),e.converter)}(function(e,t=!0){tE(yn),Me(new Ne("firestore",((r,{instanceIdentifier:s,options:i})=>{const a=r.getProvider("app").getImmediate(),c=new Gt(new sE(r.getProvider("auth-internal")),new aE(a,r.getProvider("app-check-internal")),bE(a,s),a);return i={useFetchStreams:t,...i},c._setSettings(i),c}),"PUBLIC").setMultipleInstances(!0)),me(Zu,eh,e),me(Zu,eh,"esm2020")})();const yp="firebasestorage.googleapis.com",bA="storageBucket",SA=120*1e3,RA=600*1e3;class ht extends $e{constructor(e,t,r=0){super(Eo(e),`Firebase Storage: ${t} (${Eo(e)})`),this.status_=r,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,ht.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return Eo(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}
|
|
37
|
-
${this.customData.serverResponse}`:this.message=this._baseMessage}}var lt;(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"})(lt||(lt={}));function Eo(n){return"storage/"+n}function PA(){const n="An unknown error occurred, please check the error payload for server response.";return new ht(lt.UNKNOWN,n)}function CA(){return new ht(lt.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function kA(){return new ht(lt.CANCELED,"User canceled the upload/download.")}function NA(n){return new ht(lt.INVALID_URL,"Invalid URL '"+n+"'.")}function DA(n){return new ht(lt.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+n+"'.")}function ih(n){return new ht(lt.INVALID_ARGUMENT,n)}function Tp(){return new ht(lt.APP_DELETED,"The Firebase app was deleted.")}function VA(n){return new ht(lt.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 We{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 r;try{r=We.makeFromUrl(e,t)}catch{return new We(e,"")}if(r.path==="")return r;throw DA(e)}static makeFromUrl(e,t){let r=null;const s="([A-Za-z0-9.\\-_]+)";function i(te){te.path.charAt(te.path.length-1)==="/"&&(te.path_=te.path_.slice(0,-1))}const a="(/(.*))?$",c=new RegExp("^gs://"+s+a,"i"),u={bucket:1,path:3};function h(te){te.path_=decodeURIComponent(te.path)}const f="v[A-Za-z0-9_]+",m=t.replace(/[.]/g,"\\."),y="(/([^?#]*).*)?$",S=new RegExp(`^https?://${m}/${f}/b/${s}/o${y}`,"i"),k={bucket:1,path:3},V=t===yp?"(?:storage.googleapis.com|storage.cloud.google.com)":t,N="([^?#]*)",$=new RegExp(`^https?://${V}/${s}/${N}`,"i"),Q=[{regex:c,indices:u,postModify:i},{regex:S,indices:k,postModify:h},{regex:$,indices:{bucket:1,path:2},postModify:h}];for(let te=0;te<Q.length;te++){const we=Q[te],oe=we.regex.exec(e);if(oe){const v=oe[we.indices.bucket];let g=oe[we.indices.path];g||(g=""),r=new We(v,g),we.postModify(r);break}}if(r==null)throw NA(e);return r}}class OA{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}}function LA(n,e,t){let r=1,s=null,i=null,a=!1,c=0;function u(){return c===2}let h=!1;function f(...N){h||(h=!0,e.apply(null,N))}function m(N){s=setTimeout(()=>{s=null,n(S,u())},N)}function y(){i&&clearTimeout(i)}function S(N,...$){if(h){y();return}if(N){y(),f.call(null,N,...$);return}if(u()||a){y(),f.call(null,N,...$);return}r<64&&(r*=2);let Q;c===1?(c=2,Q=0):Q=(r+Math.random())*1e3,m(Q)}let k=!1;function V(N){k||(k=!0,y(),!h&&(s!==null?(N||(c=2),clearTimeout(s),m(0)):N||(c=1)))}return m(0),i=setTimeout(()=>{a=!0,V(!0)},t),V}function MA(n){n(!1)}function xA(n){return n!==void 0}function oh(n,e,t,r){if(r<e)throw ih(`Invalid value for '${n}'. Expected ${e} or greater.`);if(r>t)throw ih(`Invalid value for '${n}'. Expected ${t} or less.`)}function FA(n){const e=encodeURIComponent;let t="?";for(const r in n)if(n.hasOwnProperty(r)){const s=e(r)+"="+e(n[r]);t=t+s+"&"}return t=t.slice(0,-1),t}var Qs;(function(n){n[n.NO_ERROR=0]="NO_ERROR",n[n.NETWORK_ERROR=1]="NETWORK_ERROR",n[n.ABORT=2]="ABORT"})(Qs||(Qs={}));function UA(n,e){const t=n>=500&&n<600,s=[408,429].indexOf(n)!==-1,i=e.indexOf(n)!==-1;return t||s||i}class BA{constructor(e,t,r,s,i,a,c,u,h,f,m,y=!0,S=!1){this.url_=e,this.method_=t,this.headers_=r,this.body_=s,this.successCodes_=i,this.additionalRetryCodes_=a,this.callback_=c,this.errorCallback_=u,this.timeout_=h,this.progressCallback_=f,this.connectionFactory_=m,this.retry=y,this.isUsingEmulator=S,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((k,V)=>{this.resolve_=k,this.reject_=V,this.start_()})}start_(){const e=(r,s)=>{if(s){r(!1,new ps(!1,null,!0));return}const i=this.connectionFactory_();this.pendingConnection_=i;const a=c=>{const u=c.loaded,h=c.lengthComputable?c.total:-1;this.progressCallback_!==null&&this.progressCallback_(u,h)};this.progressCallback_!==null&&i.addUploadProgressListener(a),i.send(this.url_,this.method_,this.isUsingEmulator,this.body_,this.headers_).then(()=>{this.progressCallback_!==null&&i.removeUploadProgressListener(a),this.pendingConnection_=null;const c=i.getErrorCode()===Qs.NO_ERROR,u=i.getStatus();if(!c||UA(u,this.additionalRetryCodes_)&&this.retry){const f=i.getErrorCode()===Qs.ABORT;r(!1,new ps(!1,null,f));return}const h=this.successCodes_.indexOf(u)!==-1;r(!0,new ps(h,i))})},t=(r,s)=>{const i=this.resolve_,a=this.reject_,c=s.connection;if(s.wasSuccessCode)try{const u=this.callback_(c,c.getResponse());xA(u)?i(u):i()}catch(u){a(u)}else if(c!==null){const u=PA();u.serverResponse=c.getErrorText(),this.errorCallback_?a(this.errorCallback_(c,u)):a(u)}else if(s.canceled){const u=this.appDelete_?Tp():kA();a(u)}else{const u=CA();a(u)}};this.canceled_?t(!1,new ps(!1,null,!0)):this.backoffId_=LA(e,t,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&MA(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}}class ps{constructor(e,t,r){this.wasSuccessCode=e,this.connection=t,this.canceled=!!r}}function qA(n,e){e!==null&&e.length>0&&(n.Authorization="Firebase "+e)}function $A(n,e){n["X-Firebase-Storage-Version"]="webjs/"+(e??"AppManager")}function jA(n,e){e&&(n["X-Firebase-GMPID"]=e)}function zA(n,e){e!==null&&(n["X-Firebase-AppCheck"]=e)}function HA(n,e,t,r,s,i,a=!0,c=!1){const u=FA(n.urlParams),h=n.url+u,f=Object.assign({},n.headers);return jA(f,e),qA(f,t),$A(f,i),zA(f,r),new BA(h,n.method,f,n.body,n.successCodes,n.additionalRetryCodes,n.handler,n.errorHandler,n.timeout,n.progressCallback,s,a,c)}function GA(n){if(n.length===0)return null;const e=n.lastIndexOf("/");return e===-1?"":n.slice(0,e)}function KA(n){const e=n.lastIndexOf("/",n.length-2);return e===-1?n:n.slice(e+1)}class Js{constructor(e,t){this._service=e,t instanceof We?this._location=t:this._location=We.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new Js(e,t)}get root(){const e=new We(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return KA(this._location.path)}get storage(){return this._service}get parent(){const e=GA(this._location.path);if(e===null)return null;const t=new We(this._location.bucket,e);return new Js(this._service,t)}_throwIfRoot(e){if(this._location.path==="")throw VA(e)}}function ah(n,e){const t=e?.[bA];return t==null?null:We.makeFromBucketSpec(t,n)}function WA(n,e,t,r={}){n.host=`${e}:${t}`;const s=vt(e);s&&(ii(`https://${n.host}/b`),oi("Storage",!0)),n._isUsingEmulator=!0,n._protocol=s?"https":"http";const{mockUserToken:i}=r;i&&(n._overrideAuthToken=typeof i=="string"?i:Oh(i,n.app.options.projectId))}class QA{constructor(e,t,r,s,i,a=!1){this.app=e,this._authProvider=t,this._appCheckProvider=r,this._url=s,this._firebaseVersion=i,this._isUsingEmulator=a,this._bucket=null,this._host=yp,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=SA,this._maxUploadRetryTime=RA,this._requests=new Set,s!=null?this._bucket=We.makeFromBucketSpec(s,this._host):this._bucket=ah(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,this._url!=null?this._bucket=We.makeFromBucketSpec(this._url,e):this._bucket=ah(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){oh("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){oh("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(Fe(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 Js(this,e)}_makeRequest(e,t,r,s,i=!0){if(this._deleted)return new OA(Tp());{const a=HA(e,this._appId,r,s,t,this._firebaseVersion,i,this._isUsingEmulator);return this._requests.add(a),a.getPromise().then(()=>this._requests.delete(a),()=>this._requests.delete(a)),a}}async makeRequestWithTokens(e,t){const[r,s]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,r,s).getPromise()}}const ch="@firebase/storage",lh="0.14.0";const wp="storage";function JA(n=$n(),e){n=ee(n);const r=ut(n,wp).getImmediate({identifier:e}),s=la("storage");return s&&Ep(r,...s),r}function Ep(n,e,t,r={}){WA(n,e,t,r)}function YA(n,{instanceIdentifier:e}){const t=n.getProvider("app").getImmediate(),r=n.getProvider("auth-internal"),s=n.getProvider("app-check-internal");return new QA(t,r,s,e,yn)}function XA(){Me(new Ne(wp,YA,"PUBLIC").setMultipleInstances(!0)),me(ch,lh,""),me(ch,lh,"esm2020")}XA();const ZA="type.googleapis.com/google.protobuf.Int64Value",e0="type.googleapis.com/google.protobuf.UInt64Value";function vp(n,e){const t={};for(const r in n)n.hasOwnProperty(r)&&(t[r]=e(n[r]));return t}function Ys(n){if(n==null)return null;if(n instanceof Number&&(n=n.valueOf()),typeof n=="number"&&isFinite(n)||n===!0||n===!1||Object.prototype.toString.call(n)==="[object String]")return n;if(n instanceof Date)return n.toISOString();if(Array.isArray(n))return n.map(e=>Ys(e));if(typeof n=="function"||typeof n=="object")return vp(n,e=>Ys(e));throw new Error("Data cannot be encoded in JSON: "+n)}function qn(n){if(n==null)return n;if(n["@type"])switch(n["@type"]){case ZA:case e0:{const e=Number(n.value);if(isNaN(e))throw new Error("Data cannot be decoded from JSON: "+n);return e}default:throw new Error("Data cannot be decoded from JSON: "+n)}return Array.isArray(n)?n.map(e=>qn(e)):typeof n=="function"||typeof n=="object"?vp(n,e=>qn(e)):n}const pc="functions";const uh={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class Le extends $e{constructor(e,t,r){super(`${pc}/${e}`,t||""),this.details=r,Object.setPrototypeOf(this,Le.prototype)}}function t0(n){if(n>=200&&n<300)return"ok";switch(n){case 0:return"internal";case 400:return"invalid-argument";case 401:return"unauthenticated";case 403:return"permission-denied";case 404:return"not-found";case 409:return"aborted";case 429:return"resource-exhausted";case 499:return"cancelled";case 500:return"internal";case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline-exceeded"}return"unknown"}function Xs(n,e){let t=t0(n),r=t,s;try{const i=e&&e.error;if(i){const a=i.status;if(typeof a=="string"){if(!uh[a])return new Le("internal","internal");t=uh[a],r=a}const c=i.message;typeof c=="string"&&(r=c),s=i.details,s!==void 0&&(s=qn(s))}}catch{}return t==="ok"?null:new Le(t,r,s)}class n0{constructor(e,t,r,s){this.app=e,this.auth=null,this.messaging=null,this.appCheck=null,this.serverAppAppCheckToken=null,Fe(e)&&e.settings.appCheckToken&&(this.serverAppAppCheckToken=e.settings.appCheckToken),this.auth=t.getImmediate({optional:!0}),this.messaging=r.getImmediate({optional:!0}),this.auth||t.get().then(i=>this.auth=i,()=>{}),this.messaging||r.get().then(i=>this.messaging=i,()=>{}),this.appCheck||s?.get().then(i=>this.appCheck=i,()=>{})}async getAuthToken(){if(this.auth)try{return(await this.auth.getToken())?.accessToken}catch{return}}async getMessagingToken(){if(!(!this.messaging||!("Notification"in self)||Notification.permission!=="granted"))try{return await this.messaging.getToken()}catch{return}}async getAppCheckToken(e){if(this.serverAppAppCheckToken)return this.serverAppAppCheckToken;if(this.appCheck){const t=e?await this.appCheck.getLimitedUseToken():await this.appCheck.getToken();return t.error?null:t.token}return null}async getContext(e){const t=await this.getAuthToken(),r=await this.getMessagingToken(),s=await this.getAppCheckToken(e);return{authToken:t,messagingToken:r,appCheckToken:s}}}const na="us-central1",r0=/^data: (.*?)(?:\n|$)/;function s0(n){let e=null;return{promise:new Promise((t,r)=>{e=setTimeout(()=>{r(new Le("deadline-exceeded","deadline-exceeded"))},n)}),cancel:()=>{e&&clearTimeout(e)}}}class i0{constructor(e,t,r,s,i=na,a=(...c)=>fetch(...c)){this.app=e,this.fetchImpl=a,this.emulatorOrigin=null,this.contextProvider=new n0(e,t,r,s),this.cancelAllRequests=new Promise(c=>{this.deleteService=()=>Promise.resolve(c())});try{const c=new URL(i);this.customDomain=c.origin+(c.pathname==="/"?"":c.pathname),this.region=na}catch{this.customDomain=null,this.region=i}}_delete(){return this.deleteService()}_url(e){const t=this.app.options.projectId;return this.emulatorOrigin!==null?`${this.emulatorOrigin}/${t}/${this.region}/${e}`:this.customDomain!==null?`${this.customDomain}/${e}`:`https://${this.region}-${t}.cloudfunctions.net/${e}`}}function o0(n,e,t){const r=vt(e);n.emulatorOrigin=`http${r?"s":""}://${e}:${t}`,r&&(ii(n.emulatorOrigin+"/backends"),oi("Functions",!0))}function a0(n,e,t){const r=s=>l0(n,e,s,{});return r.stream=(s,i)=>h0(n,e,s,i),r}function Ip(n){return n.emulatorOrigin&&vt(n.emulatorOrigin)?"include":void 0}async function c0(n,e,t,r,s){t["Content-Type"]="application/json";let i;try{i=await r(n,{method:"POST",body:JSON.stringify(e),headers:t,credentials:Ip(s)})}catch{return{status:0,json:null}}let a=null;try{a=await i.json()}catch{}return{status:i.status,json:a}}async function Ap(n,e){const t={},r=await n.contextProvider.getContext(e.limitedUseAppCheckTokens);return r.authToken&&(t.Authorization="Bearer "+r.authToken),r.messagingToken&&(t["Firebase-Instance-ID-Token"]=r.messagingToken),r.appCheckToken!==null&&(t["X-Firebase-AppCheck"]=r.appCheckToken),t}function l0(n,e,t,r){const s=n._url(e);return u0(n,s,t,r)}async function u0(n,e,t,r){t=Ys(t);const s={data:t},i=await Ap(n,r),a=r.timeout||7e4,c=s0(a),u=await Promise.race([c0(e,s,i,n.fetchImpl,n),c.promise,n.cancelAllRequests]);if(c.cancel(),!u)throw new Le("cancelled","Firebase Functions instance was deleted.");const h=Xs(u.status,u.json);if(h)throw h;if(!u.json)throw new Le("internal","Response is not valid JSON object.");let f=u.json.data;if(typeof f>"u"&&(f=u.json.result),typeof f>"u")throw new Le("internal","Response is missing data field.");return{data:qn(f)}}function h0(n,e,t,r){const s=n._url(e);return d0(n,s,t,r||{})}async function d0(n,e,t,r){t=Ys(t);const s={data:t},i=await Ap(n,r);i["Content-Type"]="application/json",i.Accept="text/event-stream";let a;try{a=await n.fetchImpl(e,{method:"POST",body:JSON.stringify(s),headers:i,signal:r?.signal,credentials:Ip(n)})}catch(y){if(y instanceof Error&&y.name==="AbortError"){const k=new Le("cancelled","Request was cancelled.");return{data:Promise.reject(k),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(k)}}}}}}const S=Xs(0,null);return{data:Promise.reject(S),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(S)}}}}}}let c,u;const h=new Promise((y,S)=>{c=y,u=S});r?.signal?.addEventListener("abort",()=>{const y=new Le("cancelled","Request was cancelled.");u(y)});const f=a.body.getReader(),m=f0(f,c,u,r?.signal);return{stream:{[Symbol.asyncIterator](){const y=m.getReader();return{async next(){const{value:S,done:k}=await y.read();return{value:S,done:k}},async return(){return await y.cancel(),{done:!0,value:void 0}}}}},data:h}}function f0(n,e,t,r){const s=(a,c)=>{const u=a.match(r0);if(!u)return;const h=u[1];try{const f=JSON.parse(h);if("result"in f){e(qn(f.result));return}if("message"in f){c.enqueue(qn(f.message));return}if("error"in f){const m=Xs(0,f);c.error(m),t(m);return}}catch(f){if(f instanceof Le){c.error(f),t(f);return}}},i=new TextDecoder;return new ReadableStream({start(a){let c="";return u();async function u(){if(r?.aborted){const h=new Le("cancelled","Request was cancelled");return a.error(h),t(h),Promise.resolve()}try{const{value:h,done:f}=await n.read();if(f){c.trim()&&s(c.trim(),a),a.close();return}if(r?.aborted){const y=new Le("cancelled","Request was cancelled");a.error(y),t(y),await n.cancel();return}c+=i.decode(h,{stream:!0});const m=c.split(`
|
|
38
|
-
`);c=m.pop()||"";for(const y of m)y.trim()&&s(y.trim(),a);return u()}catch(h){const f=h instanceof Le?h:Xs(0,null);a.error(f),t(f)}}},cancel(){return n.cancel()}})}const hh="@firebase/functions",dh="0.13.1";const p0="auth-internal",m0="app-check-internal",g0="messaging-internal";function _0(n){const e=(t,{instanceIdentifier:r})=>{const s=t.getProvider("app").getImmediate(),i=t.getProvider(p0),a=t.getProvider(g0),c=t.getProvider(m0);return new i0(s,i,a,c,r)};Me(new Ne(pc,e,"PUBLIC").setMultipleInstances(!0)),me(hh,dh,n),me(hh,dh,"esm2020")}function y0(n=$n(),e=na){const r=ut(ee(n),pc).getImmediate({identifier:e}),s=la("functions");return s&&bp(r,...s),r}function bp(n,e,t){o0(ee(n),e,t)}function T0(n,e,t){return a0(ee(n),e)}_0();const w0="/firebase-messaging-sw.js",E0="/firebase-cloud-messaging-push-scope",Sp="BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4",v0="https://fcmregistrations.googleapis.com/v1",Rp="google.c.a.c_id",I0="google.c.a.c_l",A0="google.c.a.ts",b0="google.c.a.e",fh=1e4;var ph;(function(n){n[n.DATA_MESSAGE=1]="DATA_MESSAGE",n[n.DISPLAY_NOTIFICATION=3]="DISPLAY_NOTIFICATION"})(ph||(ph={}));var Lr;(function(n){n.PUSH_RECEIVED="push-received",n.NOTIFICATION_CLICKED="notification-clicked"})(Lr||(Lr={}));function dt(n){const e=new Uint8Array(n);return btoa(String.fromCharCode(...e)).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function S0(n){const e="=".repeat((4-n.length%4)%4),t=(n+e).replace(/\-/g,"+").replace(/_/g,"/"),r=atob(t),s=new Uint8Array(r.length);for(let i=0;i<r.length;++i)s[i]=r.charCodeAt(i);return s}const vo="fcm_token_details_db",R0=5,mh="fcm_token_object_Store";async function P0(n){if("databases"in indexedDB&&!(await indexedDB.databases()).map(i=>i.name).includes(vo))return null;let e=null;return(await ci(vo,R0,{upgrade:async(r,s,i,a)=>{if(s<2||!r.objectStoreNames.contains(mh))return;const c=a.objectStore(mh),u=await c.index("fcmSenderId").get(n);if(await c.clear(),!!u){if(s===2){const h=u;if(!h.auth||!h.p256dh||!h.endpoint)return;e={token:h.fcmToken,createTime:h.createTime??Date.now(),subscriptionOptions:{auth:h.auth,p256dh:h.p256dh,endpoint:h.endpoint,swScope:h.swScope,vapidKey:typeof h.vapidKey=="string"?h.vapidKey:dt(h.vapidKey)}}}else if(s===3){const h=u;e={token:h.fcmToken,createTime:h.createTime,subscriptionOptions:{auth:dt(h.auth),p256dh:dt(h.p256dh),endpoint:h.endpoint,swScope:h.swScope,vapidKey:dt(h.vapidKey)}}}else if(s===4){const h=u;e={token:h.fcmToken,createTime:h.createTime,subscriptionOptions:{auth:dt(h.auth),p256dh:dt(h.p256dh),endpoint:h.endpoint,swScope:h.swScope,vapidKey:dt(h.vapidKey)}}}}}})).close(),await io(vo),await io("fcm_vapid_details_db"),await io("undefined"),C0(e)?e:null}function C0(n){if(!n||!n.subscriptionOptions)return!1;const{subscriptionOptions:e}=n;return typeof n.createTime=="number"&&n.createTime>0&&typeof n.token=="string"&&n.token.length>0&&typeof e.auth=="string"&&e.auth.length>0&&typeof e.p256dh=="string"&&e.p256dh.length>0&&typeof e.endpoint=="string"&&e.endpoint.length>0&&typeof e.swScope=="string"&&e.swScope.length>0&&typeof e.vapidKey=="string"&&e.vapidKey.length>0}const k0="firebase-messaging-database",N0=1,_n="firebase-messaging-store";let Io=null;function mc(){return Io||(Io=ci(k0,N0,{upgrade:(n,e)=>{e===0&&n.createObjectStore(_n)}})),Io}async function Pp(n){const e=_c(n),r=await(await mc()).transaction(_n).objectStore(_n).get(e);if(r)return r;{const s=await P0(n.appConfig.senderId);if(s)return await gc(n,s),s}}async function gc(n,e){const t=_c(n),s=(await mc()).transaction(_n,"readwrite");return await s.objectStore(_n).put(e,t),await s.done,e}async function D0(n){const e=_c(n),r=(await mc()).transaction(_n,"readwrite");await r.objectStore(_n).delete(e),await r.done}function _c({appConfig:n}){return n.appId}const V0={"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"only-available-in-window":"This method is available in a Window context.","only-available-in-sw":"This method is available in a service worker context.","permission-default":"The notification permission was not granted and dismissed instead.","permission-blocked":"The notification permission was not granted and blocked instead.","unsupported-browser":"This browser doesn't support the API's required to use the Firebase SDK.","indexed-db-unsupported":"This browser doesn't support indexedDb.open() (ex. Safari iFrame, Firefox Private Browsing, etc)","failed-service-worker-registration":"We are unable to register the default service worker. {$browserErrorMessage}","token-subscribe-failed":"A problem occurred while subscribing the user to FCM: {$errorInfo}","token-subscribe-no-token":"FCM returned no token when subscribing the user to push.","token-unsubscribe-failed":"A problem occurred while unsubscribing the user from FCM: {$errorInfo}","token-update-failed":"A problem occurred while updating the user from FCM: {$errorInfo}","token-update-no-token":"FCM returned no token when updating the user to push.","use-sw-after-get-token":"The useServiceWorker() method may only be called once and must be called before calling getToken() to ensure your service worker is used.","invalid-sw-registration":"The input to useServiceWorker() must be a ServiceWorkerRegistration.","invalid-bg-handler":"The input to setBackgroundMessageHandler() must be a function.","invalid-vapid-key":"The public VAPID key must be a string.","use-vapid-key-after-get-token":"The usePublicVapidKey() method may only be called once and must be called before calling getToken() to ensure your VAPID key is used."},be=new Kt("messaging","Messaging",V0);async function O0(n,e){const t=await Tc(n),r=kp(e),s={method:"POST",headers:t,body:JSON.stringify(r)};let i;try{i=await(await fetch(yc(n.appConfig),s)).json()}catch(a){throw be.create("token-subscribe-failed",{errorInfo:a?.toString()})}if(i.error){const a=i.error.message;throw be.create("token-subscribe-failed",{errorInfo:a})}if(!i.token)throw be.create("token-subscribe-no-token");return i.token}async function L0(n,e){const t=await Tc(n),r=kp(e.subscriptionOptions),s={method:"PATCH",headers:t,body:JSON.stringify(r)};let i;try{i=await(await fetch(`${yc(n.appConfig)}/${e.token}`,s)).json()}catch(a){throw be.create("token-update-failed",{errorInfo:a?.toString()})}if(i.error){const a=i.error.message;throw be.create("token-update-failed",{errorInfo:a})}if(!i.token)throw be.create("token-update-no-token");return i.token}async function Cp(n,e){const r={method:"DELETE",headers:await Tc(n)};try{const i=await(await fetch(`${yc(n.appConfig)}/${e}`,r)).json();if(i.error){const a=i.error.message;throw be.create("token-unsubscribe-failed",{errorInfo:a})}}catch(s){throw be.create("token-unsubscribe-failed",{errorInfo:s?.toString()})}}function yc({projectId:n}){return`${v0}/projects/${n}/registrations`}async function Tc({appConfig:n,installations:e}){const t=await e.getToken();return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":n.apiKey,"x-goog-firebase-installations-auth":`FIS ${t}`})}function kp({p256dh:n,auth:e,endpoint:t,vapidKey:r}){const s={web:{endpoint:t,auth:e,p256dh:n}};return r!==Sp&&(s.web.applicationPubKey=r),s}const M0=10080*60*1e3;async function x0(n){const e=await B0(n.swRegistration,n.vapidKey),t={vapidKey:n.vapidKey,swScope:n.swRegistration.scope,endpoint:e.endpoint,auth:dt(e.getKey("auth")),p256dh:dt(e.getKey("p256dh"))},r=await Pp(n.firebaseDependencies);if(r){if(q0(r.subscriptionOptions,t))return Date.now()>=r.createTime+M0?U0(n,{token:r.token,createTime:Date.now(),subscriptionOptions:t}):r.token;try{await Cp(n.firebaseDependencies,r.token)}catch(s){console.warn(s)}return gh(n.firebaseDependencies,t)}else return gh(n.firebaseDependencies,t)}async function F0(n){const e=await Pp(n.firebaseDependencies);e&&(await Cp(n.firebaseDependencies,e.token),await D0(n.firebaseDependencies));const t=await n.swRegistration.pushManager.getSubscription();return t?t.unsubscribe():!0}async function U0(n,e){try{const t=await L0(n.firebaseDependencies,e),r={...e,token:t,createTime:Date.now()};return await gc(n.firebaseDependencies,r),t}catch(t){throw t}}async function gh(n,e){const r={token:await O0(n,e),createTime:Date.now(),subscriptionOptions:e};return await gc(n,r),r.token}async function B0(n,e){const t=await n.pushManager.getSubscription();return t||n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:S0(e)})}function q0(n,e){const t=e.vapidKey===n.vapidKey,r=e.endpoint===n.endpoint,s=e.auth===n.auth,i=e.p256dh===n.p256dh;return t&&r&&s&&i}function _h(n){const e={from:n.from,collapseKey:n.collapse_key,messageId:n.fcmMessageId};return $0(e,n),j0(e,n),z0(e,n),e}function $0(n,e){if(!e.notification)return;n.notification={};const t=e.notification.title;t&&(n.notification.title=t);const r=e.notification.body;r&&(n.notification.body=r);const s=e.notification.image;s&&(n.notification.image=s);const i=e.notification.icon;i&&(n.notification.icon=i)}function j0(n,e){e.data&&(n.data=e.data)}function z0(n,e){if(!e.fcmOptions&&!e.notification?.click_action)return;n.fcmOptions={};const t=e.fcmOptions?.link??e.notification?.click_action;t&&(n.fcmOptions.link=t);const r=e.fcmOptions?.analytics_label;r&&(n.fcmOptions.analyticsLabel=r)}function H0(n){return typeof n=="object"&&!!n&&Rp in n}function G0(n){if(!n||!n.options)throw Ao("App Configuration Object");if(!n.name)throw Ao("App Name");const e=["projectId","apiKey","appId","messagingSenderId"],{options:t}=n;for(const r of e)if(!t[r])throw Ao(r);return{appName:n.name,projectId:t.projectId,apiKey:t.apiKey,appId:t.appId,senderId:t.messagingSenderId}}function Ao(n){return be.create("missing-app-config-values",{valueName:n})}class K0{constructor(e,t,r){this.deliveryMetricsExportedToBigQueryEnabled=!1,this.onBackgroundMessageHandler=null,this.onMessageHandler=null,this.logEvents=[],this.isLogServiceStarted=!1;const s=G0(e);this.firebaseDependencies={app:e,appConfig:s,installations:t,analyticsProvider:r}}_delete(){return Promise.resolve()}}async function Np(n){try{n.swRegistration=await navigator.serviceWorker.register(w0,{scope:E0}),n.swRegistration.update().catch(()=>{}),await W0(n.swRegistration)}catch(e){throw be.create("failed-service-worker-registration",{browserErrorMessage:e?.message})}}async function W0(n){return new Promise((e,t)=>{const r=setTimeout(()=>t(new Error(`Service worker not registered after ${fh} ms`)),fh),s=n.installing||n.waiting;n.active?(clearTimeout(r),e()):s?s.onstatechange=i=>{i.target?.state==="activated"&&(s.onstatechange=null,clearTimeout(r),e())}:(clearTimeout(r),t(new Error("No incoming service worker found.")))})}async function Q0(n,e){if(!e&&!n.swRegistration&&await Np(n),!(!e&&n.swRegistration)){if(!(e instanceof ServiceWorkerRegistration))throw be.create("invalid-sw-registration");n.swRegistration=e}}async function J0(n,e){e?n.vapidKey=e:n.vapidKey||(n.vapidKey=Sp)}async function Dp(n,e){if(!navigator)throw be.create("only-available-in-window");if(Notification.permission==="default"&&await Notification.requestPermission(),Notification.permission!=="granted")throw be.create("permission-blocked");return await J0(n,e?.vapidKey),await Q0(n,e?.serviceWorkerRegistration),x0(n)}async function Y0(n,e,t){const r=X0(e);(await n.firebaseDependencies.analyticsProvider.get()).logEvent(r,{message_id:t[Rp],message_name:t[I0],message_time:t[A0],message_device_time:Math.floor(Date.now()/1e3)})}function X0(n){switch(n){case Lr.NOTIFICATION_CLICKED:return"notification_open";case Lr.PUSH_RECEIVED:return"notification_foreground";default:throw new Error}}async function Z0(n,e){const t=e.data;if(!t.isFirebaseMessaging)return;n.onMessageHandler&&t.messageType===Lr.PUSH_RECEIVED&&(typeof n.onMessageHandler=="function"?n.onMessageHandler(_h(t)):n.onMessageHandler.next(_h(t)));const r=t.data;H0(r)&&r[b0]==="1"&&await Y0(n,t.messageType,r)}const yh="@firebase/messaging",Th="0.12.23";const eb=n=>{const e=new K0(n.getProvider("app").getImmediate(),n.getProvider("installations-internal").getImmediate(),n.getProvider("analytics-internal"));return navigator.serviceWorker.addEventListener("message",t=>Z0(e,t)),e},tb=n=>{const e=n.getProvider("messaging").getImmediate();return{getToken:r=>Dp(e,r)}};function nb(){Me(new Ne("messaging",eb,"PUBLIC")),Me(new Ne("messaging-internal",tb,"PRIVATE")),me(yh,Th),me(yh,Th,"esm2020")}async function rb(){try{await ha()}catch{return!1}return typeof window<"u"&&ua()&&Mh()&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&"fetch"in window&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey")}async function sb(n){if(!navigator)throw be.create("only-available-in-window");return n.swRegistration||await Np(n),F0(n)}function ib(n=$n()){return rb().then(e=>{if(!e)throw be.create("unsupported-browser")},e=>{throw be.create("indexed-db-unsupported")}),ut(ee(n),"messaging").getImmediate()}async function ob(n,e){return n=ee(n),Dp(n,e)}function ab(n){return n=ee(n),sb(n)}nb();let He=null;exports.auth=void 0;exports.provider=void 0;exports.analytics=void 0;exports.db=void 0;exports.storage=void 0;exports.functions=void 0;exports.messaging=void 0;function cb(n){if(He)return He;const{functionsRegion:e,...t}=n;return He=Uh(t),exports.auth=Zw(He),exports.provider=new ft,exports.analytics=Xy(He),exports.db=aA(He),exports.storage=JA(He),exports.functions=y0(He,e),exports.messaging=ib(He),je.isDev&&(op(exports.db,"localhost",8080),bd(exports.auth,"http://localhost:9099"),bp(exports.functions,"localhost",5001),Ep(exports.storage,"localhost",9199)),He}function ra(){if(!He)throw new Error("[cic-kit] Firebase non inizializzato. Chiama setupFirebase(firebaseConfig) nel main.")}const Zs="Sei offline: cancello in locale, sincronizzo quando torni online.";function Vp(){return typeof navigator<"u"?!!navigator.onLine:!0}function wc(){return!Vp()}function Ar(n){if(n instanceof z)return n;try{return new z(n.seconds,n.nanoseconds)}catch{return U.logError({title:"reviveTimestamp errore:",message:`seconds:${n.seconds}; nanoseconds:${n.nanoseconds};`}),z.now()}}function sa(n){try{if(n==null||n instanceof z)return n;if(typeof n=="object"&&n.type==="firestore/timestamp/1.0"&&typeof n.seconds=="number"&&typeof n.nanoseconds=="number")return Ar(n);if(Array.isArray(n))return n.map(e=>sa(e));if(typeof n=="object"){const e={};for(const[t,r]of Object.entries(n))e[t]=sa(r);return e}return n}catch(e){return U.logError({title:"reviveTimestampsDeep error",message:e?.message??"Errore sconosciuto"}),n}}const ei=n=>{if(n==null)return n;if(n instanceof z)return n.toJSON();if(n&&typeof n=="object"&&n._methodName==="serverTimestamp")return U.logError("non puoi salvare un serverTimestamp devi usare Timestamp.now()"),z.now().toJSON();if(Array.isArray(n))return n.map(e=>ei(e));if(typeof n=="object"){const e={};for(const[t,r]of Object.entries(n))e[t]=ei(r);return e}return n},ia={unknown:"Errore sconosciuto.",undefined:"Non trovato.",cancelled:"Operazione annullata.","invalid-argument":"Argomento non valido.","deadline-exceeded":"Timeout dell’operazione.","not-found":"Risorsa non trovata.","already-exists":"La risorsa esiste già.","permission-denied":"Non hai i permessi necessari.","resource-exhausted":"Limite superato, riprova più tardi.","failed-precondition":"Stato non valido per questa operazione.",aborted:"Conflitto, operazione annullata.",unavailable:"Servizio momentaneamente non disponibile.","auth/email-already-in-use":"Questa email è già registrata.","auth/wrong-password":"Password errata.","auth/user-not-found":"Utente non trovato.","auth/invalid-email":"Indirizzo email non valido.","auth/too-many-requests":"Troppi tentativi, riprova più tardi.","auth/requires-recent-login":"Per favore effettua di nuovo il login.","storage/object-not-found":"File non trovato.","storage/unauthenticated":"Devi effettuare il login.","storage/unauthorized":"Non hai accesso a questo file.","storage/quota-exceeded":"Quota di archiviazione superata."};function lb(n){return n in ia}function nt(n,e){if(e===!1)return;const t=typeof n?.code=="string"?n?.code:"",r=lb(t)?ia[t]:!1;if(r)U.error(r);else{U.error(ia.unknown),console.log(`%cTodo gestire error.code "%c${n?.code}%c"`,"color:#fb9005; font-weight:bold;","color:#0dfb05; font-weight:bold;","color:#fb9005; font-weight:bold;");try{U.logError(String(n))}catch{U.logError("on try to parse error")}finally{console.log("[ERROR from middlewareCatchCall]:",n)}}}function ti(n,e,t,...r){!je.debugFirestore||!(i=>{if(!i)return;if(typeof je.debugFirestore=="boolean")return je.debugFirestore;const a=typeof je.debugFirestore=="string"?[je.debugFirestore]:je.debugFirestore;return a.length>0?a.includes(i):!1})(n)||console.log(`${e}[${t}] [${n??"no collectionName"}]`,...r)}function bo(n){if(wc()){if(n!==!0)throw Zs;U.warning(Zs)}}const ge={offlineAllow:!1,touchUpdate:!0,localSet:!0};class Ge{id;createdAt;updatedAt;deleteAt;constructor(e){this.id=e.id,Object.assign(this,e);const t=z.now();this.createdAt=e.createdAt?Ar(e.createdAt):t,this.updatedAt=e.updatedAt?Ar(e.updatedAt):t,this.deleteAt=e.deleteAt&&e.deleteAt!==null?Ar(e.deleteAt):null}static collectionName;debugLog(e,...t){ti(this?.collectionName??"no-collectionName","🔥📡🏪",e,t)}get ref(){const e=this.constructor,r=this.getCollectionPath?.()??e.collectionName;if(!r)throw new Error(`${e.name}: nessuna collectionName statica e nessuna getCollectionPath() definita.`);return Ir(exports.db,r,this.id)}static async get(e,t){try{ti(this?.collectionName??"no-collectionName","🔥📡🏪","get");const r=t?.collectionPath??this.collectionName;if(!r)throw new Error(`${this.name}.get: serve opts.collectionPath per collezioni dinamiche, oppure definisci static collectionName.`);const s=Ir(exports.db,r,e),i=await ta(s);if(!i.exists())return;const a=new this({id:e,...i.data()}),c=await a.onGetBeforeStoreSet(a);return c.canLocalSave(t?.localSet)&&c.localSet(),c}catch(r){throw nt(r),r}}static cleanDataAAA(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>{if(r==null)return[t,Zo()];if(typeof r=="object"&&r!==null&&!(r instanceof z)&&!(r instanceof Date))try{return[t,structuredClone(r)]}catch{return[t,JSON.parse(JSON.stringify(r))]}return[t,r]}))}static isPlainObject(e){return!!e&&typeof e=="object"}static stripUndefinedDeep(e){if(e!==void 0){if(e===null)return null;if(e instanceof z||e instanceof Date||e instanceof Or)return e;if(Array.isArray(e))return e.map(t=>Ge.stripUndefinedDeep(t)).filter(t=>t!==void 0);if(Ge.isPlainObject(e)){const t={};for(const[r,s]of Object.entries(e)){const i=Ge.stripUndefinedDeep(s);i!==void 0&&(t[r]=i)}return t}return e}}static cleanData(e){const t=Ge.stripUndefinedDeep(e);return Object.fromEntries(Object.entries(t??{}).map(([s,i])=>{if(i==null)return[s,Zo()];if((Ge.isPlainObject(i)||Array.isArray(i))&&!(i instanceof z)&&!(i instanceof Date)&&!(i instanceof Or))try{return[s,structuredClone(i)]}catch{return[s,JSON.parse(JSON.stringify(i))]}return[s,i]}))}async onGetBeforeStoreSet(e){return e}async save({offlineAllow:e=ge.offlineAllow,touchUpdate:t=ge.touchUpdate,localSet:r=ge.localSet}=ge){this.debugLog("save");try{bo(e);const s=this.toData(),i=Ge.cleanData(s);t&&!i.updatedAt&&(i.updatedAt=this.touchUpdated()),await gp(this.ref,{...i},{merge:!0}),this.canLocalSave(r)&&this.localSet()}catch(s){throw nt(s),s}}async update(e,{offlineAllow:t=ge.offlineAllow,touchUpdate:r=ge.touchUpdate,localSet:s=ge.localSet}=ge){this.debugLog("update");try{bo(t);const i=Ge.cleanData(e);r&&!i.updatedAt&&(i.updatedAt=this.touchUpdated()),await vA(this.ref,i),Object.assign(this,e),this.canLocalSave(s)&&this.localSet()}catch(i){throw nt(i),i}}async delete(e,t=ge){return this.debugLog("deleteUsingStore",`[id=${this.id}]`),await e.delete(this.id,t)}async deleteJustOnline_NotLocalStore({offlineAllow:e=ge.offlineAllow,localSet:t=ge.localSet}=ge){this.debugLog("delete");try{bo(e),await IA(this.ref),this.canLocalSave(t)&&this.localSet(!0)}catch(r){throw nt(r),r}}get isDeleted(){return this.deleteAt!==null}timestampbleProps(){return{createdAt:this.createdAt,updatedAt:this.updatedAt,deleteAt:this.deleteAt}}touchUpdated(){const e=z.now();return this.updatedAt=e,e}async softDelete(e){if(this.debugLog("softDelete"),this.deleteAt!==null){U.warning("Elemento già nel cestino.");return}const t=z.now();this.deleteAt=t,await this.update({deleteAt:t},e)}async restore(e){if(this.debugLog("restore"),this.deleteAt===null){U.warning("Elemento non è nel cestino.");return}this.deleteAt=null,await this.update({deleteAt:null},e)}canLocalSave(e){if(e===!1)return!1;try{return!!this?.localStorageKey?.()}catch{return!1}}localSet(e){this.debugLog("localSet");const t=this?.localStorageKey?.();if(!t)return;const r=this?.toData?.()??{id:this.id},s=ei(r),i=Ce.getParsed(t);if(i&&typeof i=="object"&&!Array.isArray(i)){if(e){i[this.id]&&(delete i[this.id],Ce.set(t,i));return}Ce.set(t,{...i,[this.id]:s})}else Ce.set(t,{[this.id]:s})}}function ub(n){if(wc()){if(n!==!0)throw Zs;U.warning(Zs)}}class hb{ModelInstnce;makeModel(e,t){return new this.ModelInstnce({id:e,...t})}_collectionPath;debugLog(e,...t){ti(this.collectionPath,"🔥📡📦",e,t)}items={};snapshotFnStop=null;isFirstRun=!0;prevStartQuery="";get live(){return!!this.snapshotFnStop}get ref(){return oA(exports.db,this.collectionPath)}constructor(e,t){this.ModelInstnce=e,this._collectionPath=t?.collectionPath}get collectionPath(){const e=this._collectionPath??this.ModelInstnce.collectionName;if(!e)throw new Error("collectionPath non definita");return e}get name(){return this.collectionPath}get itemsActive(){return Object.fromEntries(Object.entries(this.items).filter(([,e])=>!e.isDeleted))}get itemsDeleted(){return Object.fromEntries(Object.entries(this.items).filter(([,e])=>e.isDeleted))}get itemsArray(){return Object.values(this.items)}get itemsActiveArray(){return Object.values(this.items).filter(e=>!e.isDeleted)}get itemsDeletedArray(){return Object.values(this.items).filter(e=>e.isDeleted)}get isEmpty(){return Object.keys(this.items).length===0}get isActiveEmpty(){return this.itemsActiveArray.length===0}get isDeletedEmpty(){return this.itemsDeletedArray.length===0}get localStorageKey(){const e=this.ModelInstnce?.prototype?.localStorageKey?.();if(!e){U.logError("Impossibile svuotare LocalStorage: localStorageKey() non definita nel Model.");return}return e}itemsArrayOrderedBy(e,t){return[...t===void 0?this.itemsArray:t?this.itemsDeletedArray:this.itemsActiveArray].sort((s,i)=>{const a=s[e]?.toMillis?.()??0;return(i[e]?.toMillis?.()??0)-a})}findItemsById(e){if(!(!e||e===""))return this.items?.[e]}async get(e={}){this.debugLog("get");try{const t=oa(e),r=t?nh(this.ref,...t):this.ref,s=await EA(r);e.forceLocalSet&&(this.items={},this.localClear());for(const i of s.docs){const a=this.makeModel(i.id,i.data()),c=await a.onGetBeforeStoreSet(a);this.items[i.id]=c,(c.canLocalSave(e.localSet)||e.forceLocalSet&&c.canLocalSave())&&c.localSet()}return this.items}catch(t){throw nt(t),t}}async getIds(e){this.debugLog("getIds");const t=Array.from(new Set((e??[]).map(u=>(u??"").trim()).filter(Boolean)));if(t.length===0)return{foundIds:!1,notFoundIds:!1};const r=(u,h)=>{const f=[];for(let m=0;m<u.length;m+=h)f.push(u.slice(m,m+h));return f},s=new Set,i=r(t,10);for(const u of i){const h=await this.get({query:ea(Xo(),"in",u)});for(const f of Object.keys(h))s.add(f)}const a=Array.from(s),c=t.filter(u=>!s.has(u));return{foundIds:a.length>0?a:!1,notFoundIds:c.length>0?c:!1}}localGet(){const e=this.localStorageKey;try{if(!e){U.logError({title:"localGet "+e,message:"LocalStorageKey not found"});return}const t=Ce.getParsed(e);for(const r in t)this.items[r]=this.makeModel(r,t[r])}catch{U.logError({title:"localGet "+e,message:"errore try parse o makeModel"})}}async start(e={}){if(this.debugLog("👂 start"),!Ec(e))return;const t=JSON.stringify([e.ids,e.query,e.limit,e.orderBy].map(i=>i?.toString?.()??String(i)));if(this.live&&this.prevStartQuery===t)return;this.stop(),this.prevStartQuery=t;const r=oa(e,!0),s=r?nh(this.ref,...r):this.ref;this.snapshotFnStop=AA(s,async i=>{const a=i.docChanges();this.isFirstRun&&(this.debugLog("👂 firstRun"),this.isFirstRun=!1,this.onStartFirstRun(a,e.forceLocalSet),e.forceLocalSet&&(this.items={},this.localClear()));for(const c of a){const u=c.doc.id;if(c.type==="removed"){this.items[u]?.localSet(!0),delete this.items[u];continue}const h=c.doc.data(),f=this.makeModel(u,h),m=await f.onGetBeforeStoreSet(f);this.items[u]=m,m.canLocalSave(e.localSet)&&m.localSet()}},i=>{this.stop(),nt(i)})}onStartFirstRun(e,t){}stop(){this.snapshotFnStop&&(this.debugLog("🛑 stop"),this.prevStartQuery=null,this.snapshotFnStop(),this.snapshotFnStop=null,this.isFirstRun=!0)}async add(e,{offlineAllow:t=ge.offlineAllow,localSet:r=ge.localSet}=ge){try{this.debugLog("add"),ub(t);const{id:s,...i}=e,a=Ge.stripUndefinedDeep(i);let c=s??"";if(s){const h=Ir(exports.db,this.collectionPath,s);if((await ta(h)).exists())throw new Error("Documento già esistente")}else c=Ir(this.ref).id;const u=this.makeModel(c,a);return await u.save({offlineAllow:t,touchUpdate:!0,localSet:r}),this.items[c]=u,u}catch(s){throw nt(s),s}}async delete(e,t=ge){try{if(this.items[e]){const r=this.items[e].deleteJustOnline_NotLocalStore(t);return delete this.items[e],await r}}catch(r){throw nt(r),r}}findByUid(e){if(!(!this.itemsArray||!this.itemsArray.length))return this.itemsArray.find(t=>t.uid===e)}async getOne(e,t){this.debugLog("getOne");try{const r=Ir(exports.db,this.collectionPath,e),s=await ta(r);if(!s.exists())throw this.items[e]&&delete this.items[e],new Error("[404] non trovato");const i=s.data(),a=this.makeModel(e,i),c=await a.onGetBeforeStoreSet(a);return this.items[e]=c,c.canLocalSave(t?.localSet)&&c.localSet(),c}catch(r){throw nt(r),r}}async ensureOne(e){const t=this.items[e];return t||this.getOne(e)}localClear(){const e=this.localStorageKey;Ce.has(e)?(Ce.remove(e),U.log(`LocalStorage "${e}" svuotato con successo.`)):U.log(`Nessun dato trovato per LocalStorage "${e}".`)}}function Ec(n){if(n.ids&&n.ids.length>0){if(n.ids.length>10)return U.logError("Non puoi lanciare start con più di 10 id"),!1;if(n.query)return U.logError('Non è supportato usare "query" insieme a "ids" in start()'),!1}if(n.lastByCreate||n.lastByUpdate){if(n.lastByCreate&&n.lastByUpdate)return U.logError("Non puoi usare lastByCreate e lastByUpdate insieme"),!1;if(n.limit||n.orderBy)return U.logError("Non puoi usare limit o orderBy insieme a lastByCreate / lastByUpdate"),!1}return!0}function oa(n,e=!1){if(!e&&!Ec(n))return!1;const t=[];if(n.ids&&n.ids.length>0){const r=Array.from(new Set(n.ids.map(s=>(s??"").trim()).filter(Boolean)));r.length===1?t.push(ea(Xo(),"==",r[0])):r.length>1&&t.push(ea(Xo(),"in",r))}else n.query&&t.push(...Array.isArray(n.query)?n.query:[n.query]);return n.lastByCreate?(t.push(To("createdAt","desc")),t.push(wo(n.lastByCreate)),t):n.lastByUpdate?(t.push(To("updatedAt","desc")),t.push(wo(n.lastByUpdate)),t):(n.orderBy&&t.push(To(n.orderBy.fieldPath,n.orderBy.directionStr??"asc")),n.limit&&t.push(wo(n.limit)),t)}function db(n){let e=null;_.onBeforeUnmount(()=>{e?.(),e=null;for(const t of n)t.store.stop()})}const Op={SUPERADMIN:"SUPERADMIN",ADMIN:"ADMIN",MODAL_DEV_ON:"MODAL_DEV_ON",MANAGE_USERS:"MANAGE_USERS",OFFLINE_ALLOW:"OFFLINE_ALLOW",BETA_FEATURES:"BETA_FEATURES"};class fb extends Ge{static collectionName="users";localStorageKey(){return Ce.defaultKey.currentUser}userPublicId;name;surname;email;birthDate;phoneNumber;photoURL;description;permissions;gender;birthHideYear;fcmTokens;constructor(e){super(e),this.userPublicId=e.userPublicId,this.name=e.name,this.surname=e.surname,this.email=e.email,this.birthDate=e.birthDate,this.phoneNumber=e.phoneNumber,this.photoURL=e.photoURL,this.description=e.description,this.permissions=e.permissions??[],this.gender=e.gender,this.birthHideYear=e.birthHideYear,this.fcmTokens=e.fcmTokens}toData(){return{id:this.id,userPublicId:this.userPublicId,name:this.name,surname:this.surname,email:this.email,birthDate:this.birthDate,phoneNumber:this.phoneNumber,photoURL:this.photoURL,description:this.description,permissions:this.permissions,gender:this.gender,birthHideYear:this.birthHideYear,fcmTokens:this.fcmTokens}}async create(){try{const e=this.toData(),t=Object.fromEntries(Object.entries(e).map(([r,s])=>s==null?[r,Zo()]:[r,s]));t.permissions!==void 0&&delete t.permissions,await gp(this.ref,t,{merge:!0})}catch(e){throw U.error(String(e)),e}}get fullName(){let e=`${this.name} ${this.surname}`.trim();return e===""&&(e="-"),e}get fullNameInitials(){const e=this.fullName,t=e.split(" ").filter(Boolean);return((t[0]?.[0]||"")+(t[1]?.[0]||"")||e?.[0]||"?").toUpperCase()}async updateName(e,t){await this.update({name:e,surname:t})}async updateBirthDate(e){await this.update({birthDate:e})}hasPermission(e){return Array.isArray(this.permissions)&&this.permissions.includes(e)}hasAnyPermissions(){return Array.isArray(this.permissions)&&this.permissions.length>0}hasAnyPermissionsExclud(e){return!Array.isArray(this.permissions)||this.permissions.length===0?!1:this.permissions.some(t=>!e.includes(t))}get offlineAllow(){return this.hasPermission(Op.OFFLINE_ALLOW)}async addPermissions(e){const r=(Array.isArray(e)?e:[e]).filter(s=>!this.permissions.includes(s));return r.length===0?!1:(this.permissions.push(...r),this.update({permissions:this.permissions}).then(()=>!0))}async deletePermissions(e){const t=Array.isArray(e)?e:[e],r=this.permissions.length;return this.permissions=this.permissions.filter(s=>!t.includes(s)),this.permissions.length===r?!1:this.update({permissions:this.permissions}).then(()=>!0)}hasFcmToken(e){return e?(this.fcmTokens??[]).includes(e):!1}async addFcmToken(e){return Array.isArray(this.fcmTokens)||(this.fcmTokens=[]),this.hasFcmToken(e)?!1:(this.fcmTokens.push(e),this.update({fcmTokens:this.fcmTokens}).then(()=>!0))}async removeFcmToken(e){if(!Array.isArray(this.fcmTokens)||this.fcmTokens.length===0)return!1;const t=this.fcmTokens.length;return this.fcmTokens=this.fcmTokens.filter(r=>r!==e),this.fcmTokens.length===t?!1:this.update({fcmTokens:this.fcmTokens}).then(()=>!0)}}function wh(n){const e=typeof n=="string"?{title:n}:n,{title:t,...r}=e;return r.icon||(r.icon="/img/logo/pwa.png"),r.tag||(r.tag=`default-${new Date().toISOString().slice(0,10)}`),r.data||(r.data={url:"/"}),r?.data?.url||(r.data.url="/"),{title:t,options:r}}const aa=_.reactive({reg:void 0,VAPID_PUBLIC_KEY:void 0,isNotificationSupported:typeof Notification<"u",get permission(){return this.isNotificationSupported?Notification.permission:"denied"},get needToAskPermission(){return this.isNotificationSupported?Notification.permission==="default":!1},async askPermission(n){if(!aa.isNotificationSupported)return U.error("Le notifiche non sono supportate su questo dispositivo"),"denied";aa.permission==="denied"&&U.warning("Notifiche disabilitate. Per abilitarle cercare nelle impostazioni del browser.");const e=await Notification.requestPermission();return e!=="granted"?U.warning("Hai disabilitato le notifiche. Per abilitarle cercare nelle impostazioni del browser."):this.registerFcmToken(n),e},async send(n,e){if(!this.isNotificationSupported){U.error("Le notifiche non sono supportate su questo dispositivo");return}if(this.permission!=="granted"&&await this.askPermission(n)!=="granted")return;const{title:t,options:r}=wh(e);this.reg?await this.reg.showNotification(t,r):new Notification(t,r)},async sendTo(n,e){let t=!1;try{const r=T0(exports.functions,"sendUserPush"),{title:s,options:i}=wh(e);console.log({title:s,options:i}),await r({toUid:n,title:s,options:i}),t=!0}catch(r){console.error(r),U.error("Errore invio notifica")}return t},async getCurrentFcmToken(){return ra(),this.isNotificationSupported?this.reg?this.VAPID_PUBLIC_KEY?await ob(exports.messaging,{vapidKey:this.VAPID_PUBLIC_KEY,serviceWorkerRegistration:this.reg}).catch(()=>null)||null:(U.error("VAPID_PUBLIC_KEY mancante"),null):(U.error("ServiceWorker non registrato"),null):null},async registerFcmToken(n){if(ra(),!this.isNotificationSupported)return null;this.needToAskPermission&&await this.askPermission(n);const e=await this.getCurrentFcmToken();return e?(await n.addFcmToken(e)?U.success("Abilitato"):U.warning("Token non aggiunto possibilmente già presente."),e):null},async removeThisDeviceToken(n){const e=await this.getCurrentFcmToken();let t=!1;try{t=await ab(exports.messaging)}catch(s){console.warn("deleteToken() failed (continuo con cleanup lato currentUser):",s)}let r=!1;if(e)try{r=await n.removeFcmToken(e)}catch(s){console.warn("removeFcmToken() user failed:",s)}return t||r?(U.success("Notifiche disattivate per questo dispositivo."),!0):(U.warning("Nessun token da rimuovere per questo dispositivo."),!1)}});function bs(n){const e=globalThis.structuredClone;if(typeof e=="function")try{return e(n)}catch{return Nt(n)}return Nt(n)}function Nt(n,e=new WeakMap){if(n===null||typeof n!="object")return n;if(e.has(n))return e.get(n);if(n instanceof Date)return new Date(n.getTime());if(n instanceof Map){const r=new Map;return e.set(n,r),n.forEach((s,i)=>r.set(Nt(i,e),Nt(s,e))),r}if(n instanceof Set){const r=new Set;return e.set(n,r),n.forEach(s=>r.add(Nt(s,e))),r}if(Array.isArray(n)){const r=new Array(n.length);e.set(n,r);for(let s=0;s<n.length;s++)r[s]=Nt(n[s],e);return r}const t={};e.set(n,t);for(const r of Object.keys(n))t[r]=Nt(n[r],e);for(const r of Object.getOwnPropertySymbols(n))t[r]=Nt(n[r],e);return t}const pb=(n,e="")=>{const t=n.trim();if(t.startsWith("+")){const r=t.match(/^\+(\d{1,3})\s*(.+)$/);if(r)return[`+${r[1]}`,(r[2]??"").replace(/\s+/g,"")]}return[e,t.replace(/\s+/g,"")]};class mb{id;values;errors;touched;_initial;schema;_onSubmit;_onInvalid;_validateOnChangeMap;_touchOnChangeMap;_stopWatch;_fieldCache={};_allFields;_submitOnChange;_suspendAutoSubmit=!1;_debouncedSubmit;_syncPreference;_effects;_onAnyChange;_makeDebouncedSubmit(e){let t;return()=>{t&&clearTimeout(t),t=window.setTimeout(()=>{this._suspendAutoSubmit||this.submit()},e)}}constructor(e,t){this.id=e.id??"";const r=S=>"initialValues"in S;this._syncPreference=r(e)&&e.syncPreference?e.syncPreference:"db";const s=r(e)?e.initialValues:e,i=Object.keys(s),a=(S,k)=>{const V={};for(const N of i)V[N]=k;if(typeof S=="boolean")for(const N of i)V[N]=S;else S&&typeof S=="object"&&Object.assign(V,S);return V},c=(r(e)?e.validator:t)??{},u=r(e)?e.onSubmit:void 0,h=r(e)?e.onInvalid:void 0,f=r(e)?e.validateOnChange:void 0,m=r(e)?e.touchOnChange:void 0;this._validateOnChangeMap=a(f,!0),this._touchOnChangeMap=a(m,!0);const y=r(e)?e.syncWith:void 0;this._initial=bs(s),this.values=_.reactive(bs(s)),this.errors=_.reactive(Object.keys(s).reduce((S,k)=>(S[k]=null,S),{})),this.touched=_.reactive(Object.keys(s).reduce((S,k)=>(S[k]=!1,S),{})),this.schema=c,this._onSubmit=u,this._onInvalid=h,this._submitOnChange=r(e)?e.submitOnChange:void 0,this._effects=r(e)?e.effects:void 0,this._onAnyChange=r(e)?e.onAnyChange:void 0,typeof this._submitOnChange=="number"&&this._submitOnChange>=0&&(this._debouncedSubmit=this._makeDebouncedSubmit(this._submitOnChange)),y&&(_.isRef(y)?this._stopWatch=_.watch(y,S=>{S&&this.fill(S)},{immediate:!0}):typeof y=="function"&&(this._stopWatch=_.watch(y,S=>{S&&this.fill(S)},{immediate:!0})))}touch(e){this.touched[e]=!0}touchAll(){for(const e of Object.keys(this.touched))this.touched[e]=!0}field(e){const t=this._fieldCache[e];if(t)return t;const r=_.computed({get:()=>this.values[e],set:s=>this.set(e,s)});return this._fieldCache[e]=r,r}fields(){if(!this._allFields){const e={};for(const t of Object.keys(this.values))e[t]=this.field(t);this._allFields=e}return this._allFields}set(e,t,r){this.values[e]=t,!this.touched[e]&&(this._touchOnChangeMap[e]??!1)&&(this.touched[e]=!0),(r??!!this._validateOnChangeMap[e])&&this.validateField(e),this._effects?.[e]?.(t,this),this._onAnyChange?.(e,t,this),!this._suspendAutoSubmit&&this._submitOnChange&&(this._submitOnChange===!0?this.submit():typeof this._submitOnChange=="number"&&this._debouncedSubmit?.())}validateField(e){const t=this.schema[e]??[];for(const r of t){const s=r(this.values[e]);if(this.errors[e]=s,s)return!1}return this.errors[e]=null,!0}validateAll(){let e=!0;for(const t of Object.keys(this.values))this.validateField(t)||(this.touch(t),e=!1);return e}fill(e,t){let{validate:r}=t??{};r===void 0&&(r=!1),this._suspendAutoSubmit=!0;try{for(const s in e){if(!(s in this.values))continue;const i=s;this._syncPreference==="local"&&this.touched[i]||(this.values[i]=e[i])}r&&this.validateAll()}finally{this._suspendAutoSubmit=!1}}reset({keepTouched:e=!1}={}){for(const t of Object.keys(this._initial))this.values[t]=this._initial[t];for(const t of Object.keys(this.errors))this.errors[t]=null;if(!e)for(const t of Object.keys(this.touched))this.touched[t]=!1}resetWithInitialValues(e){this._initial=bs(e),this.reset()}bindField(e,t){return _.computed({get:()=>this.values[e],set:r=>this.set(e,r,t??this._validateOnChangeMap[e]??!1)})}showError(e){return this.touched[e]?this.errors[e]:null}hasError(e){return!!this.showError(e)}getFieldId(e){return`${this.id!==""?this.id+"_":""}field_${String(e)}`}getFieldIdError(e){return`${this.getFieldId(e)}-error`}getFieldProps(e){return{id:this.getFieldId(e),"aria-invalid":this.hasError(e),"aria-describedby":this.getFieldIdError(e),class:{"is-invalid":!!this.showError(e)}}}get isValid(){return Object.values(this.errors).every(e=>e==null)}get isDirty(){return JSON.stringify(this.values)!==JSON.stringify(this._initial)}get touchedValues(){const e={};for(const t of Object.keys(this.values))this.touched[t]&&(e[t]=this.values[t]);return e}dispose(){this._stopWatch?.()}submit=async()=>{if(!this.validateAll()){this._onInvalid?.(this.errors);return}await this._onSubmit?.(this.values,this.touchedValues,this.touched)};setSyncPreference(e){this._syncPreference=e}}const gb=(n="Obbligatorio")=>e=>e==null||typeof e=="string"&&e.trim().length===0||Array.isArray(e)&&e.length===0?n:null,_b=(n="Email non valida")=>e=>e?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)?null:n:null,yb=(n="Formato richiesto: AAAA-MM-GG")=>e=>e?/^\d{4}-\d{2}-\d{2}$/.test(e)?null:n:null,Tb=(n="URL non valido")=>e=>{if(!e)return null;try{return new URL(e),null}catch{return n}},wb=(n,e="Seleziona un’opzione")=>t=>t?n.includes(t)?null:e:null,Eb=(n="Devi accettare")=>e=>e?null:n,vb=(n="Deve essere un numero")=>e=>e==null||e===""?null:isNaN(Number(e))?n:null,Ib=(n,e)=>t=>{if(t==null||t==="")return null;const r=Number(t);return isNaN(r)?e??"Deve essere un numero":r<n?e??`Il numero deve essere ≥ ${n}`:null},Ab=(n,e)=>t=>{if(t==null||t==="")return null;const r=Number(t);return isNaN(r)?e??"Deve essere un numero":r>n?e??`Il numero deve essere ≤ ${n}`:null},bb=(n,e)=>t=>t&&t.length<n?e??`Minimo ${n} caratteri`:null,Sb=(n,e)=>t=>t&&t.length>n?e??`Massimo ${n} caratteri`:null,Lp=/^(?=.*[A-Z])(?=.*\d)(?!.*\s).+$/,Rb=(n="La password deve contenere almeno una maiuscola, un numero e nessuno spazio")=>e=>e?Lp.test(e)?null:n:null,Pb=(n,e)=>t=>t?t.length<n?e??`La password deve avere almeno ${n} caratteri`:Lp.test(t)?null:e??"La password deve contenere almeno una maiuscola, un numero e nessuno spazio":null,Cb=(n,e="Le password non coincidono")=>t=>{if(!t)return null;const r=n()??"";return t===r?null:e};function un(n){if(!n)return null;if(n instanceof Date)return isNaN(n.getTime())?null:n;if(/^\d{4}-\d{2}-\d{2}$/.test(n)){const e=new Date(n+"T00:00:00");return isNaN(e.getTime())?null:e}return null}const kb=(n,e="La data deve essere successiva")=>t=>{if(!t)return null;const r=un(t),s=un(n());return!r||!s||r>=s?null:e},Nb=(n,e="La data deve essere precedente")=>t=>{if(!t)return null;const r=un(t),s=un(n());return!r||!s||r<=s?null:e},Db=(n,e,t="La data deve essere compresa nell’intervallo")=>r=>{if(!r)return null;const s=un(r),i=un(n()),a=un(e());return!s||!i||!a||s>=i&&s<=a?null:t},ni=n=>String(n).padStart(2,"0");function ri(n){return n instanceof Date&&!isNaN(n.getTime())}function Ni(n){if(!n)return null;if(n instanceof Date)return ri(n)?n:null;if(n instanceof z)return n.toDate();if(typeof n=="string"||typeof n=="number"){const e=new Date(n);return ri(e)?e:null}return null}function Mp(n){const e=Ni(n);return e?`${e.getFullYear()}-${ni(e.getMonth()+1)}-${ni(e.getDate())}`:""}function xp(n){const e=Ni(n);return e?`${ni(e.getHours())}:${ni(e.getMinutes())}`:""}function Vb(n){const e=Ni(n);return e?`${Mp(e)}T${xp(e)}`:""}function Ob(n){if(!n)return null;const e=new Date(`${n}T00:00:00`);return ri(e)?e:null}function Lb(n,e){if(!n)return null;console.log(e);const t=e&&e!==""?e:"00:00";console.log(`${n}T${t}:00`);const r=new Date(`${n}T${t}:00`);return ri(r)?z.fromDate(r):null}function Mb(n,e=""){return n==null?e:String(n)}function xb(n){if(n==null||n==="")return"";const e=Number(n);return isNaN(e)?"":e}function Fb(n){return!!n}function Ub(n){return Array.isArray(n)?n.map(e=>String(e)).filter(Boolean):[]}function Bb(n,e){if(!n)return"";const t=String(n);return e&&!e.includes(t)?"":t}function qb(n,e=void 0){const t=Ni(n);return t?t.toLocaleString(e):""}function $b(n){if(n==null)return"-";const e=String(n).trim();return e===""?"-":e}const jb={install(n){n.component("AccordionCmp",Eh),n.component("Btn",gr),n.component("ToastCmp",Ah),n.component("FieldGender",bh),n.component("FieldPhoneNumber",Sh),n.component("InputField",Rh)}};exports.AccordionCmp=Eh;exports.Btn=gr;exports.CicKit=jb;exports.FieldGender=bh;exports.FieldPhoneNumber=Sh;exports.FirestoreModel=Ge;exports.FirestoreStore=hb;exports.FormValidator=mb;exports.InputField=Rh;exports.LS=Ce;exports.Toast=vh;exports.ToastCmp=Ah;exports.User=fb;exports.buildConstraintsFromGetProps=oa;exports.cicKitStore=je;exports.clone=bs;exports.dateAfter=kb;exports.dateBefore=Nb;exports.dateBetween=Db;exports.dateISO=yb;exports.defaultUserPermission=Op;exports.email=_b;exports.emptyToDash=$b;exports.ensureFirebase=ra;exports.fireDebugLog=ti;exports.inputDateTimeToTimestamp=Lb;exports.inputDateToDate=Ob;exports.isBrowserOffline=wc;exports.isBrowserOnline=Vp;exports.isNumber=vb;exports.maxLength=Sb;exports.maxNumber=Ab;exports.middlewareCatchCall=nt;exports.minLength=bb;exports.minNumber=Ib;exports.oneOf=wb;exports.optionFireModelDefault=ge;exports.password=Rb;exports.passwordRetype=Cb;exports.passwordWithMin=Pb;exports.phoneNumberFromString=pb;exports.pushMsg=aa;exports.required=gb;exports.requiredTrue=Eb;exports.reviveTimestamp=Ar;exports.reviveTimestampsDeep=sa;exports.serializeTimestamp=ei;exports.setupFirebase=cb;exports.shareLink=Ih;exports.signInWithPopup=cw;exports.timestampInputDate=Mp;exports.timestampInputDateTimeLocal=Vb;exports.timestampInputTime=xp;exports.timestampToLocale=qb;exports.toast=U;exports.url=Tb;exports.useStoreWatch=db;exports.validateQueryGetOpts=Ec;exports.valueToInputBoolean=Fb;exports.valueToInputNumber=xb;exports.valueToInputString=Mb;exports.valueToSelect=Bb;exports.valueToStringArray=Ub;
|
|
35
|
+
)`}copy(e,t){const r=new Ur;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=t,r}}class Kf{constructor(){this.ga=new ce(B.comparator)}track(e){const t=e.doc.key,r=this.ga.get(t);r?e.type!==0&&r.type===3?this.ga=this.ga.insert(t,e):e.type===3&&r.type!==1?this.ga=this.ga.insert(t,{type:r.type,doc:e.doc}):e.type===2&&r.type===2?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):e.type===2&&r.type===0?this.ga=this.ga.insert(t,{type:0,doc:e.doc}):e.type===1&&r.type===0?this.ga=this.ga.remove(t):e.type===1&&r.type===2?this.ga=this.ga.insert(t,{type:1,doc:r.doc}):e.type===0&&r.type===1?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):W(63341,{Vt:e,pa:r}):this.ga=this.ga.insert(t,e)}ya(){const e=[];return this.ga.inorderTraversal(((t,r)=>{e.push(r)})),e}}class es{constructor(e,t,r,s,i,o,c,l,h){this.query=e,this.docs=t,this.oldDocs=r,this.docChanges=s,this.mutatedKeys=i,this.fromCache=o,this.syncStateChanged=c,this.excludesMetadataChanges=l,this.hasCachedResults=h}static fromInitialDocuments(e,t,r,s,i){const o=[];return t.forEach((c=>{o.push({type:0,doc:c})})),new es(e,t,Ur.emptySet(t),o,r,s,!0,!1,i)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&va(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,r=e.docChanges;if(t.length!==r.length)return!1;for(let s=0;s<t.length;s++)if(t[s].type!==r[s].type||!t[s].doc.isEqual(r[s].doc))return!1;return!0}}class pD{constructor(){this.wa=void 0,this.ba=[]}Sa(){return this.ba.some((e=>e.Da()))}}class mD{constructor(){this.queries=Gf(),this.onlineState="Unknown",this.Ca=new Set}terminate(){(function(t,r){const s=Y(t),i=s.queries;s.queries=Gf(),i.forEach(((o,c)=>{for(const l of c.ba)l.onError(r)}))})(this,new M(N.ABORTED,"Firestore shutting down"))}}function Gf(){return new fr((n=>C_(n)),va)}async function ku(n,e){const t=Y(n);let r=3;const s=e.query;let i=t.queries.get(s);i?!i.Sa()&&e.Da()&&(r=2):(i=new pD,r=e.Da()?0:1);try{switch(r){case 0:i.wa=await t.onListen(s,!0);break;case 1:i.wa=await t.onListen(s,!1);break;case 2:await t.onFirstRemoteStoreListen(s)}}catch(o){const c=Ru(o,`Initialization of query '${Nr(e.query)}' failed`);return void e.onError(c)}t.queries.set(s,i),i.ba.push(e),e.va(t.onlineState),i.wa&&e.Fa(i.wa)&&Nu(t)}async function Pu(n,e){const t=Y(n),r=e.query;let s=3;const i=t.queries.get(r);if(i){const o=i.ba.indexOf(e);o>=0&&(i.ba.splice(o,1),i.ba.length===0?s=e.Da()?0:1:!i.Sa()&&e.Da()&&(s=2))}switch(s){case 0:return t.queries.delete(r),t.onUnlisten(r,!0);case 1:return t.queries.delete(r),t.onUnlisten(r,!1);case 2:return t.onLastRemoteStoreUnlisten(r);default:return}}function gD(n,e){const t=Y(n);let r=!1;for(const s of e){const i=s.query,o=t.queries.get(i);if(o){for(const c of o.ba)c.Fa(s)&&(r=!0);o.wa=s}}r&&Nu(t)}function _D(n,e,t){const r=Y(n),s=r.queries.get(e);if(s)for(const i of s.ba)i.onError(t);r.queries.delete(e)}function Nu(n){n.Ca.forEach((e=>{e.next()}))}var fl,Yf;(Yf=fl||(fl={})).Ma="default",Yf.Cache="cache";class Du{constructor(e,t,r){this.query=e,this.xa=t,this.Oa=!1,this.Na=null,this.onlineState="Unknown",this.options=r||{}}Fa(e){if(!this.options.includeMetadataChanges){const r=[];for(const s of e.docChanges)s.type!==3&&r.push(s);e=new es(e.query,e.docs,e.oldDocs,r,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Oa?this.Ba(e)&&(this.xa.next(e),t=!0):this.La(e,this.onlineState)&&(this.ka(e),t=!0),this.Na=e,t}onError(e){this.xa.error(e)}va(e){this.onlineState=e;let t=!1;return this.Na&&!this.Oa&&this.La(this.Na,e)&&(this.ka(this.Na),t=!0),t}La(e,t){if(!e.fromCache||!this.Da())return!0;const r=t!=="Offline";return(!this.options.Ka||!r)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}Ba(e){if(e.docChanges.length>0)return!0;const t=this.Na&&this.Na.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}ka(e){e=es.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Oa=!0,this.xa.next(e)}Da(){return this.options.source!==fl.Cache}}class cy{constructor(e){this.key=e}}class ly{constructor(e){this.key=e}}class yD{constructor(e,t){this.query=e,this.Za=t,this.Xa=null,this.hasCachedResults=!1,this.current=!1,this.Ya=ee(),this.mutatedKeys=ee(),this.eu=R_(e),this.tu=new Ur(this.eu)}get nu(){return this.Za}ru(e,t){const r=t?t.iu:new Kf,s=t?t.tu:this.tu;let i=t?t.mutatedKeys:this.mutatedKeys,o=s,c=!1;const l=this.query.limitType==="F"&&s.size===this.query.limit?s.last():null,h=this.query.limitType==="L"&&s.size===this.query.limit?s.first():null;if(e.inorderTraversal(((f,g)=>{const _=s.get(f),T=Ta(this.query,g)?g:null,C=!!_&&this.mutatedKeys.has(_.key),P=!!T&&(T.hasLocalMutations||this.mutatedKeys.has(T.key)&&T.hasCommittedMutations);let k=!1;_&&T?_.data.isEqual(T.data)?C!==P&&(r.track({type:3,doc:T}),k=!0):this.su(_,T)||(r.track({type:2,doc:T}),k=!0,(l&&this.eu(T,l)>0||h&&this.eu(T,h)<0)&&(c=!0)):!_&&T?(r.track({type:0,doc:T}),k=!0):_&&!T&&(r.track({type:1,doc:_}),k=!0,(l||h)&&(c=!0)),k&&(T?(o=o.add(T),i=P?i.add(f):i.delete(f)):(o=o.delete(f),i=i.delete(f)))})),this.query.limit!==null)for(;o.size>this.query.limit;){const f=this.query.limitType==="F"?o.last():o.first();o=o.delete(f.key),i=i.delete(f.key),r.track({type:1,doc:f})}return{tu:o,iu:r,Ss:c,mutatedKeys:i}}su(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,r,s){const i=this.tu;this.tu=e.tu,this.mutatedKeys=e.mutatedKeys;const o=e.iu.ya();o.sort(((f,g)=>(function(T,C){const P=k=>{switch(k){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return W(20277,{Vt:k})}};return P(T)-P(C)})(f.type,g.type)||this.eu(f.doc,g.doc))),this.ou(r),s=s??!1;const c=t&&!s?this._u():[],l=this.Ya.size===0&&this.current&&!s?1:0,h=l!==this.Xa;return this.Xa=l,o.length!==0||h?{snapshot:new es(this.query,e.tu,i,o,e.mutatedKeys,l===0,h,!1,!!r&&r.resumeToken.approximateByteSize()>0),au:c}:{au:c}}va(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({tu:this.tu,iu:new Kf,mutatedKeys:this.mutatedKeys,Ss:!1},!1)):{au:[]}}uu(e){return!this.Za.has(e)&&!!this.tu.has(e)&&!this.tu.get(e).hasLocalMutations}ou(e){e&&(e.addedDocuments.forEach((t=>this.Za=this.Za.add(t))),e.modifiedDocuments.forEach((t=>{})),e.removedDocuments.forEach((t=>this.Za=this.Za.delete(t))),this.current=e.current)}_u(){if(!this.current)return[];const e=this.Ya;this.Ya=ee(),this.tu.forEach((r=>{this.uu(r.key)&&(this.Ya=this.Ya.add(r.key))}));const t=[];return e.forEach((r=>{this.Ya.has(r)||t.push(new ly(r))})),this.Ya.forEach((r=>{e.has(r)||t.push(new cy(r))})),t}cu(e){this.Za=e.ks,this.Ya=ee();const t=this.ru(e.documents);return this.applyChanges(t,!0)}lu(){return es.fromInitialDocuments(this.query,this.tu,this.mutatedKeys,this.Xa===0,this.hasCachedResults)}}const Ou="SyncEngine";class ED{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}}class vD{constructor(e){this.key=e,this.hu=!1}}class TD{constructor(e,t,r,s,i,o){this.localStore=e,this.remoteStore=t,this.eventManager=r,this.sharedClientState=s,this.currentUser=i,this.maxConcurrentLimboResolutions=o,this.Pu={},this.Tu=new fr((c=>C_(c)),va),this.Iu=new Map,this.Eu=new Set,this.Ru=new ce(B.comparator),this.Au=new Map,this.Vu=new Eu,this.du={},this.mu=new Map,this.fu=Zr.ar(),this.onlineState="Unknown",this.gu=void 0}get isPrimaryClient(){return this.gu===!0}}async function wD(n,e,t=!0){const r=my(n);let s;const i=r.Tu.get(e);return i?(r.sharedClientState.addLocalQueryTarget(i.targetId),s=i.view.lu()):s=await uy(r,e,t,!0),s}async function bD(n,e){const t=my(n);await uy(t,e,!0,!1)}async function uy(n,e,t,r){const s=await qN(n.localStore,Ct(e)),i=s.targetId,o=n.sharedClientState.addLocalQueryTarget(i,t);let c;return r&&(c=await AD(n,e,i,o==="current",s.resumeToken)),n.isPrimaryClient&&t&&ny(n.remoteStore,s),c}async function AD(n,e,t,r,s){n.pu=(g,_,T)=>(async function(P,k,L,$){let U=k.view.ru(L);U.Ss&&(U=await Bf(P.localStore,k.query,!1).then((({documents:w})=>k.view.ru(w,U))));const F=$&&$.targetChanges.get(k.targetId),j=$&&$.targetMismatches.get(k.targetId)!=null,H=k.view.applyChanges(U,P.isPrimaryClient,F,j);return Jf(P,k.targetId,H.au),H.snapshot})(n,g,_,T);const i=await Bf(n.localStore,e,!0),o=new yD(e,i.ks),c=o.ru(i.documents),l=vi.createSynthesizedTargetChangeForCurrentChange(t,r&&n.onlineState!=="Offline",s),h=o.applyChanges(c,n.isPrimaryClient,l);Jf(n,t,h.au);const f=new ED(e,t,o);return n.Tu.set(e,f),n.Iu.has(t)?n.Iu.get(t).push(e):n.Iu.set(t,[e]),h.snapshot}async function ID(n,e,t){const r=Y(n),s=r.Tu.get(e),i=r.Iu.get(s.targetId);if(i.length>1)return r.Iu.set(s.targetId,i.filter((o=>!va(o,e)))),void r.Tu.delete(e);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(s.targetId),r.sharedClientState.isActiveQueryTarget(s.targetId)||await hl(r.localStore,s.targetId,!1).then((()=>{r.sharedClientState.clearQueryState(s.targetId),t&&bu(r.remoteStore,s.targetId),pl(r,s.targetId)})).catch(ls)):(pl(r,s.targetId),await hl(r.localStore,s.targetId,!0))}async function SD(n,e){const t=Y(n),r=t.Tu.get(e),s=t.Iu.get(r.targetId);t.isPrimaryClient&&s.length===1&&(t.sharedClientState.removeLocalQueryTarget(r.targetId),bu(t.remoteStore,r.targetId))}async function CD(n,e,t){const r=VD(n);try{const s=await(function(o,c){const l=Y(o),h=J.now(),f=c.reduce(((T,C)=>T.add(C.key)),ee());let g,_;return l.persistence.runTransaction("Locally write mutations","readwrite",(T=>{let C=Xt(),P=ee();return l.xs.getEntries(T,f).next((k=>{C=k,C.forEach(((L,$)=>{$.isValidDocument()||(P=P.add(L))}))})).next((()=>l.localDocuments.getOverlayedDocuments(T,C))).next((k=>{g=k;const L=[];for(const $ of c){const U=BP($,g.get($.key).overlayedDocument);U!=null&&L.push(new xn($.key,U,E_(U.value.mapValue),gt.exists(!0)))}return l.mutationQueue.addMutationBatch(T,h,L,c)})).next((k=>{_=k;const L=k.applyToLocalDocumentSet(g,P);return l.documentOverlayCache.saveOverlays(T,k.batchId,L)}))})).then((()=>({batchId:_.batchId,changes:P_(g)})))})(r.localStore,e);r.sharedClientState.addPendingMutation(s.batchId),(function(o,c,l){let h=o.du[o.currentUser.toKey()];h||(h=new ce(Z)),h=h.insert(c,l),o.du[o.currentUser.toKey()]=h})(r,s.batchId,t),await wi(r,s.changes),await Ca(r.remoteStore)}catch(s){const i=Ru(s,"Failed to persist write");t.reject(i)}}async function hy(n,e){const t=Y(n);try{const r=await $N(t.localStore,e);e.targetChanges.forEach(((s,i)=>{const o=t.Au.get(i);o&&(ne(s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size<=1,22616),s.addedDocuments.size>0?o.hu=!0:s.modifiedDocuments.size>0?ne(o.hu,14607):s.removedDocuments.size>0&&(ne(o.hu,42227),o.hu=!1))})),await wi(t,r,e)}catch(r){await ls(r)}}function Qf(n,e,t){const r=Y(n);if(r.isPrimaryClient&&t===0||!r.isPrimaryClient&&t===1){const s=[];r.Tu.forEach(((i,o)=>{const c=o.view.va(e);c.snapshot&&s.push(c.snapshot)})),(function(o,c){const l=Y(o);l.onlineState=c;let h=!1;l.queries.forEach(((f,g)=>{for(const _ of g.ba)_.va(c)&&(h=!0)})),h&&Nu(l)})(r.eventManager,e),s.length&&r.Pu.J_(s),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}async function RD(n,e,t){const r=Y(n);r.sharedClientState.updateQueryState(e,"rejected",t);const s=r.Au.get(e),i=s&&s.key;if(i){let o=new ce(B.comparator);o=o.insert(i,Re.newNoDocument(i,G.min()));const c=ee().add(i),l=new Aa(G.min(),new Map,new ce(Z),o,c);await hy(r,l),r.Ru=r.Ru.remove(i),r.Au.delete(e),Vu(r)}else await hl(r.localStore,e,!1).then((()=>pl(r,e,t))).catch(ls)}async function kD(n,e){const t=Y(n),r=e.batch.batchId;try{const s=await FN(t.localStore,e);fy(t,r,null),dy(t,r),t.sharedClientState.updateMutationState(r,"acknowledged"),await wi(t,s)}catch(s){await ls(s)}}async function PD(n,e,t){const r=Y(n);try{const s=await(function(o,c){const l=Y(o);return l.persistence.runTransaction("Reject batch","readwrite-primary",(h=>{let f;return l.mutationQueue.lookupMutationBatch(h,c).next((g=>(ne(g!==null,37113),f=g.keys(),l.mutationQueue.removeMutationBatch(h,g)))).next((()=>l.mutationQueue.performConsistencyCheck(h))).next((()=>l.documentOverlayCache.removeOverlaysForBatchId(h,f,c))).next((()=>l.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(h,f))).next((()=>l.localDocuments.getDocuments(h,f)))}))})(r.localStore,e);fy(r,e,t),dy(r,e),r.sharedClientState.updateMutationState(e,"rejected",t),await wi(r,s)}catch(s){await ls(s)}}function dy(n,e){(n.mu.get(e)||[]).forEach((t=>{t.resolve()})),n.mu.delete(e)}function fy(n,e,t){const r=Y(n);let s=r.du[r.currentUser.toKey()];if(s){const i=s.get(e);i&&(t?i.reject(t):i.resolve(),s=s.remove(e)),r.du[r.currentUser.toKey()]=s}}function pl(n,e,t=null){n.sharedClientState.removeLocalQueryTarget(e);for(const r of n.Iu.get(e))n.Tu.delete(r),t&&n.Pu.yu(r,t);n.Iu.delete(e),n.isPrimaryClient&&n.Vu.Gr(e).forEach((r=>{n.Vu.containsKey(r)||py(n,r)}))}function py(n,e){n.Eu.delete(e.path.canonicalString());const t=n.Ru.get(e);t!==null&&(bu(n.remoteStore,t),n.Ru=n.Ru.remove(e),n.Au.delete(t),Vu(n))}function Jf(n,e,t){for(const r of t)r instanceof cy?(n.Vu.addReference(r.key,e),ND(n,r)):r instanceof ly?(x(Ou,"Document no longer in limbo: "+r.key),n.Vu.removeReference(r.key,e),n.Vu.containsKey(r.key)||py(n,r.key)):W(19791,{wu:r})}function ND(n,e){const t=e.key,r=t.path.canonicalString();n.Ru.get(t)||n.Eu.has(r)||(x(Ou,"New document in limbo: "+t),n.Eu.add(r),Vu(n))}function Vu(n){for(;n.Eu.size>0&&n.Ru.size<n.maxConcurrentLimboResolutions;){const e=n.Eu.values().next().value;n.Eu.delete(e);const t=new B(se.fromString(e)),r=n.fu.next();n.Au.set(r,new vD(t)),n.Ru=n.Ru.insert(t,r),ny(n.remoteStore,new yn(Ct(Ea(t.path)),r,"TargetPurposeLimboResolution",ga.ce))}}async function wi(n,e,t){const r=Y(n),s=[],i=[],o=[];r.Tu.isEmpty()||(r.Tu.forEach(((c,l)=>{o.push(r.pu(l,e,t).then((h=>{if((h||t)&&r.isPrimaryClient){const f=h?!h.fromCache:t?.targetChanges.get(l.targetId)?.current;r.sharedClientState.updateQueryState(l.targetId,f?"current":"not-current")}if(h){s.push(h);const f=Tu.Es(l.targetId,h);i.push(f)}})))})),await Promise.all(o),r.Pu.J_(s),await(async function(l,h){const f=Y(l);try{await f.persistence.runTransaction("notifyLocalViewChanges","readwrite",(g=>D.forEach(h,(_=>D.forEach(_.Ts,(T=>f.persistence.referenceDelegate.addReference(g,_.targetId,T))).next((()=>D.forEach(_.Is,(T=>f.persistence.referenceDelegate.removeReference(g,_.targetId,T)))))))))}catch(g){if(!us(g))throw g;x(wu,"Failed to update sequence numbers: "+g)}for(const g of h){const _=g.targetId;if(!g.fromCache){const T=f.vs.get(_),C=T.snapshotVersion,P=T.withLastLimboFreeSnapshotVersion(C);f.vs=f.vs.insert(_,P)}}})(r.localStore,i))}async function DD(n,e){const t=Y(n);if(!t.currentUser.isEqual(e)){x(Ou,"User change. New user:",e.toKey());const r=await X_(t.localStore,e);t.currentUser=e,(function(i,o){i.mu.forEach((c=>{c.forEach((l=>{l.reject(new M(N.CANCELLED,o))}))})),i.mu.clear()})(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,r.removedBatchIds,r.addedBatchIds),await wi(t,r.Ns)}}function OD(n,e){const t=Y(n),r=t.Au.get(e);if(r&&r.hu)return ee().add(r.key);{let s=ee();const i=t.Iu.get(e);if(!i)return s;for(const o of i){const c=t.Tu.get(o);s=s.unionWith(c.view.nu)}return s}}function my(n){const e=Y(n);return e.remoteStore.remoteSyncer.applyRemoteEvent=hy.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=OD.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=RD.bind(null,e),e.Pu.J_=gD.bind(null,e.eventManager),e.Pu.yu=_D.bind(null,e.eventManager),e}function VD(n){const e=Y(n);return e.remoteStore.remoteSyncer.applySuccessfulWrite=kD.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=PD.bind(null,e),e}class Uo{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=Ia(e.databaseInfo.databaseId),this.sharedClientState=this.Du(e),this.persistence=this.Cu(e),await this.persistence.start(),this.localStore=this.vu(e),this.gcScheduler=this.Fu(e,this.localStore),this.indexBackfillerScheduler=this.Mu(e,this.localStore)}Fu(e,t){return null}Mu(e,t){return null}vu(e){return xN(this.persistence,new VN,e.initialUser,this.serializer)}Cu(e){return new J_(vu.Vi,this.serializer)}Du(e){return new HN}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}Uo.provider={build:()=>new Uo};class LD extends Uo{constructor(e){super(),this.cacheSizeBytes=e}Fu(e,t){ne(this.persistence.referenceDelegate instanceof Fo,46915);const r=this.persistence.referenceDelegate.garbageCollector;return new EN(r,e.asyncQueue,t)}Cu(e){const t=this.cacheSizeBytes!==void 0?$e.withCacheSize(this.cacheSizeBytes):$e.DEFAULT;return new J_((r=>Fo.Vi(r,t)),this.serializer)}}class ml{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=r=>Qf(this.syncEngine,r,1),this.remoteStore.remoteSyncer.handleCredentialChange=DD.bind(null,this.syncEngine),await fD(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return(function(){return new mD})()}createDatastore(e){const t=Ia(e.databaseInfo.databaseId),r=YN(e.databaseInfo);return eD(e.authCredentials,e.appCheckCredentials,r,t)}createRemoteStore(e){return(function(r,s,i,o,c){return new nD(r,s,i,o,c)})(this.localStore,this.datastore,e.asyncQueue,(t=>Qf(this.syncEngine,t,0)),(function(){return Hf.v()?new Hf:new WN})())}createSyncEngine(e,t){return(function(s,i,o,c,l,h,f){const g=new TD(s,i,o,c,l,h);return f&&(g.gu=!0),g})(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){await(async function(t){const r=Y(t);x(ar,"RemoteStore shutting down."),r.Ea.add(5),await Ti(r),r.Aa.shutdown(),r.Va.set("Unknown")})(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}}ml.provider={build:()=>new ml};class Lu{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ou(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ou(this.observer.error,e):Jt("Uncaught Error in snapshot listener:",e.toString()))}Nu(){this.muted=!0}Ou(e,t){setTimeout((()=>{this.muted||e(t)}),0)}}const Pn="FirestoreClient";class MD{constructor(e,t,r,s,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=r,this._databaseInfo=s,this.user=Ce.UNAUTHENTICATED,this.clientId=cu.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(r,(async o=>{x(Pn,"Received user=",o.uid),await this.authCredentialListener(o),this.user=o})),this.appCheckCredentials.start(r,(o=>(x(Pn,"Received new app check token=",o),this.appCheckCredentialListener(o,this.user))))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this._databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();const e=new zt;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){const r=Ru(t,"Failed to shutdown persistence");e.reject(r)}})),e.promise}}async function Rc(n,e){n.asyncQueue.verifyOperationInProgress(),x(Pn,"Initializing OfflineComponentProvider");const t=n.configuration;await e.initialize(t);let r=t.initialUser;n.setCredentialChangeListener((async s=>{r.isEqual(s)||(await X_(e.localStore,s),r=s)})),e.persistence.setDatabaseDeletedListener((()=>n.terminate())),n._offlineComponents=e}async function Xf(n,e){n.asyncQueue.verifyOperationInProgress();const t=await xD(n);x(Pn,"Initializing OnlineComponentProvider"),await e.initialize(t,n.configuration),n.setCredentialChangeListener((r=>zf(e.remoteStore,r))),n.setAppCheckTokenChangeListener(((r,s)=>zf(e.remoteStore,s))),n._onlineComponents=e}async function xD(n){if(!n._offlineComponents)if(n._uninitializedComponentsProvider){x(Pn,"Using user provided OfflineComponentProvider");try{await Rc(n,n._uninitializedComponentsProvider._offline)}catch(e){const t=e;if(!(function(s){return s.name==="FirebaseError"?s.code===N.FAILED_PRECONDITION||s.code===N.UNIMPLEMENTED:!(typeof DOMException<"u"&&s instanceof DOMException)||s.code===22||s.code===20||s.code===11})(t))throw t;Yr("Error using user provided cache. Falling back to memory cache: "+t),await Rc(n,new Uo)}}else x(Pn,"Using default OfflineComponentProvider"),await Rc(n,new LD(void 0));return n._offlineComponents}async function gy(n){return n._onlineComponents||(n._uninitializedComponentsProvider?(x(Pn,"Using user provided OnlineComponentProvider"),await Xf(n,n._uninitializedComponentsProvider._online)):(x(Pn,"Using default OnlineComponentProvider"),await Xf(n,new ml))),n._onlineComponents}function FD(n){return gy(n).then((e=>e.syncEngine))}async function Bo(n){const e=await gy(n),t=e.eventManager;return t.onListen=wD.bind(null,e.syncEngine),t.onUnlisten=ID.bind(null,e.syncEngine),t.onFirstRemoteStoreListen=bD.bind(null,e.syncEngine),t.onLastRemoteStoreUnlisten=SD.bind(null,e.syncEngine),t}function $D(n,e,t,r){const s=new Lu(r),i=new Du(e,s,t);return n.asyncQueue.enqueueAndForget((async()=>ku(await Bo(n),i))),()=>{s.Nu(),n.asyncQueue.enqueueAndForget((async()=>Pu(await Bo(n),i)))}}function UD(n,e,t={}){const r=new zt;return n.asyncQueue.enqueueAndForget((async()=>(function(i,o,c,l,h){const f=new Lu({next:_=>{f.Nu(),o.enqueueAndForget((()=>Pu(i,g)));const T=_.docs.has(c);!T&&_.fromCache?h.reject(new M(N.UNAVAILABLE,"Failed to get document because the client is offline.")):T&&_.fromCache&&l&&l.source==="server"?h.reject(new M(N.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):h.resolve(_)},error:_=>h.reject(_)}),g=new Du(Ea(c.path),f,{includeMetadataChanges:!0,Ka:!0});return ku(i,g)})(await Bo(n),n.asyncQueue,e,t,r))),r.promise}function BD(n,e,t={}){const r=new zt;return n.asyncQueue.enqueueAndForget((async()=>(function(i,o,c,l,h){const f=new Lu({next:_=>{f.Nu(),o.enqueueAndForget((()=>Pu(i,g))),_.fromCache&&l.source==="server"?h.reject(new M(N.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):h.resolve(_)},error:_=>h.reject(_)}),g=new Du(c,f,{includeMetadataChanges:!0,Ka:!0});return ku(i,g)})(await Bo(n),n.asyncQueue,e,t,r))),r.promise}function qD(n,e){const t=new zt;return n.asyncQueue.enqueueAndForget((async()=>CD(await FD(n),e,t))),t.promise}function _y(n){const e={};return n.timeoutSeconds!==void 0&&(e.timeoutSeconds=n.timeoutSeconds),e}const jD="ComponentProvider",Zf=new Map;function HD(n,e,t,r,s){return new lP(n,e,t,s.host,s.ssl,s.experimentalForceLongPolling,s.experimentalAutoDetectLongPolling,_y(s.experimentalLongPollingOptions),s.useFetchStreams,s.isUsingEmulator,r)}const yy="firestore.googleapis.com",ep=!0;class tp{constructor(e){if(e.host===void 0){if(e.ssl!==void 0)throw new M(N.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=yy,this.ssl=ep}else this.host=e.host,this.ssl=e.ssl??ep;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=Q_;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<_N)throw new M(N.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}Jk("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=_y(e.experimentalLongPollingOptions??{}),(function(r){if(r.timeoutSeconds!==void 0){if(isNaN(r.timeoutSeconds))throw new M(N.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (must not be NaN)`);if(r.timeoutSeconds<5)throw new M(N.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (minimum allowed value is 5)`);if(r.timeoutSeconds>30)throw new M(N.INVALID_ARGUMENT,`invalid long polling timeout: ${r.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(r,s){return r.timeoutSeconds===s.timeoutSeconds})(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class Ra{constructor(e,t,r,s){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=r,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new tp({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new M(N.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 M(N.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 tp(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=(function(r){if(!r)return new Bk;switch(r.type){case"firstParty":return new Wk(r.sessionIndex||"0",r.iamToken||null,r.authTokenFactory||null);case"provider":return r.client;default:throw new M(N.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}})(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return(function(t){const r=Zf.get(t);r&&(x(jD,"Removing Datastore"),Zf.delete(t),r.terminate())})(this),Promise.resolve()}}function Ey(n,e,t,r={}){n=Qe(n,Ra);const s=en(e),i=n._getSettings(),o={...i,emulatorOptions:n._getEmulatorOptions()},c=`${e}:${t}`;s&&(oa(`https://${c}`),aa("Firestore",!0)),i.host!==yy&&i.host!==c&&Yr("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");const l={...i,host:c,ssl:s,emulatorOptions:r};if(!An(l,o)&&(n._setSettings(l),r.mockUserToken)){let h,f;if(typeof r.mockUserToken=="string")h=r.mockUserToken,f=Ce.MOCK_USER;else{h=Gm(r.mockUserToken,n._app?.options.projectId);const g=r.mockUserToken.sub||r.mockUserToken.user_id;if(!g)throw new M(N.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");f=new Ce(g)}n._authCredentials=new qk(new a_(h,f))}}class tn{constructor(e,t,r){this.converter=t,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new tn(this.firestore,e,this._query)}}class he{constructor(e,t,r){this.converter=t,this._key=r,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new Tn(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new he(this.firestore,e,this._key)}toJSON(){return{type:he._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,r){if(yi(t,he._jsonSchema))return new he(e,r||null,new B(se.fromString(t.referencePath)))}}he._jsonSchemaVersion="firestore/documentReference/1.0",he._jsonSchema={type:me("string",he._jsonSchemaVersion),referencePath:me("string")};class Tn extends tn{constructor(e,t,r){super(e,t,Ea(r)),this._path=r,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 he(this.firestore,null,new B(e))}withConverter(e){return new Tn(this.firestore,e,this._path)}}function WD(n,e,...t){if(n=ie(n),c_("collection","path",e),n instanceof Ra){const r=se.fromString(e,...t);return pf(r),new Tn(n,null,r)}{if(!(n instanceof he||n instanceof Tn))throw new M(N.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(se.fromString(e,...t));return pf(r),new Tn(n.firestore,null,r)}}function Gs(n,e,...t){if(n=ie(n),arguments.length===1&&(e=cu.newId()),c_("doc","path",e),n instanceof Ra){const r=se.fromString(e,...t);return ff(r),new he(n,null,new B(r))}{if(!(n instanceof he||n instanceof Tn))throw new M(N.INVALID_ARGUMENT,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(se.fromString(e,...t));return ff(r),new he(n.firestore,n instanceof Tn?n.converter:null,new B(r))}}const np="AsyncQueue";class rp{constructor(e=Promise.resolve()){this.Yu=[],this.ec=!1,this.tc=[],this.nc=null,this.rc=!1,this.sc=!1,this.oc=[],this.M_=new ey(this,"async_queue_retry"),this._c=()=>{const r=Cc();r&&x(np,"Visibility state changed to "+r.visibilityState),this.M_.w_()},this.ac=e;const t=Cc();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=Cc();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this._c)}}enqueue(e){if(this.uc(),this.ec)return new Promise((()=>{}));const t=new zt;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.Yu.push(e),this.lc())))}async lc(){if(this.Yu.length!==0){try{await this.Yu[0](),this.Yu.shift(),this.M_.reset()}catch(e){if(!us(e))throw e;x(np,"Operation failed with retryable error: "+e)}this.Yu.length>0&&this.M_.p_((()=>this.lc()))}}cc(e){const t=this.ac.then((()=>(this.rc=!0,e().catch((r=>{throw this.nc=r,this.rc=!1,Jt("INTERNAL UNHANDLED ERROR: ",sp(r)),r})).then((r=>(this.rc=!1,r))))));return this.ac=t,t}enqueueAfterDelay(e,t,r){this.uc(),this.oc.indexOf(e)>-1&&(t=0);const s=Cu.createAndSchedule(this,e,t,r,(i=>this.hc(i)));return this.tc.push(s),s}uc(){this.nc&&W(47125,{Pc:sp(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,r)=>t.targetTimeMs-r.targetTimeMs));for(const t of this.tc)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.Tc()}))}Rc(e){this.oc.push(e)}hc(e){const t=this.tc.indexOf(e);this.tc.splice(t,1)}}function sp(n){let e=n.message||"";return n.stack&&(e=n.stack.includes(n.message)?n.stack:n.message+`
|
|
36
|
+
`+n.stack),e}class Nn extends Ra{constructor(e,t,r,s){super(e,t,r,s),this.type="firestore",this._queue=new rp,this._persistenceKey=s?.name||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new rp(e),this._firestoreClient=void 0,await e}}}function zD(n,e){const t=typeof n=="object"?n:os(),r=typeof n=="string"?n:No,s=Vt(t,"firestore").getImmediate({identifier:r});if(!s._initialized){const i=Bl("firestore");i&&Ey(s,...i)}return s}function ka(n){if(n._terminated)throw new M(N.FAILED_PRECONDITION,"The client has already been terminated.");return n._firestoreClient||KD(n),n._firestoreClient}function KD(n){const e=n._freezeSettings(),t=HD(n._databaseId,n._app?.options.appId||"",n._persistenceKey,n._app?.options.apiKey,e);n._componentsProvider||e.localCache?._offlineComponentProvider&&e.localCache?._onlineComponentProvider&&(n._componentsProvider={_offline:e.localCache._offlineComponentProvider,_online:e.localCache._onlineComponentProvider}),n._firestoreClient=new MD(n._authCredentials,n._appCheckCredentials,n._queue,t,n._componentsProvider&&(function(s){const i=s?._online.build();return{_offline:s?._offline.build(i),_online:i}})(n._componentsProvider))}class st{constructor(e){this._byteString=e}static fromBase64String(e){try{return new st(Ie.fromBase64String(e))}catch(t){throw new M(N.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new st(Ie.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:st._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(yi(e,st._jsonSchema))return st.fromBase64String(e.bytes)}}st._jsonSchemaVersion="firestore/bytes/1.0",st._jsonSchema={type:me("string",st._jsonSchemaVersion),bytes:me("string")};class Pa{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new M(N.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new Ae(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}function gl(){return new Pa(tl)}class oi{constructor(e){this._methodName=e}}class kt{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new M(N.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new M(N.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 Z(this._lat,e._lat)||Z(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:kt._jsonSchemaVersion}}static fromJSON(e){if(yi(e,kt._jsonSchema))return new kt(e.latitude,e.longitude)}}kt._jsonSchemaVersion="firestore/geoPoint/1.0",kt._jsonSchema={type:me("string",kt._jsonSchemaVersion),latitude:me("number"),longitude:me("number")};class _t{constructor(e){this._values=(e||[]).map((t=>t))}toArray(){return this._values.map((e=>e))}isEqual(e){return(function(r,s){if(r.length!==s.length)return!1;for(let i=0;i<r.length;++i)if(r[i]!==s[i])return!1;return!0})(this._values,e._values)}toJSON(){return{type:_t._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(yi(e,_t._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every((t=>typeof t=="number")))return new _t(e.vectorValues);throw new M(N.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}_t._jsonSchemaVersion="firestore/vectorValue/1.0",_t._jsonSchema={type:me("string",_t._jsonSchemaVersion),vectorValues:me("object")};const GD=/^__.*__$/;class YD{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return this.fieldMask!==null?new xn(e,this.data,this.fieldMask,t,this.fieldTransforms):new Ei(e,this.data,t,this.fieldTransforms)}}class vy{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return new xn(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function Ty(n){switch(n){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw W(40011,{dataSource:n})}}class Mu{constructor(e,t,r,s,i,o){this.settings=e,this.databaseId=t,this.serializer=r,this.ignoreUndefinedProperties=s,i===void 0&&this.validatePath(),this.fieldTransforms=i||[],this.fieldMask=o||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}contextWith(e){return new Mu({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}childContextForField(e){const t=this.path?.child(e),r=this.contextWith({path:t,arrayElement:!1});return r.validatePathSegment(e),r}childContextForFieldPath(e){const t=this.path?.child(e),r=this.contextWith({path:t,arrayElement:!1});return r.validatePath(),r}childContextForArray(e){return this.contextWith({path:void 0,arrayElement:!0})}createError(e){return qo(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return this.fieldMask.find((t=>e.isPrefixOf(t)))!==void 0||this.fieldTransforms.find((t=>e.isPrefixOf(t.field)))!==void 0}validatePath(){if(this.path)for(let e=0;e<this.path.length;e++)this.validatePathSegment(this.path.get(e))}validatePathSegment(e){if(e.length===0)throw this.createError("Document fields must not be empty");if(Ty(this.dataSource)&&GD.test(e))throw this.createError('Document fields cannot begin and end with "__"')}}class QD{constructor(e,t,r){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=r||Ia(e)}createContext(e,t,r,s=!1){return new Mu({dataSource:e,methodName:t,targetDoc:r,path:Ae.emptyPath(),arrayElement:!1,hasConverter:s},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function xu(n){const e=n._freezeSettings(),t=Ia(n._databaseId);return new QD(n._databaseId,!!e.ignoreUndefinedProperties,t)}function JD(n,e,t,r,s,i={}){const o=n.createContext(i.merge||i.mergeFields?2:0,e,t,s);Fu("Data must be an object, but it was:",o,r);const c=wy(r,o);let l,h;if(i.merge)l=new Ge(o.fieldMask),h=o.fieldTransforms;else if(i.mergeFields){const f=[];for(const g of i.mergeFields){const _=cr(e,g,t);if(!o.contains(_))throw new M(N.INVALID_ARGUMENT,`Field '${_}' is specified in your field mask but missing from your input data.`);Iy(f,_)||f.push(_)}l=new Ge(f),h=o.fieldTransforms.filter((g=>l.covers(g.field)))}else l=null,h=o.fieldTransforms;return new YD(new Be(c),l,h)}class bi extends oi{_toFieldTransform(e){if(e.dataSource!==2)throw e.dataSource===1?e.createError(`${this._methodName}() can only appear at the top level of your update data`):e.createError(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof bi}}function XD(n,e,t,r){const s=n.createContext(1,e,t);Fu("Data must be an object, but it was:",s,r);const i=[],o=Be.empty();Mn(r,((l,h)=>{const f=Ay(e,l,t);h=ie(h);const g=s.childContextForFieldPath(f);if(h instanceof bi)i.push(f);else{const _=Ai(h,g);_!=null&&(i.push(f),o.set(f,_))}}));const c=new Ge(i);return new vy(o,c,s.fieldTransforms)}function ZD(n,e,t,r,s,i){const o=n.createContext(1,e,t),c=[cr(e,r,t)],l=[s];if(i.length%2!=0)throw new M(N.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let _=0;_<i.length;_+=2)c.push(cr(e,i[_])),l.push(i[_+1]);const h=[],f=Be.empty();for(let _=c.length-1;_>=0;--_)if(!Iy(h,c[_])){const T=c[_];let C=l[_];C=ie(C);const P=o.childContextForFieldPath(T);if(C instanceof bi)h.push(T);else{const k=Ai(C,P);k!=null&&(h.push(T),f.set(T,k))}}const g=new Ge(h);return new vy(f,g,o.fieldTransforms)}function e1(n,e,t,r=!1){return Ai(t,n.createContext(r?4:3,e))}function Ai(n,e){if(by(n=ie(n)))return Fu("Unsupported field value:",e,n),wy(n,e);if(n instanceof oi)return(function(r,s){if(!Ty(s.dataSource))throw s.createError(`${r._methodName}() can only be used with update() and set()`);if(!s.path)throw s.createError(`${r._methodName}() is not currently supported inside arrays`);const i=r._toFieldTransform(s);i&&s.fieldTransforms.push(i)})(n,e),null;if(n===void 0&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),n instanceof Array){if(e.settings.arrayElement&&e.dataSource!==4)throw e.createError("Nested arrays are not supported");return(function(r,s){const i=[];let o=0;for(const c of r){let l=Ai(c,s.childContextForArray(o));l==null&&(l={nullValue:"NULL_VALUE"}),i.push(l),o++}return{arrayValue:{values:i}}})(n,e)}return(function(r,s){if((r=ie(r))===null)return{nullValue:"NULL_VALUE"};if(typeof r=="number")return LP(s.serializer,r);if(typeof r=="boolean")return{booleanValue:r};if(typeof r=="string")return{stringValue:r};if(r instanceof Date){const i=J.fromDate(r);return{timestampValue:xo(s.serializer,i)}}if(r instanceof J){const i=new J(r.seconds,1e3*Math.floor(r.nanoseconds/1e3));return{timestampValue:xo(s.serializer,i)}}if(r instanceof kt)return{geoPointValue:{latitude:r.latitude,longitude:r.longitude}};if(r instanceof st)return{bytesValue:q_(s.serializer,r._byteString)};if(r instanceof he){const i=s.databaseId,o=r.firestore._databaseId;if(!o.isEqual(i))throw s.createError(`Document reference is for database ${o.projectId}/${o.database} but should be for database ${i.projectId}/${i.database}`);return{referenceValue:yu(r.firestore._databaseId||s.databaseId,r._key.path)}}if(r instanceof _t)return(function(o,c){const l=o instanceof _t?o.toArray():o;return{mapValue:{fields:{[__]:{stringValue:y_},[Do]:{arrayValue:{values:l.map((f=>{if(typeof f!="number")throw c.createError("VectorValues must only contain numeric values.");return pu(c.serializer,f)}))}}}}}})(r,s);if(Y_(r))return r._toProto(s.serializer);throw s.createError(`Unsupported field value: ${ma(r)}`)})(n,e)}function wy(n,e){const t={};return h_(n)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):Mn(n,((r,s)=>{const i=Ai(s,e.childContextForField(r));i!=null&&(t[r]=i)})),{mapValue:{fields:t}}}function by(n){return!(typeof n!="object"||n===null||n instanceof Array||n instanceof Date||n instanceof J||n instanceof kt||n instanceof st||n instanceof he||n instanceof oi||n instanceof _t||Y_(n))}function Fu(n,e,t){if(!by(t)||!l_(t)){const r=ma(t);throw r==="an object"?e.createError(n+" a custom object"):e.createError(n+" "+r)}}function cr(n,e,t){if((e=ie(e))instanceof Pa)return e._internalPath;if(typeof e=="string")return Ay(n,e);throw qo("Field path arguments must be of type string or ",n,!1,void 0,t)}const t1=new RegExp("[~\\*/\\[\\]]");function Ay(n,e,t){if(e.search(t1)>=0)throw qo(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,n,!1,void 0,t);try{return new Pa(...e.split("."))._internalPath}catch{throw qo(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,n,!1,void 0,t)}}function qo(n,e,t,r,s){const i=r&&!r.isEmpty(),o=s!==void 0;let c=`Function ${e}() called with invalid data`;t&&(c+=" (via `toFirestore()`)"),c+=". ";let l="";return(i||o)&&(l+=" (found",i&&(l+=` in field ${r}`),o&&(l+=` in document ${s}`),l+=")"),new M(N.INVALID_ARGUMENT,c+n+l)}function Iy(n,e){return n.some((t=>t.isEqual(e)))}class n1{convertValue(e,t="none"){switch(Rn(e)){case 0:return null;case 1:return e.booleanValue;case 2:return de(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(Cn(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw W(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const r={};return Mn(e,((s,i)=>{r[s]=this.convertValue(i,t)})),r}convertVectorValue(e){const t=e.fields?.[Do].arrayValue?.values?.map((r=>de(r.doubleValue)));return new _t(t)}convertGeoPoint(e){return new kt(de(e.latitude),de(e.longitude))}convertArray(e,t){return(e.values||[]).map((r=>this.convertValue(r,t)))}convertServerTimestamp(e,t){switch(t){case"previous":const r=ya(e);return r==null?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(ei(e));default:return null}}convertTimestamp(e){const t=Sn(e);return new J(t.seconds,t.nanos)}convertDocumentKey(e,t){const r=se.fromString(e);ne(G_(r),9688,{name:e});const s=new ti(r.get(1),r.get(3)),i=new B(r.popFirst(5));return s.isEqual(t)||Jt(`Document ${i} contains a document reference within a different database (${s.projectId}/${s.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),i}}class $u extends n1{constructor(e){super(),this.firestore=e}convertBytes(e){return new st(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new he(this.firestore,null,t)}}function _l(){return new bi("deleteField")}const ip="@firebase/firestore",op="4.10.0";function ap(n){return(function(t,r){if(typeof t!="object"||t===null)return!1;const s=t;for(const i of r)if(i in s&&typeof s[i]=="function")return!0;return!1})(n,["next","error","complete"])}class Sy{constructor(e,t,r,s,i){this._firestore=e,this._userDataWriter=t,this._key=r,this._document=s,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new he(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new r1(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){return this._document?.data.clone().value.mapValue.fields??void 0}get(e){if(this._document){const t=this._document.data.field(cr("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}}class r1 extends Sy{data(){return super.data()}}function Cy(n){if(n.limitType==="L"&&n.explicitOrderBy.length===0)throw new M(N.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Uu{}class Bu extends Uu{}function cp(n,e,...t){let r=[];e instanceof Uu&&r.push(e),r=r.concat(t),(function(i){const o=i.filter((l=>l instanceof qu)).length,c=i.filter((l=>l instanceof Na)).length;if(o>1||o>0&&c>0)throw new M(N.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")})(r);for(const s of r)n=s._apply(n);return n}class Na extends Bu{constructor(e,t,r){super(),this._field=e,this._op=t,this._value=r,this.type="where"}static _create(e,t,r){return new Na(e,t,r)}_apply(e){const t=this._parse(e);return Ry(e._query,t),new tn(e.firestore,e.converter,ol(e._query,t))}_parse(e){const t=xu(e.firestore);return(function(i,o,c,l,h,f,g){let _;if(h.isKeyField()){if(f==="array-contains"||f==="array-contains-any")throw new M(N.INVALID_ARGUMENT,`Invalid Query. You can't perform '${f}' queries on documentId().`);if(f==="in"||f==="not-in"){up(g,f);const C=[];for(const P of g)C.push(lp(l,i,P));_={arrayValue:{values:C}}}else _=lp(l,i,g)}else f!=="in"&&f!=="not-in"&&f!=="array-contains-any"||up(g,f),_=e1(c,o,g,f==="in"||f==="not-in");return pe.create(h,f,_)})(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value)}}function yl(n,e,t){const r=e,s=cr("where",n);return Na._create(s,r,t)}class qu extends Uu{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new qu(e,t)}_parse(e){const t=this._queryConstraints.map((r=>r._parse(e))).filter((r=>r.getFilters().length>0));return t.length===1?t[0]:yt.create(t,this._getOperator())}_apply(e){const t=this._parse(e);return t.getFilters().length===0?e:((function(s,i){let o=s;const c=i.getFlattenedFilters();for(const l of c)Ry(o,l),o=ol(o,l)})(e._query,t),new tn(e.firestore,e.converter,ol(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}class ju extends Bu{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new ju(e,t)}_apply(e){const t=(function(s,i,o){if(s.startAt!==null)throw new M(N.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(s.endAt!==null)throw new M(N.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new ri(i,o)})(e._query,this._field,this._direction);return new tn(e.firestore,e.converter,CP(e._query,t))}}function kc(n,e="asc"){const t=e,r=cr("orderBy",n);return ju._create(r,t)}class Hu extends Bu{constructor(e,t,r){super(),this.type=e,this._limit=t,this._limitType=r}static _create(e,t,r){return new Hu(e,t,r)}_apply(e){return new tn(e.firestore,e.converter,Vo(e._query,this._limit,this._limitType))}}function Pc(n){return Xk("limit",n),Hu._create("limit",n,"F")}function lp(n,e,t){if(typeof(t=ie(t))=="string"){if(t==="")throw new M(N.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!S_(e)&&t.indexOf("/")!==-1)throw new M(N.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${t}' contains a '/' character.`);const r=e.path.child(se.fromString(t));if(!B.isDocumentKey(r))throw new M(N.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return wf(n,new B(r))}if(t instanceof he)return wf(n,t._key);throw new M(N.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${ma(t)}.`)}function up(n,e){if(!Array.isArray(n)||n.length===0)throw new M(N.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`)}function Ry(n,e){const t=(function(s,i){for(const o of s)for(const c of o.getFlattenedFilters())if(i.indexOf(c.op)>=0)return c.op;return null})(n.filters,(function(s){switch(s){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}})(e.op));if(t!==null)throw t===e.op?new M(N.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new M(N.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${t.toString()}' filters.`)}function s1(n,e,t){let r;return r=n?t&&(t.merge||t.mergeFields)?n.toFirestore(e,t):n.toFirestore(e):e,r}class $s{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class Xn extends Sy{constructor(e,t,r,s,i,o){super(e,t,r,s,o),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new fo(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 r=this._document.data.field(cr("DocumentSnapshot.get",e));if(r!==null)return this._userDataWriter.convertValue(r,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new M(N.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=Xn._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)}}Xn._jsonSchemaVersion="firestore/documentSnapshot/1.0",Xn._jsonSchema={type:me("string",Xn._jsonSchemaVersion),bundleSource:me("string","DocumentSnapshot"),bundleName:me("string"),bundle:me("string")};class fo extends Xn{data(e={}){return super.data(e)}}class Zn{constructor(e,t,r,s){this._firestore=e,this._userDataWriter=t,this._snapshot=s,this.metadata=new $s(s.hasPendingWrites,s.fromCache),this.query=r}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((r=>{e.call(t,new fo(this._firestore,this._userDataWriter,r.key,r,new $s(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new M(N.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,i){if(s._snapshot.oldDocs.isEmpty()){let o=0;return s._snapshot.docChanges.map((c=>{const l=new fo(s._firestore,s._userDataWriter,c.doc.key,c.doc,new $s(s._snapshot.mutatedKeys.has(c.doc.key),s._snapshot.fromCache),s.query.converter);return c.doc,{type:"added",doc:l,oldIndex:-1,newIndex:o++}}))}{let o=s._snapshot.oldDocs;return s._snapshot.docChanges.filter((c=>i||c.type!==3)).map((c=>{const l=new fo(s._firestore,s._userDataWriter,c.doc.key,c.doc,new $s(s._snapshot.mutatedKeys.has(c.doc.key),s._snapshot.fromCache),s.query.converter);let h=-1,f=-1;return c.type!==0&&(h=o.indexOf(c.doc.key),o=o.delete(c.doc.key)),c.type!==1&&(o=o.add(c.doc),f=o.indexOf(c.doc.key)),{type:i1(c.type),doc:l,oldIndex:h,newIndex:f}}))}})(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new M(N.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e={};e.type=Zn._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=cu.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const t=[],r=[],s=[];return this.docs.forEach((i=>{i._document!==null&&(t.push(i._document),r.push(this._userDataWriter.convertObjectMap(i._document.data.value.mapValue.fields,"previous")),s.push(i.ref.path))})),e.bundle=(this._firestore,this.query._query,e.bundleName,"NOT SUPPORTED"),e}}function i1(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return W(61501,{type:n})}}Zn._jsonSchemaVersion="firestore/querySnapshot/1.0",Zn._jsonSchema={type:me("string",Zn._jsonSchemaVersion),bundleSource:me("string","QuerySnapshot"),bundleName:me("string"),bundle:me("string")};function El(n){n=Qe(n,he);const e=Qe(n.firestore,Nn),t=ka(e);return UD(t,n._key).then((r=>Py(e,n,r)))}function o1(n){n=Qe(n,tn);const e=Qe(n.firestore,Nn),t=ka(e),r=new $u(e);return Cy(n._query),BD(t,n._query).then((s=>new Zn(e,r,n,s)))}function ky(n,e,t){n=Qe(n,he);const r=Qe(n.firestore,Nn),s=s1(n.converter,e,t),i=xu(r);return Wu(r,[JD(i,"setDoc",n._key,s,n.converter!==null,t).toMutation(n._key,gt.none())])}function a1(n,e,t,...r){n=Qe(n,he);const s=Qe(n.firestore,Nn),i=xu(s);let o;return o=typeof(e=ie(e))=="string"||e instanceof Pa?ZD(i,"updateDoc",n._key,e,t,r):XD(i,"updateDoc",n._key,e),Wu(s,[o.toMutation(n._key,gt.exists(!0))])}function c1(n){return Wu(Qe(n.firestore,Nn),[new mu(n._key,gt.none())])}function l1(n,...e){n=ie(n);let t={includeMetadataChanges:!1,source:"default"},r=0;typeof e[r]!="object"||ap(e[r])||(t=e[r++]);const s={includeMetadataChanges:t.includeMetadataChanges,source:t.source};if(ap(e[r])){const h=e[r];e[r]=h.next?.bind(h),e[r+1]=h.error?.bind(h),e[r+2]=h.complete?.bind(h)}let i,o,c;if(n instanceof he)o=Qe(n.firestore,Nn),c=Ea(n._key.path),i={next:h=>{e[r]&&e[r](Py(o,n,h))},error:e[r+1],complete:e[r+2]};else{const h=Qe(n,tn);o=Qe(h.firestore,Nn),c=h._query;const f=new $u(o);i={next:g=>{e[r]&&e[r](new Zn(o,f,h,g))},error:e[r+1],complete:e[r+2]},Cy(n._query)}const l=ka(o);return $D(l,c,s,i)}function Wu(n,e){const t=ka(n);return qD(t,e)}function Py(n,e,t){const r=t.docs.get(e._key),s=new $u(n);return new Xn(n,s,e._key,r,new $s(t.hasPendingWrites,t.fromCache),e.converter)}(function(e,t=!0){Uk(dr),je(new Fe("firestore",((r,{instanceIdentifier:s,options:i})=>{const o=r.getProvider("app").getImmediate(),c=new Nn(new jk(r.getProvider("auth-internal")),new zk(o,r.getProvider("app-check-internal")),uP(o,s),o);return i={useFetchStreams:t,...i},c._setSettings(i),c}),"PUBLIC").setMultipleInstances(!0)),Te(ip,op,e),Te(ip,op,"esm2020")})();const Ny="firebasestorage.googleapis.com",u1="storageBucket",h1=120*1e3,d1=600*1e3;class Lt extends et{constructor(e,t,r=0){super(Nc(e),`Firebase Storage: ${t} (${Nc(e)})`),this.status_=r,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,Lt.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return Nc(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}
|
|
37
|
+
${this.customData.serverResponse}`:this.message=this._baseMessage}}var Ot;(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"})(Ot||(Ot={}));function Nc(n){return"storage/"+n}function f1(){const n="An unknown error occurred, please check the error payload for server response.";return new Lt(Ot.UNKNOWN,n)}function p1(){return new Lt(Ot.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function m1(){return new Lt(Ot.CANCELED,"User canceled the upload/download.")}function g1(n){return new Lt(Ot.INVALID_URL,"Invalid URL '"+n+"'.")}function _1(n){return new Lt(Ot.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+n+"'.")}function hp(n){return new Lt(Ot.INVALID_ARGUMENT,n)}function Dy(){return new Lt(Ot.APP_DELETED,"The Firebase app was deleted.")}function y1(n){return new Lt(Ot.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 pt{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 r;try{r=pt.makeFromUrl(e,t)}catch{return new pt(e,"")}if(r.path==="")return r;throw _1(e)}static makeFromUrl(e,t){let r=null;const s="([A-Za-z0-9.\\-_]+)";function i(F){F.path.charAt(F.path.length-1)==="/"&&(F.path_=F.path_.slice(0,-1))}const o="(/(.*))?$",c=new RegExp("^gs://"+s+o,"i"),l={bucket:1,path:3};function h(F){F.path_=decodeURIComponent(F.path)}const f="v[A-Za-z0-9_]+",g=t.replace(/[.]/g,"\\."),_="(/([^?#]*).*)?$",T=new RegExp(`^https?://${g}/${f}/b/${s}/o${_}`,"i"),C={bucket:1,path:3},P=t===Ny?"(?:storage.googleapis.com|storage.cloud.google.com)":t,k="([^?#]*)",L=new RegExp(`^https?://${P}/${s}/${k}`,"i"),U=[{regex:c,indices:l,postModify:i},{regex:T,indices:C,postModify:h},{regex:L,indices:{bucket:1,path:2},postModify:h}];for(let F=0;F<U.length;F++){const j=U[F],H=j.regex.exec(e);if(H){const w=H[j.indices.bucket];let y=H[j.indices.path];y||(y=""),r=new pt(w,y),j.postModify(r);break}}if(r==null)throw g1(e);return r}}class E1{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}}function v1(n,e,t){let r=1,s=null,i=null,o=!1,c=0;function l(){return c===2}let h=!1;function f(...k){h||(h=!0,e.apply(null,k))}function g(k){s=setTimeout(()=>{s=null,n(T,l())},k)}function _(){i&&clearTimeout(i)}function T(k,...L){if(h){_();return}if(k){_(),f.call(null,k,...L);return}if(l()||o){_(),f.call(null,k,...L);return}r<64&&(r*=2);let U;c===1?(c=2,U=0):U=(r+Math.random())*1e3,g(U)}let C=!1;function P(k){C||(C=!0,_(),!h&&(s!==null?(k||(c=2),clearTimeout(s),g(0)):k||(c=1)))}return g(0),i=setTimeout(()=>{o=!0,P(!0)},t),P}function T1(n){n(!1)}function w1(n){return n!==void 0}function dp(n,e,t,r){if(r<e)throw hp(`Invalid value for '${n}'. Expected ${e} or greater.`);if(r>t)throw hp(`Invalid value for '${n}'. Expected ${t} or less.`)}function b1(n){const e=encodeURIComponent;let t="?";for(const r in n)if(n.hasOwnProperty(r)){const s=e(r)+"="+e(n[r]);t=t+s+"&"}return t=t.slice(0,-1),t}var jo;(function(n){n[n.NO_ERROR=0]="NO_ERROR",n[n.NETWORK_ERROR=1]="NETWORK_ERROR",n[n.ABORT=2]="ABORT"})(jo||(jo={}));function A1(n,e){const t=n>=500&&n<600,s=[408,429].indexOf(n)!==-1,i=e.indexOf(n)!==-1;return t||s||i}class I1{constructor(e,t,r,s,i,o,c,l,h,f,g,_=!0,T=!1){this.url_=e,this.method_=t,this.headers_=r,this.body_=s,this.successCodes_=i,this.additionalRetryCodes_=o,this.callback_=c,this.errorCallback_=l,this.timeout_=h,this.progressCallback_=f,this.connectionFactory_=g,this.retry=_,this.isUsingEmulator=T,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((C,P)=>{this.resolve_=C,this.reject_=P,this.start_()})}start_(){const e=(r,s)=>{if(s){r(!1,new Zi(!1,null,!0));return}const i=this.connectionFactory_();this.pendingConnection_=i;const o=c=>{const l=c.loaded,h=c.lengthComputable?c.total:-1;this.progressCallback_!==null&&this.progressCallback_(l,h)};this.progressCallback_!==null&&i.addUploadProgressListener(o),i.send(this.url_,this.method_,this.isUsingEmulator,this.body_,this.headers_).then(()=>{this.progressCallback_!==null&&i.removeUploadProgressListener(o),this.pendingConnection_=null;const c=i.getErrorCode()===jo.NO_ERROR,l=i.getStatus();if(!c||A1(l,this.additionalRetryCodes_)&&this.retry){const f=i.getErrorCode()===jo.ABORT;r(!1,new Zi(!1,null,f));return}const h=this.successCodes_.indexOf(l)!==-1;r(!0,new Zi(h,i))})},t=(r,s)=>{const i=this.resolve_,o=this.reject_,c=s.connection;if(s.wasSuccessCode)try{const l=this.callback_(c,c.getResponse());w1(l)?i(l):i()}catch(l){o(l)}else if(c!==null){const l=f1();l.serverResponse=c.getErrorText(),this.errorCallback_?o(this.errorCallback_(c,l)):o(l)}else if(s.canceled){const l=this.appDelete_?Dy():m1();o(l)}else{const l=p1();o(l)}};this.canceled_?t(!1,new Zi(!1,null,!0)):this.backoffId_=v1(e,t,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&T1(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}}class Zi{constructor(e,t,r){this.wasSuccessCode=e,this.connection=t,this.canceled=!!r}}function S1(n,e){e!==null&&e.length>0&&(n.Authorization="Firebase "+e)}function C1(n,e){n["X-Firebase-Storage-Version"]="webjs/"+(e??"AppManager")}function R1(n,e){e&&(n["X-Firebase-GMPID"]=e)}function k1(n,e){e!==null&&(n["X-Firebase-AppCheck"]=e)}function P1(n,e,t,r,s,i,o=!0,c=!1){const l=b1(n.urlParams),h=n.url+l,f=Object.assign({},n.headers);return R1(f,e),S1(f,t),C1(f,i),k1(f,r),new I1(h,n.method,f,n.body,n.successCodes,n.additionalRetryCodes,n.handler,n.errorHandler,n.timeout,n.progressCallback,s,o,c)}function N1(n){if(n.length===0)return null;const e=n.lastIndexOf("/");return e===-1?"":n.slice(0,e)}function D1(n){const e=n.lastIndexOf("/",n.length-2);return e===-1?n:n.slice(e+1)}class Ho{constructor(e,t){this._service=e,t instanceof pt?this._location=t:this._location=pt.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new Ho(e,t)}get root(){const e=new pt(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return D1(this._location.path)}get storage(){return this._service}get parent(){const e=N1(this._location.path);if(e===null)return null;const t=new pt(this._location.bucket,e);return new Ho(this._service,t)}_throwIfRoot(e){if(this._location.path==="")throw y1(e)}}function fp(n,e){const t=e?.[u1];return t==null?null:pt.makeFromBucketSpec(t,n)}function O1(n,e,t,r={}){n.host=`${e}:${t}`;const s=en(e);s&&(oa(`https://${n.host}/b`),aa("Storage",!0)),n._isUsingEmulator=!0,n._protocol=s?"https":"http";const{mockUserToken:i}=r;i&&(n._overrideAuthToken=typeof i=="string"?i:Gm(i,n.app.options.projectId))}class V1{constructor(e,t,r,s,i,o=!1){this.app=e,this._authProvider=t,this._appCheckProvider=r,this._url=s,this._firebaseVersion=i,this._isUsingEmulator=o,this._bucket=null,this._host=Ny,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=h1,this._maxUploadRetryTime=d1,this._requests=new Set,s!=null?this._bucket=pt.makeFromBucketSpec(s,this._host):this._bucket=fp(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,this._url!=null?this._bucket=pt.makeFromBucketSpec(this._url,e):this._bucket=fp(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){dp("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){dp("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(Ke(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 Ho(this,e)}_makeRequest(e,t,r,s,i=!0){if(this._deleted)return new E1(Dy());{const o=P1(e,this._appId,r,s,t,this._firebaseVersion,i,this._isUsingEmulator);return this._requests.add(o),o.getPromise().then(()=>this._requests.delete(o),()=>this._requests.delete(o)),o}}async makeRequestWithTokens(e,t){const[r,s]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,r,s).getPromise()}}const pp="@firebase/storage",mp="0.14.0";const Oy="storage";function L1(n=os(),e){n=ie(n);const r=Vt(n,Oy).getImmediate({identifier:e}),s=Bl("storage");return s&&Vy(r,...s),r}function Vy(n,e,t,r={}){O1(n,e,t,r)}function M1(n,{instanceIdentifier:e}){const t=n.getProvider("app").getImmediate(),r=n.getProvider("auth-internal"),s=n.getProvider("app-check-internal");return new V1(t,r,s,e,dr)}function x1(){je(new Fe(Oy,M1,"PUBLIC").setMultipleInstances(!0)),Te(pp,mp,""),Te(pp,mp,"esm2020")}x1();const F1="type.googleapis.com/google.protobuf.Int64Value",$1="type.googleapis.com/google.protobuf.UInt64Value";function Ly(n,e){const t={};for(const r in n)n.hasOwnProperty(r)&&(t[r]=e(n[r]));return t}function Wo(n){if(n==null)return null;if(n instanceof Number&&(n=n.valueOf()),typeof n=="number"&&isFinite(n)||n===!0||n===!1||Object.prototype.toString.call(n)==="[object String]")return n;if(n instanceof Date)return n.toISOString();if(Array.isArray(n))return n.map(e=>Wo(e));if(typeof n=="function"||typeof n=="object")return Ly(n,e=>Wo(e));throw new Error("Data cannot be encoded in JSON: "+n)}function ts(n){if(n==null)return n;if(n["@type"])switch(n["@type"]){case F1:case $1:{const e=Number(n.value);if(isNaN(e))throw new Error("Data cannot be decoded from JSON: "+n);return e}default:throw new Error("Data cannot be decoded from JSON: "+n)}return Array.isArray(n)?n.map(e=>ts(e)):typeof n=="function"||typeof n=="object"?Ly(n,e=>ts(e)):n}const zu="functions";const gp={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class qe extends et{constructor(e,t,r){super(`${zu}/${e}`,t||""),this.details=r,Object.setPrototypeOf(this,qe.prototype)}}function U1(n){if(n>=200&&n<300)return"ok";switch(n){case 0:return"internal";case 400:return"invalid-argument";case 401:return"unauthenticated";case 403:return"permission-denied";case 404:return"not-found";case 409:return"aborted";case 429:return"resource-exhausted";case 499:return"cancelled";case 500:return"internal";case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline-exceeded"}return"unknown"}function zo(n,e){let t=U1(n),r=t,s;try{const i=e&&e.error;if(i){const o=i.status;if(typeof o=="string"){if(!gp[o])return new qe("internal","internal");t=gp[o],r=o}const c=i.message;typeof c=="string"&&(r=c),s=i.details,s!==void 0&&(s=ts(s))}}catch{}return t==="ok"?null:new qe(t,r,s)}class B1{constructor(e,t,r,s){this.app=e,this.auth=null,this.messaging=null,this.appCheck=null,this.serverAppAppCheckToken=null,Ke(e)&&e.settings.appCheckToken&&(this.serverAppAppCheckToken=e.settings.appCheckToken),this.auth=t.getImmediate({optional:!0}),this.messaging=r.getImmediate({optional:!0}),this.auth||t.get().then(i=>this.auth=i,()=>{}),this.messaging||r.get().then(i=>this.messaging=i,()=>{}),this.appCheck||s?.get().then(i=>this.appCheck=i,()=>{})}async getAuthToken(){if(this.auth)try{return(await this.auth.getToken())?.accessToken}catch{return}}async getMessagingToken(){if(!(!this.messaging||!("Notification"in self)||Notification.permission!=="granted"))try{return await this.messaging.getToken()}catch{return}}async getAppCheckToken(e){if(this.serverAppAppCheckToken)return this.serverAppAppCheckToken;if(this.appCheck){const t=e?await this.appCheck.getLimitedUseToken():await this.appCheck.getToken();return t.error?null:t.token}return null}async getContext(e){const t=await this.getAuthToken(),r=await this.getMessagingToken(),s=await this.getAppCheckToken(e);return{authToken:t,messagingToken:r,appCheckToken:s}}}const vl="us-central1",q1=/^data: (.*?)(?:\n|$)/;function j1(n){let e=null;return{promise:new Promise((t,r)=>{e=setTimeout(()=>{r(new qe("deadline-exceeded","deadline-exceeded"))},n)}),cancel:()=>{e&&clearTimeout(e)}}}class H1{constructor(e,t,r,s,i=vl,o=(...c)=>fetch(...c)){this.app=e,this.fetchImpl=o,this.emulatorOrigin=null,this.contextProvider=new B1(e,t,r,s),this.cancelAllRequests=new Promise(c=>{this.deleteService=()=>Promise.resolve(c())});try{const c=new URL(i);this.customDomain=c.origin+(c.pathname==="/"?"":c.pathname),this.region=vl}catch{this.customDomain=null,this.region=i}}_delete(){return this.deleteService()}_url(e){const t=this.app.options.projectId;return this.emulatorOrigin!==null?`${this.emulatorOrigin}/${t}/${this.region}/${e}`:this.customDomain!==null?`${this.customDomain}/${e}`:`https://${this.region}-${t}.cloudfunctions.net/${e}`}}function W1(n,e,t){const r=en(e);n.emulatorOrigin=`http${r?"s":""}://${e}:${t}`,r&&(oa(n.emulatorOrigin+"/backends"),aa("Functions",!0))}function z1(n,e,t){const r=s=>G1(n,e,s,{});return r.stream=(s,i)=>Q1(n,e,s,i),r}function My(n){return n.emulatorOrigin&&en(n.emulatorOrigin)?"include":void 0}async function K1(n,e,t,r,s){t["Content-Type"]="application/json";let i;try{i=await r(n,{method:"POST",body:JSON.stringify(e),headers:t,credentials:My(s)})}catch{return{status:0,json:null}}let o=null;try{o=await i.json()}catch{}return{status:i.status,json:o}}async function xy(n,e){const t={},r=await n.contextProvider.getContext(e.limitedUseAppCheckTokens);return r.authToken&&(t.Authorization="Bearer "+r.authToken),r.messagingToken&&(t["Firebase-Instance-ID-Token"]=r.messagingToken),r.appCheckToken!==null&&(t["X-Firebase-AppCheck"]=r.appCheckToken),t}function G1(n,e,t,r){const s=n._url(e);return Y1(n,s,t,r)}async function Y1(n,e,t,r){t=Wo(t);const s={data:t},i=await xy(n,r),o=r.timeout||7e4,c=j1(o),l=await Promise.race([K1(e,s,i,n.fetchImpl,n),c.promise,n.cancelAllRequests]);if(c.cancel(),!l)throw new qe("cancelled","Firebase Functions instance was deleted.");const h=zo(l.status,l.json);if(h)throw h;if(!l.json)throw new qe("internal","Response is not valid JSON object.");let f=l.json.data;if(typeof f>"u"&&(f=l.json.result),typeof f>"u")throw new qe("internal","Response is missing data field.");return{data:ts(f)}}function Q1(n,e,t,r){const s=n._url(e);return J1(n,s,t,r||{})}async function J1(n,e,t,r){t=Wo(t);const s={data:t},i=await xy(n,r);i["Content-Type"]="application/json",i.Accept="text/event-stream";let o;try{o=await n.fetchImpl(e,{method:"POST",body:JSON.stringify(s),headers:i,signal:r?.signal,credentials:My(n)})}catch(_){if(_ instanceof Error&&_.name==="AbortError"){const C=new qe("cancelled","Request was cancelled.");return{data:Promise.reject(C),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(C)}}}}}}const T=zo(0,null);return{data:Promise.reject(T),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(T)}}}}}}let c,l;const h=new Promise((_,T)=>{c=_,l=T});r?.signal?.addEventListener("abort",()=>{const _=new qe("cancelled","Request was cancelled.");l(_)});const f=o.body.getReader(),g=X1(f,c,l,r?.signal);return{stream:{[Symbol.asyncIterator](){const _=g.getReader();return{async next(){const{value:T,done:C}=await _.read();return{value:T,done:C}},async return(){return await _.cancel(),{done:!0,value:void 0}}}}},data:h}}function X1(n,e,t,r){const s=(o,c)=>{const l=o.match(q1);if(!l)return;const h=l[1];try{const f=JSON.parse(h);if("result"in f){e(ts(f.result));return}if("message"in f){c.enqueue(ts(f.message));return}if("error"in f){const g=zo(0,f);c.error(g),t(g);return}}catch(f){if(f instanceof qe){c.error(f),t(f);return}}},i=new TextDecoder;return new ReadableStream({start(o){let c="";return l();async function l(){if(r?.aborted){const h=new qe("cancelled","Request was cancelled");return o.error(h),t(h),Promise.resolve()}try{const{value:h,done:f}=await n.read();if(f){c.trim()&&s(c.trim(),o),o.close();return}if(r?.aborted){const _=new qe("cancelled","Request was cancelled");o.error(_),t(_),await n.cancel();return}c+=i.decode(h,{stream:!0});const g=c.split(`
|
|
38
|
+
`);c=g.pop()||"";for(const _ of g)_.trim()&&s(_.trim(),o);return l()}catch(h){const f=h instanceof qe?h:zo(0,null);o.error(f),t(f)}}},cancel(){return n.cancel()}})}const _p="@firebase/functions",yp="0.13.1";const Z1="auth-internal",eO="app-check-internal",tO="messaging-internal";function nO(n){const e=(t,{instanceIdentifier:r})=>{const s=t.getProvider("app").getImmediate(),i=t.getProvider(Z1),o=t.getProvider(tO),c=t.getProvider(eO);return new H1(s,i,o,c,r)};je(new Fe(zu,e,"PUBLIC").setMultipleInstances(!0)),Te(_p,yp,n),Te(_p,yp,"esm2020")}function rO(n=os(),e=vl){const r=Vt(ie(n),zu).getImmediate({identifier:e}),s=Bl("functions");return s&&Fy(r,...s),r}function Fy(n,e,t){W1(ie(n),e,t)}function sO(n,e,t){return z1(ie(n),e)}nO();const iO="/firebase-messaging-sw.js",oO="/firebase-cloud-messaging-push-scope",$y="BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4",aO="https://fcmregistrations.googleapis.com/v1",Uy="google.c.a.c_id",cO="google.c.a.c_l",lO="google.c.a.ts",uO="google.c.a.e",Ep=1e4;var vp;(function(n){n[n.DATA_MESSAGE=1]="DATA_MESSAGE",n[n.DISPLAY_NOTIFICATION=3]="DISPLAY_NOTIFICATION"})(vp||(vp={}));var ai;(function(n){n.PUSH_RECEIVED="push-received",n.NOTIFICATION_CLICKED="notification-clicked"})(ai||(ai={}));function $t(n){const e=new Uint8Array(n);return btoa(String.fromCharCode(...e)).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function hO(n){const e="=".repeat((4-n.length%4)%4),t=(n+e).replace(/\-/g,"+").replace(/_/g,"/"),r=atob(t),s=new Uint8Array(r.length);for(let i=0;i<r.length;++i)s[i]=r.charCodeAt(i);return s}const Dc="fcm_token_details_db",dO=5,Tp="fcm_token_object_Store";async function fO(n){if("databases"in indexedDB&&!(await indexedDB.databases()).map(i=>i.name).includes(Dc))return null;let e=null;return(await la(Dc,dO,{upgrade:async(r,s,i,o)=>{if(s<2||!r.objectStoreNames.contains(Tp))return;const c=o.objectStore(Tp),l=await c.index("fcmSenderId").get(n);if(await c.clear(),!!l){if(s===2){const h=l;if(!h.auth||!h.p256dh||!h.endpoint)return;e={token:h.fcmToken,createTime:h.createTime??Date.now(),subscriptionOptions:{auth:h.auth,p256dh:h.p256dh,endpoint:h.endpoint,swScope:h.swScope,vapidKey:typeof h.vapidKey=="string"?h.vapidKey:$t(h.vapidKey)}}}else if(s===3){const h=l;e={token:h.fcmToken,createTime:h.createTime,subscriptionOptions:{auth:$t(h.auth),p256dh:$t(h.p256dh),endpoint:h.endpoint,swScope:h.swScope,vapidKey:$t(h.vapidKey)}}}else if(s===4){const h=l;e={token:h.fcmToken,createTime:h.createTime,subscriptionOptions:{auth:$t(h.auth),p256dh:$t(h.p256dh),endpoint:h.endpoint,swScope:h.swScope,vapidKey:$t(h.vapidKey)}}}}}})).close(),await gc(Dc),await gc("fcm_vapid_details_db"),await gc("undefined"),pO(e)?e:null}function pO(n){if(!n||!n.subscriptionOptions)return!1;const{subscriptionOptions:e}=n;return typeof n.createTime=="number"&&n.createTime>0&&typeof n.token=="string"&&n.token.length>0&&typeof e.auth=="string"&&e.auth.length>0&&typeof e.p256dh=="string"&&e.p256dh.length>0&&typeof e.endpoint=="string"&&e.endpoint.length>0&&typeof e.swScope=="string"&&e.swScope.length>0&&typeof e.vapidKey=="string"&&e.vapidKey.length>0}const mO="firebase-messaging-database",gO=1,lr="firebase-messaging-store";let Oc=null;function Ku(){return Oc||(Oc=la(mO,gO,{upgrade:(n,e)=>{e===0&&n.createObjectStore(lr)}})),Oc}async function By(n){const e=Yu(n),r=await(await Ku()).transaction(lr).objectStore(lr).get(e);if(r)return r;{const s=await fO(n.appConfig.senderId);if(s)return await Gu(n,s),s}}async function Gu(n,e){const t=Yu(n),s=(await Ku()).transaction(lr,"readwrite");return await s.objectStore(lr).put(e,t),await s.done,e}async function _O(n){const e=Yu(n),r=(await Ku()).transaction(lr,"readwrite");await r.objectStore(lr).delete(e),await r.done}function Yu({appConfig:n}){return n.appId}const yO={"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"only-available-in-window":"This method is available in a Window context.","only-available-in-sw":"This method is available in a service worker context.","permission-default":"The notification permission was not granted and dismissed instead.","permission-blocked":"The notification permission was not granted and blocked instead.","unsupported-browser":"This browser doesn't support the API's required to use the Firebase SDK.","indexed-db-unsupported":"This browser doesn't support indexedDb.open() (ex. Safari iFrame, Firefox Private Browsing, etc)","failed-service-worker-registration":"We are unable to register the default service worker. {$browserErrorMessage}","token-subscribe-failed":"A problem occurred while subscribing the user to FCM: {$errorInfo}","token-subscribe-no-token":"FCM returned no token when subscribing the user to push.","token-unsubscribe-failed":"A problem occurred while unsubscribing the user from FCM: {$errorInfo}","token-update-failed":"A problem occurred while updating the user from FCM: {$errorInfo}","token-update-no-token":"FCM returned no token when updating the user to push.","use-sw-after-get-token":"The useServiceWorker() method may only be called once and must be called before calling getToken() to ensure your service worker is used.","invalid-sw-registration":"The input to useServiceWorker() must be a ServiceWorkerRegistration.","invalid-bg-handler":"The input to setBackgroundMessageHandler() must be a function.","invalid-vapid-key":"The public VAPID key must be a string.","use-vapid-key-after-get-token":"The usePublicVapidKey() method may only be called once and must be called before calling getToken() to ensure your VAPID key is used."},ke=new Ln("messaging","Messaging",yO);async function EO(n,e){const t=await Ju(n),r=jy(e),s={method:"POST",headers:t,body:JSON.stringify(r)};let i;try{i=await(await fetch(Qu(n.appConfig),s)).json()}catch(o){throw ke.create("token-subscribe-failed",{errorInfo:o?.toString()})}if(i.error){const o=i.error.message;throw ke.create("token-subscribe-failed",{errorInfo:o})}if(!i.token)throw ke.create("token-subscribe-no-token");return i.token}async function vO(n,e){const t=await Ju(n),r=jy(e.subscriptionOptions),s={method:"PATCH",headers:t,body:JSON.stringify(r)};let i;try{i=await(await fetch(`${Qu(n.appConfig)}/${e.token}`,s)).json()}catch(o){throw ke.create("token-update-failed",{errorInfo:o?.toString()})}if(i.error){const o=i.error.message;throw ke.create("token-update-failed",{errorInfo:o})}if(!i.token)throw ke.create("token-update-no-token");return i.token}async function qy(n,e){const r={method:"DELETE",headers:await Ju(n)};try{const i=await(await fetch(`${Qu(n.appConfig)}/${e}`,r)).json();if(i.error){const o=i.error.message;throw ke.create("token-unsubscribe-failed",{errorInfo:o})}}catch(s){throw ke.create("token-unsubscribe-failed",{errorInfo:s?.toString()})}}function Qu({projectId:n}){return`${aO}/projects/${n}/registrations`}async function Ju({appConfig:n,installations:e}){const t=await e.getToken();return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":n.apiKey,"x-goog-firebase-installations-auth":`FIS ${t}`})}function jy({p256dh:n,auth:e,endpoint:t,vapidKey:r}){const s={web:{endpoint:t,auth:e,p256dh:n}};return r!==$y&&(s.web.applicationPubKey=r),s}const TO=10080*60*1e3;async function wO(n){const e=await IO(n.swRegistration,n.vapidKey),t={vapidKey:n.vapidKey,swScope:n.swRegistration.scope,endpoint:e.endpoint,auth:$t(e.getKey("auth")),p256dh:$t(e.getKey("p256dh"))},r=await By(n.firebaseDependencies);if(r){if(SO(r.subscriptionOptions,t))return Date.now()>=r.createTime+TO?AO(n,{token:r.token,createTime:Date.now(),subscriptionOptions:t}):r.token;try{await qy(n.firebaseDependencies,r.token)}catch(s){console.warn(s)}return wp(n.firebaseDependencies,t)}else return wp(n.firebaseDependencies,t)}async function bO(n){const e=await By(n.firebaseDependencies);e&&(await qy(n.firebaseDependencies,e.token),await _O(n.firebaseDependencies));const t=await n.swRegistration.pushManager.getSubscription();return t?t.unsubscribe():!0}async function AO(n,e){try{const t=await vO(n.firebaseDependencies,e),r={...e,token:t,createTime:Date.now()};return await Gu(n.firebaseDependencies,r),t}catch(t){throw t}}async function wp(n,e){const r={token:await EO(n,e),createTime:Date.now(),subscriptionOptions:e};return await Gu(n,r),r.token}async function IO(n,e){const t=await n.pushManager.getSubscription();return t||n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:hO(e)})}function SO(n,e){const t=e.vapidKey===n.vapidKey,r=e.endpoint===n.endpoint,s=e.auth===n.auth,i=e.p256dh===n.p256dh;return t&&r&&s&&i}function bp(n){const e={from:n.from,collapseKey:n.collapse_key,messageId:n.fcmMessageId};return CO(e,n),RO(e,n),kO(e,n),e}function CO(n,e){if(!e.notification)return;n.notification={};const t=e.notification.title;t&&(n.notification.title=t);const r=e.notification.body;r&&(n.notification.body=r);const s=e.notification.image;s&&(n.notification.image=s);const i=e.notification.icon;i&&(n.notification.icon=i)}function RO(n,e){e.data&&(n.data=e.data)}function kO(n,e){if(!e.fcmOptions&&!e.notification?.click_action)return;n.fcmOptions={};const t=e.fcmOptions?.link??e.notification?.click_action;t&&(n.fcmOptions.link=t);const r=e.fcmOptions?.analytics_label;r&&(n.fcmOptions.analyticsLabel=r)}function PO(n){return typeof n=="object"&&!!n&&Uy in n}function NO(n){if(!n||!n.options)throw Vc("App Configuration Object");if(!n.name)throw Vc("App Name");const e=["projectId","apiKey","appId","messagingSenderId"],{options:t}=n;for(const r of e)if(!t[r])throw Vc(r);return{appName:n.name,projectId:t.projectId,apiKey:t.apiKey,appId:t.appId,senderId:t.messagingSenderId}}function Vc(n){return ke.create("missing-app-config-values",{valueName:n})}class DO{constructor(e,t,r){this.deliveryMetricsExportedToBigQueryEnabled=!1,this.onBackgroundMessageHandler=null,this.onMessageHandler=null,this.logEvents=[],this.isLogServiceStarted=!1;const s=NO(e);this.firebaseDependencies={app:e,appConfig:s,installations:t,analyticsProvider:r}}_delete(){return Promise.resolve()}}async function Hy(n){try{n.swRegistration=await navigator.serviceWorker.register(iO,{scope:oO}),n.swRegistration.update().catch(()=>{}),await OO(n.swRegistration)}catch(e){throw ke.create("failed-service-worker-registration",{browserErrorMessage:e?.message})}}async function OO(n){return new Promise((e,t)=>{const r=setTimeout(()=>t(new Error(`Service worker not registered after ${Ep} ms`)),Ep),s=n.installing||n.waiting;n.active?(clearTimeout(r),e()):s?s.onstatechange=i=>{i.target?.state==="activated"&&(s.onstatechange=null,clearTimeout(r),e())}:(clearTimeout(r),t(new Error("No incoming service worker found.")))})}async function VO(n,e){if(!e&&!n.swRegistration&&await Hy(n),!(!e&&n.swRegistration)){if(!(e instanceof ServiceWorkerRegistration))throw ke.create("invalid-sw-registration");n.swRegistration=e}}async function LO(n,e){e?n.vapidKey=e:n.vapidKey||(n.vapidKey=$y)}async function Wy(n,e){if(!navigator)throw ke.create("only-available-in-window");if(Notification.permission==="default"&&await Notification.requestPermission(),Notification.permission!=="granted")throw ke.create("permission-blocked");return await LO(n,e?.vapidKey),await VO(n,e?.serviceWorkerRegistration),wO(n)}async function MO(n,e,t){const r=xO(e);(await n.firebaseDependencies.analyticsProvider.get()).logEvent(r,{message_id:t[Uy],message_name:t[cO],message_time:t[lO],message_device_time:Math.floor(Date.now()/1e3)})}function xO(n){switch(n){case ai.NOTIFICATION_CLICKED:return"notification_open";case ai.PUSH_RECEIVED:return"notification_foreground";default:throw new Error}}async function FO(n,e){const t=e.data;if(!t.isFirebaseMessaging)return;n.onMessageHandler&&t.messageType===ai.PUSH_RECEIVED&&(typeof n.onMessageHandler=="function"?n.onMessageHandler(bp(t)):n.onMessageHandler.next(bp(t)));const r=t.data;PO(r)&&r[uO]==="1"&&await MO(n,t.messageType,r)}const Ap="@firebase/messaging",Ip="0.12.23";const $O=n=>{const e=new DO(n.getProvider("app").getImmediate(),n.getProvider("installations-internal").getImmediate(),n.getProvider("analytics-internal"));return navigator.serviceWorker.addEventListener("message",t=>FO(e,t)),e},UO=n=>{const e=n.getProvider("messaging").getImmediate();return{getToken:r=>Wy(e,r)}};function BO(){je(new Fe("messaging",$O,"PUBLIC")),je(new Fe("messaging-internal",UO,"PRIVATE")),Te(Ap,Ip),Te(Ap,Ip,"esm2020")}async function qO(){try{await jl()}catch{return!1}return typeof window<"u"&&ql()&&Qm()&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&"fetch"in window&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey")}async function jO(n){if(!navigator)throw ke.create("only-available-in-window");return n.swRegistration||await Hy(n),bO(n)}function HO(n=os()){return qO().then(e=>{if(!e)throw ke.create("unsupported-browser")},e=>{throw ke.create("indexed-db-unsupported")}),Vt(ie(n),"messaging").getImmediate()}async function WO(n,e){return n=ie(n),Wy(n,e)}function zO(n){return n=ie(n),jO(n)}BO();let ht=null;exports.auth=void 0;exports.provider=void 0;exports.analytics=void 0;exports.db=void 0;exports.storage=void 0;exports.functions=void 0;exports.messaging=void 0;function KO(n){if(ht)return ht;const{functionsRegion:e,...t}=n;return ht=Zm(t),exports.auth=Fk(ht),exports.provider=new Ut,exports.analytics=xC(ht),exports.db=zD(ht),exports.storage=L1(ht),exports.functions=rO(ht,e),exports.messaging=HO(ht),rt.isDev&&(Ey(exports.db,"localhost",8080),$g(exports.auth,"http://localhost:9099"),Fy(exports.functions,"localhost",5001),Vy(exports.storage,"localhost",9199)),ht}function Tl(){if(!ht)throw new Error("[cic-kit] Firebase non inizializzato. Chiama setupFirebase(firebaseConfig) nel main.")}const Ko="Sei offline: cancello in locale, sincronizzo quando torni online.";function zy(){return typeof navigator<"u"?!!navigator.onLine:!0}function Xu(){return!zy()}function Ys(n){if(n instanceof J)return n;try{return new J(n.seconds,n.nanoseconds)}catch{return K.logError({title:"reviveTimestamp errore:",message:`seconds:${n.seconds}; nanoseconds:${n.nanoseconds};`}),J.now()}}function wl(n){try{if(n==null||n instanceof J)return n;if(typeof n=="object"&&n.type==="firestore/timestamp/1.0"&&typeof n.seconds=="number"&&typeof n.nanoseconds=="number")return Ys(n);if(Array.isArray(n))return n.map(e=>wl(e));if(typeof n=="object"){const e={};for(const[t,r]of Object.entries(n))e[t]=wl(r);return e}return n}catch(e){return K.logError({title:"reviveTimestampsDeep error",message:e?.message??"Errore sconosciuto"}),n}}const Go=n=>{if(n==null)return n;if(n instanceof J)return n.toJSON();if(n&&typeof n=="object"&&n._methodName==="serverTimestamp")return K.logError("non puoi salvare un serverTimestamp devi usare Timestamp.now()"),J.now().toJSON();if(Array.isArray(n))return n.map(e=>Go(e));if(typeof n=="object"){const e={};for(const[t,r]of Object.entries(n))e[t]=Go(r);return e}return n},bl={unknown:"Errore sconosciuto.",undefined:"Non trovato.",cancelled:"Operazione annullata.","invalid-argument":"Argomento non valido.","deadline-exceeded":"Timeout dell’operazione.","not-found":"Risorsa non trovata.","already-exists":"La risorsa esiste già.","permission-denied":"Non hai i permessi necessari.","resource-exhausted":"Limite superato, riprova più tardi.","failed-precondition":"Stato non valido per questa operazione.",aborted:"Conflitto, operazione annullata.",unavailable:"Servizio momentaneamente non disponibile.","auth/email-already-in-use":"Questa email è già registrata.","auth/wrong-password":"Password errata.","auth/user-not-found":"Utente non trovato.","auth/invalid-email":"Indirizzo email non valido.","auth/too-many-requests":"Troppi tentativi, riprova più tardi.","auth/requires-recent-login":"Per favore effettua di nuovo il login.","storage/object-not-found":"File non trovato.","storage/unauthenticated":"Devi effettuare il login.","storage/unauthorized":"Non hai accesso a questo file.","storage/quota-exceeded":"Quota di archiviazione superata."};function GO(n){return n in bl}function bt(n,e){if(e===!1)return;const t=typeof n?.code=="string"?n?.code:"",r=GO(t)?bl[t]:!1;if(r)K.error(r);else{K.error(bl.unknown),console.log(`%cTodo gestire error.code "%c${n?.code}%c"`,"color:#fb9005; font-weight:bold;","color:#0dfb05; font-weight:bold;","color:#fb9005; font-weight:bold;");try{K.logError(String(n))}catch{K.logError("on try to parse error")}finally{console.log("[ERROR from middlewareCatchCall]:",n)}}}function Yo(n,e,t,...r){!rt.debugFirestore||!(i=>{if(!i)return;if(typeof rt.debugFirestore=="boolean")return rt.debugFirestore;const o=typeof rt.debugFirestore=="string"?[rt.debugFirestore]:rt.debugFirestore;return o.length>0?o.includes(i):!1})(n)||console.log(`${e}[${t}] [${n??"no collectionName"}]`,...r)}function Lc(n){if(Xu()){if(n!==!0)throw Ko;K.warning(Ko)}}const we={offlineAllow:!1,touchUpdate:!0,localSet:!0};class dt{id;createdAt;updatedAt;deleteAt;constructor(e){this.id=e.id,Object.assign(this,e);const t=J.now();this.createdAt=e.createdAt?Ys(e.createdAt):t,this.updatedAt=e.updatedAt?Ys(e.updatedAt):t,this.deleteAt=e.deleteAt&&e.deleteAt!==null?Ys(e.deleteAt):null}static collectionName;debugLog(e,...t){Yo(this?.collectionName??"no-collectionName","🔥📡🏪",e,t)}get ref(){const e=this.constructor,r=this.getCollectionPath?.()??e.collectionName;if(!r)throw new Error(`${e.name}: nessuna collectionName statica e nessuna getCollectionPath() definita.`);return Gs(exports.db,r,this.id)}static async get(e,t){try{Yo(this?.collectionName??"no-collectionName","🔥📡🏪","get");const r=t?.collectionPath??this.collectionName;if(!r)throw new Error(`${this.name}.get: serve opts.collectionPath per collezioni dinamiche, oppure definisci static collectionName.`);const s=Gs(exports.db,r,e),i=await El(s);if(!i.exists())return;const o=new this({id:e,...i.data()}),c=await o.onGetBeforeStoreSet(o);return c.canLocalSave(t?.localSet)&&c.localSet(),c}catch(r){throw bt(r),r}}static cleanDataAAA(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>{if(r==null)return[t,_l()];if(typeof r=="object"&&r!==null&&!(r instanceof J)&&!(r instanceof Date))try{return[t,structuredClone(r)]}catch{return[t,JSON.parse(JSON.stringify(r))]}return[t,r]}))}static isPlainObject(e){return!!e&&typeof e=="object"}static stripUndefinedDeep(e){if(e!==void 0){if(e===null)return null;if(e instanceof J||e instanceof Date||e instanceof oi)return e;if(Array.isArray(e))return e.map(t=>dt.stripUndefinedDeep(t)).filter(t=>t!==void 0);if(dt.isPlainObject(e)){const t={};for(const[r,s]of Object.entries(e)){const i=dt.stripUndefinedDeep(s);i!==void 0&&(t[r]=i)}return t}return e}}static cleanData(e){const t=dt.stripUndefinedDeep(e);return Object.fromEntries(Object.entries(t??{}).map(([s,i])=>{if(i==null)return[s,_l()];if((dt.isPlainObject(i)||Array.isArray(i))&&!(i instanceof J)&&!(i instanceof Date)&&!(i instanceof oi))try{return[s,structuredClone(i)]}catch{return[s,JSON.parse(JSON.stringify(i))]}return[s,i]}))}async onGetBeforeStoreSet(e){return e}async save({offlineAllow:e=we.offlineAllow,touchUpdate:t=we.touchUpdate,localSet:r=we.localSet}=we){this.debugLog("save");try{Lc(e);const s=this.toData(),i=dt.cleanData(s);t&&!i.updatedAt&&(i.updatedAt=this.touchUpdated()),await ky(this.ref,{...i},{merge:!0}),this.canLocalSave(r)&&this.localSet()}catch(s){throw bt(s),s}}async update(e,{offlineAllow:t=we.offlineAllow,touchUpdate:r=we.touchUpdate,localSet:s=we.localSet}=we){this.debugLog("update");try{Lc(t);const i=dt.cleanData(e);r&&!i.updatedAt&&(i.updatedAt=this.touchUpdated()),await a1(this.ref,i),Object.assign(this,e),this.canLocalSave(s)&&this.localSet()}catch(i){throw bt(i),i}}async delete(e,t=we){return this.debugLog("deleteUsingStore",`[id=${this.id}]`),await e.delete(this.id,t)}async deleteJustOnline_NotLocalStore({offlineAllow:e=we.offlineAllow,localSet:t=we.localSet}=we){this.debugLog("delete");try{Lc(e),await c1(this.ref),this.canLocalSave(t)&&this.localSet(!0)}catch(r){throw bt(r),r}}get isDeleted(){return this.deleteAt!==null}timestampbleProps(){return{createdAt:this.createdAt,updatedAt:this.updatedAt,deleteAt:this.deleteAt}}touchUpdated(){const e=J.now();return this.updatedAt=e,e}async softDelete(e){if(this.debugLog("softDelete"),this.deleteAt!==null){K.warning("Elemento già nel cestino.");return}const t=J.now();this.deleteAt=t,await this.update({deleteAt:t},e)}async restore(e){if(this.debugLog("restore"),this.deleteAt===null){K.warning("Elemento non è nel cestino.");return}this.deleteAt=null,await this.update({deleteAt:null},e)}canLocalSave(e){if(e===!1)return!1;try{return!!this?.localStorageKey?.()}catch{return!1}}localSet(e){this.debugLog("localSet");const t=this?.localStorageKey?.();if(!t)return;const r=this?.toData?.()??{id:this.id},s=Go(r),i=Ve.getParsed(t);if(i&&typeof i=="object"&&!Array.isArray(i)){if(e){i[this.id]&&(delete i[this.id],Ve.set(t,i));return}Ve.set(t,{...i,[this.id]:s})}else Ve.set(t,{[this.id]:s})}}function YO(n){if(Xu()){if(n!==!0)throw Ko;K.warning(Ko)}}class QO{ModelInstnce;makeModel(e,t){return new this.ModelInstnce({id:e,...t})}_collectionPath;debugLog(e,...t){Yo(this.collectionPath,"🔥📡📦",e,t)}items={};snapshotFnStop=null;isFirstRun=!0;prevStartQuery="";get live(){return!!this.snapshotFnStop}get ref(){return WD(exports.db,this.collectionPath)}constructor(e,t){this.ModelInstnce=e,this._collectionPath=t?.collectionPath}get collectionPath(){const e=this._collectionPath??this.ModelInstnce.collectionName;if(!e)throw new Error("collectionPath non definita");return e}get name(){return this.collectionPath}get itemsActive(){return Object.fromEntries(Object.entries(this.items).filter(([,e])=>!e.isDeleted))}get itemsDeleted(){return Object.fromEntries(Object.entries(this.items).filter(([,e])=>e.isDeleted))}get itemsArray(){return Object.values(this.items)}get itemsActiveArray(){return Object.values(this.items).filter(e=>!e.isDeleted)}get itemsDeletedArray(){return Object.values(this.items).filter(e=>e.isDeleted)}get isEmpty(){return Object.keys(this.items).length===0}get isActiveEmpty(){return this.itemsActiveArray.length===0}get isDeletedEmpty(){return this.itemsDeletedArray.length===0}get localStorageKey(){const e=this.ModelInstnce?.prototype?.localStorageKey?.();if(!e){K.logError("Impossibile svuotare LocalStorage: localStorageKey() non definita nel Model.");return}return e}itemsArrayOrderedBy(e,t){return[...t===void 0?this.itemsArray:t?this.itemsDeletedArray:this.itemsActiveArray].sort((s,i)=>{const o=s[e]?.toMillis?.()??0;return(i[e]?.toMillis?.()??0)-o})}findItemsById(e){if(!(!e||e===""))return this.items?.[e]}async get(e={}){this.debugLog("get");try{const t=Al(e),r=t?cp(this.ref,...t):this.ref,s=await o1(r);e.forceLocalSet&&(this.items={},this.localClear());for(const i of s.docs){const o=this.makeModel(i.id,i.data()),c=await o.onGetBeforeStoreSet(o);this.items[i.id]=c,(c.canLocalSave(e.localSet)||e.forceLocalSet&&c.canLocalSave())&&c.localSet()}return this.items}catch(t){throw bt(t),t}}async getIds(e){this.debugLog("getIds");const t=Array.from(new Set((e??[]).map(l=>(l??"").trim()).filter(Boolean)));if(t.length===0)return{foundIds:!1,notFoundIds:!1};const r=(l,h)=>{const f=[];for(let g=0;g<l.length;g+=h)f.push(l.slice(g,g+h));return f},s=new Set,i=r(t,10);for(const l of i){const h=await this.get({query:yl(gl(),"in",l)});for(const f of Object.keys(h))s.add(f)}const o=Array.from(s),c=t.filter(l=>!s.has(l));return{foundIds:o.length>0?o:!1,notFoundIds:c.length>0?c:!1}}localGet(){const e=this.localStorageKey;try{if(!e){K.logError({title:"localGet "+e,message:"LocalStorageKey not found"});return}const t=Ve.getParsed(e);for(const r in t)this.items[r]=this.makeModel(r,t[r])}catch{K.logError({title:"localGet "+e,message:"errore try parse o makeModel"})}}async start(e={}){if(this.debugLog("👂 start"),!Zu(e))return;const t=JSON.stringify([e.ids,e.query,e.limit,e.orderBy].map(i=>i?.toString?.()??String(i)));if(this.live&&this.prevStartQuery===t)return;this.stop(),this.prevStartQuery=t;const r=Al(e,!0),s=r?cp(this.ref,...r):this.ref;this.snapshotFnStop=l1(s,async i=>{const o=i.docChanges();this.isFirstRun&&(this.debugLog("👂 firstRun"),this.isFirstRun=!1,this.onStartFirstRun(o,e.forceLocalSet),e.forceLocalSet&&(this.items={},this.localClear()));for(const c of o){const l=c.doc.id;if(c.type==="removed"){this.items[l]?.localSet(!0),delete this.items[l];continue}const h=c.doc.data(),f=this.makeModel(l,h),g=await f.onGetBeforeStoreSet(f);this.items[l]=g,g.canLocalSave(e.localSet)&&g.localSet()}},i=>{this.stop(),bt(i)})}onStartFirstRun(e,t){}stop(){this.snapshotFnStop&&(this.debugLog("🛑 stop"),this.prevStartQuery=null,this.snapshotFnStop(),this.snapshotFnStop=null,this.isFirstRun=!0)}async add(e,{offlineAllow:t=we.offlineAllow,localSet:r=we.localSet}=we){try{this.debugLog("add"),YO(t);const{id:s,...i}=e,o=dt.stripUndefinedDeep(i);let c=s??"";if(s){const h=Gs(exports.db,this.collectionPath,s);if((await El(h)).exists())throw new Error("Documento già esistente")}else c=Gs(this.ref).id;const l=this.makeModel(c,o);return await l.save({offlineAllow:t,touchUpdate:!0,localSet:r}),this.items[c]=l,l}catch(s){throw bt(s),s}}async delete(e,t=we){try{if(this.items[e]){const r=this.items[e].deleteJustOnline_NotLocalStore(t);return delete this.items[e],await r}}catch(r){throw bt(r),r}}findByUid(e){if(!(!this.itemsArray||!this.itemsArray.length))return this.itemsArray.find(t=>t.uid===e)}async getOne(e,t){this.debugLog("getOne");try{const r=Gs(exports.db,this.collectionPath,e),s=await El(r);if(!s.exists())throw this.items[e]&&delete this.items[e],new Error("[404] non trovato");const i=s.data(),o=this.makeModel(e,i),c=await o.onGetBeforeStoreSet(o);return this.items[e]=c,c.canLocalSave(t?.localSet)&&c.localSet(),c}catch(r){throw bt(r),r}}async ensureOne(e){const t=this.items[e];return t||this.getOne(e)}localClear(){const e=this.localStorageKey;Ve.has(e)?(Ve.remove(e),K.log(`LocalStorage "${e}" svuotato con successo.`)):K.log(`Nessun dato trovato per LocalStorage "${e}".`)}}function Zu(n){if(n.ids&&n.ids.length>0){if(n.ids.length>10)return K.logError("Non puoi lanciare start con più di 10 id"),!1;if(n.query)return K.logError('Non è supportato usare "query" insieme a "ids" in start()'),!1}if(n.lastByCreate||n.lastByUpdate){if(n.lastByCreate&&n.lastByUpdate)return K.logError("Non puoi usare lastByCreate e lastByUpdate insieme"),!1;if(n.limit||n.orderBy)return K.logError("Non puoi usare limit o orderBy insieme a lastByCreate / lastByUpdate"),!1}return!0}function Al(n,e=!1){if(!e&&!Zu(n))return!1;const t=[];if(n.ids&&n.ids.length>0){const r=Array.from(new Set(n.ids.map(s=>(s??"").trim()).filter(Boolean)));r.length===1?t.push(yl(gl(),"==",r[0])):r.length>1&&t.push(yl(gl(),"in",r))}else n.query&&t.push(...Array.isArray(n.query)?n.query:[n.query]);return n.lastByCreate?(t.push(kc("createdAt","desc")),t.push(Pc(n.lastByCreate)),t):n.lastByUpdate?(t.push(kc("updatedAt","desc")),t.push(Pc(n.lastByUpdate)),t):(n.orderBy&&t.push(kc(n.orderBy.fieldPath,n.orderBy.directionStr??"asc")),n.limit&&t.push(Pc(n.limit)),t)}function JO(n){let e=null;p.onBeforeUnmount(()=>{e?.(),e=null;for(const t of n)t.store.stop()})}const Ky={SUPERADMIN:"SUPERADMIN",ADMIN:"ADMIN",MODAL_DEV_ON:"MODAL_DEV_ON",MANAGE_USERS:"MANAGE_USERS",OFFLINE_ALLOW:"OFFLINE_ALLOW",BETA_FEATURES:"BETA_FEATURES"};class XO extends dt{static collectionName="users";localStorageKey(){return Ve.defaultKey.currentUser}userPublicId;name;surname;email;birthDate;phoneNumber;photoURL;description;permissions;gender;birthHideYear;fcmTokens;constructor(e){super(e),this.userPublicId=e.userPublicId,this.name=e.name,this.surname=e.surname,this.email=e.email,this.birthDate=e.birthDate,this.phoneNumber=e.phoneNumber,this.photoURL=e.photoURL,this.description=e.description,this.permissions=e.permissions??[],this.gender=e.gender,this.birthHideYear=e.birthHideYear,this.fcmTokens=e.fcmTokens}toData(){return{id:this.id,userPublicId:this.userPublicId,name:this.name,surname:this.surname,email:this.email,birthDate:this.birthDate,phoneNumber:this.phoneNumber,photoURL:this.photoURL,description:this.description,permissions:this.permissions,gender:this.gender,birthHideYear:this.birthHideYear,fcmTokens:this.fcmTokens}}async create(){try{const e=this.toData(),t=Object.fromEntries(Object.entries(e).map(([r,s])=>s==null?[r,_l()]:[r,s]));t.permissions!==void 0&&delete t.permissions,await ky(this.ref,t,{merge:!0})}catch(e){throw K.error(String(e)),e}}get fullName(){let e=`${this.name} ${this.surname}`.trim();return e===""&&(e="-"),e}get fullNameInitials(){const e=this.fullName,t=e.split(" ").filter(Boolean);return((t[0]?.[0]||"")+(t[1]?.[0]||"")||e?.[0]||"?").toUpperCase()}async updateName(e,t){await this.update({name:e,surname:t})}async updateBirthDate(e){await this.update({birthDate:e})}hasPermission(e){return Array.isArray(this.permissions)&&this.permissions.includes(e)}hasAnyPermissions(){return Array.isArray(this.permissions)&&this.permissions.length>0}hasAnyPermissionsExclud(e){return!Array.isArray(this.permissions)||this.permissions.length===0?!1:this.permissions.some(t=>!e.includes(t))}get offlineAllow(){return this.hasPermission(Ky.OFFLINE_ALLOW)}async addPermissions(e){const r=(Array.isArray(e)?e:[e]).filter(s=>!this.permissions.includes(s));return r.length===0?!1:(this.permissions.push(...r),this.update({permissions:this.permissions}).then(()=>!0))}async deletePermissions(e){const t=Array.isArray(e)?e:[e],r=this.permissions.length;return this.permissions=this.permissions.filter(s=>!t.includes(s)),this.permissions.length===r?!1:this.update({permissions:this.permissions}).then(()=>!0)}hasFcmToken(e){return e?(this.fcmTokens??[]).includes(e):!1}async addFcmToken(e){return Array.isArray(this.fcmTokens)||(this.fcmTokens=[]),this.hasFcmToken(e)?!1:(this.fcmTokens.push(e),this.update({fcmTokens:this.fcmTokens}).then(()=>!0))}async removeFcmToken(e){if(!Array.isArray(this.fcmTokens)||this.fcmTokens.length===0)return!1;const t=this.fcmTokens.length;return this.fcmTokens=this.fcmTokens.filter(r=>r!==e),this.fcmTokens.length===t?!1:this.update({fcmTokens:this.fcmTokens}).then(()=>!0)}}function Sp(n){const e=typeof n=="string"?{title:n}:n,{title:t,...r}=e;return r.icon||(r.icon="/img/logo/pwa.png"),r.tag||(r.tag=`default-${new Date().toISOString().slice(0,10)}`),r.data||(r.data={url:"/"}),r?.data?.url||(r.data.url="/"),{title:t,options:r}}const Il=p.reactive({reg:void 0,VAPID_PUBLIC_KEY:void 0,isNotificationSupported:typeof Notification<"u",get permission(){return this.isNotificationSupported?Notification.permission:"denied"},get needToAskPermission(){return this.isNotificationSupported?Notification.permission==="default":!1},async askPermission(n){if(!Il.isNotificationSupported)return K.error("Le notifiche non sono supportate su questo dispositivo"),"denied";Il.permission==="denied"&&K.warning("Notifiche disabilitate. Per abilitarle cercare nelle impostazioni del browser.");const e=await Notification.requestPermission();return e!=="granted"?K.warning("Hai disabilitato le notifiche. Per abilitarle cercare nelle impostazioni del browser."):this.registerFcmToken(n),e},async send(n,e){if(!this.isNotificationSupported){K.error("Le notifiche non sono supportate su questo dispositivo");return}if(this.permission!=="granted"&&await this.askPermission(n)!=="granted")return;const{title:t,options:r}=Sp(e);this.reg?await this.reg.showNotification(t,r):new Notification(t,r)},async sendTo(n,e){let t=!1;try{const r=sO(exports.functions,"sendUserPush"),{title:s,options:i}=Sp(e);console.log({title:s,options:i}),await r({toUid:n,title:s,options:i}),t=!0}catch(r){console.error(r),K.error("Errore invio notifica")}return t},async getCurrentFcmToken(){return Tl(),this.isNotificationSupported?this.reg?this.VAPID_PUBLIC_KEY?await WO(exports.messaging,{vapidKey:this.VAPID_PUBLIC_KEY,serviceWorkerRegistration:this.reg}).catch(()=>null)||null:(K.error("VAPID_PUBLIC_KEY mancante"),null):(K.error("ServiceWorker non registrato"),null):null},async registerFcmToken(n){if(Tl(),!this.isNotificationSupported)return null;this.needToAskPermission&&await this.askPermission(n);const e=await this.getCurrentFcmToken();return e?(await n.addFcmToken(e)?K.success("Abilitato"):K.warning("Token non aggiunto possibilmente già presente."),e):null},async removeThisDeviceToken(n){const e=await this.getCurrentFcmToken();let t=!1;try{t=await zO(exports.messaging)}catch(s){console.warn("deleteToken() failed (continuo con cleanup lato currentUser):",s)}let r=!1;if(e)try{r=await n.removeFcmToken(e)}catch(s){console.warn("removeFcmToken() user failed:",s)}return t||r?(K.success("Notifiche disattivate per questo dispositivo."),!0):(K.warning("Nessun token da rimuovere per questo dispositivo."),!1)}});function po(n){const e=globalThis.structuredClone;if(typeof e=="function")try{return e(n)}catch{return pn(n)}return pn(n)}function pn(n,e=new WeakMap){if(n===null||typeof n!="object")return n;if(e.has(n))return e.get(n);if(n instanceof Date)return new Date(n.getTime());if(n instanceof Map){const r=new Map;return e.set(n,r),n.forEach((s,i)=>r.set(pn(i,e),pn(s,e))),r}if(n instanceof Set){const r=new Set;return e.set(n,r),n.forEach(s=>r.add(pn(s,e))),r}if(Array.isArray(n)){const r=new Array(n.length);e.set(n,r);for(let s=0;s<n.length;s++)r[s]=pn(n[s],e);return r}const t={};e.set(n,t);for(const r of Object.keys(n))t[r]=pn(n[r],e);for(const r of Object.getOwnPropertySymbols(n))t[r]=pn(n[r],e);return t}const ZO=(n,e="")=>{const t=n.trim();if(t.startsWith("+")){const r=t.match(/^\+(\d{1,3})\s*(.+)$/);if(r)return[`+${r[1]}`,(r[2]??"").replace(/\s+/g,"")]}return[e,t.replace(/\s+/g,"")]};class eV{id;values;errors;touched;_initial;schema;_onSubmit;_onInvalid;_validateOnChangeMap;_touchOnChangeMap;_stopWatch;_fieldCache={};_allFields;_submitOnChange;_suspendAutoSubmit=!1;_debouncedSubmit;_syncPreference;_effects;_onAnyChange;_makeDebouncedSubmit(e){let t;return()=>{t&&clearTimeout(t),t=window.setTimeout(()=>{this._suspendAutoSubmit||this.submit()},e)}}constructor(e,t){this.id=e.id??"";const r=T=>"initialValues"in T;this._syncPreference=r(e)&&e.syncPreference?e.syncPreference:"db";const s=r(e)?e.initialValues:e,i=Object.keys(s),o=(T,C)=>{const P={};for(const k of i)P[k]=C;if(typeof T=="boolean")for(const k of i)P[k]=T;else T&&typeof T=="object"&&Object.assign(P,T);return P},c=(r(e)?e.validator:t)??{},l=r(e)?e.onSubmit:void 0,h=r(e)?e.onInvalid:void 0,f=r(e)?e.validateOnChange:void 0,g=r(e)?e.touchOnChange:void 0;this._validateOnChangeMap=o(f,!0),this._touchOnChangeMap=o(g,!0);const _=r(e)?e.syncWith:void 0;this._initial=po(s),this.values=p.reactive(po(s)),this.errors=p.reactive(Object.keys(s).reduce((T,C)=>(T[C]=null,T),{})),this.touched=p.reactive(Object.keys(s).reduce((T,C)=>(T[C]=!1,T),{})),this.schema=c,this._onSubmit=l,this._onInvalid=h,this._submitOnChange=r(e)?e.submitOnChange:void 0,this._effects=r(e)?e.effects:void 0,this._onAnyChange=r(e)?e.onAnyChange:void 0,typeof this._submitOnChange=="number"&&this._submitOnChange>=0&&(this._debouncedSubmit=this._makeDebouncedSubmit(this._submitOnChange)),_&&(p.isRef(_)?this._stopWatch=p.watch(_,T=>{T&&this.fill(T)},{immediate:!0}):typeof _=="function"&&(this._stopWatch=p.watch(_,T=>{T&&this.fill(T)},{immediate:!0})))}touch(e){this.touched[e]=!0}touchAll(){for(const e of Object.keys(this.touched))this.touched[e]=!0}field(e){const t=this._fieldCache[e];if(t)return t;const r=p.computed({get:()=>this.values[e],set:s=>this.set(e,s)});return this._fieldCache[e]=r,r}fields(){if(!this._allFields){const e={};for(const t of Object.keys(this.values))e[t]=this.field(t);this._allFields=e}return this._allFields}set(e,t,r){this.values[e]=t,!this.touched[e]&&(this._touchOnChangeMap[e]??!1)&&(this.touched[e]=!0),(r??!!this._validateOnChangeMap[e])&&this.validateField(e),this._effects?.[e]?.(t,this),this._onAnyChange?.(e,t,this),!this._suspendAutoSubmit&&this._submitOnChange&&(this._submitOnChange===!0?this.submit():typeof this._submitOnChange=="number"&&this._debouncedSubmit?.())}validateField(e){const t=this.schema[e]??[];for(const r of t){const s=r(this.values[e]);if(this.errors[e]=s,s)return!1}return this.errors[e]=null,!0}validateAll(){let e=!0;for(const t of Object.keys(this.values))this.validateField(t)||(this.touch(t),e=!1);return e}fill(e,t){let{validate:r}=t??{};r===void 0&&(r=!1),this._suspendAutoSubmit=!0;try{for(const s in e){if(!(s in this.values))continue;const i=s;this._syncPreference==="local"&&this.touched[i]||(this.values[i]=e[i])}r&&this.validateAll()}finally{this._suspendAutoSubmit=!1}}reset({keepTouched:e=!1}={}){for(const t of Object.keys(this._initial))this.values[t]=this._initial[t];for(const t of Object.keys(this.errors))this.errors[t]=null;if(!e)for(const t of Object.keys(this.touched))this.touched[t]=!1}resetWithInitialValues(e){this._initial=po(e),this.reset()}bindField(e,t){return p.computed({get:()=>this.values[e],set:r=>this.set(e,r,t??this._validateOnChangeMap[e]??!1)})}showError(e){return this.touched[e]?this.errors[e]:null}hasError(e){return!!this.showError(e)}getFieldId(e){return`${this.id!==""?this.id+"_":""}field_${String(e)}`}getFieldIdError(e){return`${this.getFieldId(e)}-error`}getFieldProps(e){return{id:this.getFieldId(e),"aria-invalid":this.hasError(e),"aria-describedby":this.getFieldIdError(e),class:{"is-invalid":!!this.showError(e)}}}get isValid(){return Object.values(this.errors).every(e=>e==null)}get isDirty(){return JSON.stringify(this.values)!==JSON.stringify(this._initial)}get touchedValues(){const e={};for(const t of Object.keys(this.values))this.touched[t]&&(e[t]=this.values[t]);return e}dispose(){this._stopWatch?.()}submit=async()=>{if(!this.validateAll()){this._onInvalid?.(this.errors);return}await this._onSubmit?.(this.values,this.touchedValues,this.touched)};setSyncPreference(e){this._syncPreference=e}}const tV=(n="Obbligatorio")=>e=>e==null||typeof e=="string"&&e.trim().length===0||Array.isArray(e)&&e.length===0?n:null,nV=(n="Email non valida")=>e=>e?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)?null:n:null,rV=(n="Formato richiesto: AAAA-MM-GG")=>e=>e?/^\d{4}-\d{2}-\d{2}$/.test(e)?null:n:null,sV=(n="URL non valido")=>e=>{if(!e)return null;try{return new URL(e),null}catch{return n}},iV=(n,e="Seleziona un’opzione")=>t=>t?n.includes(t)?null:e:null,oV=(n="Devi accettare")=>e=>e?null:n,aV=(n="Deve essere un numero")=>e=>e==null||e===""?null:isNaN(Number(e))?n:null,cV=(n,e)=>t=>{if(t==null||t==="")return null;const r=Number(t);return isNaN(r)?e??"Deve essere un numero":r<n?e??`Il numero deve essere ≥ ${n}`:null},lV=(n,e)=>t=>{if(t==null||t==="")return null;const r=Number(t);return isNaN(r)?e??"Deve essere un numero":r>n?e??`Il numero deve essere ≤ ${n}`:null},uV=(n,e)=>t=>t&&t.length<n?e??`Minimo ${n} caratteri`:null,hV=(n,e)=>t=>t&&t.length>n?e??`Massimo ${n} caratteri`:null,Gy=/^(?=.*[A-Z])(?=.*\d)(?!.*\s).+$/,dV=(n="La password deve contenere almeno una maiuscola, un numero e nessuno spazio")=>e=>e?Gy.test(e)?null:n:null,fV=(n,e)=>t=>t?t.length<n?e??`La password deve avere almeno ${n} caratteri`:Gy.test(t)?null:e??"La password deve contenere almeno una maiuscola, un numero e nessuno spazio":null,pV=(n,e="Le password non coincidono")=>t=>{if(!t)return null;const r=n()??"";return t===r?null:e};function er(n){if(!n)return null;if(n instanceof Date)return isNaN(n.getTime())?null:n;if(/^\d{4}-\d{2}-\d{2}$/.test(n)){const e=new Date(n+"T00:00:00");return isNaN(e.getTime())?null:e}return null}const mV=(n,e="La data deve essere successiva")=>t=>{if(!t)return null;const r=er(t),s=er(n());return!r||!s||r>=s?null:e},gV=(n,e="La data deve essere precedente")=>t=>{if(!t)return null;const r=er(t),s=er(n());return!r||!s||r<=s?null:e},_V=(n,e,t="La data deve essere compresa nell’intervallo")=>r=>{if(!r)return null;const s=er(r),i=er(n()),o=er(e());return!s||!i||!o||s>=i&&s<=o?null:t},Qo=n=>String(n).padStart(2,"0");function Jo(n){return n instanceof Date&&!isNaN(n.getTime())}function Da(n){if(!n)return null;if(n instanceof Date)return Jo(n)?n:null;if(n instanceof J)return n.toDate();if(typeof n=="string"||typeof n=="number"){const e=new Date(n);return Jo(e)?e:null}return null}function Yy(n){const e=Da(n);return e?`${e.getFullYear()}-${Qo(e.getMonth()+1)}-${Qo(e.getDate())}`:""}function Qy(n){const e=Da(n);return e?`${Qo(e.getHours())}:${Qo(e.getMinutes())}`:""}function yV(n){const e=Da(n);return e?`${Yy(e)}T${Qy(e)}`:""}function EV(n){if(!n)return null;const e=new Date(`${n}T00:00:00`);return Jo(e)?e:null}function vV(n,e){if(!n)return null;console.log(e);const t=e&&e!==""?e:"00:00";console.log(`${n}T${t}:00`);const r=new Date(`${n}T${t}:00`);return Jo(r)?J.fromDate(r):null}function TV(n,e=""){return n==null?e:String(n)}function wV(n){if(n==null||n==="")return"";const e=Number(n);return isNaN(e)?"":e}function bV(n){return!!n}function AV(n){return Array.isArray(n)?n.map(e=>String(e)).filter(Boolean):[]}function IV(n,e){if(!n)return"";const t=String(n);return e&&!e.includes(t)?"":t}function SV(n,e=void 0){const t=Da(n);return t?t.toLocaleString(e):""}function CV(n){if(n==null)return"-";const e=String(n).trim();return e===""?"-":e}const RV={install(n){n.component("Accordion",Cp),n.component("Btn",ze),n.component("ToastCmp",Pp),n.component("FieldGender",Np),n.component("FieldPhoneNumber",Dp),n.component("InputField",Op),n.component("Offcanvas",Ul),n.component("ObjectDataViewer",$m),n.component("ContainerSubSettings",Um),n.component("ContainerSideTabs",Bm)}};exports.Accordion=Cp;exports.Btn=ze;exports.CicKit=RV;exports.ContainerSideTabs=Bm;exports.ContainerSubSettings=Um;exports.FieldGender=Np;exports.FieldPhoneNumber=Dp;exports.FirestoreModel=dt;exports.FirestoreStore=QO;exports.FormValidator=eV;exports.InputField=Op;exports.LS=Ve;exports.ObjectDataViewer=$m;exports.Offcanvas=Ul;exports.Toast=Rp;exports.ToastCmp=Pp;exports.User=XO;exports.buildConstraintsFromGetProps=Al;exports.cicKitStore=rt;exports.clone=po;exports.dateAfter=mV;exports.dateBefore=gV;exports.dateBetween=_V;exports.dateISO=rV;exports.defaultUserPermission=Ky;exports.email=nV;exports.emptyToDash=CV;exports.ensureFirebase=Tl;exports.fireDebugLog=Yo;exports.inputDateTimeToTimestamp=vV;exports.inputDateToDate=EV;exports.isBrowserOffline=Xu;exports.isBrowserOnline=zy;exports.isNumber=aV;exports.maxLength=hV;exports.maxNumber=lV;exports.middlewareCatchCall=bt;exports.minLength=uV;exports.minNumber=cV;exports.oneOf=iV;exports.optionFireModelDefault=we;exports.password=dV;exports.passwordRetype=pV;exports.passwordWithMin=fV;exports.phoneNumberFromString=ZO;exports.pushMsg=Il;exports.required=tV;exports.requiredTrue=oV;exports.reviveTimestamp=Ys;exports.reviveTimestampsDeep=wl;exports.serializeTimestamp=Go;exports.setupFirebase=KO;exports.shareLink=kp;exports.signInWithPopup=KR;exports.timestampInputDate=Yy;exports.timestampInputDateTimeLocal=yV;exports.timestampInputTime=Qy;exports.timestampToLocale=SV;exports.toast=K;exports.url=sV;exports.useStoreWatch=JO;exports.validateQueryGetOpts=Zu;exports.valueToInputBoolean=bV;exports.valueToInputNumber=wV;exports.valueToInputString=TV;exports.valueToSelect=IV;exports.valueToStringArray=AV;
|