@chaibuilder/pages 0.15.21 → 0.15.24

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 (64) hide show
  1. package/dist/{2AITGKQY-JdTvsit7.js → 2AITGKQY-B6ojx8vV.js} +2 -2
  2. package/dist/{2AITGKQY-CuxhppUA.cjs → 2AITGKQY-wLnL_T-W.cjs} +1 -1
  3. package/dist/{NCMVHL6D-rzEn9a-Z.cjs → NCMVHL6D-DGH2CRR6.cjs} +1 -1
  4. package/dist/{NCMVHL6D-CTrkJrNW.js → NCMVHL6D-vsNnIwmV.js} +2 -2
  5. package/dist/{ZDWCUMSJ-DZa1ZX5H.cjs → ZDWCUMSJ-3BnFdOH2.cjs} +1 -1
  6. package/dist/{ZDWCUMSJ-DIAJ5hj-.js → ZDWCUMSJ-CoYx1TP5.js} +1 -1
  7. package/dist/{add-new-language-page-DPbVVRnt.cjs → add-new-language-page-VDZSKD95.cjs} +1 -1
  8. package/dist/{add-new-language-page-3fFJlIi4.js → add-new-language-page-d0-cAxlt.js} +2 -2
  9. package/dist/{add-new-page-C-DdGfOJ.js → add-new-page-Bcoxw6U5.js} +1 -1
  10. package/dist/{add-new-page-CgsPADOI.cjs → add-new-page-D4IkZL8h.cjs} +1 -1
  11. package/dist/ai-panel-content-Cn3SA_Sr.cjs +46 -0
  12. package/dist/ai-panel-content-qmOJKjkE.js +524 -0
  13. package/dist/{delete-page-ftu1i43t.cjs → delete-page-DeKAD4Ld.cjs} +1 -1
  14. package/dist/{delete-page-X6KE9Snl.js → delete-page-KS6p6b8f.js} +1 -1
  15. package/dist/{digital-asset-manager-zEPka3BT.cjs → digital-asset-manager-C9gYL2SF.cjs} +1 -1
  16. package/dist/{digital-asset-manager-CWneIIcn.js → digital-asset-manager-Dfe9SS09.js} +1 -1
  17. package/dist/{duplicate-page-D-2tkgsd.cjs → duplicate-page-CKr-HNs-.cjs} +1 -1
  18. package/dist/{duplicate-page-Bwp0RTTE.js → duplicate-page-vCgYnw4H.js} +2 -2
  19. package/dist/{dynamic-page-selector-Vl0aOeHK.js → dynamic-page-selector-A4fqWqZZ.js} +1 -1
  20. package/dist/{dynamic-page-selector-DDyEyh7e.cjs → dynamic-page-selector-C7w3TOdK.cjs} +1 -1
  21. package/dist/index-LfuCMBwI.cjs +5 -0
  22. package/dist/{index-DHfaX2M6.js → index-NSqs69Op.js} +850 -842
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +1 -1
  25. package/dist/{json-diff-viewer-BCtaXLmG.js → json-diff-viewer-7TGemUrn.js} +1 -1
  26. package/dist/{json-diff-viewer-CM1kUeoR.cjs → json-diff-viewer-nLLX6kJK.cjs} +1 -1
  27. package/dist/{lang-panel-CaOkz8d3.js → lang-panel-C6KxjKn_.js} +2 -2
  28. package/dist/{lang-panel-DNQEDZ5D.cjs → lang-panel-dc9uBMtE.cjs} +1 -1
  29. package/dist/{mark-as-template-CD1bYgow.cjs → mark-as-template-CJ9SiEBl.cjs} +1 -1
  30. package/dist/{mark-as-template-XIeQkqPw.js → mark-as-template-CRUOQ_FZ.js} +1 -1
  31. package/dist/{no-language-page-content-BHacGf6H.cjs → no-language-page-content--8a37nsW.cjs} +1 -1
  32. package/dist/{no-language-page-content-CtN5VB9K.js → no-language-page-content-ByHFQjkV.js} +1 -1
  33. package/dist/{page-creator-C7j6rkr2.cjs → page-creator-CzUQicdh.cjs} +1 -1
  34. package/dist/{page-creator-Ci3yqsDv.js → page-creator-J_CNgdj5.js} +2 -2
  35. package/dist/{page-lock-request-BNS3-biN.cjs → page-lock-request-BE9-Oego.cjs} +1 -1
  36. package/dist/{page-lock-request-01G9AeVF.js → page-lock-request-CD93n5pq.js} +1 -1
  37. package/dist/{page-locked-by-dialog-Cei-v0MT.cjs → page-locked-by-dialog-1Lm9dcT6.cjs} +1 -1
  38. package/dist/{page-locked-by-dialog-BQV9X0UF.js → page-locked-by-dialog-noDLCQWF.js} +1 -1
  39. package/dist/{page-manager-new-XGKr4mup.cjs → page-manager-new-BoTBCqZF.cjs} +1 -1
  40. package/dist/{page-manager-new-DE_2H_ow.js → page-manager-new-D-U4B9y9.js} +2 -2
  41. package/dist/{page-manager-search-and-filter-BDw2AYXn.cjs → page-manager-search-and-filter-BJmETYq-.cjs} +1 -1
  42. package/dist/{page-manager-search-and-filter-B8zCpxug.js → page-manager-search-and-filter-h-YzJVcH.js} +1 -1
  43. package/dist/{page-revisions-content-BIdaOcUx.cjs → page-revisions-content-BNBb2qYh.cjs} +1 -1
  44. package/dist/{page-revisions-content-mih9gx3J.js → page-revisions-content-C7DXjFls.js} +2 -2
  45. package/dist/{publish-pages-content-jYi-Q1Vl.js → publish-pages-content-DAKh_sSW.js} +2 -2
  46. package/dist/{publish-pages-content-1knN5SPM.cjs → publish-pages-content-DsOVOiBD.cjs} +1 -1
  47. package/dist/{save-to-lib-CpFEdU_R.js → save-to-lib-BPR_--qN.js} +1 -1
  48. package/dist/{save-to-lib-B56XAto8.cjs → save-to-lib-BR1Qhw3Q.cjs} +1 -1
  49. package/dist/{seo-panel-D3bp2i90.js → seo-panel-C7XC-XRg.js} +1 -1
  50. package/dist/{seo-panel-DRb3uTUp.cjs → seo-panel-CUqtdGoF.cjs} +1 -1
  51. package/dist/{shared-json-ld-C4Kjka5m.js → shared-json-ld-0JD8sokD.js} +1 -1
  52. package/dist/{shared-json-ld-pNjN-zzY.cjs → shared-json-ld-CDffP4G3.cjs} +1 -1
  53. package/dist/{slug-input-BeepGXWz.cjs → slug-input-BYH90lv1.cjs} +1 -1
  54. package/dist/{slug-input-CKIckRno.js → slug-input-CvIDihGn.js} +1 -1
  55. package/dist/{theme-panel-footer-B0NRCfkL.cjs → theme-panel-footer-CUSfduTK.cjs} +1 -1
  56. package/dist/{theme-panel-footer-DscF7mar.js → theme-panel-footer-DPpLzCDu.js} +1 -1
  57. package/dist/{unmark-as-template-9-wHwCPl.cjs → unmark-as-template-Bxw4t_Xi.cjs} +1 -1
  58. package/dist/{unmark-as-template-Dezq0GEM.js → unmark-as-template-CjqRfFDL.js} +1 -1
  59. package/dist/{unpublish-page-DU3jKAJ5.cjs → unpublish-page-BjiB3d7l.cjs} +1 -1
  60. package/dist/{unpublish-page-COPOrCk_.js → unpublish-page-CKKU1St1.js} +1 -1
  61. package/dist/{web-preview-DBBTePPU.cjs → web-preview-CNMYCWxW.cjs} +1 -1
  62. package/dist/{web-preview-sSS97N-o.js → web-preview-D0OpieXz.js} +1 -1
  63. package/package.json +13 -12
  64. package/dist/index-DOlBrCPx.cjs +0 -5
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),M=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),F=require("lodash-es"),f=require("lucide-react"),u=require("react"),fe=require("react-dropzone"),g=require("./index-DOlBrCPx.cjs"),w=require("sonner"),Y=require("./image-compression-DZ9WMmyn.cjs"),z=require("@tanstack/react-query"),pe=()=>{const n=g.useAssetsApiUrl(),r=z.useQueryClient(),x=g.useFetch();return z.useMutation({mutationFn:async i=>{const o=i.map(async l=>x(n,{action:g.ACTIONS.UPLOAD_ASSET,data:l}));return await Promise.all(o)},onSuccess:i=>{var o;if(i!=null&&i.some(s=>s.error))throw new Error(((o=i==null?void 0:i.find(s=>s.error))==null?void 0:o.error)||"Failed to upload asset");{r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSETS]});const s=i==null?void 0:i.length;w.toast.success(`${s===1?"Asset":s+" Assets"} uploaded successfully`)}},onError:()=>{w.toast.error("Failed to upload asset")}})},ge=()=>{const n=g.useAssetsApiUrl(),r=z.useQueryClient(),x=g.useFetch();return z.useMutation({mutationFn:async i=>x(n,{action:g.ACTIONS.DELETE_ASSET,data:{id:i}}),onSuccess:i=>{if(i!=null&&i.error)throw new Error(i==null?void 0:i.error);r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSETS]}),w.toast.success("Asset deleted successfully")},onError:()=>{w.toast.error("Failed to delete asset")}})},je=()=>{const n=g.useAssetsApiUrl(),r=z.useQueryClient(),x=g.useFetch();return z.useMutation({mutationFn:async i=>x(n,{action:g.ACTIONS.UPDATE_ASSET,data:i}),onSuccess:i=>{if(i!=null&&i.error)throw new Error(i==null?void 0:i.error);r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSETS]}),i!=null&&i.id&&r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSET,i.id]}),w.toast.success("Asset updated successfully")},onError:()=>{w.toast.error("Failed to update asset")}})};function ve({currentPage:n,totalPages:r,onPageChange:x,pageRangeDisplayed:i=3,showPageInput:o=!0,className:s=""}){const[l,E]=u.useState(String(n)),N=u.useMemo(()=>{const c=Math.floor(i/2);let m=Math.max(1,n-c),d=Math.min(r,n+c);d-m+1<i&&(m===1?d=Math.min(r,m+i-1):d===r&&(m=Math.max(1,d-i+1)));const p=[];m>1&&(p.push(1),m>2&&p.push("..."));for(let y=m;y<=d;y++)p.push(y);return d<r&&(d<r-1&&p.push("..."),p.push(r)),p},[n,r,i]),v=c=>{c!==n&&c>=1&&c<=r&&(x(c),E(String(c)))},j=()=>{n>1&&v(n-1)},b=()=>{n<r&&v(n+1)},C=()=>{const c=Number(l);!isNaN(c)&&c>=1&&c<=r&&v(c)},A=c=>{c.key==="Enter"&&C()};return r<=1?null:e.jsxs("div",{className:`flex flex-wrap items-center justify-center gap-3 ${s}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a.Button,{variant:"outline",size:"sm",onClick:j,disabled:n===1,className:"px-2 py-1 text-sm hover:bg-gray-50",children:[e.jsx(f.ChevronLeft,{className:" h-4 w-4"}),"Previous"]}),e.jsx("div",{className:"flex items-center gap-2",children:N.map((c,m)=>{if(c==="...")return e.jsx("span",{className:"px-2 text-muted-foreground",children:"..."},`ellipsis-${m}`);const d=c,p=d===n;return e.jsx(a.Button,{variant:p?"default":"outline",size:"sm",onClick:()=>v(d),className:p?"border-blue-600 bg-blue-600 px-3 py-1 text-sm text-white":"border px-3 py-1 text-sm hover:bg-gray-50 hover:text-black",children:d},d)})}),e.jsxs(a.Button,{variant:"outline",size:"sm",onClick:b,disabled:n===r,className:"px-2 py-1 text-sm hover:bg-gray-50",children:["Next",e.jsx(f.ChevronRight,{className:" h-4 w-4"})]})]}),o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Go to"}),e.jsx(a.Input,{type:"number",min:1,max:r,value:l,onChange:c=>{const m=c.target.value.replace(/[^\d]/g,"");E(m)},onKeyDown:A,className:"h-8 w-16 px-2 py-1"}),e.jsx(a.Button,{variant:"outline",size:"sm",onClick:C,disabled:l===""||Number(l)<1||Number(l)>r,children:"Go"})]})]})}const ye=(n={})=>{const r=g.useAssetsApiUrl(),x=g.useFetch(),{search:i,page:o=1,limit:s=30}=n;return z.useQuery({queryKey:[g.ACTIONS.GET_ASSETS,i,o,s],queryFn:async()=>{const l=await x(r,{action:g.ACTIONS.GET_ASSETS,data:{search:i,page:o,limit:s}});return l.page=o,l.limit=s,l},staleTime:1/0,retry:1})},Ne=n=>{const r=g.useAssetsApiUrl(),x=g.useFetch();return z.useQuery({queryKey:[g.ACTIONS.GET_ASSET,n],queryFn:async()=>n?await x(r,{action:g.ACTIONS.GET_ASSET,data:{id:n}}):null,staleTime:1/0,retry:1})};function be(n){const r=isNaN(n)?0:typeof n=="number"?n:parseInt(n);return r?r<1024?`${r.toFixed(2)} B`:r<1024*1024?`${(r/1024).toFixed(2)} KB`:`${(r/(1024*1024)).toFixed(2)} MB`:"0 B"}function Z(n){if(!n)return"N/A";const r=new Date(n);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)}function J(n,r){let x=n,i=r==null?void 0:r.description;return(!i||typeof i!="string")&&(i=""),(!x||typeof x!="string")&&(x=""),x!==i}const we=({assetId:n,onBack:r,onEdit:x,onSave:i,isSaving:o})=>{var c,m;const{t:s}=M.useTranslation(),{data:l,isLoading:E,isError:N}=Ne(n||""),[v,j]=u.useState(""),[b,C]=u.useState(!1);u.useEffect(()=>{const d=new Image;return d.src=(l==null?void 0:l.url)||"",d.onload=()=>C(!0),()=>{d.onload=null}},[l]);const A=async(d,p)=>{try{await navigator.clipboard.writeText(d),w.toast.success(s("{{type}} copied to clipboard",{type:p}))}catch(y){w.toast.error(s("Failed to copy {{type}}",{type:p}),{description:y==null?void 0:y.message})}};return u.useEffect(()=>{l!=null&&l.description&&j(l.description)},[l]),E||!b?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(f.Loader,{className:"h-8 w-8 animate-spin"})}):N||!(l!=null&&l.id)?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center max-w-md mx-auto p-6",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(f.AlertCircle,{className:"h-12 w-12 text-gray-400"})}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:s("No Asset Found")}),e.jsx("p",{className:"text-sm text-gray-500 mb-6",children:s(N?"There was an error loading the asset. Please try again later.":"The asset you're looking for doesn't exist or has been removed.")}),e.jsxs("div",{className:"flex justify-center gap-4",children:[e.jsx(a.Button,{variant:"outline",onClick:r,children:s("Back to Assets")}),N&&e.jsx(a.Button,{variant:"default",onClick:()=>window.location.reload(),children:s("Try Again")})]})]})}):e.jsxs("div",{className:"flex-1 flex flex-col gap-y-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(a.Button,{variant:"outline",size:"sm",onClick:r,disabled:o,children:[e.jsx(f.ChevronLeft,{className:"h-4 w-4"}),s("Back to Assets")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(a.Button,{variant:"outline",onClick:r,disabled:o,children:s("Cancel")}),e.jsxs(a.Button,{variant:"outline",onClick:()=>A(l.url,s("Asset URL")),disabled:o,children:[e.jsx(f.Copy,{className:"h-4 w-4 mr-2"}),s("Copy URL")]}),e.jsxs(a.Button,{variant:"default",onClick:()=>x(l),disabled:o,children:[e.jsx(f.Pencil,{className:"h-4 w-4"}),s("Edit Image")]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 items-start gap-6 flex-1 overflow-hidden",children:[e.jsx("div",{className:"relative h-[calc(80vh-200px)] w-full flex items-start justify-center",children:e.jsx("img",{src:l.url,alt:l.name,className:"w-full h-full object-contain rounded-lg max-h-max max-w-max"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-3 border rounded-md pt-2 bg-gray-100",children:[e.jsx(a.Label,{className:"w-full text-center",children:s("Details")}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2 bg-white",children:[{label:s("File Name"),value:l.name},{label:s("Type"),value:l.type,capitalize:!0},{label:s("Format"),value:((c=l.metadata)==null?void 0:c.format)||l.type,capitalize:!0},{label:s("Size"),value:be(l.size)},{label:s("Dimensions"),value:`${l.width||0} × ${l.height||0}`},{label:s("Created"),value:Z(l.createdAt)},{label:s("Updated"),value:Z(((m=l.metadata)==null?void 0:m.updatedAt)||(l==null?void 0:l.updatedAt)||l.createdAt)},{label:s("URL"),value:l.url,copyable:!0}].map(d=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Label,{className:"w-max text-left px-2 w-1/4 font-normal text-gray-700",children:d.label}),":",e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-max text-left font-medium text-gray-900"+(d.capitalize?" capitalize":""),children:d.value}),d.copyable&&e.jsx(a.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>A(d.value,d.label),children:e.jsx(f.Link,{className:"h-3 w-3"})})]})]},d.label))})]}),l.usedOn&&l.usedOn.length>0&&e.jsxs("div",{className:"grid gap-3",children:[e.jsx(a.Label,{children:s("Used On")}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2",children:l.usedOn.map((d,p)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-max text-left font-medium text-gray-900",children:d.name}),e.jsxs("div",{className:"text-gray-500",children:["(",d.slug,")"]})]},p))})]}),e.jsxs("div",{className:"grid gap-3 border rounded-md pt-2 bg-gray-100 relative",children:[e.jsx(a.Label,{className:"w-full text-center",children:s("Description")}),e.jsx(a.Textarea,{id:"description",value:v,placeholder:s("Enter a description for the asset"),onChange:d=>j(d.target.value),rows:3,disabled:o,className:"hover:border-black/40 bg-white"}),e.jsx("div",{className:"flex justify-end items-start absolute top-1.5 right-2",children:e.jsx("button",{type:"button",onClick:()=>i(v),disabled:o||!J(v,l),className:`py-0 bg-blue-500 text-white px-3 py-0.5 rounded-md text-sm ${o||!J(v,l)?"opacity-50 cursor-not-allowed":""}`,children:o?e.jsxs(e.Fragment,{children:[e.jsx(f.Loader,{className:"h-4 w-4 mr-2 animate-spin"}),s("Saving...")]}):s("Save")})})]})]})]})]})},Ce=u.lazy(()=>Promise.resolve().then(()=>require("./image-editor-CnDnY97s.cjs"))),Ae=25*1024*1024,Se=({isUpdatingAsset:n,allowedTypes:r,uploadAssets:x,isUploadingAsset:i,onUploaded:o})=>{const{t:s}=M.useTranslation(),[l,E]=u.useState(()=>{const c=localStorage.getItem("chai_optimize_images");return c!==null?c==="true":!0});u.useEffect(()=>{localStorage.setItem("chai_optimize_images",l.toString())},[l]);const N=n||i,v=u.useCallback(async c=>{try{const m=c;if(!m.every(S=>S.type.startsWith("image/")))return w.toast.error(s("Invalid file type. Please upload a valid file.")),Promise.reject(new Error("Invalid file type"));const d=m.map(async S=>{let U=S;return S.type.startsWith("image/")&&(U=await Y.compressImageIfNeeded(S)),new Promise((_,B)=>{const L=new FileReader;L.readAsDataURL(U),L.onload=async()=>{_({file:L.result,folderId:void 0,name:S.name,optimize:l})},L.onerror=()=>B(null)})}),p=await Promise.all(d),y=await x(p);return(y==null?void 0:y.length)===1&&o(y[0]),y}catch(m){return Promise.reject(m)}},[x,l,o,s]),j=c=>{const m=[];let d=0;return c.forEach(p=>{p.size>Ae?d++:m.push(p)}),d>0&&w.toast.error(`${d===1&&c.length===1?s("File"):d+s(d===1?" file":" files")} ${s("exceed the maximum size limit of 10MB.")}`),F.isEmpty(m)?[]:v(m)},{getRootProps:b,getInputProps:C,isDragActive:A}=fe.useDropzone({onDrop:j,accept:{"image/*":r.includes("image")?[]:[]},disabled:n||i,multiple:!0});return e.jsx("div",{className:`flex h-[60px] w-full flex-col items-center justify-center rounded-lg border-2 border-dashed border-slate-300 p-0 py-2 hover:border-black/50 ${N?"pointer-events-none bg-gray-100 opacity-90":"bg-gray-100 hover:border-black/50 hover:bg-gray-100"}`,children:e.jsxs("div",{...b(),className:M.mergeClasses("flex h-max w-full cursor-pointer flex-col justify-center rounded-lg text-center",N?"items-start":"items-center",A?"border-primary bg-primary/5":"border-muted-foreground/20"),children:[e.jsx("input",{...C()}),N?e.jsx("div",{className:"flex flex-col items-center px-6",children:e.jsxs("div",{className:"flex items-center justify-center gap-2 leading-tight",children:[e.jsx("div",{className:"flex items-center justify-center rounded-full bg-indigo-100 p-2",children:e.jsx(f.Loader,{className:"h-4 w-4 animate-spin text-indigo-500"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:s(n?"Updating file...":"Uploading file...")}),e.jsxs("div",{className:"text-xs font-light text-muted-foreground",children:[s("Please wait while we")," ",s(n?"update":"upload")," ",s("your file...")]})]})]})}):e.jsxs("div",{className:"flex w-full items-center justify-between px-6",children:[e.jsx("div",{className:"flex flex-col items-center",children:e.jsxs("div",{className:"flex items-center justify-between gap-2 leading-tight",children:[e.jsx("div",{className:"flex items-center justify-center rounded-full border border-indigo-500 bg-indigo-100 p-2",children:e.jsx(f.Upload,{className:"h-4 w-4 text-indigo-500"})}),e.jsxs("div",{className:"text-left",children:[e.jsxs("div",{className:"font-medium",children:[s("Drop your file here or")," ",e.jsx("span",{className:"cursor-pointer text-indigo-500 hover:underline",children:s("browse")})]}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:e.jsxs("span",{className:"",children:[s("Accepted file types:")," ",e.jsx("span",{className:"capitalize text-indigo-400",children:r.join(", ")})]})})]})]})}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs",children:[s("Optimization:")," "," ",e.jsx("span",{className:l?"text-indigo-600":"text-gray-400",children:s(l?"On":"Off")})]}),e.jsx(a.Switch,{checked:l,onCheckedChange:c=>{E(c)},onClick:c=>{c.stopPropagation()},className:"data-[state=checked]:bg-indigo-500"})]}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx("span",{className:`flex cursor-help items-center text-amber-500 ${l?"invisible":""}`,children:e.jsx(f.AlertTriangle,{className:"mr-1 h-4 w-4"})})}),e.jsx(a.TooltipContent,{side:"top",children:e.jsx("p",{className:"text-xs text-white",children:s("Warning: Unoptimized images may affect performance and page load times")})})]})})]})]})]})})};function Te({close:n,onSelect:r,mode:x="image",assetId:i}){const{t:o}=M.useTranslation(),s=!1,l=10,E=u.useMemo(()=>[x],[x]),[N,v]=u.useState(null),[j,b]=u.useState(null),[C,A]=u.useState(null),[c,m]=u.useState({show:!1,file:""}),[d,p]=u.useState(!1),[y,S]=u.useState(i?"details":"grid"),[U,_]=u.useState(""),[B,L]=u.useState(""),[P,Q]=u.useState(1),[R]=u.useState(30),[T,G]=u.useState([]);u.useEffect(()=>{i&&(v(i),S("details"))},[i]),u.useEffect(()=>{const t=setTimeout(()=>{_(B),Q(1)},300);return()=>clearTimeout(t)},[B]);const{data:q,isLoading:$,refetch:ee}=ye({search:U.toLowerCase().trim(),page:P,limit:R}),D=(q==null?void 0:q.assets)||[],te=(q==null?void 0:q.total)||0,I=Math.ceil(te/R);u.useEffect(()=>{$||I<=0||Q(t=>t>I?I:t<1?1:t)},[$,I]);const se=(D==null?void 0:D.length)>0,{mutate:ie}=ge(),{mutateAsync:K,isPending:le}=pe(),{mutateAsync:W,isPending:ae}=je(),V=u.useCallback(t=>{const h=Math.min(Math.max(1,t),Math.max(1,I));h!==P&&Q(h)},[I,P]),re=t=>{L(t.target.value)},ne=u.useCallback(t=>{G(h=>F.find(h,{id:t.id})?[]:[t])},[s]),oe=u.useCallback(()=>{G([])},[]),H=t=>{(t==null?void 0:t.length)!==0&&(r(F.pick(F.first(t||T),["id","url","width","height","description"])),n())},ce=async t=>{b(t)},de=async()=>{j&&(A(j==null?void 0:j.id),await ie(j.id,{onSuccess:()=>{A(null),b(null)},onError:()=>{A(null)}}),b(null))},ue=t=>{v(t.id),S("details")},me=async(t,h)=>{try{const O=localStorage.getItem("chai_optimize_images")!=="false";if(h){const k=await K([{file:t,folderId:void 0,name:c.name||"",optimize:O}]);if((k==null?void 0:k.length)>0){const X=k[0];r({...F.pick(X,["id","width","height","description"]),url:X.url})}}else{const k=await W({id:c.id||"",file:t});k&&r({...F.pick(k,["id","width","height","description"]),url:k.url})}m({show:!1,file:""}),n()}catch(O){console.error(o("Error saving edited image:"),O)}},he=u.useCallback(t=>{G([t])},[]),xe=u.useCallback(t=>{V(t)},[V]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-[80vh] max-h-[1232px] w-[80vw] max-w-[1232px] flex-col space-y-4",children:[e.jsx("h1",{className:"text-lg font-medium",children:o("Digital Asset Manager")}),y==="grid"?e.jsxs(e.Fragment,{children:[e.jsx(Se,{maxFileSize:l,allowedTypes:E,uploadAssets:K,isUpdatingAsset:ae,isUploadingAsset:le,onUploaded:he}),e.jsxs("div",{className:"relative flex flex-1 flex-col gap-y-3 overflow-hidden rounded-lg border p-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"relative w-1/2",children:[e.jsx(f.Search,{strokeWidth:3,className:`absolute left-2 top-2.5 h-4 w-4 text-muted-foreground ${B.length>0?"text-indigo-800":""}`}),e.jsx(a.Input,{placeholder:o("Search assets..."),onChange:re,value:B,className:"pl-8"})]}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[T.length>0?e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[T.length>0&&e.jsx(e.Fragment,{children:e.jsx(a.Button,{variant:"outline",size:"sm",onClick:()=>oe(),title:o("Clear selection"),children:o("Clear")})}),e.jsx(a.Button,{size:"sm",onClick:()=>H(T),disabled:T.length===0,children:o("Select Asset")})]})}):null,e.jsx(a.Button,{variant:"ghost",size:"icon",onClick:()=>ee(),children:e.jsx(f.RefreshCwIcon,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto pb-[66px]",children:$?e.jsxs("div",{className:"columns-1 gap-3 space-y-3 sm:columns-3 md:columns-5",children:[e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"})]}):!$&&!se?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center rounded-lg border",children:[e.jsx("div",{className:"text-muted-foreground",children:e.jsx(f.Archive,{className:"h-9 w-9 text-indigo-500"})}),e.jsx("div",{className:"text-lg text-muted-foreground",children:o("No assets found")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:U.length>0?o("No assets found for your search: {{query}}",{query:U}):o("Start uploading assets to get started")}),e.jsx("br",{})]}):e.jsx("div",{className:"flex flex-wrap gap-3 p-1",children:D==null?void 0:D.map(t=>e.jsxs("div",{className:M.mergeClasses("group relative flex max-h-[180px] max-w-[180px] cursor-pointer flex-col justify-between overflow-hidden rounded-lg border-2 transition-all",T.some(h=>h.id===t.id)?"border-blue-500":"hover:border-black/90",C&&(j==null?void 0:j.id)===t.id?"pointer-events-none opacity-50":"",C===t.id?"pointer-events-none opacity-50":""),onClick:()=>ne(t),onDoubleClick:()=>H([t]),children:[e.jsxs("div",{className:"aspect-square relative overflow-hidden",children:[C===t.id?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:e.jsx(f.Loader,{className:"h-8 w-8 animate-spin text-white"})}):null,t.type==="image"?e.jsx("img",{src:`${t.thumbnailUrl||"/placeholder.svg"}?v=${(t==null?void 0:t.updatedAt)||t.createdAt}`,alt:t.name,className:`h-full min-h-[80px] w-full object-contain ${T.some(h=>h.id===t.id)?"":"group-hover:blur group-hover:contrast-50"}`}):e.jsxs("div",{className:"flex h-full items-center justify-center",children:[e.jsx(f.Film,{className:"h-12 w-12 text-muted-foreground"}),t.thumbnailUrl&&e.jsx("img",{src:`${t.thumbnailUrl||"/placeholder.svg"}?v=${(t==null?void 0:t.updatedAt)||t.createdAt}`,alt:t.name,className:"absolute inset-0 h-full w-full object-cover"})]})]}),e.jsxs("div",{className:"flex items-end justify-between border-t-[1px] border-black/10 bg-white px-2 py-1",children:[e.jsx("div",{className:"truncate text-xs leading-tight",title:t.name,children:t.name}),e.jsx("div",{className:"flex items-center justify-between whitespace-nowrap text-[9px] font-light text-muted-foreground",children:e.jsx("span",{children:Y.formatFileSize((t==null?void 0:t.size)||0)})})]}),!T.some(h=>h.id===t.id)&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 transition-opacity group-hover:opacity-100",children:e.jsxs("div",{className:"grid grid-cols-4 gap-2 p-2",children:[e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),ue(t)},children:e.jsx(f.ImageIcon,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("View Details")})})]})}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),navigator.clipboard.writeText(t.url),w.toast.success(o("Asset URL copied to clipboard"))},children:e.jsx(f.Copy,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("Copy URL")})})]})}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),m({id:t.id,show:!0,file:t.url,name:t.name})},children:e.jsx(f.Edit,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("Edit Image")})})]})}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"destructive",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),ce(t)},children:e.jsx(f.Trash2,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("Delete Asset")})})]})})]})}),T.some(h=>h.id===t.id)&&e.jsx("div",{className:"absolute right-1 top-1 h-max rounded-full border border-white bg-blue-500 p-1",children:e.jsx(f.Check,{className:"h-3 w-3 text-white",strokeWidth:5})})]},t.id))})}),I>1&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 border-t bg-white p-4",children:e.jsx(g.ErrorBoundary,{fallback:e.jsx("div",{className:"text-red-500",children:o("Error loading pagination")}),children:e.jsx(ve,{currentPage:P,totalPages:I,onPageChange:xe,pageRangeDisplayed:3,showPageInput:!0})})})]})]}):e.jsx(we,{assetId:N||i||"",onBack:()=>{S("grid"),v(null)},onEdit:t=>{m({id:t.id,show:!0,file:t.url,name:t.name})},onSave:async t=>{if(N){p(!0);try{const h=D.find(O=>O.id===N);h&&await W(F.merge(h,{description:t}))}finally{p(!1)}}},isSaving:d})]}),c.show&&e.jsx(u.Suspense,{fallback:e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(f.Loader,{className:"h-8 w-8 animate-spin"})}),children:e.jsx(Ce,{imageUrl:c.file,onSave:me,onClose:()=>m({show:!1,file:""}),defaultSavedImageName:c.name,isEditing:!!c.id})}),j&&e.jsx(a.Dialog,{open:!!j,onOpenChange:()=>b(null),children:e.jsxs(a.DialogContent,{children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:o("Delete Asset")}),e.jsx(a.DialogDescription,{children:o('Are you sure you want to delete "{{name}}"? This action cannot be undone.',{name:j.name})})]}),e.jsxs(a.DialogFooter,{className:"gap-2 sm:gap-0",children:[e.jsx(a.Button,{variant:"outline",onClick:()=>b(null),children:o("Cancel")}),e.jsx(a.Button,{variant:"destructive",onClick:de,children:o("Delete")})]})]})})]})}exports.default=Te;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),M=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),F=require("lodash-es"),f=require("lucide-react"),u=require("react"),fe=require("react-dropzone"),g=require("./index-LfuCMBwI.cjs"),w=require("sonner"),Y=require("./image-compression-DZ9WMmyn.cjs"),z=require("@tanstack/react-query"),pe=()=>{const n=g.useAssetsApiUrl(),r=z.useQueryClient(),x=g.useFetch();return z.useMutation({mutationFn:async i=>{const o=i.map(async l=>x(n,{action:g.ACTIONS.UPLOAD_ASSET,data:l}));return await Promise.all(o)},onSuccess:i=>{var o;if(i!=null&&i.some(s=>s.error))throw new Error(((o=i==null?void 0:i.find(s=>s.error))==null?void 0:o.error)||"Failed to upload asset");{r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSETS]});const s=i==null?void 0:i.length;w.toast.success(`${s===1?"Asset":s+" Assets"} uploaded successfully`)}},onError:()=>{w.toast.error("Failed to upload asset")}})},ge=()=>{const n=g.useAssetsApiUrl(),r=z.useQueryClient(),x=g.useFetch();return z.useMutation({mutationFn:async i=>x(n,{action:g.ACTIONS.DELETE_ASSET,data:{id:i}}),onSuccess:i=>{if(i!=null&&i.error)throw new Error(i==null?void 0:i.error);r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSETS]}),w.toast.success("Asset deleted successfully")},onError:()=>{w.toast.error("Failed to delete asset")}})},je=()=>{const n=g.useAssetsApiUrl(),r=z.useQueryClient(),x=g.useFetch();return z.useMutation({mutationFn:async i=>x(n,{action:g.ACTIONS.UPDATE_ASSET,data:i}),onSuccess:i=>{if(i!=null&&i.error)throw new Error(i==null?void 0:i.error);r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSETS]}),i!=null&&i.id&&r.invalidateQueries({queryKey:[g.ACTIONS.GET_ASSET,i.id]}),w.toast.success("Asset updated successfully")},onError:()=>{w.toast.error("Failed to update asset")}})};function ve({currentPage:n,totalPages:r,onPageChange:x,pageRangeDisplayed:i=3,showPageInput:o=!0,className:s=""}){const[l,E]=u.useState(String(n)),N=u.useMemo(()=>{const c=Math.floor(i/2);let m=Math.max(1,n-c),d=Math.min(r,n+c);d-m+1<i&&(m===1?d=Math.min(r,m+i-1):d===r&&(m=Math.max(1,d-i+1)));const p=[];m>1&&(p.push(1),m>2&&p.push("..."));for(let y=m;y<=d;y++)p.push(y);return d<r&&(d<r-1&&p.push("..."),p.push(r)),p},[n,r,i]),v=c=>{c!==n&&c>=1&&c<=r&&(x(c),E(String(c)))},j=()=>{n>1&&v(n-1)},b=()=>{n<r&&v(n+1)},C=()=>{const c=Number(l);!isNaN(c)&&c>=1&&c<=r&&v(c)},A=c=>{c.key==="Enter"&&C()};return r<=1?null:e.jsxs("div",{className:`flex flex-wrap items-center justify-center gap-3 ${s}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a.Button,{variant:"outline",size:"sm",onClick:j,disabled:n===1,className:"px-2 py-1 text-sm hover:bg-gray-50",children:[e.jsx(f.ChevronLeft,{className:" h-4 w-4"}),"Previous"]}),e.jsx("div",{className:"flex items-center gap-2",children:N.map((c,m)=>{if(c==="...")return e.jsx("span",{className:"px-2 text-muted-foreground",children:"..."},`ellipsis-${m}`);const d=c,p=d===n;return e.jsx(a.Button,{variant:p?"default":"outline",size:"sm",onClick:()=>v(d),className:p?"border-blue-600 bg-blue-600 px-3 py-1 text-sm text-white":"border px-3 py-1 text-sm hover:bg-gray-50 hover:text-black",children:d},d)})}),e.jsxs(a.Button,{variant:"outline",size:"sm",onClick:b,disabled:n===r,className:"px-2 py-1 text-sm hover:bg-gray-50",children:["Next",e.jsx(f.ChevronRight,{className:" h-4 w-4"})]})]}),o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Go to"}),e.jsx(a.Input,{type:"number",min:1,max:r,value:l,onChange:c=>{const m=c.target.value.replace(/[^\d]/g,"");E(m)},onKeyDown:A,className:"h-8 w-16 px-2 py-1"}),e.jsx(a.Button,{variant:"outline",size:"sm",onClick:C,disabled:l===""||Number(l)<1||Number(l)>r,children:"Go"})]})]})}const ye=(n={})=>{const r=g.useAssetsApiUrl(),x=g.useFetch(),{search:i,page:o=1,limit:s=30}=n;return z.useQuery({queryKey:[g.ACTIONS.GET_ASSETS,i,o,s],queryFn:async()=>{const l=await x(r,{action:g.ACTIONS.GET_ASSETS,data:{search:i,page:o,limit:s}});return l.page=o,l.limit=s,l},staleTime:1/0,retry:1})},Ne=n=>{const r=g.useAssetsApiUrl(),x=g.useFetch();return z.useQuery({queryKey:[g.ACTIONS.GET_ASSET,n],queryFn:async()=>n?await x(r,{action:g.ACTIONS.GET_ASSET,data:{id:n}}):null,staleTime:1/0,retry:1})};function be(n){const r=isNaN(n)?0:typeof n=="number"?n:parseInt(n);return r?r<1024?`${r.toFixed(2)} B`:r<1024*1024?`${(r/1024).toFixed(2)} KB`:`${(r/(1024*1024)).toFixed(2)} MB`:"0 B"}function Z(n){if(!n)return"N/A";const r=new Date(n);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)}function J(n,r){let x=n,i=r==null?void 0:r.description;return(!i||typeof i!="string")&&(i=""),(!x||typeof x!="string")&&(x=""),x!==i}const we=({assetId:n,onBack:r,onEdit:x,onSave:i,isSaving:o})=>{var c,m;const{t:s}=M.useTranslation(),{data:l,isLoading:E,isError:N}=Ne(n||""),[v,j]=u.useState(""),[b,C]=u.useState(!1);u.useEffect(()=>{const d=new Image;return d.src=(l==null?void 0:l.url)||"",d.onload=()=>C(!0),()=>{d.onload=null}},[l]);const A=async(d,p)=>{try{await navigator.clipboard.writeText(d),w.toast.success(s("{{type}} copied to clipboard",{type:p}))}catch(y){w.toast.error(s("Failed to copy {{type}}",{type:p}),{description:y==null?void 0:y.message})}};return u.useEffect(()=>{l!=null&&l.description&&j(l.description)},[l]),E||!b?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(f.Loader,{className:"h-8 w-8 animate-spin"})}):N||!(l!=null&&l.id)?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center max-w-md mx-auto p-6",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(f.AlertCircle,{className:"h-12 w-12 text-gray-400"})}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:s("No Asset Found")}),e.jsx("p",{className:"text-sm text-gray-500 mb-6",children:s(N?"There was an error loading the asset. Please try again later.":"The asset you're looking for doesn't exist or has been removed.")}),e.jsxs("div",{className:"flex justify-center gap-4",children:[e.jsx(a.Button,{variant:"outline",onClick:r,children:s("Back to Assets")}),N&&e.jsx(a.Button,{variant:"default",onClick:()=>window.location.reload(),children:s("Try Again")})]})]})}):e.jsxs("div",{className:"flex-1 flex flex-col gap-y-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(a.Button,{variant:"outline",size:"sm",onClick:r,disabled:o,children:[e.jsx(f.ChevronLeft,{className:"h-4 w-4"}),s("Back to Assets")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(a.Button,{variant:"outline",onClick:r,disabled:o,children:s("Cancel")}),e.jsxs(a.Button,{variant:"outline",onClick:()=>A(l.url,s("Asset URL")),disabled:o,children:[e.jsx(f.Copy,{className:"h-4 w-4 mr-2"}),s("Copy URL")]}),e.jsxs(a.Button,{variant:"default",onClick:()=>x(l),disabled:o,children:[e.jsx(f.Pencil,{className:"h-4 w-4"}),s("Edit Image")]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 items-start gap-6 flex-1 overflow-hidden",children:[e.jsx("div",{className:"relative h-[calc(80vh-200px)] w-full flex items-start justify-center",children:e.jsx("img",{src:l.url,alt:l.name,className:"w-full h-full object-contain rounded-lg max-h-max max-w-max"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-3 border rounded-md pt-2 bg-gray-100",children:[e.jsx(a.Label,{className:"w-full text-center",children:s("Details")}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2 bg-white",children:[{label:s("File Name"),value:l.name},{label:s("Type"),value:l.type,capitalize:!0},{label:s("Format"),value:((c=l.metadata)==null?void 0:c.format)||l.type,capitalize:!0},{label:s("Size"),value:be(l.size)},{label:s("Dimensions"),value:`${l.width||0} × ${l.height||0}`},{label:s("Created"),value:Z(l.createdAt)},{label:s("Updated"),value:Z(((m=l.metadata)==null?void 0:m.updatedAt)||(l==null?void 0:l.updatedAt)||l.createdAt)},{label:s("URL"),value:l.url,copyable:!0}].map(d=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Label,{className:"w-max text-left px-2 w-1/4 font-normal text-gray-700",children:d.label}),":",e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-max text-left font-medium text-gray-900"+(d.capitalize?" capitalize":""),children:d.value}),d.copyable&&e.jsx(a.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>A(d.value,d.label),children:e.jsx(f.Link,{className:"h-3 w-3"})})]})]},d.label))})]}),l.usedOn&&l.usedOn.length>0&&e.jsxs("div",{className:"grid gap-3",children:[e.jsx(a.Label,{children:s("Used On")}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2",children:l.usedOn.map((d,p)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-max text-left font-medium text-gray-900",children:d.name}),e.jsxs("div",{className:"text-gray-500",children:["(",d.slug,")"]})]},p))})]}),e.jsxs("div",{className:"grid gap-3 border rounded-md pt-2 bg-gray-100 relative",children:[e.jsx(a.Label,{className:"w-full text-center",children:s("Description")}),e.jsx(a.Textarea,{id:"description",value:v,placeholder:s("Enter a description for the asset"),onChange:d=>j(d.target.value),rows:3,disabled:o,className:"hover:border-black/40 bg-white"}),e.jsx("div",{className:"flex justify-end items-start absolute top-1.5 right-2",children:e.jsx("button",{type:"button",onClick:()=>i(v),disabled:o||!J(v,l),className:`py-0 bg-blue-500 text-white px-3 py-0.5 rounded-md text-sm ${o||!J(v,l)?"opacity-50 cursor-not-allowed":""}`,children:o?e.jsxs(e.Fragment,{children:[e.jsx(f.Loader,{className:"h-4 w-4 mr-2 animate-spin"}),s("Saving...")]}):s("Save")})})]})]})]})]})},Ce=u.lazy(()=>Promise.resolve().then(()=>require("./image-editor-CnDnY97s.cjs"))),Ae=25*1024*1024,Se=({isUpdatingAsset:n,allowedTypes:r,uploadAssets:x,isUploadingAsset:i,onUploaded:o})=>{const{t:s}=M.useTranslation(),[l,E]=u.useState(()=>{const c=localStorage.getItem("chai_optimize_images");return c!==null?c==="true":!0});u.useEffect(()=>{localStorage.setItem("chai_optimize_images",l.toString())},[l]);const N=n||i,v=u.useCallback(async c=>{try{const m=c;if(!m.every(S=>S.type.startsWith("image/")))return w.toast.error(s("Invalid file type. Please upload a valid file.")),Promise.reject(new Error("Invalid file type"));const d=m.map(async S=>{let U=S;return S.type.startsWith("image/")&&(U=await Y.compressImageIfNeeded(S)),new Promise((_,B)=>{const L=new FileReader;L.readAsDataURL(U),L.onload=async()=>{_({file:L.result,folderId:void 0,name:S.name,optimize:l})},L.onerror=()=>B(null)})}),p=await Promise.all(d),y=await x(p);return(y==null?void 0:y.length)===1&&o(y[0]),y}catch(m){return Promise.reject(m)}},[x,l,o,s]),j=c=>{const m=[];let d=0;return c.forEach(p=>{p.size>Ae?d++:m.push(p)}),d>0&&w.toast.error(`${d===1&&c.length===1?s("File"):d+s(d===1?" file":" files")} ${s("exceed the maximum size limit of 10MB.")}`),F.isEmpty(m)?[]:v(m)},{getRootProps:b,getInputProps:C,isDragActive:A}=fe.useDropzone({onDrop:j,accept:{"image/*":r.includes("image")?[]:[]},disabled:n||i,multiple:!0});return e.jsx("div",{className:`flex h-[60px] w-full flex-col items-center justify-center rounded-lg border-2 border-dashed border-slate-300 p-0 py-2 hover:border-black/50 ${N?"pointer-events-none bg-gray-100 opacity-90":"bg-gray-100 hover:border-black/50 hover:bg-gray-100"}`,children:e.jsxs("div",{...b(),className:M.mergeClasses("flex h-max w-full cursor-pointer flex-col justify-center rounded-lg text-center",N?"items-start":"items-center",A?"border-primary bg-primary/5":"border-muted-foreground/20"),children:[e.jsx("input",{...C()}),N?e.jsx("div",{className:"flex flex-col items-center px-6",children:e.jsxs("div",{className:"flex items-center justify-center gap-2 leading-tight",children:[e.jsx("div",{className:"flex items-center justify-center rounded-full bg-indigo-100 p-2",children:e.jsx(f.Loader,{className:"h-4 w-4 animate-spin text-indigo-500"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:s(n?"Updating file...":"Uploading file...")}),e.jsxs("div",{className:"text-xs font-light text-muted-foreground",children:[s("Please wait while we")," ",s(n?"update":"upload")," ",s("your file...")]})]})]})}):e.jsxs("div",{className:"flex w-full items-center justify-between px-6",children:[e.jsx("div",{className:"flex flex-col items-center",children:e.jsxs("div",{className:"flex items-center justify-between gap-2 leading-tight",children:[e.jsx("div",{className:"flex items-center justify-center rounded-full border border-indigo-500 bg-indigo-100 p-2",children:e.jsx(f.Upload,{className:"h-4 w-4 text-indigo-500"})}),e.jsxs("div",{className:"text-left",children:[e.jsxs("div",{className:"font-medium",children:[s("Drop your file here or")," ",e.jsx("span",{className:"cursor-pointer text-indigo-500 hover:underline",children:s("browse")})]}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:e.jsxs("span",{className:"",children:[s("Accepted file types:")," ",e.jsx("span",{className:"capitalize text-indigo-400",children:r.join(", ")})]})})]})]})}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs",children:[s("Optimization:")," "," ",e.jsx("span",{className:l?"text-indigo-600":"text-gray-400",children:s(l?"On":"Off")})]}),e.jsx(a.Switch,{checked:l,onCheckedChange:c=>{E(c)},onClick:c=>{c.stopPropagation()},className:"data-[state=checked]:bg-indigo-500"})]}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx("span",{className:`flex cursor-help items-center text-amber-500 ${l?"invisible":""}`,children:e.jsx(f.AlertTriangle,{className:"mr-1 h-4 w-4"})})}),e.jsx(a.TooltipContent,{side:"top",children:e.jsx("p",{className:"text-xs text-white",children:s("Warning: Unoptimized images may affect performance and page load times")})})]})})]})]})]})})};function Te({close:n,onSelect:r,mode:x="image",assetId:i}){const{t:o}=M.useTranslation(),s=!1,l=10,E=u.useMemo(()=>[x],[x]),[N,v]=u.useState(null),[j,b]=u.useState(null),[C,A]=u.useState(null),[c,m]=u.useState({show:!1,file:""}),[d,p]=u.useState(!1),[y,S]=u.useState(i?"details":"grid"),[U,_]=u.useState(""),[B,L]=u.useState(""),[P,Q]=u.useState(1),[R]=u.useState(30),[T,G]=u.useState([]);u.useEffect(()=>{i&&(v(i),S("details"))},[i]),u.useEffect(()=>{const t=setTimeout(()=>{_(B),Q(1)},300);return()=>clearTimeout(t)},[B]);const{data:q,isLoading:$,refetch:ee}=ye({search:U.toLowerCase().trim(),page:P,limit:R}),D=(q==null?void 0:q.assets)||[],te=(q==null?void 0:q.total)||0,I=Math.ceil(te/R);u.useEffect(()=>{$||I<=0||Q(t=>t>I?I:t<1?1:t)},[$,I]);const se=(D==null?void 0:D.length)>0,{mutate:ie}=ge(),{mutateAsync:K,isPending:le}=pe(),{mutateAsync:W,isPending:ae}=je(),V=u.useCallback(t=>{const h=Math.min(Math.max(1,t),Math.max(1,I));h!==P&&Q(h)},[I,P]),re=t=>{L(t.target.value)},ne=u.useCallback(t=>{G(h=>F.find(h,{id:t.id})?[]:[t])},[s]),oe=u.useCallback(()=>{G([])},[]),H=t=>{(t==null?void 0:t.length)!==0&&(r(F.pick(F.first(t||T),["id","url","width","height","description"])),n())},ce=async t=>{b(t)},de=async()=>{j&&(A(j==null?void 0:j.id),await ie(j.id,{onSuccess:()=>{A(null),b(null)},onError:()=>{A(null)}}),b(null))},ue=t=>{v(t.id),S("details")},me=async(t,h)=>{try{const O=localStorage.getItem("chai_optimize_images")!=="false";if(h){const k=await K([{file:t,folderId:void 0,name:c.name||"",optimize:O}]);if((k==null?void 0:k.length)>0){const X=k[0];r({...F.pick(X,["id","width","height","description"]),url:X.url})}}else{const k=await W({id:c.id||"",file:t});k&&r({...F.pick(k,["id","width","height","description"]),url:k.url})}m({show:!1,file:""}),n()}catch(O){console.error(o("Error saving edited image:"),O)}},he=u.useCallback(t=>{G([t])},[]),xe=u.useCallback(t=>{V(t)},[V]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-[80vh] max-h-[1232px] w-[80vw] max-w-[1232px] flex-col space-y-4",children:[e.jsx("h1",{className:"text-lg font-medium",children:o("Digital Asset Manager")}),y==="grid"?e.jsxs(e.Fragment,{children:[e.jsx(Se,{maxFileSize:l,allowedTypes:E,uploadAssets:K,isUpdatingAsset:ae,isUploadingAsset:le,onUploaded:he}),e.jsxs("div",{className:"relative flex flex-1 flex-col gap-y-3 overflow-hidden rounded-lg border p-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"relative w-1/2",children:[e.jsx(f.Search,{strokeWidth:3,className:`absolute left-2 top-2.5 h-4 w-4 text-muted-foreground ${B.length>0?"text-indigo-800":""}`}),e.jsx(a.Input,{placeholder:o("Search assets..."),onChange:re,value:B,className:"pl-8"})]}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[T.length>0?e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[T.length>0&&e.jsx(e.Fragment,{children:e.jsx(a.Button,{variant:"outline",size:"sm",onClick:()=>oe(),title:o("Clear selection"),children:o("Clear")})}),e.jsx(a.Button,{size:"sm",onClick:()=>H(T),disabled:T.length===0,children:o("Select Asset")})]})}):null,e.jsx(a.Button,{variant:"ghost",size:"icon",onClick:()=>ee(),children:e.jsx(f.RefreshCwIcon,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto pb-[66px]",children:$?e.jsxs("div",{className:"columns-1 gap-3 space-y-3 sm:columns-3 md:columns-5",children:[e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-64 w-full animate-pulse rounded bg-gray-200"})]}):!$&&!se?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center rounded-lg border",children:[e.jsx("div",{className:"text-muted-foreground",children:e.jsx(f.Archive,{className:"h-9 w-9 text-indigo-500"})}),e.jsx("div",{className:"text-lg text-muted-foreground",children:o("No assets found")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:U.length>0?o("No assets found for your search: {{query}}",{query:U}):o("Start uploading assets to get started")}),e.jsx("br",{})]}):e.jsx("div",{className:"flex flex-wrap gap-3 p-1",children:D==null?void 0:D.map(t=>e.jsxs("div",{className:M.mergeClasses("group relative flex max-h-[180px] max-w-[180px] cursor-pointer flex-col justify-between overflow-hidden rounded-lg border-2 transition-all",T.some(h=>h.id===t.id)?"border-blue-500":"hover:border-black/90",C&&(j==null?void 0:j.id)===t.id?"pointer-events-none opacity-50":"",C===t.id?"pointer-events-none opacity-50":""),onClick:()=>ne(t),onDoubleClick:()=>H([t]),children:[e.jsxs("div",{className:"aspect-square relative overflow-hidden",children:[C===t.id?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:e.jsx(f.Loader,{className:"h-8 w-8 animate-spin text-white"})}):null,t.type==="image"?e.jsx("img",{src:`${t.thumbnailUrl||"/placeholder.svg"}?v=${(t==null?void 0:t.updatedAt)||t.createdAt}`,alt:t.name,className:`h-full min-h-[80px] w-full object-contain ${T.some(h=>h.id===t.id)?"":"group-hover:blur group-hover:contrast-50"}`}):e.jsxs("div",{className:"flex h-full items-center justify-center",children:[e.jsx(f.Film,{className:"h-12 w-12 text-muted-foreground"}),t.thumbnailUrl&&e.jsx("img",{src:`${t.thumbnailUrl||"/placeholder.svg"}?v=${(t==null?void 0:t.updatedAt)||t.createdAt}`,alt:t.name,className:"absolute inset-0 h-full w-full object-cover"})]})]}),e.jsxs("div",{className:"flex items-end justify-between border-t-[1px] border-black/10 bg-white px-2 py-1",children:[e.jsx("div",{className:"truncate text-xs leading-tight",title:t.name,children:t.name}),e.jsx("div",{className:"flex items-center justify-between whitespace-nowrap text-[9px] font-light text-muted-foreground",children:e.jsx("span",{children:Y.formatFileSize((t==null?void 0:t.size)||0)})})]}),!T.some(h=>h.id===t.id)&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 transition-opacity group-hover:opacity-100",children:e.jsxs("div",{className:"grid grid-cols-4 gap-2 p-2",children:[e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),ue(t)},children:e.jsx(f.ImageIcon,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("View Details")})})]})}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),navigator.clipboard.writeText(t.url),w.toast.success(o("Asset URL copied to clipboard"))},children:e.jsx(f.Copy,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("Copy URL")})})]})}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),m({id:t.id,show:!0,file:t.url,name:t.name})},children:e.jsx(f.Edit,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("Edit Image")})})]})}),e.jsx(a.TooltipProvider,{children:e.jsxs(a.Tooltip,{children:[e.jsx(a.TooltipTrigger,{asChild:!0,children:e.jsx(a.Button,{variant:"destructive",size:"icon",className:"h-8 w-8 rounded-full",onClick:h=>{h.stopPropagation(),ce(t)},children:e.jsx(f.Trash2,{className:"h-4 w-4"})})}),e.jsx(a.TooltipContent,{children:e.jsx("p",{children:o("Delete Asset")})})]})})]})}),T.some(h=>h.id===t.id)&&e.jsx("div",{className:"absolute right-1 top-1 h-max rounded-full border border-white bg-blue-500 p-1",children:e.jsx(f.Check,{className:"h-3 w-3 text-white",strokeWidth:5})})]},t.id))})}),I>1&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 border-t bg-white p-4",children:e.jsx(g.ErrorBoundary,{fallback:e.jsx("div",{className:"text-red-500",children:o("Error loading pagination")}),children:e.jsx(ve,{currentPage:P,totalPages:I,onPageChange:xe,pageRangeDisplayed:3,showPageInput:!0})})})]})]}):e.jsx(we,{assetId:N||i||"",onBack:()=>{S("grid"),v(null)},onEdit:t=>{m({id:t.id,show:!0,file:t.url,name:t.name})},onSave:async t=>{if(N){p(!0);try{const h=D.find(O=>O.id===N);h&&await W(F.merge(h,{description:t}))}finally{p(!1)}}},isSaving:d})]}),c.show&&e.jsx(u.Suspense,{fallback:e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(f.Loader,{className:"h-8 w-8 animate-spin"})}),children:e.jsx(Ce,{imageUrl:c.file,onSave:me,onClose:()=>m({show:!1,file:""}),defaultSavedImageName:c.name,isEditing:!!c.id})}),j&&e.jsx(a.Dialog,{open:!!j,onOpenChange:()=>b(null),children:e.jsxs(a.DialogContent,{children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:o("Delete Asset")}),e.jsx(a.DialogDescription,{children:o('Are you sure you want to delete "{{name}}"? This action cannot be undone.',{name:j.name})})]}),e.jsxs(a.DialogFooter,{className:"gap-2 sm:gap-0",children:[e.jsx(a.Button,{variant:"outline",onClick:()=>b(null),children:o("Cancel")}),e.jsx(a.Button,{variant:"destructive",onClick:de,children:o("Delete")})]})]})})]})}exports.default=Te;
@@ -5,7 +5,7 @@ import { find as Ge, merge as Oe, pick as Y, first as Be, isEmpty as Ke } from "
5
5
  import { ChevronLeft as he, ChevronRight as Qe, Loader as B, AlertCircle as Re, Copy as fe, Pencil as We, Link as Ve, Search as He, RefreshCwIcon as Xe, Archive as Ze, Film as Je, ImageIcon as Ye, Edit as et, Trash2 as tt, Check as it, Upload as lt, AlertTriangle as at } from "lucide-react";
6
6
  import pe, { useState as y, useMemo as ge, useEffect as O, useCallback as M, Suspense as rt } from "react";
7
7
  import { useDropzone as nt } from "react-dropzone";
8
- import { aL as K, al as Q, A as b, aM as st } from "./index-DHfaX2M6.js";
8
+ import { aL as K, al as Q, A as b, aM as st } from "./index-NSqs69Op.js";
9
9
  import { toast as A } from "sonner";
10
10
  import { f as ct, c as ot } from "./image-compression-DsZ1oqpb.js";
11
11
  import { useQueryClient as te, useMutation as ie, useQuery as xe } from "@tanstack/react-query";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./index-DOlBrCPx.cjs"),N=require("@tanstack/react-query"),v=require("sonner"),E=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),P=require("lodash-es"),C=require("lucide-react"),g=require("react"),A=require("./slug-input-BeepGXWz.cjs"),T=()=>{const t=p.useApiUrl(),u=N.useQueryClient(),h=p.useFetch();return N.useMutation({mutationFn:async({pageId:s,name:x,slug:r})=>{const o={pageId:s,name:x};return r&&(o.slug=r),await h(t,{action:"DUPLICATE_PAGE",data:o})},onSuccess:()=>{u.invalidateQueries({queryKey:[p.ACTIONS.GET_WEBSITE_PAGES]}),v.toast.success("Page duplicated successfully")},onError:s=>{v.toast.error("Failed to duplicate page",{description:s.message||"An error occurred while duplicating the page"})}})},w=({page:t,onClose:u,closePanel:h=()=>{}})=>{const{t:s}=E.useTranslation(),{mutate:x,isPending:r}=T(),[o,i]=g.useState(null),[d,D]=g.useState(`${t.name} (Copy)`),b=p.useChangePage(),n=P.isEmpty(t.slug),[m,I]=g.useState(n?"":`${t.slug.split("/").pop()}-copy`),f=n?"":P.initial(t.slug.split("/")).join("/"),[y,j]=g.useState(!1),q=l=>{if(l.preventDefault(),!d.trim()){i(s("Name is required"));return}if(!n&&!m.trim()){i(s("Slug is required"));return}i(null),j(!0);const S={pageId:t.id,name:d};n||(S.slug=`${f}/${m}`),x(S,{onSuccess:c=>{j(!1),u(),b(c.id,h)},onError:c=>{j(!1),c.code==="SLUG_EXISTS"?i(s("A page with this slug already exists. Please choose a different slug.")):c.code==="INVALID_SLUG"?i(s("The slug format is invalid. Please use only lowercase letters, numbers, and hyphens.")):c.code==="PERMISSION_DENIED"?i(s("You don't have permission to duplicate this page.")):i(c.message||s("Failed to duplicate page. Please try again later."))}})};return e.jsx(a.Dialog,{open:!!t,onOpenChange:u,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:s("Duplicate Page")}),e.jsx(a.DialogDescription,{children:s("Create a copy of the page with a new name and slug")})]}),e.jsxs("div",{className:"mb-4 rounded-md bg-gray-50 p-3",children:[e.jsxs("h3",{className:"mb-1 text-sm font-medium",children:[s("Duplicating:"),":"]}),e.jsxs("div",{className:"flex flex-col gap-1 text-sm text-gray-700",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[s("Name"),":"]})," ",t.name]}),!n&&e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[s("Slug"),":"]})," ",t.slug]}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[s("Type"),":"]})," ",t.pageType]})]})]}),e.jsxs("form",{onSubmit:q,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:s("Name")}),e.jsx(a.Input,{id:"name",value:d,onChange:l=>D(l.target.value),required:!0})]}),!n&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"slug",className:"text-sm",children:s("Slug")}),e.jsx(A.SlugInput,{value:m,onChange:l=>I(l),parentSlug:f,onValidationChange:l=>{i(l?null:s("Invalid slug"))}})]}),o&&e.jsxs(a.Alert,{variant:"destructive",className:"py-2",children:[e.jsx(C.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:o})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(a.Button,{type:"button",variant:"outline",onClick:u,disabled:r,children:s("Cancel")}),e.jsx(a.Button,{type:"submit",disabled:!d.trim()||!n&&!m.trim()||r||y,children:s(r||y?"Duplicating...":"Duplicate")})]})]})]})})};exports.default=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./index-LfuCMBwI.cjs"),N=require("@tanstack/react-query"),v=require("sonner"),E=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),P=require("lodash-es"),C=require("lucide-react"),g=require("react"),A=require("./slug-input-BYH90lv1.cjs"),T=()=>{const t=p.useApiUrl(),u=N.useQueryClient(),h=p.useFetch();return N.useMutation({mutationFn:async({pageId:s,name:x,slug:r})=>{const o={pageId:s,name:x};return r&&(o.slug=r),await h(t,{action:"DUPLICATE_PAGE",data:o})},onSuccess:()=>{u.invalidateQueries({queryKey:[p.ACTIONS.GET_WEBSITE_PAGES]}),v.toast.success("Page duplicated successfully")},onError:s=>{v.toast.error("Failed to duplicate page",{description:s.message||"An error occurred while duplicating the page"})}})},w=({page:t,onClose:u,closePanel:h=()=>{}})=>{const{t:s}=E.useTranslation(),{mutate:x,isPending:r}=T(),[o,i]=g.useState(null),[d,D]=g.useState(`${t.name} (Copy)`),b=p.useChangePage(),n=P.isEmpty(t.slug),[m,I]=g.useState(n?"":`${t.slug.split("/").pop()}-copy`),f=n?"":P.initial(t.slug.split("/")).join("/"),[y,j]=g.useState(!1),q=l=>{if(l.preventDefault(),!d.trim()){i(s("Name is required"));return}if(!n&&!m.trim()){i(s("Slug is required"));return}i(null),j(!0);const S={pageId:t.id,name:d};n||(S.slug=`${f}/${m}`),x(S,{onSuccess:c=>{j(!1),u(),b(c.id,h)},onError:c=>{j(!1),c.code==="SLUG_EXISTS"?i(s("A page with this slug already exists. Please choose a different slug.")):c.code==="INVALID_SLUG"?i(s("The slug format is invalid. Please use only lowercase letters, numbers, and hyphens.")):c.code==="PERMISSION_DENIED"?i(s("You don't have permission to duplicate this page.")):i(c.message||s("Failed to duplicate page. Please try again later."))}})};return e.jsx(a.Dialog,{open:!!t,onOpenChange:u,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:s("Duplicate Page")}),e.jsx(a.DialogDescription,{children:s("Create a copy of the page with a new name and slug")})]}),e.jsxs("div",{className:"mb-4 rounded-md bg-gray-50 p-3",children:[e.jsxs("h3",{className:"mb-1 text-sm font-medium",children:[s("Duplicating:"),":"]}),e.jsxs("div",{className:"flex flex-col gap-1 text-sm text-gray-700",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[s("Name"),":"]})," ",t.name]}),!n&&e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[s("Slug"),":"]})," ",t.slug]}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[s("Type"),":"]})," ",t.pageType]})]})]}),e.jsxs("form",{onSubmit:q,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:s("Name")}),e.jsx(a.Input,{id:"name",value:d,onChange:l=>D(l.target.value),required:!0})]}),!n&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"slug",className:"text-sm",children:s("Slug")}),e.jsx(A.SlugInput,{value:m,onChange:l=>I(l),parentSlug:f,onValidationChange:l=>{i(l?null:s("Invalid slug"))}})]}),o&&e.jsxs(a.Alert,{variant:"destructive",className:"py-2",children:[e.jsx(C.AlertCircle,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:o})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(a.Button,{type:"button",variant:"outline",onClick:u,disabled:r,children:s("Cancel")}),e.jsx(a.Button,{type:"submit",disabled:!d.trim()||!n&&!m.trim()||r||y,children:s(r||y?"Duplicating...":"Duplicate")})]})]})]})})};exports.default=w;
@@ -1,5 +1,5 @@
1
1
  import { jsx as t, jsxs as a } from "react/jsx-runtime";
2
- import { ak as C, al as A, A as T, am as w } from "./index-DHfaX2M6.js";
2
+ import { ak as C, al as A, A as T, am as w } from "./index-NSqs69Op.js";
3
3
  import { useQueryClient as F, useMutation as _ } from "@tanstack/react-query";
4
4
  import { toast as v } from "sonner";
5
5
  import { useTranslation as q } from "@chaibuilder/sdk";
@@ -7,7 +7,7 @@ import { Dialog as G, DialogContent as L, DialogHeader as U, DialogTitle as j, D
7
7
  import { isEmpty as B, initial as M } from "lodash-es";
8
8
  import { AlertCircle as Q } from "lucide-react";
9
9
  import { useState as p } from "react";
10
- import { S as V } from "./slug-input-CKIckRno.js";
10
+ import { S as V } from "./slug-input-CvIDihGn.js";
11
11
  const H = () => {
12
12
  const s = C(), o = F(), g = A();
13
13
  return _({
@@ -4,7 +4,7 @@ import { DropdownMenu as h, DropdownMenuTrigger as p, Button as m, DropdownMenuC
4
4
  import { get as v } from "lodash-es";
5
5
  import { ChevronDown as w } from "lucide-react";
6
6
  import { useRef as b, useEffect as N } from "react";
7
- import { k as y } from "./index-DHfaX2M6.js";
7
+ import { k as y } from "./index-NSqs69Op.js";
8
8
  const D = ({
9
9
  isDefaultLang: e,
10
10
  searchQuery: l,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),h=require("lodash-es"),p=require("lucide-react"),d=require("react"),g=require("./index-DOlBrCPx.cjs"),f=({isDefaultLang:r,searchQuery:l,setSearchQuery:c})=>e.jsx(a.Input,{type:"text",autoFocus:!0,value:r?l:"",onChange:t=>c(t.target.value),placeholder:r?"Search pages...":"To search select default language",disabled:!r,onKeyDown:t=>t.stopPropagation()}),m=({dynamicPage:r,setDynamicPage:l,searchQuery:c,setSearchQuery:t,dynamicPages:n})=>{const{selectedLang:o,fallbackLang:i}=x.useLanguages(),u=(o==null?void 0:o.length)===0;return e.jsxs(a.DropdownMenu,{children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"ghost",className:"w-max focus:outline-none focus:ring-0 border-[0px] rounded-md py-1 text-sm h-max border border-gray-200 hover:bg-gray-100 pl-4",children:[r?h.get(r,"name"):"Select Page",e.jsx(p.ChevronDown,{className:"ml-2 h-4 w-4"})]})}),e.jsxs(a.DropdownMenuContent,{className:"w-96 divide-y shadow-xl p-0 max-h-[75vh]",children:[e.jsx("div",{className:"p-1.5 bg-gray-50/30",children:e.jsx(f,{isDefaultLang:u,searchQuery:c,setSearchQuery:t})}),(n==null?void 0:n.length)===0?e.jsx("div",{className:"h-24 text-xs flex items-center justify-center",children:"No pages found"}):n==null?void 0:n.map(s=>e.jsx(a.DropdownMenuItem,{onClick:()=>l(s),disabled:u?i!==s.lang:o!==s.lang,className:`flex flex-col justify-start cursor-pointer overflow-x-auto whitespace-nowrap no-scrollbar ${s.id===(r==null?void 0:r.id)?"bg-blue-50":"hover:bg-gray-50"}`,children:e.jsx("div",{className:"w-full text-xs whitespace-nowrap px-2 py-[2px]",children:e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx("span",{className:"font-medium",children:s.name}),e.jsx("span",{className:"font-mono font-medium text-gray-500 text-xs rounded-full px-2 py-[1px] border border-gray-300 truncate",children:s.slug})]})})},s.id))]})]})},j=()=>{const{dynamicPage:r,dynamicPages:l,allLangPages:c,selectedLang:t,searchQuery:n,updateDynamicPage:o,updateSearchQuery:i,onChangeLanguage:u}=g.useDynamicPageSelector(),s=d.useRef(void 0);return d.useEffect(()=>{s.current!==t&&r&&(u(),s.current=t)},[t,l]),e.jsx("div",{className:"relative",children:e.jsx(m,{dynamicPage:r,setDynamicPage:o,searchQuery:n,setSearchQuery:i,dynamicPages:c})})};exports.default=j;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),h=require("lodash-es"),p=require("lucide-react"),d=require("react"),g=require("./index-LfuCMBwI.cjs"),f=({isDefaultLang:r,searchQuery:l,setSearchQuery:c})=>e.jsx(a.Input,{type:"text",autoFocus:!0,value:r?l:"",onChange:t=>c(t.target.value),placeholder:r?"Search pages...":"To search select default language",disabled:!r,onKeyDown:t=>t.stopPropagation()}),m=({dynamicPage:r,setDynamicPage:l,searchQuery:c,setSearchQuery:t,dynamicPages:n})=>{const{selectedLang:o,fallbackLang:i}=x.useLanguages(),u=(o==null?void 0:o.length)===0;return e.jsxs(a.DropdownMenu,{children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"ghost",className:"w-max focus:outline-none focus:ring-0 border-[0px] rounded-md py-1 text-sm h-max border border-gray-200 hover:bg-gray-100 pl-4",children:[r?h.get(r,"name"):"Select Page",e.jsx(p.ChevronDown,{className:"ml-2 h-4 w-4"})]})}),e.jsxs(a.DropdownMenuContent,{className:"w-96 divide-y shadow-xl p-0 max-h-[75vh]",children:[e.jsx("div",{className:"p-1.5 bg-gray-50/30",children:e.jsx(f,{isDefaultLang:u,searchQuery:c,setSearchQuery:t})}),(n==null?void 0:n.length)===0?e.jsx("div",{className:"h-24 text-xs flex items-center justify-center",children:"No pages found"}):n==null?void 0:n.map(s=>e.jsx(a.DropdownMenuItem,{onClick:()=>l(s),disabled:u?i!==s.lang:o!==s.lang,className:`flex flex-col justify-start cursor-pointer overflow-x-auto whitespace-nowrap no-scrollbar ${s.id===(r==null?void 0:r.id)?"bg-blue-50":"hover:bg-gray-50"}`,children:e.jsx("div",{className:"w-full text-xs whitespace-nowrap px-2 py-[2px]",children:e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx("span",{className:"font-medium",children:s.name}),e.jsx("span",{className:"font-mono font-medium text-gray-500 text-xs rounded-full px-2 py-[1px] border border-gray-300 truncate",children:s.slug})]})})},s.id))]})]})},j=()=>{const{dynamicPage:r,dynamicPages:l,allLangPages:c,selectedLang:t,searchQuery:n,updateDynamicPage:o,updateSearchQuery:i,onChangeLanguage:u}=g.useDynamicPageSelector(),s=d.useRef(void 0);return d.useEffect(()=>{s.current!==t&&r&&(u(),s.current=t)},[t,l]),e.jsx("div",{className:"relative",children:e.jsx(m,{dynamicPage:r,setDynamicPage:o,searchQuery:n,setSearchQuery:i,dynamicPages:c})})};exports.default=j;
@@ -0,0 +1,5 @@
1
+ "use strict";var Wn=Object.defineProperty;var ms=e=>{throw TypeError(e)};var Yn=(e,t,s)=>t in e?Wn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var he=(e,t,s)=>Yn(e,typeof t!="symbol"?t+"":t,s),Es=(e,t,s)=>t.has(e)||ms("Cannot "+s);var v=(e,t,s)=>(Es(e,t,"read from private field"),s?s.call(e):t.get(e)),M=(e,t,s)=>t.has(e)?ms("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),G=(e,t,s,n)=>(Es(e,t,"write to private field"),n?n.call(e,s):t.set(e,s),s);const o=require("react/jsx-runtime"),p=require("lodash-es"),h=require("react"),Q=require("jotai"),P=require("@tanstack/react-query"),_=require("@chaibuilder/sdk"),F=require("sonner"),m=require("@chaibuilder/sdk/ui"),w=require("lucide-react"),Ls=require("@chaibuilder/runtime"),Jn=require("@chaibuilder/sdk/web-blocks");function Xn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const z=Xn(h),y={GET_GLOBAL_JSONLD_ITEMS:"GET_GLOBAL_JSONLD_ITEMS",GENERATE_SEO_FIELD:"GENERATE_SEO_FIELD",UPDATE_PAGE_METADATA:"UPDATE_PAGE_METADATA",GET_BLOCK_ASYNC_PROPS:"GET_BLOCK_ASYNC_PROPS",ASK_AI:"ASK_AI",GET_DRAFT_PAGE:"GET_DRAFT_PAGE",CREATE_PAGE:"CREATE_PAGE",UPDATE_PAGE:"UPDATE_PAGE",DELETE_PAGE:"DELETE_PAGE",DUPLICATE_PAGE:"DUPLICATE_PAGE",CHANGE_SLUG:"CHANGE_SLUG",TAKE_OFFLINE:"TAKE_OFFLINE",PUBLISH_PAGE:"PUBLISH_PAGE",PUBLISH_CHANGES:"PUBLISH_CHANGES",ADD_NEW_LANGUAGE:"ADD_NEW_LANGUAGE",EDIT_LANGUAGE:"EDIT_LANGUAGE",DELETE_LANGUAGE:"DELETE_LANGUAGE",GET_CHANGES:"GET_CHANGES",GET_SERVER_BLOCK:"GET_SERVER_BLOCK",GET_LANGUAGE_PAGES:"GET_LANGUAGE_PAGES",GET_PROJECT_PAGES:"GET_PROJECT_PAGES",GET_WEBSITE_PAGES:"GET_WEBSITE_PAGES",UPDATE_WEBSITE_SETTINGS:"UPDATE_WEBSITE_SETTINGS",GET_COLLECTIONS:"GET_COLLECTIONS",GET_PAGE_TYPES:"GET_PAGE_TYPES",SEARCH_PAGES:"SEARCH_PAGES",GET_WEBSITE_DRAFT_SETTINGS:"GET_WEBSITE_DRAFT_SETTINGS",AI_CONTEXT:"AI_CONTEXT",GET_WEBSITE_DATA:"GET_WEBSITE_DATA",UPDATE_WEBSITE_DATA:"UPDATE_WEBSITE_DATA",GET_CHAI_USER:"GET_CHAI_USER",GET_SEO_FIELDS:"GET_SEO_FIELDS",GET_BUILDER_PAGE_DATA:"GET_BUILDER_PAGE_DATA",GET_PAGE_REVISIONS:"GET_PAGE_REVISIONS",DELETE_PAGE_REVISION:"DELETE_PAGE_REVISION",RESTORE_PAGE_REVISION:"RESTORE_PAGE_REVISION",GET_REVISION_DATA:"GET_REVISION_DATA",GET_PAGE_DATA:"GET_PAGE_DATA",GET_COMPARE_DATA:"GET_COMPARE_DATA",GET_ROLE_AND_PERMISSIONS:"GET_ROLE_AND_PERMISSIONS",UPSERT_LIBRARY_ITEM:"UPSERT_LIBRARY_ITEM",GET_LIBRARIES:"GET_LIBRARIES",GET_LIBRARY_ITEM:"GET_LIBRARY_ITEM",GET_LIBRARY_ITEMS:"GET_LIBRARY_ITEMS",DELETE_LIBRARY_ITEM:"DELETE_LIBRARY_ITEM",MARK_AS_TEMPLATE:"MARK_AS_TEMPLATE",UNMARK_AS_TEMPLATE:"UNMARK_AS_TEMPLATE",GET_TEMPLATES_BY_TYPE:"GET_TEMPLATES_BY_TYPE",GET_DYNAMIC_PAGES:"GET_DYNAMIC_PAGES",GET_APP_SHARED_JSONLD:"GET_APP_SHARED_JSONLD",UPDATE_APP_SHARED_JSONLD:"UPDATE_APP_SHARED_JSONLD",ADD_GLOBAL_SCHEMA:"ADD_GLOBAL_SCHEMA",UPDATE_GLOBAL_SCHEMA:"UPDATE_GLOBAL_SCHEMA",DELETE_GLOBAL_SCHEMA:"DELETE_GLOBAL_SCHEMA",TOGGLE_PAGE_GLOBAL_SCHEMA:"TOGGLE_PAGE_GLOBAL_SCHEMA",APPLY_SCHEMA_TO_ALL_PAGES:"APPLY_SCHEMA_TO_ALL_PAGES",REMOVE_SCHEMA_FROM_ALL_PAGES:"REMOVE_SCHEMA_FROM_ALL_PAGES",UPLOAD_ASSET:"UPLOAD_ASSET",DELETE_ASSET:"DELETE_ASSET",UPDATE_ASSET:"UPDATE_ASSET",GET_ASSETS:"GET_ASSETS",GET_ASSET:"GET_ASSET"},Zn=Q.atom({}),jt=()=>Q.useAtom(Zn),se=(e,t)=>{const[s]=jt();return h.useMemo(()=>p.get(s,e,t),[s,e,t])},k=()=>se("apiUrl","/chai/api"),js=()=>se("usersApiUrl","/chai/users"),er=()=>se("assetsApiUrl","/chai/assets"),tr=()=>se("websocket",null),sr=async(e,t,s={})=>await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)}),nr=()=>{const e=j(),t=k();return h.useCallback(async({body:s,headers:n={},url:r=t})=>e(r,s,n),[e])},j=()=>{const e=se("onLogout"),t=se("getAccessToken"),s=k();return h.useCallback(async(n=s,r,a={})=>{const i=await t();if(!i)return console.error("No auth token found"),null;try{const l=p.get(r,"action","").toLowerCase(),c=await sr(n+(l?`?action=${l}`:""),r,{...a,Authorization:`Bearer ${i}`});if(c.status===401)return console.log("401 Response",c),e(),window.location.reload(),null;if(!c.ok){const u=await c.json();throw console.error(`API Error (${c.status}):`,u),{status:c.status,statusText:c.statusText,...u,message:u.error||u.message||`Server error: ${c.status}`}}return await c.json()}catch(l){throw console.error("API request failed:",r,l),l}},[e,t])};function ee(){const[e,t]=h.useState(new URLSearchParams(window.location.search));return h.useEffect(()=>{const s=()=>{t(new URLSearchParams(window.location.search))};return window.addEventListener("popstate",s),()=>{window.removeEventListener("popstate",s)}},[]),[e,t]}const pe=e=>{const t=k(),[s]=ee(),n=e??s.get("page"),r=j();return P.useQuery({queryKey:[y.GET_LANGUAGE_PAGES,n],staleTime:1/0,gcTime:0,placeholderData:[],queryFn:async()=>{if(!n)return null;const a=await r(t,{action:y.GET_LANGUAGE_PAGES,data:{id:n}});return p.reverse(p.sortBy(a,"primaryPage"))},enabled:!!n})},ye=()=>{const e=k(),t=j();return P.useQuery({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS],staleTime:5*60*1e3,placeholderData:{languages:[],theme:{fontFamily:"",borderRadius:"",colors:{}},appKey:"",fallbackLang:""},queryFn:async()=>t(e,{action:y.GET_WEBSITE_DRAFT_SETTINGS,data:{draft:!0}})})},ts=e=>{const{fallbackLang:t}=_.useLanguages(),{data:s}=ye(),{data:n,isFetching:r}=pe(),a=h.useMemo(()=>{const i={[t]:!0};return p.each(p.get(s,"languages"),l=>{const c=p.find(n,{lang:l});i[l]=!!c}),i},[t,n,s]);return r||p.isEmpty(e)||e&&a[e]};class ks{constructor(t,s,n,r){he(this,"channelId");he(this,"websocket");he(this,"channel",null);he(this,"userId",null);he(this,"clientId",null);he(this,"pageId",null);he(this,"callback");var a,i,l,c,u,f;this.userId=n,this.websocket=t,this.clientId=this.getClientId(),this.channelId=`WEBSITE:${s}`,this.callback=r,this.channel=this.websocket.channel(this.channelId,{config:{presence:{key:this.clientId}}}),(f=(u=(c=(l=(i=(a=this.channel)==null?void 0:a.on("presence",{event:"sync"},d=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",d)}))==null?void 0:i.on("presence",{event:"leave"},d=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",d)}))==null?void 0:l.on("presence",{event:"join"},d=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",d)}))==null?void 0:c.on("broadcast",{event:"TAKE_OVER_REQUESTED"},({payload:d})=>this.onReceiveEvent("TAKE_OVER_REQUESTED",d)))==null?void 0:u.on("broadcast",{event:"TAKE_OVER_REQUEST_ACCEPTED"},({payload:d})=>this.onReceiveEvent("TAKE_OVER_REQUEST_ACCEPTED",d)))==null||f.on("broadcast",{event:"TAKE_OVER_REQUEST_REJECTED"},({payload:d})=>this.onReceiveEvent("TAKE_OVER_REQUEST_REJECTED",d)).subscribe()}getClientId(){return crypto.randomUUID()}getOnlineUsers({pageId:t,userId:s}){var a;const n=(a=this.channel)==null?void 0:a.presenceState();let r=Object.values(n||{}).map(i=>i[0]).filter(Boolean);return t?r=r.filter(i=>i.pageId===t):s&&(r=r.filter(i=>i.userId===s)),r.sort((i,l)=>i.onlineAt-l.onlineAt)}getPageOwner(){const t=this.getOnlineUsers({pageId:this.pageId});return t.length>0?t[0]:null}getPageUserMapping(){const t=this.getOnlineUsers({}),s=p.groupBy(t,"pageId"),n={};return Object.keys(s).forEach(r=>{var i;const a=(i=p.minBy(s[r],"onlineAt"))==null?void 0:i.userId;a!==this.userId&&(n[r]=a)}),n}onReceiveEvent(t,s){if(!this.pageId)return;const n=this.getPageOwner();if(!n||n.clientId===this.clientId?this.callback("USER_JOINED",{isActiveInOtherTab:!1}):this.callback("PAGE_LOCKED",{isActiveInOtherTab:(n==null?void 0:n.userId)===this.userId&&(n==null?void 0:n.clientId)!==this.clientId}),s.targetClientId===this.clientId)switch(t){case"TAKE_OVER_REQUESTED":this.callback("TAKE_OVER_REQUESTED",{requestedBy:s==null?void 0:s.userId,requestingClientId:s==null?void 0:s.senderClientId,isRequestedFromAnotherTab:(s==null?void 0:s.senderClientId)!==this.clientId&&(s==null?void 0:s.userId)===this.userId});break;case"TAKE_OVER_REQUEST_ACCEPTED":this.channel.track({pageId:this.pageId,userId:this.userId,clientId:this.clientId,onlineAt:n?n.onlineAt-10:+new Date}),this.callback("TAKE_OVER_REQUEST_ACCEPTED",{isTakingOverFromAnotherTab:(s==null?void 0:s.senderClientId)!==this.clientId&&(s==null?void 0:s.userId)===this.userId});break;case"TAKE_OVER_REQUEST_REJECTED":this.callback("TAKE_OVER_REQUEST_REJECTED");break}}async joinPage(t){var s;this.pageId=t,(s=this.channel)==null||s.track({pageId:this.pageId,userId:this.userId,clientId:this.clientId,onlineAt:+new Date})}async leavePage(){var t;this.channel&&((t=this.channel)==null||t.untrack())}async sendEvent(t,s){var n,r;if(this.channel){const a={pageId:this.pageId,userId:this.userId,senderClientId:this.clientId};t==="TAKE_OVER_REQUESTED"?a.targetClientId=(n=this.getPageOwner())==null?void 0:n.clientId:(t==="TAKE_OVER_REQUEST_ACCEPTED"||t==="TAKE_OVER_REQUEST_REJECTED")&&(a.targetClientId=s==null?void 0:s.requestingClientId),await((r=this.channel)==null?void 0:r.send({event:t,payload:a,type:"broadcast"}))}}}const rr=Q.atom(null),Ds=()=>Q.useAtom(rr),ss=()=>{const[e]=Ds();return(e==null?void 0:e.slug)||""};function ar(e,t){const[s,n]=h.useState(e);return h.useEffect(()=>{const r=setTimeout(()=>n(e),t);return()=>clearTimeout(r)},[e,t]),s}const ir=({query:e,uuid:t})=>{const{selectedLang:s,fallbackLang:n}=_.useLanguages(),{data:r}=X(),a=r==null?void 0:r.pageType,i=k(),l=j(),{data:c,isFetching:u}=P.useQuery({queryKey:[y.GET_DYNAMIC_PAGES,e,a,t],staleTime:60*60*1e3,placeholderData:[],queryFn:async()=>await l(i,{action:y.GET_DYNAMIC_PAGES,data:{query:e,pageType:a,uuid:t}})||[],enabled:!!a}),f=h.useMemo(()=>s===""?c.filter(d=>d.lang===""||d.lang===n):c.filter(d=>d.lang===s),[s,n,c]);return{allLangPages:c,data:f,isFetching:u}},Os=()=>{const{selectedLang:e,fallbackLang:t}=_.useLanguages(),[s,n]=Ds(),[r,a]=h.useState(""),i=ar(r,500),{allLangPages:l,data:c,isFetching:u}=ir({query:i}),f=h.useCallback(E=>n(E),[n]),d=h.useCallback(E=>a(E),[a]),g=h.useCallback(()=>{if(!s)return;const E=!(s!=null&&s.primaryPage),S=e.length===0,x=E?s==null?void 0:s.id:s==null?void 0:s.primaryPage,T=l.filter(C=>(C==null?void 0:C.primaryPage)===x||C.id===x).find(C=>S?C.lang===e||C.lang===t:C.lang===e);n(T||s)},[s,e,l,n,t]);return{isFetching:u,dynamicPage:s,searchQuery:r,selectedLang:e,dynamicPages:c,allLangPages:l,updateDynamicPage:f,updateSearchQuery:d,onChangeLanguage:g}},or=Q.atom({lastSaved:void 0}),kt=()=>Q.useAtom(or),X=()=>{const[e]=ee(),t=e.get("page"),{data:s,isFetching:n}=pe();return{data:h.useMemo(()=>({...p.find(s,{id:t})||{}}),[s,t]),isFetching:n}},ue=()=>{const[e]=ee(),t=e.get("lang")??"",{data:s,isFetching:n}=pe();return{data:h.useMemo(()=>p.find(s,{lang:t})||{},[s,t]),isFetching:n}},lr=Q.atom({}),cr=()=>Q.useAtom(lr),ur=()=>{const{data:e}=ue(),t=ss(),s=se("getLiveUrl",p.noop),n=e==null?void 0:e.slug,r=s(n||"/");return t?r+t:r},gt=()=>{const e=se("currentUser"),t=se("onLogout");return{isLoggedIn:!!e,user:e,logout:t}},Gs=e=>{const t=js(),s=j();return P.useQuery({queryKey:[y.GET_CHAI_USER,e],queryFn:async()=>{const r=await s(t,{action:y.GET_CHAI_USER,data:{userId:e}});return{...r,name:r.name||r.email}},enabled:!p.isEmpty(e),staleTime:"static"})},dr=Q.atom({status:"checking",requestedBy:"",isTakeOverRequested:!1,requestingClientId:"",isActiveInOtherTab:!1}),fr=Q.atom(""),hr=Q.atom(null),ns=Q.atom({}),gr=()=>Q.useAtom(ns),Ae=()=>{const[e]=ee(),t=e.get("page"),[s,n]=Q.useAtom(dr),[r,a]=Q.useAtom(hr),[i,l]=Q.useAtom(fr),[c]=Q.useAtom(ns);return{pageLock:s,pageToUser:c,lockingStatus:i,realtimeInstance:r,setPageLock:n,setLockingStatus:l,setRealtimeInstance:a,realtimePageLockEnabled:!!r,currentEditor:c[t||""],isLocked:t&&s.status==="locked"}},mr=()=>{const e=tr(),{data:t}=X(),{user:s}=gt(),n=t==null?void 0:t.id,{data:r}=ye(),{pageLock:a,setPageLock:i,setLockingStatus:l,realtimeInstance:c,setRealtimeInstance:u}=Ae(),[,f]=Q.useAtom(ns),d=h.useRef(!1),g=h.useRef(a),E=h.useRef(!1);return h.useEffect(()=>{if(s!=null&&s.id&&e&&!c&&(r!=null&&r.appKey)&&!E.current){E.current=!0;const S=async(A,T)=>{var C,N;switch(A){case"UPDATE_ONLINE_USERS":f((T==null?void 0:T.pageToUser)||{});break;case"PAGE_LOCKED":i({...g==null?void 0:g.current,requestedBy:"",status:"locked",isActiveInOtherTab:T==null?void 0:T.isActiveInOtherTab});break;case"USER_JOINED":if(((C=g==null?void 0:g.current)==null?void 0:C.status)==="editing")return;((N=g==null?void 0:g.current)==null?void 0:N.status)==="locked"&&l("can_edit_now"),i({...g==null?void 0:g.current,requestedBy:"",status:"editing",isActiveInOtherTab:T==null?void 0:T.isActiveInOtherTab});break;case"TAKE_OVER_REQUESTED":i({...g==null?void 0:g.current,requestingClientId:T==null?void 0:T.requestingClientId,requestedBy:T!=null&&T.isRequestedFromAnotherTab?"ANOTHER_TAB":T==null?void 0:T.requestedBy});break;case"TAKE_OVER_REQUEST_ACCEPTED":T!=null&&T.isTakingOverFromAnotherTab||(l("take_over_request_accepted"),F.toast.success("Your Page Take Over Request Accepted",{position:"top-center"})),i({...g==null?void 0:g.current,status:"editing",requestedBy:"",requestingClientId:"",isTakeOverRequested:!1});break;case"TAKE_OVER_REQUEST_REJECTED":l("take_over_request_rejected"),i({...g==null?void 0:g.current,requestedBy:"",requestingClientId:"",isTakeOverRequested:!1});break}},x=new ks(e,r==null?void 0:r.appKey,s==null?void 0:s.id,S);u(x)}},[u,e,r==null?void 0:r.appKey]),h.useEffect(()=>{g.current=a},[a]),h.useEffect(()=>{if(!(!c||!n||!(s!=null&&s.id)||d.current))return d.current=!0,c==null||c.joinPage(n),()=>{c&&d.current&&(d.current=!1,g.current={requestedBy:"",status:"checking",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1},l(""),i(g.current),c==null||c.leavePage())}},[n,c]),a==null?void 0:a.status},Rs=()=>{const{data:e}=X(),{user:t}=gt(),s=e==null?void 0:e.id,{pageLock:n,setPageLock:r,realtimeInstance:a}=Ae(),{savePageAsync:i}=_.useSavePage(),l=h.useCallback(()=>{!a||!s||!(t!=null&&t.id)||(r({...n,isTakeOverRequested:!0}),a==null||a.sendEvent("TAKE_OVER_REQUESTED"))},[a,s,t==null?void 0:t.id,r,n]),c=h.useCallback(async()=>{!a||!s||!(t!=null&&t.id)||(await i(),a==null||a.sendEvent("TAKE_OVER_REQUEST_ACCEPTED",{requestingClientId:n==null?void 0:n.requestingClientId}),r({requestedBy:"",status:"locked",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1}))},[s,a,t==null?void 0:t.id,r,i,n]),u=h.useCallback(()=>{!a||!s||!(t!=null&&t.id)||(a==null||a.sendEvent("TAKE_OVER_REQUEST_REJECTED",{requestingClientId:n==null?void 0:n.requestingClientId}),r({...n,requestedBy:"",status:"editing",requestingClientId:"",isActiveInOtherTab:!1,isTakeOverRequested:!1}))},[s,a,t==null?void 0:t.id,r,n]);return{pageLock:n,acceptTakeOver:c,rejectTakeOver:u,requestTakeOver:l}},Er=h.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-content--8a37nsW.cjs"))),pr=h.lazy(()=>Promise.resolve().then(()=>require("./page-locked-by-dialog-1Lm9dcT6.cjs"))),Ut=h.lazy(()=>Promise.resolve().then(()=>require("./page-lock-request-BE9-Oego.cjs"))),yr=({isFetchingPage:e})=>{const{pageLock:t,requestTakeOver:s}=Rs(),{currentEditor:n,lockingStatus:r,setLockingStatus:a,realtimePageLockEnabled:i}=Ae(),{data:l,isFetching:c}=Gs(n),[u]=ee(),f=u.get("page"),[d]=kt(),g=P.useQueryClient(),E=h.useCallback(()=>{s()},[s]);return!f||e||!i||(t==null?void 0:t.status)==="checking"?null:t!=null&&t.requestedBy?o.jsx(h.Suspense,{children:o.jsx(Ut,{lockingStatus:"",onContinue:()=>{s()}})}):(t==null?void 0:t.status)!=="locked"?r==="take_over_request_accepted"||r==="can_edit_now"?o.jsx(h.Suspense,{children:o.jsx(Ut,{lockingStatus:r,onContinue:()=>{g.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),a("")}})}):null:t!=null&&t.isActiveInOtherTab?o.jsx(h.Suspense,{children:o.jsx(Ut,{lockingStatus:"page_is_active_in_other_tab",onContinue:s})}):o.jsx(h.Suspense,{children:o.jsx(pr,{...l,isFetchingUserInfo:c,name:(l==null?void 0:l.name)||"Unknown User",email:(l==null?void 0:l.email)||"",lastSaved:(d==null?void 0:d.lastSaved)||"",onTakeOver:E,realtimePageLockEnabled:i,isRequestRejected:r==="take_over_request_rejected"})})},Ar=()=>{const[e]=ee(),t=e.get("lang");return ts(t)?null:o.jsx(h.Suspense,{children:o.jsx(Er,{})})},Qe={ab:"Abkhazian",aa:"Afar",af:"Afrikaans",ak:"Akan",sq:"Albanian",am:"Amharic",ar:"Arabic",an:"Aragonese",hy:"Armenian",as:"Assamese",av:"Avaric",ae:"Avestan",ay:"Aymara",az:"Azerbaijani",bm:"Bambara",ba:"Bashkir",eu:"Basque",be:"Belarusian",bn:"Bengali",bh:"Bihari",bi:"Bislama",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",ny:"Chichewa",zh:"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)",cv:"Chuvash",kw:"Cornish",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",dv:"Maldivian",nl:"Dutch",dz:"Dzongkha",en:"English",eo:"Esperanto",et:"Estonian",ee:"Ewe",fo:"Faroese",fj:"Fijian",fi:"Finnish",fr:"French",ff:"Fula, Pular",gl:"Galician",gd:"Gaelic (Scottish)",gv:"Manx",ka:"Georgian",de:"German",el:"Greek",kl:"Kalaallisut",gn:"Guarani",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hz:"Herero",hi:"Hindi",ho:"Hiri Motu",hu:"Hungarian",is:"Icelandic",io:"Ido",ig:"Igbo",id:"Indonesian",ia:"Interlingua",ie:"Interlingue",iu:"Inuktitut",ik:"Inupiak",ga:"Irish",it:"Italian",ja:"Japanese",jv:"Javanese",kn:"Kannada",kr:"Kanuri",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ki:"Kikuyu",rw:"Kinyarwanda",rn:"Kirundi",ky:"Kyrgyz",kv:"Komi",kg:"Kongo",ko:"Korean",ku:"Kurdish",kj:"Kwanyama",lo:"Lao",la:"Latin",lv:"Latvian",li:"Limburgish",ln:"Lingala",lt:"Lithuanian",lu:"Luga-Katanga",lg:"Luganda, Ganda",lb:"Luxembourgish",mk:"Macedonian",mg:"Malagasy",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mh:"Marshallese",mo:"Moldavian",mn:"Mongolian",na:"Nauru",nv:"Navajo",ng:"Ndonga",nd:"Northern Ndebele",ne:"Nepali",no:"Norwegian",nb:"Norwegian bokmål",nn:"Norwegian nynorsk",ii:"Sichuan Yi",oc:"Occitan",oj:"Ojibwe",cu:"Old Church Slavonic",or:"Oriya",om:"Oromo",os:"Ossetian",pi:"Pāli",ps:"Pashto, Pushto",fa:"Persian (Farsi)",pl:"Polish",pt:"Portuguese",pa:"Punjabi (Eastern)",qu:"Quechua",rm:"Romansh",ro:"Romanian",ru:"Russian",se:"Sami",sm:"Samoan",sg:"Sango",sa:"Sanskrit",sr:"Serbian",sh:"Serbo-Croatian",st:"Sesotho",tn:"Setswana",sn:"Shona",sd:"Sindhi",si:"Sinhalese",ss:"Swati",sk:"Slovak",sl:"Slovenian",so:"Somali",nr:"Southern Ndebele",es:"Spanish",su:"Sundanese",sw:"Swahili (Kiswahili)",sv:"Swedish",tl:"Tagalog",ty:"Tahitian",tg:"Tajik",ta:"Tamil",tt:"Tatar",te:"Telugu",th:"Thai",bo:"Tibetan",ti:"Tigrinya",to:"Tonga",ts:"Tsonga",tr:"Turkish",tk:"Turkmen",tw:"Twi",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",ve:"Venda",vi:"Vietnamese",vo:"Volapük",wa:"Wallon",cy:"Welsh",wo:"Wolof",fy:"Western Frisian",xh:"Xhosa",yi:"Yiddish",yo:"Yoruba",za:"Zhuang, Chuang",zu:"Zulu"};function rs(e,t,s=!1){const n=e.toString()?`?${e.toString()}`:"/";s?window.history.replaceState(null,"",n):window.history.pushState({},"",n),t(e),window.dispatchEvent(new PopStateEvent("popstate"))}const Dt=Q.atom(null),Ot=()=>{const{data:e}=ye();return h.useMemo(()=>(e==null?void 0:e.fallbackLang)||"en",[e])},as=()=>{const e=j(),t=k();return P.useQuery({queryKey:[y.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:y.GET_WEBSITE_PAGES})||[],placeholderData:s=>s||[]})},Tr=e=>{const t=j(),s=k(),n=Ot();return P.useQuery({queryKey:[y.GET_WEBSITE_PAGES,e,n],staleTime:1e3*60*5,enabled:!!e,queryFn:async()=>{if(n===e)return{};const r=await t(s,{action:y.GET_WEBSITE_PAGES,data:{lang:e}})||[];return p.keyBy(p.map(r,a=>({...a,lang:e})),"primaryPage")},placeholderData:r=>r||{}})},Sr=h.lazy(()=>Promise.resolve().then(()=>require("./page-manager-new-BoTBCqZF.cjs"))),Ms=({children:e})=>{const{t}=_.useTranslation(),[s,n]=ee(),r=s.get("page"),{data:a,isFetching:i}=X(),{data:l,isFetching:c}=as(),[u,f]=h.useState(!1),[d,g]=h.useState(!0),{savePage:E}=_.useSavePage(),S=!!r&&!p.isEmpty(a),x=h.useMemo(()=>{if(!l||c)return!1;const N=l.find(R=>R.slug==="/");return N==null?void 0:N.id},[l,c]);h.useEffect(()=>{if(c||!x||l.some(K=>K.id===r))return;const R=new URLSearchParams({page:x});rs(R,n),!c&&l&&g(!1)},[r,c,l,x,n]);const A=!d&&!r,T=!d&&!i&&p.isEmpty(a),C=u||A||T;return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex items-center gap-x-1",children:o.jsx("div",{className:"relative",children:o.jsxs(m.Tooltip,{children:[o.jsx(m.TooltipTrigger,{asChild:!0,onClick:()=>{E(),f(!0)},children:e||o.jsx(m.Button,{variant:"outline",className:"flex w-full items-center space-x-2 py-1",children:o.jsx(w.LogsIcon,{className:"h-4 w-4"})},"template-viewer")}),o.jsx(m.TooltipContent,{side:"right",children:o.jsx("p",{children:t("Open pages manager")})})]})})}),o.jsx(m.Sheet,{open:C,onOpenChange:N=>!N&&S&&f(!1),children:o.jsxs(m.SheetContent,{side:"left","aria-describedby":"pages-manager-description",className:`z-50 !min-w-[50vh] !max-w-[800px] border-border p-0 ${S?"":"sheet-hide-close-btn"}`,children:[o.jsxs(m.SheetHeader,{className:"mb-3 px-4 pt-4",children:[o.jsxs(m.SheetTitle,{className:"flex items-center gap-2 text-sm font-semibold",children:[o.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary text-primary-foreground",children:o.jsx(w.Folder,{className:"h-4 w-4"})}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-sm font-semibold",children:t("Pages")}),o.jsx("span",{id:"pages-manager-description",className:"text-xs font-normal text-muted-foreground",children:t("Manage your site structure")})]})]}),o.jsx(m.SheetDescription,{className:"sr-only",children:t("Manage your site structure")})]}),o.jsx("div",{className:"h-[calc(100vh-80px)] overflow-y-auto",children:C&&o.jsx(h.Suspense,{children:o.jsx(Sr,{close:()=>f(!1)})})})]})})]})},Pr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-language-page-VDZSKD95.cjs"))),xr=()=>{const e=se("topLeftCorner",null);return e?o.jsx("div",{className:"max-h-9 w-full overflow-hidden pr-2",children:h.createElement(e,{})}):null},Bs=({showAdd:e=!0,variant:t="ghost"})=>{const{fallbackLang:s,languages:n,selectedLang:r,setSelectedLang:a}=_.useLanguages(),i=p.isEmpty(r)?s:r,[,l]=ee(),{isLocked:c}=Ae();h.useEffect(()=>{const A=new URLSearchParams(window.location.search),T=A.get("lang");T&&(n.includes(T)?a(T):(A.delete("lang"),l(A),a("")))},[n,l,a]);const[,u]=Q.useAtom(Dt),{data:f}=X(),{data:d}=ye(),{data:g}=pe(),E=h.useMemo(()=>{const A=p.compact(p.map(p.get(d,"languages"),T=>{const C=p.find(g,{lang:T});return{key:T,value:p.get(Qe,T,T),isLangPageAdded:!!C}})).filter(Boolean);return[{key:s,value:p.get(Qe,s),isLangPageAdded:!0},...A]},[s,g,d]),S=A=>{if(document.querySelector('[data-panel-id="seo"]')){const C=new CustomEvent("seo-language-switch-check",{detail:{fromLang:i,toLang:A,switchHandler:()=>x(A)}});window.dispatchEvent(C);return}x(A)},x=A=>{a(A);const T=new URLSearchParams(window.location.search);A===s?T.delete("lang"):T.set("lang",A),rs(T,l)};return p.isEmpty(n)?null:c?o.jsxs(m.Button,{variant:"ghost",size:"sm",className:"ml-px h-max cursor-not-allowed gap-2 py-1.5 opacity-50",children:[o.jsx(w.Languages,{className:"h-4 w-4"}),p.get(Qe,i,i),o.jsx(w.ChevronDown,{className:"h-4 w-4"})]}):o.jsx(o.Fragment,{children:o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,className:"focus:outline-none",children:o.jsxs(m.Button,{disabled:!!c,variant:t,size:"sm",className:"ml-px h-max gap-2 py-1.5",children:[o.jsx(w.Languages,{className:"h-4 w-4"}),p.get(Qe,i,i),o.jsx(w.ChevronDown,{className:"h-4 w-4"})]})}),o.jsxs(m.DropdownMenuContent,{className:"space-y-1 border-border",children:[p.map(E.filter(A=>A.isLangPageAdded),A=>o.jsxs(m.DropdownMenuItem,{className:_.mergeClasses("flex cursor-pointer items-center justify-between text-xs font-medium text-gray-800",A.key===i&&"!bg-gray-200 text-gray-700"),onClick:()=>S(A.key),children:[o.jsx("div",{className:"text-slate-600",children:A.value}),A.key===s&&o.jsxs("small",{className:"flex items-center gap-x-1 text-[9px] leading-none text-orange-500",children:[o.jsx(w.Star,{fill:"orange",className:"h-2 w-2"}),"Primary"]})]},A.value)),e&&!p.isEmpty(E.filter(A=>!A.isLangPageAdded))&&o.jsxs(o.Fragment,{children:[o.jsx(m.Separator,{}),o.jsxs(m.Button,{size:"sm",variant:"ghost",onClick:()=>{f&&u({edit:!1,primaryPage:f.id})},className:"text-xs font-normal duration-200 hover:bg-slate-300 hover:text-slate-800",children:[o.jsx(w.Plus,{className:"mr-1 h-3 w-3"})," Add Langauge"]})]})]})]})})};function _r(){const[e,t]=Q.useAtom(Dt);return o.jsxs("div",{className:"relative z-10 flex items-center justify-end gap-1",children:[o.jsx(xr,{}),o.jsx(Ms,{}),e&&o.jsx(h.Suspense,{children:o.jsx(Pr,{isOpen:!0,id:e==null?void 0:e.id,edit:!!(e!=null&&e.id),primaryPage:e==null?void 0:e.primaryPage,preselectedLang:e==null?void 0:e.preselectedLang,onClose:()=>t(null)})})]})}function vr(){return o.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((e,t)=>o.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[o.jsxs("div",{className:"flex-1 space-y-1",children:[o.jsx(m.Skeleton,{className:"h-4 w-3/4"}),o.jsx(m.Skeleton,{className:"h-3 w-1/2"}),o.jsx(m.Skeleton,{className:"mt-1 h-5 w-20"})]}),o.jsx(m.Skeleton,{className:"h-8 w-8 rounded-full"})]},t))})}const wr=z.lazy(()=>Promise.resolve().then(()=>require("./page-revisions-content-BNBb2qYh.cjs")));function br(){const[e,t]=z.useState(!1);return o.jsx(m.TooltipProvider,{children:o.jsxs(m.Tooltip,{delayDuration:0,children:[o.jsxs(m.Sheet,{open:e,onOpenChange:t,children:[o.jsx(m.SheetTrigger,{asChild:!0,children:o.jsx(m.TooltipTrigger,{asChild:!0,children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsxs(m.Button,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[o.jsx(w.History,{className:"h-4 w-4"}),o.jsx("span",{className:"sr-only",children:"View revision history"})]}),o.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})})}),o.jsx(m.SheetContent,{className:"flex h-[100vh] flex-col",children:e&&o.jsx(h.Suspense,{fallback:o.jsx(vr,{}),children:o.jsx(wr,{isOpen:e})})})]}),o.jsx(m.TooltipContent,{side:"bottom",children:o.jsx("p",{children:"Revision history"})})]})})}const Tt=({permission:e,permissions:t,children:s,fallback:n=null})=>{const{hasPermission:r}=_.usePermissions();return e&&!r(e)||t&&!t.some(a=>r(a))?n:s},Cr={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},de=()=>{const e=k(),t=j();return P.useQuery({queryKey:[y.GET_PAGE_TYPES],staleTime:1/0,placeholderData:[],queryFn:async()=>t(e,{action:y.GET_PAGE_TYPES})})},Us=e=>{const{data:t}=de();return h.useMemo(()=>t==null?void 0:t.find(s=>s.key===e),[t,e])},Ir=()=>{const e=k(),t=j();return P.useMutation({mutationFn:async({pageType:s,query:n})=>{try{return t(e,{action:y.SEARCH_PAGES,data:{pageType:s,query:Array.isArray(n)&&n.length>0?n[0]:n}})||[]}catch(r){return console.error(r),[]}}})},Nr=()=>{const e=k(),t=P.useQueryClient(),s=j(),{data:n}=de();return P.useMutation({mutationFn:async r=>await s(e,{action:y.CREATE_PAGE,data:r}),onSuccess:(r,a)=>{var l;a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES,a==null?void 0:a.lang]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]});const i=a.template?`Page created from "${a.template.name}" template`:a.hasSlug===!1?"New "+((l=p.find(n,{key:a.pageType}))==null?void 0:l.name)+" added successfully":"New page added successfully";F.toast.success(i)},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});F.toast.error(`Failed to add new ${i!=null&&i.hasSlug?"page":i.name}.`,{description:p.get(Cr,r.message,r.message)})}})},Lr=()=>{const e=k(),t=P.useQueryClient(),s=j(),{data:n}=ue(),{data:r}=de();return P.useMutation({mutationFn:async a=>await s(e,{action:y.UPDATE_PAGE,data:a}),onSuccess:(a,i)=>{(n==null?void 0:n.id)===(i==null?void 0:i.id)&&t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]}),i&&(i!=null&&i.primaryPage||i!=null&&i.seo)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,i==null?void 0:i.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(a,i)=>{const l=p.find(r,{key:i.pageType});F.toast.error(`Failed to update ${l!=null&&l.hasSlug?"page":l.name}.`,{description:a.message})}})},jr=()=>{const e=k(),t=P.useQueryClient(),s=j(),{data:n}=de();return P.useMutation({mutationFn:async r=>s(e,{action:y.DELETE_PAGE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{if(r.code==="PAGE_LOCKED"){F.toast.error("Delete not allowed",{description:"Page is currently being edited by another user."});return}a&&(a!=null&&a.primaryPage)?(t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}),t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});F.toast.error(`Failed to delete ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},kr=()=>{const e=k(),t=P.useQueryClient(),s=j(),{data:n}=de();return P.useMutation({mutationFn:async r=>s(e,{action:y.TAKE_OFFLINE,data:{id:r==null?void 0:r.id}}),onSuccess:(r,a)=>{a&&(a!=null&&a.primaryPage)?t.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,a==null?void 0:a.primaryPage]}):t.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]});const i=p.find(n,{key:a.pageType});F.toast.success(i!=null&&i.hasSlug?"Page unpublished successfully.":"New "+i.name+" added successfully.")},onError:(r,a)=>{const i=p.find(n,{key:a.pageType});F.toast.error(`Failed to take offline ${i!=null&&i.hasSlug?"page":i.name}.`,{description:r.message})}})},is=()=>{const e=k(),t=j(),s=P.useQueryClient(),{data:n}=X(),{savePageAsync:r}=_.useSavePage();return P.useMutation({mutationFn:async({ids:a})=>(await r(),t(e,{action:y.PUBLISH_CHANGES,data:{ids:a}})),onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_CHANGES]}),s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,n==null?void 0:n.id]})},onError:a=>{console.log("##",a),F.toast.error("Failed to publish pages.")}})},Dr=()=>{const e=k(),t=j(),s=P.useQueryClient();return P.useMutation({mutationFn:async n=>{var r;return t(e,{action:y.MARK_AS_TEMPLATE,data:{id:(r=n.page)==null?void 0:r.id,name:n.name,description:n.description,pageType:n.pageType,previewImage:n.previewImage}})},onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),F.toast.success("Page marked as template successfully.")},onError:()=>{F.toast.error("Failed to mark page as template.")}})},Or=()=>{const e=k(),t=j(),s=P.useQueryClient();return P.useMutation({mutationFn:async n=>t(e,{action:y.UNMARK_AS_TEMPLATE,data:{id:n==null?void 0:n.id}}),onSuccess:()=>{s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]}),F.toast.success("Page unmarked as template successfully.")},onError:()=>{F.toast.error("Failed to unmark page as template.")}})},Gr=()=>{const e=k(),t=j(),s=P.useQueryClient();return P.useMutation({mutationFn:async({id:n,slug:r})=>t(e,{action:y.CHANGE_SLUG,data:{id:n,slug:r}}),onSuccess:(n,{primaryPage:r})=>{F.toast.success("Slug changed successfully."),r?s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,r]}):s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:()=>{F.toast.error("Failed to change slug")}})},Rr=h.lazy(()=>Promise.resolve().then(()=>require("./publish-pages-content-DsOVOiBD.cjs")));function Mr({showModal:e=!1,onClose:t=()=>console.log("Cancelled")}){const{mutate:s,isPending:n}=is();return o.jsx(m.Dialog,{open:e,onOpenChange:n?()=>{}:t,children:e&&o.jsx(h.Suspense,{fallback:o.jsx("div",{className:"h-96 w-96 animate-pulse bg-gray-100"}),children:o.jsx(Rr,{onClose:t,isPending:n,publishPage:s})})})}const te={..._.PERMISSIONS,ADD_PAGE:"add_page",EDIT_PAGE:"edit_page",EDIT_SLUG:"edit_slug",DELETE_PAGE:"delete_page",CHANGE_PAGE_TYPE:"change_page_type",PUBLISH_PAGE:"publish_page",UNPUBLISH_PAGE:"unpublish_page",MARK_AS_TEMPLATE:"mark_as_template",UNMARK_AS_TEMPLATE:"unmark_as_template",ADD_PARTIAL:"add_partial",EDIT_PARTIAL:"edit_partial",DELETE_PARTIAL:"delete_partial",PUBLISH_PARTIAL:"publish_partial",UNPUBLISH_PARTIAL:"unpublish_partial",EDIT_SEO:"edit_seo",RESTORE_REVISION:"restore_revision",DELETE_REVISION:"delete_revision",PUBLISH_THEME:"publish_theme",EDIT_SETTINGS:"edit_settings",ADD_LIBRARY_BLOCK:"create_library_block",ADD_LIBRARY_TEMPLATE:"add_library_template",EDIT_LIBRARY_BLOCK:"edit_library_block",EDIT_LIBRARY_TEMPLATE:"edit_library_template",DELETE_LIBRARY_BLOCK:"delete_library_block",DELETE_LIBRARY_TEMPLATE:"delete_library_template",ADD_MEDIA:"add_media",EDIT_MEDIA:"edit_media",DELETE_MEDIA:"delete_media"},Br={particleCount:350,spread:120,origin:{y:.6},angle:90},Ur={TOP_RIGHT:{angle:225,origin:{x:.9,y:0}},BOTTOM_RIGHT:{angle:100,origin:{x:.9,y:.9}}},Fr=async()=>{const{default:e}=await Promise.resolve().then(()=>require("./confetti.module-BuUnQuWk.cjs"));return e},St=e=>{let t=Ur[e];t||(t={});const s={...Br,...t};Fr().then(n=>n(s))};function Gt({children:e,content:t,side:s="bottom",delayDuration:n=700,showTooltip:r=!0}){return r?o.jsx(m.TooltipProvider,{children:o.jsxs(m.Tooltip,{delayDuration:n,children:[o.jsx(m.TooltipTrigger,{asChild:!0,children:e}),o.jsx(m.TooltipContent,{side:s,sideOffset:10,children:o.jsx("p",{children:t})})]})}):e}const qr=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-BjiB3d7l.cjs"))),Kr=h.lazy(()=>Promise.resolve().then(()=>require("./translation-warning-modal-Kctu12rQ.cjs"))),Vr=()=>{const{t:e}=_.useTranslation(),{selectedLang:t,fallbackLang:s}=_.useLanguages(),n=se("getPreviewUrl",async g=>g),[r,a]=h.useState(""),{data:i}=X(),{data:l}=pe(),{data:c}=de(),u=h.useMemo(()=>{var g;return(g=l==null?void 0:l.find(E=>(E==null?void 0:E.lang)===t))==null?void 0:g.slug},[t,l]),f=h.useCallback(g=>{var E;return(E=p.find(c,{key:g}))==null?void 0:E.hasSlug},[c]),d=t===s?"":t;return h.useEffect(()=>{(async()=>{if(typeof n=="function"){const g=!f(i==null?void 0:i.pageType),E=await n(g?`${d!==""?d+"/":""}${i==null?void 0:i.id}`:u||"");a(E)}else a("")})()},[n,u,i==null?void 0:i.pageType,f,i==null?void 0:i.id,d]),o.jsx(o.Fragment,{children:o.jsx(Gt,{content:e("Open preview in new tab"),delayDuration:0,children:o.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:o.jsx(m.Button,{variant:"ghost",size:"sm",className:"gap-2",children:o.jsx(w.Play,{className:"h-4 w-4"})})})})})},Qr=()=>{const{t:e}=_.useTranslation(),[t,s]=_.useRightPanel();return o.jsxs(o.Fragment,{children:[o.jsx(Gt,{content:e("Theme"),delayDuration:0,children:o.jsx(m.Button,{variant:t==="theme"?"outline":"ghost",size:"icon",className:"gap-2",onClick:()=>s(t==="theme"?"block":"theme"),children:o.jsx(w.Palette,{className:"h-4 w-4"})})}),o.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})},Hr=()=>{const{t:e}=_.useTranslation(),[t,s]=h.useState(!1),{isLocked:n}=Ae(),{savePageAsync:r,saveState:a}=_.useSavePage();h.useEffect(()=>{const f=d=>{a==="UNSAVED"&&(d.preventDefault(),d.returnValue=!1)};return a==="UNSAVED"&&window.addEventListener("beforeunload",f),()=>{window.removeEventListener("beforeunload",f)}},[a]);const i=h.useCallback(async()=>{t||(s(!0),await r(),s(!1))},[r,t]),{buttonIcon:l,buttonClass:c,tooltipContent:u}=h.useMemo(()=>{switch(a){case"UNSAVED":return{tooltipContent:e("Save draft"),buttonIcon:o.jsx(w.Save,{className:"h-4 w-4"}),buttonClass:"gap-x-1"};case"SAVING":return{tooltipContent:e("Saving"),buttonIcon:o.jsx(w.Loader,{className:"h-4 w-4 animate-spin text-sky-700"}),buttonClass:"gap-x-1"};case"SAVED":return{tooltipContent:e("Saved"),buttonIcon:o.jsx(w.CheckCircle,{className:"h-4 w-4"}),buttonClass:"text-green-500 gap-x-1"}}},[a,e]);return n?null:o.jsxs(m.Button,{size:"sm",variant:"ghost",onClick:i,className:`${c} w-24 max-w-24`,children:[l," ",u]})},zr=()=>{const{t:e}=_.useTranslation(),{selectedLang:t}=_.useLanguages(),{data:s}=ue(),{data:n}=pe(),[r,a]=h.useState(!1),[i,l]=h.useState(!1),[c,u]=h.useState(null),{savePageAsync:f}=_.useSavePage(),[d,g]=h.useState(!1),{data:E}=X(),{mutate:S,isPending:x}=is(),{needTranslations:A}=_.useSavePage(),T=A(),{buttonText:C,buttonClassName:N,isPublished:R}=h.useMemo(()=>{const I=E&&(E==null?void 0:E.online);return{buttonClassName:I?"hover:bg-green-600 bg-green-500":"",isPublished:I,buttonText:e(I?"Published":"Publish")}},[E,e]),K=async()=>{if(T){g(!0);return}O()},O=()=>{const I=[s==null?void 0:s.id,s==null?void 0:s.primaryPage];S({ids:p.compact(I)},{onSuccess:()=>St("TOP_RIGHT")})},ie=()=>{g(!1),O()},oe=async()=>{g(!1),await f()},q=h.useMemo(()=>p.map(n??[],"id"),[n]);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex",children:[o.jsxs(m.Button,{size:"sm",onClick:K,disabled:x||!(E!=null&&E.id),className:`relative flex items-center gap-1 overflow-hidden rounded-r-none text-white transition-all duration-300 ease-in-out ${N}`,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[o.jsx("span",{className:`flex items-center transition-transform duration-300 ease-in-out ${i?"-translate-y-10":""}`,children:R?o.jsx(w.Send,{className:"h-4 w-4"}):o.jsx(w.Rocket,{className:"h-4 w-4"})}),o.jsx("span",{className:`absolute inset-0 left-3 flex items-center transition-transform duration-300 ease-in-out ${i?"":"translate-y-10"}`,children:R?o.jsx(w.Rocket,{className:"h-4 w-4"}):o.jsx(w.Send,{className:"h-4 w-4"})}),o.jsx("span",{children:C}),t?`(${p.upperCase(t)})`:""]}),o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,children:o.jsx(m.Button,{size:"sm",disabled:x||!(E!=null&&E.id),className:`rounded-l-none border-l border-white/50 px-2 text-white ${N}`,children:o.jsx(w.ChevronDown,{className:"h-4 w-4"})})}),o.jsxs(m.DropdownMenuContent,{align:"end",className:"w-52",children:[o.jsxs(m.DropdownMenuItem,{disabled:x,className:"cursor-pointer text-xs",onClick:()=>S({ids:q},{onSuccess:()=>St("TOP_RIGHT")}),children:[e("Publish")," with translation pages"]}),!R&&o.jsxs(m.DropdownMenuItem,{disabled:x,className:"cursor-pointer text-xs",onClick:()=>S({ids:[E==null?void 0:E.id]},{onSuccess:()=>St("TOP_RIGHT")}),children:[e("Publish")," page"]}),o.jsxs(m.DropdownMenuItem,{onClick:()=>a(!0),className:"cursor-pointer text-xs",children:[e("Open")," publish menu"]}),R&&o.jsxs(m.DropdownMenuItem,{onClick:()=>u(s),className:"cursor-pointer text-xs",children:[e("Unpublish")," page ",t?`(${p.upperCase(t)})`:""]})]})]})]}),o.jsx(Mr,{showModal:r,onClose:()=>a(!1)}),c&&o.jsx(h.Suspense,{children:o.jsx(qr,{page:c,onClose:()=>u(null)})}),d&&o.jsx(h.Suspense,{children:o.jsx(Kr,{isOpen:d,onClose:oe,onContinue:ie,isPending:x})})]})};function $r(){const{isLocked:e}=Ae(),[t]=ee(),s=t.get("lang"),n=ts(s);return e||!n?o.jsx("div",{}):o.jsxs("div",{className:"flex items-center justify-end gap-1",children:[o.jsx(br,{}),o.jsx(Tt,{permission:te.EDIT_THEME,children:o.jsx(Qr,{})}),o.jsx(Vr,{}),o.jsx(Tt,{permission:te.SAVE_PAGE,children:o.jsx(Hr,{})}),o.jsx(Tt,{permission:te.PUBLISH_PAGE,children:o.jsx(zr,{})})]})}const Fs=({page:e,setDuplicatePage:t,setAddEditPage:s,setUnpublishPage:n,setDeletePage:r,setMarkAsTemplate:a,setUnmarkAsTemplate:i,children:l,isLanguagePage:c})=>{const{t:u}=_.useTranslation(),{hasPermission:f}=_.usePermissions(),{data:d}=de(),g=h.useMemo(()=>p.find(d,{key:e.pageType}),[d,e.pageType]),E=h.useMemo(()=>!!e.isTemplate,[e.isTemplate]),S=h.useMemo(()=>!!(g!=null&&g.hasSlug),[g==null?void 0:g.hasSlug]);return!f(te.EDIT_PAGE)&&!f(te.DELETE_PAGE)&&!f(te.UNPUBLISH_PAGE)||!e?null:o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,onClick:A=>A.stopPropagation(),children:l}),o.jsxs(m.DropdownMenuContent,{align:"center",className:"text-sm",children:[f(te.ADD_PAGE)&&!c&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:A=>{A.stopPropagation(),t(e)},children:[o.jsx(w.CopyPlusIcon,{className:"size-3"}),"Duplicate page"]}),f(te.EDIT_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:A=>{A.stopPropagation(),s({...e,global:!(g!=null&&g.hasSlug)})},children:[o.jsx(w.Pencil,{className:"size-3"}),"Edit"]}),(e==null?void 0:e.online)&&f(te.UNPUBLISH_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:A=>{A.stopPropagation(),n(e)},children:[o.jsx(w.Power,{className:"size-3"}),u("Unpublish")]}),f(te.DELETE_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:A=>{A.stopPropagation(),r(e)},children:[o.jsx(w.Trash,{className:"size-3"}),u("Delete")]}),f(te.MARK_AS_TEMPLATE)&&S&&!c&&o.jsx(o.Fragment,{children:E?o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:A=>{A.stopPropagation(),i(e)},children:[o.jsx(w.SquareLibrary,{className:"size-3"}),u("Unmark as template")]}):o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:A=>{A.stopPropagation(),a(e)},children:[o.jsx(w.SquareLibrary,{className:"size-3"}),u("Mark as template")]})})]})]})},Wr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-D4IkZL8h.cjs"))),Yr=h.lazy(()=>Promise.resolve().then(()=>require("./delete-page-DeKAD4Ld.cjs"))),Jr=h.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-CKr-HNs-.cjs"))),Xr=h.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-CJ9SiEBl.cjs"))),Zr=h.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-Bxw4t_Xi.cjs"))),ea=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-BjiB3d7l.cjs"))),ta=()=>{const[e,t]=h.useState(null),[s,n]=h.useState(null),[r,a]=h.useState(null),[i,l]=h.useState(null),[c,u]=h.useState(null),[f,d]=h.useState(null),{data:g,isFetching:E}=ue(),{selectedLang:S,fallbackLang:x}=_.useLanguages(),{data:A}=pe(),T=A==null?void 0:A.find(O=>O.lang===S),{isLocked:C}=Ae(),N=!(g!=null&&g.slug),[,R]=Q.useAtom(Dt);if(!g)return null;const K=O=>{S.length>0&&S!==x?R({edit:!0,id:O==null?void 0:O.id,primaryPage:O==null?void 0:O.primaryPage}):d(O)};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between rounded px-[2px] transition-colors duration-200",children:[o.jsx(Ms,{children:o.jsx(m.Button,{className:"flex h-7 max-w-[200px] cursor-pointer items-center truncate rounded px-1 text-xs font-medium",variant:"ghost",children:E?o.jsx(w.Loader,{className:"h-4 w-4 animate-spin text-slate-400"}):o.jsxs("span",{className:"flex w-full cursor-pointer items-end overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-xs font-medium",children:[N?o.jsx(w.Hash,{className:"mr-1 h-4 w-4"}):o.jsx(w.File,{className:"mr-1 h-4 w-4"}),p.get(T||g,"name")??""]})})}),C?o.jsx(m.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 cursor-not-allowed rounded opacity-50 hover:bg-transparent",children:o.jsx(w.MoreHorizontal,{className:"h-4 w-4"})}):o.jsx(Fs,{page:g,setDuplicatePage:O=>u(O),setAddEditPage:O=>K(O),setUnpublishPage:O=>n(O),setDeletePage:O=>t(O),setMarkAsTemplate:O=>a(O),setUnmarkAsTemplate:O=>l(O),isLanguagePage:S.length>0&&S!==x,children:o.jsx(m.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded",children:o.jsx(w.MoreHorizontal,{className:"h-4 w-4"})})})]}),f&&o.jsx(h.Suspense,{children:o.jsx(Wr,{closePanel:()=>d(null),editPage:()=>{},addEditPage:f,setAddEditPage:d})}),e&&o.jsx(h.Suspense,{children:o.jsx(Yr,{page:e,onClose:()=>t(null)})}),s&&o.jsx(h.Suspense,{children:o.jsx(ea,{page:s,onClose:()=>n(null)})}),r&&o.jsx(h.Suspense,{children:o.jsx(Xr,{page:r,onClose:()=>a(null)})}),i&&o.jsx(h.Suspense,{children:o.jsx(Zr,{page:i,onClose:()=>l(null)})}),c&&o.jsx(h.Suspense,{children:o.jsx(Jr,{page:c,onClose:()=>u(null),closePanel:()=>d(null)})})]})},os=({children:e,className:t=""})=>o.jsx("div",{className:_.mergeClasses("fixed bottom-0 left-0 right-0 top-[50px] z-[20] flex w-screen flex-col items-center justify-center bg-black/40 transition-all",t),children:e}),sa=({hasDynamicPage:e})=>o.jsx(os,{children:o.jsxs("div",{className:"flex min-w-[300px] max-w-[400px] flex-col items-center justify-center rounded-lg border bg-white p-4 shadow-lg",children:[o.jsx("h1",{className:"text-lg font-medium",children:e?"Select a page":"No pages found"}),o.jsx("p",{className:"pt-2 text-center text-sm font-light text-gray-600",children:e?"Please select a page from the list in the top header. This will enable you to edit the page.":"Please add a new page"})]})}),na=h.lazy(()=>Promise.resolve().then(()=>require("./dynamic-page-selector-C7w3TOdK.cjs"))),ra=()=>{const{dynamicPage:e,allLangPages:t,isFetching:s}=Os(),n=t.length>0;return s?null:o.jsxs("div",{className:"relative",children:[!e&&o.jsx(sa,{hasDynamicPage:n}),o.jsx(h.Suspense,{children:o.jsx(na,{})})]})},aa=()=>{const{data:e,isFetching:t}=ue(),{data:s,isFetching:n}=X(),r=p.get(s,"dynamic",!1),a=ss(),i=_.useChaiFeatureFlag("dynamic-page-selector"),l=e==null?void 0:e.slug,c=!l,u=ur(),f=t||n,g=(c?`Partial: ${e==null?void 0:e.name} `:`${l}${a}`).replace(window.location.host,"");return o.jsxs("div",{className:"relative flex items-center gap-x-1",children:[o.jsx("div",{className:_.mergeClasses("flex h-8 w-auto max-w-[600px] items-center rounded-md border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800",f&&"max-w-0 overflow-hidden opacity-0"),children:o.jsx(ta,{})}),o.jsxs("div",{className:_.mergeClasses("flex h-8 w-auto max-w-[600px] items-center rounded-md border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800"+(c?" pr-2":""),f&&"max-w-0 overflow-hidden opacity-0"),children:[o.jsx(Bs,{}),o.jsxs("div",{className:"flex w-full items-center overflow-hidden",children:[o.jsx("div",{className:`w-full max-w-[200px] overflow-hidden overflow-ellipsis whitespace-nowrap pl-1 text-xs ${c?"italic text-gray-400":"font-mono text-gray-500"}`,children:g==="/"?o.jsxs("span",{className:"text-gray-900",children:["/",o.jsx("span",{className:"text-[11px] font-light italic text-gray-400",children:"(Homepage)"})]}):g}),!c&&o.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:o.jsx("div",{className:"ml-2 mr-px flex-shrink-0 rounded-sm p-1.5 text-gray-500 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300",children:o.jsx(w.ExternalLink,{className:"h-4 w-4",strokeWidth:1})})})]})]}),r&&i&&o.jsx(ra,{})]})},ia=()=>o.jsxs("div",{className:"flex h-full w-full items-center justify-between px-2",children:[o.jsx(_r,{}),o.jsx(aa,{}),o.jsx($r,{})]}),qs=()=>{const e=P.useQueryClient(),{data:t}=P.useQuery({queryKey:[y.AI_CONTEXT],initialData:"",queryFn:()=>"",staleTime:0});return{setAiContext:h.useCallback(n=>{e.setQueryData([y.AI_CONTEXT],n)},[e]),aiContext:t}},oa=()=>{const e=k(),{aiContext:t}=qs(),s=j();return h.useCallback(async(n,r,a,i)=>s(e,{action:y.ASK_AI,data:{type:n,prompt:r,blocks:a,context:t,lang:i}}),[e,t,s])},la=(e,t)=>t.map(s=>{if(p.has(e,s._type)){const n=Ls.getDefaultBlockProps(s._type);return{...n,...p.pick(s,[...p.keys(n),"_type","_id","_name","_parent","_bindings"]),...p.pickBy(s,(r,a)=>p.endsWith(a,"_attrs")),...s}}return s}),ca=e=>{const t=Ls.useRegisteredChaiBlocks();return h.useMemo(()=>{if(!e||p.isEmpty(e))return{blocks:[]};const s=p.filter(e,n=>!p.includes(n==null?void 0:n._type,"@chai/"));return{blocks:la(t,s)}},[e,t])},ua=()=>{const[e]=ee(),t=e.get("page"),s=k(),{setAiContext:n}=qs(),[,r]=kt(),[,a]=cr(),[,i]=_.useIsPageLoaded(),l=j();return P.useQuery({queryKey:[y.GET_DRAFT_PAGE,t],staleTime:1/0,gcTime:0,queryFn:async()=>{i(!1);const c=await l(s,{action:y.GET_DRAFT_PAGE,data:{id:t,draft:!0}}),u=c.blocks??[],f=p.find(u,{_type:"@chai/ai-context"});return n(p.get(f,"_value","")||""),r(d=>({...d,lastSaved:c.lastSaved})),a(p.get(c,"metadata",{})),setTimeout(()=>i(!0),500),u},enabled:!!t})},Ks=()=>{const{data:e}=X(),{data:t}=ue(),s=k(),n=j(),r=Ot(),a=ss();return P.useQuery({queryKey:[y.GET_BUILDER_PAGE_DATA,t==null?void 0:t.id,a],staleTime:1/0,gcTime:0,queryFn:async()=>n(s,{action:y.GET_BUILDER_PAGE_DATA,data:{pageType:e==null?void 0:e.pageType,lang:(t==null?void 0:t.lang)||r,dynamic:e==null?void 0:e.dynamic,pageProps:{slug:(t==null?void 0:t.slug)+a,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:r,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id,metadata:e.metadata||{}}}}),enabled:!!(e!=null&&e.pageType)&&!!t.id})},Vs=()=>{const e=k(),t=P.useQueryClient(),s=j();return P.useMutation({mutationFn:async n=>s(e,{action:y.UPDATE_WEBSITE_SETTINGS,data:n}),onSuccess:(n,r)=>{var a;t.invalidateQueries({queryKey:[y.GET_WEBSITE_DRAFT_SETTINGS]}),(a=r==null?void 0:r.settings)!=null&&a.theme||F.toast.success("Website settings updated successfully.")},onError:n=>{F.toast.error("Failed to update website settings",{description:n.message})}})},da=()=>{const e=k(),t=P.useQueryClient(),s=j(),{selectedLang:n}=_.useLanguages();return P.useMutation({mutationFn:async r=>s(e,{action:y.ADD_GLOBAL_SCHEMA,data:{...r,lang:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema added successfully.")},onError:r=>{F.toast.error("Failed to add schema",{description:r.message})}})},fa=()=>{const e=k(),t=P.useQueryClient(),s=j(),{selectedLang:n}=_.useLanguages();return P.useMutation({mutationFn:async r=>s(e,{action:y.UPDATE_GLOBAL_SCHEMA,data:{...r,lang:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema updated successfully.")},onError:r=>{F.toast.error("Failed to update schema",{description:r.message})}})},ha=()=>{const e=k(),t=P.useQueryClient(),s=j();return P.useMutation({mutationFn:async n=>s(e,{action:y.DELETE_GLOBAL_SCHEMA,data:{id:n}}),onSuccess:()=>{t.invalidateQueries({queryKey:[y.GET_GLOBAL_JSONLD_ITEMS]}),F.toast.success("Schema deleted successfully.")},onError:n=>{F.toast.error("Failed to delete schema",{description:n.message})}})},ga=()=>{const e=k(),t=j();return P.useMutation({mutationFn:async s=>t(e,{action:y.TOGGLE_PAGE_GLOBAL_SCHEMA,data:s}),onError:s=>{F.toast.error("Failed to toggle schema",{description:s.message})}})},ma=()=>{const e=k(),t=j();return P.useMutation({mutationFn:async s=>t(e,{action:y.APPLY_SCHEMA_TO_ALL_PAGES,data:{schemaId:s}}),onSuccess:s=>{F.toast.success(`Schema applied to ${s.count} page(s)`)},onError:s=>{F.toast.error("Failed to apply schema to all pages",{description:s.message})}})},Ea=()=>{const e=k(),t=j();return P.useMutation({mutationFn:async s=>t(e,{action:y.REMOVE_SCHEMA_FROM_ALL_PAGES,data:{schemaId:s}}),onSuccess:s=>{F.toast.success(`Schema removed from ${s.count} page(s)`)},onError:s=>{F.toast.error("Failed to remove schema from all pages",{description:s.message})}})},ps={async getUILibraryBlock(e,t,s){const n=await t(s,{action:"GET_LIBRARY_ITEM",data:{id:e.id}}),r=p.get(n,"html",""),a=p.get(n,"blocks",[]);return p.isArray(a)?a:_.getBlocksFromHTML(r)},async getUILibraryBlocks(e,t,s){try{return(await t(s,{action:"GET_LIBRARY_ITEMS",data:{id:e.id}})).map(r=>({...r}))}catch(n){return console.error(n),[]}}},pa=()=>{const e=k(),t=j();return P.useQuery({queryKey:["uiLibraries"],staleTime:"static",queryFn:async()=>{const n=(await t(e,{action:"GET_LIBRARIES"})).map(r=>({...r}));return n.forEach(r=>{_.registerChaiLibrary(r.id,{name:r.isSiteLibrary?r.name+" (Current Site) ":r.name,description:r.description,getBlocksList:a=>ps.getUILibraryBlocks(a,t,e),getBlock:({block:a})=>ps.getUILibraryBlock(a,t,e)})}),n}})},Qs=()=>{const e=js(),t=j(),{user:s}=gt(),n=s==null?void 0:s.id;return P.useQuery({queryKey:[y.GET_ROLE_AND_PERMISSIONS,n],queryFn:()=>t(e,{action:y.GET_ROLE_AND_PERMISSIONS,data:{userId:n}}),enabled:!!n,staleTime:1/0})},ya=()=>{const e=k(),t=j(),[,s]=kt();return{onSave:async({page:r,blocks:a,needTranslations:i})=>{try{const l=await t(e,{action:"UPDATE_PAGE",data:{id:r,blocks:a,needTranslations:i}});return l.code==="PAGE_LOCKED"?!0:(s(c=>({...c,lastSaved:new Date().toISOString()})),l)}catch(l){return console.error(l),new Error("Failed to save blocks")}}}},Aa=()=>{const{data:e}=as(),t=k(),s=j();return{getPartialBlocks:h.useCallback(async()=>{const n={};for(const r of e??[])p.isEmpty(r==null?void 0:r.slug)&&(n[r.id]={type:r.pageType,name:p.startCase(r.name??r.slug),description:""});return n},[e]),getPartialBlockBlocks:h.useCallback(async n=>{if(!n)return[];try{const r=await s(t,{action:"GET_DRAFT_PAGE",data:{id:n,draft:!0,editor:!1}});return p.filter(r.blocks,a=>p.has(a,"_id"))}catch(r){return console.error(r),[]}},[s,t])}},Ta=h.lazy(()=>Promise.resolve().then(()=>require("./ai-panel-content-Cn3SA_Sr.cjs"))),Hs="ask-ai",Sa=({className:e="h-full w-full"})=>o.jsx("svg",{className:e,viewBox:"0 0 256 256",fill:"currentColor",children:o.jsx("path",{d:"m198.39 128.986-52.16-19.216-19.216-52.16a16 16 0 0 0-30.028 0L77.77 109.77l-52.16 19.216a16 16 0 0 0 0 30.028l52.16 19.216 19.216 52.16a16 16 0 0 0 30.028 0l19.216-52.16 52.16-19.216a16 16 0 0 0 0-30.028m-57.69 34.23a15.97 15.97 0 0 0-9.483 9.483l-19.22 52.152-19.214-52.15a15.97 15.97 0 0 0-9.482-9.484l-52.152-19.22 52.15-19.214a15.97 15.97 0 0 0 9.484-9.482l19.22-52.152 19.214 52.15a15.97 15.97 0 0 0 9.482 9.484l52.152 19.22ZM144 40a8 8 0 0 1 8-8h16V16a8 8 0 0 1 16 0v16h16a8 8 0 0 1 0 16h-16v16a8 8 0 0 1-16 0V48h-16a8 8 0 0 1-8-8m104 48a8 8 0 0 1-8 8h-8v8a8 8 0 0 1-16 0v-8h-8a8 8 0 0 1 0-16h8v-8a8 8 0 0 1 16 0v8h8a8 8 0 0 1 8 8"})}),Pa=({isActive:e,show:t})=>_.useChaiFeatureFlag("enable-ai-chat-panel")?o.jsx(m.Button,{size:"icon",onClick:t,variant:e?"default":"ghost",children:o.jsx(Sa,{className:"h-4 w-4"})}):null,xa={id:Hs,label:"AI Assistant",button:Pa,panel:Ta,position:"top"},_a=h.lazy(()=>Promise.resolve().then(()=>require("./lang-panel-dc9uBMtE.cjs"))),va=({isActive:e,show:t})=>{const{data:s}=ye();return!p.has(s,"languages")||!p.get(s,"languages",[]).length?null:o.jsx(m.Button,{size:"sm",onClick:t,variant:e?"default":"ghost",children:o.jsx(w.LanguagesIcon,{className:"h-4 w-4"})})},zs="lang",wa={id:zs,label:"Languages",position:"top",panel:_a,button:va,view:"modal",width:400},ba=h.lazy(()=>Promise.resolve().then(()=>require("./seo-panel-CUqtdGoF.cjs"))),$s="seo",Ca=({isActive:e,show:t})=>{const{data:s}=X(),n=Us(s==null?void 0:s.pageType);return!p.has(n,"hasSlug")||!n.hasSlug?null:o.jsx(m.Button,{size:"icon",className:"my-1 p-0",onClick:t,variant:e?"default":"ghost",children:o.jsxs("svg",{stroke:"currentColor",fill:"none",style:{height:"20px",width:"20px"},strokeWidth:"2",viewBox:"0 0 24 24",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M7 8h-3a1 1 0 0 0 -1 1v2a1 1 0 0 0 1 1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-3"}),o.jsx("path",{d:"M14 16h-4v-8h4"}),o.jsx("path",{d:"M11 12h2"}),o.jsx("path",{d:"M17 8m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]})})},Ia={id:$s,label:"SEO",panel:ba,button:Ca,position:"top",width:600,view:"modal"},Ws="user-info",Na=()=>{const{t:e}=_.useTranslation(),{user:t,logout:s}=gt(),n=se("onLogout",p.noop);return t?o.jsxs(m.HoverCard,{children:[o.jsx(m.HoverCardTrigger,{asChild:!0,children:o.jsx(m.Button,{variant:"ghost",className:"text-sm font-medium",children:o.jsx(w.User,{className:"h-4 w-4"})})}),o.jsxs(m.HoverCardContent,{className:"w-auto space-y-2 p-4",children:[o.jsx("div",{className:"text-sm font-medium",children:t.name??t.email}),o.jsx("div",{className:"text-xs text-muted-foreground",children:t.email}),o.jsxs(m.AlertDialog,{children:[o.jsx(m.AlertDialogTrigger,{asChild:!0,children:o.jsx(m.Button,{variant:"outline",size:"sm",className:"w-full",children:e("Logout")})}),o.jsxs(m.AlertDialogContent,{children:[o.jsxs(m.AlertDialogHeader,{children:[o.jsx(m.AlertDialogTitle,{children:e("Are you sure you want to logout?")}),o.jsx(m.AlertDialogDescription,{children:e("You will be redirected to the login page.")})]}),o.jsxs(m.AlertDialogFooter,{children:[o.jsx(m.AlertDialogCancel,{children:e("Cancel")}),o.jsx(m.AlertDialogAction,{onClick:()=>{s(),p.isFunction(n)&&n()},children:e("Logout")})]})]})]})]})]}):null},La={id:Ws,label:"User Info",button:Na,position:"bottom"},ja=()=>{_.registerChaiSidebarPanel($s,Ia),_.registerChaiSidebarPanel(zs,wa),_.registerChaiSidebarPanel(Ws,La),_.registerChaiSidebarPanel(Hs,xa)};var b={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return ys(this.context.count)},getNextContextId(){return ys(this.context.count++)}};function ys(e){const t=String(e),s=t.length-1;return b.context.id+(s?String.fromCharCode(96+s):"")+t}function He(e){b.context=e}var Ys=!1,ka=(e,t)=>e===t,_t=Symbol("solid-proxy"),Js=typeof Proxy=="function",ls=Symbol("solid-track"),vt={equals:ka},Xs=on,fe=1,wt=2,Zs={owned:null,cleanups:null,context:null,owner:null},Ft={},D=null,qt=null,Da=null,B=null,J=null,ce=null,Rt=0;function ge(e,t){const s=B,n=D,r=e.length===0,a=t===void 0?n:t,i=r?Zs:{owned:null,cleanups:null,context:a?a.context:null,owner:a},l=r?e:()=>e(()=>Y(()=>Je(i)));D=i,B=null;try{return ae(l,!0)}finally{B=s,D=n}}function V(e,t){t=t?Object.assign({},vt,t):vt;const s={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},n=r=>(typeof r=="function"&&(r=r(s.value)),an(s,r));return[rn.bind(s),n]}function en(e,t,s){const n=Mt(e,t,!0,fe);Ve(n)}function me(e,t,s){const n=Mt(e,t,!1,fe);Ve(n)}function cs(e,t,s){Xs=za;const n=Mt(e,t,!1,fe);(!s||!s.render)&&(n.user=!0),ce?ce.push(n):Ve(n)}function $(e,t,s){s=s?Object.assign({},vt,s):vt;const n=Mt(e,t,!0,0);return n.observers=null,n.observerSlots=null,n.comparator=s.equals||void 0,Ve(n),rn.bind(n)}function Oa(e){return e&&typeof e=="object"&&"then"in e}function Ga(e,t,s){let n,r,a;n=!0,r=e,a={};let i=null,l=Ft,c=null,u=!1,f="initialValue"in a,d=typeof n=="function"&&$(n);const g=new Set,[E,S]=(a.storage||V)(a.initialValue),[x,A]=V(void 0),[T,C]=V(void 0,{equals:!1}),[N,R]=V(f?"ready":"unresolved");b.context&&(c=b.getNextContextId(),a.ssrLoadFrom==="initial"?l=a.initialValue:b.load&&b.has(c)&&(l=b.load(c)));function K(I,L,W,H){return i===I&&(i=null,H!==void 0&&(f=!0),(I===l||L===l)&&a.onHydrated&&queueMicrotask(()=>a.onHydrated(H,{value:L})),l=Ft,O(L,W)),L}function O(I,L){ae(()=>{L===void 0&&S(()=>I),R(L!==void 0?"errored":f?"ready":"unresolved"),A(L);for(const W of g.keys())W.decrement();g.clear()},!1)}function ie(){const I=Va,L=E(),W=x();if(W!==void 0&&!i)throw W;return B&&B.user,L}function oe(I=!0){if(I!==!1&&u)return;u=!1;const L=d?d():n;if(L==null||L===!1){K(i,Y(E));return}let W;const H=l!==Ft?l:Y(()=>{try{return r(L,{value:E(),refetching:I})}catch(ne){W=ne}});if(W!==void 0){K(i,void 0,Pt(W),L);return}else if(!Oa(H))return K(i,H,void 0,L),H;return i=H,"v"in H?(H.s===1?K(i,H.v,void 0,L):K(i,void 0,Pt(H.v),L),H):(u=!0,queueMicrotask(()=>u=!1),ae(()=>{R(f?"refreshing":"pending"),C()},!1),H.then(ne=>K(H,ne,void 0,L),ne=>K(H,void 0,Pt(ne),L)))}Object.defineProperties(ie,{state:{get:()=>N()},error:{get:()=>x()},loading:{get(){const I=N();return I==="pending"||I==="refreshing"}},latest:{get(){if(!f)return ie();const I=x();if(I&&!i)throw I;return E()}}});let q=D;return d?en(()=>(q=D,oe(!1))):oe(!1),[ie,{refetch:I=>sn(q,()=>oe(I)),mutate:S}]}function Ra(e){return ae(e,!1)}function Y(e){if(B===null)return e();const t=B;B=null;try{return e()}finally{B=t}}function Ma(e,t,s){const n=Array.isArray(e);let r,a=s&&s.defer;return i=>{let l;if(n){l=Array(e.length);for(let u=0;u<e.length;u++)l[u]=e[u]()}else l=e();if(a)return a=!1,i;const c=Y(()=>t(l,r,i));return r=l,c}}function tn(e){cs(()=>Y(e))}function qe(e){return D===null||(D.cleanups===null?D.cleanups=[e]:D.cleanups.push(e)),e}function As(){return D}function sn(e,t){const s=D,n=B;D=e,B=null;try{return ae(t,!0)}catch(r){us(r)}finally{D=s,B=n}}function Ba(e){const t=B,s=D;return Promise.resolve().then(()=>{B=t,D=s;let n;return ae(e,!1),B=D=null,n?n.done:void 0})}var[Ua,$o]=V(!1);function Fa(){return[Ua,Ba]}function qa(e,t){const s=Symbol("context");return{id:s,Provider:$a(s),defaultValue:e}}function Ka(e){let t;return D&&D.context&&(t=D.context[e.id])!==void 0?t:e.defaultValue}function nn(e){const t=$(e),s=$(()=>Ht(t()));return s.toArray=()=>{const n=s();return Array.isArray(n)?n:n!=null?[n]:[]},s}var Va;function rn(){if(this.sources&&this.state)if(this.state===fe)Ve(this);else{const e=J;J=null,ae(()=>Ct(this),!1),J=e}if(B){const e=this.observers?this.observers.length:0;B.sources?(B.sources.push(this),B.sourceSlots.push(e)):(B.sources=[this],B.sourceSlots=[e]),this.observers?(this.observers.push(B),this.observerSlots.push(B.sources.length-1)):(this.observers=[B],this.observerSlots=[B.sources.length-1])}return this.value}function an(e,t,s){let n=e.value;return(!e.comparator||!e.comparator(n,t))&&(e.value=t,e.observers&&e.observers.length&&ae(()=>{for(let r=0;r<e.observers.length;r+=1){const a=e.observers[r],i=qt&&qt.running;i&&qt.disposed.has(a),(i?!a.tState:!a.state)&&(a.pure?J.push(a):ce.push(a),a.observers&&ln(a)),i||(a.state=fe)}if(J.length>1e6)throw J=[],new Error},!1)),t}function Ve(e){if(!e.fn)return;Je(e);const t=Rt;Qa(e,e.value,t)}function Qa(e,t,s){let n;const r=D,a=B;B=D=e;try{n=e.fn(t)}catch(i){return e.pure&&(e.state=fe,e.owned&&e.owned.forEach(Je),e.owned=null),e.updatedAt=s+1,us(i)}finally{B=a,D=r}(!e.updatedAt||e.updatedAt<=s)&&(e.updatedAt!=null&&"observers"in e?an(e,n):e.value=n,e.updatedAt=s)}function Mt(e,t,s,n=fe,r){const a={fn:e,state:n,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:D,context:D?D.context:null,pure:s};return D===null||D!==Zs&&(D.owned?D.owned.push(a):D.owned=[a]),a}function bt(e){if(e.state===0)return;if(e.state===wt)return Ct(e);if(e.suspense&&Y(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<Rt);)e.state&&t.push(e);for(let s=t.length-1;s>=0;s--)if(e=t[s],e.state===fe)Ve(e);else if(e.state===wt){const n=J;J=null,ae(()=>Ct(e,t[0]),!1),J=n}}function ae(e,t){if(J)return e();let s=!1;t||(J=[]),ce?s=!0:ce=[],Rt++;try{const n=e();return Ha(s),n}catch(n){s||(ce=null),J=null,us(n)}}function Ha(e){if(J&&(on(J),J=null),e)return;const t=ce;ce=null,t.length&&ae(()=>Xs(t),!1)}function on(e){for(let t=0;t<e.length;t++)bt(e[t])}function za(e){let t,s=0;for(t=0;t<e.length;t++){const n=e[t];n.user?e[s++]=n:bt(n)}if(b.context){if(b.count){b.effects||(b.effects=[]),b.effects.push(...e.slice(0,s));return}He()}for(b.effects&&(b.done||!b.count)&&(e=[...b.effects,...e],s+=b.effects.length,delete b.effects),t=0;t<s;t++)bt(e[t])}function Ct(e,t){e.state=0;for(let s=0;s<e.sources.length;s+=1){const n=e.sources[s];if(n.sources){const r=n.state;r===fe?n!==t&&(!n.updatedAt||n.updatedAt<Rt)&&bt(n):r===wt&&Ct(n,t)}}}function ln(e){for(let t=0;t<e.observers.length;t+=1){const s=e.observers[t];s.state||(s.state=wt,s.pure?J.push(s):ce.push(s),s.observers&&ln(s))}}function Je(e){let t;if(e.sources)for(;e.sources.length;){const s=e.sources.pop(),n=e.sourceSlots.pop(),r=s.observers;if(r&&r.length){const a=r.pop(),i=s.observerSlots.pop();n<r.length&&(a.sourceSlots[i]=n,r[n]=a,s.observerSlots[n]=i)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)Je(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)Je(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function Pt(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function us(e,t=D){throw Pt(e)}function Ht(e){if(typeof e=="function"&&!e.length)return Ht(e());if(Array.isArray(e)){const t=[];for(let s=0;s<e.length;s++){const n=Ht(e[s]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function $a(e,t){return function(n){let r;return me(()=>r=Y(()=>(D.context={...D.context,[e]:n.value},nn(()=>n.children))),void 0),r}}var zt=Symbol("fallback");function It(e){for(let t=0;t<e.length;t++)e[t]()}function Wa(e,t,s={}){let n=[],r=[],a=[],i=0,l=t.length>1?[]:null;return qe(()=>It(a)),()=>{let c=e()||[],u=c.length,f,d;return c[ls],Y(()=>{let E,S,x,A,T,C,N,R,K;if(u===0)i!==0&&(It(a),a=[],n=[],r=[],i=0,l&&(l=[])),s.fallback&&(n=[zt],r[0]=ge(O=>(a[0]=O,s.fallback())),i=1);else if(i===0){for(r=new Array(u),d=0;d<u;d++)n[d]=c[d],r[d]=ge(g);i=u}else{for(x=new Array(u),A=new Array(u),l&&(T=new Array(u)),C=0,N=Math.min(i,u);C<N&&n[C]===c[C];C++);for(N=i-1,R=u-1;N>=C&&R>=C&&n[N]===c[R];N--,R--)x[R]=r[N],A[R]=a[N],l&&(T[R]=l[N]);for(E=new Map,S=new Array(R+1),d=R;d>=C;d--)K=c[d],f=E.get(K),S[d]=f===void 0?-1:f,E.set(K,d);for(f=C;f<=N;f++)K=n[f],d=E.get(K),d!==void 0&&d!==-1?(x[d]=r[f],A[d]=a[f],l&&(T[d]=l[f]),d=S[d],E.set(K,d)):a[f]();for(d=C;d<u;d++)d in x?(r[d]=x[d],a[d]=A[d],l&&(l[d]=T[d],l[d](d))):r[d]=ge(g);r=r.slice(0,i=u),n=c.slice(0)}return r});function g(E){if(a[d]=E,l){const[S,x]=V(d);return l[d]=x,t(c[d],S)}return t(c[d])}}}function Ya(e,t,s={}){let n=[],r=[],a=[],i=[],l=0,c;return qe(()=>It(a)),()=>{const u=e()||[],f=u.length;return u[ls],Y(()=>{if(f===0)return l!==0&&(It(a),a=[],n=[],r=[],l=0,i=[]),s.fallback&&(n=[zt],r[0]=ge(g=>(a[0]=g,s.fallback())),l=1),r;for(n[0]===zt&&(a[0](),a=[],n=[],r=[],l=0),c=0;c<f;c++)c<n.length&&n[c]!==u[c]?i[c](()=>u[c]):c>=n.length&&(r[c]=ge(d));for(;c<n.length;c++)a[c]();return l=i.length=a.length=f,n=u.slice(0),r=r.slice(0,l)});function d(g){a[c]=g;const[E,S]=V(u[c]);return i[c]=S,t(E,c)}}}function ds(e,t){return Y(()=>e(t||{}))}function pt(){return!0}var $t={get(e,t,s){return t===_t?s:e.get(t)},has(e,t){return t===_t?!0:e.has(t)},set:pt,deleteProperty:pt,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:pt,deleteProperty:pt}},ownKeys(e){return e.keys()}};function Kt(e){return(e=typeof e=="function"?e():e)?e:{}}function Ja(){for(let e=0,t=this.length;e<t;++e){const s=this[e]();if(s!==void 0)return s}}function fs(...e){let t=!1;for(let i=0;i<e.length;i++){const l=e[i];t=t||!!l&&_t in l,e[i]=typeof l=="function"?(t=!0,$(l)):l}if(Js&&t)return new Proxy({get(i){for(let l=e.length-1;l>=0;l--){const c=Kt(e[l])[i];if(c!==void 0)return c}},has(i){for(let l=e.length-1;l>=0;l--)if(i in Kt(e[l]))return!0;return!1},keys(){const i=[];for(let l=0;l<e.length;l++)i.push(...Object.keys(Kt(e[l])));return[...new Set(i)]}},$t);const s={},n=Object.create(null);for(let i=e.length-1;i>=0;i--){const l=e[i];if(!l)continue;const c=Object.getOwnPropertyNames(l);for(let u=c.length-1;u>=0;u--){const f=c[u];if(f==="__proto__"||f==="constructor")continue;const d=Object.getOwnPropertyDescriptor(l,f);if(!n[f])n[f]=d.get?{enumerable:!0,configurable:!0,get:Ja.bind(s[f]=[d.get.bind(l)])}:d.value!==void 0?d:void 0;else{const g=s[f];g&&(d.get?g.push(d.get.bind(l)):d.value!==void 0&&g.push(()=>d.value))}}}const r={},a=Object.keys(n);for(let i=a.length-1;i>=0;i--){const l=a[i],c=n[l];c&&c.get?Object.defineProperty(r,l,c):r[l]=c?c.value:void 0}return r}function cn(e,...t){if(Js&&_t in e){const r=new Set(t.length>1?t.flat():t[0]),a=t.map(i=>new Proxy({get(l){return i.includes(l)?e[l]:void 0},has(l){return i.includes(l)&&l in e},keys(){return i.filter(l=>l in e)}},$t));return a.push(new Proxy({get(i){return r.has(i)?void 0:e[i]},has(i){return r.has(i)?!1:i in e},keys(){return Object.keys(e).filter(i=>!r.has(i))}},$t)),a}const s={},n=t.map(()=>({}));for(const r of Object.getOwnPropertyNames(e)){const a=Object.getOwnPropertyDescriptor(e,r),i=!a.get&&!a.set&&a.enumerable&&a.writable&&a.configurable;let l=!1,c=0;for(const u of t)u.includes(r)&&(l=!0,i?n[c][r]=a.value:Object.defineProperty(n[c],r,a)),++c;l||(i?s[r]=a.value:Object.defineProperty(s,r,a))}return[...n,s]}function un(e){let t,s;const n=r=>{const a=b.context;if(a){const[l,c]=V();b.count||(b.count=0),b.count++,(s||(s=e())).then(u=>{!b.done&&He(a),b.count--,c(()=>u.default),He()}),t=l}else if(!t){const[l]=Ga(()=>(s||(s=e())).then(c=>c.default));t=l}let i;return $(()=>(i=t())?Y(()=>{if(!a||b.done)return i(r);const l=b.context;He(a);const c=i(r);return He(l),c}):"")};return n.preload=()=>s||((s=e()).then(r=>t=()=>r.default),s),n}var Xa=0;function Za(){return b.context?b.getNextContextId():`cl-${Xa++}`}var dn=e=>`Stale read from <${e}>.`;function ei(e){const t="fallback"in e&&{fallback:()=>e.fallback};return $(Wa(()=>e.each,e.children,t||void 0))}function ti(e){const t="fallback"in e&&{fallback:()=>e.fallback};return $(Ya(()=>e.each,e.children,t||void 0))}function si(e){const t=e.keyed,s=$(()=>e.when,void 0,void 0),n=t?s:$(s,void 0,{equals:(r,a)=>!r==!a});return $(()=>{const r=n();if(r){const a=e.children;return typeof a=="function"&&a.length>0?Y(()=>a(t?r:()=>{if(!Y(n))throw dn("Show");return s()})):a}return e.fallback},void 0,void 0)}function ni(e){const t=nn(()=>e.children),s=$(()=>{const n=t(),r=Array.isArray(n)?n:[n];let a=()=>{};for(let i=0;i<r.length;i++){const l=i,c=r[i],u=a,f=$(()=>u()?void 0:c.when,void 0,void 0),d=c.keyed?f:$(f,void 0,{equals:(g,E)=>!g==!E});a=()=>u()||(d()?[l,f,c]:void 0)}return a});return $(()=>{const n=s()();if(!n)return e.fallback;const[r,a,i]=n,l=i.children;return typeof l=="function"&&l.length>0?Y(()=>l(i.keyed?a():()=>{var u;if(((u=Y(s)())==null?void 0:u[0])!==r)throw dn("Match");return a()})):l},void 0,void 0)}function ri(e){return e}var ai=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected"],ii=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline",...ai]),oi=new Set(["innerHTML","textContent","innerText","children"]),li=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),ci=Object.assign(Object.create(null),{class:"className",novalidate:{$:"noValidate",FORM:1},formnovalidate:{$:"formNoValidate",BUTTON:1,INPUT:1},ismap:{$:"isMap",IMG:1},nomodule:{$:"noModule",SCRIPT:1},playsinline:{$:"playsInline",VIDEO:1},readonly:{$:"readOnly",INPUT:1,TEXTAREA:1}});function ui(e,t){const s=ci[e];return typeof s=="object"?s[t]?s.$:void 0:s}var di=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),fi=new Set(["altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view","vkern"]),hi={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},gi=e=>$(()=>e());function mi(e,t,s){let n=s.length,r=t.length,a=n,i=0,l=0,c=t[r-1].nextSibling,u=null;for(;i<r||l<a;){if(t[i]===s[l]){i++,l++;continue}for(;t[r-1]===s[a-1];)r--,a--;if(r===i){const f=a<n?l?s[l-1].nextSibling:s[a-l]:c;for(;l<a;)e.insertBefore(s[l++],f)}else if(a===l)for(;i<r;)(!u||!u.has(t[i]))&&t[i].remove(),i++;else if(t[i]===s[a-1]&&s[l]===t[r-1]){const f=t[--r].nextSibling;e.insertBefore(s[l++],t[i++].nextSibling),e.insertBefore(s[--a],f),t[r]=s[a]}else{if(!u){u=new Map;let d=l;for(;d<a;)u.set(s[d],d++)}const f=u.get(t[i]);if(f!=null)if(l<f&&f<a){let d=i,g=1,E;for(;++d<r&&d<a&&!((E=u.get(t[d]))==null||E!==f+g);)g++;if(g>f-l){const S=t[i];for(;l<f;)e.insertBefore(s[l++],S)}else e.replaceChild(s[l++],t[i++])}else i++;else t[i++].remove()}}}var We="_$DX_DELEGATE";function fn(e,t,s,n={}){let r;return ge(a=>{r=a,t===document?e():Lt(t,e(),t.firstChild?null:void 0,s)},n.owner),()=>{r(),t.textContent=""}}function Ei(e,t,s,n){let r;const a=()=>{const l=document.createElement("template");return l.innerHTML=e,l.content.firstChild},i=()=>(r||(r=a())).cloneNode(!0);return i.cloneNode=i,i}function hn(e,t=window.document){const s=t[We]||(t[We]=new Set);for(let n=0,r=e.length;n<r;n++){const a=e[n];s.has(a)||(s.add(a),t.addEventListener(a,yn))}}function pi(e=window.document){if(e[We]){for(let t of e[We].keys())e.removeEventListener(t,yn);delete e[We]}}function Nt(e,t,s){xe(e)||(s==null?e.removeAttribute(t):e.setAttribute(t,s))}function yi(e,t,s,n){xe(e)||(n==null?e.removeAttributeNS(t,s):e.setAttributeNS(t,s,n))}function Ai(e,t,s){xe(e)||(s?e.setAttribute(t,""):e.removeAttribute(t))}function gn(e,t){xe(e)||(t==null?e.removeAttribute("class"):e.className=t)}function mn(e,t,s,n){if(n)Array.isArray(s)?(e[`$$${t}`]=s[0],e[`$$${t}Data`]=s[1]):e[`$$${t}`]=s;else if(Array.isArray(s)){const r=s[0];e.addEventListener(t,s[0]=a=>r.call(e,s[1],a))}else e.addEventListener(t,s,typeof s!="function"&&s)}function Ti(e,t,s={}){const n=Object.keys(t||{}),r=Object.keys(s);let a,i;for(a=0,i=r.length;a<i;a++){const l=r[a];!l||l==="undefined"||t[l]||(Ts(e,l,!1),delete s[l])}for(a=0,i=n.length;a<i;a++){const l=n[a],c=!!t[l];!l||l==="undefined"||s[l]===c||!c||(Ts(e,l,!0),s[l]=c)}return s}function Si(e,t,s){if(!t)return s?Nt(e,"style"):t;const n=e.style;if(typeof t=="string")return n.cssText=t;typeof s=="string"&&(n.cssText=s=void 0),s||(s={}),t||(t={});let r,a;for(a in s)t[a]==null&&n.removeProperty(a),delete s[a];for(a in t)r=t[a],r!==s[a]&&(n.setProperty(a,r),s[a]=r);return s}function En(e,t={},s,n){const r={};return n||me(()=>r.children=Xe(e,t.children,r.children)),me(()=>typeof t.ref=="function"&&pn(t.ref,e)),me(()=>Pi(e,t,s,!0,r,!0)),r}function pn(e,t,s){return Y(()=>e(t,s))}function Lt(e,t,s,n){if(s!==void 0&&!n&&(n=[]),typeof t!="function")return Xe(e,t,n,s);me(r=>Xe(e,t(),r,s),n)}function Pi(e,t,s,n,r={},a=!1){t||(t={});for(const i in r)if(!(i in t)){if(i==="children")continue;r[i]=Ss(e,i,null,r[i],s,a,t)}for(const i in t){if(i==="children")continue;const l=t[i];r[i]=Ss(e,i,l,r[i],s,a,t)}}function xi(e){let t,s;return!xe()||!(t=b.registry.get(s=vi()))?e():(b.completed&&b.completed.add(t),b.registry.delete(s),t)}function xe(e){return!!b.context&&!b.done&&(!e||e.isConnected)}function _i(e){return e.toLowerCase().replace(/-([a-z])/g,(t,s)=>s.toUpperCase())}function Ts(e,t,s){const n=t.trim().split(/\s+/);for(let r=0,a=n.length;r<a;r++)e.classList.toggle(n[r],s)}function Ss(e,t,s,n,r,a,i){let l,c,u,f,d;if(t==="style")return Si(e,s,n);if(t==="classList")return Ti(e,s,n);if(s===n)return n;if(t==="ref")a||s(e);else if(t.slice(0,3)==="on:"){const g=t.slice(3);n&&e.removeEventListener(g,n,typeof n!="function"&&n),s&&e.addEventListener(g,s,typeof s!="function"&&s)}else if(t.slice(0,10)==="oncapture:"){const g=t.slice(10);n&&e.removeEventListener(g,n,!0),s&&e.addEventListener(g,s,!0)}else if(t.slice(0,2)==="on"){const g=t.slice(2).toLowerCase(),E=di.has(g);if(!E&&n){const S=Array.isArray(n)?n[0]:n;e.removeEventListener(g,S)}(E||s)&&(mn(e,g,s,E),E&&hn([g]))}else if(t.slice(0,5)==="attr:")Nt(e,t.slice(5),s);else if(t.slice(0,5)==="bool:")Ai(e,t.slice(5),s);else if((d=t.slice(0,5)==="prop:")||(u=oi.has(t))||!r&&((f=ui(t,e.tagName))||(c=ii.has(t)))||(l=e.nodeName.includes("-")||"is"in i)){if(d)t=t.slice(5),c=!0;else if(xe(e))return s;t==="class"||t==="className"?gn(e,s):l&&!c&&!u?e[_i(t)]=s:e[f||t]=s}else{const g=r&&t.indexOf(":")>-1&&hi[t.split(":")[0]];g?yi(e,g,t,s):Nt(e,li[t]||t,s)}return s}function yn(e){if(b.registry&&b.events&&b.events.find(([c,u])=>u===e))return;let t=e.target;const s=`$$${e.type}`,n=e.target,r=e.currentTarget,a=c=>Object.defineProperty(e,"target",{configurable:!0,value:c}),i=()=>{const c=t[s];if(c&&!t.disabled){const u=t[`${s}Data`];if(u!==void 0?c.call(t,u,e):c.call(t,e),e.cancelBubble)return}return t.host&&typeof t.host!="string"&&!t.host._$host&&t.contains(e.target)&&a(t.host),!0},l=()=>{for(;i()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),b.registry&&!b.done&&(b.done=_$HY.done=!0),e.composedPath){const c=e.composedPath();a(c[0]);for(let u=0;u<c.length-2&&(t=c[u],!!i());u++){if(t._$host){t=t._$host,l();break}if(t.parentNode===r)break}}else l();a(n)}function Xe(e,t,s,n,r){const a=xe(e);if(a){!s&&(s=[...e.childNodes]);let c=[];for(let u=0;u<s.length;u++){const f=s[u];f.nodeType===8&&f.data.slice(0,2)==="!$"?f.remove():c.push(f)}s=c}for(;typeof s=="function";)s=s();if(t===s)return s;const i=typeof t,l=n!==void 0;if(e=l&&s[0]&&s[0].parentNode||e,i==="string"||i==="number"){if(a||i==="number"&&(t=t.toString(),t===s))return s;if(l){let c=s[0];c&&c.nodeType===3?c.data!==t&&(c.data=t):c=document.createTextNode(t),s=ve(e,s,n,c)}else s!==""&&typeof s=="string"?s=e.firstChild.data=t:s=e.textContent=t}else if(t==null||i==="boolean"){if(a)return s;s=ve(e,s,n)}else{if(i==="function")return me(()=>{let c=t();for(;typeof c=="function";)c=c();s=Xe(e,c,s,n)}),()=>s;if(Array.isArray(t)){const c=[],u=s&&Array.isArray(s);if(Wt(c,t,s,r))return me(()=>s=Xe(e,c,s,n,!0)),()=>s;if(a){if(!c.length)return s;if(n===void 0)return s=[...e.childNodes];let f=c[0];if(f.parentNode!==e)return s;const d=[f];for(;(f=f.nextSibling)!==n;)d.push(f);return s=d}if(c.length===0){if(s=ve(e,s,n),l)return s}else u?s.length===0?Ps(e,c,n):mi(e,s,c):(s&&ve(e),Ps(e,c));s=c}else if(t.nodeType){if(a&&t.parentNode)return s=l?[t]:t;if(Array.isArray(s)){if(l)return s=ve(e,s,n,t);ve(e,s,null,t)}else s==null||s===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);s=t}}return s}function Wt(e,t,s,n){let r=!1;for(let a=0,i=t.length;a<i;a++){let l=t[a],c=s&&s[e.length],u;if(!(l==null||l===!0||l===!1))if((u=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))r=Wt(e,l,c)||r;else if(u==="function")if(n){for(;typeof l=="function";)l=l();r=Wt(e,Array.isArray(l)?l:[l],Array.isArray(c)?c:[c])||r}else e.push(l),r=!0;else{const f=String(l);c&&c.nodeType===3&&c.data===f?e.push(c):e.push(document.createTextNode(f))}}return r}function Ps(e,t,s=null){for(let n=0,r=t.length;n<r;n++)e.insertBefore(t[n],s)}function ve(e,t,s,n){if(s===void 0)return e.textContent="";const r=n||document.createTextNode("");if(t.length){let a=!1;for(let i=t.length-1;i>=0;i--){const l=t[i];if(r!==l){const c=l.parentNode===e;!a&&!i?c?e.replaceChild(r,l):e.insertBefore(r,s):c&&l.remove()}else a=!0}}else e.insertBefore(r,s);return[r]}function vi(){return b.getNextContextId()}var wi="http://www.w3.org/2000/svg";function An(e,t=!1){return t?document.createElementNS(wi,e):document.createElement(e)}function bi(e){const{useShadow:t}=e,s=document.createTextNode(""),n=()=>e.mount||document.body,r=As();let a,i=!!b.context;return cs(()=>{i&&(As().user=i=!1),a||(a=sn(r,()=>$(()=>e.children)));const l=n();if(l instanceof HTMLHeadElement){const[c,u]=V(!1),f=()=>u(!0);ge(d=>Lt(l,()=>c()?d():a(),null)),qe(f)}else{const c=An(e.isSVG?"g":"div",e.isSVG),u=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return s.parentNode},configurable:!0}),Lt(u,a),l.appendChild(c),e.ref&&e.ref(c),qe(()=>l.removeChild(c))}},void 0,{render:!i}),s}function Ci(e,t){const s=$(e);return $(()=>{const n=s();switch(typeof n){case"function":return Y(()=>n(t));case"string":const r=fi.has(n),a=b.context?xi():An(n,r);return En(a,t,r),a}})}function Ii(e){const[,t]=cn(e,["component"]);return Ci(()=>e.component,t)}var Ni=class{constructor(){this.keyToValue=new Map,this.valueToKey=new Map}set(e,t){this.keyToValue.set(e,t),this.valueToKey.set(t,e)}getByKey(e){return this.keyToValue.get(e)}getByValue(e){return this.valueToKey.get(e)}clear(){this.keyToValue.clear(),this.valueToKey.clear()}},Tn=class{constructor(e){this.generateIdentifier=e,this.kv=new Ni}register(e,t){this.kv.getByValue(e)||(t||(t=this.generateIdentifier(e)),this.kv.set(t,e))}clear(){this.kv.clear()}getIdentifier(e){return this.kv.getByValue(e)}getValue(e){return this.kv.getByKey(e)}},Li=class extends Tn{constructor(){super(e=>e.name),this.classToAllowedProps=new Map}register(e,t){typeof t=="object"?(t.allowProps&&this.classToAllowedProps.set(e,t.allowProps),super.register(e,t.identifier)):super.register(e,t)}getAllowedProps(e){return this.classToAllowedProps.get(e)}};function ji(e){if("values"in Object)return Object.values(e);const t=[];for(const s in e)e.hasOwnProperty(s)&&t.push(e[s]);return t}function ki(e,t){const s=ji(e);if("find"in s)return s.find(t);const n=s;for(let r=0;r<n.length;r++){const a=n[r];if(t(a))return a}}function Ke(e,t){Object.entries(e).forEach(([s,n])=>t(n,s))}function xt(e,t){return e.indexOf(t)!==-1}function xs(e,t){for(let s=0;s<e.length;s++){const n=e[s];if(t(n))return n}}var Di=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return ki(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},Oi=e=>Object.prototype.toString.call(e).slice(8,-1),Sn=e=>typeof e>"u",Gi=e=>e===null,Ze=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,Yt=e=>Ze(e)&&Object.keys(e).length===0,Ee=e=>Array.isArray(e),Ri=e=>typeof e=="string",Mi=e=>typeof e=="number"&&!isNaN(e),Bi=e=>typeof e=="boolean",Ui=e=>e instanceof RegExp,et=e=>e instanceof Map,tt=e=>e instanceof Set,Pn=e=>Oi(e)==="Symbol",Fi=e=>e instanceof Date&&!isNaN(e.valueOf()),qi=e=>e instanceof Error,_s=e=>typeof e=="number"&&isNaN(e),Ki=e=>Bi(e)||Gi(e)||Sn(e)||Mi(e)||Ri(e)||Pn(e),Vi=e=>typeof e=="bigint",Qi=e=>e===1/0||e===-1/0,Hi=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),zi=e=>e instanceof URL,xn=e=>e.replace(/\./g,"\\."),Vt=e=>e.map(String).map(xn).join("."),Ye=e=>{const t=[];let s="";for(let r=0;r<e.length;r++){let a=e.charAt(r);if(a==="\\"&&e.charAt(r+1)==="."){s+=".",r++;continue}if(a==="."){t.push(s),s="";continue}s+=a}const n=s;return t.push(n),t};function re(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var _n=[re(Sn,"undefined",()=>null,()=>{}),re(Vi,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),re(Fi,"Date",e=>e.toISOString(),e=>new Date(e)),re(qi,"Error",(e,t)=>{const s={name:e.name,message:e.message};return t.allowedErrorProps.forEach(n=>{s[n]=e[n]}),s},(e,t)=>{const s=new Error(e.message);return s.name=e.name,s.stack=e.stack,t.allowedErrorProps.forEach(n=>{s[n]=e[n]}),s}),re(Ui,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),s=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,s)}),re(tt,"set",e=>[...e.values()],e=>new Set(e)),re(et,"map",e=>[...e.entries()],e=>new Map(e)),re(e=>_s(e)||Qi(e),"number",e=>_s(e)?"NaN":e>0?"Infinity":"-Infinity",Number),re(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),re(zi,"URL",e=>e.toString(),e=>new URL(e))];function Bt(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var vn=Bt((e,t)=>Pn(e)?!!t.symbolRegistry.getIdentifier(e):!1,(e,t)=>["symbol",t.symbolRegistry.getIdentifier(e)],e=>e.description,(e,t,s)=>{const n=s.symbolRegistry.getValue(t[1]);if(!n)throw new Error("Trying to deserialize unknown symbol");return n}),$i=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),wn=Bt(Hi,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const s=$i[t[1]];if(!s)throw new Error("Trying to deserialize unknown typed array");return new s(e)});function bn(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var Cn=Bt(bn,(e,t)=>["class",t.classRegistry.getIdentifier(e.constructor)],(e,t)=>{const s=t.classRegistry.getAllowedProps(e.constructor);if(!s)return{...e};const n={};return s.forEach(r=>{n[r]=e[r]}),n},(e,t,s)=>{const n=s.classRegistry.getValue(t[1]);if(!n)throw new Error(`Trying to deserialize unknown class '${t[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(n.prototype),e)}),In=Bt((e,t)=>!!t.customTransformerRegistry.findApplicable(e),(e,t)=>["custom",t.customTransformerRegistry.findApplicable(e).name],(e,t)=>t.customTransformerRegistry.findApplicable(e).serialize(e),(e,t,s)=>{const n=s.customTransformerRegistry.findByName(t[1]);if(!n)throw new Error("Trying to deserialize unknown custom value");return n.deserialize(e)}),Wi=[Cn,vn,In,wn],vs=(e,t)=>{const s=xs(Wi,r=>r.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation(e,t)};const n=xs(_n,r=>r.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation}},Nn={};_n.forEach(e=>{Nn[e.annotation]=e});var Yi=(e,t,s)=>{if(Ee(t))switch(t[0]){case"symbol":return vn.untransform(e,t,s);case"class":return Cn.untransform(e,t,s);case"custom":return In.untransform(e,t,s);case"typed-array":return wn.untransform(e,t,s);default:throw new Error("Unknown transformation: "+t)}else{const n=Nn[t];if(!n)throw new Error("Unknown transformation: "+t);return n.untransform(e,s)}},we=(e,t)=>{if(t>e.size)throw new Error("index out of bounds");const s=e.keys();for(;t>0;)s.next(),t--;return s.next().value};function Ln(e){if(xt(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(xt(e,"prototype"))throw new Error("prototype is not allowed as a property");if(xt(e,"constructor"))throw new Error("constructor is not allowed as a property")}var Ji=(e,t)=>{Ln(t);for(let s=0;s<t.length;s++){const n=t[s];if(tt(e))e=we(e,+n);else if(et(e)){const r=+n,a=+t[++s]==0?"key":"value",i=we(e,r);switch(a){case"key":e=i;break;case"value":e=e.get(i);break}}else e=e[n]}return e},Jt=(e,t,s)=>{if(Ln(t),t.length===0)return s(e);let n=e;for(let a=0;a<t.length-1;a++){const i=t[a];if(Ee(n)){const l=+i;n=n[l]}else if(Ze(n))n=n[i];else if(tt(n)){const l=+i;n=we(n,l)}else if(et(n)){if(a===t.length-2)break;const c=+i,u=+t[++a]==0?"key":"value",f=we(n,c);switch(u){case"key":n=f;break;case"value":n=n.get(f);break}}}const r=t[t.length-1];if(Ee(n)?n[+r]=s(n[+r]):Ze(n)&&(n[r]=s(n[r])),tt(n)){const a=we(n,+r),i=s(a);a!==i&&(n.delete(a),n.add(i))}if(et(n)){const a=+t[t.length-2],i=we(n,a);switch(+r==0?"key":"value"){case"key":{const c=s(i);n.set(c,n.get(i)),c!==i&&n.delete(i);break}case"value":{n.set(i,s(n.get(i)));break}}}return e};function Xt(e,t,s=[]){if(!e)return;if(!Ee(e)){Ke(e,(a,i)=>Xt(a,t,[...s,...Ye(i)]));return}const[n,r]=e;r&&Ke(r,(a,i)=>{Xt(a,t,[...s,...Ye(i)])}),t(n,s)}function Xi(e,t,s){return Xt(t,(n,r)=>{e=Jt(e,r,a=>Yi(a,n,s))}),e}function Zi(e,t){function s(n,r){const a=Ji(e,Ye(r));n.map(Ye).forEach(i=>{e=Jt(e,i,()=>a)})}if(Ee(t)){const[n,r]=t;n.forEach(a=>{e=Jt(e,Ye(a),()=>e)}),r&&Ke(r,s)}else Ke(t,s);return e}var eo=(e,t)=>Ze(e)||Ee(e)||et(e)||tt(e)||bn(e,t);function to(e,t,s){const n=s.get(e);n?n.push(t):s.set(e,[t])}function so(e,t){const s={};let n;return e.forEach(r=>{if(r.length<=1)return;t||(r=r.map(l=>l.map(String)).sort((l,c)=>l.length-c.length));const[a,...i]=r;a.length===0?n=i.map(Vt):s[Vt(a)]=i.map(Vt)}),n?Yt(s)?[n]:[n,s]:Yt(s)?void 0:s}var jn=(e,t,s,n,r=[],a=[],i=new Map)=>{const l=Ki(e);if(!l){to(e,r,t);const E=i.get(e);if(E)return n?{transformedValue:null}:E}if(!eo(e,s)){const E=vs(e,s),S=E?{transformedValue:E.value,annotations:[E.type]}:{transformedValue:e};return l||i.set(e,S),S}if(xt(a,e))return{transformedValue:null};const c=vs(e,s),u=(c==null?void 0:c.value)??e,f=Ee(u)?[]:{},d={};Ke(u,(E,S)=>{if(S==="__proto__"||S==="constructor"||S==="prototype")throw new Error(`Detected property ${S}. This is a prototype pollution risk, please remove it from your object.`);const x=jn(E,t,s,n,[...r,S],[...a,e],i);f[S]=x.transformedValue,Ee(x.annotations)?d[S]=x.annotations:Ze(x.annotations)&&Ke(x.annotations,(A,T)=>{d[xn(S)+"."+T]=A})});const g=Yt(d)?{transformedValue:f,annotations:c?[c.type]:void 0}:{transformedValue:f,annotations:c?[c.type,d]:d};return l||i.set(e,g),g};function kn(e){return Object.prototype.toString.call(e).slice(8,-1)}function ws(e){return kn(e)==="Array"}function no(e){if(kn(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function ro(e,t,s,n,r){const a={}.propertyIsEnumerable.call(n,t)?"enumerable":"nonenumerable";a==="enumerable"&&(e[t]=s),r&&a==="nonenumerable"&&Object.defineProperty(e,t,{value:s,enumerable:!1,writable:!0,configurable:!0})}function Zt(e,t={}){if(ws(e))return e.map(r=>Zt(r,t));if(!no(e))return e;const s=Object.getOwnPropertyNames(e),n=Object.getOwnPropertySymbols(e);return[...s,...n].reduce((r,a)=>{if(ws(t.props)&&!t.props.includes(a))return r;const i=e[a],l=Zt(i,t);return ro(r,a,l,e,t.nonenumerable),r},{})}var U=class{constructor({dedupe:e=!1}={}){this.classRegistry=new Li,this.symbolRegistry=new Tn(t=>t.description??""),this.customTransformerRegistry=new Di,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,s=jn(e,t,this,this.dedupe),n={json:s.transformedValue};s.annotations&&(n.meta={...n.meta,values:s.annotations});const r=so(t,this.dedupe);return r&&(n.meta={...n.meta,referentialEqualities:r}),n}deserialize(e){const{json:t,meta:s}=e;let n=Zt(t);return s!=null&&s.values&&(n=Xi(n,s.values,this)),s!=null&&s.referentialEqualities&&(n=Zi(n,s.referentialEqualities)),n}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e))}registerClass(e,t){this.classRegistry.register(e,t)}registerSymbol(e,t){this.symbolRegistry.register(e,t)}registerCustom(e,t){this.customTransformerRegistry.register({name:t,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}};U.defaultInstance=new U;U.serialize=U.defaultInstance.serialize.bind(U.defaultInstance);U.deserialize=U.defaultInstance.deserialize.bind(U.defaultInstance);U.stringify=U.defaultInstance.stringify.bind(U.defaultInstance);U.parse=U.defaultInstance.parse.bind(U.defaultInstance);U.registerClass=U.defaultInstance.registerClass.bind(U.defaultInstance);U.registerSymbol=U.defaultInstance.registerSymbol.bind(U.defaultInstance);U.registerCustom=U.defaultInstance.registerCustom.bind(U.defaultInstance);U.allowErrorProps=U.defaultInstance.allowErrorProps.bind(U.defaultInstance);var Dn=U.serialize,ao=U.stringify;function io(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function oo(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function lo({queryState:e,observerCount:t,isStale:s}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":s?"yellow":"green":"gray"}function co({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function uo(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var fo=(e,t=!1)=>{const{json:s}=Dn(e);return JSON.stringify(s,null,t?2:void 0)},yt=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,ho=(e,t)=>e.queryHash.localeCompare(t.queryHash),On=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,go=(e,t)=>yt(e)===yt(t)?On(e,t):yt(e)>yt(t)?1:-1,mo={status:go,"query hash":ho,"last updated":On},At=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,Gn=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,Eo=(e,t)=>At(e)===At(t)?Gn(e,t):At(e)>At(t)?1:-1,po={status:Eo,"last updated":Gn},yo=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),Ao=()=>{const[e,t]=V("dark");return tn(()=>{const s=window.matchMedia("(prefers-color-scheme: dark)");t(s.matches?"dark":"light");const n=r=>{t(r.matches?"dark":"light")};s.addEventListener("change",n),qe(()=>s.removeEventListener("change",n))}),e},ze=(e,t,s)=>{if(t.length===0)return s;if(e instanceof Map){const n=new Map(e);if(t.length===1)return n.set(t[0],s),n;const[r,...a]=t;return n.set(r,ze(n.get(r),a,s)),n}if(e instanceof Set){const n=ze(Array.from(e),t,s);return new Set(n)}if(Array.isArray(e)){const n=[...e];if(t.length===1)return n[t[0]]=s,n;const[r,...a]=t;return n[r]=ze(n[r],a,s),n}if(e instanceof Object){const n={...e};if(t.length===1)return n[t[0]]=s,n;const[r,...a]=t;return n[r]=ze(n[r],a,s),n}return e},$e=(e,t)=>{if(e instanceof Map){const s=new Map(e);if(t.length===1)return s.delete(t[0]),s;const[n,...r]=t;return s.set(n,$e(s.get(n),r)),s}if(e instanceof Set){const s=$e(Array.from(e),t);return new Set(s)}if(Array.isArray(e)){const s=[...e];if(t.length===1)return s.filter((a,i)=>i.toString()!==t[0]);const[n,...r]=t;return s[n]=$e(s[n],r),s}if(e instanceof Object){const s={...e};if(t.length===1)return delete s[t[0]],s;const[n,...r]=t;return s[n]=$e(s[n],r),s}return e},Rn=(e,t)=>{if(!e||document.querySelector("#_goober")||(t==null?void 0:t.querySelector("#_goober")))return;const n=document.createElement("style"),r=document.createTextNode("");n.appendChild(r),n.id="_goober",n.setAttribute("nonce",e),t?t.appendChild(n):document.head.appendChild(n)},be,st,nt,rt,Se,at,Ce,Ie,Ne,Le,je,it,ke,ot,Is,To=(Is=class{constructor(e){M(this,be);M(this,st);M(this,nt);M(this,rt);M(this,Se,!1);M(this,at);M(this,Ce);M(this,Ie);M(this,Ne);M(this,Le);M(this,je);M(this,it);M(this,ke);M(this,ot);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:u,shadowDOMTarget:f,hideDisabledQueries:d}=e;G(this,be,V(t)),G(this,nt,s),G(this,rt,n),G(this,st,r),G(this,at,u),G(this,Ce,f),G(this,Ie,V(a)),G(this,Ne,V(i)),G(this,Le,V(l)),G(this,je,V(c)),G(this,it,V(d))}setButtonPosition(e){v(this,Ie)[1](e)}setPosition(e){v(this,Ne)[1](e)}setInitialIsOpen(e){v(this,Le)[1](e)}setErrorTypes(e){v(this,je)[1](e)}setClient(e){v(this,be)[1](e)}mount(e){if(v(this,Se))throw new Error("Devtools is already mounted");const t=fn(()=>{const s=this,[n]=v(this,Ie),[r]=v(this,Ne),[a]=v(this,Le),[i]=v(this,je),[l]=v(this,it),[c]=v(this,be);let u;return v(this,ke)?u=v(this,ke):(u=un(()=>Promise.resolve().then(()=>require("./NCMVHL6D-DGH2CRR6.cjs"))),G(this,ke,u)),Rn(v(this,at),v(this,Ce)),ds(u,fs({get queryFlavor(){return v(s,nt)},get version(){return v(s,rt)},get onlineManager(){return v(s,st)},get shadowDOMTarget(){return v(s,Ce)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return i()},get hideDisabledQueries(){return l()}}))},e);G(this,Se,!0),G(this,ot,t)}unmount(){var e;if(!v(this,Se))throw new Error("Devtools is not mounted");(e=v(this,ot))==null||e.call(this),G(this,Se,!1)}},be=new WeakMap,st=new WeakMap,nt=new WeakMap,rt=new WeakMap,Se=new WeakMap,at=new WeakMap,Ce=new WeakMap,Ie=new WeakMap,Ne=new WeakMap,Le=new WeakMap,je=new WeakMap,it=new WeakMap,ke=new WeakMap,ot=new WeakMap,Is),De,lt,ct,ut,Pe,dt,Oe,Ge,Re,Me,Be,ft,Ue,Fe,ht,Ns,So=(Ns=class{constructor(e){M(this,De);M(this,lt);M(this,ct);M(this,ut);M(this,Pe,!1);M(this,dt);M(this,Oe);M(this,Ge);M(this,Re);M(this,Me);M(this,Be);M(this,ft);M(this,Ue);M(this,Fe);M(this,ht);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:u,shadowDOMTarget:f,onClose:d,hideDisabledQueries:g}=e;G(this,De,V(t)),G(this,ct,s),G(this,ut,n),G(this,lt,r),G(this,dt,u),G(this,Oe,f),G(this,Ge,V(a)),G(this,Re,V(i)),G(this,Me,V(l)),G(this,Be,V(c)),G(this,ft,V(g)),G(this,Ue,V(d))}setButtonPosition(e){v(this,Ge)[1](e)}setPosition(e){v(this,Re)[1](e)}setInitialIsOpen(e){v(this,Me)[1](e)}setErrorTypes(e){v(this,Be)[1](e)}setClient(e){v(this,De)[1](e)}setOnClose(e){v(this,Ue)[1](()=>e)}mount(e){if(v(this,Pe))throw new Error("Devtools is already mounted");const t=fn(()=>{const s=this,[n]=v(this,Ge),[r]=v(this,Re),[a]=v(this,Me),[i]=v(this,Be),[l]=v(this,ft),[c]=v(this,De),[u]=v(this,Ue);let f;return v(this,Fe)?f=v(this,Fe):(f=un(()=>Promise.resolve().then(()=>require("./2AITGKQY-wLnL_T-W.cjs"))),G(this,Fe,f)),Rn(v(this,dt),v(this,Oe)),ds(f,fs({get queryFlavor(){return v(s,ct)},get version(){return v(s,ut)},get onlineManager(){return v(s,lt)},get shadowDOMTarget(){return v(s,Oe)}},{get client(){return c()},get buttonPosition(){return n()},get position(){return r()},get initialIsOpen(){return a()},get errorTypes(){return i()},get hideDisabledQueries(){return l()},get onClose(){return u()}}))},e);G(this,Pe,!0),G(this,ht,t)}unmount(){var e;if(!v(this,Pe))throw new Error("Devtools is not mounted");(e=v(this,ht))==null||e.call(this),G(this,Pe,!1)}},De=new WeakMap,lt=new WeakMap,ct=new WeakMap,ut=new WeakMap,Pe=new WeakMap,dt=new WeakMap,Oe=new WeakMap,Ge=new WeakMap,Re=new WeakMap,Me=new WeakMap,Be=new WeakMap,ft=new WeakMap,Ue=new WeakMap,Fe=new WeakMap,ht=new WeakMap,Ns);function Po(e){const t=P.useQueryClient(e.client),s=z.useRef(null),{buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:u}=e,[f]=z.useState(new To({client:t,queryFlavor:"React Query",version:"5",onlineManager:P.onlineManager,buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:u}));return z.useEffect(()=>{f.setClient(t)},[t,f]),z.useEffect(()=>{n&&f.setButtonPosition(n)},[n,f]),z.useEffect(()=>{r&&f.setPosition(r)},[r,f]),z.useEffect(()=>{f.setInitialIsOpen(a||!1)},[a,f]),z.useEffect(()=>{f.setErrorTypes(i||[])},[i,f]),z.useEffect(()=>(s.current&&f.mount(s.current),()=>{f.unmount()}),[f]),o.jsx("div",{dir:"ltr",className:"tsqd-parent-container",ref:s})}function xo(e){const t=P.useQueryClient(e.client),s=z.useRef(null),{errorTypes:n,styleNonce:r,shadowDOMTarget:a,hideDisabledQueries:i}=e,[l]=z.useState(new So({client:t,queryFlavor:"React Query",version:"5",onlineManager:P.onlineManager,buttonPosition:"bottom-left",position:"bottom",initialIsOpen:!0,errorTypes:n,styleNonce:r,shadowDOMTarget:a,onClose:e.onClose,hideDisabledQueries:i}));return z.useEffect(()=>{l.setClient(t)},[t,l]),z.useEffect(()=>{l.setOnClose(e.onClose??(()=>{}))},[e.onClose,l]),z.useEffect(()=>{l.setErrorTypes(n||[])},[n,l]),z.useEffect(()=>(s.current&&l.mount(s.current),()=>{l.unmount()}),[l]),o.jsx("div",{style:{height:"500px",...e.style},className:"tsqd-parent-container",ref:s})}var bs=process.env.NODE_ENV!=="development"?function(){return null}:Po;process.env.NODE_ENV;const Mn=Q.atom(""),_o=()=>{_.registerChaiFeatureFlag("dynamic-page-selector",{description:"Dynamic page selector"}),_.registerChaiFeatureFlag("enable-add-page-dropdown",{description:"Enable add page dropdown"}),_.registerChaiFeatureFlag("enable-ai-chat-panel",{description:"Enable AI chat panel"})},vo=()=>{const e=k(),t=j();return P.useQuery({queryKey:[y.GET_COLLECTIONS],staleTime:1/0,queryFn:async()=>t(e,{action:y.GET_COLLECTIONS})})},wo=()=>{const{data:e}=X(),{data:t}=ue(),{data:s}=ye(),n=k(),r=j(),a=h.useMemo(()=>(s==null?void 0:s.fallbackLang)||"en",[s==null?void 0:s.fallbackLang]);return P.useMutation({mutationFn:async({block:i})=>r(n,{action:y.GET_BLOCK_ASYNC_PROPS,data:{block:i,lang:(t==null?void 0:t.lang)||a,pageProps:{slug:t==null?void 0:t.slug,searchParams:{},pageType:t==null?void 0:t.pageType,fallbackLang:a,lastSaved:t.lastSaved,pageId:e.id,primaryPageId:t.primaryPage||e.id,pageBaseSlug:t==null?void 0:t.slug,dynamic:e==null?void 0:e.dynamic,languagePageId:t.id}}})})},Bn=()=>{const[,e]=ee();return h.useCallback((t,s)=>{const r=new URLSearchParams(window.location.search).get("lang"),a=new URLSearchParams({page:t});r&&a.set("lang",r),window.history.pushState({},"",`?${a.toString()}`),e(a),window.dispatchEvent(new PopStateEvent("popstate")),s==null||s()},[e])},Un=()=>{const e=Bn();return h.useCallback(({pageId:t})=>{e(t)},[e])},bo=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-C9gYL2SF.cjs"))),Co=h.lazy(()=>Promise.resolve().then(()=>require("./save-to-lib-BR1Qhw3Q.cjs"))),Io=h.lazy(()=>Promise.resolve().then(()=>require("./theme-panel-footer-CUSfduTK.cjs"))),No=h.lazy(()=>Promise.resolve().then(()=>require("./web-preview-CNMYCWxW.cjs")));_o();Jn.loadWebBlocks();_.registerChaiTopBar(ia);ja();_.registerChaiMediaManager(bo);_.registerChaiSaveToLibrary(Co);const Lo={role:"",permissions:null},Cs=e=>{const{data:t}=pa();mr();const s=Ot(),{data:n=Lo,isFetching:r}=Qs(),{data:a,isFetching:i}=de(),{data:l,isFetching:c}=vo(),{data:u,isFetching:f}=ye(),d=r||i||c||f,[g]=ee(),E=g.get("page"),{data:S}=X(),{data:x,isFetching:A}=ua(),{blocks:T}=ca(x),{lockingStatus:C,pageLock:N}=Ae(),{data:R,isFetching:K}=Ks(),O=oa(),{onSave:ie}=ya(),{mutateAsync:oe}=wo(),{getPartialBlocks:q,getPartialBlockBlocks:I}=Aa(),{mutateAsync:L}=Ir(),{mutateAsync:W}=Vs(),H=Un(),[ne,mt]=h.useState(!1),le=h.useRef([]),_e=h.useMemo(()=>p.get(u,"theme",{})||{},[u]),Te=p.isEmpty(C)&&(N==null?void 0:N.status)==="editing",Kn=(N==null?void 0:N.status)==="checking",hs=A||Kn||K;le.current=T;const[Vn]=Q.useAtom(Mn);h.useEffect(()=>{const Z=()=>{document.hidden?mt(!0):mt(!1)};return window.addEventListener("visibilitychange",Z),()=>window.removeEventListener("visibilitychange",Z)},[]);const Qn=h.useMemo(()=>{const Z={};return n&&(Z.permissions=p.get(n,"permissions",null),Z.role=p.get(n,"role","user")),Z},[n]),Hn=h.useMemo(()=>t==null?void 0:t.some(Z=>Z.isSiteLibrary),[t]),zn=h.useCallback(async(Z,Et)=>await L({pageType:Z,query:Et}),[L]);return o.jsxs(o.Fragment,{children:[hs&&o.jsx(os,{className:d?"fixed inset-0 bg-white":"bg-white/75",children:o.jsx(w.Loader,{className:`animate-spin text-primary ${d?"h-6 w-6":"h-5 w-5"}`})}),Vn&&o.jsx(h.Suspense,{fallback:o.jsx("div",{className:"absolute inset-0 z-[999999] flex min-h-screen w-screen items-center justify-center bg-gray-100",children:o.jsx(w.Loader,{className:"h-6 w-6 animate-spin text-primary"})}),children:o.jsx(No,{})}),o.jsx(_.ChaiBuilderEditor,{_tempProps:{librarySite:Hn},gotoPage:H,collections:l??[],getBlockAsyncProps:oe,pageExternalData:R,themePresets:e.themePresets??[],pageId:S==null?void 0:S.id,loading:A,fallbackLang:s,languages:(u==null?void 0:u.languages)||[],brandingOptions:(u==null?void 0:u.theme)||{},translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSave:!ne&&Te&&(e.autoSave??!0),autoSaveInterval:e.autoSaveInterval??15,onError:e.onError||console.error,getPartialBlockBlocks:I,getPartialBlocks:q,blocks:A?[]:T,theme:p.cloneDeep(_e),pageTypes:a,searchPageTypeItems:zn,askAiCallBack:O,onSave:async({blocks:Z,theme:Et,needTranslations:$n})=>{if(!E)return!0;le.current=Z;const gs=[...Z];return await ie({page:E,blocks:gs,needTranslations:$n}),le.current=gs,p.isEqual(Et,_e)||await W({settings:{theme:Et}}),!0},themePanelComponent:Io,...Qn}),o.jsxs("div",{children:[o.jsx(yr,{isFetchingPage:hs}),o.jsx(Ar,{})]})]})},jo=new P.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1}}}),ko=e=>{const[,t]=jt(),[s,n]=h.useState(!1);return h.useEffect(()=>(t(p.pick(e,["apiUrl","usersApiUrl","assetsApiUrl","getPreviewUrl","getLiveUrl","topLeftCorner","onLogout","getAccessToken","websocket","getLoggedInUser","features","currentUser"])),setTimeout(()=>{n(!0)},200),()=>{n(!1),t({})}),[e,t]),s?p.get(e,"hasReactQueryProvider",!1)===!0?o.jsxs(o.Fragment,{children:[o.jsx(Cs,{...e}),o.jsx(bs,{})]}):o.jsxs(P.QueryClientProvider,{client:jo,children:[o.jsx(Cs,{...e}),o.jsx(bs,{})]}):o.jsx("div",{})},Do=z.lazy(()=>Promise.resolve().then(()=>require("./nested-path-selector-content-D_iF9Sm3.cjs")));function Fn({data:e,onSelect:t,dataType:s="value",disabled:n=!1}){const[r,a]=z.useState(!1);return o.jsxs(m.Popover,{open:r,onOpenChange:a,children:[o.jsxs(m.Tooltip,{children:[o.jsx(m.TooltipTrigger,{asChild:!0,children:o.jsx(m.PopoverTrigger,{asChild:!0,children:o.jsx(m.Button,{size:"sm",variant:"outline",className:"h-6 w-6 px-1 py-0 text-[9px] text-muted-foreground",role:"combobox","aria-expanded":r,disabled:n,children:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"none",children:o.jsx("path",{d:"M9.5 5H9C7.89543 5 7 5.89543 7 7V9C7 10 6.4 12 4 12C5 12 7 12.6 7 15V17.0002C7 18.1048 7.89543 19 9 19H9.5M14.5 5H15C16.1046 5 17 5.89543 17 7V9C17 10 17.6 12 20 12C19 12 17 12.6 17 15V17.0002C17 18.1048 16.1046 19 15 19H14.5",stroke:"#000000",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})})})}),o.jsx(m.TooltipContent,{children:"Add field"})]}),r&&o.jsx(z.Suspense,{children:o.jsx(Do,{data:e,onSelect:t,dataType:s,open:r,setOpen:a})})]})}const Oo=()=>{const{savePageAsync:e}=_.useSavePage(),t=P.useQueryClient();return h.useCallback(async()=>{await e(),t.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),t.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]})},[e,t])},Go=()=>{const e=P.useQueryClient();return h.useCallback(()=>{e.clear()},[e])},Ro=()=>{const e=k(),t=j(),{data:s}=ue(),n=P.useQueryClient();return P.useMutation({mutationFn:async r=>{if(!(s!=null&&s.id))throw new Error("No active page found");return await t(`${e}`,{action:y.UPDATE_PAGE_METADATA,data:{id:s.id,metadata:r}})},onSuccess:()=>{n.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]}),n.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES]})},onError:()=>{console.error("Failed to update metadata")}})},Mo=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-C9gYL2SF.cjs"))),Bo=({assetId:e,assetUrl:t,onChange:s,className:n="",placeholder:r="Select an image",disabled:a=!1})=>{const{t:i}=_.useTranslation(),[l,c]=h.useState(!1),u=()=>{a||c(!0)},f=()=>{c(!1)},d=S=>{const x=Array.isArray(S)?S[0]:S;x!=null&&x.url&&s(p.pick(x,["url","id"])),c(!1)},g=()=>{s({url:"",id:""})},E=(t==null?void 0:t.startsWith("{{"))&&(t==null?void 0:t.endsWith("}}"));return o.jsxs("div",{className:`w-full ${n}`,children:[t?o.jsxs("div",{className:"relative overflow-hidden rounded-md border",children:[E?o.jsx("div",{className:"flex h-12 items-center bg-gray-100 px-4",children:o.jsx("p",{className:"text-xs text-gray-500",children:t})}):o.jsx("img",{onClick:u,src:t,alt:i("Selected image"),className:"h-auto max-h-[100px] w-full bg-gray-100 object-contain"}),o.jsxs("div",{className:"absolute right-2 top-2 flex gap-2",children:[o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white text-red-500",onClick:g,disabled:a,children:E?o.jsx(w.X,{className:"h-4 w-4"}):o.jsx(w.Trash2,{className:"h-4 w-4"})}),!E&&o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 rounded-full bg-white/80 hover:bg-white/90",onClick:u,disabled:a,children:o.jsx(w.ImageIcon,{className:"h-4 w-4"})})]})]}):o.jsx("div",{className:`flex cursor-pointer items-center justify-center rounded-md border border-dashed p-6 ${a?"cursor-not-allowed opacity-50":"hover:border-gray-400"}`,onClick:u,children:o.jsxs("div",{className:"flex flex-col items-center gap-2",children:[o.jsx(w.ImageIcon,{className:"h-10 w-10 text-gray-400"}),o.jsx("p",{className:"text-sm text-gray-500",children:r})]})}),o.jsx(m.Dialog,{open:l,onOpenChange:c,children:o.jsxs(m.DialogContent,{className:"h-fit w-full max-w-7xl overflow-hidden p-0",children:[o.jsxs(m.DialogHeader,{className:"hidden border-b px-4 py-2",children:[o.jsx(m.DialogTitle,{children:i("Select Image")}),o.jsx(m.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-4 top-2",onClick:f,children:o.jsx(w.X,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"h-full flex-1 p-4",children:o.jsx(h.Suspense,{children:o.jsx(Mo,{close:f,onSelect:d,mode:"image",assetId:e})})})]})})]})},Uo=h.createContext(null),Qt={didCatch:!1,error:null};class qn extends h.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Qt}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var s,n,r=arguments.length,a=new Array(r),i=0;i<r;i++)a[i]=arguments[i];(s=(n=this.props).onReset)===null||s===void 0||s.call(n,{args:a,reason:"imperative-api"}),this.setState(Qt)}}componentDidCatch(t,s){var n,r;(n=(r=this.props).onError)===null||n===void 0||n.call(r,t,s)}componentDidUpdate(t,s){const{didCatch:n}=this.state,{resetKeys:r}=this.props;if(n&&s.error!==null&&Fo(t.resetKeys,r)){var a,i;(a=(i=this.props).onReset)===null||a===void 0||a.call(i,{next:r,prev:t.resetKeys,reason:"keys"}),this.setState(Qt)}}render(){const{children:t,fallbackRender:s,FallbackComponent:n,fallback:r}=this.props,{didCatch:a,error:i}=this.state;let l=t;if(a){const c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(typeof s=="function")l=s(c);else if(n)l=h.createElement(n,c);else if(r!==void 0)l=r;else throw i}return h.createElement(Uo.Provider,{value:{didCatch:a,error:i,resetErrorBoundary:this.resetErrorBoundary}},l)}}function Fo(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((s,n)=>!Object.is(s,t[n]))}const qo=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),es=e=>{if(!e.trim())return{isValid:!1,parsed:null,placeholders:[],error:{message:"JSON is empty"}};try{return{isValid:!0,parsed:JSON.parse(e),error:null,placeholders:[]}}catch{}const t=/{{([^{}]+)}}/g,s=[];let n=e,r;for(;(r=t.exec(e))!==null;){const a=r[0],i=r.index,l=`"__placeholder_${s.length}__"`;s.push({original:a,replaced:l,position:i}),n=n.replace(a,l)}try{return{isValid:!0,parsed:JSON.parse(n),error:null,placeholders:s}}catch(a){const i=a,l=i.message.match(/position (\d+)/),c=l?parseInt(l[1]):void 0;let u,f;if(c!==void 0){const d=n.substring(0,c).split(`
2
+ `);u=d.length,f=d[d.length-1].length+1}return{isValid:!1,parsed:null,placeholders:s,error:{message:i.message,line:u,column:f,position:c}}}},Ko=(e,t)=>{let n=JSON.stringify(e,null,2);return t.forEach(({original:r},a)=>{const i=`"__placeholder_${a}__"`,l=new RegExp(qo(i),"g");n=n.replace(l,r)}),n},Vo=(e,t)=>{if(!e)return"";let s=JSON.stringify(e,null,2);const n=/{{([^{}]+)}}/g;let r;for(;(r=n.exec(s))!==null;){const a=r[1],i=p.get(t,a,null);s=s.replace(r[0],i)}return s},Qo=h.lazy(()=>Promise.resolve().then(()=>require("./shared-json-ld-CDffP4G3.cjs"))),Ho=({value:e,onChange:t,disabled:s=!1,readOnly:n=!1,placeholder:r="Enter JSON",rows:a=6,id:i="json-input",pageData:l={},handleFieldInsert:c,hasJsonLdForSelectedLang:u,copyJsonLDFromDefaultPage:f})=>{const[d,g]=h.useState("edit"),[E,S]=h.useState(null),[x,A]=h.useState(""),T=h.useRef(null),[C]=jt(),N=i==="jsonLD"&&p.get(C,"features.sharedJsonLD",!1),R=i==="jsonLD"&&!u&&!!f;h.useEffect(()=>{e.trim()===""&&t("{}")},[e,t]);const K=q=>{if(n)return;const I=q.target.value;t(I)},O=q=>{if(q.key==="Tab"){q.preventDefault();const I=q.currentTarget,L=I.selectionStart,W=I.selectionEnd;if(L!==W){const ne=e.substring(L,W).split(`
3
+ `);if(q.shiftKey){const le=ne.map(Te=>Te.startsWith(" ")?Te.substring(2):Te).join(`
4
+ `),_e=e.substring(0,L)+le+e.substring(W);t(_e),setTimeout(()=>{I.selectionStart=L,I.selectionEnd=L+le.length},0)}else{const le=ne.map(Te=>` ${Te}`).join(`
5
+ `),_e=e.substring(0,L)+le+e.substring(W);t(_e),setTimeout(()=>{I.selectionStart=L,I.selectionEnd=L+le.length},0)}}else{const H=e.substring(0,L)+" "+e.substring(W);t(H),setTimeout(()=>{I.selectionStart=I.selectionEnd=L+2},0)}}};h.useEffect(()=>{const q=es(e);if(q.isValid)if(S(null),q.parsed){const I=Vo(q.parsed,l);A(I)}else A("");else S(q.error),A("")},[e,l]);const ie=()=>{const q=es(e);if(q.isValid&&q.parsed){const I=Ko(q.parsed,q.placeholders);t(I)}},oe=()=>{E!=null&&E.position&&T.current&&(T.current.focus(),T.current.setSelectionRange(E.position,E.position+1))};return o.jsx(qn,{fallback:o.jsx("div",{children:"Some error"}),children:o.jsx("div",{className:"space-y-2",children:o.jsxs(m.Tabs,{value:d,onValueChange:g,className:"w-full",children:[o.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[o.jsxs(m.TabsList,{className:"w-max",children:[o.jsxs(m.TabsTrigger,{value:"edit",className:"flex items-center gap-1",children:[o.jsx(w.Code,{className:"h-4 w-4"}),o.jsx("span",{children:"Edit"})]}),o.jsxs(m.TabsTrigger,{value:"preview",className:"flex items-center gap-1",disabled:!e.trim()||E!==null||R,children:[o.jsx(w.Eye,{className:"h-4 w-4"}),o.jsx("span",{children:"Preview"})]}),N&&o.jsxs(m.TabsTrigger,{value:"shared",className:"flex items-center gap-1",disabled:!e.trim()||E!==null,children:[o.jsx(w.Share2,{className:"h-4 w-4"}),o.jsx("span",{children:"Shared"})]})]}),R?null:d==="edit"&&!n&&o.jsx("div",{className:"flex items-center gap-2",children:o.jsx(Fn,{dataType:"value",data:l??{},onSelect:q=>c&&c(q,i)})})]}),o.jsxs(m.TabsContent,{value:"edit",className:"relative mt-0",children:[!R&&d==="edit"&&o.jsx(Gt,{content:"Format JSON",side:"right",showTooltip:!s&&!E,children:o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",onClick:ie,className:"absolute right-1 top-1 h-6 w-6 p-1",disabled:!e.trim()||s||E!==null,children:o.jsx(w.FileCode2,{})})}),R?o.jsx("div",{className:"flex h-40 items-center justify-center rounded-md bg-black/20",children:o.jsxs("div",{className:"flex max-w-[400px] flex-col items-center gap-2 rounded-md bg-white p-4 shadow-lg",children:[o.jsx("div",{className:"max-w-xl text-center text-xs text-gray-500",children:"JSON-LD for is not added for selected language. JSON LD will be used from default language."}),o.jsxs(m.Button,{type:"button",variant:"default",size:"sm",onClick:f,children:[o.jsx(w.Plus,{}),"Copy & Edit from default language"]})]})}):o.jsx(m.Textarea,{ref:T,id:i,name:i,className:`rounded-md border border-input text-xs ${E?"border-red-500":""}`,onChange:K,onKeyDown:O,value:e,placeholder:r,rows:a,disabled:s,readOnly:n}),E&&o.jsxs(m.Alert,{variant:"destructive",className:"mt-2",children:[o.jsx(w.AlertTriangle,{className:"h-4 w-4"}),o.jsxs(m.AlertDescription,{className:"flex flex-col",children:[o.jsx("span",{className:"font-medium",children:"Invalid JSON"}),o.jsx("span",{className:"text-sm",children:E.message}),E.line&&E.column&&o.jsxs("span",{className:"text-sm",children:["Error at line ",E.line,", column ",E.column]}),o.jsx(m.Button,{type:"button",variant:"link",size:"sm",className:"mt-1 h-auto self-start p-0 text-sm",onClick:oe,children:"Show position"})]})]})]}),o.jsxs(m.TabsContent,{value:"preview",className:"mt-0",children:[o.jsx(m.Textarea,{rows:a,value:x,readOnly:!0,className:"cursor-default bg-muted font-mono text-sm"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"This is how the JSON will look after placeholder substitution."})]}),N&&o.jsx(m.TabsContent,{value:"shared",className:"mt-0",children:o.jsx(h.Suspense,{children:o.jsx(Qo,{})})})]})})})};if(typeof window>"u")throw new Error("@chaibuilder/pages is not available on the server");exports.$TRACK=ls;exports.ACTIONS=y;exports.BlurContainer=os;exports.ChaiBuilderPages=ko;exports.ChaiBuilderPagesRealtime=ks;exports.Dynamic=Ii;exports.ErrorBoundary=qn;exports.For=ei;exports.ImagePicker=Bo;exports.Index=ti;exports.LANGUAGES=Qe;exports.LanguageSwitcher=Bs;exports.Match=ri;exports.NestedPathSelector=Fn;exports.PAGES_PERMISSIONS=te;exports.PageActionsDropdown=Fs;exports.PermissionChecker=Tt;exports.Portal=bi;exports.Show=si;exports.SmartJsonInput=Ho;exports.Switch=ni;exports.Tooltip=Gt;exports.addEventListener=mn;exports.addNewLangAtom=Dt;exports.batch=Ra;exports.className=gn;exports.clearDelegatedEvents=pi;exports.convertRemToPixels=yo;exports.createComponent=ds;exports.createComputed=en;exports.createContext=qa;exports.createEffect=cs;exports.createMemo=$;exports.createRenderEffect=me;exports.createRoot=ge;exports.createSignal=V;exports.createUniqueId=Za;exports.delegateEvents=hn;exports.deleteNestedDataByPath=$e;exports.displayValue=fo;exports.getMutationStatusColor=co;exports.getPreferredColorScheme=Ao;exports.getQueryStatusColor=lo;exports.getQueryStatusColorByLabel=uo;exports.getQueryStatusLabel=io;exports.getSidedProp=oo;exports.insert=Lt;exports.memo=gi;exports.mergeProps=fs;exports.mutationSortFns=po;exports.navigateToPage=rs;exports.on=Ma;exports.onCleanup=qe;exports.onMount=tn;exports.parseJSONWithPlaceholders=es;exports.previewUrlAtom=Mn;exports.serialize=Dn;exports.setAttribute=Nt;exports.sortFns=mo;exports.splitProps=cn;exports.spread=En;exports.stringify=ao;exports.template=Ei;exports.throwConfetti=St;exports.untrack=Y;exports.updateNestedDataByPath=ze;exports.use=pn;exports.useActivePage=ue;exports.useAddGlobalSchema=da;exports.useApiUrl=k;exports.useApplySchemaToAllPages=ma;exports.useAssetsApiUrl=er;exports.useBuilderFetch=nr;exports.useBuilderPageData=Ks;exports.useChaiAuth=gt;exports.useChaiUserInfo=Gs;exports.useChangePage=Bn;exports.useChangeSlug=Gr;exports.useClearAll=Go;exports.useContext=Ka;exports.useCreatePage=Nr;exports.useCurrentPage=X;exports.useDeleteGlobalSchema=ha;exports.useDeletePage=jr;exports.useDynamicPageSelector=Os;exports.useFallbackLang=Ot;exports.useFetch=j;exports.useGotoPage=Un;exports.useIsLanguagePageCreated=ts;exports.useLanguagePages=pe;exports.useMarkAsTemplate=Dr;exports.usePageEditInfo=kt;exports.usePageLockRequestTakeOver=Rs;exports.usePageType=Us;exports.usePageTypes=de;exports.usePageUserMapping=gr;exports.usePagesProps=jt;exports.usePublishPages=is;exports.useReloadPage=Oo;exports.useRemoveSchemaFromAllPages=Ea;exports.useSearchParams=ee;exports.useTogglePageGlobalSchema=ga;exports.useTransition=Fa;exports.useUnmarkAsTemplate=Or;exports.useUnpublishPage=kr;exports.useUpdateActivePageMetadata=Ro;exports.useUpdateGlobalSchema=fa;exports.useUpdatePage=Lr;exports.useUpdateWebsiteSettings=Vs;exports.useUserRoleAndPermissions=Qs;exports.useWebsiteLanguagePages=Tr;exports.useWebsitePages=as;exports.useWebsiteSetting=ye;