@chaibuilder/sdk 4.0.0-beta.6 → 4.0.0-beta.8

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 (136) hide show
  1. package/README.md +73 -50
  2. package/dist/{2SSKDMRQ-BIryEtW-.cjs → 2SSKDMRQ-DHv4u_0i.cjs} +1 -1
  3. package/dist/{2SSKDMRQ-trME0kvt.js → 2SSKDMRQ-DewwiCoQ.js} +2 -2
  4. package/dist/{AP7HFJJL-CAGB9iMp.js → AP7HFJJL-ComnZw7J.js} +1 -1
  5. package/dist/{AP7HFJJL-5ZR38Hyh.cjs → AP7HFJJL-cz754qhG.cjs} +1 -1
  6. package/dist/{IconPicker-Mu75ni5T.js → IconPicker-2H9IGKMS.js} +2 -2
  7. package/dist/{IconPicker-CQ-BgNNU.cjs → IconPicker-U0Z2dWeR.cjs} +1 -1
  8. package/dist/{WDYDFRGG-n8sBZVFG.cjs → WDYDFRGG-BfRX3M58.cjs} +1 -1
  9. package/dist/{WDYDFRGG-Cd4hRWj-.js → WDYDFRGG-vy7nMYD4.js} +2 -2
  10. package/dist/{actions-registery-JdxhXhT6.cjs → actions-registery-CtQSSexG.cjs} +31 -31
  11. package/dist/{actions-registery-y_ENc8zj.js → actions-registery-DqrFhSMp.js} +2414 -2418
  12. package/dist/actions.cjs +1 -1
  13. package/dist/actions.d.ts +0 -34
  14. package/dist/actions.js +3 -3
  15. package/dist/{active-in-another-tab-Cb6tnX9u.js → active-in-another-tab-5hn17Jeq.js} +3 -3
  16. package/dist/{active-in-another-tab-CZLV-uAW.cjs → active-in-another-tab-ijahI5qu.cjs} +1 -1
  17. package/dist/{add-new-language-page-BKcBaqZu.js → add-new-language-page-DmOyPy0u.js} +4 -4
  18. package/dist/{add-new-language-page-C3UzNV7W.cjs → add-new-language-page-vmNKNx-e.cjs} +1 -1
  19. package/dist/{add-new-page-pH3PwqJe.js → add-new-page-NHScAQn8.js} +2 -2
  20. package/dist/{add-new-page-mULv9r3z.cjs → add-new-page-XDuCkOyb.cjs} +1 -1
  21. package/dist/{ai-panel-content-BPgRdgye.cjs → ai-panel-content-BDqW16AW.cjs} +1 -1
  22. package/dist/{ai-panel-content-CNxN84pv.js → ai-panel-content-CHJ0JcQI.js} +4 -4
  23. package/dist/{ai-panel-default-lang-CYcHjk8U.js → ai-panel-default-lang-BIomgsN0.js} +4 -4
  24. package/dist/{ai-panel-default-lang-DhTPtPgD.cjs → ai-panel-default-lang-HeYWpbMu.cjs} +2 -2
  25. package/dist/{ai-panel-other-lang-CGNU3-FI.cjs → ai-panel-other-lang-BMelEs3p.cjs} +1 -1
  26. package/dist/{ai-panel-other-lang-D8Ofvj8F.js → ai-panel-other-lang-CbAgG-qX.js} +3 -3
  27. package/dist/{ai-prompt-input-Ceuy5bs3.js → ai-prompt-input-BH8LOVT4.js} +2 -2
  28. package/dist/{ai-prompt-input-CUutJjlf.cjs → ai-prompt-input-C_GG6nwq.cjs} +1 -1
  29. package/dist/{ai-translation-prompt-CoCPLEed.cjs → ai-translation-prompt-CkHaFv5I.cjs} +1 -1
  30. package/dist/{ai-translation-prompt-BiepZRcN.js → ai-translation-prompt-DxsNw8YR.js} +2 -2
  31. package/dist/{code-display-DloSPyPr.cjs → code-display-9Onx6RCq.cjs} +1 -1
  32. package/dist/{code-display-Ck81Id9K.js → code-display-oa1j0ri7.js} +1 -1
  33. package/dist/{code-editor-Z14ByBIv.js → code-editor-CGBAc-A6.js} +1 -1
  34. package/dist/{code-editor-C1ewJzDJ.cjs → code-editor-GV8ibQ4h.cjs} +1 -1
  35. package/dist/{continue-editing-in-this-client-k9Ab5E63.cjs → continue-editing-in-this-client-DKHP0pq8.cjs} +1 -1
  36. package/dist/{continue-editing-in-this-client-Byi6ER3L.js → continue-editing-in-this-client-Da8ab_9d.js} +3 -3
  37. package/dist/core.cjs +1 -1
  38. package/dist/core.d.ts +1 -90
  39. package/dist/core.js +22 -34
  40. package/dist/css-import-modal-B4j26_cO.cjs +13 -0
  41. package/dist/{css-import-modal-De7Kvg5C.js → css-import-modal-CcZVLsF9.js} +5 -4
  42. package/dist/{delete-design-token-C6s-ESB_.cjs → delete-design-token-3-WwqXMO.cjs} +1 -1
  43. package/dist/{delete-design-token-B97CnFDU.js → delete-design-token-DzINIVtO.js} +1 -1
  44. package/dist/{delete-page-Djn97HiP.cjs → delete-page-B7ODELqM.cjs} +1 -1
  45. package/dist/{delete-page-Dnf97ZHP.js → delete-page-DwZDMwfI.js} +3 -3
  46. package/dist/{design-token-usage-B-SykAjD.js → design-token-usage-DQf180Lg.js} +2 -2
  47. package/dist/{design-token-usage-OTd93kS8.cjs → design-token-usage-Dy08kcIc.cjs} +1 -1
  48. package/dist/{digital-asset-manager-DHYRXaaq.cjs → digital-asset-manager-C7subULa.cjs} +1 -1
  49. package/dist/{digital-asset-manager-b8gDuLnI.js → digital-asset-manager-CDy9kHZO.js} +4 -4
  50. package/dist/{duplicate-page-C4Ovp8Ff.cjs → duplicate-page-CWQ9aMd9.cjs} +1 -1
  51. package/dist/{duplicate-page-Bdtpl7_R.js → duplicate-page-DTnSztlr.js} +4 -4
  52. package/dist/{dynamic-page-selector-B8DdnfrF.cjs → dynamic-page-selector-DJuxLcsM.cjs} +1 -1
  53. package/dist/{dynamic-page-selector-BVnIM1Rq.js → dynamic-page-selector-DYW3ov_u.js} +3 -3
  54. package/dist/{image-editor-C2zOHeKv.cjs → image-editor-C4H3AkZK.cjs} +1 -1
  55. package/dist/{image-editor-cckqPmk5.js → image-editor-DLeSST0K.js} +1 -1
  56. package/dist/{index-CAhEmHYP.js → index-BK0xWO1z.js} +5212 -5680
  57. package/dist/index-BRJCj7c_.cjs +5 -0
  58. package/dist/index-Bm8iS2OH.cjs +160 -0
  59. package/dist/{index-Bn0fFN58.js → index-D5d4QDq7.js} +520 -511
  60. package/dist/{json-diff-viewer-DNizzMnu.js → json-diff-viewer-BYHieVod.js} +3 -3
  61. package/dist/{json-diff-viewer-D9DVIBz4.cjs → json-diff-viewer-g6SY62bl.cjs} +1 -1
  62. package/dist/{lang-panel-DL_BtSRD.js → lang-panel-BG1GMn-1.js} +4 -4
  63. package/dist/{lang-panel-C1dbn163.cjs → lang-panel-Dm1eOO2J.cjs} +1 -1
  64. package/dist/{manage-design-tokens-xxMO_RYg.js → manage-design-tokens-BdWQUHhw.js} +3 -3
  65. package/dist/{manage-design-tokens-CXjYkarE.cjs → manage-design-tokens-XWs_B6jo.cjs} +1 -1
  66. package/dist/{mark-as-template-Ba2bmVd9.js → mark-as-template-D2XxagVO.js} +3 -3
  67. package/dist/{mark-as-template-DF1KIMr0.cjs → mark-as-template-DUFnfVM3.cjs} +1 -1
  68. package/dist/{nested-path-selector-content-Cuk7NB-u.cjs → nested-path-selector-content-CQOx2L9C.cjs} +1 -1
  69. package/dist/{nested-path-selector-content-Br1IWhK5.js → nested-path-selector-content-Wd6-Eql0.js} +2 -2
  70. package/dist/{no-language-page-content-9B2Fm-on.js → no-language-page-content-BOv6TZIk.js} +3 -3
  71. package/dist/{no-language-page-content-CxTp-LIM.cjs → no-language-page-content-C11uF6hs.cjs} +1 -1
  72. package/dist/{no-language-page-dialog-DynACvgV.cjs → no-language-page-dialog-CY5XhXsC.cjs} +1 -1
  73. package/dist/{no-language-page-dialog-CPlKMyb8.js → no-language-page-dialog-DIXyKRJq.js} +2 -2
  74. package/dist/{page-creator-BtyJz2sx.js → page-creator-WX9lMrJY.js} +4 -4
  75. package/dist/{page-creator-Cbfv9N0P.cjs → page-creator-zSUFF4eT.cjs} +1 -1
  76. package/dist/{page-lock-CzsxrmN5.js → page-lock-D9miLZjm.js} +2 -2
  77. package/dist/{page-lock-fRos9wRU.cjs → page-lock-DGhR_url.cjs} +1 -1
  78. package/dist/{page-locked-dialog-D2q9qkPk.js → page-locked-dialog-CNCUCcvH.js} +3 -3
  79. package/dist/{page-locked-dialog-D57d2gvn.cjs → page-locked-dialog-DTLnbfuP.cjs} +1 -1
  80. package/dist/{page-manager-new-D6DVIx2S.js → page-manager-new-BFFOLh-l.js} +4 -4
  81. package/dist/{page-manager-new-aE198gKS.cjs → page-manager-new-Dd2c-Q_O.cjs} +1 -1
  82. package/dist/{page-manager-search-and-filter-DGQEgKzy.cjs → page-manager-search-and-filter-BKdQUJ2W.cjs} +1 -1
  83. package/dist/{page-manager-search-and-filter-CuZkQaZg.js → page-manager-search-and-filter-C1IWF_4d.js} +3 -3
  84. package/dist/page-revisions-content-D0cflnj1.cjs +1 -0
  85. package/dist/{page-revisions-content-5rbicFbD.js → page-revisions-content-DHapiLck.js} +75 -67
  86. package/dist/pages.cjs +1 -1
  87. package/dist/pages.d.ts +2 -1
  88. package/dist/pages.js +1 -1
  89. package/dist/{publish-pages-content-WeGk-YLC.js → publish-pages-content-Bd2zJHtK.js} +4 -4
  90. package/dist/{publish-pages-content-DBb8M3TG.cjs → publish-pages-content-BqLcnKry.cjs} +1 -1
  91. package/dist/{register-chai-top-bar-ESJHs5s-.js → register-chai-top-bar-CX_JkRJn.js} +78 -78
  92. package/dist/register-chai-top-bar-DWTuRU53.cjs +1 -0
  93. package/dist/render.d.ts +2 -1
  94. package/dist/{rte-widget-modal-DBoPRXq-.cjs → rte-widget-modal-DiB5BjH1.cjs} +1 -1
  95. package/dist/{rte-widget-modal-J-_AytmK.js → rte-widget-modal-RS8PMKOn.js} +7 -7
  96. package/dist/runtime-client.cjs +1 -0
  97. package/dist/runtime-client.d.ts +158 -0
  98. package/dist/runtime-client.js +32 -0
  99. package/dist/runtime.cjs +1 -1
  100. package/dist/runtime.d.ts +1 -163
  101. package/dist/runtime.js +71 -72
  102. package/dist/{save-to-lib-CQQxoovF.js → save-to-lib--6ZXHEbC.js} +3 -3
  103. package/dist/{save-to-lib-0ysmXVbI.cjs → save-to-lib-BXJvaC1N.cjs} +1 -1
  104. package/dist/{selected-block-display-BWupQFoQ.cjs → selected-block-display-BfpJda4h.cjs} +1 -1
  105. package/dist/{selected-block-display-CgoXS8Hr.js → selected-block-display-CUnCqXQw.js} +3 -3
  106. package/dist/{seo-panel-B798Myp_.js → seo-panel-Bs-FcY1A.js} +3 -3
  107. package/dist/{seo-panel-BkFbXIL0.cjs → seo-panel-CQITMfZ6.cjs} +1 -1
  108. package/dist/{shared-json-ld-Clg_UEhd.js → shared-json-ld-7EujD341.js} +3 -3
  109. package/dist/{shared-json-ld-Cn3MCW6I.cjs → shared-json-ld-DDXXi-Mj.cjs} +1 -1
  110. package/dist/{slug-input-BHyD8cxk.cjs → slug-input-CsVJAr7r.cjs} +1 -1
  111. package/dist/{slug-input-hX5VaZpj.js → slug-input-DoEIq5rs.js} +2 -2
  112. package/dist/supabase-actions.cjs +1 -1
  113. package/dist/supabase-actions.d.ts +5 -0
  114. package/dist/supabase-actions.js +1 -1
  115. package/dist/{take-over-request-s1L5Yofb.js → take-over-request-C14kJ356.js} +3 -3
  116. package/dist/{take-over-request-Dzczo20q.cjs → take-over-request-D5Oo3MPo.cjs} +1 -1
  117. package/dist/{theme-panel-footer-sK6bYhEb.js → theme-panel-footer-Dvknelm8.js} +3 -3
  118. package/dist/{theme-panel-footer-NTNCL0SW.cjs → theme-panel-footer-Eeibz2JA.cjs} +1 -1
  119. package/dist/{translation-warning-modal-BfM4HGck.cjs → translation-warning-modal-CPzdHzqq.cjs} +1 -1
  120. package/dist/{translation-warning-modal-Jadkcver.js → translation-warning-modal-YlzP2XoO.js} +2 -2
  121. package/dist/{unmark-as-template-CqkHI3gR.cjs → unmark-as-template-BGDwuCnv.cjs} +1 -1
  122. package/dist/{unmark-as-template-D5b775eR.js → unmark-as-template-CPJvQk7L.js} +3 -3
  123. package/dist/{unpublish-page-BT5bCfs6.cjs → unpublish-page-BMowW5wT.cjs} +1 -1
  124. package/dist/{unpublish-page-DLLLgY43.js → unpublish-page-DlFHLlmI.js} +3 -3
  125. package/dist/web-blocks.cjs +1 -1
  126. package/dist/web-blocks.js +43 -43
  127. package/dist/{web-preview-C_yFwxEe.js → web-preview-BUnv3jIc.js} +2 -2
  128. package/dist/{web-preview-DU1MgppY.cjs → web-preview-D8GQHCjs.cjs} +1 -1
  129. package/package.json +29 -30
  130. package/dist/css-import-modal--bSJR-_y.cjs +0 -13
  131. package/dist/index-B-rSiAp_.cjs +0 -1
  132. package/dist/index-B0e71wJ1.cjs +0 -160
  133. package/dist/index-DKuwxj1x.cjs +0 -5
  134. package/dist/index-Dxfyt4d4.js +0 -39
  135. package/dist/page-revisions-content-CefqOvKX.cjs +0 -1
  136. package/dist/register-chai-top-bar-BqwKw4uy.cjs +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),X=require("./index-B0e71wJ1.cjs"),f=require("./index-DKuwxj1x.cjs"),B=require("./use-page-expand-manager-B6XTvk0E.cjs"),r=require("lodash-es"),O=require("jotai"),b=require("lucide-react"),l=require("react"),ne=require("react-i18next"),re=require("./register-chai-top-bar-BqwKw4uy.cjs"),Y=(e,n)=>!e||!Array.isArray(e)?[]:r.isEmpty(n)?e:r.compact(r.filter(e,a=>{const s=r.toLower(n);return r.includes(r.toLower((a==null?void 0:a.name)||""),s)||r.includes(r.toLower((a==null?void 0:a.slug)||""),s)})),ae=(e,n)=>{const a=new Set,s=r.keyBy(e,"id");return n.forEach(c=>{let o=c;for(;o.parent&&s[o.parent];)a.add(o.parent),o=s[o.parent]}),Array.from(a).map(c=>s[c])},$=(e,n,a)=>r.isEmpty(n)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?$(s.children,n,a):[]};const c=s.children&&s.children.some(o=>r.includes(r.toLower(o.name||""),r.toLower(n))||r.includes(r.toLower(o.slug||""),r.toLower(n)));return{...s,shouldExpandOnSearch:c,children:s.children?$(s.children,n,a):[]}}),le=e=>{if(!e||!e.length)return[];const n={};e.forEach(s=>{n[s.id]={...s,children:[]}});const a=[];return Object.values(n).forEach(s=>{s.parent&&n[s.parent]?n[s.parent].children.push(s):a.push(s)}),a},J=e=>!e||!e.length?[]:[...e].sort((a,s)=>(a.name||"").localeCompare(s.name||"")).map(a=>({...a,children:a.children?J(a.children):[]})),oe=(e,n,a,s)=>{if(!e||!e.length)return[];let c=e;if(a!=="all"&&(c=r.compact(r.filter(e,{pageType:a}))),r.isEmpty(n))c=Y(c,n);else{const x=Y(c,n),u=ae(e,x);c=r.uniqBy([...x,...u],"id")}const o=J(le(c)),p=$(o,n,s),v=r.filter(p,x=>s(x.pageType)).sort((x,u)=>(x.name||"").localeCompare(u.name||"")),d=r.filter(p,x=>!s(x.pageType));let y=[];if(a==="all"){const x=r.keyBy(d,"pageType");y=Object.values(r.mapValues(x,(u,g)=>({...u,id:g,name:r.startCase(g),isPartialGroup:!0,children:p.filter(w=>w.pageType===g)})))}else y=d.sort((x,u)=>(x.name||"").localeCompare(u.name||""));return[...v,...y]},ie=O.atom({pageId:null,position:{x:0,y:0}}),ce=({pageId:e,children:n})=>{const[a,s]=O.useAtom(ie),c=l.useRef(null),o=a.pageId===e;l.useEffect(()=>{const d=()=>s({pageId:null,position:{x:0,y:0}});if(o)return document.addEventListener("click",d),()=>document.removeEventListener("click",d)},[o,s]);const p=d=>{d.preventDefault(),d.stopPropagation(),s({pageId:e,position:{x:d.clientX,y:d.clientY}})},v=()=>{const d=`${window.location.pathname}?page=${e}`;window.open(d,"_blank"),s({pageId:null,position:{x:0,y:0}})};return t.jsxs(t.Fragment,{children:[t.jsx("span",{onContextMenu:p,children:n}),o&&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(re.Button,{variant:"ghost",onClick:v,className:"w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",children:[t.jsx(b.ExternalLink,{className:"h-4 w-4"}),"Open in new tab"]})})})]})},de=({page:e})=>{var s,c;const{isExpanded:n,toggleExpanded:a}=B.usePageExpandManager(e==null?void 0:e.id);return t.jsx("button",{onClick:o=>{o.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(b.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${n?"rotate-90":""}`})})},ue=({page:e,pageType:n})=>t.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?t.jsx(b.StarsIcon,{size:12,className:"text-yellow-400"}):n!=null&&n.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:n.icon}}):n!=null&&n.hasSlug?t.jsx(b.File,{size:12,className:"stroke-[1] text-slate-500"}):t.jsx(b.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),me=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),xe=({page:e,pageTypes:n,currentPage:a,onClickAction:s,languagePages:c,selectedLanguage:o,showUntranslatedPages:p})=>{const v=f.useUserId(),{pageToUser:d}=f.usePageToUser(),y=r.get(d,[e==null?void 0:e.id,"userId"]),{data:x}=f.useChaiUserInfo(y),u=x&&v!==y?x==null?void 0:x.name:null,g=f.useFallbackLang(),w=a===e.id,I=!!e.isTemplate,j=l.useMemo(()=>r.find(n,{key:e.pageType}),[n,e.pageType]);let h=r.get(c,e==null?void 0:e.id);h=r.get(h,"lang")===o?h:null;const E=o===g||!!h,L=(h==null?void 0:h.name)||(e==null?void 0:e.name)||"No name";let k=(h==null?void 0:h.slug)||(e==null?void 0:e.slug)||"";const C=k+(e!=null&&e.dynamic?`/${j==null?void 0:j.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(k.startsWith("/")&&!p){const m=k.split("/").pop();k=k.endsWith(m)&&e.dynamic?"":`/${m}`}const M=l.useMemo(()=>{const m="flex h-7 min-w-0 flex-1 cursor-pointer select-none items-center gap-x-1.5 rounded px-px text-xs duration-300 border-[1px]",T=`${w?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${m} ${T} ${u?"opacity-60":""}`:`${m} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,w,u]);return t.jsxs("div",{className:"group relative",children:[t.jsx(ce,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:M,children:[t.jsx(de,{page:e}),!e.isPartialGroup&&t.jsx(me,{isOnline:h?h.online:e.online}),!e.isPartialGroup&&t.jsx(ue,{page:e,pageType:j}),t.jsx(f.Tooltip,{content:L,side:"top",showTooltip:L.length>35,children:t.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:L})}),(k||e.dynamic)&&t.jsx(f.Tooltip,{content:C,side:"top",showTooltip:!0,children:t.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[k,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(f.Tooltip,{content:"Template",side:"top",children:t.jsx("span",{className:"text-blue-500",children:t.jsx(b.NotepadText,{size:16})})}),!e.isPartialGroup&&E&&!u?t.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:t.jsx(f.PageActionsDropdown,{isLanguagePage:!!h,page:h||e,setDuplicatePage:m=>s("duplicate",m),setAddEditPage:m=>s("edit",h||m),setUnpublishPage:m=>s("unpublish",m),setDeletePage:m=>s("delete",h||m),setMarkAsTemplate:m=>s("markAsTemplate",m),setUnmarkAsTemplate:m=>s("unmarkAsTemplate",m),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(b.MoreHorizontal,{className:"h-4 w-4",onClick:m=>m.stopPropagation()})})})}):u?t.jsx("span",{className:"duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500",children:t.jsx(b.Lock,{className:"h-3.5 w-3.5 fill-red-200 text-red-500"})}):null]})}),t.jsx(t.Fragment,{children:u&&t.jsxs("button",{className:"absolute right-px top-1/2 flex h-6 -translate-y-1/2 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:[t.jsx(b.Edit,{size:12,className:"stroke-[3]"})," ",t.jsx("span",{className:"font-medium",children:u})," is editing this page"]})}),t.jsx(t.Fragment,{children:!E&&!e.isPartialGroup&&!u&&t.jsxs("button",{onClick:m=>{m.stopPropagation(),s("addLanguagePage",{language:o,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(b.Plus,{size:12,className:"stroke-[3]"})," ",t.jsxs("span",{className:"text-[10px]",children:["Add ",r.get(f.LANGUAGES,o)," Page"]})]})})]})},K=({pages:e,tier:n,pageTypes:a,currentPage:s,onClickAction:c,languagePages:o,selectedLanguage:p,showUntranslatedPages:v})=>{const{expandedPages:d}=B.usePageExpandManager();return t.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${n*10}px`},children:e.map(y=>t.jsxs(t.Fragment,{children:[t.jsx(xe,{page:y,pageTypes:a,currentPage:s,onClickAction:c,languagePages:o,selectedLanguage:p,showUntranslatedPages:v}),y.children&&y.children.length>0&&(d==null?void 0:d.includes(y.id))&&t.jsx(K,{pages:y.children,tier:n+1,pageTypes:a,currentPage:s,onClickAction:c,languagePages:o,selectedLanguage:p,showUntranslatedPages:v})]},y.id))})},he=l.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-DGQEgKzy.cjs"))),fe=l.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-mULv9r3z.cjs"))),pe=l.lazy(()=>Promise.resolve().then(()=>require("./delete-page-Djn97HiP.cjs"))),ye=l.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-C4Ovp8Ff.cjs"))),Pe=l.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-DF1KIMr0.cjs"))),ge=l.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-CqkHI3gR.cjs"))),je=l.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-BT5bCfs6.cjs"))),be=({close:e})=>{const{t:n}=ne.useTranslation(),{languages:a,setSelectedLang:s}=X.useLanguages(),{data:c}=f.usePageTypes(),{data:o,isFetching:p}=f.useWebsitePages(),[v,d]=f.useSearchParams(),{updateForSelectedPage:y,expandPagesOnSearch:x}=B.usePageExpandManager(null),u=f.useFallbackLang(),g=v.get("page"),[w,I]=l.useState(""),[j,h]=l.useState(null),[E,L]=l.useState(null),[k,C]=l.useState(null),[M,m]=l.useState(null),[T,F]=l.useState(""),[R,G]=l.useState(null),[D,W]=l.useState(null),[S,Z]=l.useState(u),[ee,te]=l.useState(!1),_=O.useSetAtom(f.addNewLangAtom),q=ee&&S!==u,{data:A,isFetching:se}=f.useWebsiteLanguagePages(S),H=l.useCallback(P=>{var i;return(i=r.find(c,{key:P}))==null?void 0:i.hasSlug},[c]),N=l.useMemo(()=>o?q?r.filter(o,P=>!(A!=null&&A[P.id])):oe(o,w,T,H):[],[o,H,w,T,A,q]);l.useEffect(()=>{s(u)},[u,s]),l.useEffect(()=>{if(!r.isEmpty(T))return;const P=sessionStorage.getItem("pageTypeFilter")||"all";!r.isEmpty(c)&&P&&(r.find(c,{key:P})?F(P):F("all"))},[c,T]),l.useEffect(()=>{if(g&&!p&&!r.find(o,{id:g})){const i=r.find(o,{slug:"/"});if(i){const z=new URLSearchParams({page:i.id});f.navigateToPage(z,d)}else f.navigateToPage(new URLSearchParams({}),d,!0)}},[o,g,p,d]),l.useEffect(()=>{g&&!p&&!r.isEmpty(N)&&y(N,g)},[g,p,N,y]),l.useEffect(()=>{!r.isEmpty(w)&&!r.isEmpty(N)&&x(N)},[w,N,x]);const{setSelectedLang:U}=X.useLanguages(),Q=l.useCallback(P=>{const i=new URLSearchParams({page:P});S!==u?(i.set("lang",S),U(S)):U(""),f.navigateToPage(i,d),e()},[e,d,U,S,u]),V=(P,i)=>{var z;if(i)switch(P){case"add":L(i);break;case"select":Q(i);break;case"edit":S!==u?_({edit:!0,id:i==null?void 0:i.id,primaryPage:i==null?void 0:i.primaryPage}):L(i);break;case"delete":h(i);break;case"unpublish":C(i);break;case"markAsTemplate":m(i);break;case"unmarkAsTemplate":W(i);break;case"duplicate":G(i);break;case"addLanguagePage":_({edit:!1,primaryPage:((z=i==null?void 0:i.page)==null?void 0:z.id)||"",preselectedLang:(i==null?void 0:i.language)||S});break}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-full flex-col justify-between",children:[t.jsx(l.Suspense,{children:t.jsx(he,{pages:N,search:w,setSearch:I,languages:[u,...a],selectedLanguage:S,setSelectedLanguage:Z,selectedPageType:T,setSelectedPageType:F,onAddPage:P=>V("add",P),showUntranslatedPages:q,setShowUntranslatedPages:te})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:p||se?t.jsx("div",{className:"space-y-2",children:r.map([...Array(15).keys()],P=>t.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},P))}):r.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(b.File,{className:"h-6 w-6 stroke-[1]"}),n("Empty List!"),t.jsx("span",{className:"font-light",children:n("Add new page to start")})]}):t.jsx(K,{tier:0,pages:N,pageTypes:c,currentPage:g||"",onClickAction:V,languagePages:A,selectedLanguage:S,showUntranslatedPages:q})})]}),E&&t.jsx(l.Suspense,{children:t.jsx(fe,{closePanel:e,editPage:Q,addEditPage:E,setAddEditPage:L})}),j&&t.jsx(l.Suspense,{children:t.jsx(pe,{page:j,onClose:()=>h(null)})}),k&&t.jsx(l.Suspense,{children:t.jsx(je,{page:k,onClose:()=>C(null)})}),M&&t.jsx(l.Suspense,{children:t.jsx(Pe,{page:M,onClose:()=>m(null)})}),D&&t.jsx(l.Suspense,{children:t.jsx(ge,{page:D,onClose:()=>W(null)})}),R&&t.jsx(l.Suspense,{children:t.jsx(ye,{page:R,onClose:()=>G(null),closePanel:e})})]})};exports.default=be;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),X=require("./index-Bm8iS2OH.cjs"),f=require("./index-BRJCj7c_.cjs"),B=require("./use-page-expand-manager-B6XTvk0E.cjs"),r=require("lodash-es"),O=require("jotai"),b=require("lucide-react"),l=require("react"),ne=require("react-i18next"),re=require("./register-chai-top-bar-DWTuRU53.cjs"),Y=(e,n)=>!e||!Array.isArray(e)?[]:r.isEmpty(n)?e:r.compact(r.filter(e,a=>{const s=r.toLower(n);return r.includes(r.toLower((a==null?void 0:a.name)||""),s)||r.includes(r.toLower((a==null?void 0:a.slug)||""),s)})),ae=(e,n)=>{const a=new Set,s=r.keyBy(e,"id");return n.forEach(c=>{let o=c;for(;o.parent&&s[o.parent];)a.add(o.parent),o=s[o.parent]}),Array.from(a).map(c=>s[c])},$=(e,n,a)=>r.isEmpty(n)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?$(s.children,n,a):[]};const c=s.children&&s.children.some(o=>r.includes(r.toLower(o.name||""),r.toLower(n))||r.includes(r.toLower(o.slug||""),r.toLower(n)));return{...s,shouldExpandOnSearch:c,children:s.children?$(s.children,n,a):[]}}),le=e=>{if(!e||!e.length)return[];const n={};e.forEach(s=>{n[s.id]={...s,children:[]}});const a=[];return Object.values(n).forEach(s=>{s.parent&&n[s.parent]?n[s.parent].children.push(s):a.push(s)}),a},J=e=>!e||!e.length?[]:[...e].sort((a,s)=>(a.name||"").localeCompare(s.name||"")).map(a=>({...a,children:a.children?J(a.children):[]})),oe=(e,n,a,s)=>{if(!e||!e.length)return[];let c=e;if(a!=="all"&&(c=r.compact(r.filter(e,{pageType:a}))),r.isEmpty(n))c=Y(c,n);else{const x=Y(c,n),u=ae(e,x);c=r.uniqBy([...x,...u],"id")}const o=J(le(c)),p=$(o,n,s),v=r.filter(p,x=>s(x.pageType)).sort((x,u)=>(x.name||"").localeCompare(u.name||"")),d=r.filter(p,x=>!s(x.pageType));let y=[];if(a==="all"){const x=r.keyBy(d,"pageType");y=Object.values(r.mapValues(x,(u,g)=>({...u,id:g,name:r.startCase(g),isPartialGroup:!0,children:p.filter(w=>w.pageType===g)})))}else y=d.sort((x,u)=>(x.name||"").localeCompare(u.name||""));return[...v,...y]},ie=O.atom({pageId:null,position:{x:0,y:0}}),ce=({pageId:e,children:n})=>{const[a,s]=O.useAtom(ie),c=l.useRef(null),o=a.pageId===e;l.useEffect(()=>{const d=()=>s({pageId:null,position:{x:0,y:0}});if(o)return document.addEventListener("click",d),()=>document.removeEventListener("click",d)},[o,s]);const p=d=>{d.preventDefault(),d.stopPropagation(),s({pageId:e,position:{x:d.clientX,y:d.clientY}})},v=()=>{const d=`${window.location.pathname}?page=${e}`;window.open(d,"_blank"),s({pageId:null,position:{x:0,y:0}})};return t.jsxs(t.Fragment,{children:[t.jsx("span",{onContextMenu:p,children:n}),o&&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(re.Button,{variant:"ghost",onClick:v,className:"w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",children:[t.jsx(b.ExternalLink,{className:"h-4 w-4"}),"Open in new tab"]})})})]})},de=({page:e})=>{var s,c;const{isExpanded:n,toggleExpanded:a}=B.usePageExpandManager(e==null?void 0:e.id);return t.jsx("button",{onClick:o=>{o.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(b.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${n?"rotate-90":""}`})})},ue=({page:e,pageType:n})=>t.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?t.jsx(b.StarsIcon,{size:12,className:"text-yellow-400"}):n!=null&&n.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:n.icon}}):n!=null&&n.hasSlug?t.jsx(b.File,{size:12,className:"stroke-[1] text-slate-500"}):t.jsx(b.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),me=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),xe=({page:e,pageTypes:n,currentPage:a,onClickAction:s,languagePages:c,selectedLanguage:o,showUntranslatedPages:p})=>{const v=f.useUserId(),{pageToUser:d}=f.usePageToUser(),y=r.get(d,[e==null?void 0:e.id,"userId"]),{data:x}=f.useChaiUserInfo(y),u=x&&v!==y?x==null?void 0:x.name:null,g=f.useFallbackLang(),w=a===e.id,I=!!e.isTemplate,j=l.useMemo(()=>r.find(n,{key:e.pageType}),[n,e.pageType]);let h=r.get(c,e==null?void 0:e.id);h=r.get(h,"lang")===o?h:null;const E=o===g||!!h,L=(h==null?void 0:h.name)||(e==null?void 0:e.name)||"No name";let k=(h==null?void 0:h.slug)||(e==null?void 0:e.slug)||"";const C=k+(e!=null&&e.dynamic?`/${j==null?void 0:j.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(k.startsWith("/")&&!p){const m=k.split("/").pop();k=k.endsWith(m)&&e.dynamic?"":`/${m}`}const M=l.useMemo(()=>{const m="flex h-7 min-w-0 flex-1 cursor-pointer select-none items-center gap-x-1.5 rounded px-px text-xs duration-300 border-[1px]",T=`${w?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${m} ${T} ${u?"opacity-60":""}`:`${m} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,w,u]);return t.jsxs("div",{className:"group relative",children:[t.jsx(ce,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:M,children:[t.jsx(de,{page:e}),!e.isPartialGroup&&t.jsx(me,{isOnline:h?h.online:e.online}),!e.isPartialGroup&&t.jsx(ue,{page:e,pageType:j}),t.jsx(f.Tooltip,{content:L,side:"top",showTooltip:L.length>35,children:t.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:L})}),(k||e.dynamic)&&t.jsx(f.Tooltip,{content:C,side:"top",showTooltip:!0,children:t.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[k,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(f.Tooltip,{content:"Template",side:"top",children:t.jsx("span",{className:"text-blue-500",children:t.jsx(b.NotepadText,{size:16})})}),!e.isPartialGroup&&E&&!u?t.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:t.jsx(f.PageActionsDropdown,{isLanguagePage:!!h,page:h||e,setDuplicatePage:m=>s("duplicate",m),setAddEditPage:m=>s("edit",h||m),setUnpublishPage:m=>s("unpublish",m),setDeletePage:m=>s("delete",h||m),setMarkAsTemplate:m=>s("markAsTemplate",m),setUnmarkAsTemplate:m=>s("unmarkAsTemplate",m),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(b.MoreHorizontal,{className:"h-4 w-4",onClick:m=>m.stopPropagation()})})})}):u?t.jsx("span",{className:"duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500",children:t.jsx(b.Lock,{className:"h-3.5 w-3.5 fill-red-200 text-red-500"})}):null]})}),t.jsx(t.Fragment,{children:u&&t.jsxs("button",{className:"absolute right-px top-1/2 flex h-6 -translate-y-1/2 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:[t.jsx(b.Edit,{size:12,className:"stroke-[3]"})," ",t.jsx("span",{className:"font-medium",children:u})," is editing this page"]})}),t.jsx(t.Fragment,{children:!E&&!e.isPartialGroup&&!u&&t.jsxs("button",{onClick:m=>{m.stopPropagation(),s("addLanguagePage",{language:o,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(b.Plus,{size:12,className:"stroke-[3]"})," ",t.jsxs("span",{className:"text-[10px]",children:["Add ",r.get(f.LANGUAGES,o)," Page"]})]})})]})},K=({pages:e,tier:n,pageTypes:a,currentPage:s,onClickAction:c,languagePages:o,selectedLanguage:p,showUntranslatedPages:v})=>{const{expandedPages:d}=B.usePageExpandManager();return t.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${n*10}px`},children:e.map(y=>t.jsxs(t.Fragment,{children:[t.jsx(xe,{page:y,pageTypes:a,currentPage:s,onClickAction:c,languagePages:o,selectedLanguage:p,showUntranslatedPages:v}),y.children&&y.children.length>0&&(d==null?void 0:d.includes(y.id))&&t.jsx(K,{pages:y.children,tier:n+1,pageTypes:a,currentPage:s,onClickAction:c,languagePages:o,selectedLanguage:p,showUntranslatedPages:v})]},y.id))})},he=l.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-BKdQUJ2W.cjs"))),fe=l.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-XDuCkOyb.cjs"))),pe=l.lazy(()=>Promise.resolve().then(()=>require("./delete-page-B7ODELqM.cjs"))),ye=l.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-CWQ9aMd9.cjs"))),Pe=l.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-DUFnfVM3.cjs"))),ge=l.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-BGDwuCnv.cjs"))),je=l.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-BMowW5wT.cjs"))),be=({close:e})=>{const{t:n}=ne.useTranslation(),{languages:a,setSelectedLang:s}=X.useLanguages(),{data:c}=f.usePageTypes(),{data:o,isFetching:p}=f.useWebsitePages(),[v,d]=f.useSearchParams(),{updateForSelectedPage:y,expandPagesOnSearch:x}=B.usePageExpandManager(null),u=f.useFallbackLang(),g=v.get("page"),[w,I]=l.useState(""),[j,h]=l.useState(null),[E,L]=l.useState(null),[k,C]=l.useState(null),[M,m]=l.useState(null),[T,F]=l.useState(""),[R,G]=l.useState(null),[D,W]=l.useState(null),[S,Z]=l.useState(u),[ee,te]=l.useState(!1),_=O.useSetAtom(f.addNewLangAtom),q=ee&&S!==u,{data:A,isFetching:se}=f.useWebsiteLanguagePages(S),H=l.useCallback(P=>{var i;return(i=r.find(c,{key:P}))==null?void 0:i.hasSlug},[c]),N=l.useMemo(()=>o?q?r.filter(o,P=>!(A!=null&&A[P.id])):oe(o,w,T,H):[],[o,H,w,T,A,q]);l.useEffect(()=>{s(u)},[u,s]),l.useEffect(()=>{if(!r.isEmpty(T))return;const P=sessionStorage.getItem("pageTypeFilter")||"all";!r.isEmpty(c)&&P&&(r.find(c,{key:P})?F(P):F("all"))},[c,T]),l.useEffect(()=>{if(g&&!p&&!r.find(o,{id:g})){const i=r.find(o,{slug:"/"});if(i){const z=new URLSearchParams({page:i.id});f.navigateToPage(z,d)}else f.navigateToPage(new URLSearchParams({}),d,!0)}},[o,g,p,d]),l.useEffect(()=>{g&&!p&&!r.isEmpty(N)&&y(N,g)},[g,p,N,y]),l.useEffect(()=>{!r.isEmpty(w)&&!r.isEmpty(N)&&x(N)},[w,N,x]);const{setSelectedLang:U}=X.useLanguages(),Q=l.useCallback(P=>{const i=new URLSearchParams({page:P});S!==u?(i.set("lang",S),U(S)):U(""),f.navigateToPage(i,d),e()},[e,d,U,S,u]),V=(P,i)=>{var z;if(i)switch(P){case"add":L(i);break;case"select":Q(i);break;case"edit":S!==u?_({edit:!0,id:i==null?void 0:i.id,primaryPage:i==null?void 0:i.primaryPage}):L(i);break;case"delete":h(i);break;case"unpublish":C(i);break;case"markAsTemplate":m(i);break;case"unmarkAsTemplate":W(i);break;case"duplicate":G(i);break;case"addLanguagePage":_({edit:!1,primaryPage:((z=i==null?void 0:i.page)==null?void 0:z.id)||"",preselectedLang:(i==null?void 0:i.language)||S});break}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-full flex-col justify-between",children:[t.jsx(l.Suspense,{children:t.jsx(he,{pages:N,search:w,setSearch:I,languages:[u,...a],selectedLanguage:S,setSelectedLanguage:Z,selectedPageType:T,setSelectedPageType:F,onAddPage:P=>V("add",P),showUntranslatedPages:q,setShowUntranslatedPages:te})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:p||se?t.jsx("div",{className:"space-y-2",children:r.map([...Array(15).keys()],P=>t.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},P))}):r.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(b.File,{className:"h-6 w-6 stroke-[1]"}),n("Empty List!"),t.jsx("span",{className:"font-light",children:n("Add new page to start")})]}):t.jsx(K,{tier:0,pages:N,pageTypes:c,currentPage:g||"",onClickAction:V,languagePages:A,selectedLanguage:S,showUntranslatedPages:q})})]}),E&&t.jsx(l.Suspense,{children:t.jsx(fe,{closePanel:e,editPage:Q,addEditPage:E,setAddEditPage:L})}),j&&t.jsx(l.Suspense,{children:t.jsx(pe,{page:j,onClose:()=>h(null)})}),k&&t.jsx(l.Suspense,{children:t.jsx(je,{page:k,onClose:()=>C(null)})}),M&&t.jsx(l.Suspense,{children:t.jsx(Pe,{page:M,onClose:()=>m(null)})}),D&&t.jsx(l.Suspense,{children:t.jsx(ge,{page:D,onClose:()=>W(null)})}),R&&t.jsx(l.Suspense,{children:t.jsx(ye,{page:R,onClose:()=>G(null),closePanel:e})})]})};exports.default=be;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("./register-chai-top-bar-BqwKw4uy.cjs"),n=require("./index-B0e71wJ1.cjs"),f=require("./index-DKuwxj1x.cjs"),w=require("./use-page-expand-manager-B6XTvk0E.cjs"),C=require("@tanstack/react-query"),s=require("lodash-es"),d=require("lucide-react"),S=require("react"),g=require("react-i18next"),k=({selectedPageType:l,setSelectedPageType:i})=>{const{t:a}=g.useTranslation(),[r,o]=S.useState(""),{data:c}=f.usePageTypes(),u=t=>{if(!r)return!0;const x=r.toLowerCase(),m=j=>String(s.get(t,j,"")).toLowerCase().includes(x);return m("name")||m("key")},p=c.find(t=>t.key===l);return e.jsxs(n.Select,{onValueChange:i,value:l,children:[e.jsx(n.SelectTrigger,{className:`${l==="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:(p==null?void 0:p.name)||a("All")}),e.jsx(d.ListFilter,{className:`${l!=="all"?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground hover:bg-blue-300`})]})}),e.jsxs(n.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(h.Input,{placeholder:a("Search page types..."),className:"h-8 w-full rounded border pl-8 text-xs shadow-none",value:r,onChange:t=>o(t.target.value),onKeyDown:t=>t.stopPropagation()})]})}),e.jsx(n.SelectItem,{value:"all",children:a("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:a("Pages")}),s.map([...s.filter(c,t=>t.hasSlug&&u(t))].sort((t,x)=>s.get(t,"name","").localeCompare(s.get(x,"name",""))),t=>e.jsx(n.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:a("Partials")}),s.map([...s.filter(c,t=>!t.hasSlug&&u(t))].sort((t,x)=>s.get(t,"name","").localeCompare(s.get(x,"name",""))),t=>e.jsx(n.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:a("No matching page types found")})]})]})},T=({search:l,setSearch:i})=>{const{t:a}=g.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:a("Search Pages")}),e.jsx(d.Search,{className:`${l?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground`,"aria-hidden":"true"}),e.jsx(h.Input,{id:"page-search-input",placeholder:a("Search pages"),value:l,onChange:r=>i(r.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"})]})},E=({pages:l})=>{const{t:i}=g.useTranslation(),{expandAll:a,collapseAll:r,expandedPages:o}=w.usePageExpandManager(null);return e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{variant:"outline",size:"icon",onClick:()=>a(l),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsUpDown,{})})}),e.jsx(n.TooltipContent,{children:i("Expand All")})]}),e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{disabled:o.length===0,variant:"outline",size:"icon",onClick:()=>r(),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsDownUp,{})})}),e.jsx(n.TooltipContent,{children:i("Collapse All")})]})]})},b=({languages:l,selectedLanguage:i,setSelectedLanguage:a})=>{const r=f.useFallbackLang();return e.jsx("div",{className:"scrollbar-hide flex gap-1 overflow-x-auto pb-1",children:l.map(o=>e.jsxs(h.Button,{variant:i===o?"default":"outline",size:"sm",className:`h-6 flex-shrink-0 whitespace-nowrap rounded px-3 text-xs font-normal ${i===o?"bg-black text-white hover:bg-black":"text-gray-500"}`,onClick:()=>a(o.toLowerCase()),children:[o===r&&e.jsx(d.Star,{size:4,className:`p-0.5 ${i===r?"fill-white":"fill-black"}`}),f.LANGUAGES[o]||""]},o))})},y=()=>{const{t:l}=g.useTranslation(),i=C.useQueryClient();return e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{size:"sm",variant:"ghost",onClick:()=>i.invalidateQueries({queryKey:[f.ACTIONS.GET_WEBSITE_PAGES]}),className:"mt-1 h-6 w-6",children:e.jsx(d.RefreshCw,{})})}),e.jsx(n.TooltipContent,{side:"bottom",children:l("Refresh pages list")})]})},q=({pages:l,search:i,setSearch:a,languages:r,onAddPage:o,selectedLanguage:c,setSelectedLanguage:u,selectedPageType:p,setSelectedPageType:t,showUntranslatedPages:x,setShowUntranslatedPages:m})=>{const{t:j}=g.useTranslation(),v=r.length>1;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(k,{selectedPageType:p,setSelectedPageType:t}),e.jsx(T,{search:i,setSearch:a}),e.jsx(E,{pages:l}),e.jsxs(h.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:j("Add Page")})]}),!v&&e.jsx(y,{})]}),v?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(b,{languages:r,selectedLanguage:c,setSelectedLanguage:N=>{u(N),m(x&&(r==null?void 0:r[0])!==c)}}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[(r==null?void 0:r[0])!==c&&e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{variant:"ghost",onClick:()=>m(!x),className:"h-6 rounded px-3 py-1 text-xs font-normal",children:x?e.jsx(d.FilterXIcon,{}):e.jsx(d.Filter,{})})}),e.jsx(n.TooltipContent,{side:"bottom",children:j("Toggle Untranslated Pages")})]}),e.jsx(y,{})]})]}):e.jsx("div",{className:"flex items-center justify-between gap-2"})]})};exports.LanguageSelector=b;exports.default=q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("./register-chai-top-bar-DWTuRU53.cjs"),n=require("./index-Bm8iS2OH.cjs"),f=require("./index-BRJCj7c_.cjs"),w=require("./use-page-expand-manager-B6XTvk0E.cjs"),C=require("@tanstack/react-query"),s=require("lodash-es"),d=require("lucide-react"),S=require("react"),g=require("react-i18next"),k=({selectedPageType:l,setSelectedPageType:i})=>{const{t:a}=g.useTranslation(),[r,o]=S.useState(""),{data:c}=f.usePageTypes(),u=t=>{if(!r)return!0;const x=r.toLowerCase(),m=j=>String(s.get(t,j,"")).toLowerCase().includes(x);return m("name")||m("key")},p=c.find(t=>t.key===l);return e.jsxs(n.Select,{onValueChange:i,value:l,children:[e.jsx(n.SelectTrigger,{className:`${l==="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:(p==null?void 0:p.name)||a("All")}),e.jsx(d.ListFilter,{className:`${l!=="all"?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground hover:bg-blue-300`})]})}),e.jsxs(n.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(h.Input,{placeholder:a("Search page types..."),className:"h-8 w-full rounded border pl-8 text-xs shadow-none",value:r,onChange:t=>o(t.target.value),onKeyDown:t=>t.stopPropagation()})]})}),e.jsx(n.SelectItem,{value:"all",children:a("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:a("Pages")}),s.map([...s.filter(c,t=>t.hasSlug&&u(t))].sort((t,x)=>s.get(t,"name","").localeCompare(s.get(x,"name",""))),t=>e.jsx(n.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:a("Partials")}),s.map([...s.filter(c,t=>!t.hasSlug&&u(t))].sort((t,x)=>s.get(t,"name","").localeCompare(s.get(x,"name",""))),t=>e.jsx(n.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:a("No matching page types found")})]})]})},T=({search:l,setSearch:i})=>{const{t:a}=g.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:a("Search Pages")}),e.jsx(d.Search,{className:`${l?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground`,"aria-hidden":"true"}),e.jsx(h.Input,{id:"page-search-input",placeholder:a("Search pages"),value:l,onChange:r=>i(r.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"})]})},E=({pages:l})=>{const{t:i}=g.useTranslation(),{expandAll:a,collapseAll:r,expandedPages:o}=w.usePageExpandManager(null);return e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{variant:"outline",size:"icon",onClick:()=>a(l),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsUpDown,{})})}),e.jsx(n.TooltipContent,{children:i("Expand All")})]}),e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{disabled:o.length===0,variant:"outline",size:"icon",onClick:()=>r(),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsDownUp,{})})}),e.jsx(n.TooltipContent,{children:i("Collapse All")})]})]})},b=({languages:l,selectedLanguage:i,setSelectedLanguage:a})=>{const r=f.useFallbackLang();return e.jsx("div",{className:"scrollbar-hide flex gap-1 overflow-x-auto pb-1",children:l.map(o=>e.jsxs(h.Button,{variant:i===o?"default":"outline",size:"sm",className:`h-6 flex-shrink-0 whitespace-nowrap rounded px-3 text-xs font-normal ${i===o?"bg-black text-white hover:bg-black":"text-gray-500"}`,onClick:()=>a(o.toLowerCase()),children:[o===r&&e.jsx(d.Star,{size:4,className:`p-0.5 ${i===r?"fill-white":"fill-black"}`}),f.LANGUAGES[o]||""]},o))})},y=()=>{const{t:l}=g.useTranslation(),i=C.useQueryClient();return e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{size:"sm",variant:"ghost",onClick:()=>i.invalidateQueries({queryKey:[f.ACTIONS.GET_WEBSITE_PAGES]}),className:"mt-1 h-6 w-6",children:e.jsx(d.RefreshCw,{})})}),e.jsx(n.TooltipContent,{side:"bottom",children:l("Refresh pages list")})]})},q=({pages:l,search:i,setSearch:a,languages:r,onAddPage:o,selectedLanguage:c,setSelectedLanguage:u,selectedPageType:p,setSelectedPageType:t,showUntranslatedPages:x,setShowUntranslatedPages:m})=>{const{t:j}=g.useTranslation(),v=r.length>1;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(k,{selectedPageType:p,setSelectedPageType:t}),e.jsx(T,{search:i,setSearch:a}),e.jsx(E,{pages:l}),e.jsxs(h.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:j("Add Page")})]}),!v&&e.jsx(y,{})]}),v?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(b,{languages:r,selectedLanguage:c,setSelectedLanguage:N=>{u(N),m(x&&(r==null?void 0:r[0])!==c)}}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[(r==null?void 0:r[0])!==c&&e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{variant:"ghost",onClick:()=>m(!x),className:"h-6 rounded px-3 py-1 text-xs font-normal",children:x?e.jsx(d.FilterXIcon,{}):e.jsx(d.Filter,{})})}),e.jsx(n.TooltipContent,{side:"bottom",children:j("Toggle Untranslated Pages")})]}),e.jsx(y,{})]})]}):e.jsx("div",{className:"flex items-center justify-between gap-2"})]})};exports.LanguageSelector=b;exports.default=q;
