@chaibuilder/sdk 4.0.0-beta.47 → 4.0.0-beta.49

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 (122) hide show
  1. package/dist/{2SSKDMRQ-CVHl6i14.cjs → 2SSKDMRQ-CjvuNdPo.cjs} +1 -1
  2. package/dist/{2SSKDMRQ-D9rlRpnI.js → 2SSKDMRQ-Dvf9zadl.js} +2 -2
  3. package/dist/{AP7HFJJL-D18sv0Wh.cjs → AP7HFJJL-DYFttFoI.cjs} +1 -1
  4. package/dist/{AP7HFJJL-CBrphwP9.js → AP7HFJJL-q4dJdyFs.js} +1 -1
  5. package/dist/{IconPicker-CSewv0kY.js → IconPicker-Bf163F7t.js} +1 -1
  6. package/dist/{IconPicker-CxEGCcVZ.cjs → IconPicker-JWhYq2Gp.cjs} +1 -1
  7. package/dist/{WDYDFRGG-C0G8c0hR.cjs → WDYDFRGG-BEksfGMC.cjs} +1 -1
  8. package/dist/{WDYDFRGG-BCmjXFs0.js → WDYDFRGG-O9GIrtX0.js} +2 -2
  9. package/dist/{actions-registery-BQ31lpix.cjs → actions-registery-BHbZHkE3.cjs} +11 -3
  10. package/dist/{actions-registery-B1VeX52Y.js → actions-registery-gJb_wq2F.js} +25 -13
  11. package/dist/actions.cjs +1 -1
  12. package/dist/actions.d.ts +10 -3
  13. package/dist/actions.js +6 -4
  14. package/dist/{active-in-another-tab-BhbPijx9.js → active-in-another-tab-B4Ur0JP7.js} +2 -2
  15. package/dist/{active-in-another-tab-CMmhCRma.cjs → active-in-another-tab-BPdx4lWh.cjs} +1 -1
  16. package/dist/{add-new-language-page-ChQgjFwb.cjs → add-new-language-page-BfUp5Ua2.cjs} +1 -1
  17. package/dist/{add-new-language-page-C0sayTSF.js → add-new-language-page-CRR93tLq.js} +3 -3
  18. package/dist/{add-new-page-DLf5Tfb7.cjs → add-new-page-B8NGK6WS.cjs} +1 -1
  19. package/dist/{add-new-page-DLKzuaNM.js → add-new-page-Ppy5-y5j.js} +2 -2
  20. package/dist/ai-panel-default-lang-BXYQye3N.js +333 -0
  21. package/dist/ai-panel-default-lang-VhgmHFoQ.cjs +3 -0
  22. package/dist/ai-panel-other-lang-DaCf-cq4.js +148 -0
  23. package/dist/ai-panel-other-lang-Ds0EXeUC.cjs +1 -0
  24. package/dist/{ai-prompt-input-DNb1FKXQ.js → ai-prompt-input-7iWk72w5.js} +253 -258
  25. package/dist/ai-prompt-input-nZ5_Dm7X.cjs +1 -0
  26. package/dist/{ai-translation-prompt-B2MfzTjb.js → ai-translation-prompt-1OUs1P7n.js} +1 -1
  27. package/dist/{ai-translation-prompt-CL3yk8K1.cjs → ai-translation-prompt-B16cK-1Q.cjs} +1 -1
  28. package/dist/{change-password-modal-CbMifP62.js → change-password-modal-CdvJR1Ln.js} +10 -10
  29. package/dist/{change-password-modal-D_NFPZxI.cjs → change-password-modal-D5eXjiYq.cjs} +1 -1
  30. package/dist/{code-editor-53rOkfhX.js → code-editor-CyLjDiEp.js} +1 -1
  31. package/dist/{code-editor-CCsljULB.cjs → code-editor-SWbfFj1E.cjs} +1 -1
  32. package/dist/{continue-editing-in-this-client-hB4O3CHJ.js → continue-editing-in-this-client-BrSvK-Ay.js} +2 -2
  33. package/dist/{continue-editing-in-this-client-3QLL7tQH.cjs → continue-editing-in-this-client-Cmi-GkYZ.cjs} +1 -1
  34. package/dist/core.cjs +1 -1
  35. package/dist/core.js +1 -1
  36. package/dist/{css-import-modal-Bmi3LrEJ.cjs → css-import-modal-Bdwgd05S.cjs} +1 -1
  37. package/dist/{css-import-modal-DCivkVh2.js → css-import-modal-Be47CBJn.js} +1 -1
  38. package/dist/{delete-page-BW2NxLZu.js → delete-page-C99K2qzS.js} +15 -15
  39. package/dist/{delete-page-CxVfKrBz.cjs → delete-page-DLohaU-U.cjs} +1 -1
  40. package/dist/{design-token-usage-WTVjf9c-.js → design-token-usage-D1lWCJ3L.js} +1 -1
  41. package/dist/{design-token-usage-5jsa9ojN.cjs → design-token-usage-eY2wQ0l3.cjs} +1 -1
  42. package/dist/{digital-asset-manager-dNK-BYdI.js → digital-asset-manager-BZMb6sC7.js} +3 -3
  43. package/dist/{digital-asset-manager-DlFCWUP4.cjs → digital-asset-manager-Z5aJxkq0.cjs} +1 -1
  44. package/dist/{duplicate-page-BbB2anQO.js → duplicate-page-CDc2X0eW.js} +12 -12
  45. package/dist/{duplicate-page-0o6G-oY_.cjs → duplicate-page-D5Gtvqdv.cjs} +1 -1
  46. package/dist/{dynamic-page-selector-Ds3MqxTF.cjs → dynamic-page-selector-DZHhX008.cjs} +1 -1
  47. package/dist/{dynamic-page-selector-rFO8457w.js → dynamic-page-selector-DvNBXo6o.js} +2 -2
  48. package/dist/{image-editor-BnVkes6Q.js → image-editor-BBvvi9Vm.js} +1 -1
  49. package/dist/{image-editor-DqItmbk1.cjs → image-editor-DwhTYkVR.cjs} +1 -1
  50. package/dist/index-BVwFJWDq.cjs +5 -0
  51. package/dist/{index-DTNHTRZu.cjs → index-DCJDQs1a.cjs} +8 -8
  52. package/dist/{index-BYjniKhj.js → index-LBTm1Jmk.js} +838 -806
  53. package/dist/{index-B7HAfx-2.js → index-OuHV9Ann.js} +16 -9
  54. package/dist/{json-diff-viewer-B4rnFiN_.cjs → json-diff-viewer-Cb1CmRqP.cjs} +1 -1
  55. package/dist/{json-diff-viewer-CKlyO9eW.js → json-diff-viewer-DG6qMOBS.js} +6 -6
  56. package/dist/{lang-panel-YT96E5Xj.js → lang-panel-B3USOxGq.js} +9 -9
  57. package/dist/{lang-panel-DiVz4Cay.cjs → lang-panel-DxoJ0v4y.cjs} +1 -1
  58. package/dist/{manage-design-tokens-LwImeKaK.js → manage-design-tokens-6YGIctip.js} +2 -2
  59. package/dist/{manage-design-tokens-modal-BEElCTcN.cjs → manage-design-tokens-modal-BSSCXH8Y.cjs} +1 -1
  60. package/dist/{manage-design-tokens-modal-DFVcoyra.js → manage-design-tokens-modal-CzsnN49F.js} +2 -2
  61. package/dist/{manage-design-tokens-BwrIc6dS.cjs → manage-design-tokens-udLBvkHA.cjs} +1 -1
  62. package/dist/{mark-as-template-DtDkh6jB.cjs → mark-as-template-B9yLcasI.cjs} +1 -1
  63. package/dist/{mark-as-template-D2Hpz0IE.js → mark-as-template-CP_F9ZQ4.js} +2 -2
  64. package/dist/{models-D0RH2u4C.cjs → models-CQaC3EBW.cjs} +1 -1
  65. package/dist/{models-BCu-p_QK.js → models-DZ9C6CvE.js} +4 -5
  66. package/dist/{nested-path-selector-content-TqjBbNys.js → nested-path-selector-content-DmtCI3q9.js} +1 -1
  67. package/dist/{nested-path-selector-content-CJfN8Hhw.cjs → nested-path-selector-content-aTdu-o0e.cjs} +1 -1
  68. package/dist/{no-language-page-content-CcD-fgMa.cjs → no-language-page-content-C-MCdPXt.cjs} +1 -1
  69. package/dist/{no-language-page-content-Ce3wniZT.js → no-language-page-content-D8t5dfgh.js} +2 -2
  70. package/dist/{no-language-page-dialog-CU1zXsYv.js → no-language-page-dialog-C_fHI2zI.js} +2 -2
  71. package/dist/{no-language-page-dialog-B7fhPdob.cjs → no-language-page-dialog-D4QIAHnE.cjs} +1 -1
  72. package/dist/{page-creator-C7XEqUx_.cjs → page-creator-Cz_ah-qE.cjs} +1 -1
  73. package/dist/{page-creator-wg3uymVG.js → page-creator-DKEkuGCO.js} +33 -33
  74. package/dist/{page-lock-BuVma3e5.js → page-lock-CwZKJ4IE.js} +2 -2
  75. package/dist/{page-lock-CINb2air.cjs → page-lock-DdCvtA-I.cjs} +1 -1
  76. package/dist/{page-locked-dialog-s-3ROcy0.cjs → page-locked-dialog-CrTDBoC4.cjs} +1 -1
  77. package/dist/{page-locked-dialog-C7_1gjO5.js → page-locked-dialog-DqLlooUz.js} +11 -11
  78. package/dist/{page-manager-new-CKWSLVrb.cjs → page-manager-new-ah6QYar2.cjs} +1 -1
  79. package/dist/{page-manager-new-zlobCGqL.js → page-manager-new-ttsrxdW9.js} +42 -42
  80. package/dist/{page-manager-search-and-filter-BaOsl_5u.cjs → page-manager-search-and-filter-D7AupT6_.cjs} +1 -1
  81. package/dist/{page-manager-search-and-filter-BU_iNmHy.js → page-manager-search-and-filter-bsqZ6wnI.js} +2 -2
  82. package/dist/{page-revisions-content-BmaNPNoS.cjs → page-revisions-content-B6hsIla7.cjs} +1 -1
  83. package/dist/{page-revisions-content-D6l_d2jW.js → page-revisions-content-C5O8_Fms.js} +16 -16
  84. package/dist/pages.cjs +1 -1
  85. package/dist/pages.d.ts +66 -1
  86. package/dist/pages.js +19 -19
  87. package/dist/{publish-pages-content-2LG6JOrm.cjs → publish-pages-content-BrajJUcP.cjs} +1 -1
  88. package/dist/{publish-pages-content-CQteRtBA.js → publish-pages-content-KZVMHT6V.js} +32 -32
  89. package/dist/{rte-widget-modal-KzT2hLFt.cjs → rte-widget-modal-CiTwsXTr.cjs} +1 -1
  90. package/dist/{rte-widget-modal-CFk0Izg5.js → rte-widget-modal-IU8JzPuZ.js} +1 -1
  91. package/dist/{save-to-lib-D1V3bNZX.js → save-to-lib-DMnv7ENo.js} +50 -50
  92. package/dist/{save-to-lib-D82Vrekv.cjs → save-to-lib-Dc700Aop.cjs} +1 -1
  93. package/dist/{selected-block-display-BHx9N14K.cjs → selected-block-display-CAFEOrLV.cjs} +1 -1
  94. package/dist/{selected-block-display-BbUH5RaW.js → selected-block-display-CidmQ-wz.js} +2 -2
  95. package/dist/{seo-panel-CyBmGg6k.js → seo-panel-Br8gxDxu.js} +148 -158
  96. package/dist/{seo-panel-CPsjZLtL.cjs → seo-panel-CMY-adM-.cjs} +2 -2
  97. package/dist/{shared-json-ld-DyU9wqrE.cjs → shared-json-ld-CMH-eRUq.cjs} +1 -1
  98. package/dist/{shared-json-ld-SGykyppC.js → shared-json-ld-uvMmwCYp.js} +26 -26
  99. package/dist/{slug-input-BzpnOdXG.cjs → slug-input-CiHC5l3r.cjs} +1 -1
  100. package/dist/{slug-input-DpMI4nEB.js → slug-input-DLWTMTsO.js} +1 -1
  101. package/dist/supabase-actions.cjs +1 -1
  102. package/dist/supabase-actions.js +1 -1
  103. package/dist/{take-over-request-wTVLAotu.cjs → take-over-request-IRLgF1dG.cjs} +1 -1
  104. package/dist/{take-over-request-D97Fg-xB.js → take-over-request-KdR1_h_K.js} +5 -5
  105. package/dist/{translation-warning-modal-Xk6oYGFS.cjs → translation-warning-modal-CLZ9tC1F.cjs} +1 -1
  106. package/dist/{translation-warning-modal-Du-CnfyH.js → translation-warning-modal-CzNt6LDO.js} +1 -1
  107. package/dist/types.d.ts +6 -0
  108. package/dist/{unmark-as-template-BHk2F0ck.js → unmark-as-template-C5ovsEBP.js} +2 -2
  109. package/dist/{unmark-as-template-BRnMhh7n.cjs → unmark-as-template-F7TdgWjI.cjs} +1 -1
  110. package/dist/{unpublish-page-BOEjCHLB.js → unpublish-page-0fR1o0b7.js} +8 -8
  111. package/dist/{unpublish-page-Bu75lH33.cjs → unpublish-page-CUr8Xub6.cjs} +1 -1
  112. package/dist/{unpublished-partials-modal-C0_0qNvV.js → unpublished-partials-modal-BhNAub_z.js} +1 -1
  113. package/dist/{unpublished-partials-modal-BS_GddEG.cjs → unpublished-partials-modal-Cv5R9-hi.cjs} +1 -1
  114. package/dist/{web-preview-DcOhTGup.cjs → web-preview-CuMYekVJ.cjs} +1 -1
  115. package/dist/{web-preview-C3bbIF6T.js → web-preview-D9pXonAv.js} +1 -1
  116. package/package.json +1 -1
  117. package/dist/ai-panel-default-lang-DsGjoITc.cjs +0 -3
  118. package/dist/ai-panel-default-lang-Dy_4L5pH.js +0 -317
  119. package/dist/ai-panel-other-lang-1RYtb71B.js +0 -132
  120. package/dist/ai-panel-other-lang-CL3coL7Z.cjs +0 -1
  121. package/dist/ai-prompt-input-BhTL_-mT.cjs +0 -1
  122. package/dist/index-BeGLwvqs.cjs +0 -5
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),q=require("./register-chai-top-bar-DyW9GPzV.cjs"),f=require("./index-DTNHTRZu.cjs"),r=require("./index-BeGLwvqs.cjs"),U=require("./page-manager-search-and-filter-BaOsl_5u.cjs"),F=require("@tanstack/react-query"),t=require("lodash-es"),b=require("lucide-react"),a=require("react"),M=()=>{const l=r.useApiUrl(),u=r.useFetch();return F.useQuery({queryKey:[r.ACTIONS.GET_CHANGES],queryFn:async()=>u(l,{action:r.ACTIONS.GET_CHANGES})})},G=({page:l,selectedPages:u,handleCheckboxChange:N,getPageType:y,hasSlug:h,currentOwnerId:c})=>{const x=r.useUserId(),{data:d}=r.useChaiUserInfo(c),o=c===x?null:d==null?void 0:d.name;return e.jsxs("tr",{className:"group relative border-b last:border-b-0 hover:bg-gray-50",children:[e.jsxs("td",{scope:"row",className:`flex items-center gap-x-1 whitespace-nowrap px-6 py-2 text-gray-900 dark:text-white ${o?"opacity-50":""}`,children:[o?e.jsx(b.Lock,{className:"h-4 w-4 fill-red-200 text-red-500"}):e.jsx("input",{checked:t.includes(u,l==null?void 0:l.id),onClick:p=>{p.stopPropagation(),N(l==null?void 0:l.id)},type:"checkbox",className:"cursor-pointer rounded focus:outline-none focus:ring-0"})," ",h(l.pageType)?e.jsx(b.File,{className:"h-4 w-4"}):e.jsx(b.GlobeIcon,{className:"h-4 w-4"}),e.jsx(r.Tooltip,{content:l.name,side:"top",showTooltip:l.name.length>25,children:e.jsx("span",{className:"max-w-[200px] truncate font-medium text-black",children:l.name})}),l.slug&&e.jsx(r.Tooltip,{content:l.slug,side:"top",showTooltip:l.slug.length>25,children:e.jsx("span",{className:"max-w-[200px] truncate font-mono text-xs text-muted-foreground",children:l.slug})})]}),e.jsx("td",{className:"px-2",children:y(l==null?void 0:l.pageType)}),e.jsx("td",{className:"px-4 text-right",children:t.first(l.changes)||""}),e.jsx(e.Fragment,{children:o&&e.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:[e.jsx(b.Edit,{size:12,className:"stroke-[3]"})," ",e.jsx("span",{className:"font-medium",children:o})," is editing this page"]})})]},l==null?void 0:l.id)},O=({onClose:l=()=>{},isPending:u,publishPage:N})=>{const y=r.useUserId(),{pageToUser:h}=r.usePageToUser(),[c,x]=a.useState([]),d=r.useFallbackLang(),[o,p]=a.useState(d),{data:T,isFetching:C}=M(),{data:g}=r.usePageTypes(),k=a.useCallback(s=>{var n;return(n=t.find(g,{key:s}))==null?void 0:n.hasSlug},[g]),j=a.useMemo(()=>t.filter(g,s=>!k(s.key)).map(s=>s.key),[k,g]),P=t.uniq(t.map(T,"lang")).filter(Boolean),i=a.useMemo(()=>t.filter(T,s=>s.pageType==="theme"||s.pageType==="design_tokens"?!1:o===d?s.lang===o||s.lang==="":s.lang===o),[T,o,d]),w=a.useMemo(()=>t.filter(i,s=>!j.includes(s.pageType)),[i,j]),S=a.useMemo(()=>t.filter(i,s=>j.includes(s.pageType)),[i,j]);a.useEffect(()=>{const s=t.map(t.filter(i,{online:!0}),"id");a.startTransition(()=>x(s))},[i]),a.useEffect(()=>{const s=t.filter(t.keys(h),n=>t.get(h,[n,"userId"])!==y);a.startTransition(()=>x(n=>t.filter(n,m=>!t.includes(s,m))))},[h,y]);const v=c.length===(i==null?void 0:i.length),E=s=>{x(n=>t.includes(n,s)?t.filter(n,m=>m!==s):t.concat(n,s))},B=()=>{x(v?[]:t.map(i,"id"))},I=()=>{N({ids:t.uniq(c)},{onSuccess:()=>{l(),r.throwConfetti("CENTER_CENTER"),p(d)}})},A=s=>{if(s==="theme")return"Theme";const n=t.find(g,{key:s});return n?n==null?void 0:n.name:s},L=a.useMemo(()=>{const s=[{label:"Updated",top:"pt-2"},...t.orderBy(t.filter(w,{online:!0}),"pageType"),...t.orderBy(t.filter(S,{online:!0}),"pageType")].filter(m=>m.pageType!=="theme"&&m.pageType!=="design_tokens"),n=[{label:"Offline",top:"pt-6"},...t.orderBy(t.filter(w,{online:!1}),"pageType"),...t.orderBy(t.filter(S,{online:!1}),"pageType")];return[...s,...n]},[w,S]);return e.jsxs(f.DialogContent,{className:"flex max-h-[80%] max-w-4xl flex-col",children:[e.jsxs(f.DialogHeader,{children:[e.jsx(f.DialogTitle,{children:"Publish changes"}),e.jsx(f.DialogDescription,{className:"text-xs",children:"Select the pages you want to publish. Click publish when you're done."})]}),P.length>0&&e.jsx("div",{className:"my-[2px] mt-0",children:e.jsx(U.LanguageSelector,{languages:[d,...P],selectedLanguage:o,setSelectedLanguage:p})}),e.jsx("div",{className:"no-scrollbar relative -mx-4 -mt-4 h-full max-h-full overflow-y-auto",children:C?e.jsxs("div",{className:"space-y-2 px-1",children:[e.jsx("div",{className:"mt-2 h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"})]}):e.jsxs("table",{className:"w-full text-left text-xs text-gray-500 dark:text-gray-400 rtl:text-right",children:[e.jsx("thead",{className:"sticky top-0 z-10 border-b bg-gray-50 text-gray-700 dark:bg-gray-700 dark:text-gray-400",children:e.jsxs("tr",{children:[e.jsxs("th",{scope:"col",className:"w-[1 50px] flex items-center gap-x-2 px-6 py-3",children:[e.jsx("input",{checked:v,onClick:s=>{s.stopPropagation(),B()},type:"checkbox",className:"mt-1 cursor-pointer rounded focus:outline-none focus:ring-0"}),"Name"]}),e.jsx("th",{scope:"col",className:"w-[150px] px-2 py-3",children:"Type"}),e.jsx("th",{scope:"col",className:"w-[150px] px-4 py-3 text-right",children:"Status"})]})}),e.jsx("tbody",{children:t.map(L,s=>s.label?e.jsx("tr",{children:e.jsxs("td",{colSpan:3,className:`relative px-6 py-2 text-xs font-medium text-gray-800 ${s.top}`,children:[e.jsx("div",{className:"absolute inset-0 left-6 flex items-center",children:e.jsx("div",{className:"order-gray-300 w-full"})}),e.jsx("div",{className:"relative flex justify-start",children:e.jsx("span",{className:"bg-gray-50 pr-2",children:s.label})})]})},"separator"):e.jsx(G,{page:s,selectedPages:c,handleCheckboxChange:E,getPageType:A,hasSlug:k,currentOwnerId:t.get(h,[(s==null?void 0:s.primaryPage)||(s==null?void 0:s.id),"userId"])}))})]})}),e.jsxs(f.DialogFooter,{className:"mt-10 flex items-center justify-center",children:[c.length>0&&e.jsxs("span",{className:"text-center text-sm text-muted-foreground",children:[c.length," Page",c.length!==1?"s":""," Selected"]}),e.jsx(q.Button,{disabled:u,variant:"outline",onClick:l,children:"Cancel"}),e.jsx(q.Button,{disabled:u||C||t.isEmpty(c),onClick:I,children:u?"Publishing...":"Publish Selected"})]})]})};exports.default=O;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),q=require("./register-chai-top-bar-DyW9GPzV.cjs"),f=require("./index-DCJDQs1a.cjs"),r=require("./index-BVwFJWDq.cjs"),U=require("./page-manager-search-and-filter-D7AupT6_.cjs"),F=require("@tanstack/react-query"),t=require("lodash-es"),b=require("lucide-react"),a=require("react"),M=()=>{const l=r.useApiUrl(),u=r.useFetch();return F.useQuery({queryKey:[r.ACTIONS.GET_CHANGES],queryFn:async()=>u(l,{action:r.ACTIONS.GET_CHANGES})})},G=({page:l,selectedPages:u,handleCheckboxChange:N,getPageType:y,hasSlug:h,currentOwnerId:c})=>{const x=r.useUserId(),{data:d}=r.useChaiUserInfo(c),o=c===x?null:d==null?void 0:d.name;return e.jsxs("tr",{className:"group relative border-b last:border-b-0 hover:bg-gray-50",children:[e.jsxs("td",{scope:"row",className:`flex items-center gap-x-1 whitespace-nowrap px-6 py-2 text-gray-900 dark:text-white ${o?"opacity-50":""}`,children:[o?e.jsx(b.Lock,{className:"h-4 w-4 fill-red-200 text-red-500"}):e.jsx("input",{checked:t.includes(u,l==null?void 0:l.id),onClick:p=>{p.stopPropagation(),N(l==null?void 0:l.id)},type:"checkbox",className:"cursor-pointer rounded focus:outline-none focus:ring-0"})," ",h(l.pageType)?e.jsx(b.File,{className:"h-4 w-4"}):e.jsx(b.GlobeIcon,{className:"h-4 w-4"}),e.jsx(r.Tooltip,{content:l.name,side:"top",showTooltip:l.name.length>25,children:e.jsx("span",{className:"max-w-[200px] truncate font-medium text-black",children:l.name})}),l.slug&&e.jsx(r.Tooltip,{content:l.slug,side:"top",showTooltip:l.slug.length>25,children:e.jsx("span",{className:"max-w-[200px] truncate font-mono text-xs text-muted-foreground",children:l.slug})})]}),e.jsx("td",{className:"px-2",children:y(l==null?void 0:l.pageType)}),e.jsx("td",{className:"px-4 text-right",children:t.first(l.changes)||""}),e.jsx(e.Fragment,{children:o&&e.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:[e.jsx(b.Edit,{size:12,className:"stroke-[3]"})," ",e.jsx("span",{className:"font-medium",children:o})," is editing this page"]})})]},l==null?void 0:l.id)},O=({onClose:l=()=>{},isPending:u,publishPage:N})=>{const y=r.useUserId(),{pageToUser:h}=r.usePageToUser(),[c,x]=a.useState([]),d=r.useFallbackLang(),[o,p]=a.useState(d),{data:T,isFetching:C}=M(),{data:g}=r.usePageTypes(),k=a.useCallback(s=>{var n;return(n=t.find(g,{key:s}))==null?void 0:n.hasSlug},[g]),j=a.useMemo(()=>t.filter(g,s=>!k(s.key)).map(s=>s.key),[k,g]),P=t.uniq(t.map(T,"lang")).filter(Boolean),i=a.useMemo(()=>t.filter(T,s=>s.pageType==="theme"||s.pageType==="design_tokens"?!1:o===d?s.lang===o||s.lang==="":s.lang===o),[T,o,d]),w=a.useMemo(()=>t.filter(i,s=>!j.includes(s.pageType)),[i,j]),S=a.useMemo(()=>t.filter(i,s=>j.includes(s.pageType)),[i,j]);a.useEffect(()=>{const s=t.map(t.filter(i,{online:!0}),"id");a.startTransition(()=>x(s))},[i]),a.useEffect(()=>{const s=t.filter(t.keys(h),n=>t.get(h,[n,"userId"])!==y);a.startTransition(()=>x(n=>t.filter(n,m=>!t.includes(s,m))))},[h,y]);const v=c.length===(i==null?void 0:i.length),E=s=>{x(n=>t.includes(n,s)?t.filter(n,m=>m!==s):t.concat(n,s))},B=()=>{x(v?[]:t.map(i,"id"))},I=()=>{N({ids:t.uniq(c)},{onSuccess:()=>{l(),r.throwConfetti("CENTER_CENTER"),p(d)}})},A=s=>{if(s==="theme")return"Theme";const n=t.find(g,{key:s});return n?n==null?void 0:n.name:s},L=a.useMemo(()=>{const s=[{label:"Updated",top:"pt-2"},...t.orderBy(t.filter(w,{online:!0}),"pageType"),...t.orderBy(t.filter(S,{online:!0}),"pageType")].filter(m=>m.pageType!=="theme"&&m.pageType!=="design_tokens"),n=[{label:"Offline",top:"pt-6"},...t.orderBy(t.filter(w,{online:!1}),"pageType"),...t.orderBy(t.filter(S,{online:!1}),"pageType")];return[...s,...n]},[w,S]);return e.jsxs(f.DialogContent,{className:"flex max-h-[80%] max-w-4xl flex-col",children:[e.jsxs(f.DialogHeader,{children:[e.jsx(f.DialogTitle,{children:"Publish changes"}),e.jsx(f.DialogDescription,{className:"text-xs",children:"Select the pages you want to publish. Click publish when you're done."})]}),P.length>0&&e.jsx("div",{className:"my-[2px] mt-0",children:e.jsx(U.LanguageSelector,{languages:[d,...P],selectedLanguage:o,setSelectedLanguage:p})}),e.jsx("div",{className:"no-scrollbar relative -mx-4 -mt-4 h-full max-h-full overflow-y-auto",children:C?e.jsxs("div",{className:"space-y-2 px-1",children:[e.jsx("div",{className:"mt-2 h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"})]}):e.jsxs("table",{className:"w-full text-left text-xs text-gray-500 dark:text-gray-400 rtl:text-right",children:[e.jsx("thead",{className:"sticky top-0 z-10 border-b bg-gray-50 text-gray-700 dark:bg-gray-700 dark:text-gray-400",children:e.jsxs("tr",{children:[e.jsxs("th",{scope:"col",className:"w-[1 50px] flex items-center gap-x-2 px-6 py-3",children:[e.jsx("input",{checked:v,onClick:s=>{s.stopPropagation(),B()},type:"checkbox",className:"mt-1 cursor-pointer rounded focus:outline-none focus:ring-0"}),"Name"]}),e.jsx("th",{scope:"col",className:"w-[150px] px-2 py-3",children:"Type"}),e.jsx("th",{scope:"col",className:"w-[150px] px-4 py-3 text-right",children:"Status"})]})}),e.jsx("tbody",{children:t.map(L,s=>s.label?e.jsx("tr",{children:e.jsxs("td",{colSpan:3,className:`relative px-6 py-2 text-xs font-medium text-gray-800 ${s.top}`,children:[e.jsx("div",{className:"absolute inset-0 left-6 flex items-center",children:e.jsx("div",{className:"order-gray-300 w-full"})}),e.jsx("div",{className:"relative flex justify-start",children:e.jsx("span",{className:"bg-gray-50 pr-2",children:s.label})})]})},"separator"):e.jsx(G,{page:s,selectedPages:c,handleCheckboxChange:E,getPageType:A,hasSlug:k,currentOwnerId:t.get(h,[(s==null?void 0:s.primaryPage)||(s==null?void 0:s.id),"userId"])}))})]})}),e.jsxs(f.DialogFooter,{className:"mt-10 flex items-center justify-center",children:[c.length>0&&e.jsxs("span",{className:"text-center text-sm text-muted-foreground",children:[c.length," Page",c.length!==1?"s":""," Selected"]}),e.jsx(q.Button,{disabled:u,variant:"outline",onClick:l,children:"Cancel"}),e.jsx(q.Button,{disabled:u||C||t.isEmpty(c),onClick:I,children:u?"Publishing...":"Publish Selected"})]})]})};exports.default=O;
@@ -1,19 +1,19 @@
1
1
  import { jsxs as n, jsx as t, Fragment as $ } from "react/jsx-runtime";
