@qratilabs/qrati-connect 2.31.1 → 2.31.2

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.
Files changed (41) hide show
  1. package/element/{ydzHqf5r.js → 5r_0x4aK.js} +1 -1
  2. package/element/{e2mrPlw-.js → ASQv5Ahv.js} +1 -1
  3. package/element/{CS8uERGc.js → BCmdnJKF.js} +1 -1
  4. package/element/{BqPiuAuP.js → BOs_rBYA.js} +1 -1
  5. package/element/{QxKjlE-j.js → BWKUiudT.js} +1 -1
  6. package/element/{DKxH7j1t2.js → BWjYmdOz2.js} +1 -1
  7. package/element/{BALdepDv.js → BXUp7Zp4.js} +1 -1
  8. package/element/{CQMPBmQq2.js → B_SYJsyF2.js} +1 -1
  9. package/element/{Ba8sCyeC2.js → BaYMN8qa2.js} +1 -1
  10. package/element/{Clga4U4Y.js → Bc-phiG6.js} +1 -1
  11. package/element/{BgZyx8Pz.js → BpAijsfn.js} +1 -1
  12. package/element/{CXRH3zmy.js → Bq48A0Iv.js} +1 -1
  13. package/element/{cBUXG_uS.js → BszsxRY6.js} +1 -1
  14. package/element/{BxQf2Aj9.js → Bvc6t1Gu.js} +1 -1
  15. package/element/{7fZbqbYO2.js → CFRIlHtK2.js} +1 -1
  16. package/element/{BrDFXZq12.js → CHYm7f-K2.js} +1 -1
  17. package/element/{DqAzUQcH.js → CJ_l5BYI.js} +1 -1
  18. package/element/{p4NDlPrf.js → CNyy8GGA.js} +1 -1
  19. package/element/{BVxovwox.js → CQJ3AK1w.js} +1 -1
  20. package/element/{CfszNu_Q.js → CV7KmbT-.js} +1 -1
  21. package/element/{Ci9PI8hK2.js → CYGIt75r2.js} +2 -2
  22. package/element/{BGo2VsHN2.js → Cj_TL6Ks2.js} +6 -6
  23. package/element/{8QLGsYN7.js → CkBayeWW.js} +1 -1
  24. package/element/{Be3fjihP2.js → D1eaRhKY2.js} +1 -1
  25. package/element/{BwHTzCpH.js → D54cshAo.js} +1 -1
  26. package/element/{BuhJHzFX.js → D5Ja4Yts.js} +1 -1
  27. package/element/{BUd_JUBh.js → DJMlQk40.js} +1 -1
  28. package/element/{Cyknlxbq.js → DTPNRhMK.js} +1 -1
  29. package/element/{CcyeEIVb2.js → DWwbkxCM2.js} +1 -1
  30. package/element/{DIWjXG_0.js → Do4y0nPe.js} +1 -1
  31. package/element/{CdivXyOP.js → Dpwx5KMy.js} +5 -5
  32. package/element/{DLHvSz1a2.js → Te9ieH1R2.js} +1 -1
  33. package/element/{BF7pLcqs.js → V_pvG6Pc.js} +3 -3
  34. package/element/{BK_hWmGs.js → Z3MoLpu5.js} +1 -1
  35. package/element/{IK19gQaC.js → a_rT1I0D.js} +1 -1
  36. package/element/{Cnr4EYcL.js → erXAfWWY.js} +1 -1
  37. package/element/{9E5bMl4h.js → rlutojb0.js} +1 -1
  38. package/element/{B7bKBLKV2.js → tbcqJrU_2.js} +1 -1
  39. package/element/web.es.js +3 -3
  40. package/element/{Cz6OP78x2.js → xPoQq2aN2.js} +1 -1
  41. package/package.json +1 -1
@@ -1 +1 @@
1
- import{p as t,t as s,w as e}from"./BXMw4kNf.js";import{c as i}from"./Bb9ydqSB.js";import{t as r}from"./BK_hWmGs.js";import{t as o}from"./QxKjlE-j.js";import{t as a}from"./Bki5T_lb.js";var h=({url:h,alt:l="",thumbnailUrl:n,blurhash:u,pswpData:p={},curateLink:c,onClick:w})=>{const v=t(()=>(t=>Object.keys(t).reduce((s,e)=>{const i=t[e];return null==i||""===i||(s[`data-pswp-${r=e,r.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}`]=i),s;var r},{}))(p),[p]),d=/* @__PURE__ */s(e,{children:[/* @__PURE__ */s(o,{threshold:.1,src:n||h,blurhash:u,alt:l}),p.type===i.VIDEO&&/* @__PURE__ */s("div",{className:"absolute inset-0 top-0 left-0 flex items-center justify-center opacity-75",children:/* @__PURE__ */s("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-16 text-white lg:w-24",viewBox:"0 0 24 24",children:/* @__PURE__ */s("path",{fill:"currentColor",d:"M8 17.175V6.825q0-.425.3-.713t.7-.287q.125 0 .263.037t.262.113l8.15 5.175q.225.15.338.375t.112.475t-.112.475t-.338.375l-8.15 5.175q-.125.075-.262.113T9 18.175q-.4 0-.7-.288t-.3-.712"})})})]});if(w)/* @__PURE__ */return s("button",{className:"h-full w-full",onClick:w,children:d});if(c)/* @__PURE__ */return s(r,{to:c,className:"h-full w-full",children:d});const y=h&&a(h,["http:","https:"])?h:void 0;return y?/* @__PURE__ */s("a",{href:y,className:"pswp-item block h-full w-full",...v,...n?{"data-pswp-thumbnail-url":n}:{},...u?{"data-pswp-blurhash":u}:{},target:"_blank",rel:"noreferrer",children:d}):/* @__PURE__ */s("span",{className:"pswp-item block h-full w-full",...v,...n?{"data-pswp-thumbnail-url":n}:{},...u?{"data-pswp-blurhash":u}:{},children:d})},l="__qrati_photoswipe",n=t=>Boolean(t&&"object"==typeof t&&t[l]),u=class{active=!1;closingByBackButton=!1;previousState;previousUrl="";previousBrowserState;previousBrowserUrl="";nativeHistoryActive=!1;getPhotoSwipe;routerHistory;constructor(t,s){this.getPhotoSwipe=t,this.routerHistory=s}open(){if(this.active)return;this.active=!0,this.previousState=this.routerHistory?this.routerHistory.state:window.history.state,this.previousUrl=this.routerHistory?this.routerHistory.location:window.location.href,this.previousBrowserState=window.history.state,this.previousBrowserUrl=window.location.href;const t=this.previousState&&"object"==typeof this.previousState?{...this.previousState,[l]:!0}:{[l]:!0};this.routerHistory?(this.routerHistory.push(this.previousUrl,t),window.history.pushState({...this.previousBrowserState??{},[l]:!0},document.title,this.previousBrowserUrl),this.nativeHistoryActive=!0,window.addEventListener("popstate",this.handlePopState)):(window.history.pushState(t,document.title,this.previousUrl),this.nativeHistoryActive=!0,window.addEventListener("popstate",this.handlePopState))}close(){if(!this.active)return;const t=this.closingByBackButton;this.cleanup(),t?this.routerHistory&&this.routerHistory.go(-1):this.routerHistory?(this.routerHistory.go(-1),this.nativeHistoryActive&&window.history.back()):window.history.back()}destroy(){this.active&&(this.routerHistory&&n(this.routerHistory.state)?this.routerHistory.replace(this.previousUrl,this.previousState):!this.routerHistory&&n(window.history.state)&&window.history.replaceState(this.previousState,document.title,this.previousUrl),this.nativeHistoryActive&&n(window.history.state)&&window.history.replaceState(this.previousBrowserState,document.title,this.previousBrowserUrl)),this.cleanup()}isActive(){return this.active}handleBack(){this.active&&(this.closingByBackButton=!0,this.getPhotoSwipe()?.close?.())}handlePopState=()=>{this.active&&this.handleBack()};cleanup(){this.active=!1,this.closingByBackButton=!1,this.previousState=void 0,this.previousUrl="",window.removeEventListener("popstate",this.handlePopState)}};export{n,h as r,u as t};
1
+ import{p as t,t as s,w as e}from"./BXMw4kNf.js";import{c as i}from"./Bb9ydqSB.js";import{t as r}from"./Z3MoLpu5.js";import{t as o}from"./BWKUiudT.js";import{t as a}from"./Bki5T_lb.js";var h=({url:h,alt:l="",thumbnailUrl:n,blurhash:u,pswpData:p={},curateLink:c,onClick:w})=>{const v=t(()=>(t=>Object.keys(t).reduce((s,e)=>{const i=t[e];return null==i||""===i||(s[`data-pswp-${r=e,r.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}`]=i),s;var r},{}))(p),[p]),d=/* @__PURE__ */s(e,{children:[/* @__PURE__ */s(o,{threshold:.1,src:n||h,blurhash:u,alt:l}),p.type===i.VIDEO&&/* @__PURE__ */s("div",{className:"absolute inset-0 top-0 left-0 flex items-center justify-center opacity-75",children:/* @__PURE__ */s("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-16 text-white lg:w-24",viewBox:"0 0 24 24",children:/* @__PURE__ */s("path",{fill:"currentColor",d:"M8 17.175V6.825q0-.425.3-.713t.7-.287q.125 0 .263.037t.262.113l8.15 5.175q.225.15.338.375t.112.475t-.112.475t-.338.375l-8.15 5.175q-.125.075-.262.113T9 18.175q-.4 0-.7-.288t-.3-.712"})})})]});if(w)/* @__PURE__ */return s("button",{className:"h-full w-full",onClick:w,children:d});if(c)/* @__PURE__ */return s(r,{to:c,className:"h-full w-full",children:d});const y=h&&a(h,["http:","https:"])?h:void 0;return y?/* @__PURE__ */s("a",{href:y,className:"pswp-item block h-full w-full",...v,...n?{"data-pswp-thumbnail-url":n}:{},...u?{"data-pswp-blurhash":u}:{},target:"_blank",rel:"noreferrer",children:d}):/* @__PURE__ */s("span",{className:"pswp-item block h-full w-full",...v,...n?{"data-pswp-thumbnail-url":n}:{},...u?{"data-pswp-blurhash":u}:{},children:d})},l="__qrati_photoswipe",n=t=>Boolean(t&&"object"==typeof t&&t[l]),u=class{active=!1;closingByBackButton=!1;previousState;previousUrl="";previousBrowserState;previousBrowserUrl="";nativeHistoryActive=!1;getPhotoSwipe;routerHistory;constructor(t,s){this.getPhotoSwipe=t,this.routerHistory=s}open(){if(this.active)return;this.active=!0,this.previousState=this.routerHistory?this.routerHistory.state:window.history.state,this.previousUrl=this.routerHistory?this.routerHistory.location:window.location.href,this.previousBrowserState=window.history.state,this.previousBrowserUrl=window.location.href;const t=this.previousState&&"object"==typeof this.previousState?{...this.previousState,[l]:!0}:{[l]:!0};this.routerHistory?(this.routerHistory.push(this.previousUrl,t),window.history.pushState({...this.previousBrowserState??{},[l]:!0},document.title,this.previousBrowserUrl),this.nativeHistoryActive=!0,window.addEventListener("popstate",this.handlePopState)):(window.history.pushState(t,document.title,this.previousUrl),this.nativeHistoryActive=!0,window.addEventListener("popstate",this.handlePopState))}close(){if(!this.active)return;const t=this.closingByBackButton;this.cleanup(),t?this.routerHistory&&this.routerHistory.go(-1):this.routerHistory?(this.routerHistory.go(-1),this.nativeHistoryActive&&window.history.back()):window.history.back()}destroy(){this.active&&(this.routerHistory&&n(this.routerHistory.state)?this.routerHistory.replace(this.previousUrl,this.previousState):!this.routerHistory&&n(window.history.state)&&window.history.replaceState(this.previousState,document.title,this.previousUrl),this.nativeHistoryActive&&n(window.history.state)&&window.history.replaceState(this.previousBrowserState,document.title,this.previousBrowserUrl)),this.cleanup()}isActive(){return this.active}handleBack(){this.active&&(this.closingByBackButton=!0,this.getPhotoSwipe()?.close?.())}handlePopState=()=>{this.active&&this.handleBack()};cleanup(){this.active=!1,this.closingByBackButton=!1,this.previousState=void 0,this.previousUrl="",window.removeEventListener("popstate",this.handlePopState)}};export{n,h as r,u as t};
@@ -1,4 +1,4 @@
1
- import{d as e,s as r,t,v as o}from"./BXMw4kNf.js";import{n as s}from"./CdivXyOP.js";import{x as l}from"./Bb9ydqSB.js";import{u as i}from"./BK_hWmGs.js";import"./BVxovwox.js";var n=e(()=>import("./BgZyx8Pz.js")),a=e(()=>import("./Clga4U4Y.js")),c=e(()=>import("./Cnr4EYcL.js")),p=e(()=>import("./e2mrPlw-.js")),d=()=>/* @__PURE__ */t("div",{class:"flex h-full items-center justify-center",children:/* @__PURE__ */t("div",{class:"text-center",children:[
1
+ import{d as e,s as r,t,v as o}from"./BXMw4kNf.js";import{n as s}from"./Dpwx5KMy.js";import{x as l}from"./Bb9ydqSB.js";import{u as i}from"./Z3MoLpu5.js";import"./CQJ3AK1w.js";var n=e(()=>import("./BpAijsfn.js")),a=e(()=>import("./Bc-phiG6.js")),c=e(()=>import("./erXAfWWY.js")),p=e(()=>import("./ASQv5Ahv.js")),d=()=>/* @__PURE__ */t("div",{class:"flex h-full items-center justify-center",children:/* @__PURE__ */t("div",{class:"text-center",children:[
2
2
  /* @__PURE__ */t("svg",{xmlns:"http://www.w3.org/2000/svg",class:"text-muted-foreground mx-auto mb-3 size-10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5",children:[/* @__PURE__ */t("path",{d:"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7z"}),/* @__PURE__ */t("circle",{cx:"12",cy:"9",r:"2.5"})]}),
3
3
  /* @__PURE__ */t("p",{class:"text-foreground",children:"No location data available."}),
4
4
  /* @__PURE__ */t("p",{class:"text-muted-foreground mt-1 text-xs",children:"Events need location data to appear on the map."})]})}),m=()=>/* @__PURE__ */t("div",{class:"flex h-full items-center justify-center",children:/* @__PURE__ */t("div",{class:"border-primary size-8 animate-spin rounded-full border-4 border-t-transparent"})}),g=({events:e,isLoading:g=!1})=>{const{organization:x}=s(),f=i(),u=x?.integrationSettings??{},h=u.mapProvider??"openstreetmap",v=o(e=>{f(l.GALLERY(e))},[f]);if("openstreetmap_free"===h)/* @__PURE__ */return t("div",{class:"relative mt-3 h-screen sm:mt-6",children:/* @__PURE__ */t(r,{fallback:/* @__PURE__ */t(m,{}),children:/* @__PURE__ */t(n,{onExplore:v,logoUrl:x?.logoUrl})})});const y=u.mapTilerApiKey??"",b=u.googleMapsApiKey??"",j=u.mapboxApiKey??"",w=e.filter(e=>"number"==typeof e.location?.x&&"number"==typeof e.location?.y);/* @__PURE__ */
@@ -1,4 +1,4 @@
1
- import{h as a,t as s}from"./BXMw4kNf.js";import{n as o}from"./CdivXyOP.js";import{x as e}from"./Bb9ydqSB.js";import{l as r,t as l}from"./BK_hWmGs.js";import{t as i}from"./cBUXG_uS.js";import{n as t}from"./JY9kGm742.js";import{t as n}from"./DKxH7j1t2.js";import{a as d,i as m,o as p,r as w,s as c,t as g}from"./CQMPBmQq2.js";import{n as h,r as f,t as u}from"./D2-DJv4T2.js";var C=()=>{const{t:C}=t(),[b,v]=a(""),[P,y]=a(""),[N,j]=a(""),[x,A]=a(""),[k,S]=a(""),[z,F]=a(null),[L,E]=a({}),[O,R]=a(!1),[W,D]=a({google:!1,apple:!1}),[G,H]=a({showPassword:!1,showConfirmPassword:!1}),I=r(),{registerUsingEmail:U,loginWithGoogle:Q,loginWithApple:T}=o(),V=a=>{E(s=>s[a]?{...s,[a]:void 0}:s)},Y=async(a,s)=>{D(s=>({...s,[a]:!0})),F(null);try{await(s?.())}catch(o){o instanceof Error?F(o.message):F(`Failed to sign up with ${a.charAt(0).toUpperCase()+a.slice(1)}`)}finally{D(s=>({...s,[a]:!1}))}};/* @__PURE__ */
1
+ import{h as a,t as s}from"./BXMw4kNf.js";import{n as o}from"./Dpwx5KMy.js";import{x as e}from"./Bb9ydqSB.js";import{l as r,t as l}from"./Z3MoLpu5.js";import{t as i}from"./BszsxRY6.js";import{n as t}from"./JY9kGm742.js";import{t as n}from"./BWjYmdOz2.js";import{a as d,i as m,o as p,r as w,s as c,t as g}from"./B_SYJsyF2.js";import{n as h,r as f,t as u}from"./D2-DJv4T2.js";var C=()=>{const{t:C}=t(),[b,v]=a(""),[P,y]=a(""),[N,j]=a(""),[x,A]=a(""),[k,S]=a(""),[z,F]=a(null),[L,E]=a({}),[O,R]=a(!1),[W,D]=a({google:!1,apple:!1}),[G,H]=a({showPassword:!1,showConfirmPassword:!1}),I=r(),{registerUsingEmail:U,loginWithGoogle:Q,loginWithApple:T}=o(),V=a=>{E(s=>s[a]?{...s,[a]:void 0}:s)},Y=async(a,s)=>{D(s=>({...s,[a]:!0})),F(null);try{await(s?.())}catch(o){o instanceof Error?F(o.message):F(`Failed to sign up with ${a.charAt(0).toUpperCase()+a.slice(1)}`)}finally{D(s=>({...s,[a]:!1}))}};/* @__PURE__ */
2
2
  return s("div",{className:"bg-background w-full space-y-8",children:[/* @__PURE__ */s("form",{noValidate:!0,onSubmit:async a=>{a.preventDefault();const s=d(b),o=p(P),e=m(N),r=c(x),l=w(k,x);if(s||o||e||r||l)return void E({fname:s,lname:o,email:e,password:r,confirmPassword:l});E({}),R(!0),F(null);const i=await(U?.(N.toLowerCase(),x,b,P));i?.error&&F(i.error),R(!1)},className:"space-y-4",children:[
3
3
  /* @__PURE__ */s("div",{className:"grid grid-cols-2 gap-4",children:[/* @__PURE__ */s(g,{label:C("auth.firstName","First name"),name:"fname",disabled:O,type:"text",value:b,onChange:a=>{v(a.target.value),V("fname")},error:L.fname}),/* @__PURE__ */s(g,{label:C("auth.lastName","Last name"),name:"lname",disabled:O,type:"text",value:P,onChange:a=>{y(a.target.value),V("lname")},error:L.lname})]}),
4
4
  /* @__PURE__ */s(g,{label:C("auth.email","Email address"),name:"email",disabled:O,type:"email",value:N,onChange:a=>{j(a.target.value),V("email")},autoComplete:"email",error:L.email}),
@@ -1,4 +1,4 @@
1
- import{h as e,p as a,t as r}from"./BXMw4kNf.js";import{n as s}from"./CdivXyOP.js";import{x as i}from"./Bb9ydqSB.js";import{u as t}from"./BK_hWmGs.js";import{t as o}from"./cBUXG_uS.js";import{n as l}from"./JY9kGm742.js";import{t as n}from"./DKxH7j1t2.js";import{i as d,s as c,t as u}from"./CQMPBmQq2.js";var m=({count:e=1,currentStep:a=0,disabled:s,onStepClick:i})=>{const t=s||!i;/* @__PURE__ */
1
+ import{h as e,p as a,t as r}from"./BXMw4kNf.js";import{n as s}from"./Dpwx5KMy.js";import{x as i}from"./Bb9ydqSB.js";import{u as t}from"./Z3MoLpu5.js";import{t as o}from"./BszsxRY6.js";import{n as l}from"./JY9kGm742.js";import{t as n}from"./BWjYmdOz2.js";import{i as d,s as c,t as u}from"./B_SYJsyF2.js";var m=({count:e=1,currentStep:a=0,disabled:s,onStepClick:i})=>{const t=s||!i;/* @__PURE__ */
2
2
  return r("ol",{className:"flex items-center space-x-6 pl-1.5",children:Array.from({length:e}).map((e,s)=>/* @__PURE__ */r("li",{children:/* @__PURE__ */r("button",s<a?{type:"button","aria-label":`Go to step ${s+1}`,className:"bg-primary block h-3 w-3 rounded-full",disabled:t,onClick:()=>i?.(s)}:s===a?{type:"button","aria-label":`Current step ${s+1}`,className:"relative flex items-center justify-center","aria-current":"step",disabled:t,onClick:()=>i?.(s),children:[/* @__PURE__ */r("span",{className:"absolute flex size-6 p-px","aria-hidden":"true",children:/* @__PURE__ */r("span",{className:"bg-primary/40 size-full rounded-full"})}),/* @__PURE__ */r("span",{className:"bg-primary relative block size-3 rounded-full","aria-hidden":"true"})]}:{type:"button","aria-label":`Go to step ${s+1}`,className:"bg-muted block size-3 rounded-full",disabled:t,onClick:()=>i?.(s)})},`progress-dot-${s}`))})},h=({onCodeSent:a})=>{const{t:i}=l(),{sendPasswordResetCode:t}=s(),[c,m]=e(""),[h,p]=e(!1),[f,y]=e(null),[w,v]=e(null);/* @__PURE__ */
3
3
  return r("div",{className:"space-y-4",children:[
4
4
  /* @__PURE__ */r(o,{variant:"h4",children:i("auth.forgotPassword","Forgot Password")}),
@@ -1 +1 @@
1
- import{_ as t,b as e,v as s}from"./CdivXyOP.js";var i=class extends t{#t;#e;#s;#i;constructor(t){super(),this.#t=t.client,this.mutationId=t.mutationId,this.#s=t.mutationCache,this.#e=[],this.state=t.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#e.includes(t)||(this.#e.push(t),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#e=this.#e.filter(e=>e!==t),this.scheduleGc(),this.#s.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#e.length||("pending"===this.state.status?this.scheduleGc():this.#s.remove(this))}continue(){return this.#i?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#a({type:"continue"})},i={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=s({fn:()=>this.options.mutationFn?this.options.mutationFn(t,i):Promise.reject(/* @__PURE__ */new Error("No mutationFn found")),onFail:(t,e)=>{this.#a({type:"failed",failureCount:t,error:e})},onPause:()=>{this.#a({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#s.canRun(this)});const a="pending"===this.state.status,o=!this.#i.canStart();try{if(a)e();else{this.#a({type:"pending",variables:t,isPaused:o}),this.#s.config.onMutate&&await this.#s.config.onMutate(t,this,i);const e=await(this.options.onMutate?.(t,i));e!==this.state.context&&this.#a({type:"pending",context:e,variables:t,isPaused:o})}const s=await this.#i.start();return await(this.#s.config.onSuccess?.(s,t,this.state.context,this,i)),await(this.options.onSuccess?.(s,t,this.state.context,i)),await(this.#s.config.onSettled?.(s,null,this.state.variables,this.state.context,this,i)),await(this.options.onSettled?.(s,null,t,this.state.context,i)),this.#a({type:"success",data:s}),s}catch(r){try{await(this.#s.config.onError?.(r,t,this.state.context,this,i))}catch(n){Promise.reject(n)}try{await(this.options.onError?.(r,t,this.state.context,i))}catch(n){Promise.reject(n)}try{await(this.#s.config.onSettled?.(void 0,r,this.state.variables,this.state.context,this,i))}catch(n){Promise.reject(n)}try{await(this.options.onSettled?.(void 0,r,t,this.state.context,i))}catch(n){Promise.reject(n)}throw this.#a({type:"error",error:r}),r}finally{this.#s.runNext(this)}}#a(t){this.state=(e=>{switch(t.type){case"failed":return{...e,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...e,isPaused:!0};case"continue":return{...e,isPaused:!1};case"pending":return{...e,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...e,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...e,data:void 0,error:t.error,failureCount:e.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}})(this.state),e.batch(()=>{this.#e.forEach(e=>{e.onMutationUpdate(t)}),this.#s.notify({mutation:this,type:"updated",action:t})})}};function a(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}export{a as n,i as t};
1
+ import{_ as t,b as e,v as s}from"./Dpwx5KMy.js";var i=class extends t{#t;#e;#s;#i;constructor(t){super(),this.#t=t.client,this.mutationId=t.mutationId,this.#s=t.mutationCache,this.#e=[],this.state=t.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#e.includes(t)||(this.#e.push(t),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#e=this.#e.filter(e=>e!==t),this.scheduleGc(),this.#s.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#e.length||("pending"===this.state.status?this.scheduleGc():this.#s.remove(this))}continue(){return this.#i?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#a({type:"continue"})},i={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=s({fn:()=>this.options.mutationFn?this.options.mutationFn(t,i):Promise.reject(/* @__PURE__ */new Error("No mutationFn found")),onFail:(t,e)=>{this.#a({type:"failed",failureCount:t,error:e})},onPause:()=>{this.#a({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#s.canRun(this)});const a="pending"===this.state.status,o=!this.#i.canStart();try{if(a)e();else{this.#a({type:"pending",variables:t,isPaused:o}),this.#s.config.onMutate&&await this.#s.config.onMutate(t,this,i);const e=await(this.options.onMutate?.(t,i));e!==this.state.context&&this.#a({type:"pending",context:e,variables:t,isPaused:o})}const s=await this.#i.start();return await(this.#s.config.onSuccess?.(s,t,this.state.context,this,i)),await(this.options.onSuccess?.(s,t,this.state.context,i)),await(this.#s.config.onSettled?.(s,null,this.state.variables,this.state.context,this,i)),await(this.options.onSettled?.(s,null,t,this.state.context,i)),this.#a({type:"success",data:s}),s}catch(r){try{await(this.#s.config.onError?.(r,t,this.state.context,this,i))}catch(n){Promise.reject(n)}try{await(this.options.onError?.(r,t,this.state.context,i))}catch(n){Promise.reject(n)}try{await(this.#s.config.onSettled?.(void 0,r,this.state.variables,this.state.context,this,i))}catch(n){Promise.reject(n)}try{await(this.options.onSettled?.(void 0,r,t,this.state.context,i))}catch(n){Promise.reject(n)}throw this.#a({type:"error",error:r}),r}finally{this.#s.runNext(this)}}#a(t){this.state=(e=>{switch(t.type){case"failed":return{...e,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...e,isPaused:!0};case"continue":return{...e,isPaused:!1};case"pending":return{...e,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...e,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...e,data:void 0,error:t.error,failureCount:e.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}})(this.state),e.batch(()=>{this.#e.forEach(e=>{e.onMutationUpdate(t)}),this.#s.notify({mutation:this,type:"updated",action:t})})}};function a(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}export{a as n,i as t};
@@ -1,4 +1,4 @@
1
- import{E as e,_ as t,h as r,p as n,r as i,s,t as o,v as a,y as c}from"./BXMw4kNf.js";import{n as l,t as u}from"./DmpmrPE5.js";import{S as h,h as d,i as f}from"./Bb9ydqSB.js";var p=class{constructor(){this.listeners=/* @__PURE__ */new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},m=new class extends p{#e;#t;#r;constructor(){super(),this.#r=e=>{if("undefined"!=typeof window&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return"boolean"==typeof this.#e?this.#e:"hidden"!==globalThis.document?.visibilityState}},g={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},y=new class{#n=g;#i=!1;setTimeoutProvider(e){this.#n=e}setTimeout(e,t){return this.#n.setTimeout(e,t)}clearTimeout(e){this.#n.clearTimeout(e)}setInterval(e,t){return this.#n.setInterval(e,t)}clearInterval(e){this.#n.clearInterval(e)}},v="undefined"==typeof window||"Deno"in globalThis;function w(){}function b(e,t){return"function"==typeof e?e(t):e}function S(e){return"number"==typeof e&&e>=0&&e!==1/0}function R(e,t){return Math.max(e+(t||0)-Date.now(),0)}function I(e,t){return"function"==typeof e?e(t):e}function O(e,t){return"function"==typeof e?e(t):e}function T(e,t){const{type:r="all",exact:n,fetchStatus:i,predicate:s,queryKey:o,stale:a}=e;if(o)if(n){if(t.queryHash!==E(o,t.options))return!1}else if(!A(t.queryKey,o))return!1;if("all"!==r){const e=t.isActive();if("active"===r&&!e)return!1;if("inactive"===r&&e)return!1}return!("boolean"==typeof a&&t.isStale()!==a||i&&i!==t.state.fetchStatus||s&&!s(t))}function C(e,t){const{exact:r,status:n,predicate:i,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(r){if(k(t.options.mutationKey)!==k(s))return!1}else if(!A(t.options.mutationKey,s))return!1}return!(n&&t.state.status!==n||i&&!i(t))}function E(e,t){return(t?.queryKeyHashFn||k)(e)}function k(e){return JSON.stringify(e,(e,t)=>M(t)?Object.keys(t).sort().reduce((e,r)=>(e[r]=t[r],e),{}):t)}function A(e,t){return e===t||typeof e==typeof t&&!(!e||!t||"object"!=typeof e||"object"!=typeof t)&&Object.keys(t).every(r=>A(e[r],t[r]))}var x=Object.prototype.hasOwnProperty;function F(e,t,r=0){if(e===t)return e;if(r>500)return t;const n=D(e)&&D(t);if(!(n||M(e)&&M(t)))return t;const i=(n?e:Object.keys(e)).length,s=n?t:Object.keys(t),o=s.length,a=n?new Array(o):{};let c=0;for(let l=0;l<o;l++){const o=n?l:s[l],u=e[o],h=t[o];if(u===h){a[o]=u,(n?l<i:x.call(e,o))&&c++;continue}if(null===u||null===h||"object"!=typeof u||"object"!=typeof h){a[o]=h;continue}const d=F(u,h,r+1);a[o]=d,d===u&&c++}return i===o&&c===i?e:a}function P(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function D(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function M(e){if(!q(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!!q(r)&&!!r.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype}function q(e){return"[object Object]"===Object.prototype.toString.call(e)}function U(e,t,r){return"function"==typeof r.structuralSharing?r.structuralSharing(e,t):!1!==r.structuralSharing?F(e,t):t}function Q(e,t,r=0){const n=[...e,t];return r&&n.length>r?n.slice(1):n}function L(e,t,r=0){const n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var j=/* @__PURE__ */Symbol();function _(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:e.queryFn&&e.queryFn!==j?e.queryFn:()=>Promise.reject(/* @__PURE__ */new Error(`Missing queryFn: '${e.queryHash}'`))}function z(e,t){return"function"==typeof e?e(...t):!!e}var N=/* @__PURE__ */(()=>{let e=()=>v;return{isServer:()=>e(),setIsServer(t){e=t}}})();function $(){let e,t;const r=new Promise((r,n)=>{e=r,t=n});function n(e){Object.assign(r,e),delete r.resolve,delete r.reject}return r.status="pending",r.catch(()=>{}),r.resolve=t=>{n({status:"fulfilled",value:t}),e(t)},r.reject=e=>{n({status:"rejected",reason:e}),t(e)},r}var H=function(e){setTimeout(e,0)},V=function(){let e=[],t=0,r=e=>{e()},n=e=>{e()},i=H;const s=n=>{t?e.push(n):i(()=>{r(n)})};return{batch:s=>{let o;t++;try{o=s()}finally{t--,t||(()=>{const t=e;e=[],t.length&&i(()=>{n(()=>{t.forEach(e=>{r(e)})})})})()}return o},batchCalls:e=>(...t)=>{s(()=>{e(...t)})},schedule:s,setNotifyFunction:e=>{r=e},setBatchNotifyFunction:e=>{n=e},setScheduler:e=>{i=e}}}(),W=new class extends p{#s=!0;#t;#r;constructor(){super(),this.#r=e=>{if("undefined"!=typeof window&&window.addEventListener){const t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#s!==e&&(this.#s=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#s}};function G(e){return Math.min(1e3*2**e,3e4)}function Z(e){return"online"!==(e??"online")||W.isOnline()}var K=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function B(e){let t,r=!1,n=0;const i=$(),s=()=>"pending"!==i.status,o=()=>m.isFocused()&&("always"===e.networkMode||W.isOnline())&&e.canRun(),a=()=>Z(e.networkMode)&&e.canRun(),c=e=>{s()||(t?.(),i.resolve(e))},l=e=>{s()||(t?.(),i.reject(e))},u=()=>new Promise(r=>{t=e=>{(s()||o())&&r(e)},e.onPause?.()}).then(()=>{t=void 0,s()||e.onContinue?.()}),h=()=>{if(s())return;let t;const i=0===n?e.initialPromise:void 0;try{t=i??e.fn()}catch(a){t=Promise.reject(a)}Promise.resolve(t).then(c).catch(t=>{if(s())return;const i=e.retry??(N.isServer()?0:3),a=e.retryDelay??G,c="function"==typeof a?a(n,t):a,d=!0===i||"number"==typeof i&&n<i||"function"==typeof i&&i(n,t);var f;!r&&d?(n++,e.onFail?.(n,t),(f=c,new Promise(e=>{y.setTimeout(e,f)})).then(()=>o()?void 0:u()).then(()=>{r?l(t):h()})):l(t)})};return{promise:i,status:()=>i.status,cancel:t=>{if(!s()){const r=new K(t);l(r),e.onCancel?.(r)}},continue:()=>(t?.(),i),cancelRetry:()=>{r=!0},continueRetry:()=>{r=!1},canStart:a,start:()=>(a()?h():u().then(h),i)}}var J=class{#o;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),S(this.gcTime)&&(this.#o=y.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(N.isServer()?1/0:3e5))}clearGcTimeout(){void 0!==this.#o&&(y.clearTimeout(this.#o),this.#o=void 0)}};function Y(e){return{onFetch:(t,r)=>{const n=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,s=t.state.data?.pages||[],o=t.state.data?.pageParams||[];let a={pages:[],pageParams:[]},c=0;const l=async()=>{let r=!1;const l=e=>{!function(e,r,n){let i,s=!1;Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t.signal,s||(s=!0,i.aborted?n():i.addEventListener("abort",n,{once:!0})),i)})}(e,0,()=>r=!0)},u=_(t.options,t.fetchOptions),h=async(e,n,i)=>{if(r)return Promise.reject(t.signal.reason);if(null==n&&e.pages.length)return Promise.resolve(e);const s=(()=>{const e={client:t.client,queryKey:t.queryKey,pageParam:n,direction:i?"backward":"forward",meta:t.options.meta};return l(e),e})(),o=await u(s),{maxPages:a}=t.options,c=i?L:Q;return{pages:c(e.pages,o,a),pageParams:c(e.pageParams,n,a)}};if(i&&s.length){const e="backward"===i,t=e?ee:X,r={pages:s,pageParams:o};a=await h(r,t(n,r),e)}else{const t=e??s.length;do{const e=0===c?o[0]??n.initialPageParam:X(n,a);if(c>0&&null==e)break;a=await h(a,e),c++}while(c<t)}return a};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=l}}}function X(e,{pages:t,pageParams:r}){const n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function ee(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}function te(e,t){return!!t&&null!=X(e,t)}function re(e,t){return!(!t||!e.getPreviousPageParam)&&null!=ee(e,t)}var ne=class extends J{#a;#c;#l;#u;#h;#d;#f;#p;constructor(e){super(),this.#p=!1,this.#f=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#h=e.client,this.#u=this.#h.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#c=oe(this.options),this.state=e.state??this.#c,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#a}get promise(){return this.#d?.promise}setOptions(e){if(this.options={...this.#f,...e},e?._type&&(this.#a=e._type),this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){const e=oe(this.options);void 0!==e.data&&(this.setState(se(e.data,e.dataUpdatedAt)),this.#c=e)}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#u.remove(this)}setData(e,t){const r=U(this.state.data,e,this.options);return this.#m({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e){this.#m({type:"setState",state:e})}cancel(e){const t=this.#d?.promise;return this.#d?.cancel(e),t?t.then(w).catch(w):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#c}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>!1!==O(e.options.enabled,this))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===j||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>"static"===I(e.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(e=0){return void 0===this.state.data||"static"!==e&&(!!this.state.isInvalidated||!R(this.state.dataUpdatedAt,e))}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#d?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#d?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#u.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#d&&(this.#p||this.#g()?this.#d.cancel({revert:!0}):this.#d.cancelRetry()),this.scheduleGc()),this.#u.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#g(){return"paused"===this.state.fetchStatus&&"pending"===this.state.status}invalidate(){this.state.isInvalidated||this.#m({type:"invalidate"})}async fetch(e,t){if("idle"!==this.state.fetchStatus&&"rejected"!==this.#d?.status())if(void 0!==this.state.data&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#d)return this.#d.continueRetry(),this.#d.promise;if(e&&this.setOptions(e),!this.options.queryFn){const e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}const r=new AbortController,n=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#p=!0,r.signal)})},i=()=>{const e=_(this.options,t),r=(()=>{const e={client:this.#h,queryKey:this.queryKey,meta:this.meta};return n(e),e})();return this.#p=!1,this.options.persister?this.options.persister(e,r,this):e(r)},s=(()=>{const e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#h,state:this.state,fetchFn:i};return n(e),e})();("infinite"===this.#a?Y(this.options.pages):this.options.behavior)?.onFetch(s,this),this.#l=this.state,"idle"!==this.state.fetchStatus&&this.state.fetchMeta===s.fetchOptions?.meta||this.#m({type:"fetch",meta:s.fetchOptions?.meta}),this.#d=B({initialPromise:t?.initialPromise,fn:s.fetchFn,onCancel:e=>{e instanceof K&&e.revert&&this.setState({...this.#l,fetchStatus:"idle"}),r.abort()},onFail:(e,t)=>{this.#m({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#m({type:"pause"})},onContinue:()=>{this.#m({type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0});try{const e=await this.#d.start();if(void 0===e)throw new Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#u.config.onSuccess?.(e,this),this.#u.config.onSettled?.(e,this.state.error,this),e}catch(o){if(o instanceof K){if(o.silent)return this.#d.promise;if(o.revert){if(void 0===this.state.data)throw o;return this.state.data}}throw this.#m({type:"error",error:o}),this.#u.config.onError?.(o,this),this.#u.config.onSettled?.(this.state.data,o,this),o}finally{this.scheduleGc()}}#m(e){this.state=(t=>{switch(e.type){case"failed":return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":return{...t,...ie(t.data,this.options),fetchMeta:e.meta??null};case"success":const r={...t,...se(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#l=e.manual?r:void 0,r;case"error":const n=e.error;return{...t,error:n,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}})(this.state),V.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#u.notify({query:this,type:"updated",action:e})})}};function ie(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Z(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}function se(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function oe(e){const t="function"==typeof e.initialData?e.initialData():e.initialData,r=void 0!==t,n=r?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var ae=class extends p{constructor(e,t){super(),this.options=t,this.#h=e,this.#y=null,this.#v=$(),this.bindMethods(),this.setOptions(t)}#h;#w=void 0;#b=void 0;#S=void 0;#R;#I;#v;#y;#O;#T;#C;#E;#k;#A;#x=/* @__PURE__ */new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#w.addObserver(this),ce(this.#w,this.options)?this.#F():this.updateResult(),this.#P())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return le(this.#w,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return le(this.#w,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=/* @__PURE__ */new Set,this.#D(),this.#M(),this.#w.removeObserver(this)}setOptions(e){const t=this.options,r=this.#w;if(this.options=this.#h.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof O(this.options.enabled,this.#w))throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#q(),this.#w.setOptions(this.options),t._defaulted&&!P(this.options,t)&&this.#h.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#w,observer:this});const n=this.hasListeners();n&&ue(this.#w,r,this.options,t)&&this.#F(),this.updateResult(),!n||this.#w===r&&O(this.options.enabled,this.#w)===O(t.enabled,this.#w)&&I(this.options.staleTime,this.#w)===I(t.staleTime,this.#w)||this.#U();const i=this.#Q();!n||this.#w===r&&O(this.options.enabled,this.#w)===O(t.enabled,this.#w)&&i===this.#A||this.#L(i)}getOptimisticResult(e){const t=this.#h.getQueryCache().build(this.#h,e),r=this.createResult(t,e);var n;return n=r,P(this.getCurrentResult(),n)||(this.#S=r,this.#I=this.options,this.#R=this.#w.state),r}getCurrentResult(){return this.#S}trackResult(e,t){return new Proxy(e,{get:(e,r)=>(this.trackProp(r),t?.(r),"promise"===r&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==this.#v.status||this.#v.reject(/* @__PURE__ */new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,r))})}trackProp(e){this.#x.add(e)}getCurrentQuery(){return this.#w}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#h.defaultQueryOptions(e),r=this.#h.getQueryCache().build(this.#h,t);return r.fetch().then(()=>this.createResult(r,t))}fetch(e){return this.#F({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#S))}#F(e){this.#q();let t=this.#w.fetch(this.options,e);return e?.throwOnError||(t=t.catch(w)),t}#U(){this.#D();const e=I(this.options.staleTime,this.#w);if(N.isServer()||this.#S.isStale||!S(e))return;const t=R(this.#S.dataUpdatedAt,e)+1;this.#E=y.setTimeout(()=>{this.#S.isStale||this.updateResult()},t)}#Q(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#w):this.options.refetchInterval)??!1}#L(e){this.#M(),this.#A=e,!N.isServer()&&!1!==O(this.options.enabled,this.#w)&&S(this.#A)&&0!==this.#A&&(this.#k=y.setInterval(()=>{(this.options.refetchIntervalInBackground||m.isFocused())&&this.#F()},this.#A))}#P(){this.#U(),this.#L(this.#Q())}#D(){void 0!==this.#E&&(y.clearTimeout(this.#E),this.#E=void 0)}#M(){void 0!==this.#k&&(y.clearInterval(this.#k),this.#k=void 0)}createResult(e,t){const r=this.#w,n=this.options,i=this.#S,s=this.#R,o=this.#I,a=e!==r?e.state:this.#b,{state:c}=e;let l,u={...c},h=!1;if(t._optimisticResults){const i=this.hasListeners(),s=!i&&ce(e,t),o=i&&ue(e,r,t,n);(s||o)&&(u={...u,...ie(c.data,e.options)}),"isRestoring"===t._optimisticResults&&(u.fetchStatus="idle")}let{error:d,errorUpdatedAt:f,status:p}=u;l=u.data;let m=!1;if(void 0!==t.placeholderData&&void 0===l&&"pending"===p){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,m=!0):e="function"==typeof t.placeholderData?t.placeholderData(this.#C?.state.data,this.#C):t.placeholderData,void 0!==e&&(p="success",l=U(i?.data,e,t),h=!0)}if(t.select&&void 0!==l&&!m)if(i&&l===s?.data&&t.select===this.#O)l=this.#T;else try{this.#O=t.select,l=t.select(l),l=U(i?.data,l,t),this.#T=l,this.#y=null}catch(R){this.#y=R}this.#y&&(d=this.#y,l=this.#T,f=Date.now(),p="error");const g="fetching"===u.fetchStatus,y="pending"===p,v="error"===p,w=y&&g,b=void 0!==l,S={status:p,fetchStatus:u.fetchStatus,isPending:y,isSuccess:"success"===p,isError:v,isInitialLoading:w,isLoading:w,data:l,dataUpdatedAt:u.dataUpdatedAt,error:d,errorUpdatedAt:f,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:u.dataUpdateCount>a.dataUpdateCount||u.errorUpdateCount>a.errorUpdateCount,isFetching:g,isRefetching:g&&!y,isLoadingError:v&&!b,isPaused:"paused"===u.fetchStatus,isPlaceholderData:h,isRefetchError:v&&b,isStale:he(e,t),refetch:this.refetch,promise:this.#v,isEnabled:!1!==O(t.enabled,e)};if(this.options.experimental_prefetchInRender){const t=void 0!==S.data,n="error"===S.status&&!t,i=e=>{n?e.reject(S.error):t&&e.resolve(S.data)},s=()=>{const e=this.#v=S.promise=$();i(e)},o=this.#v;switch(o.status){case"pending":e.queryHash===r.queryHash&&i(o);break;case"fulfilled":(n||S.data!==o.value)&&s();break;case"rejected":n&&S.error===o.reason||s()}}return S}updateResult(){const e=this.#S,t=this.createResult(this.#w,this.options);this.#R=this.#w.state,this.#I=this.options,void 0!==this.#R.data&&(this.#C=this.#w),P(t,e)||(this.#S=t,this.#j({listeners:(()=>{if(!e)return!0;const{notifyOnChangeProps:t}=this.options,r="function"==typeof t?t():t;if("all"===r||!r&&!this.#x.size)return!0;const n=new Set(r??this.#x);return this.options.throwOnError&&n.add("error"),Object.keys(this.#S).some(t=>{const r=t;return this.#S[r]!==e[r]&&n.has(r)})})()}))}#q(){const e=this.#h.getQueryCache().build(this.#h,this.options);if(e===this.#w)return;const t=this.#w;this.#w=e,this.#b=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#P()}#j(e){V.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#S)}),this.#h.getQueryCache().notify({query:this.#w,type:"observerResultsUpdated"})})}};function ce(e,t){return function(e,t){return!1!==O(t.enabled,e)&&void 0===e.state.data&&!("error"===e.state.status&&!1===O(t.retryOnMount,e))}(e,t)||void 0!==e.state.data&&le(e,t,t.refetchOnMount)}function le(e,t,r){if(!1!==O(t.enabled,e)&&"static"!==I(t.staleTime,e)){const n="function"==typeof r?r(e):r;return"always"===n||!1!==n&&he(e,t)}return!1}function ue(e,t,r,n){return(e!==t||!1===O(n.enabled,e))&&(!r.suspense||"error"!==e.state.status)&&he(e,r)}function he(e,t){return!1!==O(t.enabled,e)&&e.isStaleByTime(I(t.staleTime,e))}var de=e(void 0),fe=e=>{const t=c(de);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},pe=({client:e,children:r})=>(t(()=>(e.mount(),()=>{e.unmount()}),[e]),/* @__PURE__ */o(de.Provider,{value:e,children:r})),me=e(!1);me.Provider;var ge=e(function(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}()),ye=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function ve(e,n,s){const o=c(me),l=c(ge),u=fe(s),h=u.defaultQueryOptions(e);u.getDefaultOptions().queries?._experimental_beforeQuery?.(h);const d=u.getQueryCache().get(h.queryHash),f=!1!==e.subscribed;h._optimisticResults=o?"isRestoring":f?"optimistic":void 0,(e=>{if(e.suspense){const t=1e3,r=e=>"static"===e?e:Math.max(e??t,t),n=e.staleTime;e.staleTime="function"==typeof n?(...e)=>r(n(...e)):r(n),"number"==typeof e.gcTime&&(e.gcTime=Math.max(e.gcTime,t))}})(h),((e,t,r)=>{const n=r?.state.error&&"function"==typeof e.throwOnError?z(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||n)&&(t.isReset()||(e.retryOnMount=!1))})(h,l,d),(e=>{t(()=>{e.clearReset()},[e])})(l);const p=!u.getQueryCache().get(h.queryHash),[m]=r(()=>new n(u,h)),g=m.getOptimisticResult(h),y=!o&&f;if(i(a(e=>{const t=y?m.subscribe(V.batchCalls(e)):w;return m.updateResult(),t},[m,y]),()=>m.getCurrentResult(),()=>m.getCurrentResult()),t(()=>{m.setOptions(h)},[h,m]),((e,t)=>e?.suspense&&t.isPending)(h,g))throw ye(h,m,l);if((({result:e,errorResetBoundary:t,throwOnError:r,query:n,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(i&&void 0===e.data||z(r,[e.error,n])))({result:g,errorResetBoundary:l,throwOnError:h.throwOnError,query:d,suspense:h.suspense}))throw g.error;return u.getDefaultOptions().queries?._experimental_afterQuery?.(h,g),h.experimental_prefetchInRender&&!N.isServer()&&((e,t)=>e.isLoading&&e.isFetching&&!t)(g,o)&&(p?ye(h,m,l):d?.promise)?.catch(w).finally(()=>{m.updateResult()}),h.notifyOnChangeProps?g:m.trackResult(g)}function we(e,t){return ve(e,ae,t)}var be=null;function Se(e){be=e}function Re(e){try{const t=JSON.stringify(e);fetch(f.REPORT_ERROR,{method:"POST",headers:{"Content-Type":"application/json",...be?{"x-org-id":be}:{}},body:t,keepalive:!0}).catch(()=>{})}catch{}}function Ie(e,t){Re({message:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0,level:t?.level??"error",component:t?.component,tags:t?.tags,context:t?.extra,url:"undefined"!=typeof window?window.location.href:void 0,userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0})}function Oe(e,t="info",r){Re({message:e,level:t,component:r?.component,tags:r?.tags,context:r?.extra,url:"undefined"!=typeof window?window.location.href:void 0,userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0})}function Te({title:e,children:t}){/* @__PURE__ */
1
+ import{E as e,_ as t,h as r,p as n,r as i,s,t as o,v as a,y as c}from"./BXMw4kNf.js";import{n as l,t as u}from"./DmpmrPE5.js";import{S as h,h as d,i as f}from"./Bb9ydqSB.js";var p=class{constructor(){this.listeners=/* @__PURE__ */new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},m=new class extends p{#e;#t;#r;constructor(){super(),this.#r=e=>{if("undefined"!=typeof window&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return"boolean"==typeof this.#e?this.#e:"hidden"!==globalThis.document?.visibilityState}},g={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},y=new class{#n=g;#i=!1;setTimeoutProvider(e){this.#n=e}setTimeout(e,t){return this.#n.setTimeout(e,t)}clearTimeout(e){this.#n.clearTimeout(e)}setInterval(e,t){return this.#n.setInterval(e,t)}clearInterval(e){this.#n.clearInterval(e)}},v="undefined"==typeof window||"Deno"in globalThis;function w(){}function b(e,t){return"function"==typeof e?e(t):e}function S(e){return"number"==typeof e&&e>=0&&e!==1/0}function R(e,t){return Math.max(e+(t||0)-Date.now(),0)}function I(e,t){return"function"==typeof e?e(t):e}function O(e,t){return"function"==typeof e?e(t):e}function T(e,t){const{type:r="all",exact:n,fetchStatus:i,predicate:s,queryKey:o,stale:a}=e;if(o)if(n){if(t.queryHash!==k(o,t.options))return!1}else if(!A(t.queryKey,o))return!1;if("all"!==r){const e=t.isActive();if("active"===r&&!e)return!1;if("inactive"===r&&e)return!1}return!("boolean"==typeof a&&t.isStale()!==a||i&&i!==t.state.fetchStatus||s&&!s(t))}function C(e,t){const{exact:r,status:n,predicate:i,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(r){if(E(t.options.mutationKey)!==E(s))return!1}else if(!A(t.options.mutationKey,s))return!1}return!(n&&t.state.status!==n||i&&!i(t))}function k(e,t){return(t?.queryKeyHashFn||E)(e)}function E(e){return JSON.stringify(e,(e,t)=>M(t)?Object.keys(t).sort().reduce((e,r)=>(e[r]=t[r],e),{}):t)}function A(e,t){return e===t||typeof e==typeof t&&!(!e||!t||"object"!=typeof e||"object"!=typeof t)&&Object.keys(t).every(r=>A(e[r],t[r]))}var x=Object.prototype.hasOwnProperty;function F(e,t,r=0){if(e===t)return e;if(r>500)return t;const n=D(e)&&D(t);if(!(n||M(e)&&M(t)))return t;const i=(n?e:Object.keys(e)).length,s=n?t:Object.keys(t),o=s.length,a=n?new Array(o):{};let c=0;for(let l=0;l<o;l++){const o=n?l:s[l],u=e[o],h=t[o];if(u===h){a[o]=u,(n?l<i:x.call(e,o))&&c++;continue}if(null===u||null===h||"object"!=typeof u||"object"!=typeof h){a[o]=h;continue}const d=F(u,h,r+1);a[o]=d,d===u&&c++}return i===o&&c===i?e:a}function P(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function D(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function M(e){if(!q(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!!q(r)&&!!r.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype}function q(e){return"[object Object]"===Object.prototype.toString.call(e)}function U(e,t,r){return"function"==typeof r.structuralSharing?r.structuralSharing(e,t):!1!==r.structuralSharing?F(e,t):t}function Q(e,t,r=0){const n=[...e,t];return r&&n.length>r?n.slice(1):n}function L(e,t,r=0){const n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var j=/* @__PURE__ */Symbol();function _(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:e.queryFn&&e.queryFn!==j?e.queryFn:()=>Promise.reject(/* @__PURE__ */new Error(`Missing queryFn: '${e.queryHash}'`))}function z(e,t){return"function"==typeof e?e(...t):!!e}var N=/* @__PURE__ */(()=>{let e=()=>v;return{isServer:()=>e(),setIsServer(t){e=t}}})();function $(){let e,t;const r=new Promise((r,n)=>{e=r,t=n});function n(e){Object.assign(r,e),delete r.resolve,delete r.reject}return r.status="pending",r.catch(()=>{}),r.resolve=t=>{n({status:"fulfilled",value:t}),e(t)},r.reject=e=>{n({status:"rejected",reason:e}),t(e)},r}var H=function(e){setTimeout(e,0)},V=function(){let e=[],t=0,r=e=>{e()},n=e=>{e()},i=H;const s=n=>{t?e.push(n):i(()=>{r(n)})};return{batch:s=>{let o;t++;try{o=s()}finally{t--,t||(()=>{const t=e;e=[],t.length&&i(()=>{n(()=>{t.forEach(e=>{r(e)})})})})()}return o},batchCalls:e=>(...t)=>{s(()=>{e(...t)})},schedule:s,setNotifyFunction:e=>{r=e},setBatchNotifyFunction:e=>{n=e},setScheduler:e=>{i=e}}}(),W=new class extends p{#s=!0;#t;#r;constructor(){super(),this.#r=e=>{if("undefined"!=typeof window&&window.addEventListener){const t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#s!==e&&(this.#s=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#s}};function G(e){return Math.min(1e3*2**e,3e4)}function Z(e){return"online"!==(e??"online")||W.isOnline()}var B=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function K(e){let t,r=!1,n=0;const i=$(),s=()=>"pending"!==i.status,o=()=>m.isFocused()&&("always"===e.networkMode||W.isOnline())&&e.canRun(),a=()=>Z(e.networkMode)&&e.canRun(),c=e=>{s()||(t?.(),i.resolve(e))},l=e=>{s()||(t?.(),i.reject(e))},u=()=>new Promise(r=>{t=e=>{(s()||o())&&r(e)},e.onPause?.()}).then(()=>{t=void 0,s()||e.onContinue?.()}),h=()=>{if(s())return;let t;const i=0===n?e.initialPromise:void 0;try{t=i??e.fn()}catch(a){t=Promise.reject(a)}Promise.resolve(t).then(c).catch(t=>{if(s())return;const i=e.retry??(N.isServer()?0:3),a=e.retryDelay??G,c="function"==typeof a?a(n,t):a,d=!0===i||"number"==typeof i&&n<i||"function"==typeof i&&i(n,t);var f;!r&&d?(n++,e.onFail?.(n,t),(f=c,new Promise(e=>{y.setTimeout(e,f)})).then(()=>o()?void 0:u()).then(()=>{r?l(t):h()})):l(t)})};return{promise:i,status:()=>i.status,cancel:t=>{if(!s()){const r=new B(t);l(r),e.onCancel?.(r)}},continue:()=>(t?.(),i),cancelRetry:()=>{r=!0},continueRetry:()=>{r=!1},canStart:a,start:()=>(a()?h():u().then(h),i)}}var J=class{#o;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),S(this.gcTime)&&(this.#o=y.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(N.isServer()?1/0:3e5))}clearGcTimeout(){void 0!==this.#o&&(y.clearTimeout(this.#o),this.#o=void 0)}};function Y(e){return{onFetch:(t,r)=>{const n=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,s=t.state.data?.pages||[],o=t.state.data?.pageParams||[];let a={pages:[],pageParams:[]},c=0;const l=async()=>{let r=!1;const l=e=>{!function(e,r,n){let i,s=!1;Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t.signal,s||(s=!0,i.aborted?n():i.addEventListener("abort",n,{once:!0})),i)})}(e,0,()=>r=!0)},u=_(t.options,t.fetchOptions),h=async(e,n,i)=>{if(r)return Promise.reject(t.signal.reason);if(null==n&&e.pages.length)return Promise.resolve(e);const s=(()=>{const e={client:t.client,queryKey:t.queryKey,pageParam:n,direction:i?"backward":"forward",meta:t.options.meta};return l(e),e})(),o=await u(s),{maxPages:a}=t.options,c=i?L:Q;return{pages:c(e.pages,o,a),pageParams:c(e.pageParams,n,a)}};if(i&&s.length){const e="backward"===i,t=e?ee:X,r={pages:s,pageParams:o};a=await h(r,t(n,r),e)}else{const t=e??s.length;do{const e=0===c?o[0]??n.initialPageParam:X(n,a);if(c>0&&null==e)break;a=await h(a,e),c++}while(c<t)}return a};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=l}}}function X(e,{pages:t,pageParams:r}){const n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function ee(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}function te(e,t){return!!t&&null!=X(e,t)}function re(e,t){return!(!t||!e.getPreviousPageParam)&&null!=ee(e,t)}var ne=class extends J{#a;#c;#l;#u;#h;#d;#f;#p;constructor(e){super(),this.#p=!1,this.#f=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#h=e.client,this.#u=this.#h.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#c=oe(this.options),this.state=e.state??this.#c,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#a}get promise(){return this.#d?.promise}setOptions(e){if(this.options={...this.#f,...e},e?._type&&(this.#a=e._type),this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){const e=oe(this.options);void 0!==e.data&&(this.setState(se(e.data,e.dataUpdatedAt)),this.#c=e)}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#u.remove(this)}setData(e,t){const r=U(this.state.data,e,this.options);return this.#m({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e){this.#m({type:"setState",state:e})}cancel(e){const t=this.#d?.promise;return this.#d?.cancel(e),t?t.then(w).catch(w):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#c}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>!1!==O(e.options.enabled,this))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===j||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>"static"===I(e.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(e=0){return void 0===this.state.data||"static"!==e&&(!!this.state.isInvalidated||!R(this.state.dataUpdatedAt,e))}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#d?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#d?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#u.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#d&&(this.#p||this.#g()?this.#d.cancel({revert:!0}):this.#d.cancelRetry()),this.scheduleGc()),this.#u.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#g(){return"paused"===this.state.fetchStatus&&"pending"===this.state.status}invalidate(){this.state.isInvalidated||this.#m({type:"invalidate"})}async fetch(e,t){if("idle"!==this.state.fetchStatus&&"rejected"!==this.#d?.status())if(void 0!==this.state.data&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#d)return this.#d.continueRetry(),this.#d.promise;if(e&&this.setOptions(e),!this.options.queryFn){const e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}const r=new AbortController,n=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#p=!0,r.signal)})},i=()=>{const e=_(this.options,t),r=(()=>{const e={client:this.#h,queryKey:this.queryKey,meta:this.meta};return n(e),e})();return this.#p=!1,this.options.persister?this.options.persister(e,r,this):e(r)},s=(()=>{const e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#h,state:this.state,fetchFn:i};return n(e),e})();("infinite"===this.#a?Y(this.options.pages):this.options.behavior)?.onFetch(s,this),this.#l=this.state,"idle"!==this.state.fetchStatus&&this.state.fetchMeta===s.fetchOptions?.meta||this.#m({type:"fetch",meta:s.fetchOptions?.meta}),this.#d=K({initialPromise:t?.initialPromise,fn:s.fetchFn,onCancel:e=>{e instanceof B&&e.revert&&this.setState({...this.#l,fetchStatus:"idle"}),r.abort()},onFail:(e,t)=>{this.#m({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#m({type:"pause"})},onContinue:()=>{this.#m({type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0});try{const e=await this.#d.start();if(void 0===e)throw new Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#u.config.onSuccess?.(e,this),this.#u.config.onSettled?.(e,this.state.error,this),e}catch(o){if(o instanceof B){if(o.silent)return this.#d.promise;if(o.revert){if(void 0===this.state.data)throw o;return this.state.data}}throw this.#m({type:"error",error:o}),this.#u.config.onError?.(o,this),this.#u.config.onSettled?.(this.state.data,o,this),o}finally{this.scheduleGc()}}#m(e){this.state=(t=>{switch(e.type){case"failed":return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":return{...t,...ie(t.data,this.options),fetchMeta:e.meta??null};case"success":const r={...t,...se(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#l=e.manual?r:void 0,r;case"error":const n=e.error;return{...t,error:n,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}})(this.state),V.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#u.notify({query:this,type:"updated",action:e})})}};function ie(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Z(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}function se(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function oe(e){const t="function"==typeof e.initialData?e.initialData():e.initialData,r=void 0!==t,n=r?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var ae=class extends p{constructor(e,t){super(),this.options=t,this.#h=e,this.#y=null,this.#v=$(),this.bindMethods(),this.setOptions(t)}#h;#w=void 0;#b=void 0;#S=void 0;#R;#I;#v;#y;#O;#T;#C;#k;#E;#A;#x=/* @__PURE__ */new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#w.addObserver(this),ce(this.#w,this.options)?this.#F():this.updateResult(),this.#P())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return le(this.#w,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return le(this.#w,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=/* @__PURE__ */new Set,this.#D(),this.#M(),this.#w.removeObserver(this)}setOptions(e){const t=this.options,r=this.#w;if(this.options=this.#h.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof O(this.options.enabled,this.#w))throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#q(),this.#w.setOptions(this.options),t._defaulted&&!P(this.options,t)&&this.#h.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#w,observer:this});const n=this.hasListeners();n&&ue(this.#w,r,this.options,t)&&this.#F(),this.updateResult(),!n||this.#w===r&&O(this.options.enabled,this.#w)===O(t.enabled,this.#w)&&I(this.options.staleTime,this.#w)===I(t.staleTime,this.#w)||this.#U();const i=this.#Q();!n||this.#w===r&&O(this.options.enabled,this.#w)===O(t.enabled,this.#w)&&i===this.#A||this.#L(i)}getOptimisticResult(e){const t=this.#h.getQueryCache().build(this.#h,e),r=this.createResult(t,e);var n;return n=r,P(this.getCurrentResult(),n)||(this.#S=r,this.#I=this.options,this.#R=this.#w.state),r}getCurrentResult(){return this.#S}trackResult(e,t){return new Proxy(e,{get:(e,r)=>(this.trackProp(r),t?.(r),"promise"===r&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==this.#v.status||this.#v.reject(/* @__PURE__ */new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,r))})}trackProp(e){this.#x.add(e)}getCurrentQuery(){return this.#w}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#h.defaultQueryOptions(e),r=this.#h.getQueryCache().build(this.#h,t);return r.fetch().then(()=>this.createResult(r,t))}fetch(e){return this.#F({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#S))}#F(e){this.#q();let t=this.#w.fetch(this.options,e);return e?.throwOnError||(t=t.catch(w)),t}#U(){this.#D();const e=I(this.options.staleTime,this.#w);if(N.isServer()||this.#S.isStale||!S(e))return;const t=R(this.#S.dataUpdatedAt,e)+1;this.#k=y.setTimeout(()=>{this.#S.isStale||this.updateResult()},t)}#Q(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#w):this.options.refetchInterval)??!1}#L(e){this.#M(),this.#A=e,!N.isServer()&&!1!==O(this.options.enabled,this.#w)&&S(this.#A)&&0!==this.#A&&(this.#E=y.setInterval(()=>{(this.options.refetchIntervalInBackground||m.isFocused())&&this.#F()},this.#A))}#P(){this.#U(),this.#L(this.#Q())}#D(){void 0!==this.#k&&(y.clearTimeout(this.#k),this.#k=void 0)}#M(){void 0!==this.#E&&(y.clearInterval(this.#E),this.#E=void 0)}createResult(e,t){const r=this.#w,n=this.options,i=this.#S,s=this.#R,o=this.#I,a=e!==r?e.state:this.#b,{state:c}=e;let l,u={...c},h=!1;if(t._optimisticResults){const i=this.hasListeners(),s=!i&&ce(e,t),o=i&&ue(e,r,t,n);(s||o)&&(u={...u,...ie(c.data,e.options)}),"isRestoring"===t._optimisticResults&&(u.fetchStatus="idle")}let{error:d,errorUpdatedAt:f,status:p}=u;l=u.data;let m=!1;if(void 0!==t.placeholderData&&void 0===l&&"pending"===p){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,m=!0):e="function"==typeof t.placeholderData?t.placeholderData(this.#C?.state.data,this.#C):t.placeholderData,void 0!==e&&(p="success",l=U(i?.data,e,t),h=!0)}if(t.select&&void 0!==l&&!m)if(i&&l===s?.data&&t.select===this.#O)l=this.#T;else try{this.#O=t.select,l=t.select(l),l=U(i?.data,l,t),this.#T=l,this.#y=null}catch(R){this.#y=R}this.#y&&(d=this.#y,l=this.#T,f=Date.now(),p="error");const g="fetching"===u.fetchStatus,y="pending"===p,v="error"===p,w=y&&g,b=void 0!==l,S={status:p,fetchStatus:u.fetchStatus,isPending:y,isSuccess:"success"===p,isError:v,isInitialLoading:w,isLoading:w,data:l,dataUpdatedAt:u.dataUpdatedAt,error:d,errorUpdatedAt:f,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:u.dataUpdateCount>a.dataUpdateCount||u.errorUpdateCount>a.errorUpdateCount,isFetching:g,isRefetching:g&&!y,isLoadingError:v&&!b,isPaused:"paused"===u.fetchStatus,isPlaceholderData:h,isRefetchError:v&&b,isStale:he(e,t),refetch:this.refetch,promise:this.#v,isEnabled:!1!==O(t.enabled,e)};if(this.options.experimental_prefetchInRender){const t=void 0!==S.data,n="error"===S.status&&!t,i=e=>{n?e.reject(S.error):t&&e.resolve(S.data)},s=()=>{const e=this.#v=S.promise=$();i(e)},o=this.#v;switch(o.status){case"pending":e.queryHash===r.queryHash&&i(o);break;case"fulfilled":(n||S.data!==o.value)&&s();break;case"rejected":n&&S.error===o.reason||s()}}return S}updateResult(){const e=this.#S,t=this.createResult(this.#w,this.options);this.#R=this.#w.state,this.#I=this.options,void 0!==this.#R.data&&(this.#C=this.#w),P(t,e)||(this.#S=t,this.#j({listeners:(()=>{if(!e)return!0;const{notifyOnChangeProps:t}=this.options,r="function"==typeof t?t():t;if("all"===r||!r&&!this.#x.size)return!0;const n=new Set(r??this.#x);return this.options.throwOnError&&n.add("error"),Object.keys(this.#S).some(t=>{const r=t;return this.#S[r]!==e[r]&&n.has(r)})})()}))}#q(){const e=this.#h.getQueryCache().build(this.#h,this.options);if(e===this.#w)return;const t=this.#w;this.#w=e,this.#b=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#P()}#j(e){V.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#S)}),this.#h.getQueryCache().notify({query:this.#w,type:"observerResultsUpdated"})})}};function ce(e,t){return function(e,t){return!1!==O(t.enabled,e)&&void 0===e.state.data&&!("error"===e.state.status&&!1===O(t.retryOnMount,e))}(e,t)||void 0!==e.state.data&&le(e,t,t.refetchOnMount)}function le(e,t,r){if(!1!==O(t.enabled,e)&&"static"!==I(t.staleTime,e)){const n="function"==typeof r?r(e):r;return"always"===n||!1!==n&&he(e,t)}return!1}function ue(e,t,r,n){return(e!==t||!1===O(n.enabled,e))&&(!r.suspense||"error"!==e.state.status)&&he(e,r)}function he(e,t){return!1!==O(t.enabled,e)&&e.isStaleByTime(I(t.staleTime,e))}var de=e(void 0),fe=e=>{const t=c(de);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},pe=({client:e,children:r})=>(t(()=>(e.mount(),()=>{e.unmount()}),[e]),/* @__PURE__ */o(de.Provider,{value:e,children:r})),me=e(!1);me.Provider;var ge=e(function(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}()),ye=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function ve(e,n,s){const o=c(me),l=c(ge),u=fe(s),h=u.defaultQueryOptions(e);u.getDefaultOptions().queries?._experimental_beforeQuery?.(h);const d=u.getQueryCache().get(h.queryHash),f=!1!==e.subscribed;h._optimisticResults=o?"isRestoring":f?"optimistic":void 0,(e=>{if(e.suspense){const t=1e3,r=e=>"static"===e?e:Math.max(e??t,t),n=e.staleTime;e.staleTime="function"==typeof n?(...e)=>r(n(...e)):r(n),"number"==typeof e.gcTime&&(e.gcTime=Math.max(e.gcTime,t))}})(h),((e,t,r)=>{const n=r?.state.error&&"function"==typeof e.throwOnError?z(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||n)&&(t.isReset()||(e.retryOnMount=!1))})(h,l,d),(e=>{t(()=>{e.clearReset()},[e])})(l);const p=!u.getQueryCache().get(h.queryHash),[m]=r(()=>new n(u,h)),g=m.getOptimisticResult(h),y=!o&&f;if(i(a(e=>{const t=y?m.subscribe(V.batchCalls(e)):w;return m.updateResult(),t},[m,y]),()=>m.getCurrentResult(),()=>m.getCurrentResult()),t(()=>{m.setOptions(h)},[h,m]),((e,t)=>e?.suspense&&t.isPending)(h,g))throw ye(h,m,l);if((({result:e,errorResetBoundary:t,throwOnError:r,query:n,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(i&&void 0===e.data||z(r,[e.error,n])))({result:g,errorResetBoundary:l,throwOnError:h.throwOnError,query:d,suspense:h.suspense}))throw g.error;return u.getDefaultOptions().queries?._experimental_afterQuery?.(h,g),h.experimental_prefetchInRender&&!N.isServer()&&((e,t)=>e.isLoading&&e.isFetching&&!t)(g,o)&&(p?ye(h,m,l):d?.promise)?.catch(w).finally(()=>{m.updateResult()}),h.notifyOnChangeProps?g:m.trackResult(g)}function we(e,t){return ve(e,ae,t)}var be=null;function Se(e){be=e}function Re(e){try{const t=JSON.stringify(e);fetch(f.REPORT_ERROR,{method:"POST",headers:{"Content-Type":"application/json",...be?{"x-org-id":be}:{}},body:t,keepalive:!0}).catch(()=>{})}catch{}}function Ie(e,t){Re({message:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0,level:t?.level??"error",component:t?.component,tags:t?.tags,context:t?.extra,url:"undefined"!=typeof window?window.location.href:void 0,userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0})}function Oe(e,t="info",r){Re({message:e,level:t,component:r?.component,tags:r?.tags,context:r?.extra,url:"undefined"!=typeof window?window.location.href:void 0,userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0})}function Te({title:e,children:t}){/* @__PURE__ */
2
2
  return o("div",{className:"mx-auto mt-24 w-fit max-w-xl space-y-8",children:[/* @__PURE__ */o("svg",{xmlns:"http://www.w3.org/2000/svg",className:"mx-auto h-64 w-fit text-[#ff4800]",width:"800",height:"469.317",viewBox:"0 0 800 469.317",role:"img","aria-label":"Error illustration",children:/* @__PURE__ */o("g",{transform:"translate(-443.142 -257.876)",children:[
3
3
  /* @__PURE__ */o("path",{d:"M898.247,664.1H371.155a30.276,30.276,0,0,1-30.241-30.241V352.525a30.276,30.276,0,0,1,30.241-30.241H898.247a30.276,30.276,0,0,1,30.241,30.241V633.862A30.276,30.276,0,0,1,898.247,664.1Z",transform:"translate(308.867 25.517)",fill:"#fff"}),
4
4
  /* @__PURE__ */o("path",{d:"M557.334,341.82H30.241A30.276,30.276,0,0,1,0,311.578V30.241A30.276,30.276,0,0,1,30.241,0H557.334a30.276,30.276,0,0,1,30.241,30.241V311.578A30.276,30.276,0,0,1,557.334,341.82ZM30.241,1.833A28.441,28.441,0,0,0,1.833,30.241V311.578a28.441,28.441,0,0,0,28.409,28.409H557.334a28.441,28.441,0,0,0,28.409-28.409V30.241A28.441,28.441,0,0,0,557.334,1.833Z",transform:"matrix(0.999, -0.035, 0.035, 0.999, 643.995, 358.158)",fill:"#d6d6e3"}),
@@ -26,7 +26,7 @@ return o("div",{className:"mx-auto mt-24 w-fit max-w-xl space-y-8",children:[/*
26
26
  /* @__PURE__ */o("ellipse",{cx:"78.271",cy:"97.971",rx:"78.271",ry:"97.971",transform:"translate(0 127.808)",fill:"#e6e6e6"}),
27
27
  /* @__PURE__ */o("path",{d:"M513.962,637.661h0a1.936,1.936,0,0,0-2.614-.811l-7.837,4.126-2.684-153.9h-.215l-4.085,221.91H504.7l-1.111-63.68,9.565-5.036A1.936,1.936,0,0,0,513.962,637.661Z",transform:"translate(-422.126 -281.002)",fill:"#ccc"}),
28
28
  /* @__PURE__ */o("path",{d:"M612.666,280.653c54.774,0,99.294,103.207,99.294,171.768s-44.4,124.14-99.177,124.14-99.177-55.579-99.177-124.14S557.892,280.653,612.666,280.653Z",transform:"translate(-422.155 -280.653)",fill:"currentColor"}),
29
- /* @__PURE__ */o("path",{d:"M630.131,617.508a2.452,2.452,0,0,0-3.312-1.027l-9.931,5.228-3.4-195h-.272L608.039,707.89h10.353l-1.408-80.69,12.119-6.38A2.452,2.452,0,0,0,630.131,617.508Z",transform:"translate(-422.315 -280.9)",fill:"#3f3d56"})]})]})}),/* @__PURE__ */o("div",{className:"space-y-4",children:[/* @__PURE__ */o("h4",{className:"text-foreground text-center text-lg font-semibold",children:e}),/* @__PURE__ */o("p",{className:"text-muted-foreground text-center",children:t})]})]})}var Ce=({organizationId:e})=>/* @__PURE__ */o("a",{className:"font-medium text-blue-500",href:d.ORGANIZATION_SETTINGS_INTEGRATION(e),target:"_blank",rel:"noreferrer",children:"Guide"});function Ee({organizationId:e,errorType:t,errorMessage:r}){/* @__PURE__ */
29
+ /* @__PURE__ */o("path",{d:"M630.131,617.508a2.452,2.452,0,0,0-3.312-1.027l-9.931,5.228-3.4-195h-.272L608.039,707.89h10.353l-1.408-80.69,12.119-6.38A2.452,2.452,0,0,0,630.131,617.508Z",transform:"translate(-422.315 -280.9)",fill:"#3f3d56"})]})]})}),/* @__PURE__ */o("div",{className:"space-y-4",children:[/* @__PURE__ */o("h4",{className:"text-foreground text-center text-lg font-semibold",children:e}),/* @__PURE__ */o("p",{className:"text-muted-foreground text-center",children:t})]})]})}var Ce=({organizationId:e})=>/* @__PURE__ */o("a",{className:"font-medium text-blue-500",href:d.ORGANIZATION_SETTINGS_INTEGRATION(e),target:"_blank",rel:"noreferrer",children:"Guide"});function ke({organizationId:e,errorType:t,errorMessage:r}){/* @__PURE__ */
30
30
  return o(Te,"custom-auth-invalid"===t?{title:"Setup needed",children:["Custom auth is enabled. Pass ",
31
31
  /* @__PURE__ */o("code",{children:"uid"}),", ",
32
32
  /* @__PURE__ */o("code",{children:"fname"}),", and ",
@@ -36,6 +36,6 @@ return o(Te,"custom-auth-invalid"===t?{title:"Setup needed",children:["Custom au
36
36
  /* @__PURE__ */o(Ce,{organizationId:e})," for details."]}:"page-not-registered"===t?{title:"Page not registered",children:["Add the current page URL in Allowed URLs under"," ",
37
37
  /* @__PURE__ */o("a",{className:"font-medium text-blue-500",href:d.ORGANIZATION_SETTINGS(e),target:"_blank",rel:"noreferrer",children:"Organization Settings"})," ","⇨ Integration Settings. See our ",
38
38
  /* @__PURE__ */o(Ce,{organizationId:e})," for details."]}:{title:"Heads up",children:["Something needs attention. See our ",
39
- /* @__PURE__ */o(Ce,{organizationId:e})," for details or contact Qrati support."]})}var ke='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',Ae=e=>e.trim().replace(/\s+/g," "),xe=e=>e?.replace(/\/+$/,"")||"",Fe=e=>{if(!e)return ke;const t=Ae("string"==typeof e?e:e.fontFamily||""),r="string"==typeof e?void 0:e.customFontName;return t&&"system"!==t?"custom"===t?`"${r||"QratiCustomFont"}", ${ke}`:`"${t}", ${ke}`:"inherit"};function Pe(e){var t,r,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(r=Pe(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function De(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=Pe(e))&&(n&&(n+=" "),n+=t);return n}var Me=(...e)=>De(e.filter(Boolean)),qe=e=>{const t=e.replace(/#/g,"");return(299*parseInt(t.slice(0,2),16)+587*parseInt(t.slice(2,4),16)+114*parseInt(t.slice(4,6),16))/1e3>=128?"#000000":"#FFFFFF"},Ue="px",Qe=(e,t="light")=>{const r=e?.themeSettings?.colors??{},n=e?.themeSettings?.border,i=e?.themeSettings?.shadow,s=e?.integrationSettings,o="dark"===t,a=(e,t,n,i)=>{const s=o?i:n;return r[o?t:e]||s},c=a("primaryLight","primaryDark","#ff4800","#ff4800");return{"--background":a("backgroundLight","backgroundDark","#fafafa","#0a0a0a"),"--foreground":a("foregroundLight","foregroundDark","#252629","#f5f5f5"),"--muted":a("mutedLight","mutedDark","#e5e5e5","#171717"),"--muted-foreground":a("mutedForegroundLight","mutedForegroundDark","#484848","#b5b8bb"),"--border":a("borderLight","borderDark","#dddddd","#353538"),"--input":a("inputLight","inputDark","#f5f5f5","#171717"),"--primary":c,"--primary-foreground":qe(c),"--popover":a("popoverLight","popoverDark","#f5f5f5","#171717"),"--popover-foreground":a("popoverForegroundLight","popoverForegroundDark","#252629","#fafafa"),"--info":a("infoLight","infoDark","#2563eb","#5b8def"),"--warning":a("warningLight","warningDark","#f59e0b","#fbbf24"),"--success":a("successLight","successDark","#10b981","#34d399"),"--destructive":a("destructiveLight","destructiveDark","#ef4444","#f87171"),"--border-width":`${n?.width??"1"}${n?.unit??"px"}`,"--radius":`${n?.radius??"10"}${n?.unit??"px"}`,"--shadow-outer-horizontal-offset":`${i?.outerHorizontalOffset??"0"}${i?.unit??Ue}`,"--shadow-outer-vertical-offset":`${i?.outerVerticalOffset??"0"}${i?.unit??Ue}`,"--shadow-outer-blur":`${i?.outerBlur??"0"}${i?.unit??Ue}`,"--shadow-outer-spread":`${i?.outerSpread??"0"}${i?.unit??Ue}`,...s?.fontFamily&&"system"!==s.fontFamily?{"--font-family":Fe(s)}:{}}},Le=async e=>{try{return await e()}catch{return null}},je=(e,t=1)=>{const r=(new TextEncoder).encode(e),n=3432918353,i=461845907;let s=t>>>0;const o=Math.floor(r.length/4),a=new DataView(r.buffer,r.byteOffset,r.byteLength);for(let h=0;h<o;h++){let e=a.getUint32(4*h,!0);e=Math.imul(e,n),e=e<<15|e>>>17,e=Math.imul(e,i),s^=e,s=s<<13|s>>>19,s=Math.imul(s,5)+3864292196>>>0}let c=0;const l=4*o,u=3&r.length;return 3===u&&(c^=r[l+2]<<16),u>=2&&(c^=r[l+1]<<8),u>=1&&(c^=r[l],c=Math.imul(c,n),c=c<<15|c>>>17,c=Math.imul(c,i),s^=c),s^=r.length,s^=s>>>16,s=Math.imul(s,2246822507)>>>0,s^=s>>>13,s=Math.imul(s,3266489909)>>>0,s^=s>>>16,s.toString(16).padStart(8,"0")},_e=e=>{if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(_e).join(",")}]`;const t=Object.keys(e).sort(),r=[];for(const n of t){const t=e[n];void 0!==t&&r.push(`${_e(n)}:${_e(t)}`)}return`{${r.join(",")}}`},ze=async({debug:e=!1}={})=>{const t=performance.now(),r=await Le(async()=>{if(!window.navigator.userAgentData||"function"!=typeof window.navigator.userAgentData.getHighEntropyValues)return null;const e=await window.navigator.userAgentData.getHighEntropyValues(["architecture","bitness","platformVersion","model","fullVersionList"]);return _e(e)}),n=await Le(()=>(()=>{const e=document.createElement("video"),t=["video/webm","video/mp4","video/ogg","audio/mp4","audio/webm","audio/ogg","audio/mpeg"],r={};for(const n of t){const t=e.canPlayType(n);r[n]=""===t?"no":t}return _e(r)})()),i=await Le(()=>(()=>{const e=["monospace","serif","sans-serif"],t=["Arial","Helvetica","Verdana","Trebuchet MS","Comic Sans MS","Georgia","Times New Roman","Courier New","Segoe UI","Roboto","Open Sans","Noto Sans","system-ui","-apple-system","BlinkMacSystemFont"],r=document.createElement("span");r.style.fontSize="72px",r.style.position="absolute",r.style.visibility="hidden",r.style.whiteSpace="nowrap",r.textContent="mmmmmmmmmwwwwwww",document.body.appendChild(r);const n={};for(const s of e)r.style.fontFamily=s,n[s]=r.offsetWidth;const i=[];for(const s of t){let t=!1;for(const o of e)if(r.style.fontFamily=`"${s}", ${o}`,r.offsetWidth!==n[o]){i.push(s),t=!0;break}t||(r.style.fontFamily=`"${s}"`,r.offsetWidth!==n.monospace&&r.offsetWidth!==n.serif&&i.push(s))}return document.body.removeChild(r),i.length?i.sort().join(","):null})()),s=await Le(()=>new Intl.NumberFormat(window.navigator.languages?.[0]||"en").resolvedOptions().numberingSystem),o=window.navigator.languages?Array.from(window.navigator.languages).join(","):window.navigator.language||null,a=Intl.DateTimeFormat().resolvedOptions(),c=a.timeZone,l=/* @__PURE__ */(new Date).getTimezoneOffset(),u=a.calendar||null,h=void 0!==a.hour12?a.hour12?"h12":"h23":a.hourCycle||null,d=window.matchMedia("(prefers-reduced-motion: reduce)").matches?"reduce":"no-preference",f=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",p=window.matchMedia("(prefers-contrast: more)").matches?"more":window.matchMedia("(prefers-contrast: less)").matches?"less":window.matchMedia("(prefers-contrast: custom)").matches?"custom":"no-preference",m=window.matchMedia("(prefers-reduced-transparency: reduce)").matches?"reduce":"no-preference",g=window.matchMedia("(forced-colors: active)").matches?"active":null,y="number"==typeof window.devicePixelRatio?Math.round(100*window.devicePixelRatio)/100:null,{pixelDepth:v,colorDepth:w}=window.screen,b="ontouchstart"in window||window.navigator.maxTouchPoints>0,S=await Le(()=>(async e=>{const t=document.createElement("canvas");t.width=280,t.height=100;const r=t.getContext("2d"),n=r.createLinearGradient(0,0,280,100);n.addColorStop(0,"#f60"),n.addColorStop(.4,"#09f"),n.addColorStop(.7,"#f09"),n.addColorStop(1,"#0f9"),r.fillStyle=n,r.fillRect(0,0,280,100),r.font='18px "Arial","Helvetica","DejaVu Sans",sans-serif',r.fillStyle="#000",r.textBaseline="alphabetic",r.fillText("Fingerprint ¼½¾™©®∆π∑€¶§",12,45),r.font='bold 22px "Georgia","Times New Roman",serif',r.fillStyle="#222",r.fillText("🦊🐱🚀 2026",12,78),r.globalAlpha=.7,r.fillStyle="rgba(255, 80, 0, 0.35)",r.fillRect(180,20,80,60),r.beginPath(),r.arc(220,50,32,0,2*Math.PI),r.strokeStyle="#fff",r.lineWidth=4,r.stroke(),r.beginPath(),r.moveTo(30,85),r.quadraticCurveTo(140,20,240,85),r.strokeStyle="#00f",r.lineWidth=3,r.stroke(),e&&(t.style.border="1px solid #444",document.body.appendChild(t));const i=t.toDataURL("image/png");return je(i)})(e)),R=await Le(()=>(async()=>{const e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl"),r=t.getExtension("WEBGL_debug_renderer_info"),n={vendor:r?t.getParameter(r.UNMASKED_VENDOR_WEBGL):t.getParameter(t.VENDOR),renderer:r?t.getParameter(r.UNMASKED_RENDERER_WEBGL):t.getParameter(t.RENDERER)};return je(_e(n))})()),I=await Le(()=>(async e=>{const t=await navigator.gpu.requestAdapter({powerPreference:"high-performance"}),r={vendor:t.info?.vendor??"",architecture:t.info?.architecture??"",description:t.info?.description??"",features:Array.from(t.features).sort(),limits:Array.from(t.limits).sort()};if(e){const e=document.createElement("pre");e.style.margin="10px 0",e.style.padding="10px",e.style.border="1px solid #444",e.style.background="#111",e.style.color="#0f8",e.style.fontFamily="monospace",e.textContent=`WebGPU:\n${JSON.stringify(r,null,2)}`,document.body.appendChild(e)}return je(_e(r))})(e)),O=await Le(()=>(async e=>{const t=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,6e3,44100),r=t.createOscillator();r.type="sawtooth",r.frequency.value=8800;const n=t.createDynamicsCompressor();n.threshold.value=-48,n.knee.value=30,n.ratio.value=14,n.attack.value=0,n.release.value=.3;const i=t.createGain();i.gain.value=.4,r.connect(n),n.connect(i),i.connect(t.destination),r.start(0);const s=(await t.startRendering()).getChannelData(0);let o=0,a=0;for(let l=3e3;l<5800;l+=2){const e=s[l];o=31*o+Math.floor(1e5*(e+1))|0,a=Math.imul(a^Math.floor(98765*e),2246822519)}const c=o>>>0^a>>>0;if(e){const e=document.createElement("canvas");e.width=500,e.height=120,e.style.border="1px solid #444",e.style.margin="10px 0",e.title="Audio buffer snippet (4500–5000 samples)";const t=e.getContext("2d");t.fillStyle="#111",t.fillRect(0,0,e.width,e.height),t.font="14px monospace",t.fillStyle="#0f8",t.textAlign="left",t.fillText("AudioID",10,20),t.strokeStyle="#0f8",t.lineWidth=1.5,t.beginPath();const r=Array.from(s.slice(4500,5e3)),n=e.width/r.length;for(let i=0;i<r.length;i++){const s=i*n,o=(r[i]+1)/2*e.height;0===i?t.moveTo(s,o):t.lineTo(s,o)}t.stroke(),document.body.appendChild(e)}return je(c.toString(16))})(e)),T=window.screen.width&&window.screen.height?(window.screen.width/window.screen.height).toFixed(4):null,C=await Le(()=>window.screen.orientation?.type||null),E=window.navigator.connection||window.navigator.mozConnection||window.navigator.webkitConnection,k=E&&E.type||null,A=E?.effectiveType||null,x=!0===E?.saveData,F="boolean"==typeof window.navigator.pdfViewerEnabled?window.navigator.pdfViewerEnabled:null,P="boolean"==typeof window.navigator.webdriver?window.navigator.webdriver:null,D=await Le(()=>"function"!=typeof Intl.supportedValuesOf?null:Intl.supportedValuesOf("calendar").join(",")),M=await Le(async()=>{if(!window.navigator.permissions||"function"!=typeof window.navigator.permissions.query)return null;const e=["geolocation","notifications"],t={};for(const r of e)try{t[r]=(await window.navigator.permissions.query({name:r})).state}catch{t[r]="unsupported"}return _e(t)}),q={vendor:window.navigator.vendor||null,platform:window.navigator.platform||null,userAgentHighEntropy:r||null,mediaCodecs:n||null,fonts:i,numberingSystem:s,languages:o,timezone:c,timezoneOffset:l,intlCalendar:u,hourCycle:h,reducedMotion:d,colorScheme:f,prefersContrast:p,prefersReducedTransparency:m,pdfViewerEnabled:F,webdriver:P,intlSupportedCalendars:D||null,permissionsState:M||null,hardwareConcurrency:window.navigator.hardwareConcurrency||null,deviceMemory:window.navigator.deviceMemory||null,forcedColors:g,devicePixelRatio:y,pixelDepth:v,colorDepth:w,touchSupport:b,screenOrientation:C||null,connectionType:k,effectiveType:A,saveData:x,canvasID:S,webglID:R,webgpuID:I,audioID:O},U={aspectRatio:T,width:window.screen.width,height:window.screen.height,maxTouchPoints:window.navigator.maxTouchPoints};(!0===navigator.userAgentData?.mobile||/Mobi|Android|iPhone|iPad|iPod|webOS|BlackBerry|Windows Phone/i.test(navigator.userAgent)||navigator.maxTouchPoints>0&&matchMedia("(pointer:coarse)").matches&&innerWidth<=1024)&&Object.assign(q,U);const Q=_e(q),L=je(Q),j=Math.round(performance.now()-t);return{fingerprint:L,...q,elapsedMs:j}};"undefined"!=typeof window&&(window.getBrowserFingerprint=ze);var Ne=e=>e?`qrati_token:${e}`:"qrati_token",$e=e=>e?.trim()||void 0,He=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),Ve=async(e,t)=>{if(e instanceof l){try{const t=e.data;if(t?.error)return t.error;if(t?.message)return t.message;if("INVALID_EMAIL_OR_PASSWORD"===t?.code)return"Invalid email or password"}catch{return t||e.message}return t||e.message}return e instanceof Error?t||e.message:t||String(e)},We=e(void 0),Ge=({props:e={},children:i})=>{const{organizationId:c,uid:d,fname:p,lname:m,theme:g="light"}=e,y=fe(),[v,w]=r(null);t(()=>(Se(c??null),()=>Se(null)),[c]);const[b,S]=r(()=>{if("undefined"==typeof window)return null;const e=localStorage.getItem(Ne(c));return e?{token:e}:null}),[R,I]=r(0),{isLoading:O,data:T,error:C}=we({queryKey:[h.QRATI_CONNECT_SESSION,c,d??null,p??null,m??null,R],queryFn:()=>(async({organizationId:e,uid:t,fname:r,lname:n,userToken:i})=>{const s=e.trim();if(!s)throw new Error("Organization ID is required for session initialization");const o=$e(t),a=$e(r),c=$e(n),h=(({userToken:e,uid:t,fname:r,lname:n})=>!e||t||r||n?null:e)({organizationId:s,uid:o,fname:a,lname:c,userToken:i}),d=await(async()=>{const e=await ze();return"string"==typeof e?e:e?.fingerprint})();try{const e=await u.post(f.INITIALIZE_SESSION,{json:{uid:o,fname:a,lname:c,browserFingerprint:d},headers:{"x-org-id":s,...h?{Authorization:`Bearer ${h}`}:{}}}).json();if(!He(e)||!He(e.data))throw new Error("Invalid session initialization response");const t=e.data;if("string"!=typeof t.sessionId||!He(t.organization)||!Array.isArray(t.folders)||void 0!==t.authSession&&null!==t.authSession&&!He(t.authSession)||void 0!==t.orgRole&&null!==t.orgRole&&"string"!=typeof t.orgRole)throw new Error("Invalid session initialization response");return{...t,requestToken:h}}catch(p){if(p instanceof l)try{const e=p.data;p.apiMessage=e?.message||e?.error}catch{}throw p}})({organizationId:c,uid:d,fname:p,lname:m,userToken:b?.token}),enabled:!!c,staleTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1});t(()=>{T&&(({data:e,setUser:t,uid:r,fname:n,lname:i,organizationId:s})=>{const o=(({data:e,uid:t,fname:r,lname:n})=>{const i=e.authSession?.session?.token??e.authSession?.token,s=e.authSession?.user;return s&&i?{kind:"authenticated",sessionUser:s,sessionToken:i}:e.organization?.customAuth&&t&&r?{kind:"custom-auth",fallbackUser:{_id:t,uid:t,name:n?`${r} ${n}`:r,fname:r,lname:n}}:e.requestToken?{kind:"expired",requestToken:e.requestToken}:{kind:"none"}})({data:e,uid:r,fname:n,lname:i});"authenticated"===o.kind?(t(e=>({...e,...o.sessionUser,token:o.sessionToken,tcAccepted:void 0===o.sessionUser.tcAccepted?e?.tcAccepted:o.sessionUser.tcAccepted})),localStorage.setItem(Ne(s),o.sessionToken)):"custom-auth"===o.kind?t(e=>e??o.fallbackUser):"expired"===o.kind&&t(e=>e?.token!==o.requestToken?e:(localStorage.removeItem(Ne(s)),null))})({data:T,setUser:S,uid:d,fname:p,lname:m,organizationId:c})},[T]);const E=n(()=>{const e=T?.organization?.integrationSettings?.fontFamily,t=((e,t)=>{const r=xe("https://qrati.com"),n=t?Ae(t):"";return r&&n?`${r}/api/connect/organization/google-font?family=${encodeURIComponent(n)}`:null})(0,e),r=((e,t)=>{const r=xe("https://qrati.com");return r&&t?`${r}/api/connect/organization/custom-font?organizationId=${encodeURIComponent(t)}`:null})(0,c);return((e,t,r)=>{if(!e?.fontFamily||"system"===e.fontFamily)return"";const n=Ae(e.fontFamily);if("custom"===n&&t){const r=e.customFontName||"QratiCustomFont",n=/\.woff2(\?|$)/i.test(t)?"woff2":/\.ttf(\?|$)/i.test(t)?"truetype":"woff";return`@font-face{font-family:"${i=r,i.replace(/"/g,'\\"')}";src:url("${t}") format("${n}");font-weight:400 700;font-style:normal;font-display:swap;}`}var i;const s=r||(e=>{if(!e)return null;const t=Ae(e);return t&&"system"!==t.toLowerCase()&&"custom"!==t.toLowerCase()?`https://fonts.googleapis.com/css2?family=${t.replace(/\s+/g,"+")}:wght@400;500;600;700&display=swap`:null})(n);return s?`@import url("${s}");`:""})(T?.organization?.integrationSettings,T?.organization?.customFontUrl?r||T.organization.customFontUrl:void 0,t||void 0)},[T?.organization?.integrationSettings,T?.organization?.customFontUrl,c]);t(()=>{const e=`data-qrati-font-${c}`;if(document.head.querySelector(`[${e}]`)?.remove(),E){if(E.startsWith("@import")){const t=E.match(/@import url\("([^"]+)"\)/);if(!t?.[1])return;const r=document.createElement("link");r.rel="stylesheet",r.href=t[1],r.setAttribute(e,""),document.head.appendChild(r)}else{const t=document.createElement("style");t.textContent=E,t.setAttribute(e,""),document.head.appendChild(t)}return()=>{document.head.querySelector(`[${e}]`)?.remove()}}},[E,c]);const k=a(async e=>{S(t=>({...t,...e}))},[]),A=a(async(e,t,r,n)=>{try{const i=await u.post(f.REGISTER,{json:{email:e,password:t,fname:r,lname:n},headers:{"x-org-id":c}}).json();if(i.error)return{error:i.error};const s={...i.user,token:i.token};return S(s),I(e=>e+1),i.token&&localStorage.setItem(Ne(c),i.token),i}catch(C){return{error:await Ve(C,"Registration failed")}}},[c]),x=a(async(e,t)=>{try{const r=await u.post(f.LOGIN,{json:{email:e,password:t},headers:{"x-org-id":c}}).json();if(r.error)return{error:r.error};const n={...r.user,token:r.token};return S(n),I(e=>e+1),r.token&&localStorage.setItem(Ne(c),r.token),r}catch(C){return{error:await Ve(C,"Invalid email or password")}}},[c]),F=a(async e=>{const t=await((e,t,r)=>new Promise((n,i)=>{if(!e)return void i(/* @__PURE__ */new Error("Provider is required"));if(!t)return void i(/* @__PURE__ */new Error("Organization ID is required"));const s=new URL(`${r}/qc-social-auth`);s.searchParams.set("provider",e),s.searchParams.set("organizationId",t),s.searchParams.set("origin",window.location.origin);const o=(window.screen.width-500)/2,a=(window.screen.height-600)/2,c=window.open(s.toString(),"qrati_social_auth",`width=500,height=600,left=${o},top=${a},scrollbars=yes,resizable=yes,status=yes`);if(!c)return void i(/* @__PURE__ */new Error("Failed to open popup window. Please allow popups and try again."));const l=()=>{clearInterval(h),clearTimeout(d),window.removeEventListener("message",u)},u=e=>{try{const t=new URL(r).origin;if(e.origin!==t)return void console.warn("Origin mismatch:",e.origin,"expected:",t)}catch(h){return void console.warn("Could not parse origin for verification")}const{type:s,data:o,error:a,organizationId:u}=e.data||{};if(u===t)switch(s){case"QRATI_SOCIAL_AUTH_SUCCESS":l(),c.close(),n({user:o.user,session:o.session,token:o.token});break;case"QRATI_SOCIAL_AUTH_ERROR":console.error("Authentication error:",a),l(),c.close(),i(new Error(a||"Social authentication failed"));break;case"QRATI_SOCIAL_AUTH_CANCELLED":l(),c.close(),i(/* @__PURE__ */new Error("Authentication was cancelled"))}else console.warn("Organization ID mismatch:",u,"expected:",t)},h=setInterval(()=>{try{c.closed&&(l(),i(/* @__PURE__ */new Error("Authentication was cancelled")))}catch(e){}},1e3);window.addEventListener("message",u);const d=setTimeout(()=>{l(),c.closed||c.close(),i(/* @__PURE__ */new Error("Authentication timeout. Please try again."))},3e5)}))(e,c??"","https://qrati.com");return t?.user&&t?.token&&(S({...t.user,token:t.token}),I(e=>e+1),localStorage.setItem(Ne(c),t.token)),t},[c]),P=a(async()=>F("google"),[F]),D=a(async()=>F("apple"),[F]),M=a(async e=>{try{const t=await u.post(f.SEND_PASSWORD_RESET_CODE,{json:{email:e.toLowerCase()},headers:{"x-org-id":c}}).json();return t.error?{error:t.error}:t}catch(C){return{error:await Ve(C,"Failed to send password reset code")}}},[c]),q=a(async(e,t)=>{try{const r=await u.post(f.VERIFY_PASSWORD_RESET_CODE,{json:{email:e.toLowerCase(),code:t},headers:{"x-org-id":c}}).json();return r.error?{error:r.error}:r}catch(C){return{error:await Ve(C,"Invalid code, please check your email")}}},[c]),U=a(async(e,t)=>{try{const r=await u.post(f.RESET_PASSWORD,{json:{passwordResetCodeId:e,newPassword:t},headers:{"x-org-id":c}}).json();return r.error?{error:r.error}:r}catch(C){return{error:C?.message}}},[c]),Q=a(async()=>{try{const e=await u.post(f.LOGOUT,{headers:{"x-org-id":c,Authorization:`Bearer ${b?.token}`}}).json();return e.error?{error:e.error}:(S(null),localStorage.removeItem(Ne(c)),await y.invalidateQueries({queryKey:[h.QRATI_CONNECT_SESSION]}),e)}catch(C){return{error:C?.message}}},[c,b?.token]),L=n(()=>({props:e,initializing:O,sessionId:T?.sessionId,organization:T?.organization,folders:T?.folders,orgRole:T?.orgRole??null,loadingUser:O,user:b,updateUser:k,registerUsingEmail:A,loginWithGoogle:P,loginWithApple:D,loginUsingEmail:x,sendPasswordResetCode:M,verifyPasswordResetCode:q,resetPassword:U,signout:Q,error:C,portalContainer:v}),[e,O,T,b,k,A,P,D,x,M,q,U,Q,C,v]);if(C){const e=C,t=401===e?.response?.status?"page-not-registered":e?.response?"generic-error":"service-unavailable";/* @__PURE__ */
40
- return o(s,{fallback:null,children:/* @__PURE__ */o(Ee,{organizationId:c??"",errorType:t,errorMessage:"generic-error"===t?e.apiMessage:void 0})})}/* @__PURE__ */
41
- return o(We.Provider,{value:L,children:/* @__PURE__ */o("div",{ref:w,id:"qrati-connect-container",style:{...Qe(T?.organization,g),fontFamily:T?.organization?.integrationSettings?.fontFamily&&"system"!==T.organization.integrationSettings.fontFamily?"var(--font-family)":"inherit"},className:Me("bg-background text-foreground relative min-h-[80vh]"),children:i})})},Ze=()=>{const e=c(We);if(void 0===e)throw new Error("useSession must be used within SessionProvider");return e};export{z as A,E as C,A as D,w as E,m as M,p as N,I as O,k as S,T,J as _,Qe as a,V as b,Oe as c,pe as d,fe as f,re as g,te as h,Me as i,j,P as k,we as l,ne as m,Ze as n,De as o,ae as p,ze as r,Ie as s,Ge as t,ve as u,B as v,C as w,b as x,W as y};
39
+ /* @__PURE__ */o(Ce,{organizationId:e})," for details or contact Qrati support."]})}var Ee='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',Ae=e=>e.trim().replace(/\s+/g," "),xe=e=>e?.replace(/\/+$/,"")||"",Fe=e=>{if(!e)return Ee;const t=Ae("string"==typeof e?e:e.fontFamily||""),r="string"==typeof e?void 0:e.customFontName;return t&&"system"!==t?"custom"===t?`"${r||"QratiCustomFont"}", ${Ee}`:`"${t}", ${Ee}`:"inherit"};function Pe(e){var t,r,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(r=Pe(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function De(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=Pe(e))&&(n&&(n+=" "),n+=t);return n}var Me=(...e)=>De(e.filter(Boolean)),qe=e=>{const t=e.replace(/#/g,"");return(299*parseInt(t.slice(0,2),16)+587*parseInt(t.slice(2,4),16)+114*parseInt(t.slice(4,6),16))/1e3>=128?"#000000":"#FFFFFF"},Ue="px",Qe=(e,t="light")=>{const r=e?.themeSettings?.colors??{},n=e?.themeSettings?.border,i=e?.themeSettings?.shadow,s=e?.integrationSettings,o="dark"===t,a=(e,t,n,i)=>{const s=o?i:n;return r[o?t:e]||s},c=a("primaryLight","primaryDark","#ff4800","#ff4800");return{"--background":a("backgroundLight","backgroundDark","#fafafa","#0a0a0a"),"--foreground":a("foregroundLight","foregroundDark","#252629","#f5f5f5"),"--muted":a("mutedLight","mutedDark","#e5e5e5","#171717"),"--muted-foreground":a("mutedForegroundLight","mutedForegroundDark","#484848","#b5b8bb"),"--border":a("borderLight","borderDark","#dddddd","#353538"),"--input":a("inputLight","inputDark","#f5f5f5","#171717"),"--primary":c,"--primary-foreground":qe(c),"--popover":a("popoverLight","popoverDark","#f5f5f5","#171717"),"--popover-foreground":a("popoverForegroundLight","popoverForegroundDark","#252629","#fafafa"),"--info":a("infoLight","infoDark","#2563eb","#5b8def"),"--warning":a("warningLight","warningDark","#f59e0b","#fbbf24"),"--success":a("successLight","successDark","#10b981","#34d399"),"--destructive":a("destructiveLight","destructiveDark","#ef4444","#f87171"),"--border-width":`${n?.width??"1"}${n?.unit??"px"}`,"--radius":`${n?.radius??"10"}${n?.unit??"px"}`,"--shadow-outer-horizontal-offset":`${i?.outerHorizontalOffset??"0"}${i?.unit??Ue}`,"--shadow-outer-vertical-offset":`${i?.outerVerticalOffset??"0"}${i?.unit??Ue}`,"--shadow-outer-blur":`${i?.outerBlur??"0"}${i?.unit??Ue}`,"--shadow-outer-spread":`${i?.outerSpread??"0"}${i?.unit??Ue}`,...s?.fontFamily&&"system"!==s.fontFamily?{"--font-family":Fe(s)}:{}}},Le=async e=>{try{return await e()}catch{return null}},je=(e,t=1)=>{const r=(new TextEncoder).encode(e),n=3432918353,i=461845907;let s=t>>>0;const o=Math.floor(r.length/4),a=new DataView(r.buffer,r.byteOffset,r.byteLength);for(let h=0;h<o;h++){let e=a.getUint32(4*h,!0);e=Math.imul(e,n),e=e<<15|e>>>17,e=Math.imul(e,i),s^=e,s=s<<13|s>>>19,s=Math.imul(s,5)+3864292196>>>0}let c=0;const l=4*o,u=3&r.length;return 3===u&&(c^=r[l+2]<<16),u>=2&&(c^=r[l+1]<<8),u>=1&&(c^=r[l],c=Math.imul(c,n),c=c<<15|c>>>17,c=Math.imul(c,i),s^=c),s^=r.length,s^=s>>>16,s=Math.imul(s,2246822507)>>>0,s^=s>>>13,s=Math.imul(s,3266489909)>>>0,s^=s>>>16,s.toString(16).padStart(8,"0")},_e=e=>{if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(_e).join(",")}]`;const t=Object.keys(e).sort(),r=[];for(const n of t){const t=e[n];void 0!==t&&r.push(`${_e(n)}:${_e(t)}`)}return`{${r.join(",")}}`},ze=async({debug:e=!1}={})=>{const t=performance.now(),r=await Le(async()=>{if(!window.navigator.userAgentData||"function"!=typeof window.navigator.userAgentData.getHighEntropyValues)return null;const e=await window.navigator.userAgentData.getHighEntropyValues(["architecture","bitness","platformVersion","model","fullVersionList"]);return _e(e)}),n=await Le(()=>(()=>{const e=document.createElement("video"),t=["video/webm","video/mp4","video/ogg","audio/mp4","audio/webm","audio/ogg","audio/mpeg"],r={};for(const n of t){const t=e.canPlayType(n);r[n]=""===t?"no":t}return _e(r)})()),i=await Le(()=>(()=>{const e=["monospace","serif","sans-serif"],t=["Arial","Helvetica","Verdana","Trebuchet MS","Comic Sans MS","Georgia","Times New Roman","Courier New","Segoe UI","Roboto","Open Sans","Noto Sans","system-ui","-apple-system","BlinkMacSystemFont"],r=document.createElement("span");r.style.fontSize="72px",r.style.position="absolute",r.style.visibility="hidden",r.style.whiteSpace="nowrap",r.textContent="mmmmmmmmmwwwwwww",document.body.appendChild(r);const n={};for(const s of e)r.style.fontFamily=s,n[s]=r.offsetWidth;const i=[];for(const s of t){let t=!1;for(const o of e)if(r.style.fontFamily=`"${s}", ${o}`,r.offsetWidth!==n[o]){i.push(s),t=!0;break}t||(r.style.fontFamily=`"${s}"`,r.offsetWidth!==n.monospace&&r.offsetWidth!==n.serif&&i.push(s))}return document.body.removeChild(r),i.length?i.sort().join(","):null})()),s=await Le(()=>new Intl.NumberFormat(window.navigator.languages?.[0]||"en").resolvedOptions().numberingSystem),o=window.navigator.languages?Array.from(window.navigator.languages).join(","):window.navigator.language||null,a=Intl.DateTimeFormat().resolvedOptions(),c=a.timeZone,l=/* @__PURE__ */(new Date).getTimezoneOffset(),u=a.calendar||null,h=void 0!==a.hour12?a.hour12?"h12":"h23":a.hourCycle||null,d=window.matchMedia("(prefers-reduced-motion: reduce)").matches?"reduce":"no-preference",f=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",p=window.matchMedia("(prefers-contrast: more)").matches?"more":window.matchMedia("(prefers-contrast: less)").matches?"less":window.matchMedia("(prefers-contrast: custom)").matches?"custom":"no-preference",m=window.matchMedia("(prefers-reduced-transparency: reduce)").matches?"reduce":"no-preference",g=window.matchMedia("(forced-colors: active)").matches?"active":null,y="number"==typeof window.devicePixelRatio?Math.round(100*window.devicePixelRatio)/100:null,{pixelDepth:v,colorDepth:w}=window.screen,b="ontouchstart"in window||window.navigator.maxTouchPoints>0,S=await Le(()=>(async e=>{const t=document.createElement("canvas");t.width=280,t.height=100;const r=t.getContext("2d"),n=r.createLinearGradient(0,0,280,100);n.addColorStop(0,"#f60"),n.addColorStop(.4,"#09f"),n.addColorStop(.7,"#f09"),n.addColorStop(1,"#0f9"),r.fillStyle=n,r.fillRect(0,0,280,100),r.font='18px "Arial","Helvetica","DejaVu Sans",sans-serif',r.fillStyle="#000",r.textBaseline="alphabetic",r.fillText("Fingerprint ¼½¾™©®∆π∑€¶§",12,45),r.font='bold 22px "Georgia","Times New Roman",serif',r.fillStyle="#222",r.fillText("🦊🐱🚀 2026",12,78),r.globalAlpha=.7,r.fillStyle="rgba(255, 80, 0, 0.35)",r.fillRect(180,20,80,60),r.beginPath(),r.arc(220,50,32,0,2*Math.PI),r.strokeStyle="#fff",r.lineWidth=4,r.stroke(),r.beginPath(),r.moveTo(30,85),r.quadraticCurveTo(140,20,240,85),r.strokeStyle="#00f",r.lineWidth=3,r.stroke(),e&&(t.style.border="1px solid #444",document.body.appendChild(t));const i=t.toDataURL("image/png");return je(i)})(e)),R=await Le(()=>(async()=>{const e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl"),r=t.getExtension("WEBGL_debug_renderer_info"),n={vendor:r?t.getParameter(r.UNMASKED_VENDOR_WEBGL):t.getParameter(t.VENDOR),renderer:r?t.getParameter(r.UNMASKED_RENDERER_WEBGL):t.getParameter(t.RENDERER)};return je(_e(n))})()),I=await Le(()=>(async e=>{const t=await navigator.gpu.requestAdapter({powerPreference:"high-performance"}),r={vendor:t.info?.vendor??"",architecture:t.info?.architecture??"",description:t.info?.description??"",features:Array.from(t.features).sort(),limits:Array.from(t.limits).sort()};if(e){const e=document.createElement("pre");e.style.margin="10px 0",e.style.padding="10px",e.style.border="1px solid #444",e.style.background="#111",e.style.color="#0f8",e.style.fontFamily="monospace",e.textContent=`WebGPU:\n${JSON.stringify(r,null,2)}`,document.body.appendChild(e)}return je(_e(r))})(e)),O=await Le(()=>(async e=>{const t=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,6e3,44100),r=t.createOscillator();r.type="sawtooth",r.frequency.value=8800;const n=t.createDynamicsCompressor();n.threshold.value=-48,n.knee.value=30,n.ratio.value=14,n.attack.value=0,n.release.value=.3;const i=t.createGain();i.gain.value=.4,r.connect(n),n.connect(i),i.connect(t.destination),r.start(0);const s=(await t.startRendering()).getChannelData(0);let o=0,a=0;for(let l=3e3;l<5800;l+=2){const e=s[l];o=31*o+Math.floor(1e5*(e+1))|0,a=Math.imul(a^Math.floor(98765*e),2246822519)}const c=o>>>0^a>>>0;if(e){const e=document.createElement("canvas");e.width=500,e.height=120,e.style.border="1px solid #444",e.style.margin="10px 0",e.title="Audio buffer snippet (4500–5000 samples)";const t=e.getContext("2d");t.fillStyle="#111",t.fillRect(0,0,e.width,e.height),t.font="14px monospace",t.fillStyle="#0f8",t.textAlign="left",t.fillText("AudioID",10,20),t.strokeStyle="#0f8",t.lineWidth=1.5,t.beginPath();const r=Array.from(s.slice(4500,5e3)),n=e.width/r.length;for(let i=0;i<r.length;i++){const s=i*n,o=(r[i]+1)/2*e.height;0===i?t.moveTo(s,o):t.lineTo(s,o)}t.stroke(),document.body.appendChild(e)}return je(c.toString(16))})(e)),T=window.screen.width&&window.screen.height?(window.screen.width/window.screen.height).toFixed(4):null,C=await Le(()=>window.screen.orientation?.type||null),k=window.navigator.connection||window.navigator.mozConnection||window.navigator.webkitConnection,E=k&&k.type||null,A=k?.effectiveType||null,x=!0===k?.saveData,F="boolean"==typeof window.navigator.pdfViewerEnabled?window.navigator.pdfViewerEnabled:null,P="boolean"==typeof window.navigator.webdriver?window.navigator.webdriver:null,D=await Le(()=>"function"!=typeof Intl.supportedValuesOf?null:Intl.supportedValuesOf("calendar").join(",")),M=await Le(async()=>{if(!window.navigator.permissions||"function"!=typeof window.navigator.permissions.query)return null;const e=["geolocation","notifications"],t={};for(const r of e)try{t[r]=(await window.navigator.permissions.query({name:r})).state}catch{t[r]="unsupported"}return _e(t)}),q={vendor:window.navigator.vendor||null,platform:window.navigator.platform||null,userAgentHighEntropy:r||null,mediaCodecs:n||null,fonts:i,numberingSystem:s,languages:o,timezone:c,timezoneOffset:l,intlCalendar:u,hourCycle:h,reducedMotion:d,colorScheme:f,prefersContrast:p,prefersReducedTransparency:m,pdfViewerEnabled:F,webdriver:P,intlSupportedCalendars:D||null,permissionsState:M||null,hardwareConcurrency:window.navigator.hardwareConcurrency||null,deviceMemory:window.navigator.deviceMemory||null,forcedColors:g,devicePixelRatio:y,pixelDepth:v,colorDepth:w,touchSupport:b,screenOrientation:C||null,connectionType:E,effectiveType:A,saveData:x,canvasID:S,webglID:R,webgpuID:I,audioID:O},U={aspectRatio:T,width:window.screen.width,height:window.screen.height,maxTouchPoints:window.navigator.maxTouchPoints};(!0===navigator.userAgentData?.mobile||/Mobi|Android|iPhone|iPad|iPod|webOS|BlackBerry|Windows Phone/i.test(navigator.userAgent)||navigator.maxTouchPoints>0&&matchMedia("(pointer:coarse)").matches&&innerWidth<=1024)&&Object.assign(q,U);const Q=_e(q),L=je(Q),j=Math.round(performance.now()-t);return{fingerprint:L,...q,elapsedMs:j}};"undefined"!=typeof window&&(window.getBrowserFingerprint=ze);var Ne=e=>e?`qrati_token:${e}`:"qrati_token",$e=e=>e?.trim()||void 0,He=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),Ve=async(e,t)=>{if(e instanceof l){try{const t=e.data;if(t?.error)return t.error;if(t?.message)return t.message;if("INVALID_EMAIL_OR_PASSWORD"===t?.code)return"Invalid email or password"}catch{return t||e.message}return t||e.message}return e instanceof Error?t||e.message:t||String(e)},We=e(void 0),Ge=({props:e={},children:i})=>{const{organizationId:c,uid:d,fname:p,lname:m,theme:g="light"}=e,y=fe(),[v,w]=r(null),b=Boolean(d);t(()=>(Se(c??null),()=>Se(null)),[c]);const[S,R]=r(()=>{if("undefined"==typeof window)return null;if(b)return null;const e=localStorage.getItem(Ne(c));return e?{token:e}:null}),[I,O]=r(0),{isLoading:T,data:C,error:k}=we({queryKey:[h.QRATI_CONNECT_SESSION,c,d??null,p??null,m??null,I],queryFn:()=>(async({organizationId:e,uid:t,fname:r,lname:n,userToken:i})=>{const s=e.trim();if(!s)throw new Error("Organization ID is required for session initialization");const o=$e(t),a=$e(r),c=$e(n),h=(({userToken:e,uid:t,fname:r,lname:n})=>!e||t||r||n?null:e)({organizationId:s,uid:o,fname:a,lname:c,userToken:i}),d=await(async()=>{const e=await ze();return"string"==typeof e?e:e?.fingerprint})();try{const e=await u.post(f.INITIALIZE_SESSION,{json:{uid:o,fname:a,lname:c,browserFingerprint:d},headers:{"x-org-id":s,...h?{Authorization:`Bearer ${h}`}:{}}}).json();if(!He(e)||!He(e.data))throw new Error("Invalid session initialization response");const t=e.data;if("string"!=typeof t.sessionId||!He(t.organization)||!Array.isArray(t.folders)||void 0!==t.authSession&&null!==t.authSession&&!He(t.authSession)||void 0!==t.orgRole&&null!==t.orgRole&&"string"!=typeof t.orgRole)throw new Error("Invalid session initialization response");return{...t,requestToken:h}}catch(p){if(p instanceof l)try{const e=p.data;p.apiMessage=e?.message||e?.error}catch{}throw p}})({organizationId:c,uid:d,fname:p,lname:m,userToken:S?.token}),enabled:!!c,staleTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1});t(()=>{C&&(({data:e,setUser:t,uid:r,fname:n,lname:i,organizationId:s,persistToken:o=!0})=>{const a=(({data:e,uid:t,fname:r,lname:n})=>{const i=e.authSession?.session?.token??e.authSession?.token,s=e.authSession?.user;return s&&i?{kind:"authenticated",sessionUser:s,sessionToken:i}:e.organization?.customAuth&&t&&r?{kind:"custom-auth",fallbackUser:{_id:t,uid:t,name:n?`${r} ${n}`:r,fname:r,lname:n}}:e.requestToken?{kind:"expired",requestToken:e.requestToken}:{kind:"none"}})({data:e,uid:r,fname:n,lname:i});"authenticated"===a.kind?(t(e=>({...e,...a.sessionUser,token:a.sessionToken,tcAccepted:void 0===a.sessionUser.tcAccepted?e?.tcAccepted:a.sessionUser.tcAccepted})),o&&localStorage.setItem(Ne(s),a.sessionToken)):"custom-auth"===a.kind?t(e=>e??a.fallbackUser):"expired"===a.kind&&t(e=>e?.token!==a.requestToken?e:(o&&localStorage.removeItem(Ne(s)),null))})({data:C,setUser:R,uid:d,fname:p,lname:m,organizationId:c,persistToken:!b})},[C,p,b,m,c,d]);const E=n(()=>{const e=C?.organization?.integrationSettings?.fontFamily,t=((e,t)=>{const r=xe("https://qrati.com"),n=t?Ae(t):"";return r&&n?`${r}/api/connect/organization/google-font?family=${encodeURIComponent(n)}`:null})(0,e),r=((e,t)=>{const r=xe("https://qrati.com");return r&&t?`${r}/api/connect/organization/custom-font?organizationId=${encodeURIComponent(t)}`:null})(0,c);return((e,t,r)=>{if(!e?.fontFamily||"system"===e.fontFamily)return"";const n=Ae(e.fontFamily);if("custom"===n&&t){const r=e.customFontName||"QratiCustomFont",n=/\.woff2(\?|$)/i.test(t)?"woff2":/\.ttf(\?|$)/i.test(t)?"truetype":"woff";return`@font-face{font-family:"${i=r,i.replace(/"/g,'\\"')}";src:url("${t}") format("${n}");font-weight:400 700;font-style:normal;font-display:swap;}`}var i;const s=r||(e=>{if(!e)return null;const t=Ae(e);return t&&"system"!==t.toLowerCase()&&"custom"!==t.toLowerCase()?`https://fonts.googleapis.com/css2?family=${t.replace(/\s+/g,"+")}:wght@400;500;600;700&display=swap`:null})(n);return s?`@import url("${s}");`:""})(C?.organization?.integrationSettings,C?.organization?.customFontUrl?r||C.organization.customFontUrl:void 0,t||void 0)},[C?.organization?.integrationSettings,C?.organization?.customFontUrl,c]);t(()=>{const e=`data-qrati-font-${c}`;if(document.head.querySelector(`[${e}]`)?.remove(),E){if(E.startsWith("@import")){const t=E.match(/@import url\("([^"]+)"\)/);if(!t?.[1])return;const r=document.createElement("link");r.rel="stylesheet",r.href=t[1],r.setAttribute(e,""),document.head.appendChild(r)}else{const t=document.createElement("style");t.textContent=E,t.setAttribute(e,""),document.head.appendChild(t)}return()=>{document.head.querySelector(`[${e}]`)?.remove()}}},[E,c]);const A=a(async e=>{R(t=>({...t,...e}))},[]),x=a(async(e,t,r,n)=>{try{const i=await u.post(f.REGISTER,{json:{email:e,password:t,fname:r,lname:n},headers:{"x-org-id":c}}).json();if(i.error)return{error:i.error};const s={...i.user,token:i.token};return R(s),O(e=>e+1),i.token&&!b&&localStorage.setItem(Ne(c),i.token),i}catch(k){return{error:await Ve(k,"Registration failed")}}},[c,b]),F=a(async(e,t)=>{try{const r=await u.post(f.LOGIN,{json:{email:e,password:t},headers:{"x-org-id":c}}).json();if(r.error)return{error:r.error};const n={...r.user,token:r.token};return R(n),O(e=>e+1),r.token&&!b&&localStorage.setItem(Ne(c),r.token),r}catch(k){return{error:await Ve(k,"Invalid email or password")}}},[c,b]),P=a(async e=>{const t=await((e,t,r)=>new Promise((n,i)=>{if(!e)return void i(/* @__PURE__ */new Error("Provider is required"));if(!t)return void i(/* @__PURE__ */new Error("Organization ID is required"));const s=new URL(`${r}/qc-social-auth`);s.searchParams.set("provider",e),s.searchParams.set("organizationId",t),s.searchParams.set("origin",window.location.origin);const o=(window.screen.width-500)/2,a=(window.screen.height-600)/2,c=window.open(s.toString(),"qrati_social_auth",`width=500,height=600,left=${o},top=${a},scrollbars=yes,resizable=yes,status=yes`);if(!c)return void i(/* @__PURE__ */new Error("Failed to open popup window. Please allow popups and try again."));const l=()=>{clearInterval(h),clearTimeout(d),window.removeEventListener("message",u)},u=e=>{try{const t=new URL(r).origin;if(e.origin!==t)return void console.warn("Origin mismatch:",e.origin,"expected:",t)}catch(h){return void console.warn("Could not parse origin for verification")}const{type:s,data:o,error:a,organizationId:u}=e.data||{};if(u===t)switch(s){case"QRATI_SOCIAL_AUTH_SUCCESS":l(),c.close(),n({user:o.user,session:o.session,token:o.token});break;case"QRATI_SOCIAL_AUTH_ERROR":console.error("Authentication error:",a),l(),c.close(),i(new Error(a||"Social authentication failed"));break;case"QRATI_SOCIAL_AUTH_CANCELLED":l(),c.close(),i(/* @__PURE__ */new Error("Authentication was cancelled"))}else console.warn("Organization ID mismatch:",u,"expected:",t)},h=setInterval(()=>{try{c.closed&&(l(),i(/* @__PURE__ */new Error("Authentication was cancelled")))}catch(e){}},1e3);window.addEventListener("message",u);const d=setTimeout(()=>{l(),c.closed||c.close(),i(/* @__PURE__ */new Error("Authentication timeout. Please try again."))},3e5)}))(e,c??"","https://qrati.com");return t?.user&&t?.token&&(R({...t.user,token:t.token}),O(e=>e+1),b||localStorage.setItem(Ne(c),t.token)),t},[c,b]),D=a(async()=>P("google"),[P]),M=a(async()=>P("apple"),[P]),q=a(async e=>{try{const t=await u.post(f.SEND_PASSWORD_RESET_CODE,{json:{email:e.toLowerCase()},headers:{"x-org-id":c}}).json();return t.error?{error:t.error}:t}catch(k){return{error:await Ve(k,"Failed to send password reset code")}}},[c]),U=a(async(e,t)=>{try{const r=await u.post(f.VERIFY_PASSWORD_RESET_CODE,{json:{email:e.toLowerCase(),code:t},headers:{"x-org-id":c}}).json();return r.error?{error:r.error}:r}catch(k){return{error:await Ve(k,"Invalid code, please check your email")}}},[c]),Q=a(async(e,t)=>{try{const r=await u.post(f.RESET_PASSWORD,{json:{passwordResetCodeId:e,newPassword:t},headers:{"x-org-id":c}}).json();return r.error?{error:r.error}:r}catch(k){return{error:k?.message}}},[c]),L=a(async()=>{try{const e=await u.post(f.LOGOUT,{headers:{"x-org-id":c,Authorization:`Bearer ${S?.token}`}}).json();return e.error?{error:e.error}:(R(null),b||localStorage.removeItem(Ne(c)),await y.invalidateQueries({queryKey:[h.QRATI_CONNECT_SESSION]}),e)}catch(k){return{error:k?.message}}},[b,c,S?.token]),j=n(()=>({props:e,initializing:T,sessionId:C?.sessionId,organization:C?.organization,folders:C?.folders,orgRole:C?.orgRole??null,loadingUser:T,user:S,updateUser:A,registerUsingEmail:x,loginWithGoogle:D,loginWithApple:M,loginUsingEmail:F,sendPasswordResetCode:q,verifyPasswordResetCode:U,resetPassword:Q,signout:L,error:k,portalContainer:v}),[e,T,C,S,A,x,D,M,F,q,U,Q,L,k,v]);if(k){const e=k,t=401===e?.response?.status?"page-not-registered":e?.response?"generic-error":"service-unavailable";/* @__PURE__ */
40
+ return o(s,{fallback:null,children:/* @__PURE__ */o(ke,{organizationId:c??"",errorType:t,errorMessage:"generic-error"===t?e.apiMessage:void 0})})}/* @__PURE__ */
41
+ return o(We.Provider,{value:j,children:/* @__PURE__ */o("div",{ref:w,id:"qrati-connect-container",style:{...Qe(C?.organization,g),fontFamily:C?.organization?.integrationSettings?.fontFamily&&"system"!==C.organization.integrationSettings.fontFamily?"var(--font-family)":"inherit"},className:Me("bg-background text-foreground relative min-h-[80vh]"),children:i})})},Ze=()=>{const e=c(We);if(void 0===e)throw new Error("useSession must be used within SessionProvider");return e};export{z as A,k as C,A as D,w as E,m as M,p as N,I as O,E as S,T,J as _,Qe as a,V as b,Oe as c,pe as d,fe as f,re as g,te as h,Me as i,j,P as k,we as l,ne as m,Ze as n,De as o,ae as p,ze as r,Ie as s,Ge as t,ve as u,K as v,C as w,b as x,W as y};
@@ -1 +1 @@
1
- import{l as r,n as e}from"./CdivXyOP.js";import{t as a}from"./DmpmrPE5.js";import{i as t}from"./Bb9ydqSB.js";var o=({eventSlug:o})=>{const{props:s}=e(),n=s?.organizationId,{isLoading:i,data:d,isError:g,error:m}=r({queryKey:[`event-data-${n??""}-${o??""}`],queryFn:async()=>{try{const r=await a.get(t.EVENT_DATA,{searchParams:o?{eventSlug:o}:void 0,headers:{"x-org-id":n}}).json();if(r.error)throw new Error(r.error);return r.data}catch(r){throw new Error(r instanceof Error?r.message:String(r)||"Failed to fetch event data")}},enabled:!!n&&!!o,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:"always"});return{loading:i,event:d?.event,ads:d?.ads,gamConfig:d?.gamConfig,parameters:d?.parameters,isError:g,error:m}};export{o as t};
1
+ import{l as r,n as e}from"./Dpwx5KMy.js";import{t as a}from"./DmpmrPE5.js";import{i as t}from"./Bb9ydqSB.js";var o=({eventSlug:o})=>{const{props:s}=e(),n=s?.organizationId,{isLoading:i,data:d,isError:g,error:m}=r({queryKey:[`event-data-${n??""}-${o??""}`],queryFn:async()=>{try{const r=await a.get(t.EVENT_DATA,{searchParams:o?{eventSlug:o}:void 0,headers:{"x-org-id":n}}).json();if(r.error)throw new Error(r.error);return r.data}catch(r){throw new Error(r instanceof Error?r.message:String(r)||"Failed to fetch event data")}},enabled:!!n&&!!o,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:"always"});return{loading:i,event:d?.event,ads:d?.ads,gamConfig:d?.gamConfig,parameters:d?.parameters,isError:g,error:m}};export{o as t};
@@ -1,10 +1,10 @@
1
- import{r as e,t}from"./DdACKOZr.js";import{E as r,_ as i,c as n,d as o,f as s,g as a,h as l,o as d,p as c,s as u,t as h,v as p,y as m}from"./BXMw4kNf.js";import{c as g,i as f,n as v,s as b}from"./CdivXyOP.js";import{t as y}from"./DmpmrPE5.js";import{b as w,i as x,p as S,s as T,x as C,y as F}from"./Bb9ydqSB.js";import{d as k,l as E,n as _,u as M}from"./BK_hWmGs.js";import{t as U}from"./cBUXG_uS.js";import{t as R}from"./Dl6jcv9I.js";import{t as I}from"./BkIDQGIs.js";import{t as P}from"./C0eP2utz.js";import{n as O}from"./CXRH3zmy.js";import{r as N}from"./JY9kGm742.js";import{t as A}from"./DLHvSz1a2.js";import{t as q}from"./DKxH7j1t2.js";import{a as D,c as L,i as j,o as z,r as $,s as B,t as H}from"./C2WFktw12.js";import{a as V,i as W,n as G,o as X,r as Y,t as K}from"./BrDFXZq12.js";import{t as Q}from"./DMnbtDXS2.js";import{i as J,n as Z,r as ee,t as te}from"./BALdepDv.js";var re=[];for(let mn=0;mn<256;++mn)re.push((mn+256).toString(16).slice(1));var ie=/* @__PURE__ */new Uint8Array(16);function ne(e,t,r){return t||e||!crypto.randomUUID?function(e,t,r){const i=(e=e||{}).random??e.rng?.()??crypto.getRandomValues(ie);if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){if((r=r||0)<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[r+e]=i[e];return t}return function(e,t=0){return(re[e[t+0]]+re[e[t+1]]+re[e[t+2]]+re[e[t+3]]+"-"+re[e[t+4]]+re[e[t+5]]+"-"+re[e[t+6]]+re[e[t+7]]+"-"+re[e[t+8]]+re[e[t+9]]+"-"+re[e[t+10]]+re[e[t+11]]+re[e[t+12]]+re[e[t+13]]+re[e[t+14]]+re[e[t+15]]).toLowerCase()}(i)}(e,t,r):crypto.randomUUID()}function oe({checked:e,defaultChecked:t,onChange:r,onBlur:i,label:n,className:o,disabled:s}){const l=e??t??!1,d=l?"checked":"unchecked",c=a();/* @__PURE__ */
1
+ import{r as e,t}from"./DdACKOZr.js";import{E as r,_ as i,c as n,d as o,f as s,g as a,h as l,o as d,p as c,s as u,t as h,v as p,y as m}from"./BXMw4kNf.js";import{c as g,i as f,n as v,s as b}from"./Dpwx5KMy.js";import{t as y}from"./DmpmrPE5.js";import{b as w,i as x,p as S,s as T,x as C,y as F}from"./Bb9ydqSB.js";import{d as k,l as E,n as _,u as M}from"./Z3MoLpu5.js";import{t as U}from"./BszsxRY6.js";import{t as R}from"./Dl6jcv9I.js";import{t as I}from"./BkIDQGIs.js";import{t as P}from"./C0eP2utz.js";import{n as O}from"./Bq48A0Iv.js";import{r as N}from"./JY9kGm742.js";import{t as A}from"./Te9ieH1R2.js";import{t as q}from"./BWjYmdOz2.js";import{a as D,c as L,i as j,o as z,r as $,s as B,t as H}from"./C2WFktw12.js";import{a as V,i as W,n as G,o as X,r as Y,t as K}from"./CHYm7f-K2.js";import{t as Q}from"./DMnbtDXS2.js";import{i as J,n as Z,r as ee,t as te}from"./BXUp7Zp4.js";var re=[];for(let mn=0;mn<256;++mn)re.push((mn+256).toString(16).slice(1));var ie=/* @__PURE__ */new Uint8Array(16);function ne(e,t,r){return t||e||!crypto.randomUUID?function(e,t,r){const i=(e=e||{}).random??e.rng?.()??crypto.getRandomValues(ie);if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){if((r=r||0)<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[r+e]=i[e];return t}return function(e,t=0){return(re[e[t+0]]+re[e[t+1]]+re[e[t+2]]+re[e[t+3]]+"-"+re[e[t+4]]+re[e[t+5]]+"-"+re[e[t+6]]+re[e[t+7]]+"-"+re[e[t+8]]+re[e[t+9]]+"-"+re[e[t+10]]+re[e[t+11]]+re[e[t+12]]+re[e[t+13]]+re[e[t+14]]+re[e[t+15]]).toLowerCase()}(i)}(e,t,r):crypto.randomUUID()}function oe({checked:e,defaultChecked:t,onChange:r,onBlur:i,label:n,className:o,disabled:s}){const l=e??t??!1,d=l?"checked":"unchecked",c=a();/* @__PURE__ */
2
2
  return h("label",{htmlFor:c,className:f("flex items-center gap-2",s&&"cursor-not-allowed opacity-50",!s&&"cursor-pointer"),children:[/* @__PURE__ */h("button",{type:"button",id:c,role:"switch","aria-checked":l,disabled:s,"data-state":d,onBlur:i,onClick:()=>!s&&r?.(!l),className:f("peer relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border-2 transition-colors","border-border bg-muted","focus-visible:ring-2 focus-visible:ring-offset-2","data-[state=checked]:border-primary data-[state=checked]:bg-primary","disabled:cursor-not-allowed disabled:opacity-50",!s&&"cursor-pointer",o),children:/* @__PURE__ */h("span",{"data-state":d,style:{transform:l?"translateX(1.25rem)":"translateX(0)"},className:f("pointer-events-none block size-5 translate-x-0 rounded-full shadow transition-transform","border-border bg-background border","data-[state=checked]:bg-primary-foreground data-[state=checked]:translate-x-5 data-[state=checked]:border-transparent")})}),n&&/* @__PURE__ */h("span",{className:"text-sm font-medium",children:n})]})}var se=["jpg","jpeg","png","webp","heic","tiff","bmp","avif"],ae=["mp4","webm","ogg","mov","avi","flv","wmv","mkv","3gp","m4v","mpg","mpeg"];function le({open:e,oversizedUids:t,onClose:r,onRemoveAndUpload:i}){const n=Object.values(t),o=n.filter(e=>"image"===e).length,s=n.filter(e=>"video"===e).length,a=[];return o>0&&a.push(`${o} image${o>1?"s":""}`),s>0&&a.push(`${s} video${s>1?"s":""}`),/* @__PURE__ */h(K,{open:e,onOpenChange:e=>!e&&r(),children:/* @__PURE__ */h(G,{children:[/* @__PURE__ */h(V,{children:[/* @__PURE__ */h(X,{children:"Some files are too large"}),/* @__PURE__ */h(Y,{children:[a.join(" and ")," exceed",1===n.length?"s":""," the size limit (25 MB for images, 250 MB for videos) and won't be uploaded."]})]}),/* @__PURE__ */h(W,{children:/* @__PURE__ */h(q,{onClick:i,children:"Remove and Upload"})})]})})}function de({open:e,count:t,onResume:r,onDiscard:i}){/* @__PURE__ */
3
3
  return h(K,{open:e,onOpenChange:e=>!e&&i(),children:/* @__PURE__ */h(G,{children:[/* @__PURE__ */h(V,{children:[/* @__PURE__ */h(X,{children:"Resume your upload?"}),/* @__PURE__ */h(Y,{children:["We found ",t," unfinished upload",t>1?"s":""," from your last visit. Resume where you left off, or remove ",t>1?"them":"it"," and start over."]})]}),/* @__PURE__ */h(W,{children:[/* @__PURE__ */h(q,{variant:"outlined",onClick:i,children:"Remove All"}),/* @__PURE__ */h(q,{onClick:r,children:"Resume"})]})]})})}var ce=["6a385dabb04f4d8783b14fe1","69ada0f82889f080a9ca53df"],ue=({open:e,onClose:t,onSuccess:r})=>{const{t:i}=N(),[n,o]=l(!1),s=v(),a=s.props?.organizationId??s.organization?._id,{user:d,updateUser:c}=s,u=!!a&&ce.includes(a.trim()),p=u?"https://qrati.com/terms-of-use-wedding-private-events":"https://qrati.com/terms-of-use",m=u?"https://qrati.com/privacy-policy-wedding-private-events":"https://qrati.com/privacy-policy";/* @__PURE__ */
4
- return h(K,{open:e,onOpenChange:e=>!e&&t(),children:/* @__PURE__ */h(G,{children:/* @__PURE__ */h("div",{className:"mx-auto max-w-sm p-4 text-center sm:max-w-lg",children:[
4
+ return h(K,{open:e,onOpenChange:e=>!e&&t(),children:/* @__PURE__ */h(G,{className:"text-foreground",children:/* @__PURE__ */h("div",{className:"mx-auto max-w-sm p-4 text-center sm:max-w-lg",children:[
5
5
  /* @__PURE__ */h(X,{children:i("upload.terms_title","Terms & Conditions")}),
6
6
  /* @__PURE__ */h(Y,{hidden:!0,children:i("upload.terms_description","Please accept our terms to proceed")}),
7
- /* @__PURE__ */h("div",{className:"mt-4 mb-6",children:/* @__PURE__ */h("p",{className:"bg-background text-base",children:[i("upload.terms_prompt","I agree to the")," ",
7
+ /* @__PURE__ */h("div",{className:"mt-4 mb-6",children:/* @__PURE__ */h("p",{className:"bg-background text-foreground text-base",children:[i("upload.terms_prompt","I agree to the")," ",
8
8
  /* @__PURE__ */h("a",{href:p,className:"text-info inline-flex items-center gap-1 underline",target:"_blank",rel:"noopener noreferrer",children:i("upload.terms_of_use","Terms of Use")})," ",i("upload.and","and")," ",
9
9
  /* @__PURE__ */h("a",{href:m,className:"text-info inline-flex items-center gap-1 underline",target:"_blank",rel:"noopener noreferrer",children:i("upload.privacy_policy","Privacy Policy")})," "]})}),
10
10
  /* @__PURE__ */h(q,{fullWidth:!0,color:"success",disabled:n,loading:n,onClick:async()=>{o(!0);try{const e=await y.post(x.ACCEPT_TERMS,{headers:{"x-org-id":a,Authorization:d?.token?`Bearer ${d.token}`:void 0}}).json();if(e.error)throw new Error(e.error);await c({tcAccepted:!0}),o(!1),r()}catch(e){b(e instanceof Error?e:new Error(String(e)),{component:"TermsAndConditionsModal",tags:["upload","terms-accept"]}),O.error(i("upload.accept_failed","Failed to accept terms"))}o(!1)},children:i("button.accept","Accept")})]})})})},he=({eventSlug:e,locationState:t})=>{const{t:r}=N(),i=e?C.GALLERY(e):C.PUBLIC_EVENTS;/* @__PURE__ */
@@ -1,4 +1,4 @@
1
- import{E as t,S as e,_ as n,f as s,h as r,p as i,t as a,v as o,w as c,y as u}from"./BXMw4kNf.js";import{i as l}from"./CdivXyOP.js";var h=t(null),p=t(null),d=class{entries;index=0;listeners=/* @__PURE__ */new Set;constructor(t="/"){this.entries=[{path:t}]}get location(){return this.entries[this.index]?.path??"/"}get state(){return this.entries[this.index]?.state}push(t,e){this.entries=this.entries.slice(0,this.index+1),this.index=this.entries.push({path:t,state:e})-1,this.notify()}replace(t,e){this.entries[this.index]={path:t,state:e},this.notify()}go(t){const e=this.index+t;e>=0&&e<this.entries.length&&(this.index=e,this.notify())}canGoBack(){return this.index>0}listen(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notify(){this.listeners.forEach(t=>t(this.location))}},f=class{listeners=/* @__PURE__ */new Set;appPushCount=0;get location(){return window.location.hash.replace(/^#/,"")||"/"}get state(){return window.history.state?.__qrati_state}makeUrl(t){return`${window.location.pathname+window.location.search}#${t}`}push(t,e){window.history.pushState({__qrati_state:e},"",this.makeUrl(t)),this.appPushCount+=1,this.notify()}replace(t,e){window.history.replaceState({__qrati_state:e},"",this.makeUrl(t)),this.notify()}go(t){this.appPushCount=Math.max(0,this.appPushCount+t),window.history.go(t)}canGoBack(){return this.appPushCount>0}listen(t){this.listeners.add(t);const e=()=>this.notify();return window.addEventListener("popstate",e),window.addEventListener("hashchange",e),queueMicrotask(()=>t(this.location)),()=>{this.listeners.delete(t),window.removeEventListener("popstate",e),window.removeEventListener("hashchange",e)}}notify(){this.listeners.forEach(t=>t(this.location))}};function m(t){const e=t.search(/[?#]/);return-1===e?t||"/":t.slice(0,e)||"/"}function w(t,e,n=!0){const s=t.split("/").filter(Boolean),r=function(t){const e=[],n=t.split("/").filter(Boolean);for(const s of n)if("*"===s)e.push({type:"wildcard"});else if(s.startsWith(":")){const t=s.endsWith("?"),n=t?s.slice(1,-1):s.slice(1);e.push({type:"param",name:n,optional:t})}else e.push({type:"static",value:s});return e}(e),i={};let a=0;for(const o of r)if("static"===o.type){if(s[a]!==o.value)return null;a++}else if("param"===o.type){if(a<s.length){try{i[o.name]=decodeURIComponent(s[a])}catch{i[o.name]=s[a]}a++}else if(!o.optional)return null}else if("wildcard"===o.type){i["*"]=s.slice(a).join("/"),a=s.length;break}return n&&a<s.length?null:{params:i}}function v(t,e){return e.startsWith("/")?e:t.endsWith("/")?t+e:`${t}/${e}`}function y(t,e,n=""){const s=m(t);for(const r of e){const t=r.path.startsWith("/")?r.path:v(n,r.path);if(r.children&&r.children.length>0){const e=w(s,t,!1);if(e){const n=[{route:r,params:e.params}],i=y(s,r.children,t);if(i)n.push(...i);else{const t=r.children.find(t=>""===t.path);t&&n.push({route:t,params:{}})}return n}}const e=w(s,t,!0);if(e)return[{route:r,params:e.params}]}return null}function g(){const t=u(p);if(!t)throw new Error("useParams must be used inside a Route");return t.params}function k(){const t=u(h);if(!t)throw new Error("useNavigate must be used inside a Router");const{navigate:e,go:n}=t;return o((t,s)=>{"number"!=typeof t?e(t,s):n(t)},[e,n])}function x(){const t=u(h);if(!t)throw new Error("useCanGoBack must be used inside a Router");return t.canGoBack}function C(){const t=u(h);if(!t)throw new Error("useRouterMode must be used inside a Router");return t.mode}function E(){const t=u(h);if(!t)throw new Error("useLocation must be used inside a Router");return function(t,e){const n=m(t),s=t.indexOf("?"),r=t.indexOf("#");return{pathname:n,state:e,search:-1===s?"":t.slice(s,-1===r?void 0:r),hash:-1===r?"":t.slice(r)}}(t.location,t.state)}function B({mode:t,initialPath:e,children:c}){const u=s("memory"===t?new d(e):new f),[l,p]=r(u.current.location),[m,w]=r(u.current.state),[v,y]=r(u.current.canGoBack());n(()=>(p(u.current.location),w(u.current.state),y(u.current.canGoBack()),u.current.listen(t=>{p(t),w(u.current.state),y(u.current.canGoBack())})),[]);const g=o((t,e)=>{const n=u.current;e&&e.replace?n.replace(t,e.state):n.push(t,e?.state)},[]),k=o(t=>{u.current.go(t)},[]),x=i(()=>({location:l,state:m,navigate:g,go:k,canGoBack:v,mode:t}),[l,m,g,k,v,t]);/* @__PURE__ */
1
+ import{E as t,S as e,_ as n,f as s,h as r,p as i,t as a,v as o,w as c,y as u}from"./BXMw4kNf.js";import{i as l}from"./Dpwx5KMy.js";var h=t(null),p=t(null),d=class{entries;index=0;listeners=/* @__PURE__ */new Set;constructor(t="/"){this.entries=[{path:t}]}get location(){return this.entries[this.index]?.path??"/"}get state(){return this.entries[this.index]?.state}push(t,e){this.entries=this.entries.slice(0,this.index+1),this.index=this.entries.push({path:t,state:e})-1,this.notify()}replace(t,e){this.entries[this.index]={path:t,state:e},this.notify()}go(t){const e=this.index+t;e>=0&&e<this.entries.length&&(this.index=e,this.notify())}canGoBack(){return this.index>0}listen(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notify(){this.listeners.forEach(t=>t(this.location))}},f=class{listeners=/* @__PURE__ */new Set;appPushCount=0;get location(){return window.location.hash.replace(/^#/,"")||"/"}get state(){return window.history.state?.__qrati_state}makeUrl(t){return`${window.location.pathname+window.location.search}#${t}`}push(t,e){window.history.pushState({__qrati_state:e},"",this.makeUrl(t)),this.appPushCount+=1,this.notify()}replace(t,e){window.history.replaceState({__qrati_state:e},"",this.makeUrl(t)),this.notify()}go(t){this.appPushCount=Math.max(0,this.appPushCount+t),window.history.go(t)}canGoBack(){return this.appPushCount>0}listen(t){this.listeners.add(t);const e=()=>this.notify();return window.addEventListener("popstate",e),window.addEventListener("hashchange",e),queueMicrotask(()=>t(this.location)),()=>{this.listeners.delete(t),window.removeEventListener("popstate",e),window.removeEventListener("hashchange",e)}}notify(){this.listeners.forEach(t=>t(this.location))}};function m(t){const e=t.search(/[?#]/);return-1===e?t||"/":t.slice(0,e)||"/"}function w(t,e,n=!0){const s=t.split("/").filter(Boolean),r=function(t){const e=[],n=t.split("/").filter(Boolean);for(const s of n)if("*"===s)e.push({type:"wildcard"});else if(s.startsWith(":")){const t=s.endsWith("?"),n=t?s.slice(1,-1):s.slice(1);e.push({type:"param",name:n,optional:t})}else e.push({type:"static",value:s});return e}(e),i={};let a=0;for(const o of r)if("static"===o.type){if(s[a]!==o.value)return null;a++}else if("param"===o.type){if(a<s.length){try{i[o.name]=decodeURIComponent(s[a])}catch{i[o.name]=s[a]}a++}else if(!o.optional)return null}else if("wildcard"===o.type){i["*"]=s.slice(a).join("/"),a=s.length;break}return n&&a<s.length?null:{params:i}}function v(t,e){return e.startsWith("/")?e:t.endsWith("/")?t+e:`${t}/${e}`}function y(t,e,n=""){const s=m(t);for(const r of e){const t=r.path.startsWith("/")?r.path:v(n,r.path);if(r.children&&r.children.length>0){const e=w(s,t,!1);if(e){const n=[{route:r,params:e.params}],i=y(s,r.children,t);if(i)n.push(...i);else{const t=r.children.find(t=>""===t.path);t&&n.push({route:t,params:{}})}return n}}const e=w(s,t,!0);if(e)return[{route:r,params:e.params}]}return null}function g(){const t=u(p);if(!t)throw new Error("useParams must be used inside a Route");return t.params}function k(){const t=u(h);if(!t)throw new Error("useNavigate must be used inside a Router");const{navigate:e,go:n}=t;return o((t,s)=>{"number"!=typeof t?e(t,s):n(t)},[e,n])}function x(){const t=u(h);if(!t)throw new Error("useCanGoBack must be used inside a Router");return t.canGoBack}function C(){const t=u(h);if(!t)throw new Error("useRouterMode must be used inside a Router");return t.mode}function E(){const t=u(h);if(!t)throw new Error("useLocation must be used inside a Router");return function(t,e){const n=m(t),s=t.indexOf("?"),r=t.indexOf("#");return{pathname:n,state:e,search:-1===s?"":t.slice(s,-1===r?void 0:r),hash:-1===r?"":t.slice(r)}}(t.location,t.state)}function B({mode:t,initialPath:e,children:c}){const u=s("memory"===t?new d(e):new f),[l,p]=r(u.current.location),[m,w]=r(u.current.state),[v,y]=r(u.current.canGoBack());n(()=>(p(u.current.location),w(u.current.state),y(u.current.canGoBack()),u.current.listen(t=>{p(t),w(u.current.state),y(u.current.canGoBack())})),[]);const g=o((t,e)=>{const n=u.current;e&&e.replace?n.replace(t,e.state):n.push(t,e?.state)},[]),k=o(t=>{u.current.go(t)},[]),x=i(()=>({location:l,state:m,navigate:g,go:k,canGoBack:v,mode:t}),[l,m,g,k,v,t]);/* @__PURE__ */
2
2
  return a(h.Provider,{value:x,children:c})}function _(t){return null}function P(t){return e(t).filter(t=>t?.type===_).map(t=>({path:t.props.path,element:t.props.element,children:t.props.children?P(t.props.children):void 0}))}function G({children:t}){const{location:n}=u(h),r=s([]),o=e(t).filter(t=>t?.type===_).map(t=>t.props.path).join("\0"),l=s("");o!==l.current&&(l.current=o,r.current=P(t));const d=r.current,f=i(()=>y(n,d),[n,d]),m=i(()=>(f??[]).reduce((t,e)=>({...t,...e.params}),{}),[f]),w=i(()=>{if(!f)return null;let t=null;for(let e=f.length-1;e>=0;e--){const n=f[e].route.element;t=/* @__PURE__ */a(p.Provider,{value:{params:m,outlet:t},children:/* @__PURE__ */a(n,{})})}return t},[f,m]);return f?/* @__PURE__ */a(c,{children:w}):null}function b(){/* @__PURE__ */
3
3
  return a(c,{children:u(p)?.outlet})}function R({to:t,state:e,replace:n,children:s,className:r,onClick:i,...c}){const l=u(h);/* @__PURE__ */
4
4
  return a("a",{href:t,onClick:o(s=>{s.preventDefault(),i?.(s),l?.navigate(t,{state:e,replace:n})},[l,t,e,n,i]),className:r,...c,children:s})}function N({to:t,state:e,replace:n,children:s,className:r,activeClassName:c,onClick:p,...d}){const f=u(h),w=i(()=>{if(!f)return!1;const e=m(f.location);return e===t||!("/"===t||!e.startsWith(`${t}/`))},[f?.location,t]);/* @__PURE__ */
@@ -1,4 +1,4 @@
1
- import{_ as e,h as t,t as l,w as n}from"./BXMw4kNf.js";import{i as r}from"./CdivXyOP.js";import{t as s}from"./QxKjlE-j.js";var a=()=>/* @__PURE__ */l("svg",{className:"size-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:/* @__PURE__ */l("path",{d:"m15 18-6-6 6-6"})}),o=()=>/* @__PURE__ */l("svg",{className:"size-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:/* @__PURE__ */l("path",{d:"m9 18 6-6-6-6"})});function i({items:s,autoplayInterval:i=3e3,showControls:d=!1,className:c}){const[u,h]=t(0);return e(()=>{if(s.length<=1)return;const e=setInterval(()=>h(e=>(e+1)%s.length),i);return()=>clearInterval(e)},[s.length,i]),0===s.length?null:/* @__PURE__ */l("div",{className:r("relative size-full overflow-hidden",c),children:[s.map((e,t)=>/* @__PURE__ */l("div",{className:r("absolute inset-0 transition-opacity duration-500",t===u?"opacity-100":"opacity-0"),children:e},t)),s.length>1&&/* @__PURE__ */l("div",{className:"absolute bottom-2 left-1/2 z-10 flex -translate-x-1/2 gap-1",children:s.map((e,t)=>/* @__PURE__ */l("button",{onClick:()=>h(t),className:r("h-1.5 rounded-full transition-all",t===u?"w-4 bg-white":"w-1.5 bg-white/50 hover:bg-white/75"),"aria-label":`Go to slide ${t+1}`},t))}),d&&s.length>1&&/* @__PURE__ */l(n,{children:[/* @__PURE__ */l("button",{onClick:()=>h(e=>0===e?s.length-1:e-1),className:"absolute top-1/2 left-2 z-10 flex size-8 -translate-y-1/2 items-center justify-center rounded-full bg-black/40 text-white hover:bg-black/60","aria-label":"Previous",children:/* @__PURE__ */l(a,{})}),/* @__PURE__ */l("button",{onClick:()=>h(e=>(e+1)%s.length),className:"absolute top-1/2 right-2 z-10 flex size-8 -translate-y-1/2 items-center justify-center rounded-full bg-black/40 text-white hover:bg-black/60","aria-label":"Next",children:/* @__PURE__ */l(o,{})})]})]})}var d=({event:e,onExplore:t})=>{const n=(e.contents||[]).map(t=>/* @__PURE__ */l(s,{alt:e.name,src:t.thumbnailUrl||t.url,containerClassName:"size-full",imgClassName:"rounded"},t._id)),r=e?.status?.toUpperCase();/* @__PURE__ */
1
+ import{_ as e,h as t,t as l,w as n}from"./BXMw4kNf.js";import{i as r}from"./Dpwx5KMy.js";import{t as s}from"./BWKUiudT.js";var a=()=>/* @__PURE__ */l("svg",{className:"size-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:/* @__PURE__ */l("path",{d:"m15 18-6-6 6-6"})}),o=()=>/* @__PURE__ */l("svg",{className:"size-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:/* @__PURE__ */l("path",{d:"m9 18 6-6-6-6"})});function i({items:s,autoplayInterval:i=3e3,showControls:d=!1,className:c}){const[u,h]=t(0);return e(()=>{if(s.length<=1)return;const e=setInterval(()=>h(e=>(e+1)%s.length),i);return()=>clearInterval(e)},[s.length,i]),0===s.length?null:/* @__PURE__ */l("div",{className:r("relative size-full overflow-hidden",c),children:[s.map((e,t)=>/* @__PURE__ */l("div",{className:r("absolute inset-0 transition-opacity duration-500",t===u?"opacity-100":"opacity-0"),children:e},t)),s.length>1&&/* @__PURE__ */l("div",{className:"absolute bottom-2 left-1/2 z-10 flex -translate-x-1/2 gap-1",children:s.map((e,t)=>/* @__PURE__ */l("button",{onClick:()=>h(t),className:r("h-1.5 rounded-full transition-all",t===u?"w-4 bg-white":"w-1.5 bg-white/50 hover:bg-white/75"),"aria-label":`Go to slide ${t+1}`},t))}),d&&s.length>1&&/* @__PURE__ */l(n,{children:[/* @__PURE__ */l("button",{onClick:()=>h(e=>0===e?s.length-1:e-1),className:"absolute top-1/2 left-2 z-10 flex size-8 -translate-y-1/2 items-center justify-center rounded-full bg-black/40 text-white hover:bg-black/60","aria-label":"Previous",children:/* @__PURE__ */l(a,{})}),/* @__PURE__ */l("button",{onClick:()=>h(e=>(e+1)%s.length),className:"absolute top-1/2 right-2 z-10 flex size-8 -translate-y-1/2 items-center justify-center rounded-full bg-black/40 text-white hover:bg-black/60","aria-label":"Next",children:/* @__PURE__ */l(o,{})})]})]})}var d=({event:e,onExplore:t})=>{const n=(e.contents||[]).map(t=>/* @__PURE__ */l(s,{alt:e.name,src:t.thumbnailUrl||t.url,containerClassName:"size-full",imgClassName:"rounded"},t._id)),r=e?.status?.toUpperCase();/* @__PURE__ */
2
2
  return l("div",{className:"w-48 max-w-full overflow-hidden rounded-lg bg-white",children:[/* @__PURE__ */l("div",{className:"relative h-40 w-full overflow-hidden",children:[/* @__PURE__ */l(i,{items:n,autoplayInterval:3e3}),"OPEN"===r&&/* @__PURE__ */l("span",{className:"absolute top-2 left-2 inline-flex items-center gap-1 rounded-full bg-green-500 px-2 py-0.5 text-[10px] font-medium text-white",children:[/* @__PURE__ */l("span",{className:"size-1.5 animate-pulse rounded-full bg-white"}),"Open"]})]}),/* @__PURE__ */l("div",{className:"p-2",children:[
3
3
  /* @__PURE__ */l("div",{className:"line-clamp-2 pb-0.5 text-sm font-medium text-black",children:e.name}),
4
4
  /* @__PURE__ */l("div",{className:"pb-2 text-xs text-gray-600",children:e.location?.label}),
@@ -1,3 +1,3 @@
1
- import{C as e,_ as r,f as t,h as n,p as s,t as a}from"./BXMw4kNf.js";import{a as o,d as i,n as c}from"./CdivXyOP.js";import{t as l}from"./9E5bMl4h.js";import{v as u}from"./Bb9ydqSB.js";import{t as m}from"./BVxovwox.js";import{t as d}from"./BUDCYszs.js";import{a as f,i as p,n as h,r as g,t as b}from"./IK19gQaC.js";var{getOwnPropertyNames:y,getOwnPropertySymbols:k}=Object,{hasOwnProperty:v}=Object.prototype;function x(e,r){return function(t,n,s){return e(t,n,s)&&r(t,n,s)}}function w(e){return function(r,t,n){if(!r||!t||"object"!=typeof r||"object"!=typeof t)return e(r,t,n);const{cache:s}=n,a=s.get(r),o=s.get(t);if(a&&o)return a===t&&o===r;s.set(r,t),s.set(t,r);const i=e(r,t,n);return s.delete(r),s.delete(t),i}}function E(e){return y(e).concat(k(e))}var C=Object.hasOwn||((e,r)=>v.call(e,r));function M(e,r){return e===r||!e&&!r&&e!=e&&r!=r}var{getOwnPropertyDescriptor:j,keys:A}=Object;function L(e,r){return e.byteLength===r.byteLength&&F(new Uint8Array(e),new Uint8Array(r))}function q(e,r,t){let n=e.length;if(r.length!==n)return!1;for(;n-- >0;)if(!t.equals(e[n],r[n],n,n,e,r,t))return!1;return!0}function O(e,r){return e.byteLength===r.byteLength&&F(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(r.buffer,r.byteOffset,r.byteLength))}function I(e,r){return M(e.getTime(),r.getTime())}function S(e,r){return e.name===r.name&&e.message===r.message&&e.cause===r.cause&&e.stack===r.stack}function _(e,r){return e===r}function z(e,r,t){const n=e.size;if(n!==r.size)return!1;if(!n)return!0;const s=new Array(n),a=e.entries();let o,i,c=0;for(;(o=a.next())&&!o.done;){const n=r.entries();let a=!1,l=0;for(;(i=n.next())&&!i.done;){if(s[l]){l++;continue}const n=o.value,u=i.value;if(t.equals(n[0],u[0],c,l,e,r,t)&&t.equals(n[1],u[1],n[0],u[0],e,r,t)){a=s[l]=!0;break}l++}if(!a)return!1;c++}return!0}var P=M;function T(e,r,t){const n=A(e);let s=n.length;if(A(r).length!==s)return!1;for(;s-- >0;)if(!D(e,r,t,n[s]))return!1;return!0}function U(e,r,t){const n=E(e);let s,a,o,i=n.length;if(E(r).length!==i)return!1;for(;i-- >0;){if(s=n[i],!D(e,r,t,s))return!1;if(a=j(e,s),o=j(r,s),(a||o)&&(!a||!o||a.configurable!==o.configurable||a.enumerable!==o.enumerable||a.writable!==o.writable))return!1}return!0}function N(e,r){return M(e.valueOf(),r.valueOf())}function $(e,r){return e.source===r.source&&e.flags===r.flags}function B(e,r,t){const n=e.size;if(n!==r.size)return!1;if(!n)return!0;const s=new Array(n),a=e.values();let o,i;for(;(o=a.next())&&!o.done;){const n=r.values();let a=!1,c=0;for(;(i=n.next())&&!i.done;){if(!s[c]&&t.equals(o.value,i.value,o.value,i.value,e,r,t)){a=s[c]=!0;break}c++}if(!a)return!1}return!0}function F(e,r){let t=e.byteLength;if(r.byteLength!==t||e.byteOffset!==r.byteOffset)return!1;for(;t-- >0;)if(e[t]!==r[t])return!1;return!0}function Z(e,r){return e.hostname===r.hostname&&e.pathname===r.pathname&&e.protocol===r.protocol&&e.port===r.port&&e.hash===r.hash&&e.username===r.username&&e.password===r.password}function D(e,r,t,n){return!("_owner"!==n&&"__o"!==n&&"__v"!==n||!e.$$typeof&&!r.$$typeof)||C(r,n)&&t.equals(e[n],r[n],n,n,e,r,t)}var R={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},G=Object.prototype.toString;var V=K();function K(e={}){const{circular:r=!1,createInternalComparator:t,createState:n,strict:s=!1}=e,a=function({areArrayBuffersEqual:e,areArraysEqual:r,areDataViewsEqual:t,areDatesEqual:n,areErrorsEqual:s,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:i,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:m,areTypedArraysEqual:d,areUrlsEqual:f,unknownTagComparators:p}){return function(h,g,b){if(h===g)return!0;if(null==h||null==g)return!1;const y=typeof h;if(y!==typeof g)return!1;if("object"!==y)return"number"===y?i(h,g,b):"function"===y&&a(h,g,b);const k=h.constructor;if(k!==g.constructor)return!1;if(k===Object)return c(h,g,b);if(Array.isArray(h))return r(h,g,b);if(k===Date)return n(h,g,b);if(k===RegExp)return u(h,g,b);if(k===Map)return o(h,g,b);if(k===Set)return m(h,g,b);const v=G.call(h);if("[object Date]"===v)return n(h,g,b);if("[object RegExp]"===v)return u(h,g,b);if("[object Map]"===v)return o(h,g,b);if("[object Set]"===v)return m(h,g,b);if("[object Object]"===v)return"function"!=typeof h.then&&"function"!=typeof g.then&&c(h,g,b);if("[object URL]"===v)return f(h,g,b);if("[object Error]"===v)return s(h,g,b);if("[object Arguments]"===v)return c(h,g,b);if(R[v])return d(h,g,b);if("[object ArrayBuffer]"===v)return e(h,g,b);if("[object DataView]"===v)return t(h,g,b);if("[object Boolean]"===v||"[object Number]"===v||"[object String]"===v)return l(h,g,b);if(p){let e=p[v];if(!e){const r=null!=(x=h)?x[Symbol.toStringTag]:void 0;r&&(e=p[r])}if(e)return e(h,g,b)}var x;return!1}}(function({circular:e,createCustomConfig:r,strict:t}){let n={areArrayBuffersEqual:L,areArraysEqual:t?U:q,areDataViewsEqual:O,areDatesEqual:I,areErrorsEqual:S,areFunctionsEqual:_,areMapsEqual:t?x(z,U):z,areNumbersEqual:P,areObjectsEqual:t?U:T,arePrimitiveWrappersEqual:N,areRegExpsEqual:$,areSetsEqual:t?x(B,U):B,areTypedArraysEqual:t?x(F,U):F,areUrlsEqual:Z,unknownTagComparators:void 0};if(r&&(n=Object.assign({},n,r(n))),e){const e=w(n.areArraysEqual),r=w(n.areMapsEqual),t=w(n.areObjectsEqual),s=w(n.areSetsEqual);n=Object.assign({},n,{areArraysEqual:e,areMapsEqual:r,areObjectsEqual:t,areSetsEqual:s})}return n}(e));return function({circular:e,comparator:r,createState:t,equals:n,strict:s}){if(t)return function(a,o){const{cache:i=(e?/* @__PURE__ */new WeakMap:void 0),meta:c}=t();return r(a,o,{cache:i,equals:n,meta:c,strict:s})};if(e)return function(e,t){return r(e,t,{cache:/* @__PURE__ */new WeakMap,equals:n,meta:void 0,strict:s})};const a={cache:void 0,equals:n,meta:void 0,strict:s};return function(e,t){return r(e,t,a)}}({circular:r,comparator:a,createState:n,equals:t?t(a):(o=a,function(e,r,t,n,s,a,i){return o(e,r,i)}),strict:s});var o}K({strict:!0}),K({circular:!0}),K({circular:!0,strict:!0}),K({createInternalComparator:()=>M}),K({strict:!0,createInternalComparator:()=>M}),K({circular:!0,createInternalComparator:()=>M}),K({circular:!0,createInternalComparator:()=>M,strict:!0});var W=class{static isAdvancedMarkerAvailable(e){return google.maps.marker&&!0===e.getMapCapabilities().isAdvancedMarkersAvailable}static isAdvancedMarker(e){return google.maps.marker&&e instanceof google.maps.marker.AdvancedMarkerElement}static setMap(e,r){this.isAdvancedMarker(e)?e.map=r:e.setMap(r)}static getPosition(e){if(this.isAdvancedMarker(e)){if(e.position){if(e.position instanceof google.maps.LatLng)return e.position;if(Number.isFinite(e.position.lat)&&Number.isFinite(e.position.lng))return new google.maps.LatLng(e.position.lat,e.position.lng)}return new google.maps.LatLng(null)}return e.getPosition()}static getVisible(e){return!!this.isAdvancedMarker(e)||e.getVisible()}},J=class{constructor({markers:e,position:r}){this.markers=[],e&&(this.markers=e),r&&(r instanceof google.maps.LatLng?this._position=r:this._position=new google.maps.LatLng(r))}get bounds(){if(0===this.markers.length&&!this._position)return;const e=new google.maps.LatLngBounds(this._position,this._position);for(const r of this.markers)e.extend(W.getPosition(r));return e}get position(){return this._position||this.bounds.getCenter()}get count(){return this.markers.filter(e=>W.getVisible(e)).length}push(e){this.markers.push(e)}delete(){this.marker&&(W.setMap(this.marker,null),this.marker=void 0),this.markers.length=0}};function X(e,r="assertion failed"){if(null==e)throw Error(r)}var H,Q=class{constructor({maxZoom:e=16}){this.maxZoom=e}noop({markers:e}){return Y(e)}},Y=e=>e.map(e=>new J({position:W.getPosition(e),markers:[e]})),ee=class extends Q{constructor(e){var{maxZoom:r,radius:t=60}=e,n=function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)r.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(t[n[s]]=e[n[s]])}return t}(e,["maxZoom","radius"]);super({maxZoom:r}),this.markers=[],this.clusters=[],this.state={zoom:-1},this.superCluster=new d(Object.assign({maxZoom:this.maxZoom,radius:t},n))}calculate(e){let r=!1,t=e.map.getZoom();X(t),t=Math.round(t);const n={zoom:t};if(!V(e.markers,this.markers)){r=!0,this.markers=[...e.markers];const t=this.markers.map(e=>{const r=W.getPosition(e);return{type:"Feature",geometry:{type:"Point",coordinates:[r.lng(),r.lat()]},properties:{marker:e}}});this.superCluster.load(t)}return r||(this.state.zoom<=this.maxZoom||n.zoom<=this.maxZoom)&&(r=!V(this.state,n)),this.state=n,0===e.markers.length?(this.clusters=[],{clusters:this.clusters,changed:r}):(r&&(this.clusters=this.cluster(e)),{clusters:this.clusters,changed:r})}cluster({map:e}){const r=e.getZoom();return X(r),this.superCluster.getClusters([-180,-90,180,90],Math.round(r)).map(e=>this.transformCluster(e))}transformCluster({geometry:{coordinates:[e,r]},properties:t}){if(t.cluster)return new J({markers:this.superCluster.getLeaves(t.cluster_id,1/0).map(e=>e.properties.marker),position:{lat:r,lng:e}});const n=t.marker;return new J({markers:[n],position:W.getPosition(n)})}},re=class{constructor(e,r){this.markers={sum:e.length};const t=r.map(e=>e.count),n=t.reduce((e,r)=>e+r,0);this.clusters={count:r.length,markers:{mean:n/r.length,sum:n,min:Math.min(...t),max:Math.max(...t)}}}},te=class{render({count:e,position:r},t,n){const s=`<svg fill="${e>Math.max(10,t.clusters.markers.mean)?"#ff0000":"#0000ff"}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 240" width="50" height="50">\n<circle cx="120" cy="120" opacity=".6" r="70" />\n<circle cx="120" cy="120" opacity=".3" r="90" />\n<circle cx="120" cy="120" opacity=".2" r="110" />\n<text x="50%" y="50%" style="fill:#fff" text-anchor="middle" font-size="50" dominant-baseline="middle" font-family="roboto,arial,sans-serif">${e}</text>\n</svg>`,a=`Cluster of ${e} markers`,o=Number(google.maps.Marker.MAX_ZINDEX)+e;if(W.isAdvancedMarkerAvailable(n)){const e=(new DOMParser).parseFromString(s,"image/svg+xml").documentElement;e.setAttribute("transform","translate(0 25)");const t={map:n,position:r,zIndex:o,title:a,content:e};return new google.maps.marker.AdvancedMarkerElement(t)}const i={position:r,zIndex:o,title:a,icon:{url:`data:image/svg+xml;base64,${btoa(s)}`,anchor:new google.maps.Point(25,25)}};return new google.maps.Marker(i)}},ne=class e{constructor(){!function(e,r){for(let t in r.prototype)e.prototype[t]=r.prototype[t]}(e,google.maps.OverlayView)}};!function(e){e.CLUSTERING_BEGIN="clusteringbegin",e.CLUSTERING_END="clusteringend",e.CLUSTER_CLICK="click",e.GMP_CLICK="gmp-click"}(H||(H={}));var se=(e,r,t)=>{r.bounds&&t.fitBounds(r.bounds)},ae=class extends ne{constructor({map:e,markers:r=[],algorithmOptions:t={},algorithm:n=new ee(t),renderer:s=new te,onClusterClick:a=se}){super(),this.map=null,this.idleListener=null,this.markers=[...r],this.clusters=[],this.algorithm=n,this.renderer=s,this.onClusterClick=a,e&&this.setMap(e)}addMarker(e,r){this.markers.includes(e)||(this.markers.push(e),r||this.render())}addMarkers(e,r){e.forEach(e=>{this.addMarker(e,!0)}),r||this.render()}removeMarker(e,r){const t=this.markers.indexOf(e);return-1!==t&&(W.setMap(e,null),this.markers.splice(t,1),r||this.render(),!0)}removeMarkers(e,r){let t=!1;return e.forEach(e=>{t=this.removeMarker(e,!0)||t}),t&&!r&&this.render(),t}clearMarkers(e){this.markers.length=0,e||this.render()}render(){const e=this.getMap();if(e instanceof google.maps.Map&&e.getProjection()){google.maps.event.trigger(this,H.CLUSTERING_BEGIN,this);const{clusters:r,changed:t}=this.algorithm.calculate({markers:this.markers,map:e,mapCanvasProjection:this.getProjection()});if(t||null==t){const e=/* @__PURE__ */new Set;for(const n of r)1==n.markers.length&&e.add(n.markers[0]);const t=[];for(const r of this.clusters)null!=r.marker&&(1==r.markers.length?e.has(r.marker)||W.setMap(r.marker,null):t.push(r.marker));this.clusters=r,this.renderClusters(),requestAnimationFrame(()=>t.forEach(e=>W.setMap(e,null)))}google.maps.event.trigger(this,H.CLUSTERING_END,this)}}onAdd(){const e=this.getMap();X(e),this.idleListener=e.addListener("idle",this.render.bind(this)),this.render()}onRemove(){this.idleListener&&google.maps.event.removeListener(this.idleListener),this.reset()}reset(){this.markers.forEach(e=>W.setMap(e,null)),this.clusters.forEach(e=>e.delete()),this.clusters=[]}renderClusters(){const e=new re(this.markers,this.clusters),r=this.getMap();this.clusters.forEach(t=>{if(1===t.markers.length)t.marker=t.markers[0];else if(t.marker=this.renderer.render(t,e,r),t.markers.forEach(e=>W.setMap(e,null)),this.onClusterClick){const e=W.isAdvancedMarker(t.marker)?H.GMP_CLICK:H.CLUSTER_CLICK;t.marker.addListener(e,e=>{google.maps.event.trigger(this,H.CLUSTER_CLICK,t),this.onClusterClick(e,t,r)})}W.setMap(t.marker,r)})}},oe={top:60,bottom:60,left:276,right:60},ie=new l,ce=e=>{const r=document.createElement("div");r.style.cssText=`\n background:${g(e.color,"#fb8500")};color:#fff;border-radius:20px;padding:5px 10px;\n font-size:12px;font-weight:600;white-space:nowrap;cursor:pointer;\n box-shadow:0 2px 8px rgba(0,0,0,0.25);border:2px solid rgba(255,255,255,0.4);\n display:inline-flex;align-items:center;gap:6px;\n `;const t=document.createElement("span");t.textContent=e.folder.name;const n=document.createElement("span");return n.style.cssText="background:rgba(0,0,0,0.18);border-radius:10px;padding:1px 5px;font-size:10px;",n.textContent=String(e.eventCount),r.appendChild(t),r.appendChild(n),r},le=(e,r)=>{const t=document.createElement("div");if(t.style.cssText=`\n width:36px;height:36px;cursor:pointer;\n background:${e};border-radius:50% 50% 50% 0;transform:rotate(-45deg);\n border:2px solid white;box-shadow:0 2px 8px rgba(0,0,0,0.3);\n display:flex;align-items:center;justify-content:center;overflow:hidden;\n `,r){const e=document.createElement("img");e.src=p(r)??"",e.style.cssText="width:24px;height:24px;border-radius:50%;object-fit:cover;transform:rotate(45deg);",t.appendChild(e)}return t},ue=({apiKey:l,mapId:d="DEMO_MAP_ID",onExplore:p,logoUrl:g})=>{const y=t(null),k=t(null),v=t(null),x=t(null),w=t(null),E=t([]),C=t([]),M=t(null),j=t(!1),A=t(!1),[L,q]=n(!1),[O,I]=n(!0),[S,_]=n(!1),{folderTree:z,activeFolderId:P,activeFolder:T,visibleEvents:U,setActiveFolderId:N,isLoadingEvents:$}=m(),{organization:B}=c(),F=o(B)["--primary"],Z=`${u}-${B?._id??"unknown"}`,D=t(Z);D.current=Z;const R=s(()=>(e=>{try{const r=sessionStorage.getItem(e);if(!r)return null;const t=JSON.parse(r);if(Array.isArray(t?.center)&&"number"==typeof t.zoom)return t}catch{}return null})(Z),[Z]),G=t(/* @__PURE__ */new Map),V=t(/* @__PURE__ */new Map),K=t(null),W=t(null),J=t(p);J.current=p;const X=(e,r,t,n,s)=>{s.event.addListenerOnce(e,"bounds_changed",()=>{const r=e.getZoom();void 0!==r&&r>n&&e.setZoom(n)}),e.fitBounds(r,t)},H=()=>{E.current.forEach(e=>{e.map=null}),E.current=[]},Q=()=>{M.current&&(M.current.clearMarkers(),M.current=null),C.current.forEach(e=>{e.map=null}),C.current=[]};return r(()=>{if(!y.current||k.current)return;let r=!1;return(async()=>{try{const{setOptions:t,importLibrary:n}=await import("./ob_CTelx.js");if(r)return;if(t({key:l,v:"weekly"}),await Promise.all([n("maps"),n("marker")]),r||!y.current)return;const s=window.google.maps;v.current=s;const a=R?.center?{lng:R.center[0],lat:R.center[1]}:{lat:20,lng:0},o=R?.zoom??3,i=new s.Map(y.current,{mapId:d,renderingType:"VECTOR",mapTypeId:"roadmap",center:a,zoom:o,mapTypeControl:!1,streetViewControl:!1});k.current=i,x.current=new s.InfoWindow({maxWidth:280}),x.current.addListener("closeclick",()=>{w.current&&(e(null,w.current),w.current=null)});const c=()=>{try{const e=i.getCenter();if(!e)return;sessionStorage.setItem(D.current,JSON.stringify({center:[e.lng(),e.lat()],zoom:i.getZoom()}))}catch{}};i.addListener("idle",c),I(!1),q(!0)}catch{r||_(!0)}finally{r||I(!1)}})(),()=>{r=!0,H(),Q(),x.current?.close(),w.current&&(e(null,w.current),w.current=null),k.current=null,v.current=null}},[l]),r(()=>{if(!L)return;const r=k.current,t=v.current;if(!r||!t)return;const n=null===P&&z.length>0,s=!n&&0===z.length&&null===P,o=n?"folders":s?"all-events":"folder-events";if(K.current!==o&&(H(),Q(),V.current.clear(),G.current.clear(),W.current=null,x.current?.close(),K.current=o),n){const e=[],n=r=>{for(const t of r)t.centroid?e.push(t):t.children.length>0&&n(t.children)};n(z);const s=new Set(e.map(e=>e.folder._id));for(const[r,t]of V.current)s.has(r)||(t.map=null,V.current.delete(r));E.current=Array.from(V.current.values());for(const a of e){const e=V.current.get(a.folder._id);if(e){e.position={lng:a.centroid[0],lat:a.centroid[1]};continue}const n=ce(a),s=new t.marker.AdvancedMarkerElement({map:r,position:{lng:a.centroid[0],lat:a.centroid[1]},content:n,gmpClickable:!0});s.addListener("click",()=>N(a.folder._id)),V.current.set(a.folder._id,s),E.current.push(s)}}else{if(0===U.length){for(const e of G.current.values())"all-events"===o?M.current?.removeMarker(e,!0):e.map=null;return G.current.clear(),void(C.current=[])}const n=s?F:T?.color||F,c=`${n}|${g??""}`,l=W.current!==c;W.current=c;const u=new Set(U.map(e=>String(e._id))),m=[];for(const[e,r]of G.current)u.has(e)||(m.push(r),G.current.delete(e));m.length>0&&M.current?.removeMarkers(m,!0);const d=[],p=new t.LatLngBounds;U.forEach(s=>{const o=String(s._id),c=s.location.y,u=s.location.x;p.extend({lat:c,lng:u});const m=G.current.get(o);if(m)return m.position={lat:c,lng:u},void(l&&(m.content=le(n,g)));const h=le(n,g),b=new t.marker.AdvancedMarkerElement({map:r,position:{lat:c,lng:u},content:h,gmpClickable:!0});b.addListener("click",()=>{w.current&&e(null,w.current);const t=document.createElement("div");((r,t)=>{e(/* @__PURE__ */a(i,{client:ie,children:/* @__PURE__ */a(f,{event:r,onExplore:e=>J.current?.(e)})}),t)})(s,t),x.current?.close(),x.current?.setContent(t),x.current?.open({anchor:b,map:r}),w.current=t}),G.current.set(o,b),d.push(b)}),C.current=Array.from(G.current.values()),l&&M.current&&(M.current.clearMarkers(),M.current=null),(d.length>0||m.length>0||l)&&(M.current?(d.length>0&&M.current.addMarkers(d,!0),M.current.render()):M.current=new ae({markers:C.current,map:r,renderer:{render:e=>{const{count:r,position:s}=e,a=document.createElement("div"),o=r<10?28:r<30?34:40;return a.style.cssText=`\n width:${o}px;height:${o}px;border-radius:50%;cursor:pointer;\n background:${n};color:#fff;\n display:flex;align-items:center;justify-content:center;\n font-size:13px;font-weight:700;\n box-shadow:0 2px 8px rgba(0,0,0,0.3);\n border:2px solid rgba(255,255,255,0.6);\n `,a.textContent=String(r),new t.marker.AdvancedMarkerElement({position:s,content:a,gmpClickable:!0,zIndex:1e6+r})}}})),s&&(A.current||(A.current=!0,R||p.isEmpty()||X(r,p,oe,8,t)))}},[P,z,U,L,g,N,T,R]),r(()=>{if(!L)return;const e=k.current,r=v.current;if(e&&r)if(j.current||!R){if(j.current=!0,P){const t=h(z,P);if(!t?.folder.boundary?.length)return;const n=new r.LatLngBounds;for(const e of t.folder.boundary)n.extend({lat:e.y,lng:e.x});n.isEmpty()||X(e,n,oe,14,r)}else if(z.length>0){const t=new r.LatLngBounds,n=e=>{for(const r of e)r.centroid?t.extend({lng:r.centroid[0],lat:r.centroid[1]}):n(r.children)};n(z),t.isEmpty()||X(e,t,oe,8,r)}}else j.current=!0},[P,z,L,R]),/* @__PURE__ */a("div",{class:"relative h-screen w-full sm:h-[calc(100vh-4rem)]",style:o(B),children:[
1
+ import{C as e,_ as r,f as t,h as n,p as s,t as a}from"./BXMw4kNf.js";import{a as o,d as i,n as c}from"./Dpwx5KMy.js";import{t as l}from"./rlutojb0.js";import{v as u}from"./Bb9ydqSB.js";import{t as m}from"./CQJ3AK1w.js";import{t as d}from"./BUDCYszs.js";import{a as f,i as p,n as h,r as g,t as b}from"./a_rT1I0D.js";var{getOwnPropertyNames:y,getOwnPropertySymbols:k}=Object,{hasOwnProperty:v}=Object.prototype;function x(e,r){return function(t,n,s){return e(t,n,s)&&r(t,n,s)}}function w(e){return function(r,t,n){if(!r||!t||"object"!=typeof r||"object"!=typeof t)return e(r,t,n);const{cache:s}=n,a=s.get(r),o=s.get(t);if(a&&o)return a===t&&o===r;s.set(r,t),s.set(t,r);const i=e(r,t,n);return s.delete(r),s.delete(t),i}}function E(e){return y(e).concat(k(e))}var C=Object.hasOwn||((e,r)=>v.call(e,r));function M(e,r){return e===r||!e&&!r&&e!=e&&r!=r}var{getOwnPropertyDescriptor:j,keys:A}=Object;function L(e,r){return e.byteLength===r.byteLength&&F(new Uint8Array(e),new Uint8Array(r))}function q(e,r,t){let n=e.length;if(r.length!==n)return!1;for(;n-- >0;)if(!t.equals(e[n],r[n],n,n,e,r,t))return!1;return!0}function O(e,r){return e.byteLength===r.byteLength&&F(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(r.buffer,r.byteOffset,r.byteLength))}function I(e,r){return M(e.getTime(),r.getTime())}function S(e,r){return e.name===r.name&&e.message===r.message&&e.cause===r.cause&&e.stack===r.stack}function _(e,r){return e===r}function z(e,r,t){const n=e.size;if(n!==r.size)return!1;if(!n)return!0;const s=new Array(n),a=e.entries();let o,i,c=0;for(;(o=a.next())&&!o.done;){const n=r.entries();let a=!1,l=0;for(;(i=n.next())&&!i.done;){if(s[l]){l++;continue}const n=o.value,u=i.value;if(t.equals(n[0],u[0],c,l,e,r,t)&&t.equals(n[1],u[1],n[0],u[0],e,r,t)){a=s[l]=!0;break}l++}if(!a)return!1;c++}return!0}var P=M;function T(e,r,t){const n=A(e);let s=n.length;if(A(r).length!==s)return!1;for(;s-- >0;)if(!D(e,r,t,n[s]))return!1;return!0}function U(e,r,t){const n=E(e);let s,a,o,i=n.length;if(E(r).length!==i)return!1;for(;i-- >0;){if(s=n[i],!D(e,r,t,s))return!1;if(a=j(e,s),o=j(r,s),(a||o)&&(!a||!o||a.configurable!==o.configurable||a.enumerable!==o.enumerable||a.writable!==o.writable))return!1}return!0}function N(e,r){return M(e.valueOf(),r.valueOf())}function $(e,r){return e.source===r.source&&e.flags===r.flags}function B(e,r,t){const n=e.size;if(n!==r.size)return!1;if(!n)return!0;const s=new Array(n),a=e.values();let o,i;for(;(o=a.next())&&!o.done;){const n=r.values();let a=!1,c=0;for(;(i=n.next())&&!i.done;){if(!s[c]&&t.equals(o.value,i.value,o.value,i.value,e,r,t)){a=s[c]=!0;break}c++}if(!a)return!1}return!0}function F(e,r){let t=e.byteLength;if(r.byteLength!==t||e.byteOffset!==r.byteOffset)return!1;for(;t-- >0;)if(e[t]!==r[t])return!1;return!0}function Z(e,r){return e.hostname===r.hostname&&e.pathname===r.pathname&&e.protocol===r.protocol&&e.port===r.port&&e.hash===r.hash&&e.username===r.username&&e.password===r.password}function D(e,r,t,n){return!("_owner"!==n&&"__o"!==n&&"__v"!==n||!e.$$typeof&&!r.$$typeof)||C(r,n)&&t.equals(e[n],r[n],n,n,e,r,t)}var R={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},G=Object.prototype.toString;var V=K();function K(e={}){const{circular:r=!1,createInternalComparator:t,createState:n,strict:s=!1}=e,a=function({areArrayBuffersEqual:e,areArraysEqual:r,areDataViewsEqual:t,areDatesEqual:n,areErrorsEqual:s,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:i,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:m,areTypedArraysEqual:d,areUrlsEqual:f,unknownTagComparators:p}){return function(h,g,b){if(h===g)return!0;if(null==h||null==g)return!1;const y=typeof h;if(y!==typeof g)return!1;if("object"!==y)return"number"===y?i(h,g,b):"function"===y&&a(h,g,b);const k=h.constructor;if(k!==g.constructor)return!1;if(k===Object)return c(h,g,b);if(Array.isArray(h))return r(h,g,b);if(k===Date)return n(h,g,b);if(k===RegExp)return u(h,g,b);if(k===Map)return o(h,g,b);if(k===Set)return m(h,g,b);const v=G.call(h);if("[object Date]"===v)return n(h,g,b);if("[object RegExp]"===v)return u(h,g,b);if("[object Map]"===v)return o(h,g,b);if("[object Set]"===v)return m(h,g,b);if("[object Object]"===v)return"function"!=typeof h.then&&"function"!=typeof g.then&&c(h,g,b);if("[object URL]"===v)return f(h,g,b);if("[object Error]"===v)return s(h,g,b);if("[object Arguments]"===v)return c(h,g,b);if(R[v])return d(h,g,b);if("[object ArrayBuffer]"===v)return e(h,g,b);if("[object DataView]"===v)return t(h,g,b);if("[object Boolean]"===v||"[object Number]"===v||"[object String]"===v)return l(h,g,b);if(p){let e=p[v];if(!e){const r=null!=(x=h)?x[Symbol.toStringTag]:void 0;r&&(e=p[r])}if(e)return e(h,g,b)}var x;return!1}}(function({circular:e,createCustomConfig:r,strict:t}){let n={areArrayBuffersEqual:L,areArraysEqual:t?U:q,areDataViewsEqual:O,areDatesEqual:I,areErrorsEqual:S,areFunctionsEqual:_,areMapsEqual:t?x(z,U):z,areNumbersEqual:P,areObjectsEqual:t?U:T,arePrimitiveWrappersEqual:N,areRegExpsEqual:$,areSetsEqual:t?x(B,U):B,areTypedArraysEqual:t?x(F,U):F,areUrlsEqual:Z,unknownTagComparators:void 0};if(r&&(n=Object.assign({},n,r(n))),e){const e=w(n.areArraysEqual),r=w(n.areMapsEqual),t=w(n.areObjectsEqual),s=w(n.areSetsEqual);n=Object.assign({},n,{areArraysEqual:e,areMapsEqual:r,areObjectsEqual:t,areSetsEqual:s})}return n}(e));return function({circular:e,comparator:r,createState:t,equals:n,strict:s}){if(t)return function(a,o){const{cache:i=(e?/* @__PURE__ */new WeakMap:void 0),meta:c}=t();return r(a,o,{cache:i,equals:n,meta:c,strict:s})};if(e)return function(e,t){return r(e,t,{cache:/* @__PURE__ */new WeakMap,equals:n,meta:void 0,strict:s})};const a={cache:void 0,equals:n,meta:void 0,strict:s};return function(e,t){return r(e,t,a)}}({circular:r,comparator:a,createState:n,equals:t?t(a):(o=a,function(e,r,t,n,s,a,i){return o(e,r,i)}),strict:s});var o}K({strict:!0}),K({circular:!0}),K({circular:!0,strict:!0}),K({createInternalComparator:()=>M}),K({strict:!0,createInternalComparator:()=>M}),K({circular:!0,createInternalComparator:()=>M}),K({circular:!0,createInternalComparator:()=>M,strict:!0});var W=class{static isAdvancedMarkerAvailable(e){return google.maps.marker&&!0===e.getMapCapabilities().isAdvancedMarkersAvailable}static isAdvancedMarker(e){return google.maps.marker&&e instanceof google.maps.marker.AdvancedMarkerElement}static setMap(e,r){this.isAdvancedMarker(e)?e.map=r:e.setMap(r)}static getPosition(e){if(this.isAdvancedMarker(e)){if(e.position){if(e.position instanceof google.maps.LatLng)return e.position;if(Number.isFinite(e.position.lat)&&Number.isFinite(e.position.lng))return new google.maps.LatLng(e.position.lat,e.position.lng)}return new google.maps.LatLng(null)}return e.getPosition()}static getVisible(e){return!!this.isAdvancedMarker(e)||e.getVisible()}},J=class{constructor({markers:e,position:r}){this.markers=[],e&&(this.markers=e),r&&(r instanceof google.maps.LatLng?this._position=r:this._position=new google.maps.LatLng(r))}get bounds(){if(0===this.markers.length&&!this._position)return;const e=new google.maps.LatLngBounds(this._position,this._position);for(const r of this.markers)e.extend(W.getPosition(r));return e}get position(){return this._position||this.bounds.getCenter()}get count(){return this.markers.filter(e=>W.getVisible(e)).length}push(e){this.markers.push(e)}delete(){this.marker&&(W.setMap(this.marker,null),this.marker=void 0),this.markers.length=0}};function X(e,r="assertion failed"){if(null==e)throw Error(r)}var H,Q=class{constructor({maxZoom:e=16}){this.maxZoom=e}noop({markers:e}){return Y(e)}},Y=e=>e.map(e=>new J({position:W.getPosition(e),markers:[e]})),ee=class extends Q{constructor(e){var{maxZoom:r,radius:t=60}=e,n=function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)r.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(t[n[s]]=e[n[s]])}return t}(e,["maxZoom","radius"]);super({maxZoom:r}),this.markers=[],this.clusters=[],this.state={zoom:-1},this.superCluster=new d(Object.assign({maxZoom:this.maxZoom,radius:t},n))}calculate(e){let r=!1,t=e.map.getZoom();X(t),t=Math.round(t);const n={zoom:t};if(!V(e.markers,this.markers)){r=!0,this.markers=[...e.markers];const t=this.markers.map(e=>{const r=W.getPosition(e);return{type:"Feature",geometry:{type:"Point",coordinates:[r.lng(),r.lat()]},properties:{marker:e}}});this.superCluster.load(t)}return r||(this.state.zoom<=this.maxZoom||n.zoom<=this.maxZoom)&&(r=!V(this.state,n)),this.state=n,0===e.markers.length?(this.clusters=[],{clusters:this.clusters,changed:r}):(r&&(this.clusters=this.cluster(e)),{clusters:this.clusters,changed:r})}cluster({map:e}){const r=e.getZoom();return X(r),this.superCluster.getClusters([-180,-90,180,90],Math.round(r)).map(e=>this.transformCluster(e))}transformCluster({geometry:{coordinates:[e,r]},properties:t}){if(t.cluster)return new J({markers:this.superCluster.getLeaves(t.cluster_id,1/0).map(e=>e.properties.marker),position:{lat:r,lng:e}});const n=t.marker;return new J({markers:[n],position:W.getPosition(n)})}},re=class{constructor(e,r){this.markers={sum:e.length};const t=r.map(e=>e.count),n=t.reduce((e,r)=>e+r,0);this.clusters={count:r.length,markers:{mean:n/r.length,sum:n,min:Math.min(...t),max:Math.max(...t)}}}},te=class{render({count:e,position:r},t,n){const s=`<svg fill="${e>Math.max(10,t.clusters.markers.mean)?"#ff0000":"#0000ff"}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 240" width="50" height="50">\n<circle cx="120" cy="120" opacity=".6" r="70" />\n<circle cx="120" cy="120" opacity=".3" r="90" />\n<circle cx="120" cy="120" opacity=".2" r="110" />\n<text x="50%" y="50%" style="fill:#fff" text-anchor="middle" font-size="50" dominant-baseline="middle" font-family="roboto,arial,sans-serif">${e}</text>\n</svg>`,a=`Cluster of ${e} markers`,o=Number(google.maps.Marker.MAX_ZINDEX)+e;if(W.isAdvancedMarkerAvailable(n)){const e=(new DOMParser).parseFromString(s,"image/svg+xml").documentElement;e.setAttribute("transform","translate(0 25)");const t={map:n,position:r,zIndex:o,title:a,content:e};return new google.maps.marker.AdvancedMarkerElement(t)}const i={position:r,zIndex:o,title:a,icon:{url:`data:image/svg+xml;base64,${btoa(s)}`,anchor:new google.maps.Point(25,25)}};return new google.maps.Marker(i)}},ne=class e{constructor(){!function(e,r){for(let t in r.prototype)e.prototype[t]=r.prototype[t]}(e,google.maps.OverlayView)}};!function(e){e.CLUSTERING_BEGIN="clusteringbegin",e.CLUSTERING_END="clusteringend",e.CLUSTER_CLICK="click",e.GMP_CLICK="gmp-click"}(H||(H={}));var se=(e,r,t)=>{r.bounds&&t.fitBounds(r.bounds)},ae=class extends ne{constructor({map:e,markers:r=[],algorithmOptions:t={},algorithm:n=new ee(t),renderer:s=new te,onClusterClick:a=se}){super(),this.map=null,this.idleListener=null,this.markers=[...r],this.clusters=[],this.algorithm=n,this.renderer=s,this.onClusterClick=a,e&&this.setMap(e)}addMarker(e,r){this.markers.includes(e)||(this.markers.push(e),r||this.render())}addMarkers(e,r){e.forEach(e=>{this.addMarker(e,!0)}),r||this.render()}removeMarker(e,r){const t=this.markers.indexOf(e);return-1!==t&&(W.setMap(e,null),this.markers.splice(t,1),r||this.render(),!0)}removeMarkers(e,r){let t=!1;return e.forEach(e=>{t=this.removeMarker(e,!0)||t}),t&&!r&&this.render(),t}clearMarkers(e){this.markers.length=0,e||this.render()}render(){const e=this.getMap();if(e instanceof google.maps.Map&&e.getProjection()){google.maps.event.trigger(this,H.CLUSTERING_BEGIN,this);const{clusters:r,changed:t}=this.algorithm.calculate({markers:this.markers,map:e,mapCanvasProjection:this.getProjection()});if(t||null==t){const e=/* @__PURE__ */new Set;for(const n of r)1==n.markers.length&&e.add(n.markers[0]);const t=[];for(const r of this.clusters)null!=r.marker&&(1==r.markers.length?e.has(r.marker)||W.setMap(r.marker,null):t.push(r.marker));this.clusters=r,this.renderClusters(),requestAnimationFrame(()=>t.forEach(e=>W.setMap(e,null)))}google.maps.event.trigger(this,H.CLUSTERING_END,this)}}onAdd(){const e=this.getMap();X(e),this.idleListener=e.addListener("idle",this.render.bind(this)),this.render()}onRemove(){this.idleListener&&google.maps.event.removeListener(this.idleListener),this.reset()}reset(){this.markers.forEach(e=>W.setMap(e,null)),this.clusters.forEach(e=>e.delete()),this.clusters=[]}renderClusters(){const e=new re(this.markers,this.clusters),r=this.getMap();this.clusters.forEach(t=>{if(1===t.markers.length)t.marker=t.markers[0];else if(t.marker=this.renderer.render(t,e,r),t.markers.forEach(e=>W.setMap(e,null)),this.onClusterClick){const e=W.isAdvancedMarker(t.marker)?H.GMP_CLICK:H.CLUSTER_CLICK;t.marker.addListener(e,e=>{google.maps.event.trigger(this,H.CLUSTER_CLICK,t),this.onClusterClick(e,t,r)})}W.setMap(t.marker,r)})}},oe={top:60,bottom:60,left:276,right:60},ie=new l,ce=e=>{const r=document.createElement("div");r.style.cssText=`\n background:${g(e.color,"#fb8500")};color:#fff;border-radius:20px;padding:5px 10px;\n font-size:12px;font-weight:600;white-space:nowrap;cursor:pointer;\n box-shadow:0 2px 8px rgba(0,0,0,0.25);border:2px solid rgba(255,255,255,0.4);\n display:inline-flex;align-items:center;gap:6px;\n `;const t=document.createElement("span");t.textContent=e.folder.name;const n=document.createElement("span");return n.style.cssText="background:rgba(0,0,0,0.18);border-radius:10px;padding:1px 5px;font-size:10px;",n.textContent=String(e.eventCount),r.appendChild(t),r.appendChild(n),r},le=(e,r)=>{const t=document.createElement("div");if(t.style.cssText=`\n width:36px;height:36px;cursor:pointer;\n background:${e};border-radius:50% 50% 50% 0;transform:rotate(-45deg);\n border:2px solid white;box-shadow:0 2px 8px rgba(0,0,0,0.3);\n display:flex;align-items:center;justify-content:center;overflow:hidden;\n `,r){const e=document.createElement("img");e.src=p(r)??"",e.style.cssText="width:24px;height:24px;border-radius:50%;object-fit:cover;transform:rotate(45deg);",t.appendChild(e)}return t},ue=({apiKey:l,mapId:d="DEMO_MAP_ID",onExplore:p,logoUrl:g})=>{const y=t(null),k=t(null),v=t(null),x=t(null),w=t(null),E=t([]),C=t([]),M=t(null),j=t(!1),A=t(!1),[L,q]=n(!1),[O,I]=n(!0),[S,_]=n(!1),{folderTree:z,activeFolderId:P,activeFolder:T,visibleEvents:U,setActiveFolderId:N,isLoadingEvents:$}=m(),{organization:B}=c(),F=o(B)["--primary"],Z=`${u}-${B?._id??"unknown"}`,D=t(Z);D.current=Z;const R=s(()=>(e=>{try{const r=sessionStorage.getItem(e);if(!r)return null;const t=JSON.parse(r);if(Array.isArray(t?.center)&&"number"==typeof t.zoom)return t}catch{}return null})(Z),[Z]),G=t(/* @__PURE__ */new Map),V=t(/* @__PURE__ */new Map),K=t(null),W=t(null),J=t(p);J.current=p;const X=(e,r,t,n,s)=>{s.event.addListenerOnce(e,"bounds_changed",()=>{const r=e.getZoom();void 0!==r&&r>n&&e.setZoom(n)}),e.fitBounds(r,t)},H=()=>{E.current.forEach(e=>{e.map=null}),E.current=[]},Q=()=>{M.current&&(M.current.clearMarkers(),M.current=null),C.current.forEach(e=>{e.map=null}),C.current=[]};return r(()=>{if(!y.current||k.current)return;let r=!1;return(async()=>{try{const{setOptions:t,importLibrary:n}=await import("./ob_CTelx.js");if(r)return;if(t({key:l,v:"weekly"}),await Promise.all([n("maps"),n("marker")]),r||!y.current)return;const s=window.google.maps;v.current=s;const a=R?.center?{lng:R.center[0],lat:R.center[1]}:{lat:20,lng:0},o=R?.zoom??3,i=new s.Map(y.current,{mapId:d,renderingType:"VECTOR",mapTypeId:"roadmap",center:a,zoom:o,mapTypeControl:!1,streetViewControl:!1});k.current=i,x.current=new s.InfoWindow({maxWidth:280}),x.current.addListener("closeclick",()=>{w.current&&(e(null,w.current),w.current=null)});const c=()=>{try{const e=i.getCenter();if(!e)return;sessionStorage.setItem(D.current,JSON.stringify({center:[e.lng(),e.lat()],zoom:i.getZoom()}))}catch{}};i.addListener("idle",c),I(!1),q(!0)}catch{r||_(!0)}finally{r||I(!1)}})(),()=>{r=!0,H(),Q(),x.current?.close(),w.current&&(e(null,w.current),w.current=null),k.current=null,v.current=null}},[l]),r(()=>{if(!L)return;const r=k.current,t=v.current;if(!r||!t)return;const n=null===P&&z.length>0,s=!n&&0===z.length&&null===P,o=n?"folders":s?"all-events":"folder-events";if(K.current!==o&&(H(),Q(),V.current.clear(),G.current.clear(),W.current=null,x.current?.close(),K.current=o),n){const e=[],n=r=>{for(const t of r)t.centroid?e.push(t):t.children.length>0&&n(t.children)};n(z);const s=new Set(e.map(e=>e.folder._id));for(const[r,t]of V.current)s.has(r)||(t.map=null,V.current.delete(r));E.current=Array.from(V.current.values());for(const a of e){const e=V.current.get(a.folder._id);if(e){e.position={lng:a.centroid[0],lat:a.centroid[1]};continue}const n=ce(a),s=new t.marker.AdvancedMarkerElement({map:r,position:{lng:a.centroid[0],lat:a.centroid[1]},content:n,gmpClickable:!0});s.addListener("click",()=>N(a.folder._id)),V.current.set(a.folder._id,s),E.current.push(s)}}else{if(0===U.length){for(const e of G.current.values())"all-events"===o?M.current?.removeMarker(e,!0):e.map=null;return G.current.clear(),void(C.current=[])}const n=s?F:T?.color||F,c=`${n}|${g??""}`,l=W.current!==c;W.current=c;const u=new Set(U.map(e=>String(e._id))),m=[];for(const[e,r]of G.current)u.has(e)||(m.push(r),G.current.delete(e));m.length>0&&M.current?.removeMarkers(m,!0);const d=[],p=new t.LatLngBounds;U.forEach(s=>{const o=String(s._id),c=s.location.y,u=s.location.x;p.extend({lat:c,lng:u});const m=G.current.get(o);if(m)return m.position={lat:c,lng:u},void(l&&(m.content=le(n,g)));const h=le(n,g),b=new t.marker.AdvancedMarkerElement({map:r,position:{lat:c,lng:u},content:h,gmpClickable:!0});b.addListener("click",()=>{w.current&&e(null,w.current);const t=document.createElement("div");((r,t)=>{e(/* @__PURE__ */a(i,{client:ie,children:/* @__PURE__ */a(f,{event:r,onExplore:e=>J.current?.(e)})}),t)})(s,t),x.current?.close(),x.current?.setContent(t),x.current?.open({anchor:b,map:r}),w.current=t}),G.current.set(o,b),d.push(b)}),C.current=Array.from(G.current.values()),l&&M.current&&(M.current.clearMarkers(),M.current=null),(d.length>0||m.length>0||l)&&(M.current?(d.length>0&&M.current.addMarkers(d,!0),M.current.render()):M.current=new ae({markers:C.current,map:r,renderer:{render:e=>{const{count:r,position:s}=e,a=document.createElement("div"),o=r<10?28:r<30?34:40;return a.style.cssText=`\n width:${o}px;height:${o}px;border-radius:50%;cursor:pointer;\n background:${n};color:#fff;\n display:flex;align-items:center;justify-content:center;\n font-size:13px;font-weight:700;\n box-shadow:0 2px 8px rgba(0,0,0,0.3);\n border:2px solid rgba(255,255,255,0.6);\n `,a.textContent=String(r),new t.marker.AdvancedMarkerElement({position:s,content:a,gmpClickable:!0,zIndex:1e6+r})}}})),s&&(A.current||(A.current=!0,R||p.isEmpty()||X(r,p,oe,8,t)))}},[P,z,U,L,g,N,T,R]),r(()=>{if(!L)return;const e=k.current,r=v.current;if(e&&r)if(j.current||!R){if(j.current=!0,P){const t=h(z,P);if(!t?.folder.boundary?.length)return;const n=new r.LatLngBounds;for(const e of t.folder.boundary)n.extend({lat:e.y,lng:e.x});n.isEmpty()||X(e,n,oe,14,r)}else if(z.length>0){const t=new r.LatLngBounds,n=e=>{for(const r of e)r.centroid?t.extend({lng:r.centroid[0],lat:r.centroid[1]}):n(r.children)};n(z),t.isEmpty()||X(e,t,oe,8,r)}}else j.current=!0},[P,z,L,R]),/* @__PURE__ */a("div",{class:"relative h-screen w-full sm:h-[calc(100vh-4rem)]",style:o(B),children:[
2
2
  /* @__PURE__ */a(b,{positionClass:"absolute top-3 left-16 z-[1000]",folderTree:z,activeFolderId:P,setActiveFolderId:N}),$&&/* @__PURE__ */a("div",{class:"absolute inset-0 z-10 flex items-center justify-center bg-white/60",children:/* @__PURE__ */a("div",{class:"border-primary size-10 animate-spin rounded-full border-4 border-t-transparent"})}),O&&/* @__PURE__ */a("div",{class:"absolute inset-0 z-20 flex items-center justify-center bg-white/85",children:/* @__PURE__ */a("div",{class:"flex flex-col items-center gap-3",children:[/* @__PURE__ */a("div",{class:"border-primary size-10 animate-spin rounded-full border-4 border-t-transparent"}),/* @__PURE__ */a("p",{class:"text-sm font-medium text-slate-700",children:"Loading map…"})]})}),S&&!O&&/* @__PURE__ */a("div",{class:"absolute inset-0 z-20 flex items-center justify-center bg-white/90",children:/* @__PURE__ */a("div",{class:"max-w-sm px-6 text-center",children:[/* @__PURE__ */a("p",{class:"font-medium text-slate-800",children:"Google Maps could not be loaded."}),/* @__PURE__ */a("p",{class:"mt-1 text-sm text-slate-600",children:"Check the organization API key and allowed referrer domains."})]})}),
3
3
  /* @__PURE__ */a("div",{ref:y,class:"size-full"})]})};export{ue as default};