@@ -1,7 +1,7 @@
1
1
  import { jsx as e, jsxs as a, Fragment as k } from "react/jsx-runtime";
2
- import { B as m, z as E } from "./register-chai-top-bar-ESJHs5s-.js";
3
- import { w as g, x as b, y, S as L, z as F, A as I, B as w } from "./index-CAhEmHYP.js";
4
- import { k as j, L as T, m as $, A as B } from "./index-Bn0fFN58.js";
2
+ import { B as m, z as E } from "./register-chai-top-bar-CX_JkRJn.js";
3
+ import { w as g, x as b, y, S as L, z as F, A as I, B as w } from "./index-BK0xWO1z.js";
4
+ import { k as j, L as T, m as $, A as B } from "./index-D5d4QDq7.js";
5
5
  import { u as G } from "./use-page-expand-manager-Cf4MUEJw.js";
6
6
  import { useQueryClient as D } from "@tanstack/react-query";
7
7
  import { isEmpty as N, filter as x, map as S, get as o } from "lodash-es";
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("./register-chai-top-bar-DWTuRU53.cjs"),i=require("./index-Bm8iS2OH.cjs"),c=require("./index-BRJCj7c_.cjs"),y=require("@tanstack/react-query"),v=require("date-fns"),B=require("lodash-es"),p=require("lucide-react"),g=require("react");function L(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const l=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(n,t,l.get?l:{enumerable:!0,get:()=>s[t]})}}return n.default=s,Object.freeze(n)}const S=L(g);function Q(s){const n=c.useApiUrl(),t=c.useFetch();return y.useQuery({queryKey:[c.ACTIONS.GET_PAGE_REVISIONS,s],queryFn:async()=>await t(n,{action:c.ACTIONS.GET_PAGE_REVISIONS,data:{pageId:s}}),enabled:!!s,refetchOnMount:!0})}const z=()=>{const s=c.useApiUrl(),n=c.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async l=>await n(s,{action:c.ACTIONS.DELETE_PAGE_REVISION,data:{revisionId:l}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},H=()=>{const s=c.useApiUrl(),n=c.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async({revisionId:l,discardCurrent:r,pageId:d})=>await n(s,{action:c.ACTIONS.RESTORE_PAGE_REVISION,data:{revisionId:l,discardCurrent:r,...d&&{pageId:d}}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},$=g.lazy(()=>Promise.resolve().then(()=>require("./json-diff-viewer-g6SY62bl.cjs"))),b=({tag:s})=>s==="draft"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-xs text-amber-600",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-amber-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Draft"})]}):s==="live"?e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-green-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Live"})]}):s==="published"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-green-500/10 px-1.5 py-0.5 text-xs text-green-600",children:[e.jsx(p.Rocket,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Published"})]}):s==="unsaved"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-red-500/10 px-1.5 py-0.5 text-xs text-red-600",children:[e.jsx(p.Save,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Unsaved changes"})]}):e.jsx("span",{className:"rounded bg-purple-500/10 px-1.5 py-0.5 font-mono text-xs font-bold text-purple-600",children:s});function J({compare:s,setCompare:n}){const{data:t}=c.useChaiCurrentPage(),{saveState:l}=i.useSavePage(),[r]=c.usePageEditInfo();if(!t)return null;const d=!!s.find(x=>{var a;return(a=x==null?void 0:x.uid)==null?void 0:a.startsWith("draft:")}),u=s.length>=2&&!d,m=l==="UNSAVED";return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border bg-primary/5 p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-1 text-sm font-medium leading-none",children:[e.jsx(b,{tag:"draft"}),e.jsx("span",{className:"text-xs font-bold",children:"Currently editing"})]})}),e.jsx("div",{className:"flex items-center pl-2 text-[11px] text-muted-foreground",children:!B.isEmpty(r.lastSaved)&&e.jsxs("span",{children:["Last updated"," ",v.formatDistanceToNow(new Date(r.lastSaved),{addSuffix:!0})]})}),e.jsx("div",{className:"flex items-center gap-2 pt-0.5",children:m?e.jsx(b,{tag:"unsaved"}):null})]}),e.jsx(A,{checked:d,disabled:u,onChange:()=>{n(d?s.filter(x=>x.uid!==`draft:${t==null?void 0:t.id}`):[...s,{uid:`draft:${t==null?void 0:t.id}`,label:"draft",item:{createdAt:Date.now()}}])}})]})}function K(){return e.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((s,n)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(i.Skeleton,{className:"h-4 w-3/4"}),e.jsx(i.Skeleton,{className:"h-3 w-1/2"}),e.jsx(i.Skeleton,{className:"mt-1 h-5 w-20"})]}),e.jsx(i.Skeleton,{className:"h-8 w-8 rounded-full"})]},n))})}function O({revision:s,isLatest:n,onRestore:t,onDelete:l,revisionNumber:r,compare:d,setCompare:u,pageId:m}){const{data:x}=c.useChaiUserInfo(s.currentEditor),a=(x==null?void 0:x.name)||"Unknown",f=!!d.find(h=>{var j;return n?(j=h==null?void 0:h.uid)==null?void 0:j.startsWith("live"):(h==null?void 0:h.uid)===s.uid}),w=d.length>=2&&!f;return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("p",{className:"flex items-center gap-1 text-xs leading-none",children:[e.jsx(b,{tag:n?"live":`#${r}`}),s.type==="published"?"Published":"Draft"," by ",e.jsx("span",{className:"text-xs font-bold",children:a})]})}),e.jsxs("div",{className:"flex items-center gap-x-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:s.type==="published"?e.jsx(b,{tag:"published"}):e.jsx(b,{tag:"draft"})}),e.jsx("div",{className:"flex items-center text-[10px] text-muted-foreground",children:e.jsx("span",{className:"leading-tight",children:v.format(s.createdAt,"MMM d, h:mm a")})})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(c.PermissionChecker,{permissions:[c.PAGES_PERMISSIONS.RESTORE_REVISION,c.PAGES_PERMISSIONS.DELETE_REVISION],children:e.jsx(Y,{revision:s,onRestore:t,onDelete:l})})}),e.jsx(A,{checked:f,disabled:w,onChange:()=>{u(f?d.filter(h=>n?h.uid!==`live:${m}`:h.uid!==s.uid):[...d,{uid:n?`live:${m}`:s.uid,label:n?"live":`#${r}`,item:s}].sort((h,j)=>new Date(h.item.createdAt).getTime()-new Date(j.item.createdAt).getTime()))}})]})}function W({compare:s,setCompare:n,pageId:t}){const[l,r]=g.useState(!1),[d,u]=s;if(s.length===0)return null;const m=({tab:x})=>e.jsxs("span",{className:"flex items-center justify-between rounded border border-blue-100 p-1 font-medium",children:[e.jsx(b,{tag:x.label}),e.jsx("button",{className:"z-0 flex h-4 w-4 items-center justify-center rounded-full text-gray-400 hover:text-red-500",style:{lineHeight:1},onClick:()=>n(s.filter(a=>a.uid!==x.uid)),"aria-label":"Remove selection 1",children:e.jsx(p.X,{className:"h-3 w-3"})})]});return e.jsxs("div",{className:"mb-2 flex w-full max-w-md flex-col gap-1 rounded border bg-accent/60 p-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-xs",children:[e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"Compare"}),d&&e.jsx(m,{tab:d}),e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"with"}),u?e.jsx(m,{tab:u}):e.jsx("span",{className:"rounded border px-1 text-xs text-muted-foreground",children:"Choose another"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pb-0.5 pt-2",children:[e.jsx(N.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none text-gray-500",variant:"outline",onClick:()=>n([]),children:e.jsx("span",{children:" Clear"})}),e.jsxs(N.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none",variant:"default",onClick:()=>r(!0),disabled:s.length<2,children:[e.jsx(p.FileJson,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"pt-0.5",children:"Show JSON Diff"})]})]}),l&&(s==null?void 0:s.length)>1&&t&&e.jsx(g.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx("span",{className:"text-sm",children:"Loading diff viewer..."})}),children:e.jsx($,{open:l,onOpenChange:r,compare:s})})]})}function A({checked:s,disabled:n,onChange:t,label:l="Compare"}){return e.jsx("div",{className:"absolute bottom-2 right-2",children:e.jsxs("label",{className:`flex cursor-pointer items-center gap-x-1 text-[11px] ${n?"opacity-50":""}`,children:[e.jsx("input",{type:"checkbox",className:"h-3 w-3 cursor-pointer rounded focus:ring-0 focus:ring-offset-0",checked:s,disabled:n,onChange:t}),e.jsx("span",{className:"select-none leading-tight",children:l})]})})}function Y({revision:s,onRestore:n,onDelete:t}){return e.jsxs(i.DropdownMenu,{children:[e.jsx(i.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(N.Button,{variant:"ghost",size:"icon",className:"h-5 w-5",children:[e.jsx(p.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More options"})]})}),e.jsxs(i.DropdownMenuContent,{align:"end",className:"text-xs",children:[e.jsx(c.PermissionChecker,{permission:c.PAGES_PERMISSIONS.RESTORE_REVISION,children:e.jsxs(i.DropdownMenuItem,{onClick:n,className:"cursor-pointer text-sm",children:[e.jsx(p.Undo2,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Restore this version"})]})}),e.jsx(c.PermissionChecker,{permission:c.PAGES_PERMISSIONS.DELETE_REVISION,children:s.uid!=="current"&&e.jsxs(e.Fragment,{children:[e.jsx(i.DropdownMenuSeparator,{}),e.jsxs(i.DropdownMenuItem,{onClick:t,className:"cursor-pointer text-destructive",children:[e.jsx(p.Trash,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Delete this version"})]})]})})]})]})}function X({open:s,onOpenChange:n,revision:t,onRestore:l,isRestoring:r}){const{data:d}=c.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),u=(d==null?void 0:d.name)||"Unknown";return t?e.jsx(i.Dialog,{open:s,onOpenChange:m=>{r||n(m)},children:e.jsxs(i.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:"Restore Revision"}),e.jsxs(i.DialogDescription,{children:["You are about to restore to revision ",t.uid.substring(0,8)," from"," ",v.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",u]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"How would you like to handle your current edits?"})}),e.jsxs(i.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(N.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>l(!1),disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Saving as draft..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.CloudOff,{className:"mr-2 h-4 w-4"}),"Save as draft"]})}),e.jsx(N.Button,{variant:"default",className:"sm:flex-1",onClick:()=>l(!0),disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Discarding current..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.Undo2,{className:"mr-2 h-4 w-4"}),"Discard current"]})})]})]})}):null}function Z({open:s,onOpenChange:n,revision:t,onDelete:l,isDeleting:r}){const{data:d}=c.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),u=(d==null?void 0:d.name)||"Unknown";return t?e.jsx(i.Dialog,{open:s,onOpenChange:m=>{r||n(m)},children:e.jsxs(i.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:"Delete Revision"}),e.jsxs(i.DialogDescription,{children:["You are about to delete revision ",t.uid.substring(0,8)," from"," ",v.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",u]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"This action cannot be undone. Are you sure you want to proceed?"})}),e.jsxs(i.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(N.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>n(!1),disabled:r,children:"Cancel"}),e.jsx(N.Button,{variant:"destructive",className:"sm:flex-1",onClick:l,disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.Trash,{className:"mr-2 h-4 w-4"}),"Delete Revision"]})})]})]})}):null}function ee({isOpen:s}){var R,I;const[n,t]=S.useState([]),[l,r]=S.useState(null),[d,u]=S.useState(!1),[m,x]=S.useState(!1),{data:a}=c.useChaiCurrentPage(),{data:f,isFetching:w,error:h,refetch:j}=Q(a==null?void 0:a.id),{mutate:T,isPending:M}=z(),{mutate:k,isPending:F}=H(),_=y.useQueryClient(),{selectedLang:q,fallbackLang:P}=i.useLanguages(),U=q||P;g.useEffect(()=>{g.startTransition(()=>t([]))},[a==null?void 0:a.id]);const G=o=>{l&&k({revisionId:l.uid,discardCurrent:o,...l.uid==="current"&&(a==null?void 0:a.id)&&{pageId:a.id}},{onSuccess:()=>{u(!1),r(null),_.invalidateQueries({queryKey:[c.ACTIONS.GET_DRAFT_PAGE]})}})},C=o=>{r(o),u(!0)},E=o=>{r(o),x(!0)},V=()=>{l&&T(l.uid,{onSuccess:()=>{x(!1),r(null)}})};return g.useEffect(()=>{s&&j()},[s,j]),e.jsxs(e.Fragment,{children:[e.jsxs(i.SheetHeader,{children:[e.jsx(i.SheetTitle,{children:"Revision History"}),(a==null?void 0:a.createdAt)&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Page created on ",v.format(new Date(a.createdAt),"MMM d, yyyy 'at' h:mm a")]})]}),w?e.jsx(K,{}):h?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"Failed to load revisions. Please try again."}):e.jsxs("div",{className:"mt-2 flex h-full min-h-0 flex-1 flex-col space-y-2",children:[e.jsx(W,{lang:U,compare:n,setCompare:t,pageId:a==null?void 0:a.id}),e.jsx(J,{compare:n,setCompare:t}),(R=f==null?void 0:f.filter(o=>o.uid==="current"))==null?void 0:R.map((o,D)=>e.jsx(O,{pageId:a==null?void 0:a.id,revision:o,isLatest:!0,onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:D,compare:n,setCompare:t},o.uid)),e.jsx(i.ScrollArea,{className:"min-h-0 flex-1",children:e.jsx("div",{className:"space-y-2",children:(I=f==null?void 0:f.filter(o=>o.uid!=="current"))==null?void 0:I.map((o,D)=>e.jsx(O,{pageId:a==null?void 0:a.id,revision:o,isLatest:o.uid==="current",onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:D+1,compare:n,setCompare:t},o.uid))})})]}),e.jsx(X,{open:d,onOpenChange:u,revision:l,onRestore:G,isRestoring:F}),e.jsx(Z,{open:m,onOpenChange:x,revision:l,onDelete:V,isDeleting:M})]})}exports.default=ee;
@@ -1,11 +1,11 @@
1
1
  import { jsxs as a, Fragment as p, jsx as e } from "react/jsx-runtime";