2
2
  import { B as L } from "./register-chai-top-bar-D6GjnauV.js";
3
- import { e as K, f as Q, g as J, o as V, q as W } from "./index-B7HAfx-2.js";
4
- import { ao as X, ap as Y, A as I, ay as O, az as Z, i as ee, k as te, am as se, T as U, aA as le } from "./index-BYjniKhj.js";
5
- import { LanguageSelector as ae } from "./page-manager-search-and-filter-BU_iNmHy.js";
3
+ import { e as K, f as Q, g as J, o as V, q as W } from "./index-OuHV9Ann.js";
4
+ import { aq as X, ar as Y, A as I, aA as O, aB as Z, i as ee, k as te, ao as se, T as U, aC as le } from "./index-LBTm1Jmk.js";
5
+ import { LanguageSelector as ae } from "./page-manager-search-and-filter-bsqZ6wnI.js";
6
6
  import { useQuery as ne } from "@tanstack/react-query";
7
- import { find as F, filter as a, map as b, keys as re, get as G, includes as C, orderBy as N, isEmpty as oe, uniq as B, first as ce, concat as ie } from "lodash-es";
8
- import { Lock as de, GlobeIcon as ue, File as me, Edit as he } from "lucide-react";
9
- import { useState as D, useCallback as ge, useMemo as p, useEffect as j, startTransition as q } from "react";
7
+ import { find as B, filter as a, map as b, keys as re, get as F, includes as P, orderBy as N, isEmpty as oe, uniq as G, first as ce, concat as ie } from "lodash-es";
8
+ import { Lock as de, GlobeIcon as ue, File as he, Edit as me } from "lucide-react";
9
+ import { useState as q, useCallback as ge, useMemo as p, useEffect as D, startTransition as j } from "react";
10
10
  const pe = () => {
11
11
  const s = X(), d = Y();
12
12
  return ne({
13
13
  queryKey: [I.GET_CHANGES],
14
14
  queryFn: async () => d(s, { action: I.GET_CHANGES })
15
15
  });
16
- }, fe = ({ page: s, selectedPages: d, handleCheckboxChange: k, getPageType: f, hasSlug: m, currentOwnerId: r }) => {
16
+ }, fe = ({ page: s, selectedPages: d, handleCheckboxChange: k, getPageType: f, hasSlug: h, currentOwnerId: r }) => {
17
17
  const u = O(), { data: i } = se(r), o = r === u ? null : i == null ? void 0 : i.name;
18
18
  return /* @__PURE__ */ n("tr", { className: "group relative border-b last:border-b-0 hover:bg-gray-50", children: [
19
19
  /* @__PURE__ */ n(
@@ -25,7 +25,7 @@ const pe = () => {
25
25
  o ? /* @__PURE__ */ t(de, { className: "h-4 w-4 fill-red-200 text-red-500" }) : /* @__PURE__ */ t(
26
26
  "input",
27
27
  {
28
- checked: C(d, s == null ? void 0 : s.id),
28
+ checked: P(d, s == null ? void 0 : s.id),
29
29
  onClick: (x) => {
30
30
  x.stopPropagation(), k(s == null ? void 0 : s.id);
31
31
  },
@@ -34,7 +34,7 @@ const pe = () => {
34
34
  }
35
35
  ),
36
36
  " ",
37
- m(s.pageType) ? /* @__PURE__ */ t(me, { className: "h-4 w-4" }) : /* @__PURE__ */ t(ue, { className: "h-4 w-4" }),
37
+ h(s.pageType) ? /* @__PURE__ */ t(he, { className: "h-4 w-4" }) : /* @__PURE__ */ t(ue, { className: "h-4 w-4" }),
38
38
  /* @__PURE__ */ t(U, { content: s.name, side: "top", showTooltip: s.name.length > 25, children: /* @__PURE__ */ t("span", { className: "max-w-[200px] truncate font-medium text-black", children: s.name }) }),
39
39
  s.slug && /* @__PURE__ */ t(U, { content: s.slug, side: "top", showTooltip: s.slug.length > 25, children: /* @__PURE__ */ t("span", { className: "max-w-[200px] truncate font-mono text-xs text-muted-foreground", children: s.slug }) })
40
40
  ]
@@ -43,7 +43,7 @@ const pe = () => {
43
43
  /* @__PURE__ */ t("td", { className: "px-2", children: f(s == null ? void 0 : s.pageType) }),
44
44
  /* @__PURE__ */ t("td", { className: "px-4 text-right", children: ce(s.changes) || "" }),
45
45
  /* @__PURE__ */ t($, { children: o && /* @__PURE__ */ n("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: [
46
- /* @__PURE__ */ t(he, { size: 12, className: "stroke-[3]" }),
46
+ /* @__PURE__ */ t(me, { size: 12, className: "stroke-[3]" }),
47
47
  " ",
48
48
  /* @__PURE__ */ t("span", { className: "font-medium", children: o }),
49
49
  " is editing this page"
@@ -55,36 +55,36 @@ const pe = () => {
55
55
  isPending: d,
56
56
  publishPage: k
57
57
  }) => {
58
- const f = O(), { pageToUser: m } = Z(), [r, u] = D([]), i = ee(), [o, x] = D(i), { data: T, isFetching: v } = pe(), { data: g } = te(), w = ge((e) => {
58
+ const f = O(), { pageToUser: h } = Z(), [r, u] = q([]), i = ee(), [o, x] = q(i), { data: T, isFetching: v } = pe(), { data: g } = te(), w = ge((e) => {
59
59
  var l;
60
- return (l = F(g, { key: e })) == null ? void 0 : l.hasSlug;
60
+ return (l = B(g, { key: e })) == null ? void 0 : l.hasSlug;
61
61
  }, [g]), y = p(
62
62
  () => a(g, (e) => !w(e.key)).map((e) => e.key),
63
63
  [w, g]
64
- ), E = B(b(T, "lang")).filter(Boolean), c = p(
64
+ ), E = G(b(T, "lang")).filter(Boolean), c = p(
65
65
  () => a(T, (e) => e.pageType === "theme" || e.pageType === "design_tokens" ? !1 : o === i ? e.lang === o || e.lang === "" : e.lang === o),
66
66
  [T, o, i]
67
67
  ), S = p(
68
68
  () => a(c, (e) => !y.includes(e.pageType)),
69
69
  [c, y]
70
- ), P = p(
70
+ ), C = p(
71
71
  () => a(c, (e) => y.includes(e.pageType)),
72
72
  [c, y]
73
73
  );
74
- j(() => {
74
+ D(() => {
75
75
  const e = b(a(c, { online: !0 }), "id");
76
- q(() => u(e));
77
- }, [c]), j(() => {
78
- const e = a(re(m), (l) => G(m, [l, "userId"]) !== f);
79
- q(() => u((l) => a(l, (h) => !C(e, h))));
80
- }, [m, f]);
76
+ j(() => u(e));
77
+ }, [c]), D(() => {
78
+ const e = a(re(h), (l) => F(h, [l, "userId"]) !== f);
79
+ j(() => u((l) => a(l, (m) => !P(e, m))));
80
+ }, [h, f]);
81
81
  const A = r.length === (c == null ? void 0 : c.length), _ = (e) => {
82
- u((l) => C(l, e) ? a(l, (h) => h !== e) : ie(l, e));
83
- }, z = () => {
84
- u(A ? [] : b(c, "id"));
82
+ u((l) => P(l, e) ? a(l, (m) => m !== e) : ie(l, e));
85
83
  }, H = () => {
84
+ u(A ? [] : b(c, "id"));
85
+ }, z = () => {
86
86
  k(
87
- { ids: B(r) },
87
+ { ids: G(r) },
88
88
  {
89
89
  onSuccess: () => {
90
90
  s(), le("CENTER_CENTER"), x(i);
@@ -93,20 +93,20 @@ const pe = () => {
93
93
  );
94
94
  }, M = (e) => {
95
95
  if (e === "theme") return "Theme";
96
- const l = F(g, { key: e });
96
+ const l = B(g, { key: e });
97
97
  return l ? l == null ? void 0 : l.name : e;
98
98
  }, R = p(() => {
99
99
  const e = [
100
100
  { label: "Updated", top: "pt-2" },
101
101
  ...N(a(S, { online: !0 }), "pageType"),
102
- ...N(a(P, { online: !0 }), "pageType")
103
- ].filter((h) => h.pageType !== "theme" && h.pageType !== "design_tokens"), l = [
102
+ ...N(a(C, { online: !0 }), "pageType")
103
+ ].filter((m) => m.pageType !== "theme" && m.pageType !== "design_tokens"), l = [
104
104
  { label: "Offline", top: "pt-6" },
105
105
  ...N(a(S, { online: !1 }), "pageType"),
106
- ...N(a(P, { online: !1 }), "pageType")
106
+ ...N(a(C, { online: !1 }), "pageType")
107
107
  ];
108
108
  return [...e, ...l];
109
- }, [S, P]);
109
+ }, [S, C]);
110
110
  return /* @__PURE__ */ n(K, { className: "flex max-h-[80%] max-w-4xl flex-col", children: [
111
111
  /* @__PURE__ */ n(Q, { children: [
112
112
  /* @__PURE__ */ t(J, { children: "Publish changes" }),
@@ -133,7 +133,7 @@ const pe = () => {
133
133
  {
134
134
  checked: A,
135
135
  onClick: (e) => {
136
- e.stopPropagation(), z();
136
+ e.stopPropagation(), H();
137
137
  },
138
138
  type: "checkbox",
139
139
  className: "mt-1 cursor-pointer rounded focus:outline-none focus:ring-0"
@@ -157,7 +157,7 @@ const pe = () => {
157
157
  handleCheckboxChange: _,
158
158
  getPageType: M,
159
159
  hasSlug: w,
160
- currentOwnerId: G(m, [(e == null ? void 0 : e.primaryPage) || (e == null ? void 0 : e.id), "userId"])
160
+ currentOwnerId: F(h, [(e == null ? void 0 : e.primaryPage) || (e == null ? void 0 : e.id), "userId"])
161
161
  }
162
162
  )
163
163
  ) })
@@ -170,7 +170,7 @@ const pe = () => {
170
170
  " Selected"
171
171
  ] }),
172
172
  /* @__PURE__ */ t(L, { disabled: d, variant: "outline", onClick: s, children: "Cancel" }),
173
- /* @__PURE__ */ t(L, { disabled: d || v || oe(r), onClick: H, children: d ? "Publishing..." : "Publish Selected" })
173
+ /* @__PURE__ */ t(L, { disabled: d || v || oe(r), onClick: z, children: d ? "Publishing..." : "Publish Selected" })
174
174
  ] })
175
175
  ] });
176
176
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-DTNHTRZu.cjs"),p=require("./register-chai-top-bar-DyW9GPzV.cjs"),S=({isOpen:m,onClose:r,editor:t,rteElement:f})=>{const a=s.usePageExternalData(),u=o=>{if(!t)return;const i=`{{${o}}}`;t.commands.focus();const{from:j,to:g}=t.state.selection;if(j!==g)t.chain().deleteSelection().insertContent(i).run();else{const{state:c}=t,n=c.selection.from,x=c.doc.textBetween(Math.max(0,n-1),n),l=c.doc.textBetween(n,Math.min(n+1,c.doc.content.size));let d="";n>0&&x!==" "&&!/[.,!?;:]/.test(x)&&(d=" ");let h="";l&&l!==" "&&!/[.,!?;:]/.test(l)&&(h=" "),t.chain().insertContent(d+i+h).run()}};return e.jsx(s.Dialog,{open:m,onOpenChange:o=>!o&&r(),children:e.jsxs(s.DialogContent,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[800px]",children:[e.jsx(s.DialogHeader,{children:e.jsxs(s.DialogTitle,{className:"flex items-center justify-between pr-8",children:[e.jsx("span",{children:"Rich Text Editor"}),a&&Object.keys(a).length>0&&e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{className:"mr-2 text-sm text-muted-foreground",children:"Add field:"}),e.jsx("div",{className:"rte-path-selector",children:e.jsx(s.NestedPathSelector,{data:a,onSelect:u})})]})]})}),f,e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(p.Button,{onClick:r,children:"Done"})})]})})};exports.default=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-DCJDQs1a.cjs"),p=require("./register-chai-top-bar-DyW9GPzV.cjs"),S=({isOpen:m,onClose:r,editor:t,rteElement:f})=>{const a=s.usePageExternalData(),u=o=>{if(!t)return;const i=`{{${o}}}`;t.commands.focus();const{from:j,to:g}=t.state.selection;if(j!==g)t.chain().deleteSelection().insertContent(i).run();else{const{state:c}=t,n=c.selection.from,x=c.doc.textBetween(Math.max(0,n-1),n),l=c.doc.textBetween(n,Math.min(n+1,c.doc.content.size));let d="";n>0&&x!==" "&&!/[.,!?;:]/.test(x)&&(d=" ");let h="";l&&l!==" "&&!/[.,!?;:]/.test(l)&&(h=" "),t.chain().insertContent(d+i+h).run()}};return e.jsx(s.Dialog,{open:m,onOpenChange:o=>!o&&r(),children:e.jsxs(s.DialogContent,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[800px]",children:[e.jsx(s.DialogHeader,{children:e.jsxs(s.DialogTitle,{className:"flex items-center justify-between pr-8",children:[e.jsx("span",{children:"Rich Text Editor"}),a&&Object.keys(a).length>0&&e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{className:"mr-2 text-sm text-muted-foreground",children:"Add field:"}),e.jsx("div",{className:"rte-path-selector",children:e.jsx(s.NestedPathSelector,{data:a,onSelect:u})})]})]})}),f,e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(p.Button,{onClick:r,children:"Done"})})]})})};exports.default=S;
@@ -1,5 +1,5 @@
1
1
  import { jsx as e, jsxs as l } from "react/jsx-runtime";
