@chaibuilder/pages 0.15.3 → 0.15.5

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 (69) hide show
  1. package/dist/{2AITGKQY-o6FgGSqg.cjs → 2AITGKQY-D4uLyw6-.cjs} +1 -1
  2. package/dist/{2AITGKQY-DhC0sF1x.js → 2AITGKQY-DYwNjBFe.js} +2 -2
  3. package/dist/{NCMVHL6D-BPM6RHYa.cjs → NCMVHL6D-C-L7-X3f.cjs} +1 -1
  4. package/dist/{NCMVHL6D-D7HU3akD.js → NCMVHL6D-DVB60g_2.js} +2 -2
  5. package/dist/{ZDWCUMSJ-NVCxv9uE.cjs → ZDWCUMSJ-BORULBXb.cjs} +1 -1
  6. package/dist/{ZDWCUMSJ-Cr1v3giV.js → ZDWCUMSJ-Dp6ML_tn.js} +1 -1
  7. package/dist/{add-new-language-page-D3PSLiUv.cjs → add-new-language-page-D4VPifNs.cjs} +1 -1
  8. package/dist/{add-new-language-page-8q4Ku3eg.js → add-new-language-page-DENCjC_f.js} +2 -2
  9. package/dist/{add-new-page-YpzILOYq.cjs → add-new-page-BuK6We-q.cjs} +1 -1
  10. package/dist/{add-new-page-BpvpSM4X.js → add-new-page-CD-9ppdS.js} +1 -1
  11. package/dist/{delete-page-w64MO7db.cjs → delete-page-B-TP6nJ7.cjs} +1 -1
  12. package/dist/{delete-page-CXRJjJ4o.js → delete-page-CatRlDfx.js} +1 -1
  13. package/dist/digital-asset-manager-DL2nAqUC.cjs +1 -0
  14. package/dist/digital-asset-manager-KakxBkBC.js +917 -0
  15. package/dist/{duplicate-page-DB_c7V2t.cjs → duplicate-page-D4Oiy71Q.cjs} +1 -1
  16. package/dist/{duplicate-page-CSQs2MOp.js → duplicate-page-DEmh0df0.js} +2 -2
  17. package/dist/{dynamic-page-selector-DTk4oull.js → dynamic-page-selector-8g1-84iW.js} +1 -1
  18. package/dist/{dynamic-page-selector-CF9nb6i_.cjs → dynamic-page-selector-Cz6zWaKo.cjs} +1 -1
  19. package/dist/index-Blg1T7nL.cjs +5 -0
  20. package/dist/{index-BuXZJnGo.js → index-zaGKeGBW.js} +850 -765
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +6 -6
  23. package/dist/{json-diff-viewer-oyxMD3Hc.js → json-diff-viewer-BF0qFBif.js} +1 -1
  24. package/dist/{json-diff-viewer-zBoPBSd3.cjs → json-diff-viewer-c3ft4c4A.cjs} +1 -1
  25. package/dist/{lang-panel-B_HcsPPo.js → lang-panel-D1FKTNui.js} +2 -2
  26. package/dist/{lang-panel-D2YUMeJZ.cjs → lang-panel-ExS97Zgk.cjs} +1 -1
  27. package/dist/{mark-as-template-C4wH4UKf.cjs → mark-as-template-CcnkROAU.cjs} +1 -1
  28. package/dist/{mark-as-template-CPEPYXg7.js → mark-as-template-v-I05xcZ.js} +1 -1
  29. package/dist/{no-language-page-content-CVyOpT9h.js → no-language-page-content-Bm5CcsUo.js} +1 -1
  30. package/dist/{no-language-page-content-ECt0SxFX.cjs → no-language-page-content-Ddz2hnYs.cjs} +1 -1
  31. package/dist/{page-creator-y6kl3nw5.js → page-creator-Crc5BzeB.js} +2 -2
  32. package/dist/{page-creator-BG2hc82u.cjs → page-creator-CsZpQ7Gy.cjs} +1 -1
  33. package/dist/{page-lock-request-fGZbOFTp.cjs → page-lock-request-Dx6OrOwM.cjs} +1 -1
  34. package/dist/{page-lock-request-DC62b588.js → page-lock-request-WKfG7Sd3.js} +1 -1
  35. package/dist/{page-locked-by-dialog-BIC-c0Jl.cjs → page-locked-by-dialog-BvdAXZPw.cjs} +1 -1
  36. package/dist/{page-locked-by-dialog-D-vXaoga.js → page-locked-by-dialog-jy3lYV3l.js} +1 -1
  37. package/dist/{page-manager-new-Cto2r7Va.js → page-manager-new-CNHlSwfe.js} +66 -66
  38. package/dist/page-manager-new-CUlpwqpH.cjs +1 -0
  39. package/dist/{page-manager-search-and-filter-sVnGlF46.js → page-manager-search-and-filter-CuAn82Db.js} +1 -1
  40. package/dist/{page-manager-search-and-filter-z2b4sgvb.cjs → page-manager-search-and-filter-eFsGtm5W.cjs} +1 -1
  41. package/dist/{page-revisions-content-BaTqBnko.js → page-revisions-content-PRgwV04S.js} +2 -2
  42. package/dist/{page-revisions-content-Tb3T6zvU.cjs → page-revisions-content-dSFvGFEO.cjs} +1 -1
  43. package/dist/{publish-pages-content-C9CgEWo0.js → publish-pages-content-C24iBibw.js} +2 -2
  44. package/dist/{publish-pages-content-BGkEZ3GK.cjs → publish-pages-content-akIgltlm.cjs} +1 -1
  45. package/dist/{save-to-lib-DNK4GPNw.cjs → save-to-lib-C3H1ZPb-.cjs} +1 -1
  46. package/dist/{save-to-lib-DGtyTG6H.js → save-to-lib-DSPvtFSd.js} +1 -1
  47. package/dist/{seo-panel-CrK7z4bR.cjs → seo-panel-Ce6aTIyt.cjs} +1 -1
  48. package/dist/{seo-panel-DESVAQM5.js → seo-panel-rZ8s88c0.js} +17 -17
  49. package/dist/server.cjs +1 -1
  50. package/dist/server.js +96 -96
  51. package/dist/shared-json-ld-DMYOwp6B.js +565 -0
  52. package/dist/shared-json-ld-hCiviuBf.cjs +1 -0
  53. package/dist/{slug-input-DMYhARDW.cjs → slug-input-BN8eQgxP.cjs} +1 -1
  54. package/dist/{slug-input-DfAsMPg8.js → slug-input-Dhzaobv6.js} +1 -1
  55. package/dist/{theme-panel-footer-Bj2yHtxO.cjs → theme-panel-footer-0GrdOHO_.cjs} +1 -1
  56. package/dist/{theme-panel-footer-RrxiDGoD.js → theme-panel-footer-BzEy5bsg.js} +1 -1
  57. package/dist/{unmark-as-template-C8hTjRVk.cjs → unmark-as-template-DXEs6foh.cjs} +1 -1
  58. package/dist/{unmark-as-template-BjetSrYF.js → unmark-as-template-Dsiyocm9.js} +1 -1
  59. package/dist/{unpublish-page-gtGfNOAq.cjs → unpublish-page-c1mqQEa_.cjs} +1 -1
  60. package/dist/{unpublish-page-BTPEVAkv.js → unpublish-page-yGyz2jiw.js} +1 -1
  61. package/dist/{web-preview-DNgPjdgZ.js → web-preview-BEyjKFDL.js} +1 -1
  62. package/dist/{web-preview-BcULgiw_.cjs → web-preview-TTKtpSUi.cjs} +1 -1
  63. package/package.json +2 -3
  64. package/dist/digital-asset-manager-B2m5T22s.js +0 -1001
  65. package/dist/digital-asset-manager-BGyKKd_6.cjs +0 -1
  66. package/dist/index-Cds1vIhw.cjs +0 -5
  67. package/dist/page-manager-new-CUfjlMed.cjs +0 -1
  68. package/dist/shared-json-ld-BMfQzOWc.js +0 -650
  69. package/dist/shared-json-ld-_ozYsSHn.cjs +0 -1
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),J=require("@chaibuilder/sdk"),l=require("@chaibuilder/sdk/ui"),D=require("lodash-es"),p=require("lucide-react"),u=require("react"),fe=require("react-dropzone"),A=require("sonner"),Y=require("./image-compression-DZ9WMmyn.cjs"),k=require("@tanstack/react-query"),v=require("./index-Cds1vIhw.cjs"),pe=u.createContext(null),Q={didCatch:!1,error:null};class ge extends u.Component{constructor(r){super(r),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Q}static getDerivedStateFromError(r){return{didCatch:!0,error:r}}resetErrorBoundary(){const{error:r}=this.state;if(r!==null){for(var o,t,d=arguments.length,i=new Array(d),m=0;m<d;m++)i[m]=arguments[m];(o=(t=this.props).onReset)===null||o===void 0||o.call(t,{args:i,reason:"imperative-api"}),this.setState(Q)}}componentDidCatch(r,o){var t,d;(t=(d=this.props).onError)===null||t===void 0||t.call(d,r,o)}componentDidUpdate(r,o){const{didCatch:t}=this.state,{resetKeys:d}=this.props;if(t&&o.error!==null&&je(r.resetKeys,d)){var i,m;(i=(m=this.props).onReset)===null||i===void 0||i.call(m,{next:d,prev:r.resetKeys,reason:"keys"}),this.setState(Q)}}render(){const{children:r,fallbackRender:o,FallbackComponent:t,fallback:d}=this.props,{didCatch:i,error:m}=this.state;let y=r;if(i){const N={error:m,resetErrorBoundary:this.resetErrorBoundary};if(typeof o=="function")y=o(N);else if(t)y=u.createElement(t,N);else if(d!==void 0)y=d;else throw m}return u.createElement(pe.Provider,{value:{didCatch:i,error:m,resetErrorBoundary:this.resetErrorBoundary}},y)}}function je(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return a.length!==r.length||a.some((o,t)=>!Object.is(o,r[t]))}const ve=()=>{const a=v.useAssetsApiUrl(),r=k.useQueryClient(),o=v.useFetch();return k.useMutation({mutationFn:async t=>{const d=t.map(async m=>o(a,{action:v.ACTIONS.UPLOAD_ASSET,data:m}));return await Promise.all(d)},onSuccess:t=>{var d;if(t!=null&&t.some(i=>i.error))throw new Error(((d=t==null?void 0:t.find(i=>i.error))==null?void 0:d.error)||"Failed to upload asset");{r.invalidateQueries({queryKey:[v.ACTIONS.GET_ASSETS]});const i=t==null?void 0:t.length;A.toast.success(`${i===1?"Asset":i+" Assets"} uploaded successfully`)}},onError:()=>{A.toast.error("Failed to upload asset")}})},ye=()=>{const a=v.useAssetsApiUrl(),r=k.useQueryClient(),o=v.useFetch();return k.useMutation({mutationFn:async t=>o(a,{action:v.ACTIONS.DELETE_ASSET,data:{id:t}}),onSuccess:t=>{if(t!=null&&t.error)throw new Error(t==null?void 0:t.error);r.invalidateQueries({queryKey:[v.ACTIONS.GET_ASSETS]}),A.toast.success("Asset deleted successfully")},onError:()=>{A.toast.error("Failed to delete asset")}})},Ne=()=>{const a=v.useAssetsApiUrl(),r=k.useQueryClient(),o=v.useFetch();return k.useMutation({mutationFn:async t=>o(a,{action:v.ACTIONS.UPDATE_ASSET,data:t}),onSuccess:t=>{if(t!=null&&t.error)throw new Error(t==null?void 0:t.error);r.invalidateQueries({queryKey:[v.ACTIONS.GET_ASSETS]}),t!=null&&t.id&&r.invalidateQueries({queryKey:[v.ACTIONS.GET_ASSET,t.id]}),A.toast.success("Asset updated successfully")},onError:()=>{A.toast.error("Failed to update asset")}})};function be({currentPage:a,totalPages:r,onPageChange:o,pageRangeDisplayed:t=3,showPageInput:d=!0,className:i=""}){const[m,y]=u.useState(String(a)),N=u.useMemo(()=>{const c=Math.floor(t/2);let n=Math.max(1,a-c),h=Math.min(r,a+c);h-n+1<t&&(n===1?h=Math.min(r,n+t-1):h===r&&(n=Math.max(1,h-t+1)));const j=[];n>1&&(j.push(1),n>2&&j.push("..."));for(let b=n;b<=h;b++)j.push(b);return h<r&&(h<r-1&&j.push("..."),j.push(r)),j},[a,r,t]),g=c=>{c!==a&&c>=1&&c<=r&&(o(c),y(String(c)))},w=()=>{a>1&&g(a-1)},S=()=>{a<r&&g(a+1)},C=()=>{const c=Number(m);!isNaN(c)&&c>=1&&c<=r&&g(c)},f=c=>{c.key==="Enter"&&C()};return r<=1?null:e.jsxs("div",{className:`flex flex-wrap items-center justify-center gap-3 ${i}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(l.Button,{variant:"outline",size:"sm",onClick:w,disabled:a===1,className:"px-2 py-1 text-sm hover:bg-gray-50",children:[e.jsx(p.ChevronLeft,{className:" h-4 w-4"}),"Previous"]}),e.jsx("div",{className:"flex items-center gap-2",children:N.map((c,n)=>{if(c==="...")return e.jsx("span",{className:"px-2 text-muted-foreground",children:"..."},`ellipsis-${n}`);const h=c,j=h===a;return e.jsx(l.Button,{variant:j?"default":"outline",size:"sm",onClick:()=>g(h),className:j?"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:h},h)})}),e.jsxs(l.Button,{variant:"outline",size:"sm",onClick:S,disabled:a===r,className:"px-2 py-1 text-sm hover:bg-gray-50",children:["Next",e.jsx(p.ChevronRight,{className:" h-4 w-4"})]})]}),d&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Go to"}),e.jsx(l.Input,{type:"number",min:1,max:r,value:m,onChange:c=>{const n=c.target.value.replace(/[^\d]/g,"");y(n)},onKeyDown:f,className:"h-8 w-16 px-2 py-1"}),e.jsx(l.Button,{variant:"outline",size:"sm",onClick:C,disabled:m===""||Number(m)<1||Number(m)>r,children:"Go"})]})]})}const we=(a={})=>{const r=v.useAssetsApiUrl(),o=v.useFetch(),{search:t,page:d=1,limit:i=30}=a;return k.useQuery({queryKey:[v.ACTIONS.GET_ASSETS,t,d,i],queryFn:async()=>{const m=await o(r,{action:v.ACTIONS.GET_ASSETS,data:{search:t,page:d,limit:i}});return m.page=d,m.limit=i,m},staleTime:1/0,retry:1})},Ce=a=>{const r=v.useAssetsApiUrl(),o=v.useFetch();return k.useQuery({queryKey:[v.ACTIONS.GET_ASSET,a],queryFn:async()=>a?await o(r,{action:v.ACTIONS.GET_ASSET,data:{id:a}}):null,staleTime:1/0,retry:1})};function Ae(a){const r=isNaN(a)?0:typeof a=="number"?a:parseInt(a);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 X(a){if(!a)return"N/A";const r=new Date(a);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)}function Z(a,r){let o=a,t=r==null?void 0:r.description;return(!t||typeof t!="string")&&(t=""),(!o||typeof o!="string")&&(o=""),o!==t}const Se=({assetId:a,onBack:r,onEdit:o,onSave:t,isSaving:d})=>{var f,c;const{data:i,isLoading:m,isError:y}=Ce(a||""),[N,g]=u.useState(""),[w,S]=u.useState(!1);u.useEffect(()=>{const n=new Image;return n.src=(i==null?void 0:i.url)||"",n.onload=()=>S(!0),()=>{n.onload=null}},[i]);const C=async(n,h)=>{try{await navigator.clipboard.writeText(n),A.toast.success(`${h} copied to clipboard`)}catch(j){A.toast.error(`Failed to copy ${h}`,{description:j==null?void 0:j.message})}};return u.useEffect(()=>{i!=null&&i.description&&g(i.description)},[i]),m||!w?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(p.Loader,{className:"h-8 w-8 animate-spin"})}):y||!(i!=null&&i.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(p.AlertCircle,{className:"h-12 w-12 text-gray-400"})}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"No Asset Found"}),e.jsx("p",{className:"text-sm text-gray-500 mb-6",children:y?"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(l.Button,{variant:"outline",onClick:r,children:"Back to Assets"}),y&&e.jsx(l.Button,{variant:"default",onClick:()=>window.location.reload(),children:"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(l.Button,{variant:"outline",size:"sm",onClick:r,disabled:d,children:[e.jsx(p.ChevronLeft,{className:"h-4 w-4"}),"Back to Assets"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(l.Button,{variant:"outline",onClick:r,disabled:d,children:"Cancel"}),e.jsxs(l.Button,{variant:"outline",onClick:()=>C(i.url,"Asset URL"),disabled:d,children:[e.jsx(p.Copy,{className:"h-4 w-4 mr-2"}),"Copy URL"]}),e.jsxs(l.Button,{variant:"default",onClick:()=>o(i),disabled:d,children:[e.jsx(p.Pencil,{className:"h-4 w-4"}),"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:i.url,alt:i.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(l.Label,{className:"w-full text-center",children:"Details"}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2 bg-white",children:[{label:"File Name",value:i.name},{label:"Type",value:i.type,capitalize:!0},{label:"Format",value:((f=i.metadata)==null?void 0:f.format)||i.type,capitalize:!0},{label:"Size",value:Ae(i.size)},{label:"Dimensions",value:`${i.width||0} × ${i.height||0}`},{label:"Created",value:X(i.createdAt)},{label:"Updated",value:X(((c=i.metadata)==null?void 0:c.updatedAt)||(i==null?void 0:i.updatedAt)||i.createdAt)},{label:"URL",value:i.url,copyable:!0}].map(n=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Label,{className:"w-max text-left px-2 w-1/4 font-normal text-gray-700",children:n.label}),":",e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-max text-left font-medium text-gray-900"+(n.capitalize?" capitalize":""),children:n.value}),n.copyable&&e.jsx(l.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>C(n.value,n.label),children:e.jsx(p.Link,{className:"h-3 w-3"})})]})]},n.label))})]}),i.usedOn&&i.usedOn.length>0&&e.jsxs("div",{className:"grid gap-3",children:[e.jsx(l.Label,{children:"Used On"}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2",children:i.usedOn.map((n,h)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-max text-left font-medium text-gray-900",children:n.name}),e.jsxs("div",{className:"text-gray-500",children:["(",n.slug,")"]})]},h))})]}),e.jsxs("div",{className:"grid gap-3 border rounded-md pt-2 bg-gray-100 relative",children:[e.jsx(l.Label,{className:"w-full text-center",children:"Description"}),e.jsx(l.Textarea,{id:"description",value:N,placeholder:"Enter a description for the asset",onChange:n=>g(n.target.value),rows:3,disabled:d,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:()=>t(N),disabled:d||!Z(N,i),className:`py-0 bg-blue-500 text-white px-3 py-0.5 rounded-md text-sm ${d||!Z(N,i)?"opacity-50 cursor-not-allowed":""}`,children:d?e.jsxs(e.Fragment,{children:[e.jsx(p.Loader,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):"Save"})})]})]})]})]})},Te=u.lazy(()=>Promise.resolve().then(()=>require("./image-editor-Da6lrqkL.cjs"))),Ee=25*1024*1024,Ie=({isUpdatingAsset:a,allowedTypes:r,uploadAssets:o,isUploadingAsset:t,onUploaded:d})=>{const[i,m]=u.useState(()=>{const f=localStorage.getItem("chai_optimize_images");return f!==null?f==="true":!0});u.useEffect(()=>{localStorage.setItem("chai_optimize_images",i.toString())},[i]);const y=a||t,N=u.useCallback(async f=>{try{const c=f;if(!c.every(b=>b.type.startsWith("image/")))return A.toast.error("Invalid file type. Please upload a valid file."),Promise.reject(new Error("Invalid file type"));const n=c.map(async b=>{let F=b;return b.type.startsWith("image/")&&(F=await Y.compressImageIfNeeded(b)),new Promise((P,B)=>{const U=new FileReader;U.readAsDataURL(F),U.onload=async()=>{P({file:U.result,folderId:void 0,name:b.name,optimize:i})},U.onerror=()=>B(null)})}),h=await Promise.all(n),j=await o(h);return(j==null?void 0:j.length)===1&&d(j[0]),j}catch(c){return Promise.reject(c)}},[o,i,d]),g=f=>{const c=[];let n=0;return f.forEach(h=>{h.size>Ee?n++:c.push(h)}),n>0&&A.toast.error(`${n===1&&f.length===1?"File":n+(n===1?" file":" files")} exceed the maximum size limit of 10MB.`),D.isEmpty(c)?[]:N(c)},{getRootProps:w,getInputProps:S,isDragActive:C}=fe.useDropzone({onDrop:g,accept:{"image/*":r.includes("image")?[]:[]},disabled:a||t,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 ${y?"pointer-events-none bg-gray-100 opacity-90":"bg-gray-100 hover:border-black/50 hover:bg-gray-100"}`,children:e.jsxs("div",{...w(),className:J.mergeClasses("flex h-max w-full cursor-pointer flex-col justify-center rounded-lg text-center",y?"items-start":"items-center",C?"border-primary bg-primary/5":"border-muted-foreground/20"),children:[e.jsx("input",{...S()}),y?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(p.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:a?"Updating file...":"Uploading file..."}),e.jsxs("div",{className:"text-xs font-light text-muted-foreground",children:["Please wait while we ",a?"update":"upload"," 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(p.Upload,{className:"h-4 w-4 text-indigo-500"})}),e.jsxs("div",{className:"text-left",children:[e.jsxs("div",{className:"font-medium",children:["Drop your file here or"," ",e.jsx("span",{className:"cursor-pointer text-indigo-500 hover:underline",children:"browse"})]}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:e.jsxs("span",{className:"",children:["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:["Optimization:"," ",e.jsx("span",{className:i?"text-indigo-600":"text-gray-400",children:i?"On":"Off"})]}),e.jsx(l.Switch,{checked:i,onCheckedChange:f=>{m(f)},onClick:f=>{f.stopPropagation()},className:"data-[state=checked]:bg-indigo-500"})]}),e.jsx(l.TooltipProvider,{children:e.jsxs(l.Tooltip,{children:[e.jsx(l.TooltipTrigger,{asChild:!0,children:e.jsx("span",{className:`flex cursor-help items-center text-amber-500 ${i?"invisible":""}`,children:e.jsx(p.AlertTriangle,{className:"mr-1 h-4 w-4"})})}),e.jsx(l.TooltipContent,{side:"top",children:e.jsxs("p",{className:"text-xs text-white",children:["Warning: Unoptimized images may affect ",e.jsx("br",{})," performance and page load times"]})})]})})]})]})]})})};function ke({close:a,onSelect:r,mode:o="image",assetId:t}){const m=u.useMemo(()=>[o],[o]),[y,N]=u.useState(null),[g,w]=u.useState(null),[S,C]=u.useState(null),[f,c]=u.useState({show:!1,file:""}),[n,h]=u.useState(!1),[j,b]=u.useState(t?"details":"grid"),[F,P]=u.useState(""),[B,U]=u.useState(""),[O,$]=u.useState(1),[G]=u.useState(30),[T,K]=u.useState([]);u.useEffect(()=>{t&&(N(t),b("details"))},[t]),u.useEffect(()=>{const s=setTimeout(()=>{P(B),$(1)},300);return()=>clearTimeout(s)},[B]);const{data:L,isLoading:M,refetch:ee}=we({search:F.toLowerCase().trim(),page:O,limit:G}),z=(L==null?void 0:L.assets)||[],te=(L==null?void 0:L.total)||0,E=Math.ceil(te/G);u.useEffect(()=>{M||E<=0||$(s=>s>E?E:s<1?1:s)},[M,E]);const se=(z==null?void 0:z.length)>0,{mutate:ie}=ye(),{mutateAsync:R,isPending:re}=ve(),{mutateAsync:_,isPending:le}=Ne(),W=u.useCallback(s=>{const x=Math.min(Math.max(1,s),Math.max(1,E));x!==O&&$(x)},[E,O]),ae=s=>{U(s.target.value)},ne=u.useCallback(s=>{K(x=>D.find(x,{id:s.id})?[]:[s])},[!1]),oe=u.useCallback(()=>{K([])},[]),V=s=>{(s==null?void 0:s.length)!==0&&(r(D.pick(D.first(s||T),["id","url","width","height","description"])),a())},ce=async s=>{w(s)},de=async()=>{g&&(C(g==null?void 0:g.id),await ie(g.id,{onSuccess:()=>{C(null),w(null)},onError:()=>{C(null)}}),w(null))},ue=s=>{N(s.id),b("details")},me=async(s,x)=>{try{const q=localStorage.getItem("chai_optimize_images")!=="false";if(x){const I=await R([{file:s,folderId:void 0,name:f.name||"",optimize:q}]);if((I==null?void 0:I.length)>0){const H=I[0];r({...D.pick(H,["id","width","height","description"]),url:H.url})}}else{const I=await _({id:f.id||"",file:s});I&&r({...D.pick(I,["id","width","height","description"]),url:I.url})}c({show:!1,file:""}),a()}catch(q){console.error("Error saving edited image:",q)}},he=u.useCallback(s=>{K([s])},[]),xe=u.useCallback(s=>{W(s)},[W]);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:"Digital Asset Manager"}),j==="grid"?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{maxFileSize:10,allowedTypes:m,uploadAssets:R,isUpdatingAsset:le,isUploadingAsset:re,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(p.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(l.Input,{placeholder:"Search assets...",onChange:ae,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(l.Button,{variant:"outline",size:"sm",onClick:()=>oe(),title:"Clear selection",children:"Clear"})}),e.jsx(l.Button,{size:"sm",onClick:()=>V(T),disabled:T.length===0,children:"Select Asset"})]})}):null,e.jsx(l.Button,{variant:"ghost",size:"icon",onClick:()=>ee(),children:e.jsx(p.RefreshCwIcon,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto pb-[66px]",children:M?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"})]}):!M&&!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(p.Archive,{className:"h-9 w-9 text-indigo-500"})}),e.jsx("div",{className:"text-lg text-muted-foreground",children:"No assets found"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:F.length>0?"No assets found for your search: "+F:"Start uploading assets to get started"}),e.jsx("br",{})]}):e.jsx("div",{className:"flex flex-wrap gap-3 p-1",children:z==null?void 0:z.map(s=>e.jsxs("div",{className:J.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(x=>x.id===s.id)?"border-blue-500":"hover:border-black/90",S&&(g==null?void 0:g.id)===s.id?"pointer-events-none opacity-50":"",S===s.id?"pointer-events-none opacity-50":""),onClick:()=>ne(s),onDoubleClick:()=>V([s]),children:[e.jsxs("div",{className:"aspect-square relative overflow-hidden",children:[S===s.id?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:e.jsx(p.Loader,{className:"h-8 w-8 animate-spin text-white"})}):null,s.type==="image"?e.jsx("img",{src:`${s.thumbnailUrl||"/placeholder.svg"}?v=${(s==null?void 0:s.updatedAt)||s.createdAt}`,alt:s.name,className:`h-full min-h-[80px] w-full object-contain ${T.some(x=>x.id===s.id)?"":"group-hover:blur group-hover:contrast-50"}`}):e.jsxs("div",{className:"flex h-full items-center justify-center",children:[e.jsx(p.Film,{className:"h-12 w-12 text-muted-foreground"}),s.thumbnailUrl&&e.jsx("img",{src:`${s.thumbnailUrl||"/placeholder.svg"}?v=${(s==null?void 0:s.updatedAt)||s.createdAt}`,alt:s.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:s.name,children:s.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((s==null?void 0:s.size)||0)})})]}),!T.some(x=>x.id===s.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(l.TooltipProvider,{children:e.jsxs(l.Tooltip,{children:[e.jsx(l.TooltipTrigger,{asChild:!0,children:e.jsx(l.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:x=>{x.stopPropagation(),ue(s)},children:e.jsx(p.ImageIcon,{className:"h-4 w-4"})})}),e.jsx(l.TooltipContent,{children:e.jsx("p",{children:"View Details"})})]})}),e.jsx(l.TooltipProvider,{children:e.jsxs(l.Tooltip,{children:[e.jsx(l.TooltipTrigger,{asChild:!0,children:e.jsx(l.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:x=>{x.stopPropagation(),navigator.clipboard.writeText(s.url),A.toast.success("Asset URL copied to clipboard")},children:e.jsx(p.Copy,{className:"h-4 w-4"})})}),e.jsx(l.TooltipContent,{children:e.jsx("p",{children:"Copy URL"})})]})}),e.jsx(l.TooltipProvider,{children:e.jsxs(l.Tooltip,{children:[e.jsx(l.TooltipTrigger,{asChild:!0,children:e.jsx(l.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:x=>{x.stopPropagation(),c({id:s.id,show:!0,file:s.url,name:s.name})},children:e.jsx(p.Edit,{className:"h-4 w-4"})})}),e.jsx(l.TooltipContent,{children:e.jsx("p",{children:"Edit Image"})})]})}),e.jsx(l.TooltipProvider,{children:e.jsxs(l.Tooltip,{children:[e.jsx(l.TooltipTrigger,{asChild:!0,children:e.jsx(l.Button,{variant:"destructive",size:"icon",className:"h-8 w-8 rounded-full",onClick:x=>{x.stopPropagation(),ce(s)},children:e.jsx(p.Trash2,{className:"h-4 w-4"})})}),e.jsx(l.TooltipContent,{children:e.jsx("p",{children:"Delete Asset"})})]})})]})}),T.some(x=>x.id===s.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(p.Check,{className:"h-3 w-3 text-white",strokeWidth:5})})]},s.id))})}),E>1&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 border-t bg-white p-4",children:e.jsx(ge,{fallback:e.jsx("div",{className:"text-red-500",children:"Error loading pagination"}),children:e.jsx(be,{currentPage:O,totalPages:E,onPageChange:xe,pageRangeDisplayed:3,showPageInput:!0})})})]})]}):e.jsx(Se,{assetId:y||t||"",onBack:()=>{b("grid"),N(null)},onEdit:s=>{c({id:s.id,show:!0,file:s.url,name:s.name})},onSave:async s=>{if(y){h(!0);try{const x=z.find(q=>q.id===y);x&&await _(D.merge(x,{description:s}))}finally{h(!1)}}},isSaving:n})]}),f.show&&e.jsx(u.Suspense,{fallback:e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(p.Loader,{className:"h-8 w-8 animate-spin"})}),children:e.jsx(Te,{imageUrl:f.file,onSave:me,onClose:()=>c({show:!1,file:""}),defaultSavedImageName:f.name,isEditing:!!f.id})}),g&&e.jsx(l.Dialog,{open:!!g,onOpenChange:()=>w(null),children:e.jsxs(l.DialogContent,{children:[e.jsxs(l.DialogHeader,{children:[e.jsx(l.DialogTitle,{children:"Delete Asset"}),e.jsxs(l.DialogDescription,{children:['Are you sure you want to delete "',g.name,'"? This action cannot be undone.']})]}),e.jsxs(l.DialogFooter,{className:"gap-2 sm:gap-0",children:[e.jsx(l.Button,{variant:"outline",onClick:()=>w(null),children:"Cancel"}),e.jsx(l.Button,{variant:"destructive",onClick:de,children:"Delete"})]})]})})]})}exports.default=ke;
@@ -1,5 +0,0 @@
1
- "use strict";var Vn=Object.defineProperty;var ms=e=>{throw TypeError(e)};var Qn=(e,t,s)=>t in e?Vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var ge=(e,t,s)=>Qn(e,typeof t!="symbol"?t+"":t,s),Es=(e,t,s)=>t.has(e)||ms("Cannot "+s);var w=(e,t,s)=>(Es(e,t,"read from private field"),s?s.call(e):t.get(e)),R=(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),k=(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"),H=require("jotai"),T=require("@tanstack/react-query"),C=require("@chaibuilder/sdk"),F=require("sonner"),m=require("@chaibuilder/sdk/ui"),v=require("lucide-react"),Ns=require("@chaibuilder/runtime"),zn=require("@chaibuilder/sdk/web-blocks");function $n(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=$n(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"},Wn=H.atom({}),Dt=()=>H.useAtom(Wn),ee=(e,t)=>{const[s]=Dt();return h.useMemo(()=>p.get(s,e,t),[s,e,t])},j=()=>ee("apiUrl","/chai/api"),Gs=()=>ee("usersApiUrl","/chai/users"),Yn=()=>ee("assetsApiUrl","/chai/assets"),Jn=()=>ee("websocket",null),Xn=async(e,t,s={})=>await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)}),L=()=>{const e=ee("onLogout"),t=ee("getAccessToken");return h.useCallback(async(s,n,r={})=>{const a=await t();if(!a)return console.error("No auth token found"),null;try{const i=p.get(n,"action","").toLowerCase(),l=await Xn(s+(i?`?action=${i}`:""),n,{...r,Authorization:`Bearer ${a}`});if(l.status===401)return console.log("401 Response",l),e(),window.location.reload(),null;if(!l.ok){const c=await l.json();throw console.error(`API Error (${l.status}):`,c),{status:l.status,statusText:l.statusText,...c,message:c.error||c.message||`Server error: ${l.status}`}}return await l.json()}catch(i){throw console.error("API request failed:",n,i),i}},[e,t])};function te(){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 ye=e=>{const t=j(),[s]=te(),n=e??s.get("page"),r=L();return T.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})},Ae=()=>{const e=j(),t=L();return T.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}=C.useLanguages(),{data:s}=Ae(),{data:n,isFetching:r}=ye(),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 Ds{constructor(t,s,n,r){ge(this,"channelId");ge(this,"websocket");ge(this,"channel",null);ge(this,"userId",null);ge(this,"clientId",null);ge(this,"pageId",null);ge(this,"callback");var a,i,l,c,d,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=(d=(c=(l=(i=(a=this.channel)==null?void 0:a.on("presence",{event:"sync"},u=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",u)}))==null?void 0:i.on("presence",{event:"leave"},u=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",u)}))==null?void 0:l.on("presence",{event:"join"},u=>{this.callback("UPDATE_ONLINE_USERS",{pageToUser:this.getPageUserMapping()}),this.onReceiveEvent("SYNC",u)}))==null?void 0:c.on("broadcast",{event:"TAKE_OVER_REQUESTED"},({payload:u})=>this.onReceiveEvent("TAKE_OVER_REQUESTED",u)))==null?void 0:d.on("broadcast",{event:"TAKE_OVER_REQUEST_ACCEPTED"},({payload:u})=>this.onReceiveEvent("TAKE_OVER_REQUEST_ACCEPTED",u)))==null||f.on("broadcast",{event:"TAKE_OVER_REQUEST_REJECTED"},({payload:u})=>this.onReceiveEvent("TAKE_OVER_REQUEST_REJECTED",u)).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 Zn=H.atom(null),ks=()=>H.useAtom(Zn),ss=()=>{const[e]=ks();return(e==null?void 0:e.slug)||""};function er(e,t){const[s,n]=h.useState(e);return h.useEffect(()=>{const r=setTimeout(()=>n(e),t);return()=>clearTimeout(r)},[e,t]),s}const tr=({query:e,uuid:t})=>{const{selectedLang:s,fallbackLang:n}=C.useLanguages(),{data:r}=Z(),a=r==null?void 0:r.pageType,i=j(),l=L(),{data:c,isFetching:d}=T.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(u=>u.lang===""||u.lang===n):c.filter(u=>u.lang===s),[s,n,c]);return{allLangPages:c,data:f,isFetching:d}},js=()=>{const{selectedLang:e,fallbackLang:t}=C.useLanguages(),[s,n]=ks(),[r,a]=h.useState(""),i=er(r,500),{allLangPages:l,data:c,isFetching:d}=tr({query:i}),f=h.useCallback(E=>n(E),[n]),u=h.useCallback(E=>a(E),[a]),g=h.useCallback(()=>{if(!s)return;const E=!(s!=null&&s.primaryPage),S=e.length===0,P=E?s==null?void 0:s.id:s==null?void 0:s.primaryPage,A=l.filter(x=>(x==null?void 0:x.primaryPage)===P||x.id===P).find(x=>S?x.lang===e||x.lang===t:x.lang===e);n(A||s)},[s,e,l,n,t]);return{isFetching:d,dynamicPage:s,searchQuery:r,selectedLang:e,dynamicPages:c,allLangPages:l,updateDynamicPage:f,updateSearchQuery:u,onChangeLanguage:g}},sr=H.atom({lastSaved:void 0}),kt=()=>H.useAtom(sr),Z=()=>{const[e]=te(),t=e.get("page"),{data:s,isFetching:n}=ye();return{data:h.useMemo(()=>({...p.find(s,{id:t})||{}}),[s,t]),isFetching:n}},ue=()=>{const[e]=te(),t=e.get("lang")??"",{data:s,isFetching:n}=ye();return{data:h.useMemo(()=>p.find(s,{lang:t})||{},[s,t]),isFetching:n}},nr=H.atom({}),rr=()=>H.useAtom(nr),ar=()=>{const{data:e}=ue(),t=ss(),s=ee("getLiveUrl",p.noop),n=e==null?void 0:e.slug,r=s(n||"/");return t?r+t:r},He=()=>{const e=ee("currentUser"),t=ee("onLogout");return{isLoggedIn:!!e,user:e,logout:t}},Os=e=>{const t=Gs(),s=L();return T.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"})},ir=H.atom({status:"checking",requestedBy:"",isTakeOverRequested:!1,requestingClientId:"",isActiveInOtherTab:!1}),or=H.atom(""),lr=H.atom(null),ns=H.atom({}),cr=()=>H.useAtom(ns),Se=()=>{const[e]=te(),t=e.get("page"),[s,n]=H.useAtom(ir),[r,a]=H.useAtom(lr),[i,l]=H.useAtom(or),[c]=H.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"}},ur=()=>{const e=Jn(),{data:t}=Z(),{user:s}=He(),n=t==null?void 0:t.id,{data:r}=Ae(),{pageLock:a,setPageLock:i,setLockingStatus:l,realtimeInstance:c,setRealtimeInstance:d}=Se(),[,f]=H.useAtom(ns),u=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)=>{var x,D;switch(_){case"UPDATE_ONLINE_USERS":f((A==null?void 0:A.pageToUser)||{});break;case"PAGE_LOCKED":i({...g==null?void 0:g.current,requestedBy:"",status:"locked",isActiveInOtherTab:A==null?void 0:A.isActiveInOtherTab});break;case"USER_JOINED":if(((x=g==null?void 0:g.current)==null?void 0:x.status)==="editing")return;((D=g==null?void 0:g.current)==null?void 0:D.status)==="locked"&&l("can_edit_now"),i({...g==null?void 0:g.current,requestedBy:"",status:"editing",isActiveInOtherTab:A==null?void 0:A.isActiveInOtherTab});break;case"TAKE_OVER_REQUESTED":i({...g==null?void 0:g.current,requestingClientId:A==null?void 0:A.requestingClientId,requestedBy:A!=null&&A.isRequestedFromAnotherTab?"ANOTHER_TAB":A==null?void 0:A.requestedBy});break;case"TAKE_OVER_REQUEST_ACCEPTED":A!=null&&A.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}},P=new Ds(e,r==null?void 0:r.appKey,s==null?void 0:s.id,S);d(P)}},[d,e,r==null?void 0:r.appKey]),h.useEffect(()=>{g.current=a},[a]),h.useEffect(()=>{if(!(!c||!n||!(s!=null&&s.id)||u.current))return u.current=!0,c==null||c.joinPage(n),()=>{c&&u.current&&(u.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}=Z(),{user:t}=He(),s=e==null?void 0:e.id,{pageLock:n,setPageLock:r,realtimeInstance:a}=Se(),{savePageAsync:i}=C.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]),d=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:d,requestTakeOver:l}},dr=h.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-content-ECt0SxFX.cjs"))),fr=h.lazy(()=>Promise.resolve().then(()=>require("./page-locked-by-dialog-BIC-c0Jl.cjs"))),Ft=h.lazy(()=>Promise.resolve().then(()=>require("./page-lock-request-fGZbOFTp.cjs"))),hr=({isFetchingPage:e})=>{const{pageLock:t,requestTakeOver:s}=Rs(),{currentEditor:n,lockingStatus:r,setLockingStatus:a,realtimePageLockEnabled:i}=Se(),{data:l,isFetching:c}=Os(n),[d]=te(),f=d.get("page"),[u]=kt(),g=T.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(Ft,{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(Ft,{lockingStatus:r,onContinue:()=>{g.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),a("")}})}):null:t!=null&&t.isActiveInOtherTab?o.jsx(h.Suspense,{children:o.jsx(Ft,{lockingStatus:"page_is_active_in_other_tab",onContinue:s})}):o.jsx(h.Suspense,{children:o.jsx(fr,{...l,isFetchingUserInfo:c,name:(l==null?void 0:l.name)||"Unknown User",email:(l==null?void 0:l.email)||"",lastSaved:(u==null?void 0:u.lastSaved)||"",onTakeOver:E,realtimePageLockEnabled:i,isRequestRejected:r==="take_over_request_rejected"})})},gr=()=>{const[e]=te(),t=e.get("lang");return ts(t)?null:o.jsx(h.Suspense,{children:o.jsx(dr,{})})},$e={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 jt=H.atom(null),Ot=()=>{const{data:e}=Ae();return h.useMemo(()=>(e==null?void 0:e.fallbackLang)||"en",[e])},as=()=>{const e=L(),t=j();return T.useQuery({queryKey:[y.GET_WEBSITE_PAGES],staleTime:1e3*60*5,queryFn:async()=>e(t,{action:y.GET_WEBSITE_PAGES})||[],placeholderData:s=>s||[]})},mr=e=>{const t=L(),s=j(),n=Ot();return T.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||{}})},Er=h.lazy(()=>Promise.resolve().then(()=>require("./page-manager-new-CUfjlMed.cjs"))),Us=({children:e})=>{const[t,s]=te(),n=t.get("page"),{data:r,isFetching:a}=Z(),{data:i,isFetching:l}=as(),[c,d]=h.useState(!1),[f,u]=h.useState(!0),{savePage:g}=C.useSavePage(),E=!!n&&!p.isEmpty(r),S=h.useMemo(()=>{if(!i||l)return!1;const x=i.find(D=>D.slug==="/");return x==null?void 0:x.id},[i,l]);h.useEffect(()=>{if(l||!S||i.some(q=>q.id===n))return;const D=new URLSearchParams({page:S});rs(D,s),!l&&i&&u(!1)},[n,l,i,S,s]);const P=!f&&!n,_=!f&&!a&&p.isEmpty(r),A=c||P||_;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:()=>{g(),d(!0)},children:e||o.jsx(m.Button,{variant:"outline",className:"flex w-full items-center space-x-2 py-1",children:o.jsx(v.LogsIcon,{className:"h-4 w-4"})},"template-viewer")}),o.jsx(m.TooltipContent,{side:"right",children:o.jsx("p",{children:"Open pages manager"})})]})})}),o.jsx(m.Sheet,{open:A,onOpenChange:x=>!x&&E&&d(!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 ${E?"":"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(v.Folder,{className:"h-4 w-4"})}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-sm font-semibold",children:"Pages"}),o.jsx("span",{id:"pages-manager-description",className:"text-xs font-normal text-muted-foreground",children:"Manage your site structure"})]})]}),o.jsx(m.SheetDescription,{className:"sr-only",children:"Manage your site structure"})]}),o.jsx("div",{className:"h-[calc(100vh-80px)] overflow-y-auto",children:A&&o.jsx(h.Suspense,{children:o.jsx(Er,{close:()=>d(!1)})})})]})})]})},pr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-language-page-D3PSLiUv.cjs"))),yr=()=>{const e=ee("topLeftCorner",null);return e?o.jsx("div",{className:"max-h-9 w-full overflow-hidden pr-2",children:h.createElement(e,{})}):null},Ms=({showAdd:e=!0,variant:t="ghost"})=>{const{fallbackLang:s,languages:n,selectedLang:r,setSelectedLang:a}=C.useLanguages(),i=p.isEmpty(r)?s:r,[,l]=te(),{isLocked:c}=Se();h.useEffect(()=>{const _=new URLSearchParams(window.location.search),A=_.get("lang");A&&(n.includes(A)?a(A):(_.delete("lang"),l(_),a("")))},[n,l,a]);const[,d]=H.useAtom(jt),{data:f}=Z(),{data:u}=Ae(),{data:g}=ye(),E=h.useMemo(()=>{const _=p.compact(p.map(p.get(u,"languages"),A=>{const x=p.find(g,{lang:A});return{key:A,value:p.get($e,A,A),isLangPageAdded:!!x}})).filter(Boolean);return[{key:s,value:p.get($e,s),isLangPageAdded:!0},..._]},[s,g,u]),S=_=>{if(document.querySelector('[data-panel-id="seo"]')){const x=new CustomEvent("seo-language-switch-check",{detail:{fromLang:i,toLang:_,switchHandler:()=>P(_)}});window.dispatchEvent(x);return}P(_)},P=_=>{a(_);const A=new URLSearchParams(window.location.search);_===s?A.delete("lang"):A.set("lang",_),rs(A,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(v.Languages,{className:"h-4 w-4"}),p.get($e,i,i),o.jsx(v.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(v.Languages,{className:"h-4 w-4"}),p.get($e,i,i),o.jsx(v.ChevronDown,{className:"h-4 w-4"})]})}),o.jsxs(m.DropdownMenuContent,{className:"space-y-1 border-border",children:[p.map(E.filter(_=>_.isLangPageAdded),_=>o.jsxs(m.DropdownMenuItem,{className:C.mergeClasses("flex cursor-pointer items-center justify-between text-xs font-medium text-gray-800",_.key===i&&"!bg-gray-200 text-gray-700"),onClick:()=>S(_.key),children:[o.jsx("div",{className:"text-slate-600",children:_.value}),_.key===s&&o.jsxs("small",{className:"flex items-center gap-x-1 text-[9px] leading-none text-orange-500",children:[o.jsx(v.Star,{fill:"orange",className:"h-2 w-2"}),"Primary"]})]},_.value)),e&&!p.isEmpty(E.filter(_=>!_.isLangPageAdded))&&o.jsxs(o.Fragment,{children:[o.jsx(m.Separator,{}),o.jsxs(m.Button,{size:"sm",variant:"ghost",onClick:()=>{f&&d({edit:!1,primaryPage:f.id})},className:"text-xs font-normal duration-200 hover:bg-slate-300 hover:text-slate-800",children:[o.jsx(v.Plus,{className:"mr-1 h-3 w-3"})," Add Langauge"]})]})]})]})})};function Ar(){const[e,t]=H.useAtom(jt);return o.jsxs("div",{className:"relative z-10 flex items-center justify-end gap-1",children:[o.jsx(yr,{}),o.jsx(Us,{}),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 Sr(){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 Tr=z.lazy(()=>Promise.resolve().then(()=>require("./page-revisions-content-Tb3T6zvU.cjs")));function Pr(){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(v.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(Sr,{}),children:o.jsx(Tr,{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}=C.usePermissions();return e&&!r(e)||t&&!t.some(a=>r(a))?n:s},Y={TOGGLE_PREVIEW:"Toggle Preview",OPEN_PREVIEW_IN_NEW_TAB:"Open preview in new tab",THEME:"Theme",SAVEDRAFT:"Save draft",SAVING:"Saving",SAVED:"Saved",PUBLISHED:"Published",PUBLISH:"Publish",UNPUBLISH:"Unpublish",WEBSITEDATA:"Website data",OPEN:"Open",EDIT_LANGUAGE:"Edit language",ADD_NEW_LANGUAGE:"Add new language page",ENTER_LANGUAGE_DETAILS:"Enter the details for the language",LANGUAGE:"Language",PAGE_NAME:"Page Name",SLUG:"Slug",UPDATE:"Update",UPDATING:"Updating...",ADDING:"Adding...",CHOOSE_LANGUAGE:"Choose language",ALL_AVAILABLE_LANGUAGE_PAGE:"All available language page is created.",TO_UPDATE_SLUG:"To update slug use 'Change slug' action",SLUG_SHOULD_START_WITH:" (Slug should start with /{lang})",CHOOSE_LANGUAGE_TO_ADD_SLUG:"Choose language to add slug",ENTER_PAGE_SLUG:"Enter page slug",ENTER_PAGE_NAME:"Enter page name",DELETE:"Delete",CHANGE_SLUG:"Change slug",PRIMARY:"Primary",SLUG_MUST_START_WITH:"Slug must start with /",EDIT:"Edit",UNPUBLISH_MSG:"Are you sure you want to unpublish",MARK_AS_TEMPLATE:"Mark as template",UNMARK_AS_TEMPLATE:"Unmark as template",PAGE_ADD_SUCCESS:"New page added successfully.",GLOBAL_BLOCK_ADD_SUCCESS:"New global block added successfully.",SEO_SETTINGS_UPDATE_SUCCESS:"SEO Settings updated successfully.",PAGE_UPDATE_SUCCESS:"Page updated successfully.",GLOBAL_BLOCK_UPDATE_SUCCESS:"Global block updated successfully.",PAGE_DELETE_SUCCESS:"Page deleted successfully.",GLOBAL_BLOCK_DELETE_SUCCESS:"Global block deleted successfully.",PAGE_UNPUBLISH_SUCCESS:"Page unpublished successfully.",GLOBAL_BLOCK_UNPUBLISH_SUCCESS:"Global block unpublished successfully.",PAGE_PUBLISH_SUCCESS:"Page published successfully.",GLOBAL_BLOCK_PUBLISH_SUCCESS:"Global block published successfully.",PAGES_PUBLISH_SUCCESS:"Your changes have been published successfully.",SLUG_CHANGE_SUCCESS:"Slug changed successfully."},_r={SLUG_ALREADY_USED:"This slug is already in use. Please choose a different one."},de=()=>{const e=j(),t=L();return T.useQuery({queryKey:[y.GET_PAGE_TYPES],staleTime:1/0,placeholderData:[],queryFn:async()=>t(e,{action:y.GET_PAGE_TYPES})})},Bs=e=>{const{data:t}=de();return h.useMemo(()=>t==null?void 0:t.find(s=>s.key===e),[t,e])},xr=()=>{const e=j(),t=L();return T.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),[]}}})},wr=()=>{const e=j(),t=T.useQueryClient(),s=L(),{data:n}=de();return T.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(_r,r.message,r.message)})}})},vr=()=>{const e=j(),t=T.useQueryClient(),s=L(),{data:n}=ue(),{data:r}=de();return T.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})}})},br=()=>{const e=j(),t=T.useQueryClient(),s=L(),{data:n}=de();return T.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})}})},Cr=()=>{const e=j(),t=T.useQueryClient(),s=L(),{data:n}=de();return T.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?Y.PAGE_UNPUBLISH_SUCCESS:"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=j(),t=L(),s=T.useQueryClient(),{data:n}=Z(),{savePageAsync:r}=C.useSavePage();return T.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.")}})},Ir=()=>{const e=j(),t=L(),s=T.useQueryClient();return T.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.")}})},Lr=()=>{const e=j(),t=L(),s=T.useQueryClient();return T.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.")}})},Nr=()=>{const e=j(),t=L(),s=T.useQueryClient();return T.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(Y.SLUG_CHANGE_SUCCESS),r?s.invalidateQueries({queryKey:[y.GET_LANGUAGE_PAGES,r]}):s.invalidateQueries({queryKey:[y.GET_WEBSITE_PAGES]})},onError:()=>{F.toast.error("Failed to change slug")}})},Gr=h.lazy(()=>Promise.resolve().then(()=>require("./publish-pages-content-BGkEZ3GK.cjs")));function Dr({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(Gr,{onClose:t,isPending:n,publishPage:s})})})}const se={...C.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"},kr={particleCount:350,spread:120,origin:{y:.6},angle:90},jr={TOP_RIGHT:{angle:225,origin:{x:.9,y:0}},BOTTOM_RIGHT:{angle:100,origin:{x:.9,y:.9}}},Or=async()=>{const{default:e}=await Promise.resolve().then(()=>require("./confetti.module-BuUnQuWk.cjs"));return e},Pt=e=>{let t=jr[e];t||(t={});const s={...kr,...t};Or().then(n=>n(s))};function Rt({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 Rr=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-gtGfNOAq.cjs"))),Ur=h.lazy(()=>Promise.resolve().then(()=>require("./translation-warning-modal-Kctu12rQ.cjs"))),Mr=()=>{const{selectedLang:e,fallbackLang:t}=C.useLanguages(),s=ee("getPreviewUrl",async u=>u),[n,r]=h.useState(""),{data:a}=Z(),{data:i}=ye(),{data:l}=de(),c=h.useMemo(()=>{var u;return(u=i==null?void 0:i.find(g=>(g==null?void 0:g.lang)===e))==null?void 0:u.slug},[e,i]),d=h.useCallback(u=>{var g;return(g=p.find(l,{key:u}))==null?void 0:g.hasSlug},[l]),f=e===t?"":e;return h.useEffect(()=>{(async()=>{if(typeof s=="function"){const u=!d(a==null?void 0:a.pageType),g=await s(u?`${f!==""?f+"/":""}${a==null?void 0:a.id}`:c||"");r(g)}else r("")})()},[s,c,a==null?void 0:a.pageType,d,a==null?void 0:a.id,f]),o.jsx(o.Fragment,{children:o.jsx(Rt,{content:Y.OPEN_PREVIEW_IN_NEW_TAB,delayDuration:0,children:o.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:o.jsx(m.Button,{variant:"ghost",size:"sm",className:"gap-2",children:o.jsx(v.Play,{className:"h-4 w-4"})})})})})},Br=()=>{const[e,t]=C.useRightPanel();return o.jsxs(o.Fragment,{children:[o.jsx(Rt,{content:Y.THEME,delayDuration:0,children:o.jsx(m.Button,{variant:e==="theme"?"outline":"ghost",size:"icon",className:"gap-2",onClick:()=>t(e==="theme"?"block":"theme"),children:o.jsx(v.Palette,{className:"h-4 w-4"})})}),o.jsx("div",{className:"h-4 w-px bg-gray-200 dark:bg-gray-700"})]})},Fr=()=>{const[e,t]=h.useState(!1),{isLocked:s}=Se(),{savePageAsync:n,saveState:r}=C.useSavePage();h.useEffect(()=>{const d=f=>{r==="UNSAVED"&&(f.preventDefault(),f.returnValue=!1)};return r==="UNSAVED"&&window.addEventListener("beforeunload",d),()=>{window.removeEventListener("beforeunload",d)}},[r]);const a=h.useCallback(async()=>{e||(t(!0),await n(),t(!1))},[n,e]),{buttonIcon:i,buttonClass:l,tooltipContent:c}=h.useMemo(()=>{switch(r){case"UNSAVED":return{tooltipContent:Y.SAVEDRAFT,buttonIcon:o.jsx(v.Save,{className:"h-4 w-4"}),buttonClass:"gap-x-1"};case"SAVING":return{tooltipContent:Y.SAVING,buttonIcon:o.jsx(v.Loader,{className:"h-4 w-4 animate-spin text-sky-700"}),buttonClass:"gap-x-1"};case"SAVED":return{tooltipContent:Y.SAVED,buttonIcon:o.jsx(v.CheckCircle,{className:"h-4 w-4"}),buttonClass:"text-green-500 gap-x-1"}}},[r]);return s?null:o.jsxs(m.Button,{size:"sm",variant:"ghost",onClick:a,className:`${l} w-24 max-w-24`,children:[i," ",c]})},qr=()=>{const{selectedLang:e}=C.useLanguages(),{data:t}=ue(),{data:s}=ye(),[n,r]=h.useState(!1),[a,i]=h.useState(!1),[l,c]=h.useState(null),{savePageAsync:d}=C.useSavePage(),[f,u]=h.useState(!1),{data:g}=Z(),{mutate:E,isPending:S}=is(),{needTranslations:P}=C.useSavePage(),_=P(),{buttonText:A,buttonClassName:x,isPublished:D}=h.useMemo(()=>{const U=g&&(g==null?void 0:g.online);return{buttonClassName:U?"hover:bg-green-600 bg-green-500":"",isPublished:U,buttonText:U?Y.PUBLISHED:Y.PUBLISH}},[g]),q=async()=>{if(_){u(!0);return}V()},V=()=>{const U=[t==null?void 0:t.id,t==null?void 0:t.primaryPage];E({ids:p.compact(U)},{onSuccess:()=>Pt("TOP_RIGHT")})},O=()=>{u(!1),V()},oe=async()=>{u(!1),await d()},le=h.useMemo(()=>p.map(s??[],"id"),[s]);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex",children:[o.jsxs(m.Button,{size:"sm",onClick:q,disabled:S||!(g!=null&&g.id),className:`relative flex items-center gap-1 overflow-hidden rounded-r-none text-white transition-all duration-300 ease-in-out ${x}`,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[o.jsx("span",{className:`flex items-center transition-transform duration-300 ease-in-out ${a?"-translate-y-10":""}`,children:D?o.jsx(v.Send,{className:"h-4 w-4"}):o.jsx(v.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 ${a?"":"translate-y-10"}`,children:D?o.jsx(v.Rocket,{className:"h-4 w-4"}):o.jsx(v.Send,{className:"h-4 w-4"})}),o.jsx("span",{children:A}),e?`(${p.upperCase(e)})`:""]}),o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,children:o.jsx(m.Button,{size:"sm",disabled:S||!(g!=null&&g.id),className:`rounded-l-none border-l border-white/50 px-2 text-white ${x}`,children:o.jsx(v.ChevronDown,{className:"h-4 w-4"})})}),o.jsxs(m.DropdownMenuContent,{align:"end",className:"w-52",children:[o.jsxs(m.DropdownMenuItem,{disabled:S,className:"cursor-pointer text-xs",onClick:()=>E({ids:le},{onSuccess:()=>Pt("TOP_RIGHT")}),children:[Y.PUBLISH," with translation pages"]}),!D&&o.jsxs(m.DropdownMenuItem,{disabled:S,className:"cursor-pointer text-xs",onClick:()=>E({ids:[g==null?void 0:g.id]},{onSuccess:()=>Pt("TOP_RIGHT")}),children:[Y.PUBLISH," page"]}),o.jsxs(m.DropdownMenuItem,{onClick:()=>r(!0),className:"cursor-pointer text-xs",children:[Y.OPEN," publish menu"]}),D&&o.jsxs(m.DropdownMenuItem,{onClick:()=>c(t),className:"cursor-pointer text-xs",children:[Y.UNPUBLISH," page ",e?`(${p.upperCase(e)})`:""]})]})]})]}),o.jsx(Dr,{showModal:n,onClose:()=>r(!1)}),l&&o.jsx(h.Suspense,{children:o.jsx(Rr,{page:l,onClose:()=>c(null)})}),f&&o.jsx(h.Suspense,{children:o.jsx(Ur,{isOpen:f,onClose:oe,onContinue:O,isPending:S})})]})};function Kr(){const{isLocked:e}=Se(),[t]=te(),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(Pr,{}),o.jsx(Tt,{permission:se.EDIT_THEME,children:o.jsx(Br,{})}),o.jsx(Mr,{}),o.jsx(Tt,{permission:se.SAVE_PAGE,children:o.jsx(Fr,{})}),o.jsx(Tt,{permission:se.PUBLISH_PAGE,children:o.jsx(qr,{})})]})}const Fs=({page:e,setDuplicatePage:t,setAddEditPage:s,setUnpublishPage:n,setDeletePage:r,setMarkAsTemplate:a,setUnmarkAsTemplate:i,children:l,isLanguagePage:c})=>{const{hasPermission:d}=C.usePermissions(),{data:f}=de(),u=h.useMemo(()=>p.find(f,{key:e.pageType}),[f,e.pageType]),g=h.useMemo(()=>!!e.isTemplate,[e.isTemplate]),E=h.useMemo(()=>!!(u!=null&&u.hasSlug),[u==null?void 0:u.hasSlug]);return!d(se.EDIT_PAGE)&&!d(se.DELETE_PAGE)&&!d(se.UNPUBLISH_PAGE)||!e?null:o.jsxs(m.DropdownMenu,{children:[o.jsx(m.DropdownMenuTrigger,{asChild:!0,onClick:P=>P.stopPropagation(),children:l}),o.jsxs(m.DropdownMenuContent,{align:"center",className:"text-sm",children:[d(se.ADD_PAGE)&&!c&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),t(e)},children:[o.jsx(v.CopyPlusIcon,{className:"size-3"}),"Duplicate page"]}),d(se.EDIT_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),s({...e,global:!(u!=null&&u.hasSlug)})},children:[o.jsx(v.Pencil,{className:"size-3"}),"Edit"]}),(e==null?void 0:e.online)&&d(se.UNPUBLISH_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),n(e)},children:[o.jsx(v.Power,{className:"size-3"}),Y.UNPUBLISH]}),d(se.DELETE_PAGE)&&o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),r(e)},children:[o.jsx(v.Trash,{className:"size-3"}),Y.DELETE]}),d(se.MARK_AS_TEMPLATE)&&E&&!c&&o.jsx(o.Fragment,{children:g?o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),i(e)},children:[o.jsx(v.SquareLibrary,{className:"size-3"}),Y.UNMARK_AS_TEMPLATE]}):o.jsxs(m.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:P=>{P.stopPropagation(),a(e)},children:[o.jsx(v.SquareLibrary,{className:"size-3"}),Y.MARK_AS_TEMPLATE]})})]})]})},Hr=h.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-YpzILOYq.cjs"))),Vr=h.lazy(()=>Promise.resolve().then(()=>require("./delete-page-w64MO7db.cjs"))),Qr=h.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-DB_c7V2t.cjs"))),zr=h.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-C4wH4UKf.cjs"))),$r=h.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-C8hTjRVk.cjs"))),Wr=h.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-gtGfNOAq.cjs"))),Yr=()=>{const[e,t]=h.useState(null),[s,n]=h.useState(null),[r,a]=h.useState(null),[i,l]=h.useState(null),[c,d]=h.useState(null),[f,u]=h.useState(null),{data:g,isFetching:E}=ue(),{selectedLang:S,fallbackLang:P}=C.useLanguages(),{data:_}=ye(),A=_==null?void 0:_.find(O=>O.lang===S),{isLocked:x}=Se(),D=!(g!=null&&g.slug),[,q]=H.useAtom(jt);if(!g)return null;const V=O=>{S.length>0&&S!==P?q({edit:!0,id:O==null?void 0:O.id,primaryPage:O==null?void 0:O.primaryPage}):u(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(Us,{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(v.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:[D?o.jsx(v.Globe,{className:"mr-1 h-4 w-4"}):o.jsx(v.File,{className:"mr-1 h-4 w-4"}),p.get(A||g,"name")??""]})})}),x?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(v.MoreHorizontal,{className:"h-4 w-4"})}):o.jsx(Fs,{page:g,setDuplicatePage:O=>d(O),setAddEditPage:O=>V(O),setUnpublishPage:O=>n(O),setDeletePage:O=>t(O),setMarkAsTemplate:O=>a(O),setUnmarkAsTemplate:O=>l(O),isLanguagePage:S.length>0&&S!==P,children:o.jsx(m.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded",children:o.jsx(v.MoreHorizontal,{className:"h-4 w-4"})})})]}),f&&o.jsx(h.Suspense,{children:o.jsx(Hr,{closePanel:()=>u(null),editPage:()=>{},addEditPage:f,setAddEditPage:u})}),e&&o.jsx(h.Suspense,{children:o.jsx(Vr,{page:e,onClose:()=>t(null)})}),s&&o.jsx(h.Suspense,{children:o.jsx(Wr,{page:s,onClose:()=>n(null)})}),r&&o.jsx(h.Suspense,{children:o.jsx(zr,{page:r,onClose:()=>a(null)})}),i&&o.jsx(h.Suspense,{children:o.jsx($r,{page:i,onClose:()=>l(null)})}),c&&o.jsx(h.Suspense,{children:o.jsx(Qr,{page:c,onClose:()=>d(null),closePanel:()=>u(null)})})]})},os=({children:e,className:t=""})=>o.jsx("div",{className:C.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}),Jr=({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"})]})}),Xr=h.lazy(()=>Promise.resolve().then(()=>require("./dynamic-page-selector-CF9nb6i_.cjs"))),Zr=()=>{const{dynamicPage:e,allLangPages:t,isFetching:s}=js(),n=t.length>0;return s?null:o.jsxs("div",{className:"relative",children:[!e&&o.jsx(Jr,{hasDynamicPage:n}),o.jsx(h.Suspense,{children:o.jsx(Xr,{})})]})},ea=()=>{const{data:e,isFetching:t}=ue(),{data:s,isFetching:n}=Z(),r=p.get(s,"dynamic",!1),a=ss(),i=C.useChaiFeatureFlag("dynamic-page-selector"),l=e==null?void 0:e.slug,c=!l,d=ar(),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:C.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(Yr,{})}),o.jsxs("div",{className:C.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(Ms,{}),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:d,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(v.ExternalLink,{className:"h-4 w-4",strokeWidth:1})})})]})]}),r&&i&&o.jsx(Zr,{})]})},ta=()=>o.jsxs("div",{className:"flex h-full w-full items-center justify-between px-2",children:[o.jsx(Ar,{}),o.jsx(ea,{}),o.jsx(Kr,{})]}),qs=()=>{const e=T.useQueryClient(),{data:t}=T.useQuery({queryKey:[y.AI_CONTEXT],initialData:"",queryFn:()=>"",staleTime:0});return{setAiContext:h.useCallback(n=>{e.setQueryData([y.AI_CONTEXT],n)},[e]),aiContext:t}},sa=()=>{const e=j(),{aiContext:t}=qs(),s=L();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])},na=(e,t)=>t.map(s=>{if(p.has(e,s._type)){const n=Ns.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}),ra=e=>{const t=Ns.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:na(t,s)}},[e,t])},aa=()=>{const[e]=te(),t=e.get("page"),s=j(),{setAiContext:n}=qs(),[,r]=kt(),[,a]=rr(),[,i]=C.useIsPageLoaded(),l=L();return T.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}}),d=c.blocks??[],f=p.find(d,{_type:"@chai/ai-context"});return n(p.get(f,"_value","")||""),r(u=>({...u,lastSaved:c.lastSaved})),a(p.get(c,"metadata",{})),setTimeout(()=>i(!0),500),d},enabled:!!t})},Ks=()=>{const{data:e}=Z(),{data:t}=ue(),s=j(),n=L(),r=Ot(),a=ss();return T.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})},Hs=()=>{const e=j(),t=T.useQueryClient(),s=L();return T.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})}})},ia=()=>{const e=j(),t=T.useQueryClient(),s=L(),{selectedLang:n}=C.useLanguages();return T.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})}})},oa=()=>{const e=j(),t=T.useQueryClient(),s=L(),{selectedLang:n}=C.useLanguages();return T.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})}})},la=()=>{const e=j(),t=T.useQueryClient(),s=L();return T.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})}})},ca=()=>{const e=j(),t=L();return T.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})}})},ua=()=>{const e=j(),t=L();return T.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})}})},da=()=>{const e=j(),t=L();return T.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:C.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),[]}}},fa=()=>{const e=j(),t=L();return T.useQuery({queryKey:["uiLibraries"],staleTime:"static",queryFn:async()=>{const n=(await t(e,{action:"GET_LIBRARIES"})).map(r=>({...r}));return n.forEach(r=>{C.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}})},Vs=()=>{const e=Gs(),t=L(),{user:s}=He(),n=s==null?void 0:s.id;return T.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})},ha=()=>{const e=j(),t=L(),[,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")}}}},ga=()=>{const{data:e}=as(),t=j(),s=L();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])}},ma=h.lazy(()=>Promise.resolve().then(()=>require("./lang-panel-D2YUMeJZ.cjs"))),Ea=({isActive:e,show:t})=>{const{data:s}=Ae();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(v.LanguagesIcon,{className:"h-4 w-4"})})},Qs="lang",pa={id:Qs,label:"Languages",position:"top",panel:ma,button:Ea,view:"modal",width:400},ya=h.lazy(()=>Promise.resolve().then(()=>require("./seo-panel-CrK7z4bR.cjs"))),zs="seo",Aa=({isActive:e,show:t})=>{const{data:s}=Z(),n=Bs(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"})]})})},Sa={id:zs,label:"SEO",panel:ya,button:Aa,position:"top",width:600,view:"modal"},$s="user-info",Ta=()=>{const{user:e,logout:t}=He(),s=ee("onLogout",p.noop);return e?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(v.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:e.name??e.email}),o.jsx("div",{className:"text-xs text-muted-foreground",children:e.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:"Logout"})}),o.jsxs(m.AlertDialogContent,{children:[o.jsxs(m.AlertDialogHeader,{children:[o.jsx(m.AlertDialogTitle,{children:"Are you sure you want to logout?"}),o.jsx(m.AlertDialogDescription,{children:"You will be redirected to the login page."})]}),o.jsxs(m.AlertDialogFooter,{children:[o.jsx(m.AlertDialogCancel,{children:"Cancel"}),o.jsx(m.AlertDialogAction,{onClick:()=>{t(),p.isFunction(s)&&s()},children:"Logout"})]})]})]})]})]}):null},Pa={id:$s,label:"User Info",button:Ta,position:"bottom"},_a=()=>{C.registerChaiSidebarPanel(zs,Sa),C.registerChaiSidebarPanel(Qs,pa),C.registerChaiSidebarPanel($s,Pa)};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 We(e){b.context=e}var Ws=!1,xa=(e,t)=>e===t,wt=Symbol("solid-proxy"),Ys=typeof Proxy=="function",ls=Symbol("solid-track"),vt={equals:xa},Js=an,fe=1,bt=2,Xs={owned:null,cleanups:null,context:null,owner:null},qt={},G=null,Kt=null,wa=null,M=null,X=null,ce=null,Ut=0;function me(e,t){const s=M,n=G,r=e.length===0,a=t===void 0?n:t,i=r?Xs:{owned:null,cleanups:null,context:a?a.context:null,owner:a},l=r?e:()=>e(()=>J(()=>et(i)));G=i,M=null;try{return ie(l,!0)}finally{M=s,G=n}}function K(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)),rn(s,r));return[nn.bind(s),n]}function Zs(e,t,s){const n=Mt(e,t,!0,fe);Ve(n)}function Ee(e,t,s){const n=Mt(e,t,!1,fe);Ve(n)}function cs(e,t,s){Js=Ua;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),nn.bind(n)}function va(e){return e&&typeof e=="object"&&"then"in e}function ba(e,t,s){let n,r,a;n=!0,r=e,a={};let i=null,l=qt,c=null,d=!1,f="initialValue"in a,u=typeof n=="function"&&$(n);const g=new Set,[E,S]=(a.storage||K)(a.initialValue),[P,_]=K(void 0),[A,x]=K(void 0,{equals:!1}),[D,q]=K(f?"ready":"unresolved");b.context&&(c=b.getNextContextId(),a.ssrLoadFrom==="initial"?l=a.initialValue:b.load&&b.has(c)&&(l=b.load(c)));function V(I,N,W,Q){return i===I&&(i=null,Q!==void 0&&(f=!0),(I===l||N===l)&&a.onHydrated&&queueMicrotask(()=>a.onHydrated(Q,{value:N})),l=qt,O(N,W)),N}function O(I,N){ie(()=>{N===void 0&&S(()=>I),q(N!==void 0?"errored":f?"ready":"unresolved"),_(N);for(const W of g.keys())W.decrement();g.clear()},!1)}function oe(){const I=ja,N=E(),W=P();if(W!==void 0&&!i)throw W;return M&&M.user,N}function le(I=!0){if(I!==!1&&d)return;d=!1;const N=u?u():n;if(N==null||N===!1){V(i,J(E));return}let W;const Q=l!==qt?l:J(()=>{try{return r(N,{value:E(),refetching:I})}catch(ne){W=ne}});if(W!==void 0){V(i,void 0,_t(W),N);return}else if(!va(Q))return V(i,Q,void 0,N),Q;return i=Q,"v"in Q?(Q.s===1?V(i,Q.v,void 0,N):V(i,void 0,_t(Q.v),N),Q):(d=!0,queueMicrotask(()=>d=!1),ie(()=>{q(f?"refreshing":"pending"),x()},!1),Q.then(ne=>V(Q,ne,void 0,N),ne=>V(Q,void 0,_t(ne),N)))}Object.defineProperties(oe,{state:{get:()=>D()},error:{get:()=>P()},loading:{get(){const I=D();return I==="pending"||I==="refreshing"}},latest:{get(){if(!f)return oe();const I=P();if(I&&!i)throw I;return E()}}});let U=G;return u?Zs(()=>(U=G,le(!1))):le(!1),[oe,{refetch:I=>tn(U,()=>le(I)),mutate:S}]}function Ca(e){return ie(e,!1)}function J(e){if(M===null)return e();const t=M;M=null;try{return e()}finally{M=t}}function Ia(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 d=0;d<e.length;d++)l[d]=e[d]()}else l=e();if(a)return a=!1,i;const c=J(()=>t(l,r,i));return r=l,c}}function en(e){cs(()=>J(e))}function qe(e){return G===null||(G.cleanups===null?G.cleanups=[e]:G.cleanups.push(e)),e}function As(){return G}function tn(e,t){const s=G,n=M;G=e,M=null;try{return ie(t,!0)}catch(r){us(r)}finally{G=s,M=n}}function La(e){const t=M,s=G;return Promise.resolve().then(()=>{M=t,G=s;let n;return ie(e,!1),M=G=null,n?n.done:void 0})}var[Na,Mo]=K(!1);function Ga(){return[Na,La]}function Da(e,t){const s=Symbol("context");return{id:s,Provider:Ma(s),defaultValue:e}}function ka(e){let t;return G&&G.context&&(t=G.context[e.id])!==void 0?t:e.defaultValue}function sn(e){const t=$(e),s=$(()=>Qt(t()));return s.toArray=()=>{const n=s();return Array.isArray(n)?n:n!=null?[n]:[]},s}var ja;function nn(){if(this.sources&&this.state)if(this.state===fe)Ve(this);else{const e=X;X=null,ie(()=>It(this),!1),X=e}if(M){const e=this.observers?this.observers.length:0;M.sources?(M.sources.push(this),M.sourceSlots.push(e)):(M.sources=[this],M.sourceSlots=[e]),this.observers?(this.observers.push(M),this.observerSlots.push(M.sources.length-1)):(this.observers=[M],this.observerSlots=[M.sources.length-1])}return this.value}function rn(e,t,s){let n=e.value;return(!e.comparator||!e.comparator(n,t))&&(e.value=t,e.observers&&e.observers.length&&ie(()=>{for(let r=0;r<e.observers.length;r+=1){const a=e.observers[r],i=Kt&&Kt.running;i&&Kt.disposed.has(a),(i?!a.tState:!a.state)&&(a.pure?X.push(a):ce.push(a),a.observers&&on(a)),i||(a.state=fe)}if(X.length>1e6)throw X=[],new Error},!1)),t}function Ve(e){if(!e.fn)return;et(e);const t=Ut;Oa(e,e.value,t)}function Oa(e,t,s){let n;const r=G,a=M;M=G=e;try{n=e.fn(t)}catch(i){return e.pure&&(e.state=fe,e.owned&&e.owned.forEach(et),e.owned=null),e.updatedAt=s+1,us(i)}finally{M=a,G=r}(!e.updatedAt||e.updatedAt<=s)&&(e.updatedAt!=null&&"observers"in e?rn(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:G,context:G?G.context:null,pure:s};return G===null||G!==Xs&&(G.owned?G.owned.push(a):G.owned=[a]),a}function Ct(e){if(e.state===0)return;if(e.state===bt)return It(e);if(e.suspense&&J(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<Ut);)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===bt){const n=X;X=null,ie(()=>It(e,t[0]),!1),X=n}}function ie(e,t){if(X)return e();let s=!1;t||(X=[]),ce?s=!0:ce=[],Ut++;try{const n=e();return Ra(s),n}catch(n){s||(ce=null),X=null,us(n)}}function Ra(e){if(X&&(an(X),X=null),e)return;const t=ce;ce=null,t.length&&ie(()=>Js(t),!1)}function an(e){for(let t=0;t<e.length;t++)Ct(e[t])}function Ua(e){let t,s=0;for(t=0;t<e.length;t++){const n=e[t];n.user?e[s++]=n:Ct(n)}if(b.context){if(b.count){b.effects||(b.effects=[]),b.effects.push(...e.slice(0,s));return}We()}for(b.effects&&(b.done||!b.count)&&(e=[...b.effects,...e],s+=b.effects.length,delete b.effects),t=0;t<s;t++)Ct(e[t])}function It(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<Ut)&&Ct(n):r===bt&&It(n,t)}}}function on(e){for(let t=0;t<e.observers.length;t+=1){const s=e.observers[t];s.state||(s.state=bt,s.pure?X.push(s):ce.push(s),s.observers&&on(s))}}function et(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--)et(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)et(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 _t(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function us(e,t=G){throw _t(e)}function Qt(e){if(typeof e=="function"&&!e.length)return Qt(e());if(Array.isArray(e)){const t=[];for(let s=0;s<e.length;s++){const n=Qt(e[s]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Ma(e,t){return function(n){let r;return Ee(()=>r=J(()=>(G.context={...G.context,[e]:n.value},sn(()=>n.children))),void 0),r}}var zt=Symbol("fallback");function Lt(e){for(let t=0;t<e.length;t++)e[t]()}function Ba(e,t,s={}){let n=[],r=[],a=[],i=0,l=t.length>1?[]:null;return qe(()=>Lt(a)),()=>{let c=e()||[],d=c.length,f,u;return c[ls],J(()=>{let E,S,P,_,A,x,D,q,V;if(d===0)i!==0&&(Lt(a),a=[],n=[],r=[],i=0,l&&(l=[])),s.fallback&&(n=[zt],r[0]=me(O=>(a[0]=O,s.fallback())),i=1);else if(i===0){for(r=new Array(d),u=0;u<d;u++)n[u]=c[u],r[u]=me(g);i=d}else{for(P=new Array(d),_=new Array(d),l&&(A=new Array(d)),x=0,D=Math.min(i,d);x<D&&n[x]===c[x];x++);for(D=i-1,q=d-1;D>=x&&q>=x&&n[D]===c[q];D--,q--)P[q]=r[D],_[q]=a[D],l&&(A[q]=l[D]);for(E=new Map,S=new Array(q+1),u=q;u>=x;u--)V=c[u],f=E.get(V),S[u]=f===void 0?-1:f,E.set(V,u);for(f=x;f<=D;f++)V=n[f],u=E.get(V),u!==void 0&&u!==-1?(P[u]=r[f],_[u]=a[f],l&&(A[u]=l[f]),u=S[u],E.set(V,u)):a[f]();for(u=x;u<d;u++)u in P?(r[u]=P[u],a[u]=_[u],l&&(l[u]=A[u],l[u](u))):r[u]=me(g);r=r.slice(0,i=d),n=c.slice(0)}return r});function g(E){if(a[u]=E,l){const[S,P]=K(u);return l[u]=P,t(c[u],S)}return t(c[u])}}}function Fa(e,t,s={}){let n=[],r=[],a=[],i=[],l=0,c;return qe(()=>Lt(a)),()=>{const d=e()||[],f=d.length;return d[ls],J(()=>{if(f===0)return l!==0&&(Lt(a),a=[],n=[],r=[],l=0,i=[]),s.fallback&&(n=[zt],r[0]=me(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]!==d[c]?i[c](()=>d[c]):c>=n.length&&(r[c]=me(u));for(;c<n.length;c++)a[c]();return l=i.length=a.length=f,n=d.slice(0),r=r.slice(0,l)});function u(g){a[c]=g;const[E,S]=K(d[c]);return i[c]=S,t(E,c)}}}function ds(e,t){return J(()=>e(t||{}))}function yt(){return!0}var $t={get(e,t,s){return t===wt?s:e.get(t)},has(e,t){return t===wt?!0:e.has(t)},set:yt,deleteProperty:yt,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:yt,deleteProperty:yt}},ownKeys(e){return e.keys()}};function Ht(e){return(e=typeof e=="function"?e():e)?e:{}}function qa(){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&&wt in l,e[i]=typeof l=="function"?(t=!0,$(l)):l}if(Ys&&t)return new Proxy({get(i){for(let l=e.length-1;l>=0;l--){const c=Ht(e[l])[i];if(c!==void 0)return c}},has(i){for(let l=e.length-1;l>=0;l--)if(i in Ht(e[l]))return!0;return!1},keys(){const i=[];for(let l=0;l<e.length;l++)i.push(...Object.keys(Ht(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 d=c.length-1;d>=0;d--){const f=c[d];if(f==="__proto__"||f==="constructor")continue;const u=Object.getOwnPropertyDescriptor(l,f);if(!n[f])n[f]=u.get?{enumerable:!0,configurable:!0,get:qa.bind(s[f]=[u.get.bind(l)])}:u.value!==void 0?u:void 0;else{const g=s[f];g&&(u.get?g.push(u.get.bind(l)):u.value!==void 0&&g.push(()=>u.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 ln(e,...t){if(Ys&&wt 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 d of t)d.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 cn(e){let t,s;const n=r=>{const a=b.context;if(a){const[l,c]=K();b.count||(b.count=0),b.count++,(s||(s=e())).then(d=>{!b.done&&We(a),b.count--,c(()=>d.default),We()}),t=l}else if(!t){const[l]=ba(()=>(s||(s=e())).then(c=>c.default));t=l}let i;return $(()=>(i=t())?J(()=>{if(!a||b.done)return i(r);const l=b.context;We(a);const c=i(r);return We(l),c}):"")};return n.preload=()=>s||((s=e()).then(r=>t=()=>r.default),s),n}var Ka=0;function Ha(){return b.context?b.getNextContextId():`cl-${Ka++}`}var un=e=>`Stale read from <${e}>.`;function Va(e){const t="fallback"in e&&{fallback:()=>e.fallback};return $(Ba(()=>e.each,e.children,t||void 0))}function Qa(e){const t="fallback"in e&&{fallback:()=>e.fallback};return $(Fa(()=>e.each,e.children,t||void 0))}function za(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?J(()=>a(t?r:()=>{if(!J(n))throw un("Show");return s()})):a}return e.fallback},void 0,void 0)}function $a(e){const t=sn(()=>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],d=a,f=$(()=>d()?void 0:c.when,void 0,void 0),u=c.keyed?f:$(f,void 0,{equals:(g,E)=>!g==!E});a=()=>d()||(u()?[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?J(()=>l(i.keyed?a():()=>{var d;if(((d=J(s)())==null?void 0:d[0])!==r)throw un("Match");return a()})):l},void 0,void 0)}function Wa(e){return e}var Ya=["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"],Ja=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline",...Ya]),Xa=new Set(["innerHTML","textContent","innerText","children"]),Za=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),ei=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 ti(e,t){const s=ei[e];return typeof s=="object"?s[t]?s.$:void 0:s}var si=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),ni=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"]),ri={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},ai=e=>$(()=>e());function ii(e,t,s){let n=s.length,r=t.length,a=n,i=0,l=0,c=t[r-1].nextSibling,d=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;)(!d||!d.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(!d){d=new Map;let u=l;for(;u<a;)d.set(s[u],u++)}const f=d.get(t[i]);if(f!=null)if(l<f&&f<a){let u=i,g=1,E;for(;++u<r&&u<a&&!((E=d.get(t[u]))==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 Xe="_$DX_DELEGATE";function dn(e,t,s,n={}){let r;return me(a=>{r=a,t===document?e():Gt(t,e(),t.firstChild?null:void 0,s)},n.owner),()=>{r(),t.textContent=""}}function oi(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 fn(e,t=window.document){const s=t[Xe]||(t[Xe]=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,pn))}}function li(e=window.document){if(e[Xe]){for(let t of e[Xe].keys())e.removeEventListener(t,pn);delete e[Xe]}}function Nt(e,t,s){xe(e)||(s==null?e.removeAttribute(t):e.setAttribute(t,s))}function ci(e,t,s,n){xe(e)||(n==null?e.removeAttributeNS(t,s):e.setAttributeNS(t,s,n))}function ui(e,t,s){xe(e)||(s?e.setAttribute(t,""):e.removeAttribute(t))}function hn(e,t){xe(e)||(t==null?e.removeAttribute("class"):e.className=t)}function gn(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 di(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]||(Ss(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||(Ss(e,l,!0),s[l]=c)}return s}function fi(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 mn(e,t={},s,n){const r={};return n||Ee(()=>r.children=tt(e,t.children,r.children)),Ee(()=>typeof t.ref=="function"&&En(t.ref,e)),Ee(()=>hi(e,t,s,!0,r,!0)),r}function En(e,t,s){return J(()=>e(t,s))}function Gt(e,t,s,n){if(s!==void 0&&!n&&(n=[]),typeof t!="function")return tt(e,t,n,s);Ee(r=>tt(e,t(),r,s),n)}function hi(e,t,s,n,r={},a=!1){t||(t={});for(const i in r)if(!(i in t)){if(i==="children")continue;r[i]=Ts(e,i,null,r[i],s,a,t)}for(const i in t){if(i==="children")continue;const l=t[i];r[i]=Ts(e,i,l,r[i],s,a,t)}}function gi(e){let t,s;return!xe()||!(t=b.registry.get(s=Ei()))?e():(b.completed&&b.completed.add(t),b.registry.delete(s),t)}function xe(e){return!!b.context&&!b.done&&(!e||e.isConnected)}function mi(e){return e.toLowerCase().replace(/-([a-z])/g,(t,s)=>s.toUpperCase())}function Ss(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 Ts(e,t,s,n,r,a,i){let l,c,d,f,u;if(t==="style")return fi(e,s,n);if(t==="classList")return di(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=si.has(g);if(!E&&n){const S=Array.isArray(n)?n[0]:n;e.removeEventListener(g,S)}(E||s)&&(gn(e,g,s,E),E&&fn([g]))}else if(t.slice(0,5)==="attr:")Nt(e,t.slice(5),s);else if(t.slice(0,5)==="bool:")ui(e,t.slice(5),s);else if((u=t.slice(0,5)==="prop:")||(d=Xa.has(t))||!r&&((f=ti(t,e.tagName))||(c=Ja.has(t)))||(l=e.nodeName.includes("-")||"is"in i)){if(u)t=t.slice(5),c=!0;else if(xe(e))return s;t==="class"||t==="className"?hn(e,s):l&&!c&&!d?e[mi(t)]=s:e[f||t]=s}else{const g=r&&t.indexOf(":")>-1&&ri[t.split(":")[0]];g?ci(e,g,t,s):Nt(e,Za[t]||t,s)}return s}function pn(e){if(b.registry&&b.events&&b.events.find(([c,d])=>d===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 d=t[`${s}Data`];if(d!==void 0?c.call(t,d,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 d=0;d<c.length-2&&(t=c[d],!!i());d++){if(t._$host){t=t._$host,l();break}if(t.parentNode===r)break}}else l();a(n)}function tt(e,t,s,n,r){const a=xe(e);if(a){!s&&(s=[...e.childNodes]);let c=[];for(let d=0;d<s.length;d++){const f=s[d];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=we(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=we(e,s,n)}else{if(i==="function")return Ee(()=>{let c=t();for(;typeof c=="function";)c=c();s=tt(e,c,s,n)}),()=>s;if(Array.isArray(t)){const c=[],d=s&&Array.isArray(s);if(Wt(c,t,s,r))return Ee(()=>s=tt(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 u=[f];for(;(f=f.nextSibling)!==n;)u.push(f);return s=u}if(c.length===0){if(s=we(e,s,n),l)return s}else d?s.length===0?Ps(e,c,n):ii(e,s,c):(s&&we(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=we(e,s,n,t);we(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],d;if(!(l==null||l===!0||l===!1))if((d=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))r=Wt(e,l,c)||r;else if(d==="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 we(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 Ei(){return b.getNextContextId()}var pi="http://www.w3.org/2000/svg";function yn(e,t=!1){return t?document.createElementNS(pi,e):document.createElement(e)}function yi(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=tn(r,()=>$(()=>e.children)));const l=n();if(l instanceof HTMLHeadElement){const[c,d]=K(!1),f=()=>d(!0);me(u=>Gt(l,()=>c()?u():a(),null)),qe(f)}else{const c=yn(e.isSVG?"g":"div",e.isSVG),d=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return s.parentNode},configurable:!0}),Gt(d,a),l.appendChild(c),e.ref&&e.ref(c),qe(()=>l.removeChild(c))}},void 0,{render:!i}),s}function Ai(e,t){const s=$(e);return $(()=>{const n=s();switch(typeof n){case"function":return J(()=>n(t));case"string":const r=ni.has(n),a=b.context?gi():yn(n,r);return mn(a,t,r),a}})}function Si(e){const[,t]=ln(e,["component"]);return Ai(()=>e.component,t)}var Ti=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()}},An=class{constructor(e){this.generateIdentifier=e,this.kv=new Ti}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)}},Pi=class extends An{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 _i(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 xi(e,t){const s=_i(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 _s(e,t){for(let s=0;s<e.length;s++){const n=e[s];if(t(n))return n}}var wi=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return xi(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},vi=e=>Object.prototype.toString.call(e).slice(8,-1),Sn=e=>typeof e>"u",bi=e=>e===null,st=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,Yt=e=>st(e)&&Object.keys(e).length===0,pe=e=>Array.isArray(e),Ci=e=>typeof e=="string",Ii=e=>typeof e=="number"&&!isNaN(e),Li=e=>typeof e=="boolean",Ni=e=>e instanceof RegExp,nt=e=>e instanceof Map,rt=e=>e instanceof Set,Tn=e=>vi(e)==="Symbol",Gi=e=>e instanceof Date&&!isNaN(e.valueOf()),Di=e=>e instanceof Error,xs=e=>typeof e=="number"&&isNaN(e),ki=e=>Li(e)||bi(e)||Sn(e)||Ii(e)||Ci(e)||Tn(e),ji=e=>typeof e=="bigint",Oi=e=>e===1/0||e===-1/0,Ri=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),Ui=e=>e instanceof URL,Pn=e=>e.replace(/\./g,"\\."),Vt=e=>e.map(String).map(Pn).join("."),Ze=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 ae(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var _n=[ae(Sn,"undefined",()=>null,()=>{}),ae(ji,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):e),ae(Gi,"Date",e=>e.toISOString(),e=>new Date(e)),ae(Di,"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}),ae(Ni,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),s=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,s)}),ae(rt,"set",e=>[...e.values()],e=>new Set(e)),ae(nt,"map",e=>[...e.entries()],e=>new Map(e)),ae(e=>xs(e)||Oi(e),"number",e=>xs(e)?"NaN":e>0?"Infinity":"-Infinity",Number),ae(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),ae(Ui,"URL",e=>e.toString(),e=>new URL(e))];function Bt(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var xn=Bt((e,t)=>Tn(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}),Mi=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),wn=Bt(Ri,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const s=Mi[t[1]];if(!s)throw new Error("Trying to deserialize unknown typed array");return new s(e)});function vn(e,t){return e!=null&&e.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var bn=Bt(vn,(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)}),Cn=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)}),Bi=[bn,xn,Cn,wn],ws=(e,t)=>{const s=_s(Bi,r=>r.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation(e,t)};const n=_s(_n,r=>r.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation}},In={};_n.forEach(e=>{In[e.annotation]=e});var Fi=(e,t,s)=>{if(pe(t))switch(t[0]){case"symbol":return xn.untransform(e,t,s);case"class":return bn.untransform(e,t,s);case"custom":return Cn.untransform(e,t,s);case"typed-array":return wn.untransform(e,t,s);default:throw new Error("Unknown transformation: "+t)}else{const n=In[t];if(!n)throw new Error("Unknown transformation: "+t);return n.untransform(e,s)}},ve=(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 qi=(e,t)=>{Ln(t);for(let s=0;s<t.length;s++){const n=t[s];if(rt(e))e=ve(e,+n);else if(nt(e)){const r=+n,a=+t[++s]==0?"key":"value",i=ve(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(pe(n)){const l=+i;n=n[l]}else if(st(n))n=n[i];else if(rt(n)){const l=+i;n=ve(n,l)}else if(nt(n)){if(a===t.length-2)break;const c=+i,d=+t[++a]==0?"key":"value",f=ve(n,c);switch(d){case"key":n=f;break;case"value":n=n.get(f);break}}}const r=t[t.length-1];if(pe(n)?n[+r]=s(n[+r]):st(n)&&(n[r]=s(n[r])),rt(n)){const a=ve(n,+r),i=s(a);a!==i&&(n.delete(a),n.add(i))}if(nt(n)){const a=+t[t.length-2],i=ve(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(!pe(e)){Ke(e,(a,i)=>Xt(a,t,[...s,...Ze(i)]));return}const[n,r]=e;r&&Ke(r,(a,i)=>{Xt(a,t,[...s,...Ze(i)])}),t(n,s)}function Ki(e,t,s){return Xt(t,(n,r)=>{e=Jt(e,r,a=>Fi(a,n,s))}),e}function Hi(e,t){function s(n,r){const a=qi(e,Ze(r));n.map(Ze).forEach(i=>{e=Jt(e,i,()=>a)})}if(pe(t)){const[n,r]=t;n.forEach(a=>{e=Jt(e,Ze(a),()=>e)}),r&&Ke(r,s)}else Ke(t,s);return e}var Vi=(e,t)=>st(e)||pe(e)||nt(e)||rt(e)||vn(e,t);function Qi(e,t,s){const n=s.get(e);n?n.push(t):s.set(e,[t])}function zi(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 Nn=(e,t,s,n,r=[],a=[],i=new Map)=>{const l=ki(e);if(!l){Qi(e,r,t);const E=i.get(e);if(E)return n?{transformedValue:null}:E}if(!Vi(e,s)){const E=ws(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=ws(e,s),d=(c==null?void 0:c.value)??e,f=pe(d)?[]:{},u={};Ke(d,(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 P=Nn(E,t,s,n,[...r,S],[...a,e],i);f[S]=P.transformedValue,pe(P.annotations)?u[S]=P.annotations:st(P.annotations)&&Ke(P.annotations,(_,A)=>{u[Pn(S)+"."+A]=_})});const g=Yt(u)?{transformedValue:f,annotations:c?[c.type]:void 0}:{transformedValue:f,annotations:c?[c.type,u]:u};return l||i.set(e,g),g};function Gn(e){return Object.prototype.toString.call(e).slice(8,-1)}function vs(e){return Gn(e)==="Array"}function $i(e){if(Gn(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function Wi(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(vs(e))return e.map(r=>Zt(r,t));if(!$i(e))return e;const s=Object.getOwnPropertyNames(e),n=Object.getOwnPropertySymbols(e);return[...s,...n].reduce((r,a)=>{if(vs(t.props)&&!t.props.includes(a))return r;const i=e[a],l=Zt(i,t);return Wi(r,a,l,e,t.nonenumerable),r},{})}var B=class{constructor({dedupe:e=!1}={}){this.classRegistry=new Pi,this.symbolRegistry=new An(t=>t.description??""),this.customTransformerRegistry=new wi,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,s=Nn(e,t,this,this.dedupe),n={json:s.transformedValue};s.annotations&&(n.meta={...n.meta,values:s.annotations});const r=zi(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=Ki(n,s.values,this)),s!=null&&s.referentialEqualities&&(n=Hi(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)}};B.defaultInstance=new B;B.serialize=B.defaultInstance.serialize.bind(B.defaultInstance);B.deserialize=B.defaultInstance.deserialize.bind(B.defaultInstance);B.stringify=B.defaultInstance.stringify.bind(B.defaultInstance);B.parse=B.defaultInstance.parse.bind(B.defaultInstance);B.registerClass=B.defaultInstance.registerClass.bind(B.defaultInstance);B.registerSymbol=B.defaultInstance.registerSymbol.bind(B.defaultInstance);B.registerCustom=B.defaultInstance.registerCustom.bind(B.defaultInstance);B.allowErrorProps=B.defaultInstance.allowErrorProps.bind(B.defaultInstance);var Dn=B.serialize,Yi=B.stringify;function Ji(e){return e.state.fetchStatus==="fetching"?"fetching":e.getObserversCount()?e.state.fetchStatus==="paused"?"paused":e.isStale()?"stale":"fresh":"inactive"}function Xi(e,t){return`${e}${t.charAt(0).toUpperCase()+t.slice(1)}`}function Zi({queryState:e,observerCount:t,isStale:s}){return e.fetchStatus==="fetching"?"blue":t?e.fetchStatus==="paused"?"purple":s?"yellow":"green":"gray"}function eo({status:e,isPaused:t}){return t?"purple":e==="error"?"red":e==="pending"?"yellow":e==="success"?"green":"gray"}function to(e){return e==="fresh"?"green":e==="stale"?"yellow":e==="paused"?"purple":e==="inactive"?"gray":"blue"}var so=(e,t=!1)=>{const{json:s}=Dn(e);return JSON.stringify(s,null,t?2:void 0)},At=e=>e.state.fetchStatus!=="idle"?0:e.getObserversCount()?e.isStale()?2:1:3,no=(e,t)=>e.queryHash.localeCompare(t.queryHash),kn=(e,t)=>e.state.dataUpdatedAt<t.state.dataUpdatedAt?1:-1,ro=(e,t)=>At(e)===At(t)?kn(e,t):At(e)>At(t)?1:-1,ao={status:ro,"query hash":no,"last updated":kn},St=e=>e.state.isPaused?0:e.state.status==="error"?2:e.state.status==="pending"?1:3,jn=(e,t)=>e.state.submittedAt<t.state.submittedAt?1:-1,io=(e,t)=>St(e)===St(t)?jn(e,t):St(e)>St(t)?1:-1,oo={status:io,"last updated":jn},lo=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),co=()=>{const[e,t]=K("dark");return en(()=>{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},Ye=(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,Ye(n.get(r),a,s)),n}if(e instanceof Set){const n=Ye(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]=Ye(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]=Ye(n[r],a,s),n}return e},Je=(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,Je(s.get(n),r)),s}if(e instanceof Set){const s=Je(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]=Je(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]=Je(s[n],r),s}return e},On=(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,at,it,ot,Pe,lt,Ce,Ie,Le,Ne,Ge,ct,De,ut,Is,uo=(Is=class{constructor(e){R(this,be);R(this,at);R(this,it);R(this,ot);R(this,Pe,!1);R(this,lt);R(this,Ce);R(this,Ie);R(this,Le);R(this,Ne);R(this,Ge);R(this,ct);R(this,De);R(this,ut);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:d,shadowDOMTarget:f,hideDisabledQueries:u}=e;k(this,be,K(t)),k(this,it,s),k(this,ot,n),k(this,at,r),k(this,lt,d),k(this,Ce,f),k(this,Ie,K(a)),k(this,Le,K(i)),k(this,Ne,K(l)),k(this,Ge,K(c)),k(this,ct,K(u))}setButtonPosition(e){w(this,Ie)[1](e)}setPosition(e){w(this,Le)[1](e)}setInitialIsOpen(e){w(this,Ne)[1](e)}setErrorTypes(e){w(this,Ge)[1](e)}setClient(e){w(this,be)[1](e)}mount(e){if(w(this,Pe))throw new Error("Devtools is already mounted");const t=dn(()=>{const s=this,[n]=w(this,Ie),[r]=w(this,Le),[a]=w(this,Ne),[i]=w(this,Ge),[l]=w(this,ct),[c]=w(this,be);let d;return w(this,De)?d=w(this,De):(d=cn(()=>Promise.resolve().then(()=>require("./NCMVHL6D-BPM6RHYa.cjs"))),k(this,De,d)),On(w(this,lt),w(this,Ce)),ds(d,fs({get queryFlavor(){return w(s,it)},get version(){return w(s,ot)},get onlineManager(){return w(s,at)},get shadowDOMTarget(){return w(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);k(this,Pe,!0),k(this,ut,t)}unmount(){var e;if(!w(this,Pe))throw new Error("Devtools is not mounted");(e=w(this,ut))==null||e.call(this),k(this,Pe,!1)}},be=new WeakMap,at=new WeakMap,it=new WeakMap,ot=new WeakMap,Pe=new WeakMap,lt=new WeakMap,Ce=new WeakMap,Ie=new WeakMap,Le=new WeakMap,Ne=new WeakMap,Ge=new WeakMap,ct=new WeakMap,De=new WeakMap,ut=new WeakMap,Is),ke,dt,ft,ht,_e,gt,je,Oe,Re,Ue,Me,mt,Be,Fe,Et,Ls,fo=(Ls=class{constructor(e){R(this,ke);R(this,dt);R(this,ft);R(this,ht);R(this,_e,!1);R(this,gt);R(this,je);R(this,Oe);R(this,Re);R(this,Ue);R(this,Me);R(this,mt);R(this,Be);R(this,Fe);R(this,Et);const{client:t,queryFlavor:s,version:n,onlineManager:r,buttonPosition:a,position:i,initialIsOpen:l,errorTypes:c,styleNonce:d,shadowDOMTarget:f,onClose:u,hideDisabledQueries:g}=e;k(this,ke,K(t)),k(this,ft,s),k(this,ht,n),k(this,dt,r),k(this,gt,d),k(this,je,f),k(this,Oe,K(a)),k(this,Re,K(i)),k(this,Ue,K(l)),k(this,Me,K(c)),k(this,mt,K(g)),k(this,Be,K(u))}setButtonPosition(e){w(this,Oe)[1](e)}setPosition(e){w(this,Re)[1](e)}setInitialIsOpen(e){w(this,Ue)[1](e)}setErrorTypes(e){w(this,Me)[1](e)}setClient(e){w(this,ke)[1](e)}setOnClose(e){w(this,Be)[1](()=>e)}mount(e){if(w(this,_e))throw new Error("Devtools is already mounted");const t=dn(()=>{const s=this,[n]=w(this,Oe),[r]=w(this,Re),[a]=w(this,Ue),[i]=w(this,Me),[l]=w(this,mt),[c]=w(this,ke),[d]=w(this,Be);let f;return w(this,Fe)?f=w(this,Fe):(f=cn(()=>Promise.resolve().then(()=>require("./2AITGKQY-o6FgGSqg.cjs"))),k(this,Fe,f)),On(w(this,gt),w(this,je)),ds(f,fs({get queryFlavor(){return w(s,ft)},get version(){return w(s,ht)},get onlineManager(){return w(s,dt)},get shadowDOMTarget(){return w(s,je)}},{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 d()}}))},e);k(this,_e,!0),k(this,Et,t)}unmount(){var e;if(!w(this,_e))throw new Error("Devtools is not mounted");(e=w(this,Et))==null||e.call(this),k(this,_e,!1)}},ke=new WeakMap,dt=new WeakMap,ft=new WeakMap,ht=new WeakMap,_e=new WeakMap,gt=new WeakMap,je=new WeakMap,Oe=new WeakMap,Re=new WeakMap,Ue=new WeakMap,Me=new WeakMap,mt=new WeakMap,Be=new WeakMap,Fe=new WeakMap,Et=new WeakMap,Ls);function ho(e){const t=T.useQueryClient(e.client),s=z.useRef(null),{buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:d}=e,[f]=z.useState(new uo({client:t,queryFlavor:"React Query",version:"5",onlineManager:T.onlineManager,buttonPosition:n,position:r,initialIsOpen:a,errorTypes:i,styleNonce:l,shadowDOMTarget:c,hideDisabledQueries:d}));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 go(e){const t=T.useQueryClient(e.client),s=z.useRef(null),{errorTypes:n,styleNonce:r,shadowDOMTarget:a,hideDisabledQueries:i}=e,[l]=z.useState(new fo({client:t,queryFlavor:"React Query",version:"5",onlineManager:T.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}:ho;process.env.NODE_ENV;const Rn=H.atom(""),mo=()=>{C.registerChaiFeatureFlag("dynamic-page-selector",{description:"Dynamic page selector"}),C.registerChaiFeatureFlag("enable-add-page-dropdown",{description:"Enable add page dropdown"})},Eo=()=>{const e=j(),t=L();return T.useQuery({queryKey:[y.GET_COLLECTIONS],staleTime:1/0,queryFn:async()=>t(e,{action:y.GET_COLLECTIONS})})},po=()=>{const{data:e}=Z(),{data:t}=ue(),{data:s}=Ae(),n=j(),r=L(),a=h.useMemo(()=>(s==null?void 0:s.fallbackLang)||"en",[s==null?void 0:s.fallbackLang]);return T.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}}})})},Un=()=>{const[,e]=te();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])},Mn=()=>{const e=Un();return h.useCallback(({pageId:t})=>{e(t)},[e])},yo=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-BGyKKd_6.cjs"))),Ao=h.lazy(()=>Promise.resolve().then(()=>require("./save-to-lib-DNK4GPNw.cjs"))),So=h.lazy(()=>Promise.resolve().then(()=>require("./theme-panel-footer-Bj2yHtxO.cjs"))),To=h.lazy(()=>Promise.resolve().then(()=>require("./web-preview-BcULgiw_.cjs")));mo();zn.loadWebBlocks();C.registerChaiTopBar(ta);_a();C.registerChaiMediaManager(yo);C.registerChaiSaveToLibrary(Ao);const Po={role:"",permissions:null},Cs=e=>{fa(),ur();const t=Ot(),{data:s=Po,isFetching:n}=Vs(),{data:r,isFetching:a}=de(),{data:i,isFetching:l}=Eo(),{data:c,isFetching:d}=Ae(),f=n||a||l||d,[u]=te(),g=u.get("page"),{data:E}=Z(),{data:S,isFetching:P}=aa(),{blocks:_}=ra(S),{lockingStatus:A,pageLock:x}=Se(),{data:D,isFetching:q}=Ks(),V=sa(),{onSave:O}=ha(),{mutateAsync:oe}=po(),{getPartialBlocks:le,getPartialBlockBlocks:U}=ga(),{mutateAsync:I}=xr(),{mutateAsync:N}=Hs(),W=Mn(),[Q,ne]=h.useState(!1),Qe=h.useRef([]),he=h.useMemo(()=>p.get(c,"theme",{})||{},[c]),ze=p.isEmpty(A)&&(x==null?void 0:x.status)==="editing",Te=(x==null?void 0:x.status)==="checking",hs=P||Te||q;Qe.current=_;const[Fn]=H.useAtom(Rn);h.useEffect(()=>{const re=()=>{document.hidden?ne(!0):ne(!1)};return window.addEventListener("visibilitychange",re),()=>window.removeEventListener("visibilitychange",re)},[]);const qn=h.useMemo(()=>{const re={};return s&&(re.permissions=p.get(s,"permissions",null),re.role=p.get(s,"role","user")),re},[s]),Kn=h.useCallback(async(re,pt)=>await I({pageType:re,query:pt}),[I]);return o.jsxs(o.Fragment,{children:[hs&&o.jsx(os,{className:f?"fixed inset-0 bg-white":"bg-white/75",children:o.jsx(v.Loader,{className:`animate-spin text-primary ${f?"h-6 w-6":"h-5 w-5"}`})}),Fn&&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(v.Loader,{className:"h-6 w-6 animate-spin text-primary"})}),children:o.jsx(To,{})}),o.jsx(C.ChaiBuilderEditor,{gotoPage:W,collections:i??[],getBlockAsyncProps:oe,pageExternalData:D,themePresets:e.themePresets??[],pageId:E==null?void 0:E.id,loading:P,fallbackLang:t,languages:(c==null?void 0:c.languages)||[],brandingOptions:(c==null?void 0:c.theme)||{},translations:e.translations||{},locale:e.locale||"en",htmlDir:e.htmlDir||"ltr",autoSave:!Q&&ze&&(e.autoSave??!0),autoSaveInterval:e.autoSaveInterval??15,onError:e.onError||console.error,getPartialBlockBlocks:U,getPartialBlocks:le,blocks:P?[]:_,theme:p.cloneDeep(he),pageTypes:r,searchPageTypeItems:Kn,askAiCallBack:V,onSave:async({blocks:re,theme:pt,needTranslations:Hn})=>{if(!g)return!0;Qe.current=re;const gs=[...re];return await O({page:g,blocks:gs,needTranslations:Hn}),Qe.current=gs,p.isEqual(pt,he)||await N({settings:{theme:pt}}),!0},themePanelComponent:So,...qn}),o.jsxs("div",{children:[o.jsx(hr,{isFetchingPage:hs}),o.jsx(gr,{})]})]})},_o=new T.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1}}}),xo=e=>{const[,t]=Dt(),[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(T.QueryClientProvider,{client:_o,children:[o.jsx(Cs,{...e}),o.jsx(bs,{})]}):o.jsx("div",{})},wo=z.lazy(()=>Promise.resolve().then(()=>require("./nested-path-selector-content-D_iF9Sm3.cjs")));function Bn({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(wo,{data:e,onSelect:t,dataType:s,open:r,setOpen:a})})]})}const vo=()=>{const{savePageAsync:e}=C.useSavePage(),t=T.useQueryClient();return h.useCallback(async()=>{await e(),t.invalidateQueries({queryKey:[y.GET_DRAFT_PAGE]}),t.invalidateQueries({queryKey:[y.GET_BUILDER_PAGE_DATA]})},[e,t])},bo=()=>{const e=T.useQueryClient();return h.useCallback(()=>{e.clear()},[e])},Co=()=>{const e=j(),t=L(),{data:s}=ue(),n=T.useQueryClient();return T.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")}})},Io=h.lazy(()=>Promise.resolve().then(()=>require("./digital-asset-manager-BGyKKd_6.cjs"))),Lo=({assetId:e,assetUrl:t,onChange:s,className:n="",placeholder:r="Select an image",disabled:a=!1})=>{const[i,l]=h.useState(!1),c=()=>{a||l(!0)},d=()=>{l(!1)},f=E=>{const S=Array.isArray(E)?E[0]:E;S!=null&&S.url&&s(p.pick(S,["url","id"])),l(!1)},u=()=>{s({url:"",id:""})},g=(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:[g?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:c,src:t,alt:"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:u,disabled:a,children:g?o.jsx(v.X,{className:"h-4 w-4"}):o.jsx(v.Trash2,{className:"h-4 w-4"})}),!g&&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:c,disabled:a,children:o.jsx(v.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:c,children:o.jsxs("div",{className:"flex flex-col items-center gap-2",children:[o.jsx(v.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:i,onOpenChange:l,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:"Select Image"}),o.jsx(m.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-4 top-2",onClick:d,children:o.jsx(v.X,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"h-full flex-1 p-4",children:o.jsx(h.Suspense,{children:o.jsx(Io,{close:d,onSelect:f,mode:"image",assetId:e})})})]})})]})},No=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 d,f;if(c!==void 0){const u=n.substring(0,c).split(`
2
- `);d=u.length,f=u[u.length-1].length+1}return{isValid:!1,parsed:null,placeholders:s,error:{message:i.message,line:d,column:f,position:c}}}},Go=(e,t)=>{let n=JSON.stringify(e,null,2);return t.forEach(({original:r},a)=>{const i=`"__placeholder_${a}__"`,l=new RegExp(No(i),"g");n=n.replace(l,r)}),n},Do=(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},ko=h.lazy(()=>Promise.resolve().then(()=>require("./shared-json-ld-_ozYsSHn.cjs"))),jo=({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:d,copyJsonLDFromDefaultPage:f})=>{const[u,g]=h.useState("edit"),[E,S]=h.useState(null),[P,_]=h.useState(""),A=h.useRef(null),[x]=Dt(),D=i==="jsonLD"&&p.get(x,"features.sharedJsonLD",!1),q=i==="jsonLD"&&!d&&!!f;h.useEffect(()=>{e.trim()===""&&t("{}")},[e,t]);const V=U=>{if(n)return;const I=U.target.value;t(I)},O=U=>{if(U.key==="Tab"){U.preventDefault();const I=U.currentTarget,N=I.selectionStart,W=I.selectionEnd;if(N!==W){const ne=e.substring(N,W).split(`
3
- `);if(U.shiftKey){const he=ne.map(Te=>Te.startsWith(" ")?Te.substring(2):Te).join(`
4
- `),ze=e.substring(0,N)+he+e.substring(W);t(ze),setTimeout(()=>{I.selectionStart=N,I.selectionEnd=N+he.length},0)}else{const he=ne.map(Te=>` ${Te}`).join(`
5
- `),ze=e.substring(0,N)+he+e.substring(W);t(ze),setTimeout(()=>{I.selectionStart=N,I.selectionEnd=N+he.length},0)}}else{const Q=e.substring(0,N)+" "+e.substring(W);t(Q),setTimeout(()=>{I.selectionStart=I.selectionEnd=N+2},0)}}};h.useEffect(()=>{const U=es(e);if(U.isValid)if(S(null),U.parsed){const I=Do(U.parsed,l);_(I)}else _("");else S(U.error),_("")},[e,l]);const oe=()=>{const U=es(e);if(U.isValid&&U.parsed){const I=Go(U.parsed,U.placeholders);t(I)}},le=()=>{E!=null&&E.position&&A.current&&(A.current.focus(),A.current.setSelectionRange(E.position,E.position+1))};return o.jsx("div",{className:"space-y-2",children:o.jsxs(m.Tabs,{value:u,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(v.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||q,children:[o.jsx(v.Eye,{className:"h-4 w-4"}),o.jsx("span",{children:"Preview"})]}),D&&o.jsxs(m.TabsTrigger,{value:"shared",className:"flex items-center gap-1",disabled:!e.trim()||E!==null,children:[o.jsx(v.Share2,{className:"h-4 w-4"}),o.jsx("span",{children:"Shared"})]})]}),q?null:u==="edit"&&!n&&o.jsx("div",{className:"flex items-center gap-2",children:o.jsx(Bn,{dataType:"value",data:l??{},onSelect:U=>c&&c(U,i)})})]}),o.jsxs(m.TabsContent,{value:"edit",className:"relative mt-0",children:[!q&&u==="edit"&&o.jsx(Rt,{content:"Format JSON",side:"right",showTooltip:!s&&!E,children:o.jsx(m.Button,{type:"button",variant:"outline",size:"icon",onClick:oe,className:"absolute right-1 top-1 h-6 w-6 p-1",disabled:!e.trim()||s||E!==null,children:o.jsx(v.FileCode2,{})})}),q?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(v.Plus,{}),"Copy & Edit from default language"]})]})}):o.jsx(m.Textarea,{ref:A,id:i,name:i,className:`rounded-md border border-input text-xs ${E?"border-red-500":""}`,onChange:V,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(v.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:le,children:"Show position"})]})]})]}),o.jsxs(m.TabsContent,{value:"preview",className:"mt-0",children:[o.jsx(m.Textarea,{rows:a,value:P,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."})]}),D&&o.jsx(m.TabsContent,{value:"shared",className:"mt-0",children:o.jsx(h.Suspense,{children:o.jsx(ko,{})})})]})})},Oo=()=>{const e=ee("getAccessToken");return{getAccessToken:h.useCallback(async()=>{try{return await e()}catch{return""}},[e])}},Ro=()=>{const{logout:e}=He(),{getAccessToken:t}=Oo();return h.useCallback(async({url:s,method:n="GET",body:r={},headers:a={}})=>{const i=await t();if(!i)throw new Error("No auth token");if(!s)throw new Error("URL is required");try{const l=await fetch(s,{method:n,headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`,...a},body:JSON.stringify(r)});if(l.status===401)return console.log("Session expired",l),await e(),window.location.reload(),null;if(l.status===400)throw new Error((await l.json()).error);return await l.json()}catch(l){throw console.log("Something went wrong",l),l}},[e,t])};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.CONTENT=Y;exports.ChaiBuilderPages=xo;exports.ChaiBuilderPagesRealtime=Ds;exports.Dynamic=Si;exports.For=Va;exports.ImagePicker=Lo;exports.Index=Qa;exports.LANGUAGES=$e;exports.LanguageSwitcher=Ms;exports.Match=Wa;exports.NestedPathSelector=Bn;exports.PAGES_PERMISSIONS=se;exports.PageActionsDropdown=Fs;exports.PermissionChecker=Tt;exports.Portal=yi;exports.Show=za;exports.SmartJsonInput=jo;exports.Switch=$a;exports.Tooltip=Rt;exports.addEventListener=gn;exports.addNewLangAtom=jt;exports.batch=Ca;exports.className=hn;exports.clearDelegatedEvents=li;exports.convertRemToPixels=lo;exports.createComponent=ds;exports.createComputed=Zs;exports.createContext=Da;exports.createEffect=cs;exports.createMemo=$;exports.createRenderEffect=Ee;exports.createRoot=me;exports.createSignal=K;exports.createUniqueId=Ha;exports.delegateEvents=fn;exports.deleteNestedDataByPath=Je;exports.displayValue=so;exports.getMutationStatusColor=eo;exports.getPreferredColorScheme=co;exports.getQueryStatusColor=Zi;exports.getQueryStatusColorByLabel=to;exports.getQueryStatusLabel=Ji;exports.getSidedProp=Xi;exports.insert=Gt;exports.memo=ai;exports.mergeProps=fs;exports.mutationSortFns=oo;exports.navigateToPage=rs;exports.on=Ia;exports.onCleanup=qe;exports.onMount=en;exports.parseJSONWithPlaceholders=es;exports.previewUrlAtom=Rn;exports.serialize=Dn;exports.setAttribute=Nt;exports.sortFns=ao;exports.splitProps=ln;exports.spread=mn;exports.stringify=Yi;exports.template=oi;exports.throwConfetti=Pt;exports.untrack=J;exports.updateNestedDataByPath=Ye;exports.use=En;exports.useActivePage=ue;exports.useAddGlobalSchema=ia;exports.useApiUrl=j;exports.useApplySchemaToAllPages=ua;exports.useAssetsApiUrl=Yn;exports.useBuilderPageData=Ks;exports.useChaiAuth=He;exports.useChaiFetch=Ro;exports.useChaiUserInfo=Os;exports.useChangePage=Un;exports.useChangeSlug=Nr;exports.useClearAll=bo;exports.useContext=ka;exports.useCreatePage=wr;exports.useCurrentPage=Z;exports.useDeleteGlobalSchema=la;exports.useDeletePage=br;exports.useDynamicPageSelector=js;exports.useFallbackLang=Ot;exports.useFetch=L;exports.useGotoPage=Mn;exports.useIsLanguagePageCreated=ts;exports.useLanguagePages=ye;exports.useMarkAsTemplate=Ir;exports.usePageEditInfo=kt;exports.usePageLockRequestTakeOver=Rs;exports.usePageType=Bs;exports.usePageTypes=de;exports.usePageUserMapping=cr;exports.usePagesProps=Dt;exports.usePublishPages=is;exports.useReloadPage=vo;exports.useRemoveSchemaFromAllPages=da;exports.useSearchParams=te;exports.useTogglePageGlobalSchema=ca;exports.useTransition=Ga;exports.useUnmarkAsTemplate=Lr;exports.useUnpublishPage=Cr;exports.useUpdateActivePageMetadata=Co;exports.useUpdateGlobalSchema=oa;exports.useUpdatePage=vr;exports.useUpdateWebsiteSettings=Hs;exports.useUserRoleAndPermissions=Vs;exports.useWebsiteLanguagePages=mr;exports.useWebsitePages=as;exports.useWebsiteSetting=Ae;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),x=require("./index-Cds1vIhw.cjs"),B=require("./use-page-expand-manager-2KjeYfVS.cjs"),n=require("lodash-es"),Q=require("@chaibuilder/sdk"),se=require("jotai"),v=require("lucide-react"),l=require("react"),V=(e,r)=>!e||!Array.isArray(e)?[]:n.isEmpty(r)?e:n.compact(n.filter(e,a=>{const t=n.toLower(r);return n.includes(n.toLower((a==null?void 0:a.name)||""),t)||n.includes(n.toLower((a==null?void 0:a.slug)||""),t)})),te=(e,r)=>{const a=new Set,t=n.keyBy(e,"id");return r.forEach(o=>{let c=o;for(;c.parent&&t[c.parent];)a.add(c.parent),c=t[c.parent]}),Array.from(a).map(o=>t[o])},$=(e,r,a)=>n.isEmpty(r)?e:e.map(t=>{if(!a(t.pageType))return{...t,shouldExpandOnSearch:!0,children:t.children?$(t.children,r,a):[]};const o=t.children&&t.children.some(c=>n.includes(n.toLower(c.name||""),n.toLower(r))||n.includes(n.toLower(c.slug||""),n.toLower(r)));return{...t,shouldExpandOnSearch:o,children:t.children?$(t.children,r,a):[]}}),ne=e=>{if(!e||!e.length)return[];const r={};e.forEach(t=>{r[t.id]={...t,children:[]}});const a=[];return Object.values(r).forEach(t=>{t.parent&&r[t.parent]?r[t.parent].children.push(t):a.push(t)}),a},J=e=>!e||!e.length?[]:[...e].sort((a,t)=>(a.name||"").localeCompare(t.name||"")).map(a=>({...a,children:a.children?J(a.children):[]})),re=(e,r,a,t)=>{if(!e||!e.length)return[];let o=e;if(a!=="all"&&(o=n.compact(n.filter(e,{pageType:a}))),n.isEmpty(r))o=V(o,r);else{const m=V(o,r),d=te(e,m);o=n.uniqBy([...m,...d],"id")}const c=J(ne(o)),b=$(c,r,t),y=n.filter(b,m=>t(m.pageType)).sort((m,d)=>(m.name||"").localeCompare(d.name||"")),p=n.filter(b,m=>!t(m.pageType));let f=[];if(a==="all"){const m=n.keyBy(p,"pageType");f=Object.values(n.mapValues(m,(d,j)=>({...d,id:j,name:n.startCase(j),isPartialGroup:!0,children:b.filter(N=>N.pageType===j)})))}else f=p.sort((m,d)=>(m.name||"").localeCompare(d.name||""));return[...y,...f]},ae=({page:e})=>{var t,o;const{isExpanded:r,toggleExpanded:a}=B.usePageExpandManager(e==null?void 0:e.id);return s.jsx("button",{onClick:c=>{c.stopPropagation(),a()},disabled:!((t=e==null?void 0:e.children)!=null&&t.length),className:`flex h-[calc(100%-2px)] w-5 items-center justify-center rounded text-gray-400 transition-colors hover:bg-gray-200 hover:px-1 hover:text-gray-500 ${(o=e==null?void 0:e.children)!=null&&o.length?"hover:text-blue-400":"opacity-0"}`,children:s.jsx(v.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${r?"rotate-90":""}`})})},le=({page:e,pageType:r})=>s.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?s.jsx(v.StarsIcon,{size:12,className:"text-yellow-400"}):r!=null&&r.icon?s.jsx("div",{className:"flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",dangerouslySetInnerHTML:{__html:r.icon}}):r!=null&&r.hasSlug?s.jsx(v.File,{size:12,className:"stroke-[1] text-slate-500"}):s.jsx(v.Globe,{size:12,className:"stroke-[1] text-slate-500"})}),ie=({isOnline:e})=>s.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),oe=({page:e,pageTypes:r,currentPage:a,onClickAction:t,languagePages:o,selectedLanguage:c,showUntranslatedPages:b})=>{const[y]=x.usePageUserMapping(),p=x.useFallbackLang(),f=a===e.id,m=!!e.isTemplate,d=l.useMemo(()=>n.find(r,{key:e.pageType}),[r,e.pageType]),j=y==null?void 0:y[e.id],{data:N}=x.useChaiUserInfo(j),g=N?N==null?void 0:N.name:null;let h=n.get(o,e==null?void 0:e.id);h=n.get(h,"lang")===c?h:null;const E=c===p||!!h,L=(h==null?void 0:h.name)||(e==null?void 0:e.name)||"No name";let S=(h==null?void 0:h.slug)||(e==null?void 0:e.slug)||"";const C=S+(e!=null&&e.dynamic?`/${d==null?void 0:d.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(S.startsWith("/")&&!b){const u=S.split("/").pop();S=S.endsWith(u)&&e.dynamic?"":`/${u}`}const q=l.useMemo(()=>{const u="flex h-7 min-w-0 flex-1 cursor-pointer select-none items-center gap-x-1.5 rounded px-px text-xs duration-300 border-[1px]",T=`${f?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${u} ${T} ${g?"opacity-60":""}`:`${u} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,f,g]);return s.jsxs("div",{className:"group relative",children:[s.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&t("select",e==null?void 0:e.id),className:q,children:[s.jsx(ae,{page:e}),!e.isPartialGroup&&s.jsx(ie,{isOnline:h?h.online:e.online}),s.jsx(le,{page:e,pageType:d}),s.jsx(x.Tooltip,{content:L,side:"top",showTooltip:L.length>35,children:s.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:L})}),(S||e.dynamic)&&s.jsx(x.Tooltip,{content:C,side:"top",showTooltip:!0,children:s.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[S,e.dynamic&&(d==null?void 0:d.dynamicSlug)&&s.jsxs("span",{className:"text-xs text-gray-500",children:["/",d==null?void 0:d.dynamicSlug,e.dynamicSlugCustom]})]})}),m&&s.jsx(x.Tooltip,{content:"Template",side:"top",children:s.jsx("span",{className:"text-blue-500",children:s.jsx(v.NotepadText,{size:16})})}),!e.isPartialGroup&&E&&!g?s.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:s.jsx(x.PageActionsDropdown,{isLanguagePage:!!h,page:h||e,setDuplicatePage:u=>t("duplicate",u),setAddEditPage:u=>t("edit",h||u),setUnpublishPage:u=>t("unpublish",u),setDeletePage:u=>t("delete",h||u),setMarkAsTemplate:u=>t("markAsTemplate",u),setUnmarkAsTemplate:u=>t("unmarkAsTemplate",u),children:s.jsx("div",{className:"m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white",children:s.jsx(v.MoreHorizontal,{className:"h-4 w-4",onClick:u=>u.stopPropagation()})})})}):g?s.jsx("span",{className:"duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500",children:s.jsx(v.Lock,{className:"h-3.5 w-3.5 fill-red-200 text-red-500"})}):null]}),s.jsx(s.Fragment,{children:g&&s.jsxs("button",{className:"absolute right-0 top-0 flex h-full items-center gap-x-1 rounded bg-red-50 px-2 py-0.5 text-xs font-light text-red-500 opacity-0 group-hover:opacity-100",children:[s.jsx(v.Edit,{size:12,className:"stroke-[3]"})," ",s.jsx("span",{className:"font-medium",children:g})," is editing this page"]})}),s.jsx(s.Fragment,{children:!E&&!e.isPartialGroup&&!g&&s.jsxs("button",{onClick:u=>{u.stopPropagation(),t("addLanguagePage",{language:c,page:e})},className:"absolute left-1/2 top-1 flex -translate-x-1/2 items-center gap-x-1 rounded bg-blue-500 px-2 py-0.5 text-xs text-white opacity-0 duration-200 hover:bg-blue-700 group-hover:opacity-100",children:[s.jsx(v.Plus,{size:12,className:"stroke-[3]"})," ",s.jsxs("span",{className:"text-[10px]",children:["Add ",n.get(x.LANGUAGES,c)," Page"]})]})})]})},K=({pages:e,tier:r,pageTypes:a,currentPage:t,onClickAction:o,languagePages:c,selectedLanguage:b,showUntranslatedPages:y})=>{const{expandedPages:p}=B.usePageExpandManager();return s.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${r*10}px`},children:e.map(f=>s.jsxs(s.Fragment,{children:[s.jsx(oe,{page:f,pageTypes:a,currentPage:t,onClickAction:o,languagePages:c,selectedLanguage:b,showUntranslatedPages:y}),f.children&&f.children.length>0&&(p==null?void 0:p.includes(f.id))&&s.jsx(K,{pages:f.children,tier:r+1,pageTypes:a,currentPage:t,onClickAction:o,languagePages:c,selectedLanguage:b,showUntranslatedPages:y})]},f.id))})},ce=l.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-z2b4sgvb.cjs"))),de=l.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-YpzILOYq.cjs"))),ue=l.lazy(()=>Promise.resolve().then(()=>require("./delete-page-w64MO7db.cjs"))),me=l.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-DB_c7V2t.cjs"))),he=l.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-C4wH4UKf.cjs"))),xe=l.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-C8hTjRVk.cjs"))),fe=l.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-gtGfNOAq.cjs"))),Pe=({close:e})=>{const{languages:r,setSelectedLang:a}=Q.useLanguages(),{data:t}=x.usePageTypes(),{data:o,isFetching:c}=x.useWebsitePages(),[b,y]=x.useSearchParams(),{updateForSelectedPage:p,expandPagesOnSearch:f}=B.usePageExpandManager(null),m=x.useFallbackLang(),d=b.get("page"),[j,N]=l.useState(""),[g,h]=l.useState(null),[E,L]=l.useState(null),[S,C]=l.useState(null),[q,u]=l.useState(null),[T,F]=l.useState(""),[I,G]=l.useState(null),[O,R]=l.useState(null),[k,X]=l.useState(m),[Y,Z]=l.useState(!1),[,D]=se.useAtom(x.addNewLangAtom),M=Y&&k!==m,{data:A,isFetching:ee}=x.useWebsiteLanguagePages(k),W=l.useCallback(P=>{var i;return(i=n.find(t,{key:P}))==null?void 0:i.hasSlug},[t]),w=l.useMemo(()=>o?M?n.filter(o,P=>!(A!=null&&A[P.id])):re(o,j,T,W):[],[o,W,j,T,A,M]);l.useEffect(()=>{a(m)},[m,a]),l.useEffect(()=>{if(!n.isEmpty(T))return;const P=sessionStorage.getItem("pageTypeFilter")||"all";!n.isEmpty(t)&&P&&(n.find(t,{key:P})?F(P):F("all"))},[t,T]),l.useEffect(()=>{if(d&&!c&&!n.find(o,{id:d})){const i=n.find(o,{slug:"/"});if(i){const z=new URLSearchParams({page:i.id});x.navigateToPage(z,y)}else x.navigateToPage(new URLSearchParams({}),y,!0)}},[o,d,c,y]),l.useEffect(()=>{d&&!c&&!n.isEmpty(w)&&p(w,d)},[d,c,w,p]),l.useEffect(()=>{!n.isEmpty(j)&&!n.isEmpty(w)&&f(w)},[j,w,f]);const{setSelectedLang:U}=Q.useLanguages(),_=l.useCallback(P=>{const i=new URLSearchParams({page:P});k!==m?(i.set("lang",k),U(k)):U(""),x.navigateToPage(i,y),e()},[e,y,U,k,m]),H=(P,i)=>{var z;if(i)switch(P){case"add":L(i);break;case"select":_(i);break;case"edit":k!==m?D({edit:!0,id:i==null?void 0:i.id,primaryPage:i==null?void 0:i.primaryPage}):L(i);break;case"delete":h(i);break;case"unpublish":C(i);break;case"markAsTemplate":u(i);break;case"unmarkAsTemplate":R(i);break;case"duplicate":G(i);break;case"addLanguagePage":D({edit:!1,primaryPage:((z=i==null?void 0:i.page)==null?void 0:z.id)||"",preselectedLang:(i==null?void 0:i.language)||k});break}};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex h-full flex-col justify-between",children:[s.jsx(l.Suspense,{children:s.jsx(ce,{pages:w,search:j,setSearch:N,languages:[m,...r],selectedLanguage:k,setSelectedLanguage:X,selectedPageType:T,setSelectedPageType:F,onAddPage:P=>H("add",P),showUntranslatedPages:M,setShowUntranslatedPages:Z})}),s.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:c||ee?s.jsx("div",{className:"space-y-2",children:n.map([...Array(15).keys()],P=>s.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},P))}):n.isEmpty(w)?s.jsxs("div",{className:"flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500",children:[s.jsx(v.File,{className:"h-6 w-6 stroke-[1]"}),"Empty List!",s.jsx("span",{className:"font-light",children:"Add new page to start"})]}):s.jsx(K,{tier:0,pages:w,pageTypes:t,currentPage:d||"",onClickAction:H,languagePages:A,selectedLanguage:k,showUntranslatedPages:M})})]}),E&&s.jsx(l.Suspense,{children:s.jsx(de,{closePanel:e,editPage:_,addEditPage:E,setAddEditPage:L})}),g&&s.jsx(l.Suspense,{children:s.jsx(ue,{page:g,onClose:()=>h(null)})}),S&&s.jsx(l.Suspense,{children:s.jsx(fe,{page:S,onClose:()=>C(null)})}),q&&s.jsx(l.Suspense,{children:s.jsx(he,{page:q,onClose:()=>u(null)})}),O&&s.jsx(l.Suspense,{children:s.jsx(xe,{page:O,onClose:()=>R(null)})}),I&&s.jsx(l.Suspense,{children:s.jsx(me,{page:I,onClose:()=>G(null),closePanel:e})})]})};exports.default=Pe;