2
- import { B as g } from "./register-chai-top-bar-ESJHs5s-.js";
3
- import { n as le, a9 as re, aa as ie, a2 as de, ab as y, Q as ce, D as q, d as G, e as j, f as L, p as z, q as P, r as oe, s as ue, t as me, v as U, ac as he } from "./index-CAhEmHYP.js";
4
- import { ar as R, as as A, A as b, aw as $, az as fe, ap as I, ax as C, ay as w } from "./index-Bn0fFN58.js";
5
- import { useQuery as pe, useQueryClient as O, useMutation as H } from "@tanstack/react-query";
2
+ import { B as g } from "./register-chai-top-bar-CX_JkRJn.js";
3
+ import { n as le, a9 as re, aa as ie, a2 as de, ab as y, Q as ce, D as q, d as G, e as j, f as L, p as z, q as $, r as oe, s as ue, t as me, v as U, ac as he } from "./index-BK0xWO1z.js";
4
+ import { ar as R, as as A, A as b, aw as H, az as fe, ap as I, ax as C, ay as w } from "./index-D5d4QDq7.js";
5
+ import { useQuery as pe, useQueryClient as O, useMutation as Q } from "@tanstack/react-query";
6
6
  import { format as D, formatDistanceToNow as xe } from "date-fns";
