@chaibuilder/sdk 1.2.26 → 1.2.27

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 (95) hide show
  1. package/dist/AddBlocks-S-4jzdWv.cjs +1 -0
  2. package/dist/{AddBlocks-l1JENNvq.js → AddBlocks-ksZjjn0k.js} +6 -7
  3. package/dist/BrandingOptions-EMCT0Wa3.cjs +1 -0
  4. package/dist/{BrandingOptions-udtH5yJs.js → BrandingOptions-T_kbQFQv.js} +5 -6
  5. package/dist/{CanvasArea-zme1r3Zi.cjs → CanvasArea-SDzbubar.cjs} +2 -2
  6. package/dist/{CanvasArea-h0W-Tyha.js → CanvasArea-rhOeubmu.js} +7 -8
  7. package/dist/{Class-lGzsNBOK.js → Class-3k8xjeiM.js} +1 -1
  8. package/dist/{Class-PoYusiA5.cjs → Class-MmCxz2Ay.cjs} +1 -1
  9. package/dist/{CurrentPage-tJUjXWdb.js → CurrentPage-0eeU1V_c.js} +8 -9
  10. package/dist/CurrentPage-aTjWjc3o.cjs +1 -0
  11. package/dist/{ListTree-cZ-Ihlt3.js → ListTree-Muu4rAtp.js} +8 -9
  12. package/dist/ListTree-SWsqdfcG.cjs +1 -0
  13. package/dist/MODIFIERS-9EwxLM8V.cjs +1 -0
  14. package/dist/{MODIFIERS-dytZ-osO.js → MODIFIERS-WQdaNvb8.js} +8 -4
  15. package/dist/PagesPanel-n3x-0ozR.cjs +1 -0
  16. package/dist/{PagesPanel-6rrLXEO-.js → PagesPanel-rYN28QpN.js} +8 -9
  17. package/dist/{ProjectPanel-tz3bjdXy.js → ProjectPanel-ivFOhdcz.js} +13 -14
  18. package/dist/ProjectPanel-pBePMOta.cjs +1 -0
  19. package/dist/Settings-JRyJayf5.cjs +1 -0
  20. package/dist/{Settings-4s2LUVmC.js → Settings-XWmKzRl9.js} +6 -7
  21. package/dist/SidePanels-BtUeo6M9.cjs +1 -0
  22. package/dist/{SidePanels-bugFfInz.js → SidePanels-ODktnGbC.js} +16 -17
  23. package/dist/Topbar-QMeD3hvq.cjs +1 -0
  24. package/dist/{Topbar-pWzBEOed.js → Topbar-Yunooh00.js} +5 -6
  25. package/dist/UnsplashImages-05JR8oIu.cjs +1 -0
  26. package/dist/{UnsplashImages-qvwFbV-E.js → UnsplashImages-QMl0bxix.js} +15 -16
  27. package/dist/UploadImages-OgSN1HVt.cjs +1 -0
  28. package/dist/{UploadImages-9NapgXBq.js → UploadImages-Si-A26bc.js} +10 -11
  29. package/dist/add-page-modal-9pTKItY-.cjs +1 -0
  30. package/dist/{add-page-modal-k2Kb92HS.js → add-page-modal-U7AUUrI1.js} +24 -25
  31. package/dist/confirm-alert-DhRc-Zcd.cjs +1 -0
  32. package/dist/{confirm-alert-GUhZ_G8w.js → confirm-alert-kV5-c70T.js} +5 -6
  33. package/dist/core.cjs +1 -1
  34. package/dist/core.js +46 -47
  35. package/dist/defaultTheme-7Lk2zq60.cjs +1 -0
  36. package/dist/{defaultTheme-D8B4-wHO.js → defaultTheme-gunU_Fe5.js} +1 -1
  37. package/dist/delete-page-modal-4s-6AIy4.cjs +1 -0
  38. package/dist/{delete-page-modal-zONvdebd.js → delete-page-modal-UCBpdjLe.js} +8 -9
  39. package/dist/email-blocks.cjs +1 -1
  40. package/dist/email-blocks.js +1 -1
  41. package/dist/email.cjs +1 -1
  42. package/dist/email.js +6 -7
  43. package/dist/{form-lBQ_76Uw.cjs → form-Ap63cNec.cjs} +1 -1
  44. package/dist/{form-STUz-6nE.js → form-zmlTjM9j.js} +1 -1
  45. package/dist/html-to-json-C_Eobs_d.cjs +1 -0
  46. package/dist/{html-to-json-ngX9ef2u.js → html-to-json-p__Fgqdg.js} +75 -50
  47. package/dist/{index-Gk6sASBd.js → index-CFUoB97-.js} +128 -129
  48. package/dist/index-F4AQQ6qq.cjs +1 -0
  49. package/dist/{index-mbyqq81O.cjs → index-Qk028f-N.cjs} +1 -1
  50. package/dist/{index-llTXLDGE.js → index-f0AbmoYY.js} +4 -4
  51. package/dist/{index-OB199Izc.cjs → index-l19JVVXI.cjs} +2 -2
  52. package/dist/{index-SkyM3d6Q.js → index-lOJfSheQ.js} +2 -2
  53. package/dist/lib.cjs +3 -3
  54. package/dist/lib.js +16 -17
  55. package/dist/page-viewer-YFrIG3L7.cjs +1 -0
  56. package/dist/{page-viewer-Pdg9F5Hv.js → page-viewer-jOwy--9A.js} +9 -10
  57. package/dist/{project-general-setting-f8Ebsn6K.js → project-general-setting-3N8HZ2fe.js} +9 -10
  58. package/dist/project-general-setting-hK7I7FuN.cjs +1 -0
  59. package/dist/{project-seo-setting-pX34Qsym.js → project-seo-setting-bSiNgO_1.js} +6 -7
  60. package/dist/project-seo-setting-x-FK0pez.cjs +1 -0
  61. package/dist/render.cjs +1 -1
  62. package/dist/render.js +13 -14
  63. package/dist/{single-page-detail-dpe5LT0M.js → single-page-detail--AZlZ-pC.js} +10 -11
  64. package/dist/single-page-detail-9abF2g2R.cjs +1 -0
  65. package/dist/studio.cjs +1 -1
  66. package/dist/studio.js +7 -8
  67. package/dist/ui.cjs +1 -1
  68. package/dist/ui.js +137 -138
  69. package/dist/web-blocks.cjs +1 -6
  70. package/dist/web-blocks.js +385 -486
  71. package/package.json +1 -1
  72. package/dist/AddBlocks-zPPKkeKs.cjs +0 -1
  73. package/dist/BrandingOptions-DkpqGARR.cjs +0 -1
  74. package/dist/CurrentPage-Hl52iub_.cjs +0 -1
  75. package/dist/ListTree-WvTjY5rr.cjs +0 -1
  76. package/dist/MODIFIERS-0g14w5RS.cjs +0 -1
  77. package/dist/PagesPanel-WzCocl6u.cjs +0 -1
  78. package/dist/ProjectPanel-o7gdcwPn.cjs +0 -1
  79. package/dist/STRINGS--j49GZJP.js +0 -7
  80. package/dist/STRINGS-gPz7CUOk.cjs +0 -1
  81. package/dist/Settings-AqoKwR92.cjs +0 -1
  82. package/dist/SidePanels-3o6Okmvu.cjs +0 -1
  83. package/dist/Topbar-CqW7G360.cjs +0 -1
  84. package/dist/UnsplashImages-NGskB93R.cjs +0 -1
  85. package/dist/UploadImages-Oh7Glr9A.cjs +0 -1
  86. package/dist/add-page-modal--6TTBRYa.cjs +0 -1
  87. package/dist/confirm-alert-C4M9eF-o.cjs +0 -1
  88. package/dist/defaultTheme-7VqqhOcp.cjs +0 -1
  89. package/dist/delete-page-modal-cFoL-wdo.cjs +0 -1
  90. package/dist/html-to-json-efmv1pCj.cjs +0 -1
  91. package/dist/index-h-hd6EvN.cjs +0 -1
  92. package/dist/page-viewer-2kwnKM6v.cjs +0 -1
  93. package/dist/project-general-setting-CnNL98NM.cjs +0 -1
  94. package/dist/project-seo-setting-mlxL_e2_.cjs +0 -1
  95. package/dist/single-page-detail-XfzrGlzA.cjs +0 -1