2
- import { h as D, D as N, e as S, f as j, g as v, N as w } from "./index-B7HAfx-2.js";
2
+ import { h as D, D as N, e as S, f as j, g as v, N as w } from "./index-OuHV9Ann.js";
3
3
  import { B } from "./register-chai-top-bar-D6GjnauV.js";
4
4
  const M = ({
5
5
  isOpen: f,
@@ -1,7 +1,7 @@
1
- import { jsx as e, jsxs as o } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as i } from "react/jsx-runtime";
2
2
  import { B as b, z as L } from "./register-chai-top-bar-D6GjnauV.js";
3
- import { aF as ne, c as M, X as oe, Y as ie, P as le, aG as ce, ax as de, aH as ue, p as P } from "./index-B7HAfx-2.js";
4
- import { ao as D, ap as G, A as _, av as me } from "./index-BYjniKhj.js";
3
+ import { aF as ne, c as M, X as ie, Y as oe, P as le, aG as ce, ax as de, aH as ue, p as P } from "./index-OuHV9Ann.js";
4
+ import { aq as D, ar as G, A as _, ax as me } from "./index-LBTm1Jmk.js";
5
5
  import { useQuery as K, useMutation as A, useQueryClient as pe } from "@tanstack/react-query";
6
6
  import { useSetAtom as fe } from "jotai";
7
7
  import { toast as N } from "sonner";
@@ -10,9 +10,9 @@ import { useState as h, useRef as V, useMemo as S, useEffect as w, useCallback a
10
10
  import { c as ve } from "./image-compression-DPFITwOL.js";
11
11
  import { isEmpty as Ne, set as Be, has as Ce } from "lodash-es";
12
12
  const Ie = (r) => {
13
- const a = D(), i = G();
13
+ const a = D(), o = G();
14
14
  return A({
15
- mutationFn: async (t) => i(a, {
15
+ mutationFn: async (t) => o(a, {
16
16
  action: _.UPSERT_LIBRARY_ITEM,
17
17
  data: t
18
18
  }),
@@ -26,7 +26,7 @@ const Ie = (r) => {
26
26
  }
27
27
  });
28
28
  }, we = (r) => {
29
- const a = D(), i = G();
29
+ const a = D(), o = G();
30
30
  return K({
31
31
  staleTime: "static",
32
32
  queryKey: [_.GET_LIBRARY_ITEM, r],
@@ -35,7 +35,7 @@ const Ie = (r) => {
35
35
  queryFn: async () => {
36
36
  if (!r) return null;
37
37
  try {
38
- return await i(a, {
38
+ return await o(a, {
39
39
  action: _.GET_LIBRARY_ITEM,
40
40
  data: { id: r }
41
41
  });
@@ -46,9 +46,9 @@ const Ie = (r) => {
46
46
  retry: !1
47
47
  });
48
48
  }, Ee = (r) => {
49
- const a = D(), i = G(), t = fe(ne);
49
+ const a = D(), o = G(), t = fe(ne);
50
50
  return A({
51
- mutationFn: async (l) => i(a, {
51
+ mutationFn: async (l) => o(a, {
52
52
  action: _.DELETE_LIBRARY_ITEM,
53
53
  data: { id: l }
54
54
  }),
@@ -69,7 +69,7 @@ const Ie = (r) => {
69
69
  }, xe = ({
70
70
  blockId: r,
71
71
  libBlockId: a,
72
- isOpen: i,
72
+ isOpen: o,
73
73
  onClose: t,
74
74
  blockName: l,
75
75
  trigger: m
@@ -77,8 +77,8 @@ const Ie = (r) => {
77
77
  const [u, c] = h(!1), d = M(), y = Ee(() => {
78
78
  d([r], { _libBlockId: void 0 }), N.success("Block deleted successfully"), c(!1), t();
79
79
  });
80
- return /* @__PURE__ */ o(oe, { open: i, onOpenChange: (p) => !p && t(), children: [
81
- /* @__PURE__ */ e(ie, { asChild: !0, children: m || /* @__PURE__ */ o(b, { type: "button", variant: "destructive", size: "sm", onClick: (p) => p.preventDefault(), disabled: u, children: [
80
+ return /* @__PURE__ */ i(ie, { open: o, onOpenChange: (p) => !p && t(), children: [
81
+ /* @__PURE__ */ e(oe, { asChild: !0, children: m || /* @__PURE__ */ i(b, { type: "button", variant: "destructive", size: "sm", onClick: (p) => p.preventDefault(), disabled: u, children: [
82
82
  /* @__PURE__ */ e(Y, { className: "mr-2 h-4 w-4" }),
83
83
  "Delete"
84
84
  ] }) }),
@@ -88,11 +88,11 @@ const Ie = (r) => {
88
88
  className: "z-[9999] w-72 p-4",
89
89
  sideOffset: 5,
90
90
  align: "center",
91
- children: /* @__PURE__ */ o("div", { className: "space-y-3", children: [
91
+ children: /* @__PURE__ */ i("div", { className: "space-y-3", children: [
92
92
  /* @__PURE__ */ e("h4", { className: "font-medium", children: "Delete Block" }),
93
- /* @__PURE__ */ o("p", { className: "text-sm", children: [
93
+ /* @__PURE__ */ i("p", { className: "text-sm", children: [
94
94
  "Are you sure you want to delete the block",
95
- /* @__PURE__ */ o("span", { className: "font-medium", children: [
95
+ /* @__PURE__ */ i("span", { className: "font-medium", children: [
96
96
  ' "',
97
97
  l,
98
98
  '"'
@@ -100,7 +100,7 @@ const Ie = (r) => {
100
100
  "?"
101
101
  ] }),
102
102
  /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: "This block will be permanently removed from the library. This action cannot be undone." }),
103
- /* @__PURE__ */ o("div", { className: "flex justify-end gap-2 pt-2", children: [
103
+ /* @__PURE__ */ i("div", { className: "flex justify-end gap-2 pt-2", children: [
104
104
  /* @__PURE__ */ e(b, { type: "button", variant: "outline", size: "sm", onClick: t, disabled: u, children: "Cancel" }),
105
105
  /* @__PURE__ */ e(b, { type: "button", variant: "destructive", size: "sm", onClick: () => {
106
106
  c(!0), y.mutate(a);
@@ -113,7 +113,7 @@ const Ie = (r) => {
113
113
  }, Pe = ({
114
114
  blockId: r,
115
115
  libBlockId: a,
116
- blockName: i,
116
+ blockName: o,
117
117
  size: t = "sm",
118
118
  className: l = "",
119
119
  close: m
@@ -128,8 +128,8 @@ const Ie = (r) => {
128
128
  onClose: () => {
129
129
  c(!1), m();
130
130
  },
131
- blockName: i,
132
- trigger: /* @__PURE__ */ o(
131
+ blockName: o,
132
+ trigger: /* @__PURE__ */ i(
133
133
  b,
134
134
  {
135
135
  type: "button",
@@ -146,7 +146,7 @@ const Ie = (r) => {
146
146
  }
147
147
  );
148
148
  }, Le = () => {
149
- const r = D(), a = G(), i = pe(), {
149
+ const r = D(), a = G(), o = pe(), {
150
150
  data: t = [],
151
151
  isLoading: l,
152
152
  error: m
@@ -173,7 +173,7 @@ const Ie = (r) => {
173
173
  });
174
174
  },
175
175
  onSuccess: () => {
176
- i.invalidateQueries({
176
+ o.invalidateQueries({
177
177
  queryKey: ["library-groups"]
178
178
  }), N.success("Group created successfully");
179
179
  },
@@ -191,7 +191,7 @@ const Ie = (r) => {
191
191
  isCreating: c
192
192
  };
193
193
  }, _e = ({ value: r, onChange: a }) => {
194
- const [i, t] = h(!1), [l, m] = h(""), u = V(null), { groups: c } = Le(), [d, y] = h([
194
+ const [o, t] = h(!1), [l, m] = h(""), u = V(null), { groups: c } = Le(), [d, y] = h([
195
195
  { id: "hero", name: "Hero" },
196
196
  { id: "feature", name: "Feature" },
197
197
  { id: "footer", name: "Footer" },
@@ -232,14 +232,14 @@ const Ie = (r) => {
232
232
  y((E) => [...E, B]), a(B.id), m(""), t(!1);
233
233
  };
234
234
  w(() => {
235
- i && u.current && u.current.focus();
236
- }, [i]);
235
+ o && u.current && u.current.focus();
236
+ }, [o]);
237
237
  const p = (s) => {
238
238
  s.key === "Enter" && (s.preventDefault(), g());
239
239
  };
240
240
  return w(() => {
241
241
  r && !f.some((s) => s.id === r) && a("");
242
- }, [r, f, a]), i ? /* @__PURE__ */ o("div", { className: "space-y-2", children: [
242
+ }, [r, f, a]), o ? /* @__PURE__ */ i("div", { className: "space-y-2", children: [
243
243
  /* @__PURE__ */ e(
244
244
  L,
245
245
  {
@@ -250,12 +250,12 @@ const Ie = (r) => {
250
250
  onKeyDown: p
251
251
  }
252
252
  ),
253
- /* @__PURE__ */ o("div", { className: "flex justify-end gap-2", children: [
253
+ /* @__PURE__ */ i("div", { className: "flex justify-end gap-2", children: [
254
254
  /* @__PURE__ */ e(b, { variant: "outline", size: "sm", onClick: () => t(!1), children: "Cancel" }),
255
255
  /* @__PURE__ */ e(b, { size: "sm", onClick: g, children: "Create" })
256
256
  ] })
257
- ] }) : /* @__PURE__ */ o("div", { className: "flex gap-2", children: [
258
- /* @__PURE__ */ o(
257
+ ] }) : /* @__PURE__ */ i("div", { className: "flex gap-2", children: [
258
+ /* @__PURE__ */ i(
259
259
  "select",
260
260
  {
261
261
  className: "w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
@@ -271,7 +271,7 @@ const Ie = (r) => {
271
271
  /* @__PURE__ */ e(b, { type: "button", size: "icon", variant: "outline", onClick: () => t(!0), children: /* @__PURE__ */ e(he, { className: "h-4 w-4" }) })
272
272
  ] });
273
273
  }, De = ({ value: r, onChange: a }) => {
274
- const [i, t] = h(!1), l = V(null), m = ke(
274
+ const [o, t] = h(!1), l = V(null), m = ke(
275
275
  async (d) => {
276
276
  var f;
277
277
  const y = (f = d.target.files) == null ? void 0 : f[0];
@@ -292,16 +292,16 @@ const Ie = (r) => {
292
292
  },
293
293
  [a]
294
294
  );
295
- return /* @__PURE__ */ o("div", { className: "space-y-2", children: [
296
- /* @__PURE__ */ o("div", { className: "flex items-center gap-2", children: [
295
+ return /* @__PURE__ */ i("div", { className: "space-y-2", children: [
296
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
297
297
  /* @__PURE__ */ e(L, { type: "file", ref: l, onChange: m, accept: "image/*", className: "hidden" }),
298
298
  /* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick: () => {
299
299
  var d;
300
300
  (d = l.current) == null || d.click();
301
- }, disabled: i, className: "w-full", children: i ? /* @__PURE__ */ o("span", { className: "flex items-center gap-2", children: [
301
+ }, disabled: o, className: "w-full", children: o ? /* @__PURE__ */ i("span", { className: "flex items-center gap-2", children: [
302
302
  /* @__PURE__ */ e("div", { className: "h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }),
303
303
  "Uploading..."
304
- ] }) : /* @__PURE__ */ o("span", { className: "flex items-center gap-2", children: [
304
+ ] }) : /* @__PURE__ */ i("span", { className: "flex items-center gap-2", children: [
305
305
  /* @__PURE__ */ e(ge, { className: "h-4 w-4" }),
306
306
  "Select image"
307
307
  ] }) }),
@@ -312,7 +312,7 @@ const Ie = (r) => {
312
312
  r && /* @__PURE__ */ e("div", { className: "aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border", children: /* @__PURE__ */ e("img", { src: r, alt: "Preview", className: "h-full w-full object-contain" }) })
313
313
  ] });
314
314
  }, Me = (r) => {
315
- const { blocks: a, close: i, blockId: t } = r, { getPartialBlocks: l } = ce(), m = a.find((n) => n._id === t), u = m == null ? void 0 : m._libBlockId, c = !!u, d = S(() => a.some((n) => n._type === "PartialBlock" || n._type === "GlobalBlock"), [a]), y = S(() => {
315
+ const { blocks: a, close: o, blockId: t } = r, { getPartialBlocks: l } = ce(), m = a.find((n) => n._id === t), u = m == null ? void 0 : m._libBlockId, c = !!u, d = S(() => a.some((n) => n._type === "PartialBlock" || n._type === "GlobalBlock"), [a]), y = S(() => {
316
316
  let n = [];
317
317
  for (const k of a)
318
318
  if (k._type === "PartialBlock" || k._type === "GlobalBlock") {
@@ -322,7 +322,7 @@ const Ie = (r) => {
322
322
  n.push(k);
323
323
  return n;
324
324
  }, [a, l]), [f, g] = h(""), [p, s] = h(""), [B, E] = h(""), [x, U] = h(""), [C, W] = h({}), [Q, $] = h(!1), [H, q] = h(c), [X, J] = h(!1), { hasPermission: Z } = de(), ee = Z(me.DELETE_LIBRARY_BLOCK), O = M(), te = () => {
325
- O([t], { _libBlockId: void 0 }), N.success("Block delinked from library"), i();
325
+ O([t], { _libBlockId: void 0 }), N.success("Block delinked from library"), o();
326
326
  }, {
327
327
  data: I,
328
328
  isLoading: F,
@@ -340,7 +340,7 @@ const Ie = (r) => {
340
340
  const n = {};
341
341
  return f.trim() ? f.length < 2 && (n.name = "Name must be at least 2 characters") : n.name = "Name is required", p || (n.group = "Group is required"), W(n), Object.keys(n).length === 0;
342
342
  }, { resetLibrary: ae } = ue({ id: "" }), z = Ie((n) => {
343
- c || O([t], { _libBlockId: n.id }), N.success(`Block ${c ? "updated" : "saved"} successfully`), ae(n.library), i();
343
+ c || O([t], { _libBlockId: n.id }), N.success(`Block ${c ? "updated" : "saved"} successfully`), ae(n.library), o();
344
344
  }), se = async (n) => {
345
345
  if (n.preventDefault(), !re()) return;
346
346
  const k = y.map((v) => (Ce(v, "_libBlockId") && delete v._libBlockId, v));
@@ -355,23 +355,23 @@ const Ie = (r) => {
355
355
  ...c ? { id: u } : {}
356
356
  });
357
357
  }, T = z.isPending;
358
- return H || F ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-8", children: /* @__PURE__ */ e("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" }) }) : X ? /* @__PURE__ */ o("div", { className: "space-y-4 p-6", children: [
358
+ return H || F ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-8", children: /* @__PURE__ */ e("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" }) }) : X ? /* @__PURE__ */ i("div", { className: "space-y-4 p-6", children: [
359
359
  /* @__PURE__ */ e("div", { className: "font-medium text-destructive", children: "Block Not Found" }),
360
360
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "This block could not be found on the server. It may have been deleted." }),
361
- /* @__PURE__ */ o("div", { className: "flex justify-end gap-2 pt-4", children: [
362
- /* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick: i, children: "Cancel" }),
361
+ /* @__PURE__ */ i("div", { className: "flex justify-end gap-2 pt-4", children: [
362
+ /* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick: o, children: "Cancel" }),
363
363
  /* @__PURE__ */ e(b, { onClick: te, variant: "destructive", children: "Delink Block" })
364
364
  ] })
365
- ] }) : /* @__PURE__ */ o("div", { children: [
366
- d && /* @__PURE__ */ o("div", { className: "mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive", children: [
365
+ ] }) : /* @__PURE__ */ i("div", { children: [
366
+ d && /* @__PURE__ */ i("div", { className: "mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive", children: [
367
367
  /* @__PURE__ */ e(ye, { className: "mt-0.5 h-5 w-5 flex-shrink-0" }),
368
- /* @__PURE__ */ o("div", { children: [
368
+ /* @__PURE__ */ i("div", { children: [
369
369
  /* @__PURE__ */ e("p", { className: "font-medium", children: "Partial Blocks Detected" }),
370
370
  /* @__PURE__ */ e("p", { className: "mt-1 text-xs", children: "This block contains one or more Partial Blocks. Partial blocks will be merged into the library block" })
371
371
  ] })
372
372
  ] }),
373
- /* @__PURE__ */ o("form", { onSubmit: se, className: "space-y-4", children: [
374
- /* @__PURE__ */ o("div", { className: "space-y-2", children: [
373
+ /* @__PURE__ */ i("form", { onSubmit: se, className: "space-y-4", children: [
374
+ /* @__PURE__ */ i("div", { className: "space-y-2", children: [
375
375
  /* @__PURE__ */ e(P, { htmlFor: "name", className: C.name ? "text-destructive" : "", children: "Name" }),
376
376
  /* @__PURE__ */ e(
377
377
  L,
@@ -385,12 +385,12 @@ const Ie = (r) => {
385
385
  ),
386
386
  C.name && /* @__PURE__ */ e("p", { className: "text-xs text-destructive", children: C.name })
387
387
  ] }),
388
- /* @__PURE__ */ o("div", { className: "space-y-2", children: [
388
+ /* @__PURE__ */ i("div", { className: "space-y-2", children: [
389
389
  /* @__PURE__ */ e(P, { htmlFor: "group", className: C.group ? "text-destructive" : "", children: "Group" }),
390
390
  /* @__PURE__ */ e(_e, { value: p, onChange: s }),
391
391
  C.group && /* @__PURE__ */ e("p", { className: "text-xs text-destructive", children: C.group })
392
392
  ] }),
393
- /* @__PURE__ */ o("div", { className: "space-y-2", children: [
393
+ /* @__PURE__ */ i("div", { className: "space-y-2", children: [
394
394
  /* @__PURE__ */ e(P, { htmlFor: "description", children: "Description (optional)" }),
395
395
  /* @__PURE__ */ e(
396
396
  L,
@@ -403,11 +403,11 @@ const Ie = (r) => {
403
403
  }
404
404
  )
405
405
  ] }),
406
- /* @__PURE__ */ o("div", { className: "space-y-2", children: [
406
+ /* @__PURE__ */ i("div", { className: "space-y-2", children: [
407
407
  /* @__PURE__ */ e(P, { htmlFor: "previewImage", children: "Preview Image (optional)" }),
408
408
  /* @__PURE__ */ e(De, { value: x, onChange: U })
409
409
  ] }),
410
- /* @__PURE__ */ o("div", { className: "flex justify-end gap-2 pt-2", children: [
410
+ /* @__PURE__ */ i("div", { className: "flex justify-end gap-2 pt-2", children: [
411
411
  c && ee && /* @__PURE__ */ e(
412
412
  Pe,
413
413
  {
@@ -415,10 +415,10 @@ const Ie = (r) => {
415
415
  libBlockId: u,
416
416
  blockName: f,
417
417
  className: "mr-auto",
418
- close: i
418
+ close: o
419
419
  }
420
420
  ),
421
- /* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick: i, disabled: T, children: "Cancel" }),
421
+ /* @__PURE__ */ e(b, { type: "button", variant: "outline", onClick: o, disabled: T, children: "Cancel" }),
422
422
  /* @__PURE__ */ e(b, { type: "submit", disabled: T || !Q, children: T ? "Saving..." : c ? "Update Block" : "Save Block" })
423
423
  ] })
424
424
  ] })
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./register-chai-top-bar-DyW9GPzV.cjs"),x=require("./index-DTNHTRZu.cjs"),b=require("./index-BeGLwvqs.cjs"),C=require("@tanstack/react-query"),X=require("jotai"),j=require("sonner"),E=require("lucide-react"),i=require("react"),J=require("./image-compression-UaU7Bwqe.cjs"),R=require("lodash-es"),Z=s=>{const r=b.useApiUrl(),l=b.useFetch();return C.useMutation({mutationFn:async t=>l(r,{action:b.ACTIONS.UPSERT_LIBRARY_ITEM,data:t}),onSuccess:t=>{s?s(t):j.toast.success("Block saved successfully")},onError:t=>{console.error("Error saving block:",t),j.toast.error("Failed to save block",{description:t instanceof Error?t.message:"Unknown error"})}})},ee=s=>{const r=b.useApiUrl(),l=b.useFetch();return C.useQuery({staleTime:"static",queryKey:[b.ACTIONS.GET_LIBRARY_ITEM,s],enabled:!!s,queryFn:async()=>{if(!s)return null;try{return await l(r,{action:b.ACTIONS.GET_LIBRARY_ITEM,data:{id:s}})}catch(t){throw console.error(t),new Error("The block could not be found on the server. It may have been deleted.")}},retry:!1})},te=s=>{const r=b.useApiUrl(),l=b.useFetch(),t=X.useSetAtom(x.libraryBlocksAtom);return C.useMutation({mutationFn:async c=>l(r,{action:b.ACTIONS.DELETE_LIBRARY_ITEM,data:{id:c}}),onSuccess:()=>{t(c=>{const m={...c};return Object.keys(m).forEach(u=>{m[u]={loading:"idle",blocks:[],error:!1}}),m}),s?s():j.toast.success("Block deleted successfully")},onError:c=>{console.error("Error deleting block:",c),j.toast.error("Failed to delete block",{description:c instanceof Error?c.message:"Unknown error"})}})},se=({blockId:s,libBlockId:r,isOpen:l,onClose:t,blockName:c,trigger:m})=>{const[u,o]=i.useState(!1),d=x.useUpdateBlocksPropsRealtime(),y=te(()=>{d([s],{_libBlockId:void 0}),j.toast.success("Block deleted successfully"),o(!1),t()}),h=()=>{o(!0),y.mutate(r)},g=e.jsxs(p.Button,{type:"button",variant:"destructive",size:"sm",onClick:f=>f.preventDefault(),disabled:u,children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]});return e.jsxs(x.Popover,{open:l,onOpenChange:f=>!f&&t(),children:[e.jsx(x.PopoverTrigger,{asChild:!0,children:m||g}),e.jsx(x.PopoverContent,{className:"z-[9999] w-72 p-4",sideOffset:5,align:"center",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-medium",children:"Delete Block"}),e.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete the block",e.jsxs("span",{className:"font-medium",children:[' "',c,'"']}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This block will be permanently removed from the library. This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(p.Button,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:u,children:"Cancel"}),e.jsx(p.Button,{type:"button",variant:"destructive",size:"sm",onClick:h,disabled:u,children:u?"Deleting...":"Delete"})]})]})})]})},re=({blockId:s,libBlockId:r,blockName:l,size:t="sm",className:c="",close:m})=>{const[u,o]=i.useState(!1);return e.jsx(se,{blockId:s,libBlockId:r,isOpen:u,onClose:()=>{o(!1),m()},blockName:l,trigger:e.jsxs(p.Button,{type:"button",variant:"destructive",size:t,className:c,onClick:()=>o(!0),children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})})},ne=()=>{const s=b.useApiUrl(),r=b.useFetch(),l=C.useQueryClient(),{data:t=[],isLoading:c,error:m}=C.useQuery({queryKey:["library-groups"],staleTime:"static",placeholderData:[],queryFn:async()=>{try{return await r(s,{action:"GET_LIBRARY_GROUPS"})||[]}catch(d){return console.error("Error fetching library groups:",d),[]}}}),{mutateAsync:u,isPending:o}=C.useMutation({mutationFn:async d=>{if(!d.trim())throw new Error("Group name is required");return r(s,{action:"CREATE_BLOCK_GROUP",data:{name:d}})},onSuccess:()=>{l.invalidateQueries({queryKey:["library-groups"]}),j.toast.success("Group created successfully")},onError:d=>{console.error("Error creating group:",d),j.toast.error("Failed to create group",{description:d instanceof Error?d.message:"Unknown error"})}});return{groups:t,isLoading:c,error:m,createGroup:u,isCreating:o}},ae=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),[c,m]=i.useState(""),u=i.useRef(null),{groups:o}=ne(),[d,y]=i.useState([{id:"hero",name:"Hero"},{id:"feature",name:"Feature"},{id:"footer",name:"Footer"},{id:"content",name:"Content"},{id:"testimonial",name:"Testimonial"},{id:"pricing",name:"Pricing"},{id:"login",name:"Login"},{id:"logos",name:"Logos"},{id:"about",name:"About"},{id:"banner",name:"Banner"},{id:"blog",name:"Blog"},{id:"careers",name:"Careers"},{id:"casestudy",name:"Casestudy"},{id:"changelog",name:"Changelog"},{id:"compare",name:"Compare"},{id:"contact",name:"Contact"},{id:"cta",name:"Cta"},{id:"faq",name:"Faq"},{id:"gallery",name:"Gallery"},{id:"integration",name:"Integration"},{id:"list",name:"List"},{id:"navbar",name:"Navbar"},{id:"product",name:"Product"},{id:"signup",name:"Signup"},{id:"stats",name:"Stats"},{id:"team",name:"Team"},{id:"timeline",name:"Timeline"}]),h=i.useMemo(()=>[...o,...d.filter(n=>!o.some(B=>B.id===n.id))],[o,d]),g=()=>{const n=c.trim();if(!n)return;const B={id:n,name:n};y(w=>[...w,B]),r(B.id),m(""),t(!1)};i.useEffect(()=>{l&&u.current&&u.current.focus()},[l]);const f=n=>{n.key==="Enter"&&(n.preventDefault(),g())};return i.useEffect(()=>{s&&!h.some(n=>n.id===s)&&r("")},[s,h,r]),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(p.Input,{ref:u,placeholder:"Enter new group name",value:c,onChange:n=>m(n.target.value),onKeyDown:f}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(p.Button,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(p.Button,{size:"sm",onClick:g,children:"Create"})]})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",value:s,onChange:n=>r(n.target.value),children:[e.jsx("option",{value:"",children:"Select a group"}),o.length>0&&e.jsx("optgroup",{label:"Library Groups",children:o.map(n=>e.jsx("option",{value:n.id,children:n.name},`lib-${n.id}`))}),d.length>0&&e.jsx("optgroup",{label:"Predefined Groups",children:d.filter(n=>!o.some(B=>B.id===n.id)).map(n=>e.jsx("option",{value:n.id,children:n.name},`local-${n.id}`))})]}),e.jsx(p.Button,{type:"button",size:"icon",variant:"outline",onClick:()=>t(!0),children:e.jsx(E.Plus,{className:"h-4 w-4"})})]})},oe=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),c=i.useRef(null),m=i.useCallback(async d=>{var h;const y=(h=d.target.files)==null?void 0:h[0];if(y)try{t(!0);let g=y;y.type.startsWith("image/")&&(g=await J.compressImageIfNeeded(y));const f=new FileReader;f.onloadend=()=>{r(f.result),t(!1)},f.readAsDataURL(g)}catch(g){console.error("Error reading file:",g),t(!1),j.toast.error("Failed to process image",{description:g instanceof Error?g.message:"Unknown error"})}},[r]),u=()=>{r(""),c.current&&(c.current.value="")},o=()=>{var d;(d=c.current)==null||d.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p.Input,{type:"file",ref:c,onChange:m,accept:"image/*",className:"hidden"}),e.jsx(p.Button,{type:"button",variant:"outline",onClick:o,disabled:l,className:"w-full",children:l?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Uploading..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(E.ImageIcon,{className:"h-4 w-4"}),"Select image"]})}),s&&e.jsx(p.Button,{type:"button",variant:"outline",size:"icon",onClick:u,children:e.jsx(E.X,{className:"h-4 w-4"})})]}),s&&e.jsx("div",{className:"aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border",children:e.jsx("img",{src:s,alt:"Preview",className:"h-full w-full object-contain"})})]})},ie=s=>{const{blocks:r,close:l,blockId:t}=s,{getPartialBlocks:c}=x.usePartialBlocksStore(),m=r.find(a=>a._id===t),u=m==null?void 0:m._libBlockId,o=!!u,d=i.useMemo(()=>r.some(a=>a._type==="PartialBlock"||a._type==="GlobalBlock"),[r]),y=i.useMemo(()=>{let a=[];for(const k of r)if(k._type==="PartialBlock"||k._type==="GlobalBlock"){let v=c(k.partialBlockId);k._parent&&(v==null?void 0:v.length)>0&&(v=v.map(T=>(R.isEmpty(T._parent)&&R.set(T,"_parent",k._parent),T))),a=[...a,...v]}else a.push(k);return a},[r,c]),[h,g]=i.useState(""),[f,n]=i.useState(""),[B,w]=i.useState(""),[S,_]=i.useState(""),[N,U]=i.useState({}),[q,M]=i.useState(!1),[O,F]=i.useState(o),[z,K]=i.useState(!1),{hasPermission:Y}=x.usePermissions(),Q=Y(b.PAGES_PERMISSIONS.DELETE_LIBRARY_BLOCK),D=x.useUpdateBlocksPropsRealtime(),V=()=>{D([t],{_libBlockId:void 0}),j.toast.success("Block delinked from library"),l()},{data:I,isLoading:P,isError:G}=ee(u);i.useEffect(()=>{G&&o&&(K(!0),F(!1))},[G,o]),i.useEffect(()=>{I&&!P&&(g(I.name||""),n(I.group||""),w(I.description||""),_(I.preview||""),F(!1))},[I,P]),i.useEffect(()=>{const a=h.trim().length>=2,k=f.trim()!=="";M(a&&k)},[h,f]);const W=()=>{const a={};return h.trim()?h.length<2&&(a.name="Name must be at least 2 characters"):a.name="Name is required",f||(a.group="Group is required"),U(a),Object.keys(a).length===0},{resetLibrary:$}=x.useLibraryBlocks({id:""}),A=Z(a=>{o||D([t],{_libBlockId:a.id}),j.toast.success(`Block ${o?"updated":"saved"} successfully`),$(a.library),l()}),H=async a=>{if(a.preventDefault(),!W())return;const k=y.map(v=>(R.has(v,"_libBlockId")&&delete v._libBlockId,v));A.mutate({name:h.trim(),group:f,blocks:k,description:B.trim(),...S&&S.startsWith("data:")?{previewImage:S}:{},...o?{id:u}:{}})},L=A.isPending;return O||P?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):z?e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx("div",{className:"font-medium text-destructive",children:"Block Not Found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This block could not be found on the server. It may have been deleted."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(p.Button,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(p.Button,{onClick:V,variant:"destructive",children:"Delink Block"})]})]}):e.jsxs("div",{children:[d&&e.jsxs("div",{className:"mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive",children:[e.jsx(E.AlertCircle,{className:"mt-0.5 h-5 w-5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Partial Blocks Detected"}),e.jsx("p",{className:"mt-1 text-xs",children:"This block contains one or more Partial Blocks. Partial blocks will be merged into the library block"})]})]}),e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"name",className:N.name?"text-destructive":"",children:"Name"}),e.jsx(p.Input,{id:"name",placeholder:"Enter block name",value:h,onChange:a=>g(a.target.value),className:N.name?"border-destructive":""}),N.name&&e.jsx("p",{className:"text-xs text-destructive",children:N.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"group",className:N.group?"text-destructive":"",children:"Group"}),e.jsx(ae,{value:f,onChange:n}),N.group&&e.jsx("p",{className:"text-xs text-destructive",children:N.group})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(p.Input,{id:"description",placeholder:"Enter a brief description",className:"resize-none",value:B,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"previewImage",children:"Preview Image (optional)"}),e.jsx(oe,{value:S,onChange:_})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o&&Q&&e.jsx(re,{blockId:t,libBlockId:u,blockName:h,className:"mr-auto",close:l}),e.jsx(p.Button,{type:"button",variant:"outline",onClick:l,disabled:L,children:"Cancel"}),e.jsx(p.Button,{type:"submit",disabled:L||!q,children:L?"Saving...":o?"Update Block":"Save Block"})]})]})]})};exports.default=ie;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./register-chai-top-bar-DyW9GPzV.cjs"),x=require("./index-DCJDQs1a.cjs"),b=require("./index-BVwFJWDq.cjs"),C=require("@tanstack/react-query"),X=require("jotai"),j=require("sonner"),E=require("lucide-react"),i=require("react"),J=require("./image-compression-UaU7Bwqe.cjs"),R=require("lodash-es"),Z=s=>{const r=b.useApiUrl(),l=b.useFetch();return C.useMutation({mutationFn:async t=>l(r,{action:b.ACTIONS.UPSERT_LIBRARY_ITEM,data:t}),onSuccess:t=>{s?s(t):j.toast.success("Block saved successfully")},onError:t=>{console.error("Error saving block:",t),j.toast.error("Failed to save block",{description:t instanceof Error?t.message:"Unknown error"})}})},ee=s=>{const r=b.useApiUrl(),l=b.useFetch();return C.useQuery({staleTime:"static",queryKey:[b.ACTIONS.GET_LIBRARY_ITEM,s],enabled:!!s,queryFn:async()=>{if(!s)return null;try{return await l(r,{action:b.ACTIONS.GET_LIBRARY_ITEM,data:{id:s}})}catch(t){throw console.error(t),new Error("The block could not be found on the server. It may have been deleted.")}},retry:!1})},te=s=>{const r=b.useApiUrl(),l=b.useFetch(),t=X.useSetAtom(x.libraryBlocksAtom);return C.useMutation({mutationFn:async c=>l(r,{action:b.ACTIONS.DELETE_LIBRARY_ITEM,data:{id:c}}),onSuccess:()=>{t(c=>{const m={...c};return Object.keys(m).forEach(u=>{m[u]={loading:"idle",blocks:[],error:!1}}),m}),s?s():j.toast.success("Block deleted successfully")},onError:c=>{console.error("Error deleting block:",c),j.toast.error("Failed to delete block",{description:c instanceof Error?c.message:"Unknown error"})}})},se=({blockId:s,libBlockId:r,isOpen:l,onClose:t,blockName:c,trigger:m})=>{const[u,o]=i.useState(!1),d=x.useUpdateBlocksPropsRealtime(),y=te(()=>{d([s],{_libBlockId:void 0}),j.toast.success("Block deleted successfully"),o(!1),t()}),h=()=>{o(!0),y.mutate(r)},g=e.jsxs(p.Button,{type:"button",variant:"destructive",size:"sm",onClick:f=>f.preventDefault(),disabled:u,children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]});return e.jsxs(x.Popover,{open:l,onOpenChange:f=>!f&&t(),children:[e.jsx(x.PopoverTrigger,{asChild:!0,children:m||g}),e.jsx(x.PopoverContent,{className:"z-[9999] w-72 p-4",sideOffset:5,align:"center",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-medium",children:"Delete Block"}),e.jsxs("p",{className:"text-sm",children:["Are you sure you want to delete the block",e.jsxs("span",{className:"font-medium",children:[' "',c,'"']}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This block will be permanently removed from the library. This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(p.Button,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:u,children:"Cancel"}),e.jsx(p.Button,{type:"button",variant:"destructive",size:"sm",onClick:h,disabled:u,children:u?"Deleting...":"Delete"})]})]})})]})},re=({blockId:s,libBlockId:r,blockName:l,size:t="sm",className:c="",close:m})=>{const[u,o]=i.useState(!1);return e.jsx(se,{blockId:s,libBlockId:r,isOpen:u,onClose:()=>{o(!1),m()},blockName:l,trigger:e.jsxs(p.Button,{type:"button",variant:"destructive",size:t,className:c,onClick:()=>o(!0),children:[e.jsx(E.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})})},ne=()=>{const s=b.useApiUrl(),r=b.useFetch(),l=C.useQueryClient(),{data:t=[],isLoading:c,error:m}=C.useQuery({queryKey:["library-groups"],staleTime:"static",placeholderData:[],queryFn:async()=>{try{return await r(s,{action:"GET_LIBRARY_GROUPS"})||[]}catch(d){return console.error("Error fetching library groups:",d),[]}}}),{mutateAsync:u,isPending:o}=C.useMutation({mutationFn:async d=>{if(!d.trim())throw new Error("Group name is required");return r(s,{action:"CREATE_BLOCK_GROUP",data:{name:d}})},onSuccess:()=>{l.invalidateQueries({queryKey:["library-groups"]}),j.toast.success("Group created successfully")},onError:d=>{console.error("Error creating group:",d),j.toast.error("Failed to create group",{description:d instanceof Error?d.message:"Unknown error"})}});return{groups:t,isLoading:c,error:m,createGroup:u,isCreating:o}},ae=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),[c,m]=i.useState(""),u=i.useRef(null),{groups:o}=ne(),[d,y]=i.useState([{id:"hero",name:"Hero"},{id:"feature",name:"Feature"},{id:"footer",name:"Footer"},{id:"content",name:"Content"},{id:"testimonial",name:"Testimonial"},{id:"pricing",name:"Pricing"},{id:"login",name:"Login"},{id:"logos",name:"Logos"},{id:"about",name:"About"},{id:"banner",name:"Banner"},{id:"blog",name:"Blog"},{id:"careers",name:"Careers"},{id:"casestudy",name:"Casestudy"},{id:"changelog",name:"Changelog"},{id:"compare",name:"Compare"},{id:"contact",name:"Contact"},{id:"cta",name:"Cta"},{id:"faq",name:"Faq"},{id:"gallery",name:"Gallery"},{id:"integration",name:"Integration"},{id:"list",name:"List"},{id:"navbar",name:"Navbar"},{id:"product",name:"Product"},{id:"signup",name:"Signup"},{id:"stats",name:"Stats"},{id:"team",name:"Team"},{id:"timeline",name:"Timeline"}]),h=i.useMemo(()=>[...o,...d.filter(n=>!o.some(B=>B.id===n.id))],[o,d]),g=()=>{const n=c.trim();if(!n)return;const B={id:n,name:n};y(w=>[...w,B]),r(B.id),m(""),t(!1)};i.useEffect(()=>{l&&u.current&&u.current.focus()},[l]);const f=n=>{n.key==="Enter"&&(n.preventDefault(),g())};return i.useEffect(()=>{s&&!h.some(n=>n.id===s)&&r("")},[s,h,r]),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(p.Input,{ref:u,placeholder:"Enter new group name",value:c,onChange:n=>m(n.target.value),onKeyDown:f}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(p.Button,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(p.Button,{size:"sm",onClick:g,children:"Create"})]})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",value:s,onChange:n=>r(n.target.value),children:[e.jsx("option",{value:"",children:"Select a group"}),o.length>0&&e.jsx("optgroup",{label:"Library Groups",children:o.map(n=>e.jsx("option",{value:n.id,children:n.name},`lib-${n.id}`))}),d.length>0&&e.jsx("optgroup",{label:"Predefined Groups",children:d.filter(n=>!o.some(B=>B.id===n.id)).map(n=>e.jsx("option",{value:n.id,children:n.name},`local-${n.id}`))})]}),e.jsx(p.Button,{type:"button",size:"icon",variant:"outline",onClick:()=>t(!0),children:e.jsx(E.Plus,{className:"h-4 w-4"})})]})},oe=({value:s,onChange:r})=>{const[l,t]=i.useState(!1),c=i.useRef(null),m=i.useCallback(async d=>{var h;const y=(h=d.target.files)==null?void 0:h[0];if(y)try{t(!0);let g=y;y.type.startsWith("image/")&&(g=await J.compressImageIfNeeded(y));const f=new FileReader;f.onloadend=()=>{r(f.result),t(!1)},f.readAsDataURL(g)}catch(g){console.error("Error reading file:",g),t(!1),j.toast.error("Failed to process image",{description:g instanceof Error?g.message:"Unknown error"})}},[r]),u=()=>{r(""),c.current&&(c.current.value="")},o=()=>{var d;(d=c.current)==null||d.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p.Input,{type:"file",ref:c,onChange:m,accept:"image/*",className:"hidden"}),e.jsx(p.Button,{type:"button",variant:"outline",onClick:o,disabled:l,className:"w-full",children:l?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Uploading..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(E.ImageIcon,{className:"h-4 w-4"}),"Select image"]})}),s&&e.jsx(p.Button,{type:"button",variant:"outline",size:"icon",onClick:u,children:e.jsx(E.X,{className:"h-4 w-4"})})]}),s&&e.jsx("div",{className:"aspect-video h-[200px] max-h-[200px] overflow-hidden rounded-md border",children:e.jsx("img",{src:s,alt:"Preview",className:"h-full w-full object-contain"})})]})},ie=s=>{const{blocks:r,close:l,blockId:t}=s,{getPartialBlocks:c}=x.usePartialBlocksStore(),m=r.find(a=>a._id===t),u=m==null?void 0:m._libBlockId,o=!!u,d=i.useMemo(()=>r.some(a=>a._type==="PartialBlock"||a._type==="GlobalBlock"),[r]),y=i.useMemo(()=>{let a=[];for(const k of r)if(k._type==="PartialBlock"||k._type==="GlobalBlock"){let v=c(k.partialBlockId);k._parent&&(v==null?void 0:v.length)>0&&(v=v.map(T=>(R.isEmpty(T._parent)&&R.set(T,"_parent",k._parent),T))),a=[...a,...v]}else a.push(k);return a},[r,c]),[h,g]=i.useState(""),[f,n]=i.useState(""),[B,w]=i.useState(""),[S,_]=i.useState(""),[N,U]=i.useState({}),[q,M]=i.useState(!1),[O,F]=i.useState(o),[z,K]=i.useState(!1),{hasPermission:Y}=x.usePermissions(),Q=Y(b.PAGES_PERMISSIONS.DELETE_LIBRARY_BLOCK),D=x.useUpdateBlocksPropsRealtime(),V=()=>{D([t],{_libBlockId:void 0}),j.toast.success("Block delinked from library"),l()},{data:I,isLoading:P,isError:G}=ee(u);i.useEffect(()=>{G&&o&&(K(!0),F(!1))},[G,o]),i.useEffect(()=>{I&&!P&&(g(I.name||""),n(I.group||""),w(I.description||""),_(I.preview||""),F(!1))},[I,P]),i.useEffect(()=>{const a=h.trim().length>=2,k=f.trim()!=="";M(a&&k)},[h,f]);const W=()=>{const a={};return h.trim()?h.length<2&&(a.name="Name must be at least 2 characters"):a.name="Name is required",f||(a.group="Group is required"),U(a),Object.keys(a).length===0},{resetLibrary:$}=x.useLibraryBlocks({id:""}),A=Z(a=>{o||D([t],{_libBlockId:a.id}),j.toast.success(`Block ${o?"updated":"saved"} successfully`),$(a.library),l()}),H=async a=>{if(a.preventDefault(),!W())return;const k=y.map(v=>(R.has(v,"_libBlockId")&&delete v._libBlockId,v));A.mutate({name:h.trim(),group:f,blocks:k,description:B.trim(),...S&&S.startsWith("data:")?{previewImage:S}:{},...o?{id:u}:{}})},L=A.isPending;return O||P?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):z?e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsx("div",{className:"font-medium text-destructive",children:"Block Not Found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This block could not be found on the server. It may have been deleted."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(p.Button,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(p.Button,{onClick:V,variant:"destructive",children:"Delink Block"})]})]}):e.jsxs("div",{children:[d&&e.jsxs("div",{className:"mb-4 flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-destructive",children:[e.jsx(E.AlertCircle,{className:"mt-0.5 h-5 w-5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Partial Blocks Detected"}),e.jsx("p",{className:"mt-1 text-xs",children:"This block contains one or more Partial Blocks. Partial blocks will be merged into the library block"})]})]}),e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"name",className:N.name?"text-destructive":"",children:"Name"}),e.jsx(p.Input,{id:"name",placeholder:"Enter block name",value:h,onChange:a=>g(a.target.value),className:N.name?"border-destructive":""}),N.name&&e.jsx("p",{className:"text-xs text-destructive",children:N.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"group",className:N.group?"text-destructive":"",children:"Group"}),e.jsx(ae,{value:f,onChange:n}),N.group&&e.jsx("p",{className:"text-xs text-destructive",children:N.group})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(p.Input,{id:"description",placeholder:"Enter a brief description",className:"resize-none",value:B,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x.Label,{htmlFor:"previewImage",children:"Preview Image (optional)"}),e.jsx(oe,{value:S,onChange:_})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o&&Q&&e.jsx(re,{blockId:t,libBlockId:u,blockName:h,className:"mr-auto",close:l}),e.jsx(p.Button,{type:"button",variant:"outline",onClick:l,disabled:L,children:"Cancel"}),e.jsx(p.Button,{type:"submit",disabled:L||!q,children:L?"Saving...":o?"Update Block":"Save Block"})]})]})]})};exports.default=ie;