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

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 (156) hide show
  1. package/README.md +35 -52
  2. package/dist/{2SSKDMRQ-CjvuNdPo.cjs → 2SSKDMRQ-BSYe_xPq.cjs} +1 -1
  3. package/dist/{2SSKDMRQ-Dvf9zadl.js → 2SSKDMRQ-Dv-C_YAA.js} +3 -3
  4. package/dist/{AP7HFJJL-DYFttFoI.cjs → AP7HFJJL-BJolKJBt.cjs} +1 -1
  5. package/dist/{AP7HFJJL-q4dJdyFs.js → AP7HFJJL-DhdVstVC.js} +1 -1
  6. package/dist/{IconPicker-Bf163F7t.js → IconPicker-BBkl0T8b.js} +13 -13
  7. package/dist/{IconPicker-JWhYq2Gp.cjs → IconPicker-C0WWlb8t.cjs} +1 -1
  8. package/dist/{WDYDFRGG-O9GIrtX0.js → WDYDFRGG-CJs2MxSq.js} +4 -4
  9. package/dist/{WDYDFRGG-BEksfGMC.cjs → WDYDFRGG-DRt6Zg7Q.cjs} +1 -1
  10. package/dist/{actions-registery-BHbZHkE3.cjs → actions-registery-CLL3KrNv.cjs} +2 -2
  11. package/dist/{actions-registery-gJb_wq2F.js → actions-registery-CrGIlqUX.js} +88 -88
  12. package/dist/actions.cjs +1 -1
  13. package/dist/actions.js +2 -2
  14. package/dist/{add-new-language-page-BfUp5Ua2.cjs → add-new-language-page-ByMSfRcN.cjs} +1 -1
  15. package/dist/{add-new-language-page-CRR93tLq.js → add-new-language-page-DtVoDNfI.js} +35 -35
  16. package/dist/{add-new-page-B8NGK6WS.cjs → add-new-page-CnuChfJz.cjs} +1 -1
  17. package/dist/add-new-page-DanzzvYo.js +31 -0
  18. package/dist/{ai-panel-default-lang-BXYQye3N.js → ai-panel-default-lang-BaPz2d_6.js} +35 -35
  19. package/dist/{ai-panel-default-lang-VhgmHFoQ.cjs → ai-panel-default-lang-CoIQSz_Y.cjs} +2 -2
  20. package/dist/{ai-panel-other-lang-DaCf-cq4.js → ai-panel-other-lang--i-5z4e2.js} +22 -22
  21. package/dist/{ai-panel-other-lang-Ds0EXeUC.cjs → ai-panel-other-lang-ChlMVodg.cjs} +1 -1
  22. package/dist/{ai-prompt-input-7iWk72w5.js → ai-prompt-input-BQi0VDJC.js} +77 -77
  23. package/dist/{ai-prompt-input-nZ5_Dm7X.cjs → ai-prompt-input-BT5426AB.cjs} +1 -1
  24. package/dist/{ai-translation-prompt-1OUs1P7n.js → ai-translation-prompt-BN78s33t.js} +8 -8
  25. package/dist/{ai-translation-prompt-B16cK-1Q.cjs → ai-translation-prompt-BQPaekp3.cjs} +1 -1
  26. package/dist/{apply-binding-CBSjMYSk.cjs → apply-binding-Cjh1kqMO.cjs} +1 -1
  27. package/dist/{apply-binding-vAuN-TGV.js → apply-binding-v_W4uR3U.js} +28 -28
  28. package/dist/{plugin-BSjgGgwo.js → chai-theme-helpers-BEf2rwE4.js} +83 -83
  29. package/dist/chai-theme-helpers-q3nwoNht.cjs +22 -0
  30. package/dist/{change-password-modal-D5eXjiYq.cjs → change-password-modal-DHUrrKw7.cjs} +1 -1
  31. package/dist/{change-password-modal-CdvJR1Ln.js → change-password-modal-pEp-nMNb.js} +30 -30
  32. package/dist/{code-display-DdWcOQ_i.js → code-display-BaLKScgW.js} +5 -5
  33. package/dist/{code-display-BR-gij5j.cjs → code-display-i7jb2kmw.cjs} +1 -1
  34. package/dist/{code-editor-CyLjDiEp.js → code-editor-CRoniyP0.js} +12 -12
  35. package/dist/{code-editor-SWbfFj1E.cjs → code-editor-gwFRjQ2_.cjs} +1 -1
  36. package/dist/core.cjs +1 -1
  37. package/dist/core.d.ts +0 -5
  38. package/dist/core.js +49 -49
  39. package/dist/{css-import-modal-Be47CBJn.js → css-import-modal-B3qxX9Iv.js} +14 -14
  40. package/dist/{css-import-modal-Bdwgd05S.cjs → css-import-modal-nAB5FSwn.cjs} +2 -2
  41. package/dist/{delete-page-C99K2qzS.js → delete-page-DbawNFf7.js} +13 -13
  42. package/dist/{delete-page-DLohaU-U.cjs → delete-page-YP1HEAoD.cjs} +1 -1
  43. package/dist/{digital-asset-manager-BZMb6sC7.js → digital-asset-manager-DTD5mf24.js} +388 -357
  44. package/dist/digital-asset-manager-kJnuMqpw.cjs +1 -0
  45. package/dist/{duplicate-page-D5Gtvqdv.cjs → duplicate-page-CxqW_EO7.cjs} +1 -1
  46. package/dist/{duplicate-page-CDc2X0eW.js → duplicate-page-DnRb1y6K.js} +19 -19
  47. package/dist/{dynamic-page-selector-DZHhX008.cjs → dynamic-page-selector-2EqJhUrB.cjs} +1 -1
  48. package/dist/{dynamic-page-selector-DvNBXo6o.js → dynamic-page-selector-D6VLDIN9.js} +17 -17
  49. package/dist/{get-chai-builder-tailwind-config-7CxFxEYL.cjs → get-chai-builder-tailwind-config-DNp8Vhme.cjs} +1 -1
  50. package/dist/{get-chai-builder-tailwind-config-DC4sDOYK.js → get-chai-builder-tailwind-config-k8l5sdcw.js} +3 -3
  51. package/dist/{get-chai-builder-theme-BpuwSLeS.js → get-chai-builder-theme-DLpviqPJ.js} +1 -1
  52. package/dist/get-chai-builder-theme-Du4ARJlw.cjs +1 -0
  53. package/dist/{image-editor-DwhTYkVR.cjs → image-editor-BQcOGsli.cjs} +1 -1
  54. package/dist/{image-editor-BBvvi9Vm.js → image-editor-CMf731xL.js} +15 -15
  55. package/dist/index-BYrRPW_c.cjs +5 -0
  56. package/dist/index-D-r_K4yA.cjs +160 -0
  57. package/dist/{index-OuHV9Ann.js → index-DPV6NiJ-.js} +5894 -6049
  58. package/dist/index-DqzFD1CG.js +4861 -0
  59. package/dist/{mark-as-template-CP_F9ZQ4.js → mark-as-template-D7jqSCXw.js} +28 -28
  60. package/dist/{mark-as-template-B9yLcasI.cjs → mark-as-template-DyB56HzI.cjs} +1 -1
  61. package/dist/{nested-path-selector-content-DmtCI3q9.js → nested-path-selector-content-dwSikrsV.js} +2 -2
  62. package/dist/{nested-path-selector-content-aTdu-o0e.cjs → nested-path-selector-content-g9_Tq_sR.cjs} +1 -1
  63. package/dist/no-language-page-content-BRITuyfN.js +43 -0
  64. package/dist/{no-language-page-content-C-MCdPXt.cjs → no-language-page-content-ZvMNVY-Y.cjs} +1 -1
  65. package/dist/{no-language-page-dialog-D4QIAHnE.cjs → no-language-page-dialog-Cndq8xRP.cjs} +1 -1
  66. package/dist/no-language-page-dialog-D7L9nVb9.js +10 -0
  67. package/dist/page-creator-BAIbU14q.js +652 -0
  68. package/dist/page-creator-qL3-M8g3.cjs +1 -0
  69. package/dist/{page-manager-new-ah6QYar2.cjs → page-manager-new-By3eGO3i.cjs} +1 -1
  70. package/dist/{page-manager-new-ttsrxdW9.js → page-manager-new-YRG89y4f.js} +63 -63
  71. package/dist/page-manager-search-and-filter-BbdgOU9V.cjs +1 -0
  72. package/dist/page-manager-search-and-filter-Cllju4CV.js +184 -0
  73. package/dist/pages.cjs +1 -1
  74. package/dist/pages.d.ts +0 -15
  75. package/dist/pages.js +20 -21
  76. package/dist/{publish-pages-content-KZVMHT6V.js → publish-pages-content-CG5LBUnY.js} +48 -48
  77. package/dist/{publish-pages-content-BrajJUcP.cjs → publish-pages-content-DxMiBxNU.cjs} +1 -1
  78. package/dist/{register-chai-top-bar-DyW9GPzV.cjs → register-chai-top-bar-CCssW5dL.cjs} +1 -1
  79. package/dist/{register-chai-top-bar-D6GjnauV.js → register-chai-top-bar-DWmJ2efT.js} +11 -11
  80. package/dist/render.cjs +1 -1
  81. package/dist/render.js +54 -54
  82. package/dist/{rte-widget-modal-CiTwsXTr.cjs → rte-widget-modal-CsTqFJc_.cjs} +1 -1
  83. package/dist/{rte-widget-modal-IU8JzPuZ.js → rte-widget-modal-DoeTMRtX.js} +2 -2
  84. package/dist/runtime-client.cjs +1 -1
  85. package/dist/runtime-client.js +1 -1
  86. package/dist/runtime.cjs +1 -1
  87. package/dist/runtime.js +1 -1
  88. package/dist/sdk.css +1 -1
  89. package/dist/{selected-block-display-CidmQ-wz.js → selected-block-display-Ck1kkNEi.js} +17 -28
  90. package/dist/{selected-block-display-CAFEOrLV.cjs → selected-block-display-DSow6N4b.cjs} +1 -1
  91. package/dist/seo-panel---mYZmLD.js +559 -0
  92. package/dist/seo-panel-mfX63fua.cjs +1 -0
  93. package/dist/{shared-json-ld-uvMmwCYp.js → shared-json-ld-B3I_RLE2.js} +46 -46
  94. package/dist/{shared-json-ld-CMH-eRUq.cjs → shared-json-ld-CGgwUOlW.cjs} +1 -1
  95. package/dist/{slug-input-DLWTMTsO.js → slug-input-DQ4t3-Tt.js} +5 -5
  96. package/dist/{slug-input-CiHC5l3r.cjs → slug-input-DaNbl597.cjs} +1 -1
  97. package/dist/supabase-actions.cjs +1 -1
  98. package/dist/supabase-actions.js +2 -2
  99. package/dist/types.d.ts +0 -96
  100. package/dist/{unmark-as-template-F7TdgWjI.cjs → unmark-as-template-CZ65AE4v.cjs} +1 -1
  101. package/dist/{unmark-as-template-C5ovsEBP.js → unmark-as-template-DvmoTbVu.js} +11 -11
  102. package/dist/unpublish-page-3--vO5b0.js +28 -0
  103. package/dist/{unpublish-page-CUr8Xub6.cjs → unpublish-page-B46TiWlU.cjs} +1 -1
  104. package/dist/{unpublished-partials-modal-BhNAub_z.js → unpublished-partials-modal-DVMz3q83.js} +18 -15
  105. package/dist/{unpublished-partials-modal-Cv5R9-hi.cjs → unpublished-partials-modal-U5lKBOSR.cjs} +1 -1
  106. package/dist/utils.cjs +1 -1
  107. package/dist/utils.js +2 -2
  108. package/dist/web-blocks.cjs +1 -1
  109. package/dist/web-blocks.js +2 -2
  110. package/dist/{web-preview-D9pXonAv.js → web-preview-D5o5XQo0.js} +2 -2
  111. package/dist/{web-preview-CuMYekVJ.cjs → web-preview-Da3RhcjQ.cjs} +1 -1
  112. package/package.json +1 -1
  113. package/dist/active-in-another-tab-B4Ur0JP7.js +0 -35
  114. package/dist/active-in-another-tab-BPdx4lWh.cjs +0 -1
  115. package/dist/add-new-page-Ppy5-y5j.js +0 -31
  116. package/dist/continue-editing-in-this-client-BrSvK-Ay.js +0 -25
  117. package/dist/continue-editing-in-this-client-Cmi-GkYZ.cjs +0 -1
  118. package/dist/design-token-usage-D1lWCJ3L.js +0 -114
  119. package/dist/design-token-usage-eY2wQ0l3.cjs +0 -1
  120. package/dist/digital-asset-manager-Z5aJxkq0.cjs +0 -1
  121. package/dist/get-chai-builder-theme-B5RkBTsB.cjs +0 -1
  122. package/dist/image-compression-DPFITwOL.js +0 -37
  123. package/dist/image-compression-UaU7Bwqe.cjs +0 -1
  124. package/dist/index-BVwFJWDq.cjs +0 -5
  125. package/dist/index-DCJDQs1a.cjs +0 -160
  126. package/dist/index-LBTm1Jmk.js +0 -5199
  127. package/dist/json-diff-viewer-Cb1CmRqP.cjs +0 -8
  128. package/dist/json-diff-viewer-DG6qMOBS.js +0 -261
  129. package/dist/lang-panel-B3USOxGq.js +0 -216
  130. package/dist/lang-panel-DxoJ0v4y.cjs +0 -1
  131. package/dist/manage-design-tokens-6YGIctip.js +0 -446
  132. package/dist/manage-design-tokens-modal-BSSCXH8Y.cjs +0 -1
  133. package/dist/manage-design-tokens-modal-CzsnN49F.js +0 -161
  134. package/dist/manage-design-tokens-udLBvkHA.cjs +0 -1
  135. package/dist/no-language-page-content-D8t5dfgh.js +0 -43
  136. package/dist/no-language-page-dialog-C_fHI2zI.js +0 -10
  137. package/dist/page-creator-Cz_ah-qE.cjs +0 -1
  138. package/dist/page-creator-DKEkuGCO.js +0 -796
  139. package/dist/page-lock-CwZKJ4IE.js +0 -30
  140. package/dist/page-lock-DdCvtA-I.cjs +0 -1
  141. package/dist/page-locked-dialog-CrTDBoC4.cjs +0 -1
  142. package/dist/page-locked-dialog-DqLlooUz.js +0 -136
  143. package/dist/page-manager-search-and-filter-D7AupT6_.cjs +0 -1
  144. package/dist/page-manager-search-and-filter-bsqZ6wnI.js +0 -210
  145. package/dist/page-revisions-content-B6hsIla7.cjs +0 -1
  146. package/dist/page-revisions-content-C5O8_Fms.js +0 -459
  147. package/dist/plugin-DHpuZZXz.cjs +0 -22
  148. package/dist/save-to-lib-DMnv7ENo.js +0 -429
  149. package/dist/save-to-lib-Dc700Aop.cjs +0 -1
  150. package/dist/seo-panel-Br8gxDxu.js +0 -789
  151. package/dist/seo-panel-CMY-adM-.cjs +0 -2
  152. package/dist/take-over-request-IRLgF1dG.cjs +0 -1
  153. package/dist/take-over-request-KdR1_h_K.js +0 -64
  154. package/dist/translation-warning-modal-CLZ9tC1F.cjs +0 -1
  155. package/dist/translation-warning-modal-CzNt6LDO.js +0 -27
  156. package/dist/unpublish-page-0fR1o0b7.js +0 -28
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),W=require("lodash-es"),v=require("lucide-react"),i=require("react"),K=require("sonner"),d=require("./register-chai-top-bar-CCssW5dL.cjs"),l=require("./index-D-r_K4yA.cjs"),V=require("./slug-input-DaNbl597.cjs"),O=require("./index-BYrRPW_c.cjs"),ge=require("./get-seo-defaults-Cw7vFt-B.cjs");function Be({value:n,onChange:x,placeholder:b="Enter custom slug part",dynamicPattern:p,onValidationChange:o}){const[f,c]=i.useState(null),m=i.useRef(null),[I,F]=i.useState(p+n);i.useEffect(()=>{F(p+n)},[n,p]);const B=j=>{const y=j.target.value;if(!y.startsWith(p)){const T=y.replace(p,""),z=p+T;F(z),x(T);return}const u=y.substring(p.length).replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),t=(u.match(/\./g)||[]).length,h=t<=1;t>1?c("Invalid slug. Only one dot (.) is allowed in the slug"):c(null),o&&o(h);const g=p+u;F(g),x(u)},q=()=>{if(m.current){const j=m.current;setTimeout(()=>{const y=p.length;j.setSelectionRange(y,y)},0)}},A=j=>{const y=j.currentTarget;(y.selectionStart||0)<=p.length&&setTimeout(()=>{const u=p.length;y.setSelectionRange(u,u)},0)};return e.jsx("div",{children:e.jsxs("div",{className:"relative",children:[e.jsxs("p",{className:"mb-2 text-xs text-gray-500",children:[`${p}`," is a dynamic segment of slug"]}),e.jsx(d.Input,{ref:m,value:I,onChange:B,onFocus:q,onClick:A,placeholder:b,className:f?"border-red-500":""}),f&&e.jsx("div",{className:"mt-1 text-xs text-red-500",children:f})]})})}const se=({children:n,onWheel:x,...b})=>{const p=o=>{try{o.preventDefault();const f=o.currentTarget;f.scrollTop+=o.deltaY}catch{o.preventDefault()}x&&x(o)};return e.jsx(l.CommandList,{...b,onWheel:p,children:n})},ee=(...n)=>n.filter(Boolean).join(" ");function Re({pages:n,selectedParentId:x,onChange:b,className:p,id:o="parentPage",currentPage:f}){const[c,m]=i.useState(!1),[I,F]=i.useState(""),B=d.useChaiFeatureFlag("enable-add-page-dropdown");B||(p="w-full rounded-md border border-gray-300 px-3 py-2");const q=i.useMemo(()=>!n||n.length===0?[]:n.filter(h=>!W.isEmpty(h.slug)).filter(h=>h.slug!=="/").sort((h,g)=>h.slug.localeCompare(g.slug)),[n]),A=i.useMemo(()=>{if(!I.trim())return q;const t=I.toLowerCase();return q.filter(h=>h.name.toLowerCase().includes(t)||h.slug.toLowerCase().includes(t))},[q,I]),j=t=>Math.max(0,(t.match(/\//g)||[]).length-1),y=t=>"    ".repeat(t),R=t=>{if(t==="/")return"/";const h=t.split("/").filter(Boolean);if(h.length<=1){const g=h[0]||"";return`/${V.removeSlugExtension(g)}`}return`/${V.removeSlugExtension(h[h.length-1])}`},u=()=>{if(!x||x==="none")return"None";const t=q.find(h=>h.id===x);return t?`${t.name} (${R(t.slug)})`:"None"};return e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(l.Label,{htmlFor:o,className:"text-sm",children:"Parent"}),B?e.jsxs(l.Popover,{open:c,onOpenChange:m,children:[e.jsx(l.PopoverTrigger,{asChild:!0,children:e.jsxs(d.Button,{id:o,variant:"outline",role:"combobox",className:ee("w-full justify-between",p),"data-testid":"parent-page-selector",children:[u(),e.jsx(v.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(l.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(l.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"relative border-none py-2",children:e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(v.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(d.Input,{placeholder:"Search pages...",className:"h-8 pl-8 text-xs",value:I,onChange:t=>F(t.target.value)})]})})}),e.jsxs(se,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(l.CommandEmpty,{children:"No pages found."}),e.jsxs(l.CommandGroup,{children:[e.jsxs(l.CommandItem,{value:"none",onSelect:()=>{b(""),m(!1),F("")},className:"flex cursor-pointer items-center justify-between",children:[e.jsx("span",{children:"None"}),e.jsx(v.Check,{className:ee("mr-2 h-4 w-4",x?"opacity-0":"opacity-100")})]}),A.map(t=>{const h=y(j(t.slug)),g=R(t.slug),T=e.jsxs("span",{className:"flex items-center text-sm",children:[h,t.name,e.jsxs("span",{className:"text-xs text-gray-500",children:[" (",g,")"]})]});return e.jsxs(l.CommandItem,{value:t.id,onSelect:()=>{b(t.id),m(!1),F("")},className:"flex cursor-pointer items-center justify-between whitespace-pre-wrap",children:[e.jsx("span",{children:T}),e.jsx(v.Check,{className:ee("mr-2 h-4 w-4 shrink-0",x===t.id?"opacity-100":"opacity-0")})]},t.id)})]})]})]})})]}):e.jsxs("select",{id:o,value:x||"none",onChange:t=>b(t.target.value),className:p,"data-testid":"parent-page-selector",children:[e.jsx("option",{value:"none",children:"None"}),q.map(t=>{const h=j(t.slug),g=h>0?y(h):"",T=R(t.slug);return(f==null?void 0:f.id)&&(f.id===t.id||t.slug.startsWith(f.slug+"/"))?null:e.jsxs("option",{value:t.id,children:[g,t.name," (",T,")"]},t.id)})]})]})}const U=(...n)=>n.filter(Boolean).join(" ");function ze({addEditPage:n,close:x,closePanel:b}){var pe,xe;const{data:p}=O.usePageTypes(),o=i.useMemo(()=>p??[],[p]),f=O.useChangePage(),c=!!(n!=null&&n.id),{data:m}=O.useWebsitePrimaryPages(),{mutate:I,isPending:F}=O.useCreatePage(),{mutate:B,isPending:q}=O.useUpdatePage(),[A,j]=i.useState(null),[y,R]=i.useState(!0),[u,t]=i.useState((n==null?void 0:n.pageType)??"page"),{hasPermission:h}=l.usePermissions(),g=h(O.PAGES_PERMISSIONS.CHANGE_PAGE_TYPE),[T,z]=i.useState(!1),[de,fe]=i.useState(""),{selectedLang:je,fallbackLang:ye}=l.useLanguages(),ne=je||ye,[$,Q]=i.useState(""),[te,Y]=i.useState(!1),le=i.useMemo(()=>{const s=o.find(r=>r.key===u);return(s==null?void 0:s.hasSlug)===!1},[u,o]),[C,Se]=i.useState((n==null?void 0:n.parent)??""),[M,ae]=i.useState((n==null?void 0:n.name)??""),[w,re]=i.useState((n==null?void 0:n.dynamic)??!1),[k,H]=i.useState(w?"":((n==null?void 0:n.slug)??"").split("/").pop()||""),[oe,ie]=i.useState((n==null?void 0:n.dynamicSlugCustom)??""),[ce,ve]=i.useState(!0),[Ce,X]=i.useState(!1),_=F||q,ue=d.useChaiFeatureFlag("enable-add-page-dropdown"),P=i.useMemo(()=>!c||!(n!=null&&n.id)||!m?null:m.find(s=>s.id===n.id),[c,n==null?void 0:n.id,m]),Ne=(P==null?void 0:P.online)||!1,be=i.useMemo(()=>!c||!(n!=null&&n.id)||!m?!1:m.some(s=>s.parent===n.id),[c,n==null?void 0:n.id,m]),a=o.find(s=>s.key===u),G=s=>{if(c&&u!==s){fe(s),z(!0),Q(""),Y(!1);return}t(s),Q(""),Y(!1)},me=()=>{t(de),z(!1),re(!1)},we=s=>{re(s),s?H(""):ie("")},ke=s=>{if(Se(s),s&&s!=="none"){const r=m==null?void 0:m.find(S=>S.id===s),L=(r==null?void 0:r.slug)||"";if(k.startsWith(L)){const S=k.slice(L.length).replace(/^\/+/,"");H(S)}else H(k.replace(/^\/+/,""))}else H(k?`${k}`:"")},Le=()=>M.trim()?w&&!W.isEmpty(k)?(j("Slug must be empty when using dynamic slug"),!1):w&&!ce?(j("Dynamic slug is invalid"),!1):!0:(K.toast.error("Name is required"),!1),De=()=>{const s={pageType:a==null?void 0:a.key,name:M,slug:"",hasSlug:!1};c?B({id:n==null?void 0:n.id,name:M},{onSuccess:()=>{K.toast.success((a==null?void 0:a.name)+" updated successfully"),x()}}):I(s,{onSuccess:r=>{x(),f(r.page.id,b)}})},Ie=(s,r)=>{if(!s.trim()&&!w)return j("Child page slug is required"),!1;const L=V.removeSlugExtension(r),S=V.combineParentChildSlugs(L,s);return Object.keys(O.LANGUAGES).some(J=>S===`/${J}`||(S==null?void 0:S.startsWith(`/${J}/`)))?(j("Slugs cannot start with a language code for primary page"),!1):!0},Fe=(s,r)=>{const L=V.removeSlugExtension(r),S=V.combineParentChildSlugs(L,s),N={pageType:u,name:M,slug:S.replace(/\/$/,""),parent:C,dynamic:w,hasSlug:!0,template:void 0,tracking:{},seo:{},jsonLD:{}};if(w&&(N.dynamicSlugCustom=oe),c){const D=W.pick(N,["pageType","parent","name","slug","dynamic","dynamicSlugCustom"]);B({id:n==null?void 0:n.id,...D},{onSuccess:()=>{K.toast.success("Page updated successfully"),x()}})}else{const D=W.find(o,{key:u});D!=null&&D.trackingDefault&&(N.tracking=D.trackingDefault);const{seo:J,jsonLD:Te}=ge.getSeoDefaults(D,ne);W.set(N,"seo",J),W.set(N,"jsonLD",Te),I(N,{onSuccess:We=>{x(),f(We.page.id,b)}})}},qe=()=>{const s={pageType:u,name:M,slug:k===""?"/":`/${k.replace(/\/$/,"")}`,template:void 0,parent:null,tracking:{}};if(c)B({id:n==null?void 0:n.id,...s},{onSuccess:()=>{K.toast.success("Page updated successfully"),x()}});else{const r=W.find(o,{key:u});r!=null&&r.trackingDefault&&(s.tracking=r.trackingDefault);const{seo:L,jsonLD:S}=ge.getSeoDefaults(r,ne);W.set(s,"seo",L),W.set(s,"jsonLD",S),I(s,{onSuccess:N=>{var D;(D=N==null?void 0:N.page)!=null&&D.id&&f(N.page.id,b),x()}})}},he=s=>{if(s.preventDefault(),j(null),!!Le()){if(!(a!=null&&a.hasSlug)){De();return}if(C&&C!=="none"){const r=m==null?void 0:m.find(S=>S.id===C),L=(r==null?void 0:r.slug)||"";if(!Ie(k,L))return;Fe(k,L)}else qe()}},{pagesType:E,partialsType:Z}=i.useMemo(()=>{const s=r=>$?r.name.toLowerCase().includes($.toLowerCase())||r.key.toLowerCase().includes($.toLowerCase()):!0;return{pagesType:o.filter(r=>r.hasSlug!==!1&&s(r)),partialsType:o.filter(r=>r.hasSlug===!1&&s(r))}},[o,$]);return a!=null&&a.hasSlug?e.jsxs("form",{onSubmit:he,className:"mx-auto w-full max-w-md space-y-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(l.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),ue?e.jsxs(l.Popover,{open:te,onOpenChange:Y,children:[e.jsx(l.PopoverTrigger,{asChild:!0,children:e.jsxs(d.Button,{variant:"outline",role:"combobox",disabled:c&&!g,className:U("w-full justify-between",c&&!g?"cursor-not-allowed text-gray-500":""),children:[(a==null?void 0:a.name)||"Select page type",e.jsx(v.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(l.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(l.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(v.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(d.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:$,onChange:s=>Q(s.target.value)})]})}),e.jsxs(se,{className:"overflow-y-auto",children:[e.jsx(l.CommandEmpty,{children:"No page type found."}),c?le?e.jsx(l.CommandGroup,{heading:"Partials",children:Z.map(s=>e.jsxs(l.CommandItem,{value:s.key,onSelect:()=>G(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(v.Check,{className:U("mr-2 h-4 w-4",u===s.key?"opacity-100":"opacity-0")})]},s.key))}):e.jsx(l.CommandGroup,{heading:"Pages",children:E.map(s=>e.jsxs(l.CommandItem,{value:s.key,onSelect:()=>G(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(v.Check,{className:U("mr-2 h-4 w-4",u===s.key?"opacity-100":"opacity-0")})]},s.key))}):e.jsxs(e.Fragment,{children:[E.length>0&&e.jsx(l.CommandGroup,{heading:"Pages",children:E.map(s=>e.jsxs(l.CommandItem,{value:s.key,onSelect:()=>G(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(v.Check,{className:U("mr-2 h-4 w-4",u===s.key?"opacity-100":"opacity-0")})]},s.key))}),Z.length>0&&e.jsx(l.CommandGroup,{heading:"Partials",children:Z.map(s=>e.jsxs(l.CommandItem,{value:s.key,onSelect:()=>G(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(v.Check,{className:U("mr-2 h-4 w-4",u===s.key?"opacity-100":"opacity-0")})]},s.key))})]})]})]})})]}):e.jsx("select",{id:"pageType",value:u,disabled:c&&!g,onChange:s=>G(s.target.value),className:`w-full rounded-md border border-gray-300 px-3 py-2 ${c&&!g?"cursor-not-allowed text-gray-500":""}`,children:c?le?e.jsx("optgroup",{label:"Partials",children:o.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}):e.jsx("optgroup",{label:"Pages",children:o.filter(s=>s.hasSlug!==!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}):e.jsxs(e.Fragment,{children:[e.jsx("optgroup",{label:"Pages",children:o.filter(s=>s.hasSlug!==!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}),e.jsx("optgroup",{label:"Partials",children:o.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})]})}),T&&e.jsxs("div",{className:"mt-2 rounded-md border border-yellow-200 bg-yellow-50 p-3",children:[e.jsx("p",{className:"text-sm text-yellow-800",children:"Changing the page type may impact the page data. Are you sure you want to proceed?"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(d.Button,{variant:"outline",size:"sm",onClick:()=>z(!1),children:"Cancel"}),e.jsx(d.Button,{variant:"default",size:"sm",onClick:me,children:"Confirm"})]})]})]}),e.jsx(Re,{pages:m,selectedParentId:C,onChange:ke,currentPage:n}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(l.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(d.Input,{id:"name",value:M,onChange:s=>ae(s.target.value),required:!0,"aria-required":"true",placeholder:"Enter page name"})]}),(a==null?void 0:a.dynamicSegments)&&C&&C!=="none"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"useDynamicSlug",checked:w,onChange:s=>we(s.target.checked),className:"rounded border-gray-300"}),e.jsx(l.Label,{htmlFor:"useDynamicSlug",className:"text-sm",children:"Use Dynamic Slug"})]}),w&&e.jsx("div",{className:"space-y-2",children:e.jsx("div",{className:"space-y-0.5",children:e.jsx(Be,{value:oe,onChange:ie,dynamicPattern:(a==null?void 0:a.dynamicSlug)||"{{id}}",placeholder:"Enter custom slug part (optional)",onValidationChange:ve})})})]}),(!(a!=null&&a.dynamicSegments)||!w)&&e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(l.Label,{htmlFor:"slug",className:"text-sm",children:"Slug"}),e.jsx(V.SlugInput,{value:k,onChange:s=>{var r;H(s),c&&s!==(((r=n==null?void 0:n.slug)==null?void 0:r.split("/").pop())||"")?X(!!(Ne||be)):X(!1)},placeholder:C&&C!=="none"?"Enter page slug":u==="page"?"Leave empty for home page":"Required - e.g. your-slug",parentSlug:C&&C!=="none"?(xe=m==null?void 0:m.find(s=>s.id===C))==null?void 0:xe.slug:void 0,onValidationChange:R}),A&&e.jsx("p",{className:"text-xs text-red-500",children:A}),Ce&&e.jsx("div",{className:"mt-4 rounded-md border border-amber-200 bg-amber-50 p-3",children:e.jsxs("div",{className:"flex items-start space-x-2",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("svg",{className:"h-5 w-5 text-amber-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-sm font-medium text-amber-800",children:"Slug Change Warning"}),e.jsx("div",{className:"mt-1 text-sm text-amber-700",children:e.jsx("p",{children:"The previous URL and any child pages will become inaccessible. You may want to set up a redirect to avoid broken links."})})]})]})})]}),e.jsx(d.Button,{disabled:_||!y&&(!(a!=null&&a.dynamicSegments)||!w)||w&&!ce,type:"submit",className:"w-full",children:c?_?"Updating...":"Update page":_?"Creating...":"Create Page"})]}):e.jsxs("form",{onSubmit:he,className:"mx-auto w-full max-w-md space-y-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(l.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),ue?e.jsxs(l.Popover,{open:te,onOpenChange:Y,children:[e.jsx(l.PopoverTrigger,{asChild:!0,children:e.jsxs(d.Button,{variant:"outline",role:"combobox",disabled:c&&!g,className:U("w-full justify-between",c&&!g?"cursor-not-allowed text-gray-500":""),children:[(a==null?void 0:a.name)||"Select page type",e.jsx(v.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(l.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(l.Command,{shouldFilter:!1,children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(v.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(d.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:$,onChange:s=>Q(s.target.value)})]})}),e.jsxs(se,{className:"max-h-[200px] overflow-y-auto",children:[e.jsx(l.CommandEmpty,{children:"No page type found."}),e.jsx(l.CommandGroup,{heading:"Partials",children:Z.map(s=>e.jsxs(l.CommandItem,{value:s.key,onSelect:()=>{G(s.key),Y(!1)},className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(v.Check,{className:U("mr-2 h-4 w-4",u===s.key?"opacity-100":"opacity-0")})]},s.key))})]})]})})]}):e.jsx("select",{id:"pageType",value:u,disabled:c&&!g,onChange:s=>G(s.target.value),className:`w-full rounded-md border border-gray-300 px-3 py-2 ${c&&!g?"cursor-not-allowed text-gray-500":""}`,children:e.jsx("optgroup",{label:"Partials",children:o.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})}),T&&e.jsxs("div",{className:"mt-2 rounded-md border border-yellow-200 bg-yellow-50 p-3",children:[e.jsx("p",{className:"text-sm text-yellow-800",children:"Changing the page type may impact the page data. Are you sure you want to proceed?"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(d.Button,{variant:"outline",size:"sm",onClick:()=>z(!1),children:"Cancel"}),e.jsx(d.Button,{variant:"default",size:"sm",onClick:me,children:"Confirm"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:(pe=o.find(s=>s.key===u))==null?void 0:pe.helpText})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(l.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(d.Input,{id:"name",value:M,onChange:s=>ae(s.target.value),required:!0,"aria-required":"true"})]}),e.jsx(d.Button,{disabled:_,type:"submit",className:"w-full",children:c?_?"Updating...":"Update "+(a==null?void 0:a.name):_?"Creating...":"Create "+(a==null?void 0:a.name)})]})}exports.default=ze;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),K=require("./index-DCJDQs1a.cjs"),y=require("./index-BVwFJWDq.cjs"),G=require("./use-page-expand-manager-B6XTvk0E.cjs"),n=require("lodash-es"),R=require("jotai"),k=require("lucide-react"),o=require("react"),oe=require("react-i18next"),ie=require("./register-chai-top-bar-DyW9GPzV.cjs"),Z=(e,r)=>!e||!Array.isArray(e)?[]:n.isEmpty(r)?e:n.compact(n.filter(e,a=>{const s=n.toLower(r);return n.includes(n.toLower((a==null?void 0:a.name)||""),s)||n.includes(n.toLower((a==null?void 0:a.slug)||""),s)})),le=(e,r)=>{const a=new Set,s=n.keyBy(e,"id");return r.forEach(c=>{let l=c;for(;l.parent&&s[l.parent];)a.add(l.parent),l=s[l.parent]}),Array.from(a).map(c=>s[c])},O=(e,r,a)=>n.isEmpty(r)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?O(s.children,r,a):[]};const c=s.children&&s.children.some(l=>n.includes(n.toLower(l.name||""),n.toLower(r))||n.includes(n.toLower(l.slug||""),n.toLower(r)));return{...s,shouldExpandOnSearch:c,children:s.children?O(s.children,r,a):[]}}),ce=e=>{if(!e||!e.length)return[];const r={};e.forEach(s=>{r[s.id]={...s,children:[]}});const a=[];return Object.values(r).forEach(s=>{s.parent&&r[s.parent]?r[s.parent].children.push(s):a.push(s)}),a},ee=e=>!e||!e.length?[]:[...e].sort((a,s)=>(a.name||"").localeCompare(s.name||"")).map(a=>({...a,children:a.children?ee(a.children):[]})),de=(e,r,a,s)=>{if(!e||!e.length)return[];let c=e;if(a!=="all"&&(c=n.compact(n.filter(e,{pageType:a}))),n.isEmpty(r))c=Z(c,r);else{const x=Z(c,r),d=le(e,x);c=n.uniqBy([...x,...d],"id")}const l=ee(ce(c)),p=O(l,r,s),g=n.filter(p,x=>s(x.pageType)).sort((x,d)=>(x.name||"").localeCompare(d.name||"")),u=n.filter(p,x=>!s(x.pageType));let P=[];if(a==="all"){const x=n.keyBy(u,"pageType");P=Object.values(n.mapValues(x,(d,w)=>({...d,id:w,name:n.startCase(w),isPartialGroup:!0,children:p.filter(v=>v.pageType===w)})))}else P=u.sort((x,d)=>(x.name||"").localeCompare(d.name||""));return[...g,...P]},ue=R.atom({pageId:null,position:{x:0,y:0}}),me=({pageId:e,children:r})=>{const[a,s]=R.useAtom(ue),c=o.useRef(null),l=a.pageId===e;o.useEffect(()=>{const u=()=>s({pageId:null,position:{x:0,y:0}});if(l)return document.addEventListener("click",u),()=>document.removeEventListener("click",u)},[l,s]);const p=u=>{u.preventDefault(),u.stopPropagation(),s({pageId:e,position:{x:u.clientX,y:u.clientY}})},g=()=>{const u=`${window.location.pathname}?page=${e}`;window.open(u,"_blank"),s({pageId:null,position:{x:0,y:0}})};return t.jsxs(t.Fragment,{children:[t.jsx("span",{onContextMenu:p,children:r}),l&&t.jsx("div",{ref:c,className:"fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",style:{top:a.position.y,left:a.position.x},children:t.jsx("div",{className:"",children:t.jsxs(ie.Button,{variant:"ghost",onClick:g,className:"w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",children:[t.jsx(k.ExternalLink,{className:"h-4 w-4"}),"Open in new tab"]})})})]})},he=({page:e})=>{var s,c;const{isExpanded:r,toggleExpanded:a}=G.usePageExpandManager(e==null?void 0:e.id);return t.jsx("button",{onClick:l=>{l.stopPropagation(),a()},disabled:!((s=e==null?void 0:e.children)!=null&&s.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 ${(c=e==null?void 0:e.children)!=null&&c.length?"hover:text-blue-400":"opacity-0"}`,children:t.jsx(k.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${r?"rotate-90":""}`})})},xe=({page:e,pageType:r})=>t.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?t.jsx(k.StarsIcon,{size:12,className:"text-yellow-400"}):r!=null&&r.icon?t.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?t.jsx(k.File,{size:12,className:"stroke-[1] text-slate-500"}):t.jsx(k.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),fe=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),ye=({page:e,pageTypes:r,currentPage:a,onClickAction:s,languagePages:c,selectedLanguage:l,showUntranslatedPages:p})=>{const g=y.useUserId(),{pageToUser:u}=y.usePageToUser(),P=n.get(u,[e==null?void 0:e.id,"userId"]),{data:x}=y.useChaiUserInfo(P),d=x&&g!==P?x==null?void 0:x.name:null,w=y.useFallbackLang(),v=a===e.id,j=o.useMemo(()=>n.find(r,{key:e.pageType}),[r,e.pageType]);let m=n.get(c,e==null?void 0:e.id);m=n.get(m,"lang")===l?m:null;const E=l===w||!!m,A=(m==null?void 0:m.name)||(e==null?void 0:e.name)||"No name";let S=(m==null?void 0:m.slug)||(e==null?void 0:e.slug)||"";const $=S+(e!=null&&e.dynamic?`/${j==null?void 0:j.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(S.startsWith("/")&&!p){const f=S.split("/").pop();S=S.endsWith(f)&&e.dynamic?"":`/${f}`}const q=o.useMemo(()=>{const f="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]",C=`${v?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${f} ${C} ${d?"opacity-60":""}`:`${f} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,v,d]),I=o.useMemo(()=>{if(e.isPartialGroup)return!1;if(m){if(!m.online||n.isEmpty(m.changes))return!1}else if(e&&(!e.online||n.isEmpty(e.changes)))return!1;return!0},[m,e]);return t.jsxs("div",{className:"group relative",children:[t.jsx(me,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:q,children:[t.jsx(he,{page:e}),!e.isPartialGroup&&t.jsx(fe,{isOnline:m?m.online:e.online}),!e.isPartialGroup&&t.jsx(xe,{page:e,pageType:j}),t.jsx(y.Tooltip,{content:A,side:"top",showTooltip:A.length>35,children:t.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:A})}),(S||e.dynamic)&&t.jsx(y.Tooltip,{content:$,side:"top",showTooltip:!0,children:t.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[S,e.dynamic&&(j==null?void 0:j.dynamicSlug)&&t.jsxs("span",{className:"text-xs text-gray-500",children:["/",j==null?void 0:j.dynamicSlug,e.dynamicSlugCustom]})]})}),I&&t.jsx(y.Tooltip,{content:"Has unpublished changes",side:"top",children:t.jsx("span",{className:"text-amber-500",children:t.jsx(k.Pencil,{size:12,className:"stroke-[2]"})})}),!e.isPartialGroup&&E&&!d?t.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:t.jsx(y.PageActionsDropdown,{isLanguagePage:!!m,page:m||e,setDuplicatePage:f=>s("duplicate",f),setAddEditPage:f=>s("edit",m||f),setUnpublishPage:f=>s("unpublish",f),setDeletePage:f=>s("delete",m||f),children:t.jsx("div",{className:"m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white",children:t.jsx(k.MoreHorizontal,{className:"h-4 w-4",onClick:f=>f.stopPropagation()})})})}):d?t.jsxs("span",{className:"duration absolute right-1.5 top-1/2 flex -translate-y-1/2 items-center gap-x-1 text-xs text-red-500",children:[t.jsx(k.Lock,{className:"h-3 w-3 fill-red-200 text-red-500"}),t.jsx(y.Tooltip,{content:`${d} is editing this page`,children:t.jsx("span",{className:"font-bold",children:d})})]}):null]})}),t.jsx(t.Fragment,{children:!E&&!e.isPartialGroup&&!d&&t.jsxs("button",{onClick:f=>{f.stopPropagation(),s("addLanguagePage",{language:l,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:[t.jsx(k.Plus,{size:12,className:"stroke-[3]"})," ",t.jsxs("span",{className:"text-[10px]",children:["Add ",n.get(y.LANGUAGES,l)," Page"]})]})})]})},te=({pages:e,tier:r,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g})=>{const{expandedPages:u}=G.usePageExpandManager();return t.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${r*10}px`},children:e.map(P=>t.jsxs(t.Fragment,{children:[t.jsx(ye,{page:P,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g}),P.children&&P.children.length>0&&(u==null?void 0:u.includes(P.id))&&t.jsx(te,{pages:P.children,tier:r+1,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g})]},P.id))})},pe=o.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-D7AupT6_.cjs"))),Pe=o.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-B8NGK6WS.cjs"))),we=o.lazy(()=>Promise.resolve().then(()=>require("./delete-page-DLohaU-U.cjs"))),ge=o.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-D5Gtvqdv.cjs"))),je=o.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-B9yLcasI.cjs"))),be=o.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-F7TdgWjI.cjs"))),Se=o.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-CUr8Xub6.cjs"))),ve=({close:e})=>{const{t:r}=oe.useTranslation(),{languages:a,setSelectedLang:s}=K.useLanguages(),{data:c}=y.usePageTypes(),{data:l,isFetching:p}=y.useWebsitePrimaryPages(),[g,u]=y.useSearchParams(),{updateForSelectedPage:P,expandPagesOnSearch:x}=G.usePageExpandManager(null),d=y.useFallbackLang(),w=g.get("page"),[v,j]=o.useState(""),[m,E]=o.useState(null),[A,S]=o.useState(null),[$,q]=o.useState(null),[I,f]=o.useState(null),[C,z]=o.useState(""),[D,W]=o.useState(null),[H,_]=o.useState(null),[b,F]=o.useState(d),[se,ne]=o.useState(!1),V=R.useSetAtom(y.addNewLangAtom),U=se&&b!==d,{data:M,isFetching:re}=y.useWebsiteLanguagePages(b),Q=o.useCallback(h=>{var i;return(i=n.find(c,{key:h}))==null?void 0:i.hasSlug},[c]),N=o.useMemo(()=>l?U?n.filter(l,h=>!(M!=null&&M[h.id])):de(l,v,C,Q):[],[l,Q,v,C,M,U]);o.useEffect(()=>{s(d)},[d,s]),o.useEffect(()=>{const h=g.get("lang");if(h){const i=a,L=a[0]??d,T=i.includes(h);o.startTransition(()=>{T&&b!==h?F(h):!T&&b!==L&&F(L)})}},[]),o.useEffect(()=>{if(!n.isEmpty(C))return;const h=sessionStorage.getItem("pageTypeFilter")||"all";!n.isEmpty(c)&&h&&(n.find(c,{key:h})?z(h):z("all"))},[c,C]),o.useEffect(()=>{if(w&&!p&&!n.find(l,{id:w})){const i=new URLSearchParams(g.toString());if(i.delete("page"),[...i.keys()].length>0){if(typeof window<"u"&&window.history&&window.location){const L=i.toString(),T=window.location.hash||"",J=window.location.pathname,ae=L?`${J}?${L}${T}`:`${J}${T}`;window.history.replaceState(window.history.state,"",ae)}u(i)}else typeof window<"u"&&window.history&&window.location&&(window.history.replaceState(window.history.state,"",window.location.pathname+window.location.hash),window.dispatchEvent(new PopStateEvent("popstate",{state:window.history.state}))),u(i)}},[l,w,p,u]),o.useEffect(()=>{w&&!p&&!n.isEmpty(N)&&P(N,w)},[w,p,N,P]),o.useEffect(()=>{!n.isEmpty(v)&&!n.isEmpty(N)&&x(N)},[v,N,x]);const{setSelectedLang:B}=K.useLanguages(),X=o.useCallback(h=>{const i=new URLSearchParams({page:h});b!==d?(i.set("lang",b),B(b)):B(""),y.navigateToPage(i,u),e()},[e,u,B,b,d]),Y=(h,i)=>{var L;if(i)switch(h){case"add":S(i);break;case"select":X(i);break;case"edit":b!==d?V({edit:!0,id:i==null?void 0:i.id,primaryPage:i==null?void 0:i.primaryPage}):S(i);break;case"delete":E(i);break;case"unpublish":q(i);break;case"markAsTemplate":f(i);break;case"unmarkAsTemplate":_(i);break;case"duplicate":W(i);break;case"addLanguagePage":V({edit:!1,primaryPage:((L=i==null?void 0:i.page)==null?void 0:L.id)||"",preselectedLang:(i==null?void 0:i.language)||b});break}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-full flex-col justify-between",children:[t.jsx(o.Suspense,{children:t.jsx(pe,{pages:N,search:v,setSearch:j,languages:[d,...a],selectedLanguage:b,setSelectedLanguage:F,selectedPageType:C,setSelectedPageType:z,onAddPage:h=>Y("add",h),showUntranslatedPages:U,setShowUntranslatedPages:ne})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:p||re?t.jsx("div",{className:"space-y-2",children:n.map([...Array(15).keys()],h=>t.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},h))}):n.isEmpty(N)?t.jsxs("div",{className:"flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500",children:[t.jsx(k.File,{className:"h-6 w-6 stroke-[1]"}),r("Empty List!"),t.jsx("span",{className:"font-light",children:r("Add new page to start")})]}):t.jsx(te,{tier:0,pages:N,pageTypes:c,currentPage:w||"",onClickAction:Y,languagePages:M,selectedLanguage:b,showUntranslatedPages:U})})]}),A&&t.jsx(o.Suspense,{children:t.jsx(Pe,{closePanel:e,editPage:X,addEditPage:A,setAddEditPage:S})}),m&&t.jsx(o.Suspense,{children:t.jsx(we,{page:m,onClose:()=>E(null)})}),$&&t.jsx(o.Suspense,{children:t.jsx(Se,{page:$,onClose:()=>q(null)})}),I&&t.jsx(o.Suspense,{children:t.jsx(je,{page:I,onClose:()=>f(null)})}),H&&t.jsx(o.Suspense,{children:t.jsx(be,{page:H,onClose:()=>_(null)})}),D&&t.jsx(o.Suspense,{children:t.jsx(ge,{page:D,onClose:()=>W(null),closePanel:e})})]})};exports.default=ve;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),G=require("jotai"),n=require("lodash-es"),k=require("lucide-react"),o=require("react"),oe=require("react-i18next"),K=require("./index-D-r_K4yA.cjs"),y=require("./index-BYrRPW_c.cjs"),R=require("./use-page-expand-manager-B6XTvk0E.cjs"),ie=require("./register-chai-top-bar-CCssW5dL.cjs"),Z=(e,r)=>!e||!Array.isArray(e)?[]:n.isEmpty(r)?e:n.compact(n.filter(e,a=>{const s=n.toLower(r);return n.includes(n.toLower((a==null?void 0:a.name)||""),s)||n.includes(n.toLower((a==null?void 0:a.slug)||""),s)})),le=(e,r)=>{const a=new Set,s=n.keyBy(e,"id");return r.forEach(c=>{let l=c;for(;l.parent&&s[l.parent];)a.add(l.parent),l=s[l.parent]}),Array.from(a).map(c=>s[c])},O=(e,r,a)=>n.isEmpty(r)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?O(s.children,r,a):[]};const c=s.children&&s.children.some(l=>n.includes(n.toLower(l.name||""),n.toLower(r))||n.includes(n.toLower(l.slug||""),n.toLower(r)));return{...s,shouldExpandOnSearch:c,children:s.children?O(s.children,r,a):[]}}),ce=e=>{if(!e||!e.length)return[];const r={};e.forEach(s=>{r[s.id]={...s,children:[]}});const a=[];return Object.values(r).forEach(s=>{s.parent&&r[s.parent]?r[s.parent].children.push(s):a.push(s)}),a},ee=e=>!e||!e.length?[]:[...e].sort((a,s)=>(a.name||"").localeCompare(s.name||"")).map(a=>({...a,children:a.children?ee(a.children):[]})),de=(e,r,a,s)=>{if(!e||!e.length)return[];let c=e;if(a!=="all"&&(c=n.compact(n.filter(e,{pageType:a}))),n.isEmpty(r))c=Z(c,r);else{const x=Z(c,r),d=le(e,x);c=n.uniqBy([...x,...d],"id")}const l=ee(ce(c)),p=O(l,r,s),g=n.filter(p,x=>s(x.pageType)).sort((x,d)=>(x.name||"").localeCompare(d.name||"")),u=n.filter(p,x=>!s(x.pageType));let P=[];if(a==="all"){const x=n.keyBy(u,"pageType");P=Object.values(n.mapValues(x,(d,w)=>({...d,id:w,name:n.startCase(w),isPartialGroup:!0,children:p.filter(v=>v.pageType===w)})))}else P=u.sort((x,d)=>(x.name||"").localeCompare(d.name||""));return[...g,...P]},ue=G.atom({pageId:null,position:{x:0,y:0}}),me=({pageId:e,children:r})=>{const[a,s]=G.useAtom(ue),c=o.useRef(null),l=a.pageId===e;o.useEffect(()=>{const u=()=>s({pageId:null,position:{x:0,y:0}});if(l)return document.addEventListener("click",u),()=>document.removeEventListener("click",u)},[l,s]);const p=u=>{u.preventDefault(),u.stopPropagation(),s({pageId:e,position:{x:u.clientX,y:u.clientY}})},g=()=>{const u=`${window.location.pathname}?page=${e}`;window.open(u,"_blank"),s({pageId:null,position:{x:0,y:0}})};return t.jsxs(t.Fragment,{children:[t.jsx("span",{onContextMenu:p,children:r}),l&&t.jsx("div",{ref:c,className:"fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",style:{top:a.position.y,left:a.position.x},children:t.jsx("div",{className:"",children:t.jsxs(ie.Button,{variant:"ghost",onClick:g,className:"w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",children:[t.jsx(k.ExternalLink,{className:"h-4 w-4"}),"Open in new tab"]})})})]})},he=({page:e})=>{var s,c;const{isExpanded:r,toggleExpanded:a}=R.usePageExpandManager(e==null?void 0:e.id);return t.jsx("button",{onClick:l=>{l.stopPropagation(),a()},disabled:!((s=e==null?void 0:e.children)!=null&&s.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 ${(c=e==null?void 0:e.children)!=null&&c.length?"hover:text-blue-400":"opacity-0"}`,children:t.jsx(k.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${r?"rotate-90":""}`})})},xe=({page:e,pageType:r})=>t.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?t.jsx(k.StarsIcon,{size:12,className:"text-yellow-400"}):r!=null&&r.icon?t.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?t.jsx(k.File,{size:12,className:"stroke-[1] text-slate-500"}):t.jsx(k.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),fe=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),ye=({page:e,pageTypes:r,currentPage:a,onClickAction:s,languagePages:c,selectedLanguage:l,showUntranslatedPages:p})=>{const g=y.useUserId(),{pageToUser:u}=y.usePageToUser(),P=n.get(u,[e==null?void 0:e.id,"userId"]),{data:x}=y.useChaiUserInfo(P),d=x&&g!==P?x==null?void 0:x.name:null,w=y.useFallbackLang(),v=a===e.id,j=o.useMemo(()=>n.find(r,{key:e.pageType}),[r,e.pageType]);let m=n.get(c,e==null?void 0:e.id);m=n.get(m,"lang")===l?m:null;const E=l===w||!!m,A=(m==null?void 0:m.name)||(e==null?void 0:e.name)||"No name";let S=(m==null?void 0:m.slug)||(e==null?void 0:e.slug)||"";const $=S+(e!=null&&e.dynamic?`/${j==null?void 0:j.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(S.startsWith("/")&&!p){const f=S.split("/").pop();S=S.endsWith(f)&&e.dynamic?"":`/${f}`}const q=o.useMemo(()=>{const f="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]",C=`${v?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${f} ${C} ${d?"opacity-60":""}`:`${f} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,v,d]),I=o.useMemo(()=>{if(e.isPartialGroup)return!1;if(m){if(!m.online||n.isEmpty(m.changes))return!1}else if(e&&(!e.online||n.isEmpty(e.changes)))return!1;return!0},[m,e]);return t.jsxs("div",{className:"group relative",children:[t.jsx(me,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:q,children:[t.jsx(he,{page:e}),!e.isPartialGroup&&t.jsx(fe,{isOnline:m?m.online:e.online}),!e.isPartialGroup&&t.jsx(xe,{page:e,pageType:j}),t.jsx(y.Tooltip,{content:A,side:"top",showTooltip:A.length>35,children:t.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:A})}),(S||e.dynamic)&&t.jsx(y.Tooltip,{content:$,side:"top",showTooltip:!0,children:t.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[S,e.dynamic&&(j==null?void 0:j.dynamicSlug)&&t.jsxs("span",{className:"text-xs text-gray-500",children:["/",j==null?void 0:j.dynamicSlug,e.dynamicSlugCustom]})]})}),I&&t.jsx(y.Tooltip,{content:"Has unpublished changes",side:"top",children:t.jsx("span",{className:"text-amber-500",children:t.jsx(k.Pencil,{size:12,className:"stroke-[2]"})})}),!e.isPartialGroup&&E&&!d?t.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:t.jsx(y.PageActionsDropdown,{isLanguagePage:!!m,page:m||e,setDuplicatePage:f=>s("duplicate",f),setAddEditPage:f=>s("edit",m||f),setUnpublishPage:f=>s("unpublish",f),setDeletePage:f=>s("delete",m||f),children:t.jsx("div",{className:"m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white",children:t.jsx(k.MoreHorizontal,{className:"h-4 w-4",onClick:f=>f.stopPropagation()})})})}):d?t.jsxs("span",{className:"duration absolute right-1.5 top-1/2 flex -translate-y-1/2 items-center gap-x-1 text-xs text-red-500",children:[t.jsx(k.Lock,{className:"h-3 w-3 fill-red-200 text-red-500"}),t.jsx(y.Tooltip,{content:`${d} is editing this page`,children:t.jsx("span",{className:"font-bold",children:d})})]}):null]})}),t.jsx(t.Fragment,{children:!E&&!e.isPartialGroup&&!d&&t.jsxs("button",{onClick:f=>{f.stopPropagation(),s("addLanguagePage",{language:l,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:[t.jsx(k.Plus,{size:12,className:"stroke-[3]"})," ",t.jsxs("span",{className:"text-[10px]",children:["Add ",n.get(y.LANGUAGES,l)," Page"]})]})})]})},te=({pages:e,tier:r,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g})=>{const{expandedPages:u}=R.usePageExpandManager();return t.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${r*10}px`},children:e.map(P=>t.jsxs(t.Fragment,{children:[t.jsx(ye,{page:P,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g}),P.children&&P.children.length>0&&(u==null?void 0:u.includes(P.id))&&t.jsx(te,{pages:P.children,tier:r+1,pageTypes:a,currentPage:s,onClickAction:c,languagePages:l,selectedLanguage:p,showUntranslatedPages:g})]},P.id))})},pe=o.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-BbdgOU9V.cjs"))),Pe=o.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-CnuChfJz.cjs"))),we=o.lazy(()=>Promise.resolve().then(()=>require("./delete-page-YP1HEAoD.cjs"))),ge=o.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-CxqW_EO7.cjs"))),je=o.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-DyB56HzI.cjs"))),be=o.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-CZ65AE4v.cjs"))),Se=o.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-B46TiWlU.cjs"))),ve=({close:e})=>{const{t:r}=oe.useTranslation(),{languages:a,setSelectedLang:s}=K.useLanguages(),{data:c}=y.usePageTypes(),{data:l,isFetching:p}=y.useWebsitePrimaryPages(),[g,u]=y.useSearchParams(),{updateForSelectedPage:P,expandPagesOnSearch:x}=R.usePageExpandManager(null),d=y.useFallbackLang(),w=g.get("page"),[v,j]=o.useState(""),[m,E]=o.useState(null),[A,S]=o.useState(null),[$,q]=o.useState(null),[I,f]=o.useState(null),[C,z]=o.useState(""),[D,W]=o.useState(null),[H,_]=o.useState(null),[b,F]=o.useState(d),[se,ne]=o.useState(!1),V=G.useSetAtom(y.addNewLangAtom),U=se&&b!==d,{data:M,isFetching:re}=y.useWebsiteLanguagePages(b),Q=o.useCallback(h=>{var i;return(i=n.find(c,{key:h}))==null?void 0:i.hasSlug},[c]),N=o.useMemo(()=>l?U?n.filter(l,h=>!(M!=null&&M[h.id])):de(l,v,C,Q):[],[l,Q,v,C,M,U]);o.useEffect(()=>{s(d)},[d,s]),o.useEffect(()=>{const h=g.get("lang");if(h){const i=a,L=a[0]??d,T=i.includes(h);o.startTransition(()=>{T&&b!==h?F(h):!T&&b!==L&&F(L)})}},[]),o.useEffect(()=>{if(!n.isEmpty(C))return;const h=sessionStorage.getItem("pageTypeFilter")||"all";!n.isEmpty(c)&&h&&(n.find(c,{key:h})?z(h):z("all"))},[c,C]),o.useEffect(()=>{if(w&&!p&&!n.find(l,{id:w})){const i=new URLSearchParams(g.toString());if(i.delete("page"),[...i.keys()].length>0){if(typeof window<"u"&&window.history&&window.location){const L=i.toString(),T=window.location.hash||"",J=window.location.pathname,ae=L?`${J}?${L}${T}`:`${J}${T}`;window.history.replaceState(window.history.state,"",ae)}u(i)}else typeof window<"u"&&window.history&&window.location&&(window.history.replaceState(window.history.state,"",window.location.pathname+window.location.hash),window.dispatchEvent(new PopStateEvent("popstate",{state:window.history.state}))),u(i)}},[l,w,p,u]),o.useEffect(()=>{w&&!p&&!n.isEmpty(N)&&P(N,w)},[w,p,N,P]),o.useEffect(()=>{!n.isEmpty(v)&&!n.isEmpty(N)&&x(N)},[v,N,x]);const{setSelectedLang:B}=K.useLanguages(),X=o.useCallback(h=>{const i=new URLSearchParams({page:h});b!==d?(i.set("lang",b),B(b)):B(""),y.navigateToPage(i,u),e()},[e,u,B,b,d]),Y=(h,i)=>{var L;if(i)switch(h){case"add":S(i);break;case"select":X(i);break;case"edit":b!==d?V({edit:!0,id:i==null?void 0:i.id,primaryPage:i==null?void 0:i.primaryPage}):S(i);break;case"delete":E(i);break;case"unpublish":q(i);break;case"markAsTemplate":f(i);break;case"unmarkAsTemplate":_(i);break;case"duplicate":W(i);break;case"addLanguagePage":V({edit:!1,primaryPage:((L=i==null?void 0:i.page)==null?void 0:L.id)||"",preselectedLang:(i==null?void 0:i.language)||b});break}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-full flex-col justify-between",children:[t.jsx(o.Suspense,{children:t.jsx(pe,{pages:N,search:v,setSearch:j,languages:[d,...a],selectedLanguage:b,setSelectedLanguage:F,selectedPageType:C,setSelectedPageType:z,onAddPage:h=>Y("add",h),showUntranslatedPages:U,setShowUntranslatedPages:ne})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:p||re?t.jsx("div",{className:"space-y-2",children:n.map([...Array(15).keys()],h=>t.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},h))}):n.isEmpty(N)?t.jsxs("div",{className:"flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500",children:[t.jsx(k.File,{className:"h-6 w-6 stroke-[1]"}),r("Empty List!"),t.jsx("span",{className:"font-light",children:r("Add new page to start")})]}):t.jsx(te,{tier:0,pages:N,pageTypes:c,currentPage:w||"",onClickAction:Y,languagePages:M,selectedLanguage:b,showUntranslatedPages:U})})]}),A&&t.jsx(o.Suspense,{children:t.jsx(Pe,{closePanel:e,editPage:X,addEditPage:A,setAddEditPage:S})}),m&&t.jsx(o.Suspense,{children:t.jsx(we,{page:m,onClose:()=>E(null)})}),$&&t.jsx(o.Suspense,{children:t.jsx(Se,{page:$,onClose:()=>q(null)})}),I&&t.jsx(o.Suspense,{children:t.jsx(je,{page:I,onClose:()=>f(null)})}),H&&t.jsx(o.Suspense,{children:t.jsx(be,{page:H,onClose:()=>_(null)})}),D&&t.jsx(o.Suspense,{children:t.jsx(ge,{page:D,onClose:()=>W(null),closePanel:e})})]})};exports.default=ve;
@@ -1,20 +1,20 @@
1
1
  import { jsxs as w, Fragment as q, jsx as t } from "react/jsx-runtime";
2
- import { d as ie } from "./index-OuHV9Ann.js";
3
- import { aA as be, aB as ge, ao as ke, i as de, T as D, aR as ve, L as Ne, k as Se, e as Le, c as Ce, au as Ae, aS as Ee, aT as $e } from "./index-LBTm1Jmk.js";
2
+ import { atom as be, useAtom as ge, useSetAtom as ke } from "jotai";
3
+ import { compact as de, filter as z, isEmpty as k, uniqBy as ve, keyBy as ue, mapValues as Ne, startCase as Se, toLower as T, includes as _, get as D, find as H, map as Le } from "lodash-es";
4
+ import { ExternalLink as Ce, Pencil as Ae, MoreHorizontal as Ee, Lock as $e, Plus as Te, ChevronRight as Ie, StarsIcon as Me, Hash as Ue, File as me } from "lucide-react";
5
+ import { useRef as Fe, useEffect as $, useMemo as W, useState as N, useCallback as ie, startTransition as ze, Suspense as E, lazy as I } from "react";
6
+ import { useTranslation as Be } from "react-i18next";
7
+ import { d as le } from "./index-DPV6NiJ-.js";
8
+ import { am as Ge, an as Oe, ao as je, f as he, T as R, aF as De, L as Re, h as He, b as We, u as _e, aG as qe, aH as Ve, aI as Qe } from "./index-DqzFD1CG.js";
4
9
  import { u as J } from "./use-page-expand-manager-Cf4MUEJw.js";
5
- import { compact as ue, filter as F, isEmpty as k, uniqBy as Te, keyBy as me, mapValues as Me, startCase as Ue, toLower as T, includes as _, get as R, find as W, map as Ie } from "lodash-es";
6
- import { atom as Be, useAtom as Fe, useSetAtom as ze } from "jotai";
7
- import { ExternalLink as Oe, Pencil as je, MoreHorizontal as Ge, Lock as De, Plus as Re, ChevronRight as We, StarsIcon as He, Hash as _e, File as he } from "lucide-react";
8
- import { useRef as qe, useEffect as $, useMemo as H, useState as N, useCallback as le, startTransition as Ve, Suspense as E, lazy as M } from "react";
9
- import { useTranslation as Qe } from "react-i18next";
10
- import { B as Xe } from "./register-chai-top-bar-D6GjnauV.js";
11
- const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
12
- F(e, (a) => {
10
+ import { B as Xe } from "./register-chai-top-bar-DWmJ2efT.js";
11
+ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : de(
12
+ z(e, (a) => {
13
13
  const n = T(s);
14
14
  return _(T((a == null ? void 0 : a.name) || ""), n) || _(T((a == null ? void 0 : a.slug) || ""), n);
15
15
  })
16
16
  ), Ye = (e, s) => {
17
- const a = /* @__PURE__ */ new Set(), n = me(e, "id");
17
+ const a = /* @__PURE__ */ new Set(), n = ue(e, "id");
18
18
  return s.forEach((i) => {
19
19
  let o = i;
20
20
  for (; o.parent && n[o.parent]; )
@@ -51,23 +51,23 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
51
51
  })), Ke = (e, s, a, n) => {
52
52
  if (!e || !e.length) return [];
53
53
  let i = e;
54
- if (a !== "all" && (i = ue(F(e, { pageType: a }))), k(s))
54
+ if (a !== "all" && (i = de(z(e, { pageType: a }))), k(s))
55
55
  i = ce(i, s);
56
56
  else {
57
57
  const m = ce(i, s), l = Ye(e, m);
58
- i = Te([...m, ...l], "id");
58
+ i = ve([...m, ...l], "id");
59
59
  }
60
- const o = fe(Je(i)), f = Y(o, s, n), y = F(f, (m) => n(m.pageType)).sort(
60
+ const o = fe(Je(i)), f = Y(o, s, n), y = z(f, (m) => n(m.pageType)).sort(
61
61
  (m, l) => (m.name || "").localeCompare(l.name || "")
62
- ), c = F(f, (m) => !n(m.pageType));
62
+ ), c = z(f, (m) => !n(m.pageType));
63
63
  let x = [];
64
64
  if (a === "all") {
65
- const m = me(c, "pageType");
65
+ const m = ue(c, "pageType");
66
66
  x = Object.values(
67
- Me(m, (l, p) => ({
67
+ Ne(m, (l, p) => ({
68
68
  ...l,
69
69
  id: p,
70
- name: Ue(p),
70
+ name: Se(p),
71
71
  isPartialGroup: !0,
72
72
  children: f.filter((v) => v.pageType === p)
73
73
  }))
@@ -75,11 +75,11 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
75
75
  } else
76
76
  x = c.sort((m, l) => (m.name || "").localeCompare(l.name || ""));
77
77
  return [...y, ...x];
78
- }, Ze = Be({
78
+ }, Ze = be({
79
79
  pageId: null,
80
80
  position: { x: 0, y: 0 }
81
81
  }), et = ({ pageId: e, children: s }) => {
82
- const [a, n] = Fe(Ze), i = qe(null), o = a.pageId === e;
82
+ const [a, n] = ge(Ze), i = Fe(null), o = a.pageId === e;
83
83
  $(() => {
84
84
  const c = () => n({ pageId: null, position: { x: 0, y: 0 } });
85
85
  if (o)
@@ -106,7 +106,7 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
106
106
  onClick: y,
107
107
  className: "w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",
108
108
  children: [
109
- /* @__PURE__ */ t(Oe, { className: "h-4 w-4" }),
109
+ /* @__PURE__ */ t(Ce, { className: "h-4 w-4" }),
110
110
  "Open in new tab"
111
111
  ]
112
112
  }
@@ -126,7 +126,7 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
126
126
  disabled: !((n = e == null ? void 0 : e.children) != null && n.length),
127
127
  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 ${(i = e == null ? void 0 : e.children) != null && i.length ? "hover:text-blue-400" : "opacity-0"}`,
128
128
  children: /* @__PURE__ */ t(
129
- We,
129
+ Ie,
130
130
  {
131
131
  size: 12,
132
132
  className: `stroke-[4] transition-transform duration-200 ${s ? "rotate-90" : ""}`
@@ -134,13 +134,13 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
134
134
  )
135
135
  }
136
136
  );
137
- }, nt = ({ page: e, pageType: s }) => /* @__PURE__ */ t("div", { className: "flex h-full items-center justify-center gap-x-1", children: e.dynamic ? /* @__PURE__ */ t(He, { size: 12, className: "text-yellow-400" }) : s != null && s.icon ? /* @__PURE__ */ t(
137
+ }, nt = ({ page: e, pageType: s }) => /* @__PURE__ */ t("div", { className: "flex h-full items-center justify-center gap-x-1", children: e.dynamic ? /* @__PURE__ */ t(Me, { size: 12, className: "text-yellow-400" }) : s != null && s.icon ? /* @__PURE__ */ t(
138
138
  "div",
139
139
  {
140
140
  className: "flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",
141
141
  dangerouslySetInnerHTML: { __html: s.icon }
142
142
  }
143
- ) : s != null && s.hasSlug ? /* @__PURE__ */ t(he, { size: 12, className: "stroke-[1] text-slate-500" }) : /* @__PURE__ */ t(_e, { size: 12, className: "stroke-[1] text-slate-500" }) }), st = ({ isOnline: e }) => /* @__PURE__ */ t("div", { className: `h-2 w-2 rounded-full ${e ? "bg-green-300" : "bg-gray-300"}` }), at = ({
143
+ ) : s != null && s.hasSlug ? /* @__PURE__ */ t(me, { size: 12, className: "stroke-[1] text-slate-500" }) : /* @__PURE__ */ t(Ue, { size: 12, className: "stroke-[1] text-slate-500" }) }), st = ({ isOnline: e }) => /* @__PURE__ */ t("div", { className: `h-2 w-2 rounded-full ${e ? "bg-green-300" : "bg-gray-300"}` }), at = ({
144
144
  page: e,
145
145
  pageTypes: s,
146
146
  currentPage: a,
@@ -149,20 +149,20 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
149
149
  selectedLanguage: o,
150
150
  showUntranslatedPages: f
151
151
  }) => {
152
- const y = be(), { pageToUser: c } = ge(), x = R(c, [e == null ? void 0 : e.id, "userId"]), { data: m } = ke(x), l = m && y !== x ? m == null ? void 0 : m.name : null, p = de(), v = a === e.id, P = H(() => W(s, { key: e.pageType }), [s, e.pageType]);
153
- let d = R(i, e == null ? void 0 : e.id);
154
- d = R(d, "lang") === o ? d : null;
155
- const L = o === p || !!d, U = (d == null ? void 0 : d.name) || (e == null ? void 0 : e.name) || "No name";
152
+ const y = Ge(), { pageToUser: c } = Oe(), x = D(c, [e == null ? void 0 : e.id, "userId"]), { data: m } = je(x), l = m && y !== x ? m == null ? void 0 : m.name : null, p = he(), v = a === e.id, P = W(() => H(s, { key: e.pageType }), [s, e.pageType]);
153
+ let d = D(i, e == null ? void 0 : e.id);
154
+ d = D(d, "lang") === o ? d : null;
155
+ const L = o === p || !!d, M = (d == null ? void 0 : d.name) || (e == null ? void 0 : e.name) || "No name";
156
156
  let g = (d == null ? void 0 : d.slug) || (e == null ? void 0 : e.slug) || "";
157
- const z = g + (e != null && e.dynamic ? `/${P == null ? void 0 : P.dynamicSlug}` : "") + (e != null && e.dynamicSlugCustom ? `${e.dynamicSlugCustom}` : "");
157
+ const B = g + (e != null && e.dynamic ? `/${P == null ? void 0 : P.dynamicSlug}` : "") + (e != null && e.dynamicSlugCustom ? `${e.dynamicSlugCustom}` : "");
158
158
  if (g.startsWith("/") && !f) {
159
159
  const h = g.split("/").pop();
160
160
  g = g.endsWith(h) && e.dynamic ? "" : `/${h}`;
161
161
  }
162
- const O = H(() => {
162
+ const G = W(() => {
163
163
  const h = "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]", A = `${v ? "border-primary/30 bg-primary/5" : "border-transparent hover:border-gray-200 hover:bg-gray-100"}`;
164
164
  return L ? `${h} ${A} ${l ? "opacity-60" : ""}` : `${h} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`;
165
- }, [L, v, l]), j = H(() => {
165
+ }, [L, v, l]), O = W(() => {
166
166
  if (e.isPartialGroup) return !1;
167
167
  if (d) {
168
168
  if (!d.online || k(d.changes)) return !1;
@@ -175,13 +175,13 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
175
175
  "div",
176
176
  {
177
177
  onClick: () => !e.isPartialGroup && L && n("select", e == null ? void 0 : e.id),
178
- className: O,
178
+ className: G,
179
179
  children: [
180
180
  /* @__PURE__ */ t(tt, { page: e }),
181
181
  !e.isPartialGroup && /* @__PURE__ */ t(st, { isOnline: d ? d.online : e.online }),
182
182
  !e.isPartialGroup && /* @__PURE__ */ t(nt, { page: e, pageType: P }),
183
- /* @__PURE__ */ t(D, { content: U, side: "top", showTooltip: U.length > 35, children: /* @__PURE__ */ t("span", { className: "max-w-[40%] truncate font-medium text-black", children: U }) }),
184
- (g || e.dynamic) && /* @__PURE__ */ t(D, { content: z, side: "top", showTooltip: !0, children: /* @__PURE__ */ w("span", { className: "max-w-[40%] truncate font-mono text-xs text-muted-foreground", children: [
183
+ /* @__PURE__ */ t(R, { content: M, side: "top", showTooltip: M.length > 35, children: /* @__PURE__ */ t("span", { className: "max-w-[40%] truncate font-medium text-black", children: M }) }),
184
+ (g || e.dynamic) && /* @__PURE__ */ t(R, { content: B, side: "top", showTooltip: !0, children: /* @__PURE__ */ w("span", { className: "max-w-[40%] truncate font-mono text-xs text-muted-foreground", children: [
185
185
  g,
186
186
  e.dynamic && (P == null ? void 0 : P.dynamicSlug) && /* @__PURE__ */ w("span", { className: "text-xs text-gray-500", children: [
187
187
  "/",
@@ -189,9 +189,9 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
189
189
  e.dynamicSlugCustom
190
190
  ] })
191
191
  ] }) }),
192
- j && /* @__PURE__ */ t(D, { content: "Has unpublished changes", side: "top", children: /* @__PURE__ */ t("span", { className: "text-amber-500", children: /* @__PURE__ */ t(je, { size: 12, className: "stroke-[2]" }) }) }),
192
+ O && /* @__PURE__ */ t(R, { content: "Has unpublished changes", side: "top", children: /* @__PURE__ */ t("span", { className: "text-amber-500", children: /* @__PURE__ */ t(Ae, { size: 12, className: "stroke-[2]" }) }) }),
193
193
  !e.isPartialGroup && L && !l ? /* @__PURE__ */ t("div", { className: "duration absolute right-0.5 top-[3px]", children: /* @__PURE__ */ t(
194
- ve,
194
+ De,
195
195
  {
196
196
  isLanguagePage: !!d,
197
197
  page: d || e,
@@ -199,11 +199,11 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
199
199
  setAddEditPage: (h) => n("edit", d || h),
200
200
  setUnpublishPage: (h) => n("unpublish", h),
201
201
  setDeletePage: (h) => n("delete", d || h),
202
- children: /* @__PURE__ */ t("div", { className: "m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white", children: /* @__PURE__ */ t(Ge, { className: "h-4 w-4", onClick: (h) => h.stopPropagation() }) })
202
+ children: /* @__PURE__ */ t("div", { className: "m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white", children: /* @__PURE__ */ t(Ee, { className: "h-4 w-4", onClick: (h) => h.stopPropagation() }) })
203
203
  }
204
204
  ) }) : l ? /* @__PURE__ */ w("span", { className: "duration absolute right-1.5 top-1/2 flex -translate-y-1/2 items-center gap-x-1 text-xs text-red-500", children: [
205
- /* @__PURE__ */ t(De, { className: "h-3 w-3 fill-red-200 text-red-500" }),
206
- /* @__PURE__ */ t(D, { content: `${l} is editing this page`, children: /* @__PURE__ */ t("span", { className: "font-bold", children: l }) })
205
+ /* @__PURE__ */ t($e, { className: "h-3 w-3 fill-red-200 text-red-500" }),
206
+ /* @__PURE__ */ t(R, { content: `${l} is editing this page`, children: /* @__PURE__ */ t("span", { className: "font-bold", children: l }) })
207
207
  ] }) : null
208
208
  ]
209
209
  }
@@ -216,11 +216,11 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
216
216
  },
217
217
  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",
218
218
  children: [
219
- /* @__PURE__ */ t(Re, { size: 12, className: "stroke-[3]" }),
219
+ /* @__PURE__ */ t(Te, { size: 12, className: "stroke-[3]" }),
220
220
  " ",
221
221
  /* @__PURE__ */ w("span", { className: "text-[10px]", children: [
222
222
  "Add ",
223
- R(Ne, o),
223
+ D(Re, o),
224
224
  " Page"
225
225
  ] })
226
226
  ]
@@ -265,34 +265,34 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
265
265
  }
266
266
  )
267
267
  ] }, x.id)) });
268
- }, rt = M(() => import("./page-manager-search-and-filter-bsqZ6wnI.js")), ot = M(() => import("./add-new-page-Ppy5-y5j.js")), it = M(() => import("./delete-page-C99K2qzS.js")), lt = M(() => import("./duplicate-page-CDc2X0eW.js")), ct = M(() => import("./mark-as-template-CP_F9ZQ4.js")), dt = M(() => import("./unmark-as-template-C5ovsEBP.js")), ut = M(() => import("./unpublish-page-0fR1o0b7.js")), kt = ({ close: e }) => {
269
- const { t: s } = Qe(), { languages: a, setSelectedLang: n } = ie(), { data: i } = Se(), { data: o, isFetching: f } = Le(), [y, c] = Ce(), { updateForSelectedPage: x, expandPagesOnSearch: m } = J(null), l = de(), p = y.get("page"), [v, P] = N(""), [d, L] = N(null), [U, g] = N(null), [z, O] = N(null), [j, h] = N(null), [A, V] = N(""), [K, Z] = N(null), [ee, te] = N(null), [b, Q] = N(l), [pe, we] = N(!1), ne = ze(Ae), G = pe && b !== l, { data: I, isFetching: ye } = Ee(b), se = le(
268
+ }, rt = I(() => import("./page-manager-search-and-filter-Cllju4CV.js")), ot = I(() => import("./add-new-page-DanzzvYo.js")), it = I(() => import("./delete-page-DbawNFf7.js")), lt = I(() => import("./duplicate-page-DnRb1y6K.js")), ct = I(() => import("./mark-as-template-D7jqSCXw.js")), dt = I(() => import("./unmark-as-template-DvmoTbVu.js")), ut = I(() => import("./unpublish-page-3--vO5b0.js")), kt = ({ close: e }) => {
269
+ const { t: s } = Be(), { languages: a, setSelectedLang: n } = le(), { data: i } = He(), { data: o, isFetching: f } = We(), [y, c] = _e(), { updateForSelectedPage: x, expandPagesOnSearch: m } = J(null), l = he(), p = y.get("page"), [v, P] = N(""), [d, L] = N(null), [M, g] = N(null), [B, G] = N(null), [O, h] = N(null), [A, V] = N(""), [K, Z] = N(null), [ee, te] = N(null), [b, Q] = N(l), [pe, we] = N(!1), ne = ke(qe), j = pe && b !== l, { data: U, isFetching: ye } = Ve(b), se = ie(
270
270
  (u) => {
271
271
  var r;
272
- return (r = W(i, { key: u })) == null ? void 0 : r.hasSlug;
272
+ return (r = H(i, { key: u })) == null ? void 0 : r.hasSlug;
273
273
  },
274
274
  [i]
275
- ), S = H(() => o ? G ? F(o, (u) => !(I != null && I[u.id])) : Ke(o, v, A, se) : [], [o, se, v, A, I, G]);
275
+ ), S = W(() => o ? j ? z(o, (u) => !(U != null && U[u.id])) : Ke(o, v, A, se) : [], [o, se, v, A, U, j]);
276
276
  $(() => {
277
277
  n(l);
278
278
  }, [l, n]), $(() => {
279
279
  const u = y.get("lang");
280
280
  if (u) {
281
- const r = a, C = a[0] ?? l, B = r.includes(u);
282
- Ve(() => {
283
- B && b !== u ? Q(u) : !B && b !== C && Q(C);
281
+ const r = a, C = a[0] ?? l, F = r.includes(u);
282
+ ze(() => {
283
+ F && b !== u ? Q(u) : !F && b !== C && Q(C);
284
284
  });
285
285
  }
286
286
  }, []), $(() => {
287
287
  if (!k(A)) return;
288
288
  const u = sessionStorage.getItem("pageTypeFilter") || "all";
289
- !k(i) && u && (W(i, { key: u }) ? V(u) : V("all"));
289
+ !k(i) && u && (H(i, { key: u }) ? V(u) : V("all"));
290
290
  }, [i, A]), $(() => {
291
- if (p && !f && !W(o, { id: p })) {
291
+ if (p && !f && !H(o, { id: p })) {
292
292
  const r = new URLSearchParams(y.toString());
293
293
  if (r.delete("page"), [...r.keys()].length > 0) {
294
294
  if (typeof window < "u" && window.history && window.location) {
295
- const C = r.toString(), B = window.location.hash || "", oe = window.location.pathname, Pe = C ? `${oe}?${C}${B}` : `${oe}${B}`;
295
+ const C = r.toString(), F = window.location.hash || "", oe = window.location.pathname, Pe = C ? `${oe}?${C}${F}` : `${oe}${F}`;
296
296
  window.history.replaceState(window.history.state, "", Pe);
297
297
  }
298
298
  c(r);
@@ -304,10 +304,10 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
304
304
  }, [p, f, S, x]), $(() => {
305
305
  !k(v) && !k(S) && m(S);
306
306
  }, [v, S, m]);
307
- const { setSelectedLang: X } = ie(), ae = le(
307
+ const { setSelectedLang: X } = le(), ae = ie(
308
308
  (u) => {
309
309
  const r = new URLSearchParams({ page: u });
310
- b !== l ? (r.set("lang", b), X(b)) : X(""), $e(r, c), e();
310
+ b !== l ? (r.set("lang", b), X(b)) : X(""), Qe(r, c), e();
311
311
  },
312
312
  [e, c, X, b, l]
313
313
  ), re = (u, r) => {
@@ -331,7 +331,7 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
331
331
  L(r);
332
332
  break;
333
333
  case "unpublish":
334
- O(r);
334
+ G(r);
335
335
  break;
336
336
  case "markAsTemplate":
337
337
  h(r);
@@ -365,12 +365,12 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
365
365
  selectedPageType: A,
366
366
  setSelectedPageType: V,
367
367
  onAddPage: (u) => re("add", u),
368
- showUntranslatedPages: G,
368
+ showUntranslatedPages: j,
369
369
  setShowUntranslatedPages: we
370
370
  }
371
371
  ) }),
372
- /* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto px-4 pb-6 pt-2", children: f || ye ? /* @__PURE__ */ t("div", { className: "space-y-2", children: Ie([...Array(15).keys()], (u) => /* @__PURE__ */ t("div", { className: "h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200" }, u)) }) : k(S) ? /* @__PURE__ */ w("div", { className: "flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500", children: [
373
- /* @__PURE__ */ t(he, { className: "h-6 w-6 stroke-[1]" }),
372
+ /* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto px-4 pb-6 pt-2", children: f || ye ? /* @__PURE__ */ t("div", { className: "space-y-2", children: Le([...Array(15).keys()], (u) => /* @__PURE__ */ t("div", { className: "h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200" }, u)) }) : k(S) ? /* @__PURE__ */ w("div", { className: "flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500", children: [
373
+ /* @__PURE__ */ t(me, { className: "h-6 w-6 stroke-[1]" }),
374
374
  s("Empty List!"),
375
375
  /* @__PURE__ */ t("span", { className: "font-light", children: s("Add new page to start") })
376
376
  ] }) : /* @__PURE__ */ t(
@@ -381,24 +381,24 @@ const ce = (e, s) => !e || !Array.isArray(e) ? [] : k(s) ? e : ue(
381
381
  pageTypes: i,
382
382
  currentPage: p || "",
383
383
  onClickAction: re,
384
- languagePages: I,
384
+ languagePages: U,
385
385
  selectedLanguage: b,
386
- showUntranslatedPages: G
386
+ showUntranslatedPages: j
387
387
  }
388
388
  ) })
389
389
  ] }),
390
- U && /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(
390
+ M && /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(
391
391
  ot,
392
392
  {
393
393
  closePanel: e,
394
394
  editPage: ae,
395
- addEditPage: U,
395
+ addEditPage: M,
396
396
  setAddEditPage: g
397
397
  }
398
398
  ) }),
399
399
  d && /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(it, { page: d, onClose: () => L(null) }) }),
400
- z && /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(ut, { page: z, onClose: () => O(null) }) }),
401
- j && /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(ct, { page: j, onClose: () => h(null) }) }),
400
+ B && /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(ut, { page: B, onClose: () => G(null) }) }),
401
+ O && /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(ct, { page: O, onClose: () => h(null) }) }),
402
402
  ee && /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(dt, { page: ee, onClose: () => te(null) }) }),
403
403
  K && /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(lt, { page: K, onClose: () => Z(null), closePanel: e }) })
404
404
  ] });
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),y=require("@tanstack/react-query"),s=require("lodash-es"),d=require("lucide-react"),v=require("react"),m=require("react-i18next"),x=require("./register-chai-top-bar-CCssW5dL.cjs"),l=require("./index-D-r_K4yA.cjs"),j=require("./index-BYrRPW_c.cjs"),w=require("./use-page-expand-manager-B6XTvk0E.cjs"),C=({selectedPageType:a,setSelectedPageType:n})=>{const{t:r}=m.useTranslation(),[i,o]=v.useState(""),{data:c}=j.usePageTypes(),p=v.useMemo(()=>c.some(t=>!["page","global"].includes(s.get(t,"key",""))),[c]);if(v.useEffect(()=>{!p&&a!=="all"&&n("all")},[p,a,n]),!p)return null;const u=t=>{if(!i)return!0;const h=i.toLowerCase(),f=b=>String(s.get(t,b,"")).toLowerCase().includes(h);return f("name")||f("key")},g=c.find(t=>t.key===a);return e.jsxs(l.Select,{onValueChange:n,value:a,children:[e.jsx(l.SelectTrigger,{className:`${a==="all"?"bg-gray-100/30 hover:bg-gray-100":"gap-x-1 border bg-gray-100/30 hover:bg-gray-100"} h-9 w-max min-w-[150px] overflow-hidden whitespace-nowrap rounded p-0 px-2 py-1 text-xs text-gray-600 shadow-none ring-0 focus:ring-0 [&>svg]:hidden`,children:e.jsxs("div",{className:"flex w-full items-center justify-between gap-x-1.5",children:[e.jsx("span",{className:"max-w-[150px] overflow-hidden truncate whitespace-nowrap font-medium leading-tight",children:(g==null?void 0:g.name)||r("All")}),e.jsx(d.ListFilter,{className:`${a!=="all"?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground hover:bg-blue-300`})]})}),e.jsxs(l.SelectContent,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white pb-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(d.Search,{strokeWidth:2,className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-gray-400"}),e.jsx(x.Input,{placeholder:r("Search page types..."),className:"h-8 w-full rounded border pl-8 text-xs shadow-none",value:i,onChange:t=>o(t.target.value),onKeyDown:t=>t.stopPropagation()})]})}),e.jsx(l.SelectItem,{value:"all",children:r("All")}),!s.isEmpty(s.filter(c,t=>t.hasSlug&&u(t)))&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500",children:r("Pages")}),s.map([...s.filter(c,t=>t.hasSlug&&u(t))].sort((t,h)=>s.get(t,"name","").localeCompare(s.get(h,"name",""))),t=>e.jsx(l.SelectItem,{value:s.get(t,"key"),children:s.get(t,"name")},s.get(t,"key")))]}),!s.isEmpty(s.filter(c,t=>!t.hasSlug&&u(t)))&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500",children:r("Partials")}),s.map([...s.filter(c,t=>!t.hasSlug&&u(t))].sort((t,h)=>s.get(t,"name","").localeCompare(s.get(h,"name",""))),t=>e.jsx(l.SelectItem,{value:s.get(t,"key"),children:s.get(t,"name")},s.get(t,"key")))]}),s.isEmpty(s.filter(c,u))&&e.jsx("div",{className:"px-3 py-2 text-center text-sm text-gray-500",children:r("No matching page types found")})]})]})},N=({search:a,setSearch:n})=>{const{t:r}=m.useTranslation();return e.jsxs("div",{className:"relative flex h-9 flex-1 items-center gap-2 rounded-md border px-2.5",children:[e.jsx("label",{htmlFor:"page-search-input",className:"sr-only",children:r("Search Pages")}),e.jsx(d.Search,{className:`${a?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground`,"aria-hidden":"true"}),e.jsx(x.Input,{id:"page-search-input",placeholder:r("Search pages"),value:a,onChange:i=>n(i.target.value),className:"border-none px-1.5 shadow-none outline-none ring-0 transition-none focus:outline-none focus:ring-0 focus-visible:ring-0",autoComplete:"off",autoFocus:!0})]})},S=({pages:a})=>{const{t:n}=m.useTranslation(),{expandAll:r,collapseAll:i,expandedPages:o}=w.usePageExpandManager(null);return e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(l.Tooltip,{children:[e.jsx(l.TooltipTrigger,{asChild:!0,children:e.jsx(x.Button,{variant:"outline",size:"icon",onClick:()=>r(a),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsUpDown,{})})}),e.jsx(l.TooltipContent,{children:n("Expand All")})]}),e.jsxs(l.Tooltip,{children:[e.jsx(l.TooltipTrigger,{asChild:!0,children:e.jsx(x.Button,{disabled:o.length===0,variant:"outline",size:"icon",onClick:()=>i(),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsDownUp,{})})}),e.jsx(l.TooltipContent,{children:n("Collapse All")})]})]})},k=({languages:a,selectedLanguage:n,setSelectedLanguage:r})=>{const i=j.useFallbackLang();return e.jsx("div",{className:"scrollbar-hide flex gap-1 overflow-x-auto pb-1",children:a.map(o=>e.jsxs(x.Button,{variant:n===o?"default":"outline",size:"sm",className:`h-6 flex-shrink-0 whitespace-nowrap rounded px-3 text-xs font-normal ${n===o?"bg-black text-white hover:bg-black":"text-gray-500"}`,onClick:()=>r(o.toLowerCase()),children:[o===i&&e.jsx(d.Star,{size:4,className:`p-0.5 ${n===i?"fill-white":"fill-black"}`}),j.LANGUAGES[o]||""]},o))})},T=()=>{const{t:a}=m.useTranslation(),n=y.useQueryClient();return e.jsxs(l.Tooltip,{children:[e.jsx(l.TooltipTrigger,{asChild:!0,children:e.jsx(x.Button,{size:"sm",variant:"ghost",onClick:()=>n.invalidateQueries({queryKey:[j.ACTIONS.GET_WEBSITE_PAGES]}),className:"mt-1 h-6 w-6",children:e.jsx(d.RefreshCw,{})})}),e.jsx(l.TooltipContent,{side:"bottom",children:a("Refresh pages list")})]})},E=({pages:a,search:n,setSearch:r,languages:i,onAddPage:o,selectedLanguage:c,setSelectedLanguage:p,selectedPageType:u,setSelectedPageType:g,showUntranslatedPages:t,setShowUntranslatedPages:h})=>{const{t:f}=m.useTranslation();return e.jsxs("div",{className:"space-y-3 border-b border-b-gray-200 px-4 pb-1",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(C,{selectedPageType:u,setSelectedPageType:g}),e.jsx(N,{search:n,setSearch:r}),e.jsx(S,{pages:a}),e.jsxs(x.Button,{variant:"default",onClick:o,className:"rounded px-3 font-normal",children:[e.jsx(d.Plus,{strokeWidth:2,className:"stroke-white stroke-[3]"}),e.jsx("span",{className:"font-normal text-white",children:f("Add Page")})]}),e.jsx(T,{})]}),e.jsx("div",{className:"flex items-center justify-between gap-2"})]})};exports.LanguageSelector=k;exports.default=E;