7
7
  import { isEmpty as ge } from "lodash-es";
8
- import { FileJson as Ne, CloudOff as be, Undo2 as Q, Trash as J, X as ye, Rocket as ve, Save as we, MoreHorizontal as De } from "lucide-react";
8
+ import { FileJson as Ne, CloudOff as be, Undo2 as J, Trash as P, X as ye, Rocket as ve, Save as we, MoreHorizontal as De } from "lucide-react";
9
9
  import * as v from "react";
10
10
  import { useEffect as F, startTransition as Se, useState as Ee, Suspense as Ce, lazy as Re } from "react";
11
11
  function Ae(t) {
@@ -22,7 +22,7 @@ function Ae(t) {
22
22
  }
23
23
  const Ie = () => {
24
24
  const t = R(), s = A(), n = O();
25
- return H({
25
+ return Q({
26
26
  mutationFn: async (i) => await s(t, {
27
27
  action: b.DELETE_PAGE_REVISION,
28
28
  data: { revisionId: i }
@@ -35,10 +35,14 @@ const Ie = () => {
35
35
  });
36
36
  }, Oe = () => {
37
37
  const t = R(), s = A(), n = O();
38
- return H({
39
- mutationFn: async ({ revisionId: i, discardCurrent: l }) => await s(t, {
38
+ return Q({
39
+ mutationFn: async ({
40
+ revisionId: i,
41
+ discardCurrent: r,
42
+ pageId: d
43
+ }) => await s(t, {
40
44
  action: b.RESTORE_PAGE_REVISION,
41
- data: { revisionId: i, discardCurrent: l }
45
+ data: { revisionId: i, discardCurrent: r, ...d && { pageId: d } }
42
46
  }),
43
47
  onSuccess: () => {
44
48
  n.invalidateQueries({
@@ -46,7 +50,7 @@ const Ie = () => {
46
50
  });
47
51
  }
48
52
  });
49
- }, ke = Re(() => import("./json-diff-viewer-DNizzMnu.js")), N = ({ tag: t }) => t === "draft" ? /* @__PURE__ */ a("div", { className: "flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-xs text-amber-600", children: [
53
+ }, ke = Re(() => import("./json-diff-viewer-BYHieVod.js")), N = ({ tag: t }) => t === "draft" ? /* @__PURE__ */ a("div", { className: "flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-xs text-amber-600", children: [
50
54
  /* @__PURE__ */ a("span", { className: "relative flex h-2 w-2", children: [
51
55
  /* @__PURE__ */ e("span", { className: "absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75" }),
52
56
  /* @__PURE__ */ e("span", { className: "relative inline-flex h-2 w-2 rounded-full bg-amber-500" })
@@ -66,22 +70,22 @@ const Ie = () => {
66
70
  /* @__PURE__ */ e("span", { className: "text-[11px] leading-tight", children: "Unsaved changes" })
67
71
  ] }) : /* @__PURE__ */ e("span", { className: "rounded bg-purple-500/10 px-1.5 py-0.5 font-mono text-xs font-bold text-purple-600", children: t });
68
72
  function Me({ compare: t, setCompare: s }) {
69
- const { data: n } = $(), { saveState: i } = ce(), [l] = fe();
73
+ const { data: n } = H(), { saveState: i } = ce(), [r] = fe();
70
74
  if (!n) return null;
71
- const d = !!t.find((o) => {
72
- var r;
73
- return (r = o == null ? void 0 : o.uid) == null ? void 0 : r.startsWith("draft:");
74
- }), u = t.length >= 2 && !d, m = i === "UNSAVED";
75
+ const d = !!t.find((u) => {
76
+ var l;
77
+ return (l = u == null ? void 0 : u.uid) == null ? void 0 : l.startsWith("draft:");
78
+ }), o = t.length >= 2 && !d, m = i === "UNSAVED";
75
79
  return /* @__PURE__ */ a("div", { className: "relative flex items-start gap-3 rounded-md border bg-primary/5 p-2 hover:bg-accent/50", children: [
76
80
  /* @__PURE__ */ a("div", { className: "flex-1 space-y-1", children: [
77
81
  /* @__PURE__ */ e("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ a("div", { className: "flex items-center gap-1 text-sm font-medium leading-none", children: [
78
82
  /* @__PURE__ */ e(N, { tag: "draft" }),
79
83
  /* @__PURE__ */ e("span", { className: "text-xs font-bold", children: "Currently editing" })
80
84
  ] }) }),
81
- /* @__PURE__ */ e("div", { className: "flex items-center pl-2 text-[11px] text-muted-foreground", children: !ge(l.lastSaved) && /* @__PURE__ */ a("span", { children: [
85
+ /* @__PURE__ */ e("div", { className: "flex items-center pl-2 text-[11px] text-muted-foreground", children: !ge(r.lastSaved) && /* @__PURE__ */ a("span", { children: [
82
86
  "Last updated",
83
87
  " ",
84
- xe(new Date(l.lastSaved), {
88
+ xe(new Date(r.lastSaved), {
85
89
  addSuffix: !0
86
90
  })
87
91
  ] }) }),
@@ -91,9 +95,9 @@ function Me({ compare: t, setCompare: s }) {
91
95
  K,
92
96
  {
93
97
  checked: d,
94
- disabled: u,
98
+ disabled: o,
95
99
  onChange: () => {
96
- s(d ? t.filter((o) => o.uid !== `draft:${n == null ? void 0 : n.id}`) : [
100
+ s(d ? t.filter((u) => u.uid !== `draft:${n == null ? void 0 : n.id}`) : [
97
101
  ...t,
98
102
  { uid: `draft:${n == null ? void 0 : n.id}`, label: "draft", item: { createdAt: Date.now() } }
99
103
  ]);
@@ -117,22 +121,22 @@ function V({
117
121
  isLatest: s,
118
122
  onRestore: n,
119
123
  onDelete: i,
120
- revisionNumber: l,
124
+ revisionNumber: r,
121
125
  compare: d,
122
- setCompare: u,
126
+ setCompare: o,
123
127
  pageId: m
124
128
  }) {
125
- const { data: o } = I(t.currentEditor), r = (o == null ? void 0 : o.name) || "Unknown", f = !!d.find((h) => {
129
+ const { data: u } = I(t.currentEditor), l = (u == null ? void 0 : u.name) || "Unknown", f = !!d.find((h) => {
126
130
  var x;
127
131
  return s ? (x = h == null ? void 0 : h.uid) == null ? void 0 : x.startsWith("live") : (h == null ? void 0 : h.uid) === t.uid;
128
132
  }), S = d.length >= 2 && !f;
129
133
  return /* @__PURE__ */ a("div", { className: "relative flex items-start gap-3 rounded-md border p-2 hover:bg-accent/50", children: [
130
134
  /* @__PURE__ */ a("div", { className: "flex-1 space-y-3", children: [
131
135
  /* @__PURE__ */ e("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ a("p", { className: "flex items-center gap-1 text-xs leading-none", children: [
132
- /* @__PURE__ */ e(N, { tag: s ? "live" : `#${l}` }),
136
+ /* @__PURE__ */ e(N, { tag: s ? "live" : `#${r}` }),
133
137
  t.type === "published" ? "Published" : "Draft",
134
138
  " by ",
135
- /* @__PURE__ */ e("span", { className: "text-xs font-bold", children: r })
139
+ /* @__PURE__ */ e("span", { className: "text-xs font-bold", children: l })
136
140
  ] }) }),
137
141
  /* @__PURE__ */ a("div", { className: "flex items-center gap-x-3", children: [
138
142
  /* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: t.type === "published" ? /* @__PURE__ */ e(N, { tag: "published" }) : /* @__PURE__ */ e(N, { tag: "draft" }) }),
@@ -146,12 +150,12 @@ function V({
146
150
  checked: f,
147
151
  disabled: S,
148
152
  onChange: () => {
149
- u(
153
+ o(
150
154
  f ? d.filter((h) => s ? h.uid !== `live:${m}` : h.uid !== t.uid) : [
151
155
  ...d,
152
156
  {
153
157
  uid: s ? `live:${m}` : t.uid,
154
- label: s ? "live" : `#${l}`,
158
+ label: s ? "live" : `#${r}`,
155
159
  item: t
156
160
  }
157
161
  ].sort((h, x) => new Date(h.item.createdAt).getTime() - new Date(x.item.createdAt).getTime())
@@ -162,16 +166,16 @@ function V({
162
166
  ] });
163
167
  }
164
168
  function _e({ compare: t, setCompare: s, pageId: n }) {
165
- const [i, l] = Ee(!1), [d, u] = t;
169
+ const [i, r] = Ee(!1), [d, o] = t;
166
170
  if (t.length === 0) return null;
167
- const m = ({ tab: o }) => /* @__PURE__ */ a("span", { className: "flex items-center justify-between rounded border border-blue-100 p-1 font-medium", children: [
168
- /* @__PURE__ */ e(N, { tag: o.label }),
171
+ const m = ({ tab: u }) => /* @__PURE__ */ a("span", { className: "flex items-center justify-between rounded border border-blue-100 p-1 font-medium", children: [
172
+ /* @__PURE__ */ e(N, { tag: u.label }),
169
173
  /* @__PURE__ */ e(
170
174
  "button",
171
175
  {
172
176
  className: "z-0 flex h-4 w-4 items-center justify-center rounded-full text-gray-400 hover:text-red-500",
173
177
  style: { lineHeight: 1 },
174
- onClick: () => s(t.filter((r) => r.uid !== o.uid)),
178
+ onClick: () => s(t.filter((l) => l.uid !== u.uid)),
175
179
  "aria-label": "Remove selection 1",
176
180
  children: /* @__PURE__ */ e(ye, { className: "h-3 w-3" })
177
181
  }
@@ -182,7 +186,7 @@ function _e({ compare: t, setCompare: s, pageId: n }) {
182
186
  /* @__PURE__ */ e("span", { className: "font-medium leading-tight text-gray-600", children: "Compare" }),
183
187
  d && /* @__PURE__ */ e(m, { tab: d }),
184
188
  /* @__PURE__ */ e("span", { className: "font-medium leading-tight text-gray-600", children: "with" }),
185
- u ? /* @__PURE__ */ e(m, { tab: u }) : /* @__PURE__ */ e("span", { className: "rounded border px-1 text-xs text-muted-foreground", children: "Choose another" })
189
+ o ? /* @__PURE__ */ e(m, { tab: o }) : /* @__PURE__ */ e("span", { className: "rounded border px-1 text-xs text-muted-foreground", children: "Choose another" })
186
190
  ] }),
187
191
  /* @__PURE__ */ a("div", { className: "flex items-center justify-end gap-2 pb-0.5 pt-2", children: [
188
192
  /* @__PURE__ */ e(
@@ -201,7 +205,7 @@ function _e({ compare: t, setCompare: s, pageId: n }) {
201
205
  size: "sm",
202
206
  className: "h-6 gap-1 rounded px-2 text-xs leading-none",
203
207
  variant: "default",
204
- onClick: () => l(!0),
208
+ onClick: () => r(!0),
205
209
  disabled: t.length < 2,
206
210
  children: [
207
211
  /* @__PURE__ */ e(Ne, { className: "h-2.5 w-2.5" }),
@@ -214,7 +218,7 @@ function _e({ compare: t, setCompare: s, pageId: n }) {
214
218
  Ce,
215
219
  {
216
220
  fallback: /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-4", children: /* @__PURE__ */ e("span", { className: "text-sm", children: "Loading diff viewer..." }) }),
217
- children: /* @__PURE__ */ e(ke, { open: i, onOpenChange: l, compare: t })
221
+ children: /* @__PURE__ */ e(ke, { open: i, onOpenChange: r, compare: t })
218
222
  }
219
223
  )
220
224
  ] });
@@ -242,13 +246,13 @@ function Ue({ revision: t, onRestore: s, onDelete: n }) {
242
246
  ] }) }),
243
247
  /* @__PURE__ */ a(me, { align: "end", className: "text-xs", children: [
244
248
  /* @__PURE__ */ e(C, { permission: w.RESTORE_REVISION, children: /* @__PURE__ */ a(U, { onClick: s, className: "cursor-pointer text-sm", children: [
245
- /* @__PURE__ */ e(Q, { className: "mr-2 h-4 w-4" }),
249
+ /* @__PURE__ */ e(J, { className: "mr-2 h-4 w-4" }),
246
250
  /* @__PURE__ */ e("span", { children: "Restore this version" })
247
251
  ] }) }),
248
252
  /* @__PURE__ */ e(C, { permission: w.DELETE_REVISION, children: t.uid !== "current" && /* @__PURE__ */ a(p, { children: [
249
253
  /* @__PURE__ */ e(he, {}),
250
254
  /* @__PURE__ */ a(U, { onClick: n, className: "cursor-pointer text-destructive", children: [
251
- /* @__PURE__ */ e(J, { className: "mr-2 h-4 w-4" }),
255
+ /* @__PURE__ */ e(P, { className: "mr-2 h-4 w-4" }),
252
256
  /* @__PURE__ */ e("span", { children: "Delete this version" })
253
257
  ] })
254
258
  ] }) })
@@ -260,15 +264,15 @@ function Fe({
260
264
  onOpenChange: s,
261
265
  revision: n,
262
266
  onRestore: i,
263
- isRestoring: l
267
+ isRestoring: r
264
268
  }) {
265
- const { data: d } = I((n == null ? void 0 : n.currentEditor) || ""), u = (d == null ? void 0 : d.name) || "Unknown";
269
+ const { data: d } = I((n == null ? void 0 : n.currentEditor) || ""), o = (d == null ? void 0 : d.name) || "Unknown";
266
270
  return n ? /* @__PURE__ */ e(
267
271
  q,
268
272
  {
269
273
  open: t,
270
274
  onOpenChange: (m) => {
271
- l || s(m);
275
+ r || s(m);
272
276
  },
273
277
  children: /* @__PURE__ */ a(G, { className: "sm:max-w-md", children: [
274
278
  /* @__PURE__ */ a(j, { children: [
@@ -280,23 +284,23 @@ function Fe({
280
284
  " ",
281
285
  D(n.createdAt, "MMM d, yyyy 'at' h:mm a"),
282
286
  " by ",
283
- u
287
+ o
284
288
  ] })
285
289
  ] }),
286
290
  /* @__PURE__ */ e("div", { className: "py-2", children: /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "How would you like to handle your current edits?" }) }),
287
- /* @__PURE__ */ a(P, { className: "flex flex-col gap-2 sm:flex-row", children: [
288
- /* @__PURE__ */ e(g, { variant: "outline", className: "sm:flex-1", onClick: () => i(!1), disabled: l, children: l ? /* @__PURE__ */ a(p, { children: [
291
+ /* @__PURE__ */ a($, { className: "flex flex-col gap-2 sm:flex-row", children: [
292
+ /* @__PURE__ */ e(g, { variant: "outline", className: "sm:flex-1", onClick: () => i(!1), disabled: r, children: r ? /* @__PURE__ */ a(p, { children: [
289
293
  /* @__PURE__ */ e("span", { className: "mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }),
290
294
  "Saving as draft..."
291
295
  ] }) : /* @__PURE__ */ a(p, { children: [
292
296
  /* @__PURE__ */ e(be, { className: "mr-2 h-4 w-4" }),
293
297
  "Save as draft"
294
298
  ] }) }),
295
- /* @__PURE__ */ e(g, { variant: "default", className: "sm:flex-1", onClick: () => i(!0), disabled: l, children: l ? /* @__PURE__ */ a(p, { children: [
299
+ /* @__PURE__ */ e(g, { variant: "default", className: "sm:flex-1", onClick: () => i(!0), disabled: r, children: r ? /* @__PURE__ */ a(p, { children: [
296
300
  /* @__PURE__ */ e("span", { className: "mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }),
297
301
  "Discarding current..."
298
302
  ] }) : /* @__PURE__ */ a(p, { children: [
299
- /* @__PURE__ */ e(Q, { className: "mr-2 h-4 w-4" }),
303
+ /* @__PURE__ */ e(J, { className: "mr-2 h-4 w-4" }),
300
304
  "Discard current"
301
305
  ] }) })
302
306
  ] })
@@ -309,15 +313,15 @@ function Ve({
309
313
  onOpenChange: s,
310
314
  revision: n,
311
315
  onDelete: i,
312
- isDeleting: l
316
+ isDeleting: r
313
317
  }) {
314
- const { data: d } = I((n == null ? void 0 : n.currentEditor) || ""), u = (d == null ? void 0 : d.name) || "Unknown";
318
+ const { data: d } = I((n == null ? void 0 : n.currentEditor) || ""), o = (d == null ? void 0 : d.name) || "Unknown";
315
319
  return n ? /* @__PURE__ */ e(
316
320
  q,
317
321
  {
318
322
  open: t,
319
323
  onOpenChange: (m) => {
320
- l || s(m);
324
+ r || s(m);
321
325
  },
322
326
  children: /* @__PURE__ */ a(G, { className: "sm:max-w-md", children: [
323
327
  /* @__PURE__ */ a(j, { children: [
@@ -329,17 +333,17 @@ function Ve({
329
333
  " ",
330
334
  D(n.createdAt, "MMM d, yyyy 'at' h:mm a"),
331
335
  " by ",
332
- u
336
+ o
333
337
  ] })
334
338
  ] }),
335
339
  /* @__PURE__ */ e("div", { className: "py-2", children: /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "This action cannot be undone. Are you sure you want to proceed?" }) }),
336
- /* @__PURE__ */ a(P, { className: "flex flex-col gap-2 sm:flex-row", children: [
337
- /* @__PURE__ */ e(g, { variant: "outline", className: "sm:flex-1", onClick: () => s(!1), disabled: l, children: "Cancel" }),
338
- /* @__PURE__ */ e(g, { variant: "destructive", className: "sm:flex-1", onClick: i, disabled: l, children: l ? /* @__PURE__ */ a(p, { children: [
340
+ /* @__PURE__ */ a($, { className: "flex flex-col gap-2 sm:flex-row", children: [
341
+ /* @__PURE__ */ e(g, { variant: "outline", className: "sm:flex-1", onClick: () => s(!1), disabled: r, children: "Cancel" }),
342
+ /* @__PURE__ */ e(g, { variant: "destructive", className: "sm:flex-1", onClick: i, disabled: r, children: r ? /* @__PURE__ */ a(p, { children: [
339
343
  /* @__PURE__ */ e("span", { className: "mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }),
340
344
  "Deleting..."
341
345
  ] }) : /* @__PURE__ */ a(p, { children: [
342
- /* @__PURE__ */ e(J, { className: "mr-2 h-4 w-4" }),
346
+ /* @__PURE__ */ e(P, { className: "mr-2 h-4 w-4" }),
343
347
  "Delete Revision"
344
348
  ] }) })
345
349
  ] })
@@ -347,27 +351,31 @@ function Ve({
347
351
  }
348
352
  ) : null;
349
353
  }
350
- function Je({ isOpen: t }) {
354
+ function Pe({ isOpen: t }) {
351
355
  var T, _;
352
- const [s, n] = v.useState([]), [i, l] = v.useState(null), [d, u] = v.useState(!1), [m, o] = v.useState(!1), { data: r } = $(), { data: f, isFetching: S, error: h, refetch: x } = Ae(r == null ? void 0 : r.id), { mutate: B, isPending: W } = Ie(), { mutate: Y, isPending: X } = Oe(), Z = O(), { selectedLang: ee, fallbackLang: te } = le(), ae = ee || te;
356
+ const [s, n] = v.useState([]), [i, r] = v.useState(null), [d, o] = v.useState(!1), [m, u] = v.useState(!1), { data: l } = H(), { data: f, isFetching: S, error: h, refetch: x } = Ae(l == null ? void 0 : l.id), { mutate: B, isPending: W } = Ie(), { mutate: Y, isPending: X } = Oe(), Z = O(), { selectedLang: ee, fallbackLang: te } = le(), ae = ee || te;
353
357
  F(() => {
354
358
  Se(() => n([]));
355
- }, [r == null ? void 0 : r.id]);
359
+ }, [l == null ? void 0 : l.id]);
356
360
  const ne = (c) => {
357
361
  i && Y(
358
- { revisionId: i.uid, discardCurrent: c },
362
+ {
363
+ revisionId: i.uid,
364
+ discardCurrent: c,
365
+ ...i.uid === "current" && (l == null ? void 0 : l.id) && { pageId: l.id }
366
+ },
359
367
  {
360
368
  onSuccess: () => {
361
- u(!1), l(null), Z.invalidateQueries({
369
+ o(!1), r(null), Z.invalidateQueries({
362
370
  queryKey: [b.GET_DRAFT_PAGE]
363
371
  });
364
372
  }
365
373
  }
366
374
  );
367
375
  }, k = (c) => {
368
- l(c), u(!0);
376
+ r(c), o(!0);
369
377
  }, M = (c) => {
370
- l(c), o(!0);
378
+ r(c), u(!0);
371
379
  }, se = () => {
372
380
  i && B(i.uid, {
373
381
  /**
@@ -375,7 +383,7 @@ function Je({ isOpen: t }) {
375
383
  * delete dialog and resets the selected revision to null.
376
384
  */
377
385
  onSuccess: () => {
378
- o(!1), l(null);
386
+ u(!1), r(null);
379
387
  }
380
388
  });
381
389
  };
@@ -384,18 +392,18 @@ function Je({ isOpen: t }) {
384
392
  }, [t, x]), /* @__PURE__ */ a(p, { children: [
385
393
  /* @__PURE__ */ a(re, { children: [
386
394
  /* @__PURE__ */ e(ie, { children: "Revision History" }),
387
- (r == null ? void 0 : r.createdAt) && /* @__PURE__ */ a("p", { className: "mt-1 text-xs text-muted-foreground", children: [
395
+ (l == null ? void 0 : l.createdAt) && /* @__PURE__ */ a("p", { className: "mt-1 text-xs text-muted-foreground", children: [
388
396
  "Page created on ",
389
- D(new Date(r.createdAt), "MMM d, yyyy 'at' h:mm a")
397
+ D(new Date(l.createdAt), "MMM d, yyyy 'at' h:mm a")
390
398
  ] })
391
399
  ] }),
392
400
  S ? /* @__PURE__ */ e(Te, {}) : h ? /* @__PURE__ */ e("div", { className: "p-4 text-center text-sm text-muted-foreground", children: "Failed to load revisions. Please try again." }) : /* @__PURE__ */ a("div", { className: "mt-2 flex h-full min-h-0 flex-1 flex-col space-y-2", children: [
393
- /* @__PURE__ */ e(_e, { lang: ae, compare: s, setCompare: n, pageId: r == null ? void 0 : r.id }),
401
+ /* @__PURE__ */ e(_e, { lang: ae, compare: s, setCompare: n, pageId: l == null ? void 0 : l.id }),
394
402
  /* @__PURE__ */ e(Me, { compare: s, setCompare: n }),
395
403
  (T = f == null ? void 0 : f.filter((c) => c.uid === "current")) == null ? void 0 : T.map((c, E) => /* @__PURE__ */ e(
396
404
  V,
397
405
  {
398
- pageId: r == null ? void 0 : r.id,
406
+ pageId: l == null ? void 0 : l.id,
399
407
  revision: c,
400
408
  isLatest: !0,
401
409
  onRestore: () => k(c),
@@ -409,7 +417,7 @@ function Je({ isOpen: t }) {
409
417
  /* @__PURE__ */ e(de, { className: "min-h-0 flex-1", children: /* @__PURE__ */ e("div", { className: "space-y-2", children: (_ = f == null ? void 0 : f.filter((c) => c.uid !== "current")) == null ? void 0 : _.map((c, E) => /* @__PURE__ */ e(
410
418
  V,
411
419
  {
412
- pageId: r == null ? void 0 : r.id,
420
+ pageId: l == null ? void 0 : l.id,
413
421
  revision: c,
414
422
  isLatest: c.uid === "current",
415
423
  onRestore: () => k(c),
@@ -425,7 +433,7 @@ function Je({ isOpen: t }) {
425
433
  Fe,
426
434
  {
427
435
  open: d,
428
- onOpenChange: u,
436
+ onOpenChange: o,
429
437
  revision: i,
430
438
  onRestore: ne,
431
439
  isRestoring: X
@@ -435,7 +443,7 @@ function Je({ isOpen: t }) {
435
443
  Ve,
436
444
  {
437
445
  open: m,
438
- onOpenChange: o,
446
+ onOpenChange: u,
439
447
  revision: i,
440
448
  onDelete: se,
441
449
  isDeleting: W
@@ -444,5 +452,5 @@ function Je({ isOpen: t }) {
444
452
  ] });
445
453
  }
446
454
  export {
447
- Je as default
455
+ Pe as default
448
456
  };
package/dist/pages.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DKuwxj1x.cjs");exports.ChaiJsonInput=e.SmartJsonInput;exports.ChaiWebsiteBuilder=e.ChaiWebsiteBuilder;exports.ImagePicker=e.ImagePicker;exports.LanguageSwitcher=e.LanguageSwitcher;exports.NestedPathSelector=e.NestedPathSelector;exports.PermissionChecker=e.PermissionChecker;exports.useActivePage=e.useActivePage;exports.useApiUrl=e.useApiUrl;exports.useBuilderFetch=e.useBuilderFetch;exports.useBuilderPageData=e.useBuilderPageData;exports.useChaiAuth=e.useChaiAuth;exports.useChaiCurrentPage=e.useChaiCurrentPage;exports.useChaiUserInfo=e.useChaiUserInfo;exports.useClearAll=e.useClearAll;exports.useFallbackLang=e.useFallbackLang;exports.useFetch=e.useFetch;exports.useGotoPage=e.useGotoPage;exports.useLanguagePages=e.useLanguagePages;exports.usePageTypes=e.usePageTypes;exports.useReloadPage=e.useReloadPage;exports.useUpdateActivePageMetadata=e.useUpdateActivePageMetadata;exports.useUserPermissions=e.useUserRoleAndPermissions;exports.useWebsitePages=e.useWebsitePages;exports.useWebsiteSetting=e.useWebsiteSetting;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BRJCj7c_.cjs");exports.ChaiJsonInput=e.SmartJsonInput;exports.ChaiWebsiteBuilder=e.ChaiWebsiteBuilder;exports.ImagePicker=e.ImagePicker;exports.LanguageSwitcher=e.LanguageSwitcher;exports.NestedPathSelector=e.NestedPathSelector;exports.PermissionChecker=e.PermissionChecker;exports.useActivePage=e.useActivePage;exports.useApiUrl=e.useApiUrl;exports.useBuilderFetch=e.useBuilderFetch;exports.useBuilderPageData=e.useBuilderPageData;exports.useChaiAuth=e.useChaiAuth;exports.useChaiCurrentPage=e.useChaiCurrentPage;exports.useChaiUserInfo=e.useChaiUserInfo;exports.useClearAll=e.useClearAll;exports.useFallbackLang=e.useFallbackLang;exports.useFetch=e.useFetch;exports.useGotoPage=e.useGotoPage;exports.useLanguagePages=e.useLanguagePages;exports.usePageTypes=e.usePageTypes;exports.useReloadPage=e.useReloadPage;exports.useUpdateActivePageMetadata=e.useUpdateActivePageMetadata;exports.useUserPermissions=e.useUserRoleAndPermissions;exports.useWebsitePages=e.useWebsitePages;exports.useWebsiteSetting=e.useWebsiteSetting;
package/dist/pages.d.ts CHANGED
@@ -28,8 +28,9 @@ declare type ChaiBlock<T = Record<string, any>> = {
28
28
  _id: string;
29
29
  _name?: string;
30
30
  _parent?: string | null | undefined;
31
- _type: string;
32
31
  _libBlock?: string;
32
+ _type: string;
33
+ partialBlockId?: string;
33
34
  } & T;
34
35
 
35
36
  declare interface ChaiBuilderEditorProps {
package/dist/pages.js CHANGED
@@ -1,4 +1,4 @@
1
- import { aE as s, aT as u, aP as t, aN as i, aO as r, ax as g, aU as P, ar as l, v as h, aK as n, aZ as o, aw as c, ap as C, aV as d, k as p, as as m, aW as A, l as U, m as b, aX as k, aY as W, a_ as v, g as B, j as F } from "./index-Bn0fFN58.js";
1
+ import { aE as s, aT as u, aP as t, aN as i, aO as r, ax as g, aU as P, ar as l, v as h, aK as n, aZ as o, aw as c, ap as C, aV as d, k as p, as as m, aW as A, l as U, m as b, aX as k, aY as W, a_ as v, g as B, j as F } from "./index-D5d4QDq7.js";
2
2
  export {
3
3
  s as ChaiJsonInput,
4
4
  u as ChaiWebsiteBuilder,
@@ -1,8 +1,8 @@
1
1
  import { jsxs as n, jsx as t, Fragment as $ } from "react/jsx-runtime";
2
- import { B as L } from "./register-chai-top-bar-ESJHs5s-.js";
3
- import { d as K, e as Q, f as J, p as V, q as W } from "./index-CAhEmHYP.js";
4
- import { ar as X, as as Y, A as I, aA as O, aB as Z, k as ee, m as te, ap as se, T as U, t as le } from "./index-Bn0fFN58.js";
5
- import { LanguageSelector as ae } from "./page-manager-search-and-filter-CuZkQaZg.js";
2
+ import { B as L } from "./register-chai-top-bar-CX_JkRJn.js";
3
+ import { d as K, e as Q, f as J, p as V, q as W } from "./index-BK0xWO1z.js";
4
+ import { ar as X, as as Y, A as I, aA as O, aB as Z, k as ee, m as te, ap as se, T as U, t as le } from "./index-D5d4QDq7.js";
5
+ import { LanguageSelector as ae } from "./page-manager-search-and-filter-C1IWF_4d.js";
6
6
  import { useQuery as ne } from "@tanstack/react-query";
7
7
  import { find as B, filter as a, map as b, keys as re, get as F, includes as C, orderBy as N, isEmpty as oe, uniq as G, first as ce, concat as ie } from "lodash-es";
8
8
  import { Lock as de, GlobeIcon as ue, File as me, Edit as he } from "lucide-react";