@@ -0,0 +1 @@
1
+ "use strict";const k=require("react"),i=require("lodash-es"),ne=require("./Functions-N3yhPYKY.cjs"),Se=require("@chaibuilder/runtime"),p=require("jotai"),K=require("./MODIFIERS-9EwxLM8V.cjs"),nn=require("./_commonjsHelpers-wDK0ZLPo.cjs"),rn=require("@react-hookz/web"),u=require("./Class-MmCxz2Ay.cjs");require("react-i18next");const r=require("./jsx-runtime-Z_BpKhVy.cjs"),an=require("@radix-ui/react-toggle"),ce=require("class-variance-authority"),ln=require("@radix-ui/react-switch"),cn=require("@radix-ui/react-slot"),dn=require("@radix-ui/react-accordion"),G=require("@radix-ui/react-icons"),un=require("@radix-ui/react-alert-dialog"),mn=require("@radix-ui/react-dialog"),pn=require("@radix-ui/react-label"),fn=require("@radix-ui/react-scroll-area"),xn=require("@radix-ui/react-tabs"),gn=require("@radix-ui/react-tooltip"),hn=require("@radix-ui/react-popover"),bn=require("@radix-ui/react-menubar"),vn=require("@radix-ui/react-hover-card"),yn=require("@radix-ui/react-select"),jn=require("@radix-ui/react-dropdown-menu"),wn=require("@radix-ui/react-separator"),Rn=require("@radix-ui/react-toast"),J=require("cmdk"),kn=require("@radix-ui/react-context-menu"),jt=require("react-icons-picker"),Nn=require("react-dom"),Sn=require("react-quill");function U(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,o.get?o:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const f=U(k),wt=U(an),De=U(ln),le=U(dn),W=U(un),P=U(mn),Rt=U(pn),ae=U(fn),de=U(xn),pe=U(gn),he=U(hn),B=U(bn),Ce=U(vn),F=U(yn),M=U(jn),kt=U(wn),X=U(Rn),D=U(kn);var q={BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};let Cn=0;function ee(e,t){const s=`atom${++Cn}`,o={toString:()=>s};return typeof e=="function"?o.read=e:(o.init=e,o.read=n=>n(o),o.write=(n,l,a)=>l(o,typeof a=="function"?a(n(o)):a)),t&&(o.write=t),o}const Be=e=>"init"in e,Te=e=>!!e.write,Re=new WeakMap,En=(e,t)=>{Re.set(e,t),e.catch(()=>{}).finally(()=>Re.delete(e))},lt=(e,t)=>{const s=Re.get(e);s&&(Re.delete(e),s(t))},ct=(e,t)=>{e.status="fulfilled",e.value=t},dt=(e,t)=>{e.status="rejected",e.reason=t},An=e=>typeof(e==null?void 0:e.then)=="function",xe=(e,t)=>"v"in e&&"v"in t&&Object.is(e.v,t.v),ut=(e,t)=>"e"in e&&"e"in t&&Object.is(e.e,t.e),me=e=>"v"in e&&e.v instanceof Promise,_n=(e,t)=>"v"in e&&"v"in t&&e.v.orig&&e.v.orig===t.v.orig,ye=e=>{if("e"in e)throw e.e;return e.v},Nt=()=>{const e=new WeakMap,t=new WeakMap,s=new Map;let o,n,l;(q?"production":void 0)!=="production"&&(o=new Set,n=new Set,l=new Set);const a=m=>e.get(m),d=(m,h)=>{(q?"production":void 0)!=="production"&&Object.freeze(h);const y=e.get(m);if(e.set(m,h),s.has(m)||s.set(m,y),y&&me(y)){const b="v"in h?h.v instanceof Promise?h.v:Promise.resolve(h.v):Promise.reject(h.e);lt(y.v,b)}},g=(m,h,y)=>{const b=new Map;let w=!1;y.forEach((v,N)=>{!v&&N===m&&(v=h),v?(b.set(N,v),h.d.get(N)!==v&&(w=!0)):(q?"production":void 0)!=="production"&&console.warn("[Bug] atom state not found")}),(w||h.d.size!==b.size)&&(h.d=b)},c=(m,h,y)=>{const b=a(m),w={d:(b==null?void 0:b.d)||new Map,v:h};if(y&&g(m,w,y),b&&xe(b,w)&&b.d===w.d)return b;if(b&&me(b)&&me(w)&&_n(b,w)){if(b.d===w.d)return b;w.v=b.v}return d(m,w),w},x=(m,h,y,b)=>{if(An(h)){let w;const v=new Promise((N,L)=>{let E=!1;h.then(T=>{if(!E){E=!0;const A=a(m),Z=c(m,v,y);ct(v,T),N(T),(A==null?void 0:A.d)!==Z.d&&H(m,Z,A==null?void 0:A.d)}},T=>{if(!E){E=!0;const A=a(m),Z=c(m,v,y);dt(v,T),L(T),(A==null?void 0:A.d)!==Z.d&&H(m,Z,A==null?void 0:A.d)}}),w=T=>{E||(E=!0,T.then(A=>ct(v,A),A=>dt(v,A)),N(T))}});return v.orig=h,v.status="pending",En(v,N=>{N&&w(N),b==null||b()}),c(m,v,y)}return c(m,h,y)},R=(m,h,y)=>{const b=a(m),w={d:(b==null?void 0:b.d)||new Map,e:h};return y&&g(m,w,y),b&&ut(b,w)&&b.d===w.d?b:(d(m,w),w)},S=m=>{const h=a(m);if(h&&(h.d.forEach((E,T)=>{T!==m&&!t.has(T)&&S(T)}),Array.from(h.d).every(([E,T])=>{const A=a(E);return E===m||A===T||A&&!me(A)&&xe(A,T)})))return h;const y=new Map;let b=!0;const w=E=>{if(E===m){const A=a(E);if(A)return y.set(E,A),ye(A);if(Be(E))return y.set(E,void 0),E.init;throw new Error("no atom init")}const T=S(E);return y.set(E,T),ye(T)};let v,N;const L={get signal(){return v||(v=new AbortController),v.signal},get setSelf(){return(q?"production":void 0)!=="production"&&!Te(m)&&console.warn("setSelf function cannot be used with read-only atom"),!N&&Te(m)&&(N=(...E)=>{if((q?"production":void 0)!=="production"&&b&&console.warn("setSelf function cannot be called in sync"),!b)return $(m,...E)}),N}};try{const E=m.read(w,L);return x(m,E,y,()=>v==null?void 0:v.abort())}catch(E){return R(m,E,y)}finally{b=!1}},j=m=>ye(S(m)),C=m=>{let h=t.get(m);return h||(h=z(m)),h},O=(m,h)=>!h.l.size&&(!h.t.size||h.t.size===1&&h.t.has(m)),V=m=>{const h=t.get(m);h&&O(m,h)&&Q(m)},_=m=>{const h=new Map,y=new WeakMap,b=v=>{const N=t.get(v);N==null||N.t.forEach(L=>{L!==v&&(h.set(L,(h.get(L)||new Set).add(v)),y.set(L,(y.get(L)||0)+1),b(L))})};b(m);const w=v=>{const N=t.get(v);N==null||N.t.forEach(L=>{var E;if(L!==v){let T=y.get(L);if(T&&y.set(L,--T),!T){let A=!!((E=h.get(L))!=null&&E.size);if(A){const Z=a(L),on=S(L);A=!Z||!xe(Z,on)}A||h.forEach(Z=>Z.delete(L))}w(L)}})};w(m)},I=(m,...h)=>{let y=!0;const b=N=>ye(S(N)),w=(N,...L)=>{let E;if(N===m){if(!Be(N))throw new Error("atom not writable");const T=a(N),A=x(N,L[0]);(!T||!xe(T,A))&&_(N)}else E=I(N,...L);if(!y){const T=Y();(q?"production":void 0)!=="production"&&n.forEach(A=>A({type:"async-write",flushed:T}))}return E},v=m.write(b,w,...h);return y=!1,v},$=(m,...h)=>{const y=I(m,...h),b=Y();return(q?"production":void 0)!=="production"&&n.forEach(w=>w({type:"write",flushed:b})),y},z=(m,h)=>{const y={t:new Set(h&&[h]),l:new Set};if(t.set(m,y),(q?"production":void 0)!=="production"&&l.add(m),S(m).d.forEach((b,w)=>{const v=t.get(w);v?v.t.add(m):w!==m&&z(w,m)}),S(m),Te(m)&&m.onMount){const b=m.onMount((...w)=>$(m,...w));b&&(y.u=b)}return y},Q=m=>{var h;const y=(h=t.get(m))==null?void 0:h.u;y&&y(),t.delete(m),(q?"production":void 0)!=="production"&&l.delete(m);const b=a(m);b?(me(b)&&lt(b.v),b.d.forEach((w,v)=>{if(v!==m){const N=t.get(v);N&&(N.t.delete(m),O(v,N)&&Q(v))}})):(q?"production":void 0)!=="production"&&console.warn("[Bug] could not find atom state to unmount",m)},H=(m,h,y)=>{const b=new Set(h.d.keys());y==null||y.forEach((w,v)=>{if(b.has(v)){b.delete(v);return}const N=t.get(v);N&&(N.t.delete(m),O(v,N)&&Q(v))}),b.forEach(w=>{const v=t.get(w);v?v.t.add(m):t.has(m)&&z(w,m)})},Y=()=>{let m;for((q?"production":void 0)!=="production"&&(m=new Set);s.size;){const h=Array.from(s);s.clear(),h.forEach(([y,b])=>{const w=a(y);if(w){w.d!==(b==null?void 0:b.d)&&H(y,w,b==null?void 0:b.d);const v=t.get(y);v&&!(b&&!me(b)&&(xe(b,w)||ut(b,w)))&&(v.l.forEach(N=>N()),(q?"production":void 0)!=="production"&&m.add(y))}else(q?"production":void 0)!=="production"&&console.warn("[Bug] no atom state to flush")})}if((q?"production":void 0)!=="production")return o.forEach(h=>h("state")),m},oe=(m,h)=>{const y=C(m),b=Y(),w=y.l;return w.add(h),(q?"production":void 0)!=="production"&&(o.forEach(v=>v("sub")),n.forEach(v=>v({type:"sub",flushed:b}))),()=>{w.delete(h),V(m),(q?"production":void 0)!=="production"&&(o.forEach(v=>v("unsub")),n.forEach(v=>v({type:"unsub"})))}};return(q?"production":void 0)!=="production"?{get:j,set:$,sub:oe,dev_subscribe_store:(m,h)=>h!==2?(console.warn("The current StoreListener revision is 2. The older ones are deprecated."),o.add(m),()=>{o.delete(m)}):(n.add(m),()=>{n.delete(m)}),dev_get_mounted_atoms:()=>l.values(),dev_get_atom_state:m=>e.get(m),dev_get_mounted:m=>t.get(m),dev_restore_atoms:m=>{for(const[y,b]of m)Be(y)&&(x(y,b),_(y));const h=Y();n.forEach(y=>y({type:"restore",flushed:h}))}}:{get:j,set:$,sub:oe}};let Pe;const Bn=()=>(Pe||(Pe=Nt()),Pe);var Tn={BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const Pn=k.createContext(void 0),Fe=e=>{const t=k.useContext(Pn);return(e==null?void 0:e.store)||t||Bn()};const In=e=>typeof(e==null?void 0:e.then)=="function",Mn=k.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)});function St(e,t){const s=Fe(t),[[o,n,l],a]=k.useReducer(c=>{const x=s.get(e);return Object.is(c[0],x)&&c[1]===s&&c[2]===e?c:[x,s,e]},void 0,()=>[s.get(e),s,e]);let d=o;(n!==s||l!==e)&&(a(),d=s.get(e));const g=t==null?void 0:t.delay;return k.useEffect(()=>{const c=s.sub(e,()=>{if(typeof g=="number"){setTimeout(a,g);return}a()});return a(),c},[s,e,g]),k.useDebugValue(d),In(d)?Mn(d):d}function Ct(e,t){const s=Fe(t);return k.useCallback((...n)=>{if((Tn?"production":void 0)!=="production"&&!("write"in e))throw new Error("not writable atom");return s.set(e,...n)},[s,e])}function Dn(e,t){return[St(e,t),Ct(e,t)]}var Ue={BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const Et=Symbol();const mt=(e,t,s)=>(t.has(s)?t:t.set(s,e())).get(s),On=new WeakMap,Ln=(e,t,s)=>{const o=mt(()=>new WeakMap,On,t);return mt(e,o,s)},zn={},pt=e=>!!e.write,Vn=e=>typeof e=="function";function Fn(e,t){return Ln(()=>{const s=new WeakMap,o=(a,d)=>{let g=s.get(a);if(g)return g;const c=d&&s.get(d),x=[],R=[];return a.forEach((S,j)=>{const C=t?t(S):j;R[j]=C;const O=c&&c.atomList[c.keyList.indexOf(C)];if(O){x[j]=O;return}const V=I=>{const $=I(n),z=I(e),H=o(z,$==null?void 0:$.arr).keyList.indexOf(C);if(H<0||H>=z.length){const Y=a[o(a).keyList.indexOf(C)];if(Y)return Y;throw new Error("splitAtom: index out of bounds for read")}return z[H]},_=(I,$,z)=>{const Q=I(n),H=I(e),oe=o(H,Q==null?void 0:Q.arr).keyList.indexOf(C);if(oe<0||oe>=H.length)throw new Error("splitAtom: index out of bounds for write");const m=Vn(z)?z(H[oe]):z;$(e,[...H.slice(0,oe),m,...H.slice(oe+1)])};x[j]=pt(e)?ee(V,_):ee(V)}),c&&c.keyList.length===R.length&&c.keyList.every((S,j)=>S===R[j])?g=c:g={arr:a,atomList:x,keyList:R},s.set(a,g),g},n=ee(a=>{const d=a(n),g=a(e);return o(g,d==null?void 0:d.arr)});(Ue?"production":void 0)!=="production"&&(n.debugPrivate=!0),n.init=void 0;const l=pt(e)?ee(a=>a(n).atomList,(a,d,g)=>{switch(g.type){case"remove":{const c=a(l).indexOf(g.atom);if(c>=0){const x=a(e);d(e,[...x.slice(0,c),...x.slice(c+1)])}break}case"insert":{const c=g.before?a(l).indexOf(g.before):a(l).length;if(c>=0){const x=a(e);d(e,[...x.slice(0,c),g.value,...x.slice(c)])}break}case"move":{const c=a(l).indexOf(g.atom),x=g.before?a(l).indexOf(g.before):a(l).length;if(c>=0&&x>=0){const R=a(e);c<x?d(e,[...R.slice(0,c),...R.slice(c+1,x),R[c],...R.slice(x)]):d(e,[...R.slice(0,x),R[c],...R.slice(x,c),...R.slice(c+1)])}break}}}):ee(a=>a(n).atomList);return l},e,t||zn)}function Un(e){const t=Symbol(),s=ee(t);(Ue?"production":void 0)!=="production"&&(s.debugPrivate=!0);const o=ee((n,l)=>{const a=n(s);return a!==t?a:e(n,l)},(n,l,a)=>{if(a===Et)l(s,t);else if(typeof a=="function"){const d=n(o);l(s,a(d))}else l(s,a)});return o}const qn=e=>typeof(e==null?void 0:e.then)=="function";function $n(e){let t,s;const o={getItem:(n,l)=>{var a,d;const g=x=>{if(x=x||"",t!==x){try{s=JSON.parse(x)}catch{return l}t=x}return s},c=(d=(a=e())==null?void 0:a.getItem(n))!=null?d:null;return qn(c)?c.then(g):g(c)},setItem:(n,l)=>{var a;return(a=e())==null?void 0:a.setItem(n,JSON.stringify(l))},removeItem:n=>{var l;return(l=e())==null?void 0:l.removeItem(n)}};return typeof window<"u"&&typeof window.addEventListener=="function"&&(o.subscribe=(n,l,a)=>{if(!(e()instanceof window.Storage))return()=>{};const d=g=>{if(g.storageArea===e()&&g.key===n){let c;try{c=JSON.parse(g.newValue||"")}catch{c=a}l(c)}};return window.addEventListener("storage",d),()=>{window.removeEventListener("storage",d)}}),o}const Gn=$n(()=>typeof window<"u"?window.localStorage:void 0);function fe(e,t,s=Gn,o){const n=o==null?void 0:o.unstable_getOnInit,l=ee(n?s.getItem(e,t):t);return(Ue?"production":void 0)!=="production"&&(l.debugPrivate=!0),l.onMount=d=>{n||d(s.getItem(e,t));let g;return s.subscribe&&(g=s.subscribe(e,d,t)),g},ee(d=>d(l),(d,g,c)=>{const x=typeof c=="function"?c(d(l)):c;return x===Et?(g(l,t),s.removeItem(e)):x instanceof Promise?x.then(R=>(g(l,R),s.setItem(e,R))):(g(l,x),s.setItem(e,x))})}const qe=p.atom(null);qe.debugLabel="chaiBuilderPropsAtom";const At=p.atom({});At.debugLabel="chaiExternalDataAtom";const Wn=()=>!1,Hn=e=>{const t=e.replace(K.STYLES_KEY,"").split(",");return{baseClasses:t[0],classes:t[1]}},Oe=i.memoize((e,t)=>{if(!e)return!0;const s=Se.getBlockComponent(e);return s&&i.has(s,"canAcceptBlock")?s.canAcceptBlock(t):!1}),Yn=i.memoize((e,t)=>{const s=Se.getBlockComponent(t);return s&&i.has(s,"canBeNested")?s.canBeNested(e):!0}),Kn=i.memoize(e=>{const t=Se.getBlockComponent(e);return t&&i.has(t,"canDuplicate")?t.canDuplicate():!0}),Jn=i.memoize(e=>{const t=Se.getBlockComponent(e);return t&&i.has(t,"canDelete")?t.canDelete():!0});function _t(e,t,s){const o=i.filter(e,l=>l._parent===t),n=[];for(let l=0;l<o.length;l++){const a=Tt(o[l]);if(Object.keys(a).length>0&&Object.keys(a).forEach(d=>{o[l][d]=`slot:${ne.generateUUID()}`}),i.filter(e,{_parent:o[l]._id}).length>0){const d=ne.generateUUID();n.push({...o[l],oldId:o[l]._id,_id:d,_parent:s}),n.push(i.flatten(_t(e,o[l]._id,d)))}else n.push({...o[l],oldId:o[l]._id,_id:ne.generateUUID(),_parent:s})}return i.flatten(n)}function Bt(e){const t={};e.forEach(o=>{t[o._id]={...o,children:[]}});const s=[];return e.forEach(o=>{if(o._parent){const n=t[o._parent];n&&n.children.push(t[o._id])}else s.push(t[o._id])}),s}const Tt=e=>{const t={};return Object.keys(e).forEach(s=>{i.isString(e[s])&&e[s].startsWith("slot")&&(t[s]=e[s].replace("slot:",""))}),t},Qn=(e,t,s=null)=>{let o=i.find(e,{_id:t});o={...o,oldId:o._id,_id:ne.generateUUID()},s&&(o={...o,_parent:s});const n=[o];i.filter(e,{_parent:t}).length>0&&n.push(i.flatten(_t(e,t,o._id)));const l=i.flatten(n);return i.map(l,a=>{const d=a,g=Tt(d);return Object.keys(g).length>0&&Object.keys(g).forEach(c=>{const x=i.find(l,{oldId:g[c].replace("slot:","")});d[c]=`slot:${x._id}`}),i.omit(d,["global","oldId"])})};const te=p.atom([]);te.debugLabel="presentBlocksAtom";const Pt=p.atom(e=>{const t=e(te);return Bt([...t])});Pt.debugLabel="treeDSBlocks";te.debugLabel="presentBlocksAtom";const $e=Fn(te);$e.debugLabel="pageBlocksAtomsAtom";const Xn=p.atom("");Xn.debugLabel="builderActivePageAtom";const Zn=p.atom(-1);Zn.debugLabel="destinationDropIndexAtom";const It=p.atom([]);It.debugLabel="buildingBlocksAtom";const er=p.atom(e=>{const t=e(It);return i.filter(t,s=>i.has(s,"blockId"))});er.debugLabel="globalBlocksAtom";const Ge=p.atom([]);Ge.debugLabel="selectedBlockIdsAtom";const We=p.atom(e=>{const t=e(te),s=e(Ge);return i.map(i.filter(t,({_id:o})=>i.includes(s,o)),o=>({...o}))});We.debugLabel="selectedBlocksAtom";const He=p.atom(e=>{const t=e(We);return t.length===0?null:t.length===1?t[0]:{type:"Multiple",id:i.map(t,"id")}});He.debugLabel="selectedBlockAtom";const tr=e=>i.get(e,"parent",null),sr=p.atom(e=>{const t=e(We),s=i.map(t,tr);return i.filter(e(te),o=>i.includes(s,o._id))});sr.debugLabel="selectedBlocksParentsAtom";const Mt=p.atom(()=>!1);Mt.debugLabel="selectedBlockFlexChildAtom";const Dt=p.atom(()=>!1);Dt.debugLabel="selectedBlockGridChildAtom";const Ye=p.atom("");Ye.debugLabel="styleStateAtom";const Ot=fe("styleBreakpoint","xs");Ot.debugLabel="styleBreakpointAtom";const or=()=>({flexChild:p.useAtomValue(Mt),gridChild:p.useAtomValue(Dt)}),nr=()=>p.useAtomValue(He);const be=()=>{const[e,t]=p.useAtom(Ge),s=k.useCallback(o=>{t(n=>i.includes(n,o)?i.without(n,o):[...n,o])},[t]);return[e,t,s]},Le=e=>{switch(e.type){case"singular":return e.uiSchema;case"model":const{properties:t}=e,s={};return Object.keys(t).forEach(l=>{const a=t[l];if(i.includes(["slot","styles"],a.type))return;const d=l;s[d]=Le(a)}),s;case"list":const{itemProperties:o}=e,n={items:{}};return Object.keys(o).forEach(l=>{const a=o[l];if(i.includes(["slot","styles"],a.type))return;const d=l;n.items[d]=Le(a)}),n;default:return{}}},ze=e=>{switch(e.type){case"singular":return e.schema;case"model":const{properties:t,title:s}=e,o={title:s,type:"object",properties:{}};return Object.keys(t).forEach(d=>{const g=t[d];if(i.includes(["slot","styles"],g.type))return;const c=d;o.properties[c]=ze(g)}),o;case"list":const{itemProperties:n,title:l}=e,a={title:l,type:"array",items:{type:"object",properties:{}}};return Object.keys(n).forEach(d=>{const g=n[d];if(i.includes(["slot","styles"],g.type))return;const c=d;a.items.properties[c]=ze(g),i.set(a.items,"title",i.get(g,"itemTitle",`${l} item`))}),a;default:return{}}},Lt=e=>{if(!e)return{};const t={};return Object.keys(e).forEach(s=>{t[s]=ar(e[s])}),t},rr=e=>{if(i.isEmpty(e.default))return[];const{itemProperties:t}=e;return i.map(e.default,s=>{const o={...s};return i.forIn(s,(n,l)=>{i.has(t,l)&&i.get(t[l],"i18n",!1)&&(o[l]=K.I18N_KEY)}),o})},ar=e=>{switch(e.type){case"styles":return e.default;case"slot":return`${K.SLOT_KEY}${ne.generateUUID()}`;case"singular":const{i18n:t,schema:s}=e;return t?K.I18N_KEY:i.get(s,"default","");case"model":return Lt(e.properties);case"list":return rr(e);default:return""}};var Ke={exports:{}},mi=Ke.exports;(function(e){(function(){"use strict";function t(o,n,l){return o.splice(n,!l||1+l-n+(!(l<0^n>=0)&&(l<0||-1)*o.length)),o.length}let s=function(){let o=[],n=-1,l=0,a=!1,d;function g(c,x){return!c||typeof c[x]!="function"?this:(a=!0,c[x](),a=!1,this)}return{add:function(c){return a?this:(o.splice(n+1,o.length-n),o.push(c),l&&o.length>l&&t(o,0,-(l+1)),n=o.length-1,d&&d(),this)},setCallback:function(c){d=c},undo:function(){let c=o[n];if(!c)return this;const x=c.groupId;for(;c.groupId===x&&(g(c,"undo"),n-=1,c=o[n],!(!c||!c.groupId)););return d&&d(),this},redo:function(){let c=o[n+1];if(!c)return this;const x=c.groupId;for(;c.groupId===x&&(g(c,"redo"),n+=1,c=o[n+1],!(!c||!c.groupId)););return d&&d(),this},clear:function(){let c=o.length;o=[],n=-1,d&&c>0&&d()},hasUndo:function(){return n!==-1},hasRedo:function(){return n<o.length-1},getCommands:function(c){return c?o.filter(x=>x.groupId===c):o},getIndex:function(){return n},setLimit:function(c){l=c}}};e.exports?e.exports=s:window.UndoManager=s})()})(Ke);var ir=Ke.exports;const lr=nn.getDefaultExportFromCjs(ir),cr=p.atom(K.BRANDING_OPTIONS_DEFAULTS),dr=p.atom(null),Je=()=>{const[e,t]=p.useAtom(cr);return[i.isObject(e)?{...K.BRANDING_OPTIONS_DEFAULTS,...e}:K.BRANDING_OPTIONS_DEFAULTS,t]},ur=()=>p.useAtom(dr),mr=p.atom(null),zt=()=>({currentPage:p.useAtomValue(mr)});function pr(e){return Bt(e)}const Qe=(e,t)=>i.flatten(e.map(s=>{if(s=t?{...s,parent:t}:{...s},s.children){const o=[...s.children];return delete s.children,i.flatten([s,...Qe(o,s._id)])}return s}));function Xe(e,t=!1){for(let s=0;s<e.length;s++){const o=e[s];o.global&&!t?e[s]={type:"GlobalBlock",blockId:o.blockId,_parent:i.get(o,"parent",null),_id:o._id}:o.children&&o.children.length&&Xe(o.children)}}function Vt(e){let t=[],s=i.filter(e,{type:"GlobalBlock"});return s.length>0&&(s=i.map(s,Ft),i.each(s,o=>{t=[...t,...fr(o)]})),t}function fr(e){let t=[];const s=i.get(i.first(e),"parent",null);i.set(i.first(e),"parent",null);const o=[flatToNestedInstance.convert(Ut(e))];Xe(o,!0);let n=Qe(o,e[0]._id);return n=i.set(n,"0.parent",s),t=[...t,n,...Vt(n)],t}function Ft(e){const t=i.find(Ve,{_id:e._id});if(!t)return[];const s=[t],o=i.filter(Ve,{_parent:e._id});return o.length?i.flatten([...s,...i.flatten(i.map(o,Ft))]):i.flatten(s)}const Ut=e=>JSON.parse(JSON.stringify(e));let Ve=[];function xr(e){Ve=e;const t=pr(Ut(e));Xe(t);const s=Qe(t,null),o=Vt(s),n={};return i.each(o,l=>i.set(n,i.first(l).blockId,l)),[s,n]}const qt=()=>{const[e]=Je(),{currentPage:t}=zt(),[s]=ue();return k.useCallback(()=>{const o=i.map(s,l=>i.omit(l,["expanded","order","title","siblings","tempClasses"])),[n=[]]=xr(o);return{currentPage:t,blocks:n}},[e,t,s])},ie=(e,t=void 0)=>{const s=p.useAtomValue(qe);return i.get(s,e,t)},Ze=p.atom([]);Ze.debugLabel="dataProvidersAtom";const $t=()=>p.useAtom(Ze),Ee=p.atom("SAVED");Ee.debugLabel="builderSaveStateAtom";const gr=()=>{const[e,t]=p.useAtom(Ee),s=ie("onSavePage",async c=>{}),o=ie("onSave",async c=>{}),n=ie("onSaveStateChange",i.noop),l=qt(),[a]=$t(),[d]=Je();return{savePage:rn.useThrottledCallback(async()=>{t("SAVING"),n("SAVING");const c=l();return await s({blocks:c.blocks,providers:a}),await o({blocks:c.blocks,providers:a,brandingOptions:d}),setTimeout(()=>{t("SAVED"),n("SAVED")},100),!0},[l,t,d,o,n],3e3),saveState:e,setSaveState:t}},se=new lr;se.setLimit(50);const et=()=>{const[,e]=p.useAtom(Ee),t=ie("onSaveStateChange",i.noop);return k.useEffect(()=>(se.setCallback(()=>{e("UNSAVED"),t("UNSAVED")}),()=>{se.setCallback(i.noop)}),[]),{add:se.add,undo:se.undo,redo:se.redo,hasRedo:se.hasRedo,hasUndo:se.hasUndo,clear:se.clear}},tt=(e,t)=>{const s=[],o=i.filter(e,n=>i.includes(t,n._id)||i.includes(t,n._parent)?(s.push(n._id),!1):!0);return i.isEmpty(s)?o:tt(o,s)},hr=()=>{const[e]=ue(),[t,s]=be(),{setNewBlocks:o}=re();return k.useCallback(n=>{var a;const l=((a=i.find(e,{_id:n[0]}))==null?void 0:a._parent)||null;o(tt(e,n)),setTimeout(()=>s(l?[l]:[]),200)},[e,s,t])};function br(e,t,s,o){let n=e.filter(d=>!d._parent);s&&(n=e.filter(d=>d._parent===s));const l=o!==void 0?o:n.length;let a=e.length;for(let d=0,g=0;d<e.length;d++)if(e[d]._parent===s){if(g===l){a=d;break}g++}return!s&&o!==void 0&&o>=n.length&&(a=e.length),[...e.slice(0,a),...t,...e.slice(a)]}function ft(e){const t=[],s=new Map;e.forEach(n=>{s.set(n._id,n)});function o(n){const l=s.get(n);t.includes(l)||(t.push(l),e.forEach(a=>{a._parent===n&&o(a._id)}))}return e.forEach(n=>{n._parent||o(n._id)}),t}const vr=(e,t,s,o)=>{if(i.isEmpty(t))return ft(e);function n(d,g){const c=d.filter(R=>R._parent===g);let x=[...c];return c.forEach(R=>{x=x.concat(n(d,R._id))}),x}const l=t.reduce((d,g)=>{const c=e.find(x=>x._id===g);if(c){const x=n(e,g);d.push(c,...x)}return d},[]);e=e.filter(d=>!l.includes(d)),l.forEach(d=>{t.includes(d._id)&&(d._parent=s)});let a;if(!s)a=o;else{const d=e.findIndex(g=>g._id===s);if(d===-1)a=o;else{a=d+1;let g=0;for(;g<o&&a<e.length;)e[a]._parent===s&&g++,a++}}return e.splice(a,0,...l),ft(e)},yr=()=>{const[,e]=ue();return{setNewBlocks:t=>{e(t)},addBlocks:(t,s,o)=>{e(n=>br(n,t,s,o))},removeBlocks:t=>{e(s=>tt(s,t))},moveBlocks:(t,s,o)=>{e(n=>vr(n,t,s,o))},updateBlocksProps:t=>{e(s=>{const o=t.map(n=>n._id);return s.map(n=>{if(o.includes(n._id)){const l=i.find(t,{_id:n._id});return{...n,...i.omit(l,"_id")}}return n})})}}},ue=()=>p.useAtom(te),re=()=>{const{add:e}=et(),[t]=ue(),{setNewBlocks:s,addBlocks:o,removeBlocks:n,moveBlocks:l,updateBlocksProps:a}=yr();return{moveBlocks:(j,C,O)=>{const V=i.map(j,I=>{const z=t.find(Y=>Y._id===I)._parent||null,H=t.filter(Y=>z?Y._parent===z:!Y._parent).map(Y=>Y._id).indexOf(I);return{_id:I,oldParent:z,oldPosition:H}}),_=V.find(({_id:I})=>I===j[0]);_&&_.oldParent===C&&_.oldPosition===O||(l(j,C,O),e({undo:()=>i.each(V,({_id:I,oldParent:$,oldPosition:z})=>{l([I],$,z)}),redo:()=>l(j,C,O)}))},addBlocks:(j,C,O)=>{o(j,C,O),e({undo:()=>n(i.map(j,"_id")),redo:()=>o(j,C,O)})},removeBlocks:j=>{var _;const C=(_=i.first(j))==null?void 0:_._parent,V=t.filter(I=>C?I._parent===C:!I._parent).indexOf(i.first(j));n(i.map(j,"_id")),e({undo:()=>o(j,C,V),redo:()=>n(i.map(j,"_id"))})},updateBlocks:(j,C,O)=>{let V=[];if(O)V=i.map(j,_=>({_id:_,...O}));else{const _=i.keys(C);V=i.map(j,I=>{const $=t.find(Q=>Q._id===I),z={_id:I};return i.each(_,Q=>z[Q]=$[Q]),z})}a(i.map(j,_=>({_id:_,...C}))),e({undo:()=>a(V),redo:()=>a(i.map(j,_=>({_id:_,...C})))})},updateBlocksRuntime:(j,C)=>{a(i.map(j,O=>({_id:O,...C})))},setNewBlocks:j=>{s(j),e({undo:()=>s(t),redo:()=>s(j)})}}},Gt=ce.cva("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),Wt=f.forwardRef(({className:e,variant:t,size:s,...o},n)=>r.jsxRuntimeExports.jsx(wt.Root,{ref:n,className:u.cn(Gt({variant:t,size:s,className:e})),...o}));Wt.displayName=wt.Root.displayName;const Ht=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(De.Root,{className:u.cn("peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-400 focus-visible:ring-offset-2 focus-visible:ring-offset-white disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-slate-900 data-[state=unchecked]:bg-slate-200 dark:focus-visible:ring-slate-800 dark:focus-visible:ring-offset-slate-950 dark:data-[state=checked]:bg-slate-50 dark:data-[state=unchecked]:bg-slate-800",e),...t,ref:s,children:r.jsxRuntimeExports.jsx(De.Thumb,{className:u.cn("pointer-events-none block h-5 w-5 rounded-full bg-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0 dark:bg-slate-950")})}));Ht.displayName=De.Root.displayName;const Ae=ce.cva("inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),Yt=f.forwardRef(({className:e,variant:t,size:s,asChild:o=!1,...n},l)=>{const a=o?cn.Slot:"button";return r.jsxRuntimeExports.jsx(a,{className:u.cn(Ae({variant:t,size:s,className:e})),ref:l,...n})});Yt.displayName="Button";const jr=le.Root,Kt=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(le.Item,{ref:s,className:u.cn("border-b",e),...t}));Kt.displayName="AccordionItem";const Jt=f.forwardRef(({className:e,children:t,...s},o)=>r.jsxRuntimeExports.jsx(le.Header,{className:"flex",children:r.jsxRuntimeExports.jsxs(le.Trigger,{ref:o,className:u.cn("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...s,children:[t,r.jsxRuntimeExports.jsx(G.ChevronDownIcon,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200"})]})}));Jt.displayName=le.Trigger.displayName;const Qt=f.forwardRef(({className:e,children:t,...s},o)=>r.jsxRuntimeExports.jsx(le.Content,{ref:o,className:u.cn("text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",e),...s,children:r.jsxRuntimeExports.jsx("div",{className:"pb-4 pt-0",children:t})}));Qt.displayName=le.Content.displayName;const wr=ce.cva("relative w-full rounded-lg border px-4 py-3 text-sm [&:has(svg)]:pl-11 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Xt=f.forwardRef(({className:e,variant:t,...s},o)=>r.jsxRuntimeExports.jsx("div",{ref:o,role:"alert",className:u.cn(wr({variant:t}),e),...s}));Xt.displayName="Alert";const Zt=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx("h5",{ref:s,className:u.cn("mb-1 font-medium leading-none tracking-tight",e),...t}));Zt.displayName="AlertTitle";const es=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx("div",{ref:s,className:u.cn("text-sm [&_p]:leading-relaxed",e),...t}));es.displayName="AlertDescription";const ts=ce.cva("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}}),Rr=({className:e,variant:t,...s})=>r.jsxRuntimeExports.jsx("div",{className:u.cn(ts({variant:t}),e),...s}),kr=W.Root,Nr=W.Trigger,ss=({className:e,...t})=>r.jsxRuntimeExports.jsx(W.Portal,{className:u.cn(e),...t});ss.displayName=W.Portal.displayName;const os=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(W.Overlay,{className:u.cn("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:s}));os.displayName=W.Overlay.displayName;const ns=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsxs(ss,{children:[r.jsxRuntimeExports.jsx(os,{}),r.jsxRuntimeExports.jsx(W.Content,{ref:s,className:u.cn("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full",e),...t})]}));ns.displayName=W.Content.displayName;const rs=({className:e,...t})=>r.jsxRuntimeExports.jsx("div",{className:u.cn("flex flex-col space-y-2 text-center sm:text-left",e),...t});rs.displayName="AlertDialogHeader";const as=({className:e,...t})=>r.jsxRuntimeExports.jsx("div",{className:u.cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});as.displayName="AlertDialogFooter";const is=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(W.Title,{ref:s,className:u.cn("text-lg font-semibold",e),...t}));is.displayName=W.Title.displayName;const ls=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(W.Description,{ref:s,className:u.cn("text-sm text-muted-foreground",e),...t}));ls.displayName=W.Description.displayName;const cs=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(W.Action,{ref:s,className:u.cn(Ae(),e),...t}));cs.displayName=W.Action.displayName;const ds=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(W.Cancel,{ref:s,className:u.cn(Ae({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));ds.displayName=W.Cancel.displayName;const st=P.Root,us=P.Trigger,ms=({className:e,...t})=>r.jsxRuntimeExports.jsx(P.Portal,{className:u.cn(e),...t});ms.displayName=P.Portal.displayName;const ps=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(P.Overlay,{ref:s,className:u.cn("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));ps.displayName=P.Overlay.displayName;const _e=f.forwardRef(({className:e,children:t,...s},o)=>r.jsxRuntimeExports.jsxs(ms,{children:[r.jsxRuntimeExports.jsx(ps,{}),r.jsxRuntimeExports.jsxs(P.Content,{ref:o,className:u.cn("fixed left-[50%] top-[50%] z-[999] grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full",e),...s,children:[t,r.jsxRuntimeExports.jsxs(P.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[r.jsxRuntimeExports.jsx(G.Cross2Icon,{className:"h-4 w-4"}),r.jsxRuntimeExports.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));_e.displayName=P.Content.displayName;const fs=({className:e,...t})=>r.jsxRuntimeExports.jsx("div",{className:u.cn("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});fs.displayName="DialogHeader";const xs=({className:e,...t})=>r.jsxRuntimeExports.jsx("div",{className:u.cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});xs.displayName="DialogFooter";const gs=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(P.Title,{ref:s,className:u.cn("text-lg font-semibold leading-none tracking-tight",e),...t}));gs.displayName=P.Title.displayName;const hs=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(P.Description,{ref:s,className:u.cn("text-sm text-muted-foreground",e),...t}));hs.displayName=P.Description.displayName;const bs=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx("div",{ref:s,className:u.cn("rounded-xl border bg-card text-card-foreground shadow",e),...t}));bs.displayName="Card";const vs=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx("div",{ref:s,className:u.cn("flex flex-col space-y-1.5 p-6",e),...t}));vs.displayName="CardHeader";const ys=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx("h3",{ref:s,className:u.cn("font-semibold leading-none tracking-tight",e),...t}));ys.displayName="CardTitle";const js=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx("p",{ref:s,className:u.cn("text-sm text-muted-foreground",e),...t}));js.displayName="CardDescription";const ws=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx("div",{ref:s,className:u.cn("p-6 pt-0",e),...t}));ws.displayName="CardContent";const Rs=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx("div",{ref:s,className:u.cn(" flex items-center p-6 pt-0",e),...t}));Rs.displayName="CardFooter";const ks=f.forwardRef(({className:e,type:t,...s},o)=>r.jsxRuntimeExports.jsx("input",{type:t,className:u.cn("flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:o,...s}));ks.displayName="Input";const Sr=ce.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ns=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(Rt.Root,{ref:s,className:u.cn(Sr(),e),...t}));Ns.displayName=Rt.Root.displayName;const Ss=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx("textarea",{className:u.cn("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:s,...t}));Ss.displayName="Textarea";const Cs=f.forwardRef(({className:e,children:t,...s},o)=>r.jsxRuntimeExports.jsxs(ae.Root,{ref:o,className:u.cn("relative overflow-hidden",e),...s,children:[r.jsxRuntimeExports.jsx(ae.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),r.jsxRuntimeExports.jsx(ot,{}),r.jsxRuntimeExports.jsx(ae.Corner,{})]}));Cs.displayName=ae.Root.displayName;const ot=f.forwardRef(({className:e,orientation:t="vertical",...s},o)=>r.jsxRuntimeExports.jsx(ae.ScrollAreaScrollbar,{ref:o,orientation:t,className:u.cn("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 border-t border-t-transparent p-[1px]",e),...s,children:r.jsxRuntimeExports.jsx(ae.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));ot.displayName=ae.ScrollAreaScrollbar.displayName;const Es=de.Root,nt=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(de.List,{ref:s,className:u.cn("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));nt.displayName=de.List.displayName;const ke=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(de.Trigger,{ref:s,className:u.cn("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...t}));ke.displayName=de.Trigger.displayName;const Ne=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(de.Content,{ref:s,className:u.cn("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Ne.displayName=de.Content.displayName;const Cr=pe.Portal,Er=pe.Provider,Ar=pe.Root,_r=pe.Trigger,As=f.forwardRef(({className:e,sideOffset:t=4,...s},o)=>r.jsxRuntimeExports.jsx(pe.Content,{ref:o,sideOffset:t,className:u.cn("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...s}));As.displayName=pe.Content.displayName;const Br=he.Root,Tr=he.Trigger,_s=f.forwardRef(({className:e,align:t="center",sideOffset:s=4,...o},n)=>r.jsxRuntimeExports.jsx(he.Portal,{children:r.jsxRuntimeExports.jsx(he.Content,{ref:n,align:t,sideOffset:s,className:u.cn("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...o})}));_s.displayName=he.Content.displayName;const Pr=B.Menu,Ir=B.Group,Mr=B.Portal,Dr=B.Sub,Or=B.RadioGroup,Bs=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(B.Root,{ref:s,className:u.cn("flex h-9 items-center space-x-1 rounded-md border bg-background p-1 shadow-sm",e),...t}));Bs.displayName=B.Root.displayName;const Ts=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(B.Trigger,{ref:s,className:u.cn("flex cursor-default select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",e),...t}));Ts.displayName=B.Trigger.displayName;const Ps=f.forwardRef(({className:e,inset:t,children:s,...o},n)=>r.jsxRuntimeExports.jsxs(B.SubTrigger,{ref:n,className:u.cn("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",t&&"pl-8",e),...o,children:[s,r.jsxRuntimeExports.jsx(G.ChevronRightIcon,{className:"ml-auto h-4 w-4"})]}));Ps.displayName=B.SubTrigger.displayName;const Is=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(B.SubContent,{ref:s,className:u.cn("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));Is.displayName=B.SubContent.displayName;const Ms=f.forwardRef(({className:e,align:t="start",alignOffset:s=-4,sideOffset:o=8,...n},l)=>r.jsxRuntimeExports.jsx(B.Portal,{children:r.jsxRuntimeExports.jsx(B.Content,{ref:l,align:t,alignOffset:s,sideOffset:o,className:u.cn("z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Ms.displayName=B.Content.displayName;const Ds=f.forwardRef(({className:e,inset:t,...s},o)=>r.jsxRuntimeExports.jsx(B.Item,{ref:o,className:u.cn("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...s}));Ds.displayName=B.Item.displayName;const Os=f.forwardRef(({className:e,children:t,checked:s,...o},n)=>r.jsxRuntimeExports.jsxs(B.CheckboxItem,{ref:n,className:u.cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:s,...o,children:[r.jsxRuntimeExports.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsxRuntimeExports.jsx(B.ItemIndicator,{children:r.jsxRuntimeExports.jsx(G.CheckIcon,{className:"h-4 w-4"})})}),t]}));Os.displayName=B.CheckboxItem.displayName;const Ls=f.forwardRef(({className:e,children:t,...s},o)=>r.jsxRuntimeExports.jsxs(B.RadioItem,{ref:o,className:u.cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...s,children:[r.jsxRuntimeExports.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsxRuntimeExports.jsx(B.ItemIndicator,{children:r.jsxRuntimeExports.jsx(G.DotFilledIcon,{className:"h-4 w-4 fill-current"})})}),t]}));Ls.displayName=B.RadioItem.displayName;const zs=f.forwardRef(({className:e,inset:t,...s},o)=>r.jsxRuntimeExports.jsx(B.Label,{ref:o,className:u.cn("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...s}));zs.displayName=B.Label.displayName;const Vs=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(B.Separator,{ref:s,className:u.cn("-mx-1 my-1 h-px bg-muted",e),...t}));Vs.displayName=B.Separator.displayName;const Fs=({className:e,...t})=>r.jsxRuntimeExports.jsx("span",{className:u.cn("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});Fs.displayname="MenubarShortcut";const Lr=Ce.Root,zr=Ce.Trigger,Us=f.forwardRef(({className:e,align:t="center",sideOffset:s=4,...o},n)=>r.jsxRuntimeExports.jsx(Ce.Content,{ref:n,align:t,sideOffset:s,className:u.cn("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...o}));Us.displayName=Ce.Content.displayName;const Vr=F.Root,Fr=F.Group,Ur=F.Value,qs=f.forwardRef(({className:e,children:t,...s},o)=>r.jsxRuntimeExports.jsxs(F.Trigger,{ref:o,className:u.cn("flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),...s,children:[t,r.jsxRuntimeExports.jsx(F.Icon,{asChild:!0,children:r.jsxRuntimeExports.jsx(G.CaretSortIcon,{className:"h-4 w-4 opacity-50"})})]}));qs.displayName=F.Trigger.displayName;const $s=f.forwardRef(({className:e,children:t,position:s="popper",...o},n)=>r.jsxRuntimeExports.jsx(F.Portal,{children:r.jsxRuntimeExports.jsx(F.Content,{ref:n,className:u.cn("relative z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:s,...o,children:r.jsxRuntimeExports.jsx(F.Viewport,{className:u.cn("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t})})}));$s.displayName=F.Content.displayName;const Gs=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(F.Label,{ref:s,className:u.cn("px-2 py-1.5 text-sm font-semibold",e),...t}));Gs.displayName=F.Label.displayName;const Ws=f.forwardRef(({className:e,children:t,...s},o)=>r.jsxRuntimeExports.jsxs(F.Item,{ref:o,className:u.cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...s,children:[r.jsxRuntimeExports.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsxRuntimeExports.jsx(F.ItemIndicator,{children:r.jsxRuntimeExports.jsx(G.CheckIcon,{className:"h-4 w-4"})})}),r.jsxRuntimeExports.jsx(F.ItemText,{children:t})]}));Ws.displayName=F.Item.displayName;const Hs=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(F.Separator,{ref:s,className:u.cn("-mx-1 my-1 h-px bg-muted",e),...t}));Hs.displayName=F.Separator.displayName;const qr=P.Root,$r=P.Trigger,Gr=P.Close,Ys=({className:e,...t})=>r.jsxRuntimeExports.jsx(P.Portal,{className:u.cn(e),...t});Ys.displayName=P.Portal.displayName;const Ks=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(P.Overlay,{className:u.cn("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:s}));Ks.displayName=P.Overlay.displayName;const Wr=ce.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),Js=f.forwardRef(({side:e="right",className:t,children:s,...o},n)=>r.jsxRuntimeExports.jsxs(Ys,{children:[r.jsxRuntimeExports.jsx(Ks,{}),r.jsxRuntimeExports.jsxs(P.Content,{ref:n,className:u.cn(Wr({side:e}),t),...o,children:[s,r.jsxRuntimeExports.jsxs(P.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[r.jsxRuntimeExports.jsx(G.Cross2Icon,{className:"h-4 w-4"}),r.jsxRuntimeExports.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Js.displayName=P.Content.displayName;const Qs=({className:e,...t})=>r.jsxRuntimeExports.jsx("div",{className:u.cn("flex flex-col space-y-2 text-center sm:text-left",e),...t});Qs.displayName="SheetHeader";const Xs=({className:e,...t})=>r.jsxRuntimeExports.jsx("div",{className:u.cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Xs.displayName="SheetFooter";const Zs=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(P.Title,{ref:s,className:u.cn("text-lg font-semibold text-foreground",e),...t}));Zs.displayName=P.Title.displayName;const eo=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(P.Description,{ref:s,className:u.cn("text-sm text-muted-foreground",e),...t}));eo.displayName=P.Description.displayName;const Hr=M.Root,Yr=M.Trigger,Kr=M.Group,Jr=M.Portal,Qr=M.Sub,Xr=M.RadioGroup,to=f.forwardRef(({className:e,inset:t,children:s,...o},n)=>r.jsxRuntimeExports.jsxs(M.SubTrigger,{ref:n,className:u.cn("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...o,children:[s,r.jsxRuntimeExports.jsx(G.ChevronRightIcon,{className:"ml-auto h-4 w-4"})]}));to.displayName=M.SubTrigger.displayName;const so=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(M.SubContent,{ref:s,className:u.cn("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));so.displayName=M.SubContent.displayName;const oo=f.forwardRef(({className:e,sideOffset:t=4,...s},o)=>r.jsxRuntimeExports.jsx(M.Portal,{children:r.jsxRuntimeExports.jsx(M.Content,{ref:o,sideOffset:t,className:u.cn("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...s})}));oo.displayName=M.Content.displayName;const no=f.forwardRef(({className:e,inset:t,...s},o)=>r.jsxRuntimeExports.jsx(M.Item,{ref:o,className:u.cn("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...s}));no.displayName=M.Item.displayName;const ro=f.forwardRef(({className:e,children:t,checked:s,...o},n)=>r.jsxRuntimeExports.jsxs(M.CheckboxItem,{ref:n,className:u.cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:s,...o,children:[r.jsxRuntimeExports.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsxRuntimeExports.jsx(M.ItemIndicator,{children:r.jsxRuntimeExports.jsx(G.CheckIcon,{className:"h-4 w-4"})})}),t]}));ro.displayName=M.CheckboxItem.displayName;const ao=f.forwardRef(({className:e,children:t,...s},o)=>r.jsxRuntimeExports.jsxs(M.RadioItem,{ref:o,className:u.cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...s,children:[r.jsxRuntimeExports.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsxRuntimeExports.jsx(M.ItemIndicator,{children:r.jsxRuntimeExports.jsx(G.DotFilledIcon,{className:"h-4 w-4 fill-current"})})}),t]}));ao.displayName=M.RadioItem.displayName;const io=f.forwardRef(({className:e,inset:t,...s},o)=>r.jsxRuntimeExports.jsx(M.Label,{ref:o,className:u.cn("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...s}));io.displayName=M.Label.displayName;const lo=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(M.Separator,{ref:s,className:u.cn("-mx-1 my-1 h-px bg-muted",e),...t}));lo.displayName=M.Separator.displayName;const co=({className:e,...t})=>r.jsxRuntimeExports.jsx("span",{className:u.cn("ml-auto text-xs tracking-widest opacity-60",e),...t});co.displayName="DropdownMenuShortcut";const uo=f.forwardRef(({className:e,orientation:t="horizontal",decorative:s=!0,...o},n)=>r.jsxRuntimeExports.jsx(kt.Root,{ref:n,decorative:s,orientation:t,className:u.cn("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...o}));uo.displayName=kt.Root.displayName;const Zr=1,ea=1e6;let Ie=0;function ta(){return Ie=(Ie+1)%Number.MAX_VALUE,Ie.toString()}const Me=new Map,xt=e=>{if(Me.has(e))return;const t=setTimeout(()=>{Me.delete(e),ge({type:"REMOVE_TOAST",toastId:e})},ea);Me.set(e,t)},mo=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Zr)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(s=>s.id===t.toast.id?{...s,...t.toast}:s)};case"DISMISS_TOAST":{const{toastId:s}=t;return s?xt(s):e.toasts.forEach(o=>{xt(o.id)}),{...e,toasts:e.toasts.map(o=>o.id===s||s===void 0?{...o,open:!1}:o)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(s=>s.id!==t.toastId)}}},je=[];let we={toasts:[]};function ge(e){we=mo(we,e),je.forEach(t=>{t(we)})}function po({...e}){const t=ta(),s=n=>ge({type:"UPDATE_TOAST",toast:{...n,id:t}}),o=()=>ge({type:"DISMISS_TOAST",toastId:t});return ge({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:n=>{n||o()}}}),{id:t,dismiss:o,update:s}}function rt(){const[e,t]=f.useState(we);return f.useEffect(()=>(je.push(t),()=>{const s=je.indexOf(t);s>-1&&je.splice(s,1)}),[e]),{...e,toast:po,dismiss:s=>ge({type:"DISMISS_TOAST",toastId:s})}}const sa=X.Provider,fo=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(X.Viewport,{ref:s,className:u.cn("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",e),...t}));fo.displayName=X.Viewport.displayName;const oa=ce.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),xo=f.forwardRef(({className:e,variant:t,...s},o)=>r.jsxRuntimeExports.jsx(X.Root,{ref:o,className:u.cn(oa({variant:t}),e),...s}));xo.displayName=X.Root.displayName;const na=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(X.Action,{ref:s,className:u.cn("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));na.displayName=X.Action.displayName;const go=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(X.Close,{ref:s,className:u.cn("absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:r.jsxRuntimeExports.jsx(G.Cross2Icon,{className:"h-4 w-4"})}));go.displayName=X.Close.displayName;const ho=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(X.Title,{ref:s,className:u.cn("text-sm font-semibold [&+div]:text-xs",e),...t}));ho.displayName=X.Title.displayName;const bo=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(X.Description,{ref:s,className:u.cn("text-sm opacity-90",e),...t}));bo.displayName=X.Description.displayName;function ra(){const{toasts:e}=rt();return r.jsxRuntimeExports.jsxs(sa,{children:[e.map(({id:t,title:s,description:o,action:n,...l})=>r.jsxRuntimeExports.jsxs(xo,{...l,children:[r.jsxRuntimeExports.jsxs("div",{className:"grid gap-1",children:[s&&r.jsxRuntimeExports.jsx(ho,{children:s}),o&&r.jsxRuntimeExports.jsx(bo,{children:o})]}),n,r.jsxRuntimeExports.jsx(go,{})]},t)),r.jsxRuntimeExports.jsx(fo,{})]})}const aa=({className:e,...t})=>r.jsxRuntimeExports.jsx("div",{className:u.cn("animate-pulse rounded-md bg-primary/10",e),...t}),at=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(J.Command,{ref:s,className:u.cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));at.displayName=J.Command.displayName;const ia=({children:e,...t})=>r.jsxRuntimeExports.jsx(st,{...t,children:r.jsxRuntimeExports.jsx(_e,{className:"overflow-hidden p-0",children:r.jsxRuntimeExports.jsx(at,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:e})})}),vo=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[r.jsxRuntimeExports.jsx(G.MagnifyingGlassIcon,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),r.jsxRuntimeExports.jsx(J.Command.Input,{ref:s,className:u.cn("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));vo.displayName=J.Command.Input.displayName;const yo=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(J.Command.List,{ref:s,className:u.cn("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));yo.displayName=J.Command.List.displayName;const jo=f.forwardRef((e,t)=>r.jsxRuntimeExports.jsx(J.Command.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));jo.displayName=J.Command.Empty.displayName;const wo=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(J.Command.Group,{ref:s,className:u.cn("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));wo.displayName=J.Command.Group.displayName;const Ro=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(J.Command.Separator,{ref:s,className:u.cn("-mx-1 h-px bg-border",e),...t}));Ro.displayName=J.Command.Separator.displayName;const ko=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(J.Command.Item,{ref:s,className:u.cn("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...t}));ko.displayName=J.Command.Item.displayName;const No=({className:e,...t})=>r.jsxRuntimeExports.jsx("span",{className:u.cn("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});No.displayName="CommandShortcut";const la=D.Root,ca=D.Trigger,da=D.Group,ua=D.Portal,ma=D.Sub,pa=D.RadioGroup,So=f.forwardRef(({className:e,inset:t,children:s,...o},n)=>r.jsxRuntimeExports.jsxs(D.SubTrigger,{ref:n,className:u.cn("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",t&&"pl-8",e),...o,children:[s,r.jsxRuntimeExports.jsx(G.ChevronRightIcon,{className:"ml-auto h-4 w-4"})]}));So.displayName=D.SubTrigger.displayName;const Co=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(D.SubContent,{ref:s,className:u.cn("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));Co.displayName=D.SubContent.displayName;const Eo=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(D.Portal,{children:r.jsxRuntimeExports.jsx(D.Content,{ref:s,className:u.cn("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t})}));Eo.displayName=D.Content.displayName;const Ao=f.forwardRef(({className:e,inset:t,...s},o)=>r.jsxRuntimeExports.jsx(D.Item,{ref:o,className:u.cn("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...s}));Ao.displayName=D.Item.displayName;const _o=f.forwardRef(({className:e,children:t,checked:s,...o},n)=>r.jsxRuntimeExports.jsxs(D.CheckboxItem,{ref:n,className:u.cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:s,...o,children:[r.jsxRuntimeExports.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsxRuntimeExports.jsx(D.ItemIndicator,{children:r.jsxRuntimeExports.jsx(G.CheckIcon,{className:"h-4 w-4"})})}),t]}));_o.displayName=D.CheckboxItem.displayName;const Bo=f.forwardRef(({className:e,children:t,...s},o)=>r.jsxRuntimeExports.jsxs(D.RadioItem,{ref:o,className:u.cn("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...s,children:[r.jsxRuntimeExports.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsxRuntimeExports.jsx(D.ItemIndicator,{children:r.jsxRuntimeExports.jsx(G.DotFilledIcon,{className:"h-4 w-4 fill-current"})})}),t]}));Bo.displayName=D.RadioItem.displayName;const To=f.forwardRef(({className:e,inset:t,...s},o)=>r.jsxRuntimeExports.jsx(D.Label,{ref:o,className:u.cn("px-2 py-1.5 text-sm font-semibold text-foreground",t&&"pl-8",e),...s}));To.displayName=D.Label.displayName;const Po=f.forwardRef(({className:e,...t},s)=>r.jsxRuntimeExports.jsx(D.Separator,{ref:s,className:u.cn("-mx-1 my-1 h-px bg-border",e),...t}));Po.displayName=D.Separator.displayName;const Io=({className:e,...t})=>r.jsxRuntimeExports.jsx("span",{className:u.cn("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});Io.displayName="ContextMenuShortcut";const fa=e=>{try{const t=document.getElementById("icon-picker-field"),s=document.createElement("div");Nn.render(r.jsxRuntimeExports.jsx(jt.IconPickerItem,{value:e}),s),t.appendChild(s),s.hidden=!0;let o=s.innerHTML;setTimeout(()=>t.removeChild(s),100);const l=new DOMParser().parseFromString(o,"image/svg+xml"),a=l.querySelector("svg");return a&&(a.removeAttribute("width"),a.removeAttribute("height")),new XMLSerializer().serializeToString(l)}catch(t){return console.error(t),""}},xa=({value:e,onChange:t})=>{const s=o=>{t("<svg />");const n=fa(o);t(n)};return r.jsxRuntimeExports.jsxs("div",{className:"mt-1 flex h-20 items-center gap-x-2",id:"icon-picker-field",children:[r.jsxRuntimeExports.jsxs("div",{className:"group relative h-12 w-12",children:[r.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:e?e.replace("<svg",'<svg class="h-5 w-5"'):"<svg class='h-5 w-5' />"},className:"absolute left-1/2 top-1/2 z-0 -translate-x-1/2 -translate-y-1/2 transform cursor-pointer bg-white"}),r.jsxRuntimeExports.jsx(jt,{value:e?"BiSolidGrid":null,onChange:s,pickButtonStyle:{position:"relative",height:"48px",width:"48px",border:"1px solid #BBBBBB",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"6px",backgroundColor:"transparent",zIndex:1},searchInputStyle:{backgroundColor:"transparent",width:"100%",border:"1px solid #BBBBBB",margin:"0px 10px",padding:"10px"}})]}),r.jsxRuntimeExports.jsx("textarea",{value:e,onChange:o=>t(o.target.value),className:"h-full w-full rounded-sm border border-foreground/20 px-2 py-1 text-xs shadow-sm focus:border-gray-500/80 focus:outline-none focus:ring-0",placeholder:"Choose icon or enter svg"})]})},ga=k.lazy(()=>Promise.resolve().then(()=>require("./UnsplashImages-05JR8oIu.cjs"))),ha=k.lazy(()=>Promise.resolve().then(()=>require("./UploadImages-OgSN1HVt.cjs"))),Mo=({isModalView:e=!1,onSelect:t=()=>{}})=>{const[s,o]=k.useState("upload");return r.jsxRuntimeExports.jsxs("div",{className:"flex h-full flex-col",children:[r.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between rounded-md bg-background/30 p-1",children:r.jsxRuntimeExports.jsx("h1",{className:"px-1 font-semibold",children:e?"Select or upload images":"Images"})}),r.jsxRuntimeExports.jsxs(Es,{value:s,onValueChange:n=>o(n),className:"flex h-full w-full flex-col py-2",children:[r.jsxRuntimeExports.jsxs(nt,{className:"w-full",children:[r.jsxRuntimeExports.jsx(ke,{value:"upload",className:"w-1/2",children:"Upload"}),r.jsxRuntimeExports.jsx(ke,{value:"unsplash",className:"w-1/2",children:"Unsplash"})]}),s==="unsplash"?r.jsxRuntimeExports.jsx(Ne,{value:"unsplash",className:"flex h-full flex-col overflow-hidden",children:r.jsxRuntimeExports.jsx(k.Suspense,{fallback:r.jsxRuntimeExports.jsx("div",{className:"h-64 w-full animate-pulse bg-gray-100"}),children:r.jsxRuntimeExports.jsx(ga,{isModalView:e,onSelect:t})})}):r.jsxRuntimeExports.jsx(Ne,{value:"upload",className:"flex h-full flex-col overflow-hidden",children:r.jsxRuntimeExports.jsx(k.Suspense,{fallback:r.jsxRuntimeExports.jsx("div",{className:"h-64 w-full animate-pulse bg-gray-100"}),children:r.jsxRuntimeExports.jsx(ha,{isModalView:e,onSelect:t})})})]})]})},ba=Object.freeze(Object.defineProperty({__proto__:null,default:Mo},Symbol.toStringTag,{value:"Module"})),gt=({children:e,onSelect:t})=>{const[s,o]=k.useState(!1),n=(...l)=>{t.call(void 0,...l),o(!1)};return r.jsxRuntimeExports.jsxs(st,{open:s,onOpenChange:l=>o(l),children:[r.jsxRuntimeExports.jsx(us,{asChild:!0,children:e}),r.jsxRuntimeExports.jsx(_e,{className:"flex h-3/4 max-w-5xl",children:r.jsxRuntimeExports.jsx("div",{className:"h-full w-full",children:r.jsxRuntimeExports.jsx(Mo,{isModalView:!0,onSelect:n})})})]})},va=({value:e,onChange:t,id:s,onBlur:o})=>r.jsxRuntimeExports.jsxs("div",{className:"mt-1.5 flex items-center gap-x-3",children:[e?r.jsxRuntimeExports.jsx("img",{src:e,className:"h-20 w-20 overflow-hidden rounded-md border object-cover",alt:""}):r.jsxRuntimeExports.jsx(gt,{onSelect:t,children:r.jsxRuntimeExports.jsx("div",{className:"h-20 w-20 cursor-pointer rounded-md border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px] hover:border-gray-400"})}),r.jsxRuntimeExports.jsxs("div",{className:"flex w-3/5 flex-col",children:[r.jsxRuntimeExports.jsx(gt,{onSelect:t,children:r.jsxRuntimeExports.jsx("small",{className:"cursor-pointer rounded-full bg-gray-600 px-2 py-1 text-center text-xs text-white hover:bg-gray-500 dark:bg-gray-700",children:e||!i.isEmpty(e)?"Replace Image":"Choose Image"})}),r.jsxRuntimeExports.jsx("small",{className:"-pl-4 pt-2 text-center text-xs text-gray-600",children:"OR"}),r.jsxRuntimeExports.jsx("input",{type:"url",className:"text-xs",placeholder:"Enter image URL",value:e,onBlur:({target:{value:n}})=>o(s,n),onChange:n=>t(n.target.value)})]})]}),ya=({id:e,placeholder:t,value:s,onChange:o,onBlur:n})=>{const l={toolbar:[["bold","italic","underline","strike","blockquote"],[{list:"ordered"},{list:"bullet"}],[{color:[]},{background:[]},{align:[]}],["link","clean"]]},a=["header","font","list","bold","italic","underline","strike","blockquote","color","background","align","link","image"];return typeof window>"u"?null:r.jsxRuntimeExports.jsx(Sn,{id:e,value:s,onBlur:d=>n(e,d),onChange:d=>o(d),modules:l,formats:a,placeholder:t,className:"mt-1 rounded-md"})},ja=({schema:e,formData:t,onChange:s})=>{const[o,n]=k.useState([]),l=ie("getPages",()=>[]),{type:a="page",href:d="",target:g="self"}=t;return k.useEffect(()=>{(async()=>{const c=await l();n(c||[])})()},[]),r.jsxRuntimeExports.jsxs("div",{children:[r.jsxRuntimeExports.jsx("span",{className:"text-xs font-medium",children:(e==null?void 0:e.title)??"Link"}),r.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[r.jsxRuntimeExports.jsx("select",{name:"type",value:a,onChange:c=>s({...t,type:c.target.value}),children:[{const:"page",title:"Open Page"},{const:"url",title:"Open URL"},{const:"email",title:"Compose Email"},{const:"telephone",title:"Call Phone"},{const:"scroll",title:"Scroll to element"}].map(c=>r.jsxRuntimeExports.jsx("option",{value:c.const,children:c.title},c.const))}),a==="page"?r.jsxRuntimeExports.jsxs("select",{name:"href",placeholder:"Choose Page",value:d,onChange:c=>s({...t,href:c.target.value}),children:[r.jsxRuntimeExports.jsx("option",{value:"",children:"Choose page"}),i.map(o,c=>r.jsxRuntimeExports.jsx("option",{value:c.slug,children:c.name},c.uuid))]}):r.jsxRuntimeExports.jsx("input",{name:"href",type:"text",value:d,onChange:c=>s({...t,href:c.target.value}),placeholder:a==="page"||a==="url"?"Enter URL":a==="scroll"?"#ElementID":"Enter detail"}),(a==="page"||a==="url")&&r.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2",children:[r.jsxRuntimeExports.jsx("input",{type:"checkbox",defaultChecked:g==="_blank",className:"cursor-pointer rounded-md border border-border",onChange:()=>s({...t,target:g==="_blank"?"_self":"_blank"})}),r.jsxRuntimeExports.jsx("span",{className:"pt-1 text-xs",children:"Open in new tab"})]})]})]})},wa=()=>{const[e]=ue(),[,t]=be(),{addBlocks:s}=re(),{toast:o}=rt(),n=k.useCallback((a,d,g)=>{var j;for(let C=0;C<a.length;C++){const{_id:O}=a[C];a[C]._id=ne.generateUUID();const V=i.filter(a,{_parent:O});for(let _=0;_<V.length;_++)V[_]._parent=a[C]._id}const c=i.first(a);let x,R;return d&&(x=i.find(e,{_id:d}),a[0]._parent=d,R=d),!(x?Oe(x._type,c._type):!0)&&x&&(a[0]._parent=x._parent,R=x._parent),s(a,R,g),t([(j=i.first(a))==null?void 0:j._id]),i.first(a)},[e,t]);return{addCoreBlock:k.useCallback((a,d,g)=>{if(i.has(a,"blocks")){const _=a.blocks;return n(_,d,g)}const c=ne.generateUUID(),x=Lt(a.props),R=[];i.forIn(x,(_,I)=>{if(i.startsWith(_,K.SLOT_KEY)){const $=_.replace(K.SLOT_KEY,"");R.push({_id:$,_type:"Slot",_parent:c,_name:a.props[I].name,_styles:a.props[I].styles,_emptyStyles:a.props[I].emptyStyles})}});const S={_type:a.type,_id:c,...x};let j,C;if(d&&(j=i.find(e,{_id:d}),S._parent=d,C=d),!Yn(j==null?void 0:j._type,a.type)){o({variant:"destructive",title:"Error",description:`"${a.type}" cannot be added under "${j?j==null?void 0:j._type:"root"}"`}),t([]);return}!(j?Oe(j._type,a.type):!0)&&j&&(S._parent=j._parent,C=j._parent);const V=[S,...R];return s(V,C,g),t([S._id]),S},[n,e,t]),addPredefinedBlock:n}},ht={xs:420,sm:620,md:768,lg:1024,xl:1280,"2xl":1536},bt=["xs","sm","md","lg","xl","2xl"];function Ra(e,t){if(t===null)return"baseClasses";const s=t.mq;if(s==="xs"||t.dark||t.mod!=="")return"classes";let o="baseClasses",n=bt.indexOf(s);for(;n>0;){const l=bt[n-1];if(i.find(e,{mq:l,property:t.property})){o="classes";break}n--}return o}const vt=[];function ka(e="",t="",s=[]){e=e.trim().replace(/ +/g,"");let o=i.filter(i.map(e.split(" "),u.constructClassObject),c=>!i.isNull(c)),n=i.filter(i.map(t.split(" "),u.constructClassObject),c=>!i.isNull(c));n=i.filter(n,c=>!i.includes(vt,c.property));const l=[],a=[];i.each(s,c=>{const x=u.constructClassObject(c),R=i.find(o,i.pick(x,["dark","mq","mod","property"]));if(R&&(o=i.filter(o,S=>S.fullCls!==(R==null?void 0:R.fullCls))),l.push(x),x.mq==="xs"&&!x.dark&&x.mod===""&&(n=i.filter(n,S=>S.property!==x.property)),Ra(o,x)==="baseClasses"&&!i.includes(vt,x.property)){const S=i.find(n,i.pick(x,["property"]));R&&(n=i.filter(n,j=>j.fullCls!==(S==null?void 0:S.fullCls))),a.push({...x,fullCls:x.cls,mq:"xs"})}});const d=i.map(i.sortBy([...o,...l],c=>ht[c.mq]),"fullCls").join(" ");return`${i.map(i.sortBy([...n,...a],c=>ht[c.mq]),"fullCls").join(" ").trim()},${d.trim()}`.trim().replace(/ +/g,"")}const ve=p.atom([]);ve.debugLabel="selectedStylingBlocksAtom";const Do=()=>p.useAtom(ve),Na=e=>{const t=e.replace(K.STYLES_KEY,"").split(",");return{baseClasses:t[0],classes:t[1]}},Sa=p.atom(null,(e,t,{blockIds:s,newClasses:o})=>{const n=i.filter(e($e),a=>s.includes(e(a)._id)),l=i.first(e(ve));return i.map(n,a=>{const d=e(a),g=i.get(d,l.prop,`${K.STYLES_KEY},`),{baseClasses:c,classes:x}=Na(g);return{ids:[d._id],props:{[l.prop]:`${K.STYLES_KEY}${ka(x,c,o)}`}}})}),Ca=()=>{const e=p.useSetAtom(Sa),{updateBlocks:t,updateBlocksRuntime:s}=re();return k.useCallback((o,n,l=!1)=>{const a=e({blockIds:o,newClasses:n});if(!l){s(o,a[0].props);return}t(o,a[0].props)},[e])},Oo=()=>p.useAtom(Ot),Lo=fe("canvasWidth",800),zo=p.atom(e=>{const t=e(Lo);return ne.getBreakpointValue(t).toLowerCase()}),Ea=()=>{const[e,t]=p.useAtom(Lo),s=p.useAtomValue(zo),[o,n]=Oo();return k.useEffect(()=>{o!=="xs"&&n(s)},[s,o,n]),[e,s,t]},Aa=fe("canvasZoom",100),_a=()=>p.useAtom(Aa),Vo=p.atom([]),Fo=()=>{const[e,t]=p.useAtom(Vo),s=p.useSetAtom(it),o=k.useCallback(n=>{t(n),s([])},[t,s]);return[e,o]},it=p.atom([]),Ba=()=>{const[e,t]=p.useAtom(it),s=p.useSetAtom(Vo),o=k.useCallback(n=>{t(n),s([])},[t,s]);return[e,o]},Uo=fe("darkMode",!1),Ta=()=>{const[e,t]=p.useAtom(Uo);return[e,t]},qo=()=>{const[e]=ue(),[,t]=be(),{addBlocks:s}=re();return k.useCallback((o,n=null)=>{const l=[];i.each(o,a=>{const d=e.find(S=>S._id===a);n||(n=d._parent);const x=i.filter(e,S=>i.isString(n)?S._parent===n:!d._parent).indexOf(d)+1,R=Qn(e,a,n);s(R,n,x),l.push(i.get(R,"0._id",""))}),t(l)},[e,t])},Pa=p.atom([]),Ia=()=>{const[e,t]=p.useAtom(Pa),s=k.useCallback(o=>{t(n=>i.includes(n,o)?i.without(n,o):[...n,o])},[t]);return[e,t,s]},Ma=p.atom(""),$o=()=>p.useAtom(Ma),Da=()=>{const e=p.useAtomValue(te);return k.useCallback((t,s)=>{const o=i.map(e,n=>(i.includes(t,i.get(n,"_id"))&&i.set(n,"_parent",s),n));console.log("newBlocks",o)},[e])},Oa=()=>{console.warn("usePasteBlocks is not implemented");const e=p.useAtomValue(it),[t,s]=Fo(),o=qo(),n=Da();return{canPaste:k.useMemo(()=>t.length>0||e.length>0,[e,t]),pasteBlocks:k.useCallback(a=>{i.isEmpty(e)?n(t,a):o(e,a),s(()=>[])},[t,e,o,n,s])}},La=p.atom(!1),za=()=>{const[e,t]=p.useAtom(La);return[e,t]},Va=p.atom(null,(e,t,{blockIds:s,fullClasses:o})=>{const n=i.first(e(ve)),l=i.filter(e($e),a=>s.includes(e(a)._id));return i.map(l,a=>{const d=e(a),g=o;let{classes:c,baseClasses:x}=Hn(i.get(d,n.prop,"styles:,"));return i.each(g,R=>{const S=new RegExp(`(^| )${R.replace("[","\\[").replace("]","\\]")}($| )`,"g");c=c.replace(S," ").replace(/ +/g," ").trim();const j=i.first(R.split(":"));i.includes(["2xl","xl","lg","md","sm"],j)&&g.push(R.split(":").pop().trim())}),i.each(g,R=>{const S=new RegExp(`(^| )${R.replace("[","\\[").replace("]","\\]")}($| )`,"g");x=x.replace(S," ").replace(/ +/g," ").trim()}),{ids:[d._id],props:{[n.prop]:`${K.STYLES_KEY}${x},${c}`}}})}),Fa=()=>{const{updateBlocks:e}=re(),t=p.useSetAtom(Va);return k.useCallback((s,o)=>{const n=t({blockIds:s,fullClasses:o});e(s,n[0].props)},[t])},Go=p.atom(e=>{const t=i.first(e(ve)),s=e(He);if(!t||t.blockId!==i.get(s,"_id",null))return[];const n=i.get(s,t.prop,`${K.STYLES_KEY},`).replace(K.STYLES_KEY,"").split(",").join(" ");return i.filter(i.map(n.trim().split(" "),u.constructClassObject),l=>!i.isNull(l))}),Ua=()=>p.useAtomValue(Go),yt={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5},qa=p.atom(e=>{const t=e(zo),s=e(Ye),o=e(Uo),n=$a(t);let l=i.filter(e(Go),{mod:s});return i.startsWith(s,"_")||(l=i.filter(l,a=>n.includes(a.mq))),l=l.sort((a,d)=>yt[a.mq]-yt[d.mq]),o||(l=i.filter(l,{dark:!1})),l}),$a=e=>{let t=[];switch(e){case"xs":t=["xs"];break;case"sm":t=["xs","sm"];break;case"md":t=["xs","sm","md"];break;case"lg":t=["xs","sm","md","lg"];break;case"xl":t=["xs","sm","md","lg","xl"];break;case"2xl":t=["xs","sm","md","lg","xl","2xl"];break;default:t=["xs"];break}return t},Ga=()=>p.useAtomValue(qa),Wa=()=>p.useAtom(Ye),Ha=()=>{const{updateBlocks:e}=re();return k.useCallback((t,s,o)=>{e(t,s,o)},[e])},Ya=()=>{const{updateBlocksRuntime:e}=re();return k.useCallback((t,s)=>{e(t,s)},[e])},Wo={name:"",props:{},modalProps:{},backdropClose:!0},Ka=p.atom(Wo),Ja=()=>{const[e,t]=p.useAtom(Ka),s=k.useCallback((n,l={},a={})=>{t({name:n,props:l,modalProps:a})},[t]),o=k.useCallback((...n)=>{i.get(e,"props.onClose",()=>{})(...n),t(Wo)},[t,e]);return{activeModal:e,openModal:s,closeModal:o}},Qa=()=>(console.warn("useAllBlocks is deprecated, use useBlocksStore() instead"),p.useAtomValue(te)),Ho=p.atom(!1);Ho.debugLabel="readOnlyModeAtom";const Yo=p.atom("online");Yo.debugLabel="networkModeAtom";const Xa=p.atom(!1);Xa.debugLabel="codeEditorOpenAtom";const Ko=p.atom(!1);Ko.debugLabel="editLayerNameAtom";const Za=p.atom("");Za.debugLabel="activeLanguageAtom";const ei=p.atom("");ei.debugLabel="primaryLanguageAtom";const Jo=p.atom(null);Jo.debugLabel="canvasIframeAtom";const Qo=p.atom("outline");Qo.debugLabel="activePanelAtom";const Xo=p.atom("");Xo.debugLabel="showPredefinedBlockCategoryAtom";const Zo=p.atom({undoCount:0,redoCount:0});Zo.debugLabel="historyStatesAtom";const en=p.atom("");en.debugLabel="inlineEditingActiveAtom";const tn=p.atom(!1);tn.debugLabel="draggingFlagAtom";const sn=p.atom("");sn.debugLabel="draggedBlockIdAtom";const ti=()=>p.useAtomValue(Ho),si=p.atom(""),oi=p.atom(null),ni=()=>p.useAtom(si),ri=()=>p.useAtom(oi),ai=fe("selectedBreakpoints",["XS","MD","XL"]),ii=()=>{const[e,t]=p.useAtom(ai);return[e,t]},li=()=>{const e=p.useSetAtom(Zo),{clear:t}=et(),[,s]=be(),[,o]=$o(),[,n]=Do();return()=>{s([]),n([]),o(""),t(),e({undoCount:0,redoCount:0})}},ci=p.atom([]),di=()=>{const[e,t]=k.useState(!1),[s,o]=p.useAtom(ci),n=ie("getUILibraryBlocks",()=>[]);return k.useEffect(()=>{(async()=>s.length>0||(t(!0),o(await n()),t(!1)))()},[]),{data:s,isLoading:e}},ui=()=>{const[e,t]=k.useState(null),s=k.useCallback(async o=>{if(!(navigator!=null&&navigator.clipboard))return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(o),t(o),!0}catch(n){return console.warn("Copy failed",n),t(null),!1}},[]);return[e,s]};exports.Accordion=jr;exports.AccordionContent=Qt;exports.AccordionItem=Kt;exports.AccordionTrigger=Jt;exports.Alert=Xt;exports.AlertDescription=es;exports.AlertDialog=kr;exports.AlertDialogAction=cs;exports.AlertDialogCancel=ds;exports.AlertDialogContent=ns;exports.AlertDialogDescription=ls;exports.AlertDialogFooter=as;exports.AlertDialogHeader=rs;exports.AlertDialogTitle=is;exports.AlertDialogTrigger=Nr;exports.AlertTitle=Zt;exports.Badge=Rr;exports.Button=Yt;exports.Card=bs;exports.CardContent=ws;exports.CardDescription=js;exports.CardFooter=Rs;exports.CardHeader=vs;exports.CardTitle=ys;exports.Command=at;exports.CommandDialog=ia;exports.CommandEmpty=jo;exports.CommandGroup=wo;exports.CommandInput=vo;exports.CommandItem=ko;exports.CommandList=yo;exports.CommandSeparator=Ro;exports.CommandShortcut=No;exports.ContextMenu=la;exports.ContextMenuCheckboxItem=_o;exports.ContextMenuContent=Eo;exports.ContextMenuGroup=da;exports.ContextMenuItem=Ao;exports.ContextMenuLabel=To;exports.ContextMenuPortal=ua;exports.ContextMenuRadioGroup=pa;exports.ContextMenuRadioItem=Bo;exports.ContextMenuSeparator=Po;exports.ContextMenuShortcut=Io;exports.ContextMenuSub=ma;exports.ContextMenuSubContent=Co;exports.ContextMenuSubTrigger=So;exports.ContextMenuTrigger=ca;exports.Dialog=st;exports.DialogContent=_e;exports.DialogDescription=hs;exports.DialogFooter=xs;exports.DialogHeader=fs;exports.DialogTitle=gs;exports.DialogTrigger=us;exports.DropdownMenu=Hr;exports.DropdownMenuCheckboxItem=ro;exports.DropdownMenuContent=oo;exports.DropdownMenuGroup=Kr;exports.DropdownMenuItem=no;exports.DropdownMenuLabel=io;exports.DropdownMenuPortal=Jr;exports.DropdownMenuRadioGroup=Xr;exports.DropdownMenuRadioItem=ao;exports.DropdownMenuSeparator=lo;exports.DropdownMenuShortcut=co;exports.DropdownMenuSub=Qr;exports.DropdownMenuSubContent=so;exports.DropdownMenuSubTrigger=to;exports.DropdownMenuTrigger=Yr;exports.HoverCard=Lr;exports.HoverCardContent=Us;exports.HoverCardTrigger=zr;exports.IconPickerField=xa;exports.ImagePickerField=va;exports.ImagesPanel=ba;exports.Input=ks;exports.Label=Ns;exports.LinkField=ja;exports.Menubar=Bs;exports.MenubarCheckboxItem=Os;exports.MenubarContent=Ms;exports.MenubarGroup=Ir;exports.MenubarItem=Ds;exports.MenubarLabel=zs;exports.MenubarMenu=Pr;exports.MenubarPortal=Mr;exports.MenubarRadioGroup=Or;exports.MenubarRadioItem=Ls;exports.MenubarSeparator=Vs;exports.MenubarShortcut=Fs;exports.MenubarSub=Dr;exports.MenubarSubContent=Is;exports.MenubarSubTrigger=Ps;exports.MenubarTrigger=Ts;exports.Popover=Br;exports.PopoverContent=_s;exports.PopoverTrigger=Tr;exports.RichTextEditorField=ya;exports.ScrollArea=Cs;exports.ScrollBar=ot;exports.Select=Vr;exports.SelectContent=$s;exports.SelectGroup=Fr;exports.SelectItem=Ws;exports.SelectLabel=Gs;exports.SelectSeparator=Hs;exports.SelectTrigger=qs;exports.SelectValue=Ur;exports.Separator=uo;exports.Sheet=qr;exports.SheetClose=Gr;exports.SheetContent=Js;exports.SheetDescription=eo;exports.SheetFooter=Xs;exports.SheetHeader=Qs;exports.SheetTitle=Zs;exports.SheetTrigger=$r;exports.Skeleton=aa;exports.Switch=Ht;exports.Tabs=Es;exports.TabsContent=Ne;exports.TabsList=nt;exports.TabsTrigger=ke;exports.Textarea=Ss;exports.Toaster=ra;exports.Toggle=Wt;exports.Tooltip=Ar;exports.TooltipContent=As;exports.TooltipPortal=Cr;exports.TooltipProvider=Er;exports.TooltipTrigger=_r;exports.activePanelAtom=Qo;exports.atom=ee;exports.atomWithDefault=Un;exports.atomWithStorage=fe;exports.badgeVariants=ts;exports.builderSaveStateAtom=Ee;exports.buttonVariants=Ae;exports.canAcceptChildBlock=Oe;exports.canDeleteBlock=Jn;exports.canDuplicateBlock=Kn;exports.canvasIframeAtom=Jo;exports.chaiBuilderPropsAtom=qe;exports.chaiExternalDataAtom=At;exports.createStore=Nt;exports.dataProvidersAtom=Ze;exports.draggedBlockIdAtom=sn;exports.draggingFlagAtom=tn;exports.editLayerNameAtom=Ko;exports.getBlockJSONFromSchemas=ze;exports.getBlockJSONFromUISchemas=Le;exports.inlineEditingActiveAtom=en;exports.isDevelopment=Wn;exports.networkModeAtom=Yo;exports.presentBlocksAtom=te;exports.reducer=mo;exports.showPredefinedBlockCategoryAtom=Xo;exports.toast=po;exports.toggleVariants=Gt;exports.treeDSBlocks=Pt;exports.useActiveModal=Ja;exports.useActivePanel=ni;exports.useAddBlock=wa;exports.useAddBlockParent=ri;exports.useAddClassesToBlocks=Ca;exports.useAllBlocks=Qa;exports.useAtom=Dn;exports.useAtomValue=St;exports.useBlocksContainer=ur;exports.useBlocksStore=ue;exports.useBlocksStoreUndoableActions=re;exports.useBrandingOptions=Je;exports.useBuilderProp=ie;exports.useBuilderReset=li;exports.useCanvasWidth=Ea;exports.useCanvasZoom=_a;exports.useCopyBlockIds=Ba;exports.useCopyToClipboard=ui;exports.useCurrentPage=zt;exports.useCutBlockIds=Fo;exports.useDarkMode=Ta;exports.useDuplicateBlocks=qo;exports.useGetPageData=qt;exports.useHiddenBlockIds=Ia;exports.useHighlightBlockId=$o;exports.usePageDataProviders=$t;exports.usePasteBlocks=Oa;exports.usePreviewMode=za;exports.useReadOnlyMode=ti;exports.useRemoveBlocks=hr;exports.useRemoveClassesFromBlocks=Fa;exports.useSavePage=gr;exports.useSelectedBlock=nr;exports.useSelectedBlockAllClasses=Ua;exports.useSelectedBlockCurrentClasses=Ga;exports.useSelectedBlockIds=be;exports.useSelectedBlocksDisplayChild=or;exports.useSelectedBreakpoints=ii;exports.useSelectedStylingBlocks=Do;exports.useSetAtom=Ct;exports.useStore=Fe;exports.useStylingBreakpoint=Oo;exports.useStylingState=Wa;exports.useToast=rt;exports.useUILibraryBlocks=di;exports.useUndoManager=et;exports.useUpdateBlocksProps=Ha;exports.useUpdateBlocksPropsRealtime=Ya;
@@ -1 +1 @@
1
- "use strict";var H2=(a,t,h)=>{if(!t.has(a))throw TypeError("Cannot "+h)};var c=(a,t,h)=>(H2(a,t,"read from private field"),h?h.call(a):t.get(a)),o=(a,t,h)=>{if(t.has(a))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(a):t.set(a,h)},e=(a,t,h,n)=>(H2(a,t,"write to private field"),n?n.call(a,h):t.set(a,h),h);var r2=(a,t,h,n)=>({set _(v){e(a,t,v,h)},get _(){return c(a,t,n)}}),M=(a,t,h)=>(H2(a,t,"access private method"),h);const l=require("./jsx-runtime-Z_BpKhVy.cjs"),T=require("react"),s0=require("./index-OB199Izc.cjs"),i2=require("@radix-ui/react-icons"),q=require("./index-h-hd6EvN.cjs"),a1=require("sonner"),p0=require("react-i18next"),h1=require("lodash-es"),V0=require("./html-to-json-efmv1pCj.cjs"),S2=require("lucide-react"),t0=require("./index-ecnGWzh9.cjs");function f0(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const h in a)if(h!=="default"){const n=Object.getOwnPropertyDescriptor(a,h);Object.defineProperty(t,h,n.get?n:{enumerable:!0,get:()=>a[h]})}}return t.default=a,Object.freeze(t)}const A=f0(T);var W1=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(a){return this.listeners.add(a),this.onSubscribe(),()=>{this.listeners.delete(a),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},N1=typeof window>"u"||"Deno"in window;function _(){}function m0(a,t){return typeof a=="function"?a(t):a}function s2(a){return typeof a=="number"&&a>=0&&a!==1/0}function a0(a,t){return Math.max(a+(t||0)-Date.now(),0)}function R2(a,t){const{type:h="all",exact:n,fetchStatus:v,predicate:r,queryKey:i,stale:z}=a;if(i){if(n){if(t.queryHash!==A2(i,t.options))return!1}else if(!Q1(t.queryKey,i))return!1}if(h!=="all"){const s=t.isActive();if(h==="active"&&!s||h==="inactive"&&s)return!1}return!(typeof z=="boolean"&&t.isStale()!==z||typeof v<"u"&&v!==t.state.fetchStatus||r&&!r(t))}function F2(a,t){const{exact:h,status:n,predicate:v,mutationKey:r}=a;if(r){if(!t.options.mutationKey)return!1;if(h){if(U1(t.options.mutationKey)!==U1(r))return!1}else if(!Q1(t.options.mutationKey,r))return!1}return!(n&&t.state.status!==n||v&&!v(t))}function A2(a,t){return((t==null?void 0:t.queryKeyHashFn)||U1)(a)}function U1(a){return JSON.stringify(a,(t,h)=>p2(h)?Object.keys(h).sort().reduce((n,v)=>(n[v]=h[v],n),{}):h)}function Q1(a,t){return a===t?!0:typeof a!=typeof t?!1:a&&t&&typeof a=="object"&&typeof t=="object"?!Object.keys(t).some(h=>!Q1(a[h],t[h])):!1}function h0(a,t){if(a===t)return a;const h=D2(a)&&D2(t);if(h||p2(a)&&p2(t)){const n=h?a.length:Object.keys(a).length,v=h?t:Object.keys(t),r=v.length,i=h?[]:{};let z=0;for(let s=0;s<r;s++){const p=h?s:v[s];i[p]=h0(a[p],t[p]),i[p]===a[p]&&z++}return n===r&&z===n?a:i}return t}function o2(a,t){if(a&&!t||t&&!a)return!1;for(const h in a)if(a[h]!==t[h])return!1;return!0}function D2(a){return Array.isArray(a)&&a.length===Object.keys(a).length}function p2(a){if(!k2(a))return!1;const t=a.constructor;if(typeof t>"u")return!0;const h=t.prototype;return!(!k2(h)||!h.hasOwnProperty("isPrototypeOf"))}function k2(a){return Object.prototype.toString.call(a)==="[object Object]"}function n0(a){return new Promise(t=>{setTimeout(t,a)})}function E2(a){n0(0).then(a)}function V2(a,t,h){return typeof h.structuralSharing=="function"?h.structuralSharing(a,t):h.structuralSharing!==!1?h0(a,t):t}function L0(a,t,h=0){const n=[...a,t];return h&&n.length>h?n.slice(1):n}function x0(a,t,h=0){const n=[t,...a];return h&&n.length>h?n.slice(0,-1):n}var u1,e1,B1,U2,w0=(U2=class extends W1{constructor(){super();o(this,u1,void 0);o(this,e1,void 0);o(this,B1,void 0);e(this,B1,t=>{if(!N1&&window.addEventListener){const h=()=>t();return window.addEventListener("visibilitychange",h,!1),()=>{window.removeEventListener("visibilitychange",h)}}})}onSubscribe(){c(this,e1)||this.setEventListener(c(this,B1))}onUnsubscribe(){var t;this.hasListeners()||((t=c(this,e1))==null||t.call(this),e(this,e1,void 0))}setEventListener(t){var h;e(this,B1,t),(h=c(this,e1))==null||h.call(this),e(this,e1,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){c(this,u1)!==t&&(e(this,u1,t),this.onFocus())}onFocus(){this.listeners.forEach(t=>{t()})}isFocused(){var t;return typeof c(this,u1)=="boolean"?c(this,u1):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},u1=new WeakMap,e1=new WeakMap,B1=new WeakMap,U2),d2=new w0,I1,l1,G1,Q2,B0=(Q2=class extends W1{constructor(){super();o(this,I1,!0);o(this,l1,void 0);o(this,G1,void 0);e(this,G1,t=>{if(!N1&&window.addEventListener){const h=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",h,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",h),window.removeEventListener("offline",n)}}})}onSubscribe(){c(this,l1)||this.setEventListener(c(this,G1))}onUnsubscribe(){var t;this.hasListeners()||((t=c(this,l1))==null||t.call(this),e(this,l1,void 0))}setEventListener(t){var h;e(this,G1,t),(h=c(this,l1))==null||h.call(this),e(this,l1,t(this.setOnline.bind(this)))}setOnline(t){c(this,I1)!==t&&(e(this,I1,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return c(this,I1)}},I1=new WeakMap,l1=new WeakMap,G1=new WeakMap,Q2),z2=new B0;function I0(a){return Math.min(1e3*2**a,3e4)}function M2(a){return(a??"online")==="online"?z2.isOnline():!0}var c0=class{constructor(a){this.revert=a==null?void 0:a.revert,this.silent=a==null?void 0:a.silent}};function u2(a){return a instanceof c0}function v0(a){let t=!1,h=0,n=!1,v,r,i;const z=new Promise((g,u)=>{r=g,i=u}),s=g=>{var u;n||(H(new c0(g)),(u=a.abort)==null||u.call(a))},p=()=>{t=!0},d=()=>{t=!1},x=()=>!d2.isFocused()||a.networkMode!=="always"&&!z2.isOnline(),b=g=>{var u;n||(n=!0,(u=a.onSuccess)==null||u.call(a,g),v==null||v(),r(g))},H=g=>{var u;n||(n=!0,(u=a.onError)==null||u.call(a,g),v==null||v(),i(g))},V=()=>new Promise(g=>{var u;v=G=>{const f=n||!x();return f&&g(G),f},(u=a.onPause)==null||u.call(a)}).then(()=>{var g;v=void 0,n||(g=a.onContinue)==null||g.call(a)}),B=()=>{if(n)return;let g;try{g=a.fn()}catch(u){g=Promise.reject(u)}Promise.resolve(g).then(b).catch(u=>{var F;if(n)return;const G=a.retry??(N1?0:3),f=a.retryDelay??I0,m=typeof f=="function"?f(h,u):f,y=G===!0||typeof G=="number"&&h<G||typeof G=="function"&&G(h,u);if(t||!y){H(u);return}h++,(F=a.onFail)==null||F.call(a,h,u),n0(m).then(()=>{if(x())return V()}).then(()=>{t?H(u):B()})})};return M2(a.networkMode)?B():V().then(B),{promise:z,cancel:s,continue:()=>(v==null?void 0:v())?z:Promise.resolve(),cancelRetry:p,continueRetry:d}}function G0(){let a=[],t=0,h=d=>{d()},n=d=>{d()};const v=d=>{let x;t++;try{x=d()}finally{t--,t||z()}return x},r=d=>{t?a.push(d):E2(()=>{h(d)})},i=d=>(...x)=>{r(()=>{d(...x)})},z=()=>{const d=a;a=[],d.length&&E2(()=>{n(()=>{d.forEach(x=>{h(x)})})})};return{batch:v,batchCalls:i,schedule:r,setNotifyFunction:d=>{h=d},setBatchNotifyFunction:d=>{n=d}}}var O=G0(),s1,K2,r0=(K2=class{constructor(){o(this,s1,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),s2(this.gcTime)&&e(this,s1,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(a){this.gcTime=Math.max(this.gcTime||0,a??(N1?1/0:5*60*1e3))}clearGcTimeout(){c(this,s1)&&(clearTimeout(c(this,s1)),e(this,s1,void 0))}},s1=new WeakMap,K2),C1,O1,j,i1,U,S,K1,p1,S1,e2,$,c1,q2,C0=(q2=class extends r0{constructor(t){super();o(this,S1);o(this,$);o(this,C1,void 0);o(this,O1,void 0);o(this,j,void 0);o(this,i1,void 0);o(this,U,void 0);o(this,S,void 0);o(this,K1,void 0);o(this,p1,void 0);e(this,p1,!1),e(this,K1,t.defaultOptions),M(this,S1,e2).call(this,t.options),e(this,S,[]),e(this,j,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,e(this,C1,t.state||O0(this.options)),this.state=c(this,C1),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!c(this,S).length&&this.state.fetchStatus==="idle"&&c(this,j).remove(this)}setData(t,h){const n=V2(this.state.data,t,this.options);return M(this,$,c1).call(this,{data:n,type:"success",dataUpdatedAt:h==null?void 0:h.updatedAt,manual:h==null?void 0:h.manual}),n}setState(t,h){M(this,$,c1).call(this,{type:"setState",state:t,setStateOptions:h})}cancel(t){var n;const h=c(this,i1);return(n=c(this,U))==null||n.cancel(t),h?h.then(_).catch(_):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(c(this,C1))}isActive(){return c(this,S).some(t=>t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||c(this,S).some(t=>t.getCurrentResult().isStale)}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!a0(this.state.dataUpdatedAt,t)}onFocus(){var h;const t=c(this,S).find(n=>n.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(h=c(this,U))==null||h.continue()}onOnline(){var h;const t=c(this,S).find(n=>n.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(h=c(this,U))==null||h.continue()}addObserver(t){c(this,S).includes(t)||(c(this,S).push(t),this.clearGcTimeout(),c(this,j).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){c(this,S).includes(t)&&(e(this,S,c(this,S).filter(h=>h!==t)),c(this,S).length||(c(this,U)&&(c(this,p1)?c(this,U).cancel({revert:!0}):c(this,U).cancelRetry()),this.scheduleGc()),c(this,j).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return c(this,S).length}invalidate(){this.state.isInvalidated||M(this,$,c1).call(this,{type:"invalidate"})}fetch(t,h){var p,d,x,b;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(h!=null&&h.cancelRefetch))this.cancel({silent:!0});else if(c(this,i1))return(p=c(this,U))==null||p.continueRetry(),c(this,i1)}if(t&&M(this,S1,e2).call(this,t),!this.options.queryFn){const H=c(this,S).find(V=>V.options.queryFn);H&&M(this,S1,e2).call(this,H.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const n=new AbortController,v={queryKey:this.queryKey,meta:this.meta},r=H=>{Object.defineProperty(H,"signal",{enumerable:!0,get:()=>(e(this,p1,!0),n.signal)})};r(v);const i=()=>this.options.queryFn?(e(this,p1,!1),this.options.persister?this.options.persister(this.options.queryFn,v,this):this.options.queryFn(v)):Promise.reject(new Error(`Missing queryFn: '${this.options.queryHash}'`)),z={fetchOptions:h,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:i};r(z),(d=this.options.behavior)==null||d.onFetch(z,this),e(this,O1,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((x=z.fetchOptions)==null?void 0:x.meta))&&M(this,$,c1).call(this,{type:"fetch",meta:(b=z.fetchOptions)==null?void 0:b.meta});const s=H=>{var V,B,g,u;u2(H)&&H.silent||M(this,$,c1).call(this,{type:"error",error:H}),u2(H)||((B=(V=c(this,j).config).onError)==null||B.call(V,H,this),(u=(g=c(this,j).config).onSettled)==null||u.call(g,this.state.data,H,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return e(this,U,v0({fn:z.fetchFn,abort:n.abort.bind(n),onSuccess:H=>{var V,B,g,u;if(typeof H>"u"){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),s(new Error(`${this.queryHash} data is undefined`));return}this.setData(H),(B=(V=c(this,j).config).onSuccess)==null||B.call(V,H,this),(u=(g=c(this,j).config).onSettled)==null||u.call(g,H,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:s,onFail:(H,V)=>{M(this,$,c1).call(this,{type:"failed",failureCount:H,error:V})},onPause:()=>{M(this,$,c1).call(this,{type:"pause"})},onContinue:()=>{M(this,$,c1).call(this,{type:"continue"})},retry:z.options.retry,retryDelay:z.options.retryDelay,networkMode:z.options.networkMode})),e(this,i1,c(this,U).promise),c(this,i1)}},C1=new WeakMap,O1=new WeakMap,j=new WeakMap,i1=new WeakMap,U=new WeakMap,S=new WeakMap,K1=new WeakMap,p1=new WeakMap,S1=new WeakSet,e2=function(t){this.options={...c(this,K1),...t},this.updateGcTime(this.options.gcTime)},$=new WeakSet,c1=function(t){const h=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:t.meta??null,fetchStatus:M2(this.options.networkMode)?"fetching":"paused",...!n.dataUpdatedAt&&{error:null,status:"pending"}};case"success":return{...n,data:t.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const v=t.error;return u2(v)&&v.revert&&c(this,O1)?{...c(this,O1),fetchStatus:"idle"}:{...n,error:v,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:v,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=h(this.state),O.batch(()=>{c(this,S).forEach(n=>{n.onQueryUpdate()}),c(this,j).notify({query:this,type:"updated",action:t})})},q2);function O0(a){const t=typeof a.initialData=="function"?a.initialData():a.initialData,h=typeof t<"u",n=h?typeof a.initialDataUpdatedAt=="function"?a.initialDataUpdatedAt():a.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:h?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:h?"success":"pending",fetchStatus:"idle"}}var Z,_2,S0=(_2=class extends W1{constructor(t={}){super();o(this,Z,void 0);this.config=t,e(this,Z,new Map)}build(t,h,n){const v=h.queryKey,r=h.queryHash??A2(v,h);let i=this.get(r);return i||(i=new C0({cache:this,queryKey:v,queryHash:r,options:t.defaultQueryOptions(h),state:n,defaultOptions:t.getQueryDefaults(v)}),this.add(i)),i}add(t){c(this,Z).has(t.queryHash)||(c(this,Z).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const h=c(this,Z).get(t.queryHash);h&&(t.destroy(),h===t&&c(this,Z).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){O.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return c(this,Z).get(t)}getAll(){return[...c(this,Z).values()]}find(t){const h={exact:!0,...t};return this.getAll().find(n=>R2(h,n))}findAll(t={}){const h=this.getAll();return Object.keys(t).length>0?h.filter(n=>R2(t,n)):h}notify(t){O.batch(()=>{this.listeners.forEach(h=>{h(t)})})}onFocus(){O.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){O.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Z=new WeakMap,_2),Y,q1,E,A1,X,r1,$2,A0=($2=class extends r0{constructor(t){super();o(this,X);o(this,Y,void 0);o(this,q1,void 0);o(this,E,void 0);o(this,A1,void 0);this.mutationId=t.mutationId,e(this,q1,t.defaultOptions),e(this,E,t.mutationCache),e(this,Y,[]),this.state=t.state||e0(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...c(this,q1),...t},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){c(this,Y).includes(t)||(c(this,Y).push(t),this.clearGcTimeout(),c(this,E).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){e(this,Y,c(this,Y).filter(h=>h!==t)),this.scheduleGc(),c(this,E).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){c(this,Y).length||(this.state.status==="pending"?this.scheduleGc():c(this,E).remove(this))}continue(){var t;return((t=c(this,A1))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var v,r,i,z,s,p,d,x,b,H,V,B,g,u,G,f,m,y,F,I;const h=()=>(e(this,A1,v0({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(w,n1)=>{M(this,X,r1).call(this,{type:"failed",failureCount:w,error:n1})},onPause:()=>{M(this,X,r1).call(this,{type:"pause"})},onContinue:()=>{M(this,X,r1).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),c(this,A1).promise),n=this.state.status==="pending";try{if(!n){M(this,X,r1).call(this,{type:"pending",variables:t}),await((r=(v=c(this,E).config).onMutate)==null?void 0:r.call(v,t,this));const n1=await((z=(i=this.options).onMutate)==null?void 0:z.call(i,t));n1!==this.state.context&&M(this,X,r1).call(this,{type:"pending",context:n1,variables:t})}const w=await h();return await((p=(s=c(this,E).config).onSuccess)==null?void 0:p.call(s,w,t,this.state.context,this)),await((x=(d=this.options).onSuccess)==null?void 0:x.call(d,w,t,this.state.context)),await((H=(b=c(this,E).config).onSettled)==null?void 0:H.call(b,w,null,this.state.variables,this.state.context,this)),await((B=(V=this.options).onSettled)==null?void 0:B.call(V,w,null,t,this.state.context)),M(this,X,r1).call(this,{type:"success",data:w}),w}catch(w){try{throw await((u=(g=c(this,E).config).onError)==null?void 0:u.call(g,w,t,this.state.context,this)),await((f=(G=this.options).onError)==null?void 0:f.call(G,w,t,this.state.context)),await((y=(m=c(this,E).config).onSettled)==null?void 0:y.call(m,void 0,w,this.state.variables,this.state.context,this)),await((I=(F=this.options).onSettled)==null?void 0:I.call(F,void 0,w,t,this.state.context)),w}finally{M(this,X,r1).call(this,{type:"error",error:w})}}}},Y=new WeakMap,q1=new WeakMap,E=new WeakMap,A1=new WeakMap,X=new WeakSet,r1=function(t){const h=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!M2(this.options.networkMode),status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=h(this.state),O.batch(()=>{c(this,Y).forEach(n=>{n.onMutationUpdate(t)}),c(this,E).notify({mutation:this,type:"updated",action:t})})},$2);function e0(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Q,_1,V1,J2,y0=(J2=class extends W1{constructor(t={}){super();o(this,Q,void 0);o(this,_1,void 0);o(this,V1,void 0);this.config=t,e(this,Q,[]),e(this,_1,0)}build(t,h,n){const v=new A0({mutationCache:this,mutationId:++r2(this,_1)._,options:t.defaultMutationOptions(h),state:n});return this.add(v),v}add(t){c(this,Q).push(t),this.notify({type:"added",mutation:t})}remove(t){e(this,Q,c(this,Q).filter(h=>h!==t)),this.notify({type:"removed",mutation:t})}clear(){O.batch(()=>{c(this,Q).forEach(t=>{this.remove(t)})})}getAll(){return c(this,Q)}find(t){const h={exact:!0,...t};return c(this,Q).find(n=>F2(h,n))}findAll(t={}){return c(this,Q).filter(h=>F2(t,h))}notify(t){O.batch(()=>{this.listeners.forEach(h=>{h(t)})})}resumePausedMutations(){return e(this,V1,(c(this,V1)??Promise.resolve()).then(()=>{const t=c(this,Q).filter(h=>h.state.isPaused);return O.batch(()=>t.reduce((h,n)=>h.then(()=>n.continue().catch(_)),Promise.resolve()))}).then(()=>{e(this,V1,void 0)})),c(this,V1)}},Q=new WeakMap,_1=new WeakMap,V1=new WeakMap,J2);function b0(a){return{onFetch:(t,h)=>{const n=async()=>{var V,B,g,u,G;const v=t.options,r=(g=(B=(V=t.fetchOptions)==null?void 0:V.meta)==null?void 0:B.fetchMore)==null?void 0:g.direction,i=((u=t.state.data)==null?void 0:u.pages)||[],z=((G=t.state.data)==null?void 0:G.pageParams)||[],s={pages:[],pageParams:[]};let p=!1;const d=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(t.signal.aborted?p=!0:t.signal.addEventListener("abort",()=>{p=!0}),t.signal)})},x=t.options.queryFn||(()=>Promise.reject(new Error(`Missing queryFn: '${t.options.queryHash}'`))),b=async(f,m,y)=>{if(p)return Promise.reject();if(m==null&&f.pages.length)return Promise.resolve(f);const F={queryKey:t.queryKey,pageParam:m,direction:y?"backward":"forward",meta:t.options.meta};d(F);const I=await x(F),{maxPages:w}=t.options,n1=y?x0:L0;return{pages:n1(f.pages,I,w),pageParams:n1(f.pageParams,m,w)}};let H;if(r&&i.length){const f=r==="backward",m=f?P0:T2,y={pages:i,pageParams:z},F=m(v,y);H=await b(y,F,f)}else{H=await b(s,z[0]??v.initialPageParam);const f=a??i.length;for(let m=1;m<f;m++){const y=T2(v,H);H=await b(H,y)}}return H};t.options.persister?t.fetchFn=()=>{var v,r;return(r=(v=t.options).persister)==null?void 0:r.call(v,n,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},h)}:t.fetchFn=n}}}function T2(a,{pages:t,pageParams:h}){const n=t.length-1;return a.getNextPageParam(t[n],t,h[n],h)}function P0(a,{pages:t,pageParams:h}){var n;return(n=a.getPreviousPageParam)==null?void 0:n.call(a,t[0],t,h[0],h)}var C,o1,d1,y1,b1,z1,P1,R1,Z2,R0=(Z2=class{constructor(a={}){o(this,C,void 0);o(this,o1,void 0);o(this,d1,void 0);o(this,y1,void 0);o(this,b1,void 0);o(this,z1,void 0);o(this,P1,void 0);o(this,R1,void 0);e(this,C,a.queryCache||new S0),e(this,o1,a.mutationCache||new y0),e(this,d1,a.defaultOptions||{}),e(this,y1,new Map),e(this,b1,new Map),e(this,z1,0)}mount(){r2(this,z1)._++,c(this,z1)===1&&(e(this,P1,d2.subscribe(()=>{d2.isFocused()&&(this.resumePausedMutations(),c(this,C).onFocus())})),e(this,R1,z2.subscribe(()=>{z2.isOnline()&&(this.resumePausedMutations(),c(this,C).onOnline())})))}unmount(){var a,t;r2(this,z1)._--,c(this,z1)===0&&((a=c(this,P1))==null||a.call(this),e(this,P1,void 0),(t=c(this,R1))==null||t.call(this),e(this,R1,void 0))}isFetching(a){return c(this,C).findAll({...a,fetchStatus:"fetching"}).length}isMutating(a){return c(this,o1).findAll({...a,status:"pending"}).length}getQueryData(a){var t;return(t=c(this,C).find({queryKey:a}))==null?void 0:t.state.data}ensureQueryData(a){const t=this.getQueryData(a.queryKey);return t!==void 0?Promise.resolve(t):this.fetchQuery(a)}getQueriesData(a){return this.getQueryCache().findAll(a).map(({queryKey:t,state:h})=>{const n=h.data;return[t,n]})}setQueryData(a,t,h){const n=c(this,C).find({queryKey:a}),v=n==null?void 0:n.state.data,r=m0(t,v);if(typeof r>"u")return;const i=this.defaultQueryOptions({queryKey:a});return c(this,C).build(this,i).setData(r,{...h,manual:!0})}setQueriesData(a,t,h){return O.batch(()=>this.getQueryCache().findAll(a).map(({queryKey:n})=>[n,this.setQueryData(n,t,h)]))}getQueryState(a){var t;return(t=c(this,C).find({queryKey:a}))==null?void 0:t.state}removeQueries(a){const t=c(this,C);O.batch(()=>{t.findAll(a).forEach(h=>{t.remove(h)})})}resetQueries(a,t){const h=c(this,C),n={type:"active",...a};return O.batch(()=>(h.findAll(a).forEach(v=>{v.reset()}),this.refetchQueries(n,t)))}cancelQueries(a={},t={}){const h={revert:!0,...t},n=O.batch(()=>c(this,C).findAll(a).map(v=>v.cancel(h)));return Promise.all(n).then(_).catch(_)}invalidateQueries(a={},t={}){return O.batch(()=>{if(c(this,C).findAll(a).forEach(n=>{n.invalidate()}),a.refetchType==="none")return Promise.resolve();const h={...a,type:a.refetchType??a.type??"active"};return this.refetchQueries(h,t)})}refetchQueries(a={},t){const h={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},n=O.batch(()=>c(this,C).findAll(a).filter(v=>!v.isDisabled()).map(v=>{let r=v.fetch(void 0,h);return h.throwOnError||(r=r.catch(_)),v.state.fetchStatus==="paused"?Promise.resolve():r}));return Promise.all(n).then(_)}fetchQuery(a){const t=this.defaultQueryOptions(a);typeof t.retry>"u"&&(t.retry=!1);const h=c(this,C).build(this,t);return h.isStaleByTime(t.staleTime)?h.fetch(t):Promise.resolve(h.state.data)}prefetchQuery(a){return this.fetchQuery(a).then(_).catch(_)}fetchInfiniteQuery(a){return a.behavior=b0(a.pages),this.fetchQuery(a)}prefetchInfiniteQuery(a){return this.fetchInfiniteQuery(a).then(_).catch(_)}resumePausedMutations(){return c(this,o1).resumePausedMutations()}getQueryCache(){return c(this,C)}getMutationCache(){return c(this,o1)}getDefaultOptions(){return c(this,d1)}setDefaultOptions(a){e(this,d1,a)}setQueryDefaults(a,t){c(this,y1).set(U1(a),{queryKey:a,defaultOptions:t})}getQueryDefaults(a){const t=[...c(this,y1).values()];let h={};return t.forEach(n=>{Q1(a,n.queryKey)&&(h={...h,...n.defaultOptions})}),h}setMutationDefaults(a,t){c(this,b1).set(U1(a),{mutationKey:a,defaultOptions:t})}getMutationDefaults(a){const t=[...c(this,b1).values()];let h={};return t.forEach(n=>{Q1(a,n.mutationKey)&&(h={...h,...n.defaultOptions})}),h}defaultQueryOptions(a){if(a!=null&&a._defaulted)return a;const t={...c(this,d1).queries,...(a==null?void 0:a.queryKey)&&this.getQueryDefaults(a.queryKey),...a,_defaulted:!0};return t.queryHash||(t.queryHash=A2(t.queryKey,t)),typeof t.refetchOnReconnect>"u"&&(t.refetchOnReconnect=t.networkMode!=="always"),typeof t.throwOnError>"u"&&(t.throwOnError=!!t.suspense),typeof t.networkMode>"u"&&t.persister&&(t.networkMode="offlineFirst"),t}defaultMutationOptions(a){return a!=null&&a._defaulted?a:{...c(this,d1).mutations,...(a==null?void 0:a.mutationKey)&&this.getMutationDefaults(a.mutationKey),...a,_defaulted:!0}}clear(){c(this,C).clear(),c(this,o1).clear()}},C=new WeakMap,o1=new WeakMap,d1=new WeakMap,y1=new WeakMap,b1=new WeakMap,z1=new WeakMap,P1=new WeakMap,R1=new WeakMap,Z2),k,L,F1,P,f1,D1,t1,$1,k1,E1,m1,L1,g1,x1,w1,j1,J1,f2,Z1,m2,Y1,L2,X1,x2,t2,w2,a2,B2,h2,I2,g2,l0,Y2,F0=(Y2=class extends W1{constructor(t,h){super();o(this,w1);o(this,J1);o(this,Z1);o(this,Y1);o(this,X1);o(this,t2);o(this,a2);o(this,h2);o(this,g2);o(this,k,void 0);o(this,L,void 0);o(this,F1,void 0);o(this,P,void 0);o(this,f1,void 0);o(this,D1,void 0);o(this,t1,void 0);o(this,$1,void 0);o(this,k1,void 0);o(this,E1,void 0);o(this,m1,void 0);o(this,L1,void 0);o(this,g1,void 0);o(this,x1,void 0);e(this,L,void 0),e(this,F1,void 0),e(this,P,void 0),e(this,x1,new Set),e(this,k,t),this.options=h,e(this,t1,null),this.bindMethods(),this.setOptions(h)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(c(this,L).addObserver(this),N2(c(this,L),this.options)?M(this,w1,j1).call(this):this.updateResult(),M(this,X1,x2).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return G2(c(this,L),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return G2(c(this,L),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,M(this,t2,w2).call(this),M(this,a2,B2).call(this),c(this,L).removeObserver(this)}setOptions(t,h){const n=this.options,v=c(this,L);if(this.options=c(this,k).defaultQueryOptions(t),o2(n,this.options)||c(this,k).getQueryCache().notify({type:"observerOptionsUpdated",query:c(this,L),observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=n.queryKey),M(this,h2,I2).call(this);const r=this.hasListeners();r&&W2(c(this,L),v,this.options,n)&&M(this,w1,j1).call(this),this.updateResult(h),r&&(c(this,L)!==v||this.options.enabled!==n.enabled||this.options.staleTime!==n.staleTime)&&M(this,J1,f2).call(this);const i=M(this,Z1,m2).call(this);r&&(c(this,L)!==v||this.options.enabled!==n.enabled||i!==c(this,g1))&&M(this,Y1,L2).call(this,i)}getOptimisticResult(t){const h=c(this,k).getQueryCache().build(c(this,k),t),n=this.createResult(h,t);return k0(this,n)&&(e(this,P,n),e(this,D1,this.options),e(this,f1,c(this,L).state)),n}getCurrentResult(){return c(this,P)}trackResult(t){const h={};return Object.keys(t).forEach(n=>{Object.defineProperty(h,n,{configurable:!1,enumerable:!0,get:()=>(c(this,x1).add(n),t[n])})}),h}getCurrentQuery(){return c(this,L)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const h=c(this,k).defaultQueryOptions(t),n=c(this,k).getQueryCache().build(c(this,k),h);return n.isFetchingOptimistic=!0,n.fetch().then(()=>this.createResult(n,h))}fetch(t){return M(this,w1,j1).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),c(this,P)))}createResult(t,h){var F;const n=c(this,L),v=this.options,r=c(this,P),i=c(this,f1),z=c(this,D1),p=t!==n?t.state:c(this,F1),{state:d}=t;let{error:x,errorUpdatedAt:b,fetchStatus:H,status:V}=d,B=!1,g;if(h._optimisticResults){const I=this.hasListeners(),w=!I&&N2(t,h),n1=I&&W2(t,n,h,v);(w||n1)&&(H=M2(t.options.networkMode)?"fetching":"paused",d.dataUpdatedAt||(V="pending")),h._optimisticResults==="isRestoring"&&(H="idle")}if(h.select&&typeof d.data<"u")if(r&&d.data===(i==null?void 0:i.data)&&h.select===c(this,$1))g=c(this,k1);else try{e(this,$1,h.select),g=h.select(d.data),g=V2(r==null?void 0:r.data,g,h),e(this,k1,g),e(this,t1,null)}catch(I){e(this,t1,I)}else g=d.data;if(typeof h.placeholderData<"u"&&typeof g>"u"&&V==="pending"){let I;if(r!=null&&r.isPlaceholderData&&h.placeholderData===(z==null?void 0:z.placeholderData))I=r.data;else if(I=typeof h.placeholderData=="function"?h.placeholderData((F=c(this,E1))==null?void 0:F.state.data,c(this,E1)):h.placeholderData,h.select&&typeof I<"u")try{I=h.select(I),e(this,t1,null)}catch(w){e(this,t1,w)}typeof I<"u"&&(V="success",g=V2(r==null?void 0:r.data,I,h),B=!0)}c(this,t1)&&(x=c(this,t1),g=c(this,k1),b=Date.now(),V="error");const u=H==="fetching",G=V==="pending",f=V==="error",m=G&&u;return{status:V,fetchStatus:H,isPending:G,isSuccess:V==="success",isError:f,isInitialLoading:m,isLoading:m,data:g,dataUpdatedAt:d.dataUpdatedAt,error:x,errorUpdatedAt:b,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>p.dataUpdateCount||d.errorUpdateCount>p.errorUpdateCount,isFetching:u,isRefetching:u&&!G,isLoadingError:f&&d.dataUpdatedAt===0,isPaused:H==="paused",isPlaceholderData:B,isRefetchError:f&&d.dataUpdatedAt!==0,isStale:y2(t,h),refetch:this.refetch}}updateResult(t){const h=c(this,P),n=this.createResult(c(this,L),this.options);if(e(this,f1,c(this,L).state),e(this,D1,this.options),c(this,f1).data!==void 0&&e(this,E1,c(this,L)),o2(n,h))return;e(this,P,n);const v={},r=()=>{if(!h)return!0;const{notifyOnChangeProps:i}=this.options,z=typeof i=="function"?i():i;if(z==="all"||!z&&!c(this,x1).size)return!0;const s=new Set(z??c(this,x1));return this.options.throwOnError&&s.add("error"),Object.keys(c(this,P)).some(p=>{const d=p;return c(this,P)[d]!==h[d]&&s.has(d)})};(t==null?void 0:t.listeners)!==!1&&r()&&(v.listeners=!0),M(this,g2,l0).call(this,{...v,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&M(this,X1,x2).call(this)}},k=new WeakMap,L=new WeakMap,F1=new WeakMap,P=new WeakMap,f1=new WeakMap,D1=new WeakMap,t1=new WeakMap,$1=new WeakMap,k1=new WeakMap,E1=new WeakMap,m1=new WeakMap,L1=new WeakMap,g1=new WeakMap,x1=new WeakMap,w1=new WeakSet,j1=function(t){M(this,h2,I2).call(this);let h=c(this,L).fetch(this.options,t);return t!=null&&t.throwOnError||(h=h.catch(_)),h},J1=new WeakSet,f2=function(){if(M(this,t2,w2).call(this),N1||c(this,P).isStale||!s2(this.options.staleTime))return;const h=a0(c(this,P).dataUpdatedAt,this.options.staleTime)+1;e(this,m1,setTimeout(()=>{c(this,P).isStale||this.updateResult()},h))},Z1=new WeakSet,m2=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(c(this,L)):this.options.refetchInterval)??!1},Y1=new WeakSet,L2=function(t){M(this,a2,B2).call(this),e(this,g1,t),!(N1||this.options.enabled===!1||!s2(c(this,g1))||c(this,g1)===0)&&e(this,L1,setInterval(()=>{(this.options.refetchIntervalInBackground||d2.isFocused())&&M(this,w1,j1).call(this)},c(this,g1)))},X1=new WeakSet,x2=function(){M(this,J1,f2).call(this),M(this,Y1,L2).call(this,M(this,Z1,m2).call(this))},t2=new WeakSet,w2=function(){c(this,m1)&&(clearTimeout(c(this,m1)),e(this,m1,void 0))},a2=new WeakSet,B2=function(){c(this,L1)&&(clearInterval(c(this,L1)),e(this,L1,void 0))},h2=new WeakSet,I2=function(){const t=c(this,k).getQueryCache().build(c(this,k),this.options);if(t===c(this,L))return;const h=c(this,L);e(this,L,t),e(this,F1,t.state),this.hasListeners()&&(h==null||h.removeObserver(this),t.addObserver(this))},g2=new WeakSet,l0=function(t){O.batch(()=>{t.listeners&&this.listeners.forEach(h=>{h(c(this,P))}),c(this,k).getQueryCache().notify({query:c(this,L),type:"observerResultsUpdated"})})},Y2);function D0(a,t){return t.enabled!==!1&&!a.state.dataUpdatedAt&&!(a.state.status==="error"&&t.retryOnMount===!1)}function N2(a,t){return D0(a,t)||a.state.dataUpdatedAt>0&&G2(a,t,t.refetchOnMount)}function G2(a,t,h){if(t.enabled!==!1){const n=typeof h=="function"?h(a):h;return n==="always"||n!==!1&&y2(a,t)}return!1}function W2(a,t,h,n){return h.enabled!==!1&&(a!==t||n.enabled===!1)&&(!h.suspense||a.state.status!=="error")&&y2(a,h)}function y2(a,t){return a.isStaleByTime(t.staleTime)}function k0(a,t){return!o2(a.getCurrentResult(),t)}var M1,D,K,v1,T1,l2,n2,C2,X2,E0=(X2=class extends W1{constructor(t,h){super();o(this,T1);o(this,n2);o(this,M1,void 0);o(this,D,void 0);o(this,K,void 0);o(this,v1,void 0);e(this,D,void 0),e(this,M1,t),this.setOptions(h),this.bindMethods(),M(this,T1,l2).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var n;const h=this.options;this.options=c(this,M1).defaultMutationOptions(t),o2(h,this.options)||c(this,M1).getMutationCache().notify({type:"observerOptionsUpdated",mutation:c(this,K),observer:this}),(n=c(this,K))==null||n.setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=c(this,K))==null||t.removeObserver(this)}onMutationUpdate(t){M(this,T1,l2).call(this),M(this,n2,C2).call(this,t)}getCurrentResult(){return c(this,D)}reset(){e(this,K,void 0),M(this,T1,l2).call(this),M(this,n2,C2).call(this)}mutate(t,h){var n;return e(this,v1,h),(n=c(this,K))==null||n.removeObserver(this),e(this,K,c(this,M1).getMutationCache().build(c(this,M1),this.options)),c(this,K).addObserver(this),c(this,K).execute(t)}},M1=new WeakMap,D=new WeakMap,K=new WeakMap,v1=new WeakMap,T1=new WeakSet,l2=function(){var h;const t=((h=c(this,K))==null?void 0:h.state)??e0();e(this,D,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},n2=new WeakSet,C2=function(t){O.batch(()=>{var h,n,v,r,i,z,s,p;c(this,v1)&&this.hasListeners()&&((t==null?void 0:t.type)==="success"?((n=(h=c(this,v1)).onSuccess)==null||n.call(h,t.data,c(this,D).variables,c(this,D).context),(r=(v=c(this,v1)).onSettled)==null||r.call(v,t.data,null,c(this,D).variables,c(this,D).context)):(t==null?void 0:t.type)==="error"&&((z=(i=c(this,v1)).onError)==null||z.call(i,t.error,c(this,D).variables,c(this,D).context),(p=(s=c(this,v1)).onSettled)==null||p.call(s,void 0,t.error,c(this,D).variables,c(this,D).context))),this.listeners.forEach(d=>{d(c(this,D))})})},X2);var i0=A.createContext(void 0),N=a=>{const t=A.useContext(i0);if(a)return a;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},T0=({client:a,children:t})=>(A.useEffect(()=>(a.mount(),()=>{a.unmount()}),[a]),A.createElement(i0.Provider,{value:a},t)),o0=A.createContext(!1),N0=()=>A.useContext(o0),C4=o0.Provider;function W0(){let a=!1;return{clearReset:()=>{a=!1},reset:()=>{a=!0},isReset:()=>a}}var j0=A.createContext(W0()),U0=()=>A.useContext(j0);function d0(a,t){return typeof a=="function"?a(...t):!!a}var Q0=(a,t)=>{(a.suspense||a.throwOnError)&&(t.isReset()||(a.retryOnMount=!1))},K0=a=>{A.useEffect(()=>{a.clearReset()},[a])},q0=({result:a,errorResetBoundary:t,throwOnError:h,query:n})=>a.isError&&!t.isReset()&&!a.isFetching&&d0(h,[a.error,n]);var _0=a=>{a.suspense&&typeof a.staleTime!="number"&&(a.staleTime=1e3)};var $0=(a,t)=>(a==null?void 0:a.suspense)&&t.isPending,J0=(a,t,h)=>t.fetchOptimistic(a).catch(()=>{h.clearReset()});function Z0(a,t,h){if(process.env.NODE_ENV!=="production"&&(typeof a!="object"||Array.isArray(a)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=N(h),v=N0(),r=U0(),i=n.defaultQueryOptions(a);i._optimisticResults=v?"isRestoring":"optimistic",_0(i),Q0(i,r),K0(r);const[z]=A.useState(()=>new t(n,i)),s=z.getOptimisticResult(i);if(A.useSyncExternalStore(A.useCallback(p=>{const d=v?()=>{}:z.subscribe(O.batchCalls(p));return z.updateResult(),d},[z,v]),()=>z.getCurrentResult(),()=>z.getCurrentResult()),A.useEffect(()=>{z.setOptions(i,{listeners:!1})},[i,z]),$0(i,s))throw J0(i,z,r);if(q0({result:s,errorResetBoundary:r,throwOnError:i.throwOnError,query:z.getCurrentQuery()}))throw s.error;return i.notifyOnChangeProps?s:z.trackResult(s)}function c2(a,t){return Z0(a,F0,t)}function J(a,t){const h=N(t),[n]=A.useState(()=>new E0(h,a));A.useEffect(()=>{n.setOptions(a)},[n,a]);const v=A.useSyncExternalStore(A.useCallback(i=>n.subscribe(O.batchCalls(i)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),r=A.useCallback((i,z)=>{n.mutate(i,z).catch(Y0)},[n]);if(v.error&&d0(n.options.throwOnError,[v.error]))throw v.error;return{...v,mutate:r,mutateAsync:v.mutate}}function Y0(){}function R(){return N().getQueryData(["apiBaseUrl"])||"/api/chaibuilder"}const H1=()=>{const{data:a,refetch:t}=c2({queryKey:["currentPage"],queryFn:()=>localStorage.getItem("currentPage")||""});return[a,h=>{h&&(localStorage.setItem("currentPage",h||""),t())}]};let j2="";const v2=()=>(j2=localStorage.getItem("__chai_at"),j2);function X0(a){const t={method:"GET",headers:{"x-chai-access-token":v2()}};return fetch(a,t)}function t4(a,t){const h={method:"POST",headers:{"x-chai-access-token":v2()},body:JSON.stringify(t)};return fetch(a,h)}function a4(a,t){const h={method:"PUT",headers:{"x-chai-access-token":v2()},body:JSON.stringify(t)};return fetch(a,h)}function h4(a,t){const h={method:"DELETE",headers:{"x-chai-access-token":v2()},body:JSON.stringify(t)};return fetch(a,h)}const W={get:X0,post:t4,put:a4,delete:h4},b2=()=>{const[a,t]=H1(),h=R();return c2({queryKey:["project"],queryFn:async()=>{const{data:n}=await W.get(`${h}/project`).then(v=>v.json());if(!a&&n){const v=localStorage.getItem("currentPage");t(v||(n==null?void 0:n.homepage))}return n}})},P2=()=>{const a=R();return c2({queryKey:["pages"],queryFn:async()=>{const{data:t}=await W.get(`${a}/pages`).then(h=>h.json());return t||[]}})},z0=()=>{const[a]=H1(),t=R();return c2({queryKey:["page_data",a],queryFn:async()=>{const{data:h}=await W.get(`${t}/page?uuid=${a}`).then(n=>n.json());return h},enabled:!!a,staleTime:3e3})},O2=()=>l.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen bg-gray-200",children:l.jsxRuntimeExports.jsxs("div",{className:"flex flex-col h-full w-full justify-center items-center",children:[l.jsxRuntimeExports.jsxs("div",{className:"flex flex-row gap-2",children:[l.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-orange-600 animate-bounce [animation-delay:.6s]"}),l.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-blue-600 animate-bounce [animation-delay:.4s]"}),l.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-green-600 animate-bounce [animation-delay:.2s]"}),l.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-yellow-600 animate-bounce [animation-delay:.0s]"})]}),l.jsxRuntimeExports.jsx("div",{className:"text-gray-700 font-thin",children:"Loading Builder..."})]})}),g0=(a="Project updated successfully.")=>{const t=N(),h=R();return J({mutationFn:async n=>await W.put(`${h}/project`,n).then(v=>v.json()),onSuccess:()=>{t.invalidateQueries({queryKey:["project"]}),a1.toast.success(a)}})},M0=()=>{const[a]=["SAVED"],[t,h]=H1(),n=q.useBuilderReset(),{t:v}=p0.useTranslation();return r=>a!=="SAVED"?(a1.toast.error(v("You have unsaved changes. Please save before changing the page.")),!1):t===r.uuid?!1:(n(),setTimeout(()=>h(r.uuid),100),!0)},n4=()=>{const a=N(),t=M0(),h=R();return J({mutationFn:async n=>W.post(`${h}/pages`,n).then(v=>v.json()),onSuccess:n=>{a.invalidateQueries({queryKey:["pages"]}),t({uuid:n.uuid,slug:n.slug}),a1.toast.success("Page added successfully.")}})},H0=()=>{const a=R(),[t]=H1(),h=N();return J({mutationFn:async n=>W.put(`${a}/page`,n).then(v=>v.json()),onSuccess:async n=>{var v;if(n.result==="error"&&((v=n.error)==null?void 0:v.code)=="PAGE_LOCKED"){h.invalidateQueries({queryKey:["page_data",t]});return}a1.toast.success("Page saved successfully.")}})},c4=()=>{const a=R(),{data:t}=P2(),[h]=H1(),{data:n}=b2(),v=N();return J({mutationFn:async()=>{const r=t.find(i=>i.uuid===h).slug;return await W.post(`${a}/publish`,{slug:r,uuid:h,isHomepage:(n==null?void 0:n.homepage)===h}).then(i=>i.json())},onSuccess:async r=>{var i;if(r.result==="error"&&((i=r.error)==null?void 0:i.code)=="PAGE_LOCKED"){v.invalidateQueries({queryKey:["page_data",h]});return}a1.toast.success("Page published successfully.",{position:"bottom-right",duration:2e3})}})},v4=()=>{const a=N(),t=R();return J({mutationFn:async h=>W.delete(`${t}/page`,h).then(n=>n.json()),onSuccess:()=>{a1.toast.success("Page deleted successfully."),a.invalidateQueries({queryKey:["pages"]})}})},r4=()=>{const a=N(),t=R();return J({mutationFn:async h=>W.post(`${t}/take-control`,{uuid:h}).then(n=>n.json()),onSuccess:(h,n)=>{a.invalidateQueries({queryKey:["page_data",n]})}})},e4=()=>{const a=R();return J({mutationFn:async()=>{const{data:t}=await W.get(`${a}/library`).then(h=>h.json());return h1.sortBy(h1.filter(t,h=>!h1.has(h,"hidden")),"group")}})},l4=()=>{const a=R();return J({mutationFn:async t=>{if(!t||!t.uuid)return[];try{const{data:h}=await W.get(`${a}/block?uuid=${t.uuid}&format=${t.format}`).then(async n=>t.format==="html"?V0.getBlocksFromHTML(await n.text()):await n.json());return h1.set(h,"0._name",h1.capitalize(t.group)),h||[]}catch{return[]}}})},i4=()=>{const a=R();return J({mutationFn:async t=>{const h=new FormData;h.append("file",t);const{data:n}=await fetch(`${a}/upload`,{method:"POST",headers:{"x-chai-access-token":v2()},body:h}).then(v=>v.json());return n}})};function u0(a){return t0.GenIcon({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"}},{tag:"path",attr:{d:"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"}}]})(a)}function o4(a){return t0.GenIcon({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"}},{tag:"path",attr:{d:"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"}}]})(a)}const d4=()=>{const{mutate:a,isPending:t}=r4(),[h]=H1(),{data:n}=z0(),v=h1.get(n,"lockedBy.name",""),r=h1.get(n,"lockedBy.email","");return l.jsxRuntimeExports.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg drop-shadow-2xl mx-auto p-10 space-y-4 text-center max-w-xl",children:[l.jsxRuntimeExports.jsxs("h2",{className:"text-2xl font-bold",children:["Page is ",l.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"locked"})]}),l.jsxRuntimeExports.jsxs("div",{className:"text-gray-500 dark:text-gray-400 font-light",children:["This page is currently being edited by ",l.jsxRuntimeExports.jsx("br",{}),l.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-3 w-max mx-auto font-medium text-gray-700 mt-2 text-sm",children:[l.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 bg-gray-100 py-1 px-2 rounded-md",children:[l.jsxRuntimeExports.jsx(o4,{className:"w-4 h-4 text-gray-500"})," ",v]}),l.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 bg-gray-100 py-1 px-2 rounded-md lowercase",children:[l.jsxRuntimeExports.jsx(u0,{className:"w-4 h-4 text-gray-500"})," ",r]})]}),l.jsxRuntimeExports.jsxs("div",{className:"pt-4",children:["If you take control, ",v," will be ",l.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"restricted"})," from making additional edits."]})]}),l.jsxRuntimeExports.jsx(q.Button,{disabled:t,onClick:()=>a(h),className:`w-36 ${t?"bg-transparent shadow-none hover:bg-transparent":""}`,children:t?l.jsxRuntimeExports.jsx(S2.Loader,{className:"text-sm animate-spin text-gray-500"}):"Take Over"})]})},z4=()=>{const a=R(),t=N();return J({mutationFn:async h=>{const n=await fetch(`${a}/login`,{method:"POST",body:JSON.stringify(h)});if(n.ok)return await n.json();throw n.status===401?new Error("Invalid login credentials"):new Error("Invalid")},onSuccess:h=>{const{data:n}=h;if(!n.accessToken){a1.toast.error("Something went wrong. Please try again.",{position:"top-center"});return}localStorage.setItem("__chai_at",n.accessToken),localStorage.setItem("__chai_ur",JSON.stringify(h1.omit(n,["accessToken"]))),t.invalidateQueries({queryKey:["verify"]}),a1.toast.success("Logged in successfully.")},onError:()=>{a1.toast.error("Invalid login credentials. Please try again.",{position:"top-center"})}})},g4=()=>{const a=R();return c2({queryKey:["verify"],queryFn:async()=>{const t=await W.get(`${a}/verify`);return t.ok?(await t.json()).result==="success"?{valid:!0}:(localStorage.removeItem("__chai_at"),{valid:!1}):(localStorage.removeItem("__chai_at"),{valid:!0})}})},M4=()=>{const a=R(),t=N();return J({mutationFn:async()=>{const{result:h}=await W.post(`${a}/logout`).then(n=>n.json());if(h==="success")return localStorage.clear(),t.invalidateQueries({queryKey:["verify"]}),{logout:!0};throw new Error("Invalid session")}})},H4=({children:a})=>{const t=M4();return l.jsxRuntimeExports.jsxs(q.AlertDialog,{children:[l.jsxRuntimeExports.jsx(q.AlertDialogTrigger,{asChild:!0,children:a}),l.jsxRuntimeExports.jsxs(q.AlertDialogContent,{children:[l.jsxRuntimeExports.jsxs(q.AlertDialogHeader,{children:[l.jsxRuntimeExports.jsxs(q.AlertDialogTitle,{children:["Are you sure, you want to ",l.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"Sign Out"}),"?"]}),l.jsxRuntimeExports.jsx(q.AlertDialogDescription,{children:"Kindly ensure that all your data is saved before proceeding with the sign-out process to prevent any potential loss of unsaved information"})]}),l.jsxRuntimeExports.jsxs(q.AlertDialogFooter,{children:[l.jsxRuntimeExports.jsx(q.AlertDialogCancel,{disabled:t.isPending,children:"Cancel"}),l.jsxRuntimeExports.jsxs("button",{disabled:t.isPending,onClick:()=>t.mutate(),className:"rounded-md text-white w-28 text-center justify-center bg-red-600 hover:bg-red-700 flex items-center gap-x-2",children:[t.isPending&&l.jsxRuntimeExports.jsx(S2.Loader2,{className:"animate-spin w-5 h-5"}),"Sign Out"]})]})]})]})},u4=()=>l.jsxRuntimeExports.jsx(H4,{children:l.jsxRuntimeExports.jsx("button",{className:"border-gray-200 rounded-md p-2 mb-2 border",children:l.jsxRuntimeExports.jsx(S2.LogOutIcon,{className:"w-4 h-4 text-red-500 cursor-pointer hover:text-red-300 duration-300"})})}),s4=T.lazy(()=>Promise.resolve().then(()=>require("./PagesPanel-WzCocl6u.cjs"))),p4=T.lazy(()=>Promise.resolve().then(()=>require("./ProjectPanel-o7gdcwPn.cjs"))),V4=T.lazy(()=>Promise.resolve().then(()=>require("./CurrentPage-Hl52iub_.cjs"))),f4=()=>l.jsxRuntimeExports.jsx("h2",{children:"Your Logo"}),m4=()=>{const{mutate:a}=c4();return q.useBuilderProp("editable",!0)?l.jsxRuntimeExports.jsx(q.Button,{onClick:a,className:"bg-blue-600 text-white",children:"Publish"}):null},L4=a=>{var f;const{data:t,isLoading:h}=b2(),{data:n,isLoading:v}=P2(),{data:r}=z0(),{mutate:i}=g0(),{mutate:z}=H0(),[s]=H1(),p=i4(),d=e4(),x=l4(),b=R(),H=T.useCallback(async m=>await p.mutateAsync(m),[p]),V=T.useCallback(async()=>await d.mutateAsync(),[d]),B=T.useCallback(async m=>await x.mutateAsync(m),[x]),g=async(m=20,y=0)=>{const F=`limit=${m}&offset=${y}`,I=await fetch(`${b}/assets?${F}`).then(w=>w.json());return I.result==="success"?I.data:[]},{logo:u=f4}=a;if(h||!t)return l.jsxRuntimeExports.jsx(O2,{});if(v||!n)return l.jsxRuntimeExports.jsx(O2,{});const G={...a,editable:r!=null&&r.lockedBy?r==null?void 0:r.lockedBy.self:!0,nonEditableComponent:d4,blocks:(r==null?void 0:r.blocks)||[],brandingOptions:t.brandingOptions,darkMode:a.darkMode||!1,dataProviders:(r==null?void 0:r.providers)||[],onSavePage:async({blocks:m,providers:y})=>(await z({blocks:m,providers:y,uuid:s}),!0),onSaveBrandingOptions:async m=>(await i({brandingOptions:m}),!0),topBarComponents:{left:[u],center:[V4],right:[m4]},sideBarComponents:{top:[{icon:i2.FileTextIcon,name:"pages",panel:s4},{icon:i2.GearIcon,name:"settings",panel:p4},...((f=a.sideBarComponents)==null?void 0:f.top)||[]],bottom:[u4]},uploadMediaCallback:H,fetchMediaCallback:g,getUILibraryBlocks:V,getExternalPredefinedBlock:B,getPages:()=>n};return l.jsxRuntimeExports.jsx(s0.ChaiBuilderEditor,{...G})},x4=({logo:a})=>{const[t,h]=T.useState(!1),[n,v]=T.useState(""),[r,i]=T.useState(""),{mutate:z,isPending:s}=z4(),p=d=>{d.preventDefault(),z({email:n,password:r})};return l.jsxRuntimeExports.jsx("section",{className:"h-screen w-screen flex items-center justify-center bg-[radial-gradient(#AAA,transparent_0.5px)] duration-300 [background-size:6px_6px]",children:l.jsxRuntimeExports.jsx("div",{className:"overflow-hidden bg-white rounded-xl w-96 drop-shadow-2xl duration-300",children:l.jsxRuntimeExports.jsxs("div",{className:"p-12",children:[l.jsxRuntimeExports.jsxs("div",{className:"max-w-2xl mx-auto text-center",children:[l.jsxRuntimeExports.jsx(T.Suspense,{children:a?T.createElement(a):""}),l.jsxRuntimeExports.jsx("p",{className:"max-w-xl mx-auto text-base leading-relaxed text-gray-700 font-thin",children:"Enter your login credential to continue"})]}),l.jsxRuntimeExports.jsx("div",{className:"mt-8",children:l.jsxRuntimeExports.jsxs("form",{method:"POST",onSubmit:p,className:"space-y-5",children:[l.jsxRuntimeExports.jsx("div",{children:l.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[l.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:l.jsxRuntimeExports.jsx(u0,{})}),l.jsxRuntimeExports.jsx("input",{value:n,onChange:d=>v(d.target.value),type:"email",id:"email",placeholder:"Enter email",className:"block w-full py-4 px-10 text-black placeholder-gray-500 transition-all duration-200 bg-white border border-gray-200 rounded-md focus:outline-none focus:border-blue-600 caret-blue-600"})]})}),l.jsxRuntimeExports.jsx("div",{children:l.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[l.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:l.jsxRuntimeExports.jsx("svg",{className:"w-5 h-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 11c0 3.517-1.009 6.799-2.753 9.571m-3.44-2.04l.054-.09A13.916 13.916 0 008 11a4 4 0 118 0c0 1.017-.07 2.019-.203 3m-2.118 6.844A21.88 21.88 0 0015.171 17m3.839 1.132c.645-2.266.99-4.659.99-7.132A8 8 0 008 4.07M3 15.364c.64-1.319 1-2.8 1-4.364 0-1.457.39-2.823 1.07-4"})})}),l.jsxRuntimeExports.jsx("input",{value:r,onChange:d=>i(d.target.value),type:t?"text":"password",id:"pwd",placeholder:"Enter password",className:"block w-full py-4 px-10 text-black placeholder-gray-500 transition-all duration-200 bg-white border border-gray-200 rounded-md focus:outline-none focus:border-blue-600 caret-blue-600"}),l.jsxRuntimeExports.jsx("button",{type:"button",className:"absolute inset-y-0 right-4 flex items-center pl-3 cursor-pointer",onClick:()=>h(!t),children:t?l.jsxRuntimeExports.jsx(i2.EyeClosedIcon,{}):l.jsxRuntimeExports.jsx(i2.EyeOpenIcon,{})})]})}),l.jsxRuntimeExports.jsx("div",{children:l.jsxRuntimeExports.jsx("button",{disabled:s||h1.size(n)<2||h1.size(r)<2,type:"submit",className:"inline-flex disabled:bg-gray-400 items-center justify-center w-full px-4 py-4 text-base font-semibold text-white transition-all duration-200 bg-blue-600 border border-transparent rounded-md focus:outline-none hover:bg-blue-700 focus:bg-blue-700",children:s?"Signing in...":"Login"})})]})}),l.jsxRuntimeExports.jsx("div",{className:"mt-4 flex items-center justify-end gap-x-2 text-sm",children:l.jsxRuntimeExports.jsx("a",{href:"https://apps.chaibuilder.com/settings",target:"_blank",className:"text-gray-500 hover:text-blue-400",children:"Forget your password?"})})]})})})},w4=a=>{const{data:t,isLoading:h}=g4(),n=N();return T.useEffect(()=>{n.setQueryData(["apiBaseUrl"],a.apiBaseUrl||"/api/chaibuilder")},[a.apiBaseUrl,n]),h?l.jsxRuntimeExports.jsx(O2,{}):t!=null&&t.valid?l.jsxRuntimeExports.jsx(L4,{...a}):l.jsxRuntimeExports.jsx(x4,{logo:a.logo})},B4=new R0,I4=a=>l.jsxRuntimeExports.jsxs(T0,{client:B4,children:[l.jsxRuntimeExports.jsx(a1.Toaster,{richColors:!0}),l.jsxRuntimeExports.jsx(w4,{...a})]});exports.ChaiBuilderStudio=I4;exports.useAddPage=n4;exports.useChangePage=M0;exports.useCurrentPage=H1;exports.useDeletePage=v4;exports.usePages=P2;exports.useProject=b2;exports.useQueryClient=N;exports.useUpdatePage=H0;exports.useUpdateProject=g0;
1
+ "use strict";var H2=(a,t,h)=>{if(!t.has(a))throw TypeError("Cannot "+h)};var c=(a,t,h)=>(H2(a,t,"read from private field"),h?h.call(a):t.get(a)),o=(a,t,h)=>{if(t.has(a))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(a):t.set(a,h)},e=(a,t,h,n)=>(H2(a,t,"write to private field"),n?n.call(a,h):t.set(a,h),h);var r2=(a,t,h,n)=>({set _(v){e(a,t,v,h)},get _(){return c(a,t,n)}}),M=(a,t,h)=>(H2(a,t,"access private method"),h);const l=require("./jsx-runtime-Z_BpKhVy.cjs"),T=require("react"),s0=require("./index-l19JVVXI.cjs"),i2=require("@radix-ui/react-icons"),q=require("./index-F4AQQ6qq.cjs"),a1=require("sonner"),p0=require("react-i18next"),h1=require("lodash-es"),V0=require("./html-to-json-C_Eobs_d.cjs"),S2=require("lucide-react"),t0=require("./index-ecnGWzh9.cjs");function f0(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const h in a)if(h!=="default"){const n=Object.getOwnPropertyDescriptor(a,h);Object.defineProperty(t,h,n.get?n:{enumerable:!0,get:()=>a[h]})}}return t.default=a,Object.freeze(t)}const A=f0(T);var W1=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(a){return this.listeners.add(a),this.onSubscribe(),()=>{this.listeners.delete(a),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},N1=typeof window>"u"||"Deno"in window;function _(){}function m0(a,t){return typeof a=="function"?a(t):a}function s2(a){return typeof a=="number"&&a>=0&&a!==1/0}function a0(a,t){return Math.max(a+(t||0)-Date.now(),0)}function R2(a,t){const{type:h="all",exact:n,fetchStatus:v,predicate:r,queryKey:i,stale:z}=a;if(i){if(n){if(t.queryHash!==A2(i,t.options))return!1}else if(!Q1(t.queryKey,i))return!1}if(h!=="all"){const s=t.isActive();if(h==="active"&&!s||h==="inactive"&&s)return!1}return!(typeof z=="boolean"&&t.isStale()!==z||typeof v<"u"&&v!==t.state.fetchStatus||r&&!r(t))}function F2(a,t){const{exact:h,status:n,predicate:v,mutationKey:r}=a;if(r){if(!t.options.mutationKey)return!1;if(h){if(U1(t.options.mutationKey)!==U1(r))return!1}else if(!Q1(t.options.mutationKey,r))return!1}return!(n&&t.state.status!==n||v&&!v(t))}function A2(a,t){return((t==null?void 0:t.queryKeyHashFn)||U1)(a)}function U1(a){return JSON.stringify(a,(t,h)=>p2(h)?Object.keys(h).sort().reduce((n,v)=>(n[v]=h[v],n),{}):h)}function Q1(a,t){return a===t?!0:typeof a!=typeof t?!1:a&&t&&typeof a=="object"&&typeof t=="object"?!Object.keys(t).some(h=>!Q1(a[h],t[h])):!1}function h0(a,t){if(a===t)return a;const h=D2(a)&&D2(t);if(h||p2(a)&&p2(t)){const n=h?a.length:Object.keys(a).length,v=h?t:Object.keys(t),r=v.length,i=h?[]:{};let z=0;for(let s=0;s<r;s++){const p=h?s:v[s];i[p]=h0(a[p],t[p]),i[p]===a[p]&&z++}return n===r&&z===n?a:i}return t}function o2(a,t){if(a&&!t||t&&!a)return!1;for(const h in a)if(a[h]!==t[h])return!1;return!0}function D2(a){return Array.isArray(a)&&a.length===Object.keys(a).length}function p2(a){if(!k2(a))return!1;const t=a.constructor;if(typeof t>"u")return!0;const h=t.prototype;return!(!k2(h)||!h.hasOwnProperty("isPrototypeOf"))}function k2(a){return Object.prototype.toString.call(a)==="[object Object]"}function n0(a){return new Promise(t=>{setTimeout(t,a)})}function E2(a){n0(0).then(a)}function V2(a,t,h){return typeof h.structuralSharing=="function"?h.structuralSharing(a,t):h.structuralSharing!==!1?h0(a,t):t}function L0(a,t,h=0){const n=[...a,t];return h&&n.length>h?n.slice(1):n}function x0(a,t,h=0){const n=[t,...a];return h&&n.length>h?n.slice(0,-1):n}var u1,e1,B1,U2,w0=(U2=class extends W1{constructor(){super();o(this,u1,void 0);o(this,e1,void 0);o(this,B1,void 0);e(this,B1,t=>{if(!N1&&window.addEventListener){const h=()=>t();return window.addEventListener("visibilitychange",h,!1),()=>{window.removeEventListener("visibilitychange",h)}}})}onSubscribe(){c(this,e1)||this.setEventListener(c(this,B1))}onUnsubscribe(){var t;this.hasListeners()||((t=c(this,e1))==null||t.call(this),e(this,e1,void 0))}setEventListener(t){var h;e(this,B1,t),(h=c(this,e1))==null||h.call(this),e(this,e1,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){c(this,u1)!==t&&(e(this,u1,t),this.onFocus())}onFocus(){this.listeners.forEach(t=>{t()})}isFocused(){var t;return typeof c(this,u1)=="boolean"?c(this,u1):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},u1=new WeakMap,e1=new WeakMap,B1=new WeakMap,U2),d2=new w0,I1,l1,G1,Q2,B0=(Q2=class extends W1{constructor(){super();o(this,I1,!0);o(this,l1,void 0);o(this,G1,void 0);e(this,G1,t=>{if(!N1&&window.addEventListener){const h=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",h,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",h),window.removeEventListener("offline",n)}}})}onSubscribe(){c(this,l1)||this.setEventListener(c(this,G1))}onUnsubscribe(){var t;this.hasListeners()||((t=c(this,l1))==null||t.call(this),e(this,l1,void 0))}setEventListener(t){var h;e(this,G1,t),(h=c(this,l1))==null||h.call(this),e(this,l1,t(this.setOnline.bind(this)))}setOnline(t){c(this,I1)!==t&&(e(this,I1,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return c(this,I1)}},I1=new WeakMap,l1=new WeakMap,G1=new WeakMap,Q2),z2=new B0;function I0(a){return Math.min(1e3*2**a,3e4)}function M2(a){return(a??"online")==="online"?z2.isOnline():!0}var c0=class{constructor(a){this.revert=a==null?void 0:a.revert,this.silent=a==null?void 0:a.silent}};function u2(a){return a instanceof c0}function v0(a){let t=!1,h=0,n=!1,v,r,i;const z=new Promise((g,u)=>{r=g,i=u}),s=g=>{var u;n||(H(new c0(g)),(u=a.abort)==null||u.call(a))},p=()=>{t=!0},d=()=>{t=!1},x=()=>!d2.isFocused()||a.networkMode!=="always"&&!z2.isOnline(),b=g=>{var u;n||(n=!0,(u=a.onSuccess)==null||u.call(a,g),v==null||v(),r(g))},H=g=>{var u;n||(n=!0,(u=a.onError)==null||u.call(a,g),v==null||v(),i(g))},V=()=>new Promise(g=>{var u;v=G=>{const f=n||!x();return f&&g(G),f},(u=a.onPause)==null||u.call(a)}).then(()=>{var g;v=void 0,n||(g=a.onContinue)==null||g.call(a)}),B=()=>{if(n)return;let g;try{g=a.fn()}catch(u){g=Promise.reject(u)}Promise.resolve(g).then(b).catch(u=>{var F;if(n)return;const G=a.retry??(N1?0:3),f=a.retryDelay??I0,m=typeof f=="function"?f(h,u):f,y=G===!0||typeof G=="number"&&h<G||typeof G=="function"&&G(h,u);if(t||!y){H(u);return}h++,(F=a.onFail)==null||F.call(a,h,u),n0(m).then(()=>{if(x())return V()}).then(()=>{t?H(u):B()})})};return M2(a.networkMode)?B():V().then(B),{promise:z,cancel:s,continue:()=>(v==null?void 0:v())?z:Promise.resolve(),cancelRetry:p,continueRetry:d}}function G0(){let a=[],t=0,h=d=>{d()},n=d=>{d()};const v=d=>{let x;t++;try{x=d()}finally{t--,t||z()}return x},r=d=>{t?a.push(d):E2(()=>{h(d)})},i=d=>(...x)=>{r(()=>{d(...x)})},z=()=>{const d=a;a=[],d.length&&E2(()=>{n(()=>{d.forEach(x=>{h(x)})})})};return{batch:v,batchCalls:i,schedule:r,setNotifyFunction:d=>{h=d},setBatchNotifyFunction:d=>{n=d}}}var O=G0(),s1,K2,r0=(K2=class{constructor(){o(this,s1,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),s2(this.gcTime)&&e(this,s1,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(a){this.gcTime=Math.max(this.gcTime||0,a??(N1?1/0:5*60*1e3))}clearGcTimeout(){c(this,s1)&&(clearTimeout(c(this,s1)),e(this,s1,void 0))}},s1=new WeakMap,K2),C1,O1,j,i1,U,S,K1,p1,S1,e2,$,c1,q2,C0=(q2=class extends r0{constructor(t){super();o(this,S1);o(this,$);o(this,C1,void 0);o(this,O1,void 0);o(this,j,void 0);o(this,i1,void 0);o(this,U,void 0);o(this,S,void 0);o(this,K1,void 0);o(this,p1,void 0);e(this,p1,!1),e(this,K1,t.defaultOptions),M(this,S1,e2).call(this,t.options),e(this,S,[]),e(this,j,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,e(this,C1,t.state||O0(this.options)),this.state=c(this,C1),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!c(this,S).length&&this.state.fetchStatus==="idle"&&c(this,j).remove(this)}setData(t,h){const n=V2(this.state.data,t,this.options);return M(this,$,c1).call(this,{data:n,type:"success",dataUpdatedAt:h==null?void 0:h.updatedAt,manual:h==null?void 0:h.manual}),n}setState(t,h){M(this,$,c1).call(this,{type:"setState",state:t,setStateOptions:h})}cancel(t){var n;const h=c(this,i1);return(n=c(this,U))==null||n.cancel(t),h?h.then(_).catch(_):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(c(this,C1))}isActive(){return c(this,S).some(t=>t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||c(this,S).some(t=>t.getCurrentResult().isStale)}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!a0(this.state.dataUpdatedAt,t)}onFocus(){var h;const t=c(this,S).find(n=>n.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(h=c(this,U))==null||h.continue()}onOnline(){var h;const t=c(this,S).find(n=>n.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(h=c(this,U))==null||h.continue()}addObserver(t){c(this,S).includes(t)||(c(this,S).push(t),this.clearGcTimeout(),c(this,j).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){c(this,S).includes(t)&&(e(this,S,c(this,S).filter(h=>h!==t)),c(this,S).length||(c(this,U)&&(c(this,p1)?c(this,U).cancel({revert:!0}):c(this,U).cancelRetry()),this.scheduleGc()),c(this,j).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return c(this,S).length}invalidate(){this.state.isInvalidated||M(this,$,c1).call(this,{type:"invalidate"})}fetch(t,h){var p,d,x,b;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(h!=null&&h.cancelRefetch))this.cancel({silent:!0});else if(c(this,i1))return(p=c(this,U))==null||p.continueRetry(),c(this,i1)}if(t&&M(this,S1,e2).call(this,t),!this.options.queryFn){const H=c(this,S).find(V=>V.options.queryFn);H&&M(this,S1,e2).call(this,H.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const n=new AbortController,v={queryKey:this.queryKey,meta:this.meta},r=H=>{Object.defineProperty(H,"signal",{enumerable:!0,get:()=>(e(this,p1,!0),n.signal)})};r(v);const i=()=>this.options.queryFn?(e(this,p1,!1),this.options.persister?this.options.persister(this.options.queryFn,v,this):this.options.queryFn(v)):Promise.reject(new Error(`Missing queryFn: '${this.options.queryHash}'`)),z={fetchOptions:h,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:i};r(z),(d=this.options.behavior)==null||d.onFetch(z,this),e(this,O1,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((x=z.fetchOptions)==null?void 0:x.meta))&&M(this,$,c1).call(this,{type:"fetch",meta:(b=z.fetchOptions)==null?void 0:b.meta});const s=H=>{var V,B,g,u;u2(H)&&H.silent||M(this,$,c1).call(this,{type:"error",error:H}),u2(H)||((B=(V=c(this,j).config).onError)==null||B.call(V,H,this),(u=(g=c(this,j).config).onSettled)==null||u.call(g,this.state.data,H,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return e(this,U,v0({fn:z.fetchFn,abort:n.abort.bind(n),onSuccess:H=>{var V,B,g,u;if(typeof H>"u"){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),s(new Error(`${this.queryHash} data is undefined`));return}this.setData(H),(B=(V=c(this,j).config).onSuccess)==null||B.call(V,H,this),(u=(g=c(this,j).config).onSettled)==null||u.call(g,H,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:s,onFail:(H,V)=>{M(this,$,c1).call(this,{type:"failed",failureCount:H,error:V})},onPause:()=>{M(this,$,c1).call(this,{type:"pause"})},onContinue:()=>{M(this,$,c1).call(this,{type:"continue"})},retry:z.options.retry,retryDelay:z.options.retryDelay,networkMode:z.options.networkMode})),e(this,i1,c(this,U).promise),c(this,i1)}},C1=new WeakMap,O1=new WeakMap,j=new WeakMap,i1=new WeakMap,U=new WeakMap,S=new WeakMap,K1=new WeakMap,p1=new WeakMap,S1=new WeakSet,e2=function(t){this.options={...c(this,K1),...t},this.updateGcTime(this.options.gcTime)},$=new WeakSet,c1=function(t){const h=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:t.meta??null,fetchStatus:M2(this.options.networkMode)?"fetching":"paused",...!n.dataUpdatedAt&&{error:null,status:"pending"}};case"success":return{...n,data:t.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const v=t.error;return u2(v)&&v.revert&&c(this,O1)?{...c(this,O1),fetchStatus:"idle"}:{...n,error:v,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:v,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=h(this.state),O.batch(()=>{c(this,S).forEach(n=>{n.onQueryUpdate()}),c(this,j).notify({query:this,type:"updated",action:t})})},q2);function O0(a){const t=typeof a.initialData=="function"?a.initialData():a.initialData,h=typeof t<"u",n=h?typeof a.initialDataUpdatedAt=="function"?a.initialDataUpdatedAt():a.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:h?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:h?"success":"pending",fetchStatus:"idle"}}var Z,_2,S0=(_2=class extends W1{constructor(t={}){super();o(this,Z,void 0);this.config=t,e(this,Z,new Map)}build(t,h,n){const v=h.queryKey,r=h.queryHash??A2(v,h);let i=this.get(r);return i||(i=new C0({cache:this,queryKey:v,queryHash:r,options:t.defaultQueryOptions(h),state:n,defaultOptions:t.getQueryDefaults(v)}),this.add(i)),i}add(t){c(this,Z).has(t.queryHash)||(c(this,Z).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const h=c(this,Z).get(t.queryHash);h&&(t.destroy(),h===t&&c(this,Z).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){O.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return c(this,Z).get(t)}getAll(){return[...c(this,Z).values()]}find(t){const h={exact:!0,...t};return this.getAll().find(n=>R2(h,n))}findAll(t={}){const h=this.getAll();return Object.keys(t).length>0?h.filter(n=>R2(t,n)):h}notify(t){O.batch(()=>{this.listeners.forEach(h=>{h(t)})})}onFocus(){O.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){O.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Z=new WeakMap,_2),Y,q1,E,A1,X,r1,$2,A0=($2=class extends r0{constructor(t){super();o(this,X);o(this,Y,void 0);o(this,q1,void 0);o(this,E,void 0);o(this,A1,void 0);this.mutationId=t.mutationId,e(this,q1,t.defaultOptions),e(this,E,t.mutationCache),e(this,Y,[]),this.state=t.state||e0(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...c(this,q1),...t},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){c(this,Y).includes(t)||(c(this,Y).push(t),this.clearGcTimeout(),c(this,E).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){e(this,Y,c(this,Y).filter(h=>h!==t)),this.scheduleGc(),c(this,E).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){c(this,Y).length||(this.state.status==="pending"?this.scheduleGc():c(this,E).remove(this))}continue(){var t;return((t=c(this,A1))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var v,r,i,z,s,p,d,x,b,H,V,B,g,u,G,f,m,y,F,I;const h=()=>(e(this,A1,v0({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(w,n1)=>{M(this,X,r1).call(this,{type:"failed",failureCount:w,error:n1})},onPause:()=>{M(this,X,r1).call(this,{type:"pause"})},onContinue:()=>{M(this,X,r1).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),c(this,A1).promise),n=this.state.status==="pending";try{if(!n){M(this,X,r1).call(this,{type:"pending",variables:t}),await((r=(v=c(this,E).config).onMutate)==null?void 0:r.call(v,t,this));const n1=await((z=(i=this.options).onMutate)==null?void 0:z.call(i,t));n1!==this.state.context&&M(this,X,r1).call(this,{type:"pending",context:n1,variables:t})}const w=await h();return await((p=(s=c(this,E).config).onSuccess)==null?void 0:p.call(s,w,t,this.state.context,this)),await((x=(d=this.options).onSuccess)==null?void 0:x.call(d,w,t,this.state.context)),await((H=(b=c(this,E).config).onSettled)==null?void 0:H.call(b,w,null,this.state.variables,this.state.context,this)),await((B=(V=this.options).onSettled)==null?void 0:B.call(V,w,null,t,this.state.context)),M(this,X,r1).call(this,{type:"success",data:w}),w}catch(w){try{throw await((u=(g=c(this,E).config).onError)==null?void 0:u.call(g,w,t,this.state.context,this)),await((f=(G=this.options).onError)==null?void 0:f.call(G,w,t,this.state.context)),await((y=(m=c(this,E).config).onSettled)==null?void 0:y.call(m,void 0,w,this.state.variables,this.state.context,this)),await((I=(F=this.options).onSettled)==null?void 0:I.call(F,void 0,w,t,this.state.context)),w}finally{M(this,X,r1).call(this,{type:"error",error:w})}}}},Y=new WeakMap,q1=new WeakMap,E=new WeakMap,A1=new WeakMap,X=new WeakSet,r1=function(t){const h=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!M2(this.options.networkMode),status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=h(this.state),O.batch(()=>{c(this,Y).forEach(n=>{n.onMutationUpdate(t)}),c(this,E).notify({mutation:this,type:"updated",action:t})})},$2);function e0(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Q,_1,V1,J2,y0=(J2=class extends W1{constructor(t={}){super();o(this,Q,void 0);o(this,_1,void 0);o(this,V1,void 0);this.config=t,e(this,Q,[]),e(this,_1,0)}build(t,h,n){const v=new A0({mutationCache:this,mutationId:++r2(this,_1)._,options:t.defaultMutationOptions(h),state:n});return this.add(v),v}add(t){c(this,Q).push(t),this.notify({type:"added",mutation:t})}remove(t){e(this,Q,c(this,Q).filter(h=>h!==t)),this.notify({type:"removed",mutation:t})}clear(){O.batch(()=>{c(this,Q).forEach(t=>{this.remove(t)})})}getAll(){return c(this,Q)}find(t){const h={exact:!0,...t};return c(this,Q).find(n=>F2(h,n))}findAll(t={}){return c(this,Q).filter(h=>F2(t,h))}notify(t){O.batch(()=>{this.listeners.forEach(h=>{h(t)})})}resumePausedMutations(){return e(this,V1,(c(this,V1)??Promise.resolve()).then(()=>{const t=c(this,Q).filter(h=>h.state.isPaused);return O.batch(()=>t.reduce((h,n)=>h.then(()=>n.continue().catch(_)),Promise.resolve()))}).then(()=>{e(this,V1,void 0)})),c(this,V1)}},Q=new WeakMap,_1=new WeakMap,V1=new WeakMap,J2);function b0(a){return{onFetch:(t,h)=>{const n=async()=>{var V,B,g,u,G;const v=t.options,r=(g=(B=(V=t.fetchOptions)==null?void 0:V.meta)==null?void 0:B.fetchMore)==null?void 0:g.direction,i=((u=t.state.data)==null?void 0:u.pages)||[],z=((G=t.state.data)==null?void 0:G.pageParams)||[],s={pages:[],pageParams:[]};let p=!1;const d=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(t.signal.aborted?p=!0:t.signal.addEventListener("abort",()=>{p=!0}),t.signal)})},x=t.options.queryFn||(()=>Promise.reject(new Error(`Missing queryFn: '${t.options.queryHash}'`))),b=async(f,m,y)=>{if(p)return Promise.reject();if(m==null&&f.pages.length)return Promise.resolve(f);const F={queryKey:t.queryKey,pageParam:m,direction:y?"backward":"forward",meta:t.options.meta};d(F);const I=await x(F),{maxPages:w}=t.options,n1=y?x0:L0;return{pages:n1(f.pages,I,w),pageParams:n1(f.pageParams,m,w)}};let H;if(r&&i.length){const f=r==="backward",m=f?P0:T2,y={pages:i,pageParams:z},F=m(v,y);H=await b(y,F,f)}else{H=await b(s,z[0]??v.initialPageParam);const f=a??i.length;for(let m=1;m<f;m++){const y=T2(v,H);H=await b(H,y)}}return H};t.options.persister?t.fetchFn=()=>{var v,r;return(r=(v=t.options).persister)==null?void 0:r.call(v,n,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},h)}:t.fetchFn=n}}}function T2(a,{pages:t,pageParams:h}){const n=t.length-1;return a.getNextPageParam(t[n],t,h[n],h)}function P0(a,{pages:t,pageParams:h}){var n;return(n=a.getPreviousPageParam)==null?void 0:n.call(a,t[0],t,h[0],h)}var C,o1,d1,y1,b1,z1,P1,R1,Z2,R0=(Z2=class{constructor(a={}){o(this,C,void 0);o(this,o1,void 0);o(this,d1,void 0);o(this,y1,void 0);o(this,b1,void 0);o(this,z1,void 0);o(this,P1,void 0);o(this,R1,void 0);e(this,C,a.queryCache||new S0),e(this,o1,a.mutationCache||new y0),e(this,d1,a.defaultOptions||{}),e(this,y1,new Map),e(this,b1,new Map),e(this,z1,0)}mount(){r2(this,z1)._++,c(this,z1)===1&&(e(this,P1,d2.subscribe(()=>{d2.isFocused()&&(this.resumePausedMutations(),c(this,C).onFocus())})),e(this,R1,z2.subscribe(()=>{z2.isOnline()&&(this.resumePausedMutations(),c(this,C).onOnline())})))}unmount(){var a,t;r2(this,z1)._--,c(this,z1)===0&&((a=c(this,P1))==null||a.call(this),e(this,P1,void 0),(t=c(this,R1))==null||t.call(this),e(this,R1,void 0))}isFetching(a){return c(this,C).findAll({...a,fetchStatus:"fetching"}).length}isMutating(a){return c(this,o1).findAll({...a,status:"pending"}).length}getQueryData(a){var t;return(t=c(this,C).find({queryKey:a}))==null?void 0:t.state.data}ensureQueryData(a){const t=this.getQueryData(a.queryKey);return t!==void 0?Promise.resolve(t):this.fetchQuery(a)}getQueriesData(a){return this.getQueryCache().findAll(a).map(({queryKey:t,state:h})=>{const n=h.data;return[t,n]})}setQueryData(a,t,h){const n=c(this,C).find({queryKey:a}),v=n==null?void 0:n.state.data,r=m0(t,v);if(typeof r>"u")return;const i=this.defaultQueryOptions({queryKey:a});return c(this,C).build(this,i).setData(r,{...h,manual:!0})}setQueriesData(a,t,h){return O.batch(()=>this.getQueryCache().findAll(a).map(({queryKey:n})=>[n,this.setQueryData(n,t,h)]))}getQueryState(a){var t;return(t=c(this,C).find({queryKey:a}))==null?void 0:t.state}removeQueries(a){const t=c(this,C);O.batch(()=>{t.findAll(a).forEach(h=>{t.remove(h)})})}resetQueries(a,t){const h=c(this,C),n={type:"active",...a};return O.batch(()=>(h.findAll(a).forEach(v=>{v.reset()}),this.refetchQueries(n,t)))}cancelQueries(a={},t={}){const h={revert:!0,...t},n=O.batch(()=>c(this,C).findAll(a).map(v=>v.cancel(h)));return Promise.all(n).then(_).catch(_)}invalidateQueries(a={},t={}){return O.batch(()=>{if(c(this,C).findAll(a).forEach(n=>{n.invalidate()}),a.refetchType==="none")return Promise.resolve();const h={...a,type:a.refetchType??a.type??"active"};return this.refetchQueries(h,t)})}refetchQueries(a={},t){const h={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},n=O.batch(()=>c(this,C).findAll(a).filter(v=>!v.isDisabled()).map(v=>{let r=v.fetch(void 0,h);return h.throwOnError||(r=r.catch(_)),v.state.fetchStatus==="paused"?Promise.resolve():r}));return Promise.all(n).then(_)}fetchQuery(a){const t=this.defaultQueryOptions(a);typeof t.retry>"u"&&(t.retry=!1);const h=c(this,C).build(this,t);return h.isStaleByTime(t.staleTime)?h.fetch(t):Promise.resolve(h.state.data)}prefetchQuery(a){return this.fetchQuery(a).then(_).catch(_)}fetchInfiniteQuery(a){return a.behavior=b0(a.pages),this.fetchQuery(a)}prefetchInfiniteQuery(a){return this.fetchInfiniteQuery(a).then(_).catch(_)}resumePausedMutations(){return c(this,o1).resumePausedMutations()}getQueryCache(){return c(this,C)}getMutationCache(){return c(this,o1)}getDefaultOptions(){return c(this,d1)}setDefaultOptions(a){e(this,d1,a)}setQueryDefaults(a,t){c(this,y1).set(U1(a),{queryKey:a,defaultOptions:t})}getQueryDefaults(a){const t=[...c(this,y1).values()];let h={};return t.forEach(n=>{Q1(a,n.queryKey)&&(h={...h,...n.defaultOptions})}),h}setMutationDefaults(a,t){c(this,b1).set(U1(a),{mutationKey:a,defaultOptions:t})}getMutationDefaults(a){const t=[...c(this,b1).values()];let h={};return t.forEach(n=>{Q1(a,n.mutationKey)&&(h={...h,...n.defaultOptions})}),h}defaultQueryOptions(a){if(a!=null&&a._defaulted)return a;const t={...c(this,d1).queries,...(a==null?void 0:a.queryKey)&&this.getQueryDefaults(a.queryKey),...a,_defaulted:!0};return t.queryHash||(t.queryHash=A2(t.queryKey,t)),typeof t.refetchOnReconnect>"u"&&(t.refetchOnReconnect=t.networkMode!=="always"),typeof t.throwOnError>"u"&&(t.throwOnError=!!t.suspense),typeof t.networkMode>"u"&&t.persister&&(t.networkMode="offlineFirst"),t}defaultMutationOptions(a){return a!=null&&a._defaulted?a:{...c(this,d1).mutations,...(a==null?void 0:a.mutationKey)&&this.getMutationDefaults(a.mutationKey),...a,_defaulted:!0}}clear(){c(this,C).clear(),c(this,o1).clear()}},C=new WeakMap,o1=new WeakMap,d1=new WeakMap,y1=new WeakMap,b1=new WeakMap,z1=new WeakMap,P1=new WeakMap,R1=new WeakMap,Z2),k,L,F1,P,f1,D1,t1,$1,k1,E1,m1,L1,g1,x1,w1,j1,J1,f2,Z1,m2,Y1,L2,X1,x2,t2,w2,a2,B2,h2,I2,g2,l0,Y2,F0=(Y2=class extends W1{constructor(t,h){super();o(this,w1);o(this,J1);o(this,Z1);o(this,Y1);o(this,X1);o(this,t2);o(this,a2);o(this,h2);o(this,g2);o(this,k,void 0);o(this,L,void 0);o(this,F1,void 0);o(this,P,void 0);o(this,f1,void 0);o(this,D1,void 0);o(this,t1,void 0);o(this,$1,void 0);o(this,k1,void 0);o(this,E1,void 0);o(this,m1,void 0);o(this,L1,void 0);o(this,g1,void 0);o(this,x1,void 0);e(this,L,void 0),e(this,F1,void 0),e(this,P,void 0),e(this,x1,new Set),e(this,k,t),this.options=h,e(this,t1,null),this.bindMethods(),this.setOptions(h)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(c(this,L).addObserver(this),N2(c(this,L),this.options)?M(this,w1,j1).call(this):this.updateResult(),M(this,X1,x2).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return G2(c(this,L),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return G2(c(this,L),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,M(this,t2,w2).call(this),M(this,a2,B2).call(this),c(this,L).removeObserver(this)}setOptions(t,h){const n=this.options,v=c(this,L);if(this.options=c(this,k).defaultQueryOptions(t),o2(n,this.options)||c(this,k).getQueryCache().notify({type:"observerOptionsUpdated",query:c(this,L),observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=n.queryKey),M(this,h2,I2).call(this);const r=this.hasListeners();r&&W2(c(this,L),v,this.options,n)&&M(this,w1,j1).call(this),this.updateResult(h),r&&(c(this,L)!==v||this.options.enabled!==n.enabled||this.options.staleTime!==n.staleTime)&&M(this,J1,f2).call(this);const i=M(this,Z1,m2).call(this);r&&(c(this,L)!==v||this.options.enabled!==n.enabled||i!==c(this,g1))&&M(this,Y1,L2).call(this,i)}getOptimisticResult(t){const h=c(this,k).getQueryCache().build(c(this,k),t),n=this.createResult(h,t);return k0(this,n)&&(e(this,P,n),e(this,D1,this.options),e(this,f1,c(this,L).state)),n}getCurrentResult(){return c(this,P)}trackResult(t){const h={};return Object.keys(t).forEach(n=>{Object.defineProperty(h,n,{configurable:!1,enumerable:!0,get:()=>(c(this,x1).add(n),t[n])})}),h}getCurrentQuery(){return c(this,L)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const h=c(this,k).defaultQueryOptions(t),n=c(this,k).getQueryCache().build(c(this,k),h);return n.isFetchingOptimistic=!0,n.fetch().then(()=>this.createResult(n,h))}fetch(t){return M(this,w1,j1).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),c(this,P)))}createResult(t,h){var F;const n=c(this,L),v=this.options,r=c(this,P),i=c(this,f1),z=c(this,D1),p=t!==n?t.state:c(this,F1),{state:d}=t;let{error:x,errorUpdatedAt:b,fetchStatus:H,status:V}=d,B=!1,g;if(h._optimisticResults){const I=this.hasListeners(),w=!I&&N2(t,h),n1=I&&W2(t,n,h,v);(w||n1)&&(H=M2(t.options.networkMode)?"fetching":"paused",d.dataUpdatedAt||(V="pending")),h._optimisticResults==="isRestoring"&&(H="idle")}if(h.select&&typeof d.data<"u")if(r&&d.data===(i==null?void 0:i.data)&&h.select===c(this,$1))g=c(this,k1);else try{e(this,$1,h.select),g=h.select(d.data),g=V2(r==null?void 0:r.data,g,h),e(this,k1,g),e(this,t1,null)}catch(I){e(this,t1,I)}else g=d.data;if(typeof h.placeholderData<"u"&&typeof g>"u"&&V==="pending"){let I;if(r!=null&&r.isPlaceholderData&&h.placeholderData===(z==null?void 0:z.placeholderData))I=r.data;else if(I=typeof h.placeholderData=="function"?h.placeholderData((F=c(this,E1))==null?void 0:F.state.data,c(this,E1)):h.placeholderData,h.select&&typeof I<"u")try{I=h.select(I),e(this,t1,null)}catch(w){e(this,t1,w)}typeof I<"u"&&(V="success",g=V2(r==null?void 0:r.data,I,h),B=!0)}c(this,t1)&&(x=c(this,t1),g=c(this,k1),b=Date.now(),V="error");const u=H==="fetching",G=V==="pending",f=V==="error",m=G&&u;return{status:V,fetchStatus:H,isPending:G,isSuccess:V==="success",isError:f,isInitialLoading:m,isLoading:m,data:g,dataUpdatedAt:d.dataUpdatedAt,error:x,errorUpdatedAt:b,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>p.dataUpdateCount||d.errorUpdateCount>p.errorUpdateCount,isFetching:u,isRefetching:u&&!G,isLoadingError:f&&d.dataUpdatedAt===0,isPaused:H==="paused",isPlaceholderData:B,isRefetchError:f&&d.dataUpdatedAt!==0,isStale:y2(t,h),refetch:this.refetch}}updateResult(t){const h=c(this,P),n=this.createResult(c(this,L),this.options);if(e(this,f1,c(this,L).state),e(this,D1,this.options),c(this,f1).data!==void 0&&e(this,E1,c(this,L)),o2(n,h))return;e(this,P,n);const v={},r=()=>{if(!h)return!0;const{notifyOnChangeProps:i}=this.options,z=typeof i=="function"?i():i;if(z==="all"||!z&&!c(this,x1).size)return!0;const s=new Set(z??c(this,x1));return this.options.throwOnError&&s.add("error"),Object.keys(c(this,P)).some(p=>{const d=p;return c(this,P)[d]!==h[d]&&s.has(d)})};(t==null?void 0:t.listeners)!==!1&&r()&&(v.listeners=!0),M(this,g2,l0).call(this,{...v,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&M(this,X1,x2).call(this)}},k=new WeakMap,L=new WeakMap,F1=new WeakMap,P=new WeakMap,f1=new WeakMap,D1=new WeakMap,t1=new WeakMap,$1=new WeakMap,k1=new WeakMap,E1=new WeakMap,m1=new WeakMap,L1=new WeakMap,g1=new WeakMap,x1=new WeakMap,w1=new WeakSet,j1=function(t){M(this,h2,I2).call(this);let h=c(this,L).fetch(this.options,t);return t!=null&&t.throwOnError||(h=h.catch(_)),h},J1=new WeakSet,f2=function(){if(M(this,t2,w2).call(this),N1||c(this,P).isStale||!s2(this.options.staleTime))return;const h=a0(c(this,P).dataUpdatedAt,this.options.staleTime)+1;e(this,m1,setTimeout(()=>{c(this,P).isStale||this.updateResult()},h))},Z1=new WeakSet,m2=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(c(this,L)):this.options.refetchInterval)??!1},Y1=new WeakSet,L2=function(t){M(this,a2,B2).call(this),e(this,g1,t),!(N1||this.options.enabled===!1||!s2(c(this,g1))||c(this,g1)===0)&&e(this,L1,setInterval(()=>{(this.options.refetchIntervalInBackground||d2.isFocused())&&M(this,w1,j1).call(this)},c(this,g1)))},X1=new WeakSet,x2=function(){M(this,J1,f2).call(this),M(this,Y1,L2).call(this,M(this,Z1,m2).call(this))},t2=new WeakSet,w2=function(){c(this,m1)&&(clearTimeout(c(this,m1)),e(this,m1,void 0))},a2=new WeakSet,B2=function(){c(this,L1)&&(clearInterval(c(this,L1)),e(this,L1,void 0))},h2=new WeakSet,I2=function(){const t=c(this,k).getQueryCache().build(c(this,k),this.options);if(t===c(this,L))return;const h=c(this,L);e(this,L,t),e(this,F1,t.state),this.hasListeners()&&(h==null||h.removeObserver(this),t.addObserver(this))},g2=new WeakSet,l0=function(t){O.batch(()=>{t.listeners&&this.listeners.forEach(h=>{h(c(this,P))}),c(this,k).getQueryCache().notify({query:c(this,L),type:"observerResultsUpdated"})})},Y2);function D0(a,t){return t.enabled!==!1&&!a.state.dataUpdatedAt&&!(a.state.status==="error"&&t.retryOnMount===!1)}function N2(a,t){return D0(a,t)||a.state.dataUpdatedAt>0&&G2(a,t,t.refetchOnMount)}function G2(a,t,h){if(t.enabled!==!1){const n=typeof h=="function"?h(a):h;return n==="always"||n!==!1&&y2(a,t)}return!1}function W2(a,t,h,n){return h.enabled!==!1&&(a!==t||n.enabled===!1)&&(!h.suspense||a.state.status!=="error")&&y2(a,h)}function y2(a,t){return a.isStaleByTime(t.staleTime)}function k0(a,t){return!o2(a.getCurrentResult(),t)}var M1,D,K,v1,T1,l2,n2,C2,X2,E0=(X2=class extends W1{constructor(t,h){super();o(this,T1);o(this,n2);o(this,M1,void 0);o(this,D,void 0);o(this,K,void 0);o(this,v1,void 0);e(this,D,void 0),e(this,M1,t),this.setOptions(h),this.bindMethods(),M(this,T1,l2).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var n;const h=this.options;this.options=c(this,M1).defaultMutationOptions(t),o2(h,this.options)||c(this,M1).getMutationCache().notify({type:"observerOptionsUpdated",mutation:c(this,K),observer:this}),(n=c(this,K))==null||n.setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=c(this,K))==null||t.removeObserver(this)}onMutationUpdate(t){M(this,T1,l2).call(this),M(this,n2,C2).call(this,t)}getCurrentResult(){return c(this,D)}reset(){e(this,K,void 0),M(this,T1,l2).call(this),M(this,n2,C2).call(this)}mutate(t,h){var n;return e(this,v1,h),(n=c(this,K))==null||n.removeObserver(this),e(this,K,c(this,M1).getMutationCache().build(c(this,M1),this.options)),c(this,K).addObserver(this),c(this,K).execute(t)}},M1=new WeakMap,D=new WeakMap,K=new WeakMap,v1=new WeakMap,T1=new WeakSet,l2=function(){var h;const t=((h=c(this,K))==null?void 0:h.state)??e0();e(this,D,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},n2=new WeakSet,C2=function(t){O.batch(()=>{var h,n,v,r,i,z,s,p;c(this,v1)&&this.hasListeners()&&((t==null?void 0:t.type)==="success"?((n=(h=c(this,v1)).onSuccess)==null||n.call(h,t.data,c(this,D).variables,c(this,D).context),(r=(v=c(this,v1)).onSettled)==null||r.call(v,t.data,null,c(this,D).variables,c(this,D).context)):(t==null?void 0:t.type)==="error"&&((z=(i=c(this,v1)).onError)==null||z.call(i,t.error,c(this,D).variables,c(this,D).context),(p=(s=c(this,v1)).onSettled)==null||p.call(s,void 0,t.error,c(this,D).variables,c(this,D).context))),this.listeners.forEach(d=>{d(c(this,D))})})},X2);var i0=A.createContext(void 0),N=a=>{const t=A.useContext(i0);if(a)return a;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},T0=({client:a,children:t})=>(A.useEffect(()=>(a.mount(),()=>{a.unmount()}),[a]),A.createElement(i0.Provider,{value:a},t)),o0=A.createContext(!1),N0=()=>A.useContext(o0),C4=o0.Provider;function W0(){let a=!1;return{clearReset:()=>{a=!1},reset:()=>{a=!0},isReset:()=>a}}var j0=A.createContext(W0()),U0=()=>A.useContext(j0);function d0(a,t){return typeof a=="function"?a(...t):!!a}var Q0=(a,t)=>{(a.suspense||a.throwOnError)&&(t.isReset()||(a.retryOnMount=!1))},K0=a=>{A.useEffect(()=>{a.clearReset()},[a])},q0=({result:a,errorResetBoundary:t,throwOnError:h,query:n})=>a.isError&&!t.isReset()&&!a.isFetching&&d0(h,[a.error,n]);var _0=a=>{a.suspense&&typeof a.staleTime!="number"&&(a.staleTime=1e3)};var $0=(a,t)=>(a==null?void 0:a.suspense)&&t.isPending,J0=(a,t,h)=>t.fetchOptimistic(a).catch(()=>{h.clearReset()});function Z0(a,t,h){if(process.env.NODE_ENV!=="production"&&(typeof a!="object"||Array.isArray(a)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=N(h),v=N0(),r=U0(),i=n.defaultQueryOptions(a);i._optimisticResults=v?"isRestoring":"optimistic",_0(i),Q0(i,r),K0(r);const[z]=A.useState(()=>new t(n,i)),s=z.getOptimisticResult(i);if(A.useSyncExternalStore(A.useCallback(p=>{const d=v?()=>{}:z.subscribe(O.batchCalls(p));return z.updateResult(),d},[z,v]),()=>z.getCurrentResult(),()=>z.getCurrentResult()),A.useEffect(()=>{z.setOptions(i,{listeners:!1})},[i,z]),$0(i,s))throw J0(i,z,r);if(q0({result:s,errorResetBoundary:r,throwOnError:i.throwOnError,query:z.getCurrentQuery()}))throw s.error;return i.notifyOnChangeProps?s:z.trackResult(s)}function c2(a,t){return Z0(a,F0,t)}function J(a,t){const h=N(t),[n]=A.useState(()=>new E0(h,a));A.useEffect(()=>{n.setOptions(a)},[n,a]);const v=A.useSyncExternalStore(A.useCallback(i=>n.subscribe(O.batchCalls(i)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),r=A.useCallback((i,z)=>{n.mutate(i,z).catch(Y0)},[n]);if(v.error&&d0(n.options.throwOnError,[v.error]))throw v.error;return{...v,mutate:r,mutateAsync:v.mutate}}function Y0(){}function R(){return N().getQueryData(["apiBaseUrl"])||"/api/chaibuilder"}const H1=()=>{const{data:a,refetch:t}=c2({queryKey:["currentPage"],queryFn:()=>localStorage.getItem("currentPage")||""});return[a,h=>{h&&(localStorage.setItem("currentPage",h||""),t())}]};let j2="";const v2=()=>(j2=localStorage.getItem("__chai_at"),j2);function X0(a){const t={method:"GET",headers:{"x-chai-access-token":v2()}};return fetch(a,t)}function t4(a,t){const h={method:"POST",headers:{"x-chai-access-token":v2()},body:JSON.stringify(t)};return fetch(a,h)}function a4(a,t){const h={method:"PUT",headers:{"x-chai-access-token":v2()},body:JSON.stringify(t)};return fetch(a,h)}function h4(a,t){const h={method:"DELETE",headers:{"x-chai-access-token":v2()},body:JSON.stringify(t)};return fetch(a,h)}const W={get:X0,post:t4,put:a4,delete:h4},b2=()=>{const[a,t]=H1(),h=R();return c2({queryKey:["project"],queryFn:async()=>{const{data:n}=await W.get(`${h}/project`).then(v=>v.json());if(!a&&n){const v=localStorage.getItem("currentPage");t(v||(n==null?void 0:n.homepage))}return n}})},P2=()=>{const a=R();return c2({queryKey:["pages"],queryFn:async()=>{const{data:t}=await W.get(`${a}/pages`).then(h=>h.json());return t||[]}})},z0=()=>{const[a]=H1(),t=R();return c2({queryKey:["page_data",a],queryFn:async()=>{const{data:h}=await W.get(`${t}/page?uuid=${a}`).then(n=>n.json());return h},enabled:!!a,staleTime:3e3})},O2=()=>l.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen bg-gray-200",children:l.jsxRuntimeExports.jsxs("div",{className:"flex flex-col h-full w-full justify-center items-center",children:[l.jsxRuntimeExports.jsxs("div",{className:"flex flex-row gap-2",children:[l.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-orange-600 animate-bounce [animation-delay:.6s]"}),l.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-blue-600 animate-bounce [animation-delay:.4s]"}),l.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-green-600 animate-bounce [animation-delay:.2s]"}),l.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-yellow-600 animate-bounce [animation-delay:.0s]"})]}),l.jsxRuntimeExports.jsx("div",{className:"text-gray-700 font-thin",children:"Loading Builder..."})]})}),g0=(a="Project updated successfully.")=>{const t=N(),h=R();return J({mutationFn:async n=>await W.put(`${h}/project`,n).then(v=>v.json()),onSuccess:()=>{t.invalidateQueries({queryKey:["project"]}),a1.toast.success(a)}})},M0=()=>{const[a]=["SAVED"],[t,h]=H1(),n=q.useBuilderReset(),{t:v}=p0.useTranslation();return r=>a!=="SAVED"?(a1.toast.error(v("You have unsaved changes. Please save before changing the page.")),!1):t===r.uuid?!1:(n(),setTimeout(()=>h(r.uuid),100),!0)},n4=()=>{const a=N(),t=M0(),h=R();return J({mutationFn:async n=>W.post(`${h}/pages`,n).then(v=>v.json()),onSuccess:n=>{a.invalidateQueries({queryKey:["pages"]}),t({uuid:n.uuid,slug:n.slug}),a1.toast.success("Page added successfully.")}})},H0=()=>{const a=R(),[t]=H1(),h=N();return J({mutationFn:async n=>W.put(`${a}/page`,n).then(v=>v.json()),onSuccess:async n=>{var v;if(n.result==="error"&&((v=n.error)==null?void 0:v.code)=="PAGE_LOCKED"){h.invalidateQueries({queryKey:["page_data",t]});return}a1.toast.success("Page saved successfully.")}})},c4=()=>{const a=R(),{data:t}=P2(),[h]=H1(),{data:n}=b2(),v=N();return J({mutationFn:async()=>{const r=t.find(i=>i.uuid===h).slug;return await W.post(`${a}/publish`,{slug:r,uuid:h,isHomepage:(n==null?void 0:n.homepage)===h}).then(i=>i.json())},onSuccess:async r=>{var i;if(r.result==="error"&&((i=r.error)==null?void 0:i.code)=="PAGE_LOCKED"){v.invalidateQueries({queryKey:["page_data",h]});return}a1.toast.success("Page published successfully.",{position:"bottom-right",duration:2e3})}})},v4=()=>{const a=N(),t=R();return J({mutationFn:async h=>W.delete(`${t}/page`,h).then(n=>n.json()),onSuccess:()=>{a1.toast.success("Page deleted successfully."),a.invalidateQueries({queryKey:["pages"]})}})},r4=()=>{const a=N(),t=R();return J({mutationFn:async h=>W.post(`${t}/take-control`,{uuid:h}).then(n=>n.json()),onSuccess:(h,n)=>{a.invalidateQueries({queryKey:["page_data",n]})}})},e4=()=>{const a=R();return J({mutationFn:async()=>{const{data:t}=await W.get(`${a}/library`).then(h=>h.json());return h1.sortBy(h1.filter(t,h=>!h1.has(h,"hidden")),"group")}})},l4=()=>{const a=R();return J({mutationFn:async t=>{if(!t||!t.uuid)return[];try{const{data:h}=await W.get(`${a}/block?uuid=${t.uuid}&format=${t.format}`).then(async n=>t.format==="html"?V0.getBlocksFromHTML(await n.text()):await n.json());return h1.set(h,"0._name",h1.capitalize(t.group)),h||[]}catch{return[]}}})},i4=()=>{const a=R();return J({mutationFn:async t=>{const h=new FormData;h.append("file",t);const{data:n}=await fetch(`${a}/upload`,{method:"POST",headers:{"x-chai-access-token":v2()},body:h}).then(v=>v.json());return n}})};function u0(a){return t0.GenIcon({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"}},{tag:"path",attr:{d:"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"}}]})(a)}function o4(a){return t0.GenIcon({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"}},{tag:"path",attr:{d:"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"}}]})(a)}const d4=()=>{const{mutate:a,isPending:t}=r4(),[h]=H1(),{data:n}=z0(),v=h1.get(n,"lockedBy.name",""),r=h1.get(n,"lockedBy.email","");return l.jsxRuntimeExports.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg drop-shadow-2xl mx-auto p-10 space-y-4 text-center max-w-xl",children:[l.jsxRuntimeExports.jsxs("h2",{className:"text-2xl font-bold",children:["Page is ",l.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"locked"})]}),l.jsxRuntimeExports.jsxs("div",{className:"text-gray-500 dark:text-gray-400 font-light",children:["This page is currently being edited by ",l.jsxRuntimeExports.jsx("br",{}),l.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-3 w-max mx-auto font-medium text-gray-700 mt-2 text-sm",children:[l.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 bg-gray-100 py-1 px-2 rounded-md",children:[l.jsxRuntimeExports.jsx(o4,{className:"w-4 h-4 text-gray-500"})," ",v]}),l.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 bg-gray-100 py-1 px-2 rounded-md lowercase",children:[l.jsxRuntimeExports.jsx(u0,{className:"w-4 h-4 text-gray-500"})," ",r]})]}),l.jsxRuntimeExports.jsxs("div",{className:"pt-4",children:["If you take control, ",v," will be ",l.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"restricted"})," from making additional edits."]})]}),l.jsxRuntimeExports.jsx(q.Button,{disabled:t,onClick:()=>a(h),className:`w-36 ${t?"bg-transparent shadow-none hover:bg-transparent":""}`,children:t?l.jsxRuntimeExports.jsx(S2.Loader,{className:"text-sm animate-spin text-gray-500"}):"Take Over"})]})},z4=()=>{const a=R(),t=N();return J({mutationFn:async h=>{const n=await fetch(`${a}/login`,{method:"POST",body:JSON.stringify(h)});if(n.ok)return await n.json();throw n.status===401?new Error("Invalid login credentials"):new Error("Invalid")},onSuccess:h=>{const{data:n}=h;if(!n.accessToken){a1.toast.error("Something went wrong. Please try again.",{position:"top-center"});return}localStorage.setItem("__chai_at",n.accessToken),localStorage.setItem("__chai_ur",JSON.stringify(h1.omit(n,["accessToken"]))),t.invalidateQueries({queryKey:["verify"]}),a1.toast.success("Logged in successfully.")},onError:()=>{a1.toast.error("Invalid login credentials. Please try again.",{position:"top-center"})}})},g4=()=>{const a=R();return c2({queryKey:["verify"],queryFn:async()=>{const t=await W.get(`${a}/verify`);return t.ok?(await t.json()).result==="success"?{valid:!0}:(localStorage.removeItem("__chai_at"),{valid:!1}):(localStorage.removeItem("__chai_at"),{valid:!0})}})},M4=()=>{const a=R(),t=N();return J({mutationFn:async()=>{const{result:h}=await W.post(`${a}/logout`).then(n=>n.json());if(h==="success")return localStorage.clear(),t.invalidateQueries({queryKey:["verify"]}),{logout:!0};throw new Error("Invalid session")}})},H4=({children:a})=>{const t=M4();return l.jsxRuntimeExports.jsxs(q.AlertDialog,{children:[l.jsxRuntimeExports.jsx(q.AlertDialogTrigger,{asChild:!0,children:a}),l.jsxRuntimeExports.jsxs(q.AlertDialogContent,{children:[l.jsxRuntimeExports.jsxs(q.AlertDialogHeader,{children:[l.jsxRuntimeExports.jsxs(q.AlertDialogTitle,{children:["Are you sure, you want to ",l.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"Sign Out"}),"?"]}),l.jsxRuntimeExports.jsx(q.AlertDialogDescription,{children:"Kindly ensure that all your data is saved before proceeding with the sign-out process to prevent any potential loss of unsaved information"})]}),l.jsxRuntimeExports.jsxs(q.AlertDialogFooter,{children:[l.jsxRuntimeExports.jsx(q.AlertDialogCancel,{disabled:t.isPending,children:"Cancel"}),l.jsxRuntimeExports.jsxs("button",{disabled:t.isPending,onClick:()=>t.mutate(),className:"rounded-md text-white w-28 text-center justify-center bg-red-600 hover:bg-red-700 flex items-center gap-x-2",children:[t.isPending&&l.jsxRuntimeExports.jsx(S2.Loader2,{className:"animate-spin w-5 h-5"}),"Sign Out"]})]})]})]})},u4=()=>l.jsxRuntimeExports.jsx(H4,{children:l.jsxRuntimeExports.jsx("button",{className:"border-gray-200 rounded-md p-2 mb-2 border",children:l.jsxRuntimeExports.jsx(S2.LogOutIcon,{className:"w-4 h-4 text-red-500 cursor-pointer hover:text-red-300 duration-300"})})}),s4=T.lazy(()=>Promise.resolve().then(()=>require("./PagesPanel-n3x-0ozR.cjs"))),p4=T.lazy(()=>Promise.resolve().then(()=>require("./ProjectPanel-pBePMOta.cjs"))),V4=T.lazy(()=>Promise.resolve().then(()=>require("./CurrentPage-aTjWjc3o.cjs"))),f4=()=>l.jsxRuntimeExports.jsx("h2",{children:"Your Logo"}),m4=()=>{const{mutate:a}=c4();return q.useBuilderProp("editable",!0)?l.jsxRuntimeExports.jsx(q.Button,{onClick:a,className:"bg-blue-600 text-white",children:"Publish"}):null},L4=a=>{var f;const{data:t,isLoading:h}=b2(),{data:n,isLoading:v}=P2(),{data:r}=z0(),{mutate:i}=g0(),{mutate:z}=H0(),[s]=H1(),p=i4(),d=e4(),x=l4(),b=R(),H=T.useCallback(async m=>await p.mutateAsync(m),[p]),V=T.useCallback(async()=>await d.mutateAsync(),[d]),B=T.useCallback(async m=>await x.mutateAsync(m),[x]),g=async(m=20,y=0)=>{const F=`limit=${m}&offset=${y}`,I=await fetch(`${b}/assets?${F}`).then(w=>w.json());return I.result==="success"?I.data:[]},{logo:u=f4}=a;if(h||!t)return l.jsxRuntimeExports.jsx(O2,{});if(v||!n)return l.jsxRuntimeExports.jsx(O2,{});const G={...a,editable:r!=null&&r.lockedBy?r==null?void 0:r.lockedBy.self:!0,nonEditableComponent:d4,blocks:(r==null?void 0:r.blocks)||[],brandingOptions:t.brandingOptions,darkMode:a.darkMode||!1,dataProviders:(r==null?void 0:r.providers)||[],onSavePage:async({blocks:m,providers:y})=>(await z({blocks:m,providers:y,uuid:s}),!0),onSaveBrandingOptions:async m=>(await i({brandingOptions:m}),!0),topBarComponents:{left:[u],center:[V4],right:[m4]},sideBarComponents:{top:[{icon:i2.FileTextIcon,name:"pages",panel:s4},{icon:i2.GearIcon,name:"settings",panel:p4},...((f=a.sideBarComponents)==null?void 0:f.top)||[]],bottom:[u4]},uploadMediaCallback:H,fetchMediaCallback:g,getUILibraryBlocks:V,getExternalPredefinedBlock:B,getPages:()=>n};return l.jsxRuntimeExports.jsx(s0.ChaiBuilderEditor,{...G})},x4=({logo:a})=>{const[t,h]=T.useState(!1),[n,v]=T.useState(""),[r,i]=T.useState(""),{mutate:z,isPending:s}=z4(),p=d=>{d.preventDefault(),z({email:n,password:r})};return l.jsxRuntimeExports.jsx("section",{className:"h-screen w-screen flex items-center justify-center bg-[radial-gradient(#AAA,transparent_0.5px)] duration-300 [background-size:6px_6px]",children:l.jsxRuntimeExports.jsx("div",{className:"overflow-hidden bg-white rounded-xl w-96 drop-shadow-2xl duration-300",children:l.jsxRuntimeExports.jsxs("div",{className:"p-12",children:[l.jsxRuntimeExports.jsxs("div",{className:"max-w-2xl mx-auto text-center",children:[l.jsxRuntimeExports.jsx(T.Suspense,{children:a?T.createElement(a):""}),l.jsxRuntimeExports.jsx("p",{className:"max-w-xl mx-auto text-base leading-relaxed text-gray-700 font-thin",children:"Enter your login credential to continue"})]}),l.jsxRuntimeExports.jsx("div",{className:"mt-8",children:l.jsxRuntimeExports.jsxs("form",{method:"POST",onSubmit:p,className:"space-y-5",children:[l.jsxRuntimeExports.jsx("div",{children:l.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[l.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:l.jsxRuntimeExports.jsx(u0,{})}),l.jsxRuntimeExports.jsx("input",{value:n,onChange:d=>v(d.target.value),type:"email",id:"email",placeholder:"Enter email",className:"block w-full py-4 px-10 text-black placeholder-gray-500 transition-all duration-200 bg-white border border-gray-200 rounded-md focus:outline-none focus:border-blue-600 caret-blue-600"})]})}),l.jsxRuntimeExports.jsx("div",{children:l.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[l.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:l.jsxRuntimeExports.jsx("svg",{className:"w-5 h-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 11c0 3.517-1.009 6.799-2.753 9.571m-3.44-2.04l.054-.09A13.916 13.916 0 008 11a4 4 0 118 0c0 1.017-.07 2.019-.203 3m-2.118 6.844A21.88 21.88 0 0015.171 17m3.839 1.132c.645-2.266.99-4.659.99-7.132A8 8 0 008 4.07M3 15.364c.64-1.319 1-2.8 1-4.364 0-1.457.39-2.823 1.07-4"})})}),l.jsxRuntimeExports.jsx("input",{value:r,onChange:d=>i(d.target.value),type:t?"text":"password",id:"pwd",placeholder:"Enter password",className:"block w-full py-4 px-10 text-black placeholder-gray-500 transition-all duration-200 bg-white border border-gray-200 rounded-md focus:outline-none focus:border-blue-600 caret-blue-600"}),l.jsxRuntimeExports.jsx("button",{type:"button",className:"absolute inset-y-0 right-4 flex items-center pl-3 cursor-pointer",onClick:()=>h(!t),children:t?l.jsxRuntimeExports.jsx(i2.EyeClosedIcon,{}):l.jsxRuntimeExports.jsx(i2.EyeOpenIcon,{})})]})}),l.jsxRuntimeExports.jsx("div",{children:l.jsxRuntimeExports.jsx("button",{disabled:s||h1.size(n)<2||h1.size(r)<2,type:"submit",className:"inline-flex disabled:bg-gray-400 items-center justify-center w-full px-4 py-4 text-base font-semibold text-white transition-all duration-200 bg-blue-600 border border-transparent rounded-md focus:outline-none hover:bg-blue-700 focus:bg-blue-700",children:s?"Signing in...":"Login"})})]})}),l.jsxRuntimeExports.jsx("div",{className:"mt-4 flex items-center justify-end gap-x-2 text-sm",children:l.jsxRuntimeExports.jsx("a",{href:"https://apps.chaibuilder.com/settings",target:"_blank",className:"text-gray-500 hover:text-blue-400",children:"Forget your password?"})})]})})})},w4=a=>{const{data:t,isLoading:h}=g4(),n=N();return T.useEffect(()=>{n.setQueryData(["apiBaseUrl"],a.apiBaseUrl||"/api/chaibuilder")},[a.apiBaseUrl,n]),h?l.jsxRuntimeExports.jsx(O2,{}):t!=null&&t.valid?l.jsxRuntimeExports.jsx(L4,{...a}):l.jsxRuntimeExports.jsx(x4,{logo:a.logo})},B4=new R0,I4=a=>l.jsxRuntimeExports.jsxs(T0,{client:B4,children:[l.jsxRuntimeExports.jsx(a1.Toaster,{richColors:!0}),l.jsxRuntimeExports.jsx(w4,{...a})]});exports.ChaiBuilderStudio=I4;exports.useAddPage=n4;exports.useChangePage=M0;exports.useCurrentPage=H1;exports.useDeletePage=v4;exports.usePages=P2;exports.useProject=b2;exports.useQueryClient=N;exports.useUpdatePage=H0;exports.useUpdateProject=g0;
@@ -18,13 +18,13 @@ var v2 = (a, t, h, v) => ({
18
18
  import { j as i } from "./jsx-runtime-WbnYoNE9.js";
19
19
  import * as b from "react";
20
20
  import H0, { lazy as A2, useCallback as g2, useState as M2, Suspense as u0, useEffect as s0 } from "react";
21
- import { C as p0 } from "./index-SkyM3d6Q.js";
21
+ import { C as p0 } from "./index-lOJfSheQ.js";
22
22
  import { FileTextIcon as V0, GearIcon as f0, EyeClosedIcon as m0, EyeOpenIcon as L0 } from "@radix-ui/react-icons";
23
- import { u as x0, B as Y2, A as w0, a as B0, b as C0, c as O0, d as A0, e as S0, f as y0, g as b0, h as P0 } from "./index-Gk6sASBd.js";
23
+ import { u as x0, B as Y2, A as w0, a as B0, b as C0, c as O0, d as A0, e as S0, f as y0, g as b0, h as P0 } from "./index-CFUoB97-.js";
24
24
  import { toast as h1, Toaster as F0 } from "sonner";
25
25
  import { useTranslation as D0 } from "react-i18next";
26
26
  import { sortBy as R0, filter as k0, has as T0, set as E0, capitalize as N0, get as b2, omit as I0, size as P2 } from "lodash-es";
27
- import { g as W0 } from "./html-to-json-ngX9ef2u.js";
27
+ import { g as W0 } from "./html-to-json-p__Fgqdg.js";
28
28
  import { Loader as U0, Loader2 as j0, LogOutIcon as Q0 } from "lucide-react";
29
29
  import { G as X2 } from "./index-YpnaudSM.js";
30
30
  var N1 = class {
@@ -2044,7 +2044,7 @@ const k4 = () => {
2044
2044
  ] })
2045
2045
  ] })
2046
2046
  ] });
2047
- }, W4 = () => /* @__PURE__ */ i.jsx(I4, { children: /* @__PURE__ */ i.jsx("button", { className: "border-gray-200 rounded-md p-2 mb-2 border", children: /* @__PURE__ */ i.jsx(Q0, { className: "w-4 h-4 text-red-500 cursor-pointer hover:text-red-300 duration-300" }) }) }), U4 = A2(() => import("./PagesPanel-6rrLXEO-.js")), j4 = A2(() => import("./ProjectPanel-tz3bjdXy.js")), Q4 = A2(() => import("./CurrentPage-tJUjXWdb.js")), K4 = () => /* @__PURE__ */ i.jsx("h2", { children: "Your Logo" }), G4 = () => {
2047
+ }, W4 = () => /* @__PURE__ */ i.jsx(I4, { children: /* @__PURE__ */ i.jsx("button", { className: "border-gray-200 rounded-md p-2 mb-2 border", children: /* @__PURE__ */ i.jsx(Q0, { className: "w-4 h-4 text-red-500 cursor-pointer hover:text-red-300 duration-300" }) }) }), U4 = A2(() => import("./PagesPanel-rYN28QpN.js")), j4 = A2(() => import("./ProjectPanel-ivFOhdcz.js")), Q4 = A2(() => import("./CurrentPage-0eeU1V_c.js")), K4 = () => /* @__PURE__ */ i.jsx("h2", { children: "Your Logo" }), G4 = () => {
2048
2048
  const { mutate: a } = y4();
2049
2049
  return P0("editable", !0) ? /* @__PURE__ */ i.jsx(Y2, { onClick: a, className: "bg-blue-600 text-white", children: "Publish" }) : null;
2050
2050
  }, q4 = (a) => {