@chaibuilder/sdk 4.0.0-beta.3 → 4.0.0-beta.30

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 (245) hide show
  1. package/README.md +72 -50
  2. package/dist/{2SSKDMRQ-CnSDkQcy.js → 2SSKDMRQ-B5Tzwoh4.js} +2 -2
  3. package/dist/{2SSKDMRQ-BnsZi3K3.cjs → 2SSKDMRQ-Dub3pRV1.cjs} +1 -1
  4. package/dist/{AP7HFJJL-CymCmW14.js → AP7HFJJL-CfmdXP9M.js} +1 -1
  5. package/dist/{AP7HFJJL-B31839PG.cjs → AP7HFJJL-Dt6MglIr.cjs} +1 -1
  6. package/dist/{IconPicker-B1rWC-Ex.js → IconPicker-Cn8Z42-Z.js} +8 -7
  7. package/dist/IconPicker-DLqOB-ri.cjs +1 -0
  8. package/dist/STRINGS-BExFecZW.js +8 -0
  9. package/dist/STRINGS-FNnfjF5H.cjs +1 -0
  10. package/dist/{WDYDFRGG-BUVnbAci.js → WDYDFRGG-BOpmZGHS.js} +2 -2
  11. package/dist/{WDYDFRGG-BxhOCHc3.cjs → WDYDFRGG-Dfj1ikzw.cjs} +1 -1
  12. package/dist/{actions-registery-CZ1w0NKa.js → actions-registery-Bj-j1k5i.js} +2668 -2585
  13. package/dist/actions-registery-Cy1lqUVI.cjs +481 -0
  14. package/dist/actions.cjs +1 -1
  15. package/dist/actions.d.ts +0 -158
  16. package/dist/actions.js +3 -3
  17. package/dist/active-in-another-tab-CEWvA8SG.js +35 -0
  18. package/dist/active-in-another-tab-DV83cJ_v.cjs +1 -0
  19. package/dist/{add-new-language-page-WmlCnytQ.js → add-new-language-page-B3wK94-S.js} +54 -53
  20. package/dist/add-new-language-page-C3Uu92KN.cjs +1 -0
  21. package/dist/{add-new-page-soZ8GAkN.cjs → add-new-page-BOE-xwBc.cjs} +1 -1
  22. package/dist/{add-new-page-VW2wAYZp.js → add-new-page-DsvGVrR8.js} +2 -2
  23. package/dist/{ai-panel-content-D_o7Q_A-.js → ai-panel-content-BBSzHZG6.js} +12 -11
  24. package/dist/ai-panel-content-DBlnfRRi.cjs +1 -0
  25. package/dist/ai-panel-default-lang-BVBuwnyU.js +317 -0
  26. package/dist/ai-panel-default-lang-DJJWAtN0.cjs +3 -0
  27. package/dist/ai-panel-other-lang-fIEZkmRy.js +132 -0
  28. package/dist/ai-panel-other-lang-v8Yd5ggR.cjs +1 -0
  29. package/dist/ai-prompt-input-C7ha_0Cn.cjs +1 -0
  30. package/dist/{ai-prompt-input-Bhc0ds7X.js → ai-prompt-input-CmSfGxTN.js} +70 -73
  31. package/dist/ai-translation-prompt-BzTGAS3W.cjs +1 -0
  32. package/dist/{ai-translation-prompt-CZ55HQmo.js → ai-translation-prompt-CtBmvsRy.js} +2 -2
  33. package/dist/apply-binding-9XSrYzAE.cjs +1 -0
  34. package/dist/{apply-binding-6iwlED02.js → apply-binding-chfbBKi2.js} +238 -225
  35. package/dist/change-password-modal-CdOwtCWN.cjs +1 -0
  36. package/dist/change-password-modal-DxkhBI5d.js +137 -0
  37. package/dist/code-display-BR-gij5j.cjs +1 -0
  38. package/dist/{code-display-DhD_RBcg.js → code-display-DdWcOQ_i.js} +1 -1
  39. package/dist/code-editor-Bpn8z2fo.js +57 -0
  40. package/dist/code-editor-fL3s6Hk7.cjs +1 -0
  41. package/dist/{continue-editing-in-this-client-CS2aQ7yY.js → continue-editing-in-this-client-DDB816CQ.js} +10 -9
  42. package/dist/continue-editing-in-this-client-DjxpjsA8.cjs +1 -0
  43. package/dist/core-BWQrViOY.cjs +1 -0
  44. package/dist/core-QlWEXm1d.js +53 -0
  45. package/dist/core.cjs +1 -1
  46. package/dist/core.d.ts +272 -105
  47. package/dist/core.js +64 -33
  48. package/dist/{css-import-modal-Byg6wV0O.js → css-import-modal-CL8SIC3K.js} +11 -9
  49. package/dist/css-import-modal-CRC7bK1c.cjs +13 -0
  50. package/dist/{delete-design-token-BRZZiWtQ.js → delete-design-token-B0md8qUi.js} +1 -1
  51. package/dist/{delete-design-token-DkVs1oBf.cjs → delete-design-token-C94IgWdi.cjs} +1 -1
  52. package/dist/delete-page-41tvYcEw.js +71 -0
  53. package/dist/delete-page-BHPlx8ec.cjs +1 -0
  54. package/dist/{design-token-usage-xQs6SlaJ.js → design-token-usage-CyOY4Pni.js} +19 -18
  55. package/dist/design-token-usage-DtdjTCn3.cjs +1 -0
  56. package/dist/{digital-asset-manager-DbtwzxRz.js → digital-asset-manager-C_ru4Zes.js} +6 -5
  57. package/dist/digital-asset-manager-DSLQz8qk.cjs +1 -0
  58. package/dist/duplicate-page-BvggF83O.cjs +1 -0
  59. package/dist/{duplicate-page-BR7Dlo9d.js → duplicate-page-DMmDdmfS.js} +20 -19
  60. package/dist/dynamic-page-selector-C5agz2Ze.cjs +1 -0
  61. package/dist/{dynamic-page-selector-Cb5r_W8s.js → dynamic-page-selector-D2z51nLi.js} +12 -11
  62. package/dist/fonts/bungee/Bungee-Regular.woff2 +0 -0
  63. package/dist/fonts/dm_sans/dm-sans-variable.woff2 +0 -0
  64. package/dist/fonts/geist/Geist-VariableFont_wght.ttf +0 -0
  65. package/dist/fonts/geist/Geist-VariableFont_wght.woff2 +0 -0
  66. package/dist/fonts/geist/geist-variable.woff2 +0 -0
  67. package/dist/fonts/geist-mono/GeistMono-VariableFont_wght.woff2 +0 -0
  68. package/dist/fonts/inter/inter-latin.woff2 +0 -0
  69. package/dist/fonts/inter/inter-variable.woff2 +1449 -0
  70. package/dist/fonts/lato/lato-variable.woff2 +0 -0
  71. package/dist/fonts/lavishly_yours/lavishly-yours.woff2 +11 -0
  72. package/dist/fonts/merriweather/merriweather-variable.woff2 +11 -0
  73. package/dist/fonts/montserrat/montserrat-variable.woff2 +0 -0
  74. package/dist/fonts/nunito_sans/nunito-sans-variable.woff2 +11 -0
  75. package/dist/fonts/open_sans/open-sans-variable.woff2 +0 -0
  76. package/dist/fonts/oswald/oswald-variable.woff2 +0 -0
  77. package/dist/fonts/playfair_display/playfair-display-variable.woff2 +11 -0
  78. package/dist/fonts/poppins/poppins-variable.woff2 +0 -0
  79. package/dist/fonts/raleway/raleway-variable.woff2 +0 -0
  80. package/dist/fonts/roboto/roboto-variable.woff2 +11 -0
  81. package/dist/fonts/source_sans_3/source-sans-3-variable.woff2 +11 -0
  82. package/dist/fonts/ubuntu/ubuntu-variable.woff2 +0 -0
  83. package/dist/fonts-B3UYxuJI.js +25 -0
  84. package/dist/fonts-D5fTqvSS.cjs +1 -0
  85. package/dist/get-chai-builder-tailwind-config-DNp8Vhme.cjs +1 -0
  86. package/dist/{get-chai-builder-tailwind-config-DjoVOuAf.js → get-chai-builder-tailwind-config-k8l5sdcw.js} +5 -5
  87. package/dist/{get-chai-builder-theme-Dl72X7cz.cjs → get-chai-builder-theme-B5RkBTsB.cjs} +1 -1
  88. package/dist/{get-chai-builder-theme-BYtp20KD.js → get-chai-builder-theme-BSUcPs5t.js} +1 -1
  89. package/dist/{image-editor-G-K28aTS.cjs → image-editor-DFmlG348.cjs} +1 -1
  90. package/dist/{image-editor-DV8kUKhl.js → image-editor-sKvOFo-S.js} +1 -1
  91. package/dist/{index-Ct7ElCGK.js → index-BFnMzGe6.js} +5381 -5895
  92. package/dist/index-Bzn_gpaK.cjs +5 -0
  93. package/dist/index-CA1OwKJX.js +4887 -0
  94. package/dist/index-D30xvFa5.cjs +160 -0
  95. package/dist/{json-diff-viewer-krslPepD.js → json-diff-viewer-B5wAR5GY.js} +82 -79
  96. package/dist/json-diff-viewer-DRQSNhaS.cjs +8 -0
  97. package/dist/lang-panel-BZsICcBR.cjs +1 -0
  98. package/dist/{lang-panel-BwIewMyw.js → lang-panel-q04hEq5o.js} +15 -14
  99. package/dist/library-blocks/blocks-list.json +16 -0
  100. package/dist/library-blocks/hero-1/hero-1.html +74 -0
  101. package/dist/library-blocks/hero-1/hero-1.webp +0 -0
  102. package/dist/library-blocks/hero-2/hero-2.html +95 -0
  103. package/dist/library-blocks/hero-2/hero-2.webp +0 -0
  104. package/dist/{manage-design-tokens-Caz_20VK.js → manage-design-tokens-Cene3KEu.js} +16 -15
  105. package/dist/manage-design-tokens-Di5C6nTj.cjs +1 -0
  106. package/dist/mark-as-template-CT-hLGIW.cjs +1 -0
  107. package/dist/{mark-as-template-D295ZQtU.js → mark-as-template-raTtKmQ9.js} +17 -16
  108. package/dist/nested-path-selector-content-CSUHTj9G.cjs +1 -0
  109. package/dist/{nested-path-selector-content-CKYYK-C5.js → nested-path-selector-content-CzQ2Lorl.js} +24 -23
  110. package/dist/{no-language-page-content-BvqRBP6y.js → no-language-page-content-Bg6VjMVY.js} +8 -7
  111. package/dist/no-language-page-content-Bkj8JpEY.cjs +1 -0
  112. package/dist/{no-language-page-dialog-PjNqTUpl.js → no-language-page-dialog-CRPMr9YT.js} +2 -2
  113. package/dist/{no-language-page-dialog-BcEoqyQB.cjs → no-language-page-dialog-TffLjvJn.cjs} +1 -1
  114. package/dist/{page-creator-DiOITEMw.js → page-creator-CQhE1tgn.js} +147 -146
  115. package/dist/page-creator-RrUhy8uH.cjs +1 -0
  116. package/dist/{page-lock-BdYmCks0.cjs → page-lock-D9h5pgxn.cjs} +1 -1
  117. package/dist/{page-lock-Bfbs6RgL.js → page-lock-Dye1JZBB.js} +2 -2
  118. package/dist/{page-locked-dialog-B6MKTRfY.js → page-locked-dialog-BMjPVyHF.js} +19 -16
  119. package/dist/page-locked-dialog-b2_f-A7a.cjs +1 -0
  120. package/dist/page-manager-new-2mDjnSqc.cjs +1 -0
  121. package/dist/page-manager-new-DP1b_dXt.js +411 -0
  122. package/dist/page-manager-search-and-filter-D0ZXojiu.cjs +1 -0
  123. package/dist/{page-manager-search-and-filter-CM0UMb6U.js → page-manager-search-and-filter-DCcYyoPO.js} +20 -19
  124. package/dist/page-revisions-content-BX8ZWebc.cjs +1 -0
  125. package/dist/{page-revisions-content-NH9JK4Ey.js → page-revisions-content-mDwvH6J-.js} +134 -120
  126. package/dist/pages.cjs +1 -1
  127. package/dist/pages.d.ts +297 -97
  128. package/dist/pages.js +22 -19
  129. package/dist/plugin-DHpuZZXz.cjs +22 -0
  130. package/dist/plugin-Dkmjb2_e.js +248 -0
  131. package/dist/publish-pages-content-CR4e9inX.cjs +1 -0
  132. package/dist/{publish-pages-content-D9aixMN5.js → publish-pages-content-M_Kb8b-F.js} +71 -70
  133. package/dist/register-chai-top-bar-D6GjnauV.js +237 -0
  134. package/dist/register-chai-top-bar-DyW9GPzV.cjs +1 -0
  135. package/dist/render.cjs +2 -2
  136. package/dist/render.d.ts +21 -20
  137. package/dist/render.js +127 -120
  138. package/dist/rte-widget-modal-BRSm1Lnp.cjs +1 -0
  139. package/dist/{rte-widget-modal-DOJEXLIf.js → rte-widget-modal-CVZDktXI.js} +10 -9
  140. package/dist/runtime-client.cjs +1 -0
  141. package/dist/runtime-client.d.ts +158 -0
  142. package/dist/runtime-client.js +32 -0
  143. package/dist/runtime.cjs +11 -1
  144. package/dist/runtime.d.ts +158 -114
  145. package/dist/runtime.js +107 -42
  146. package/dist/{save-to-lib-eiOc_SSN.js → save-to-lib-B1ccNhR2.js} +152 -145
  147. package/dist/save-to-lib-CYEAWxL9.cjs +1 -0
  148. package/dist/sdk.css +1 -1
  149. package/dist/selected-block-display-MyU0rS4q.cjs +16 -0
  150. package/dist/{selected-block-display-CBFePS19.js → selected-block-display-aGR7p5JC.js} +36 -35
  151. package/dist/seo-panel-B5mDwpaT.cjs +2 -0
  152. package/dist/{seo-panel-C1-iMOR1.js → seo-panel-P9uixkoZ.js} +149 -148
  153. package/dist/{shared-json-ld-B4PxAM_0.js → shared-json-ld-Ba9GcvLr.js} +72 -71
  154. package/dist/shared-json-ld-DhQJh_mT.cjs +1 -0
  155. package/dist/slug-input-BdMnlYKT.cjs +1 -0
  156. package/dist/{slug-input-AwNJs9im.js → slug-input-CAfGHqMW.js} +9 -8
  157. package/dist/supabase-actions.cjs +1 -1
  158. package/dist/supabase-actions.d.ts +40 -1
  159. package/dist/supabase-actions.js +231 -192
  160. package/dist/take-over-request-BeHTL28z.cjs +1 -0
  161. package/dist/{take-over-request-C4FeDtN_.js → take-over-request-CXjaDliJ.js} +18 -17
  162. package/dist/theme-panel-footer-BkwhuXM7.js +26 -0
  163. package/dist/theme-panel-footer-D_gxD0j4.cjs +1 -0
  164. package/dist/{translation-warning-modal-B64YqlbI.js → translation-warning-modal-CTfArsb1.js} +11 -10
  165. package/dist/translation-warning-modal-D_vt37fW.cjs +1 -0
  166. package/dist/types.cjs +1 -0
  167. package/dist/types.d.ts +740 -0
  168. package/dist/types.js +1 -0
  169. package/dist/unmark-as-template-D2bvjGKt.cjs +1 -0
  170. package/dist/{unmark-as-template-CZ9sQp_P.js → unmark-as-template-vFgMIdxN.js} +12 -11
  171. package/dist/unpublish-page-CPjHmtSM.cjs +1 -0
  172. package/dist/unpublish-page-CxkjTzBB.js +28 -0
  173. package/dist/utils.cjs +1 -1
  174. package/dist/utils.d.ts +8 -5
  175. package/dist/utils.js +2 -2
  176. package/dist/web-blocks.cjs +1 -1
  177. package/dist/web-blocks.js +341 -332
  178. package/dist/{web-preview-Djy6WIyj.js → web-preview--by73Vvr.js} +2 -2
  179. package/dist/web-preview-C3AMe_BB.cjs +1 -0
  180. package/package.json +36 -31
  181. package/dist/IconPicker-DREyo007.cjs +0 -1
  182. package/dist/actions-registery-YnFmU21O.cjs +0 -418
  183. package/dist/active-in-another-tab-B47YjQGN.cjs +0 -1
  184. package/dist/active-in-another-tab-CyjngVA6.js +0 -34
  185. package/dist/add-new-language-page-88xzrUy8.cjs +0 -1
  186. package/dist/ai-panel-content-7zCil042.cjs +0 -1
  187. package/dist/ai-panel-default-lang-COYaxNwn.cjs +0 -3
  188. package/dist/ai-panel-default-lang-DnElspF0.js +0 -341
  189. package/dist/ai-panel-other-lang-CkynNlAU.cjs +0 -1
  190. package/dist/ai-panel-other-lang-Dp0E9_Hx.js +0 -162
  191. package/dist/ai-prompt-input-CThbVp0_.cjs +0 -1
  192. package/dist/ai-translation-prompt-C2kJQFDX.cjs +0 -1
  193. package/dist/apply-binding-KKp5PnpZ.cjs +0 -1
  194. package/dist/code-display-BnqzqzoP.cjs +0 -1
  195. package/dist/code-editor-DRIAnNbb.js +0 -50
  196. package/dist/code-editor-o3___nu2.cjs +0 -1
  197. package/dist/continue-editing-in-this-client-CtMYsk-A.cjs +0 -1
  198. package/dist/core-BoRDjj4h.cjs +0 -1
  199. package/dist/core-yvI6kCyw.js +0 -56
  200. package/dist/css-import-modal-CyqkXWCO.cjs +0 -13
  201. package/dist/delete-page-BzyX9TN-.js +0 -70
  202. package/dist/delete-page-DxX7PFIE.cjs +0 -1
  203. package/dist/design-token-usage-CAHzEGgJ.cjs +0 -1
  204. package/dist/digital-asset-manager--uO8Agia.cjs +0 -1
  205. package/dist/duplicate-page-CaNAbXwV.cjs +0 -1
  206. package/dist/dynamic-page-selector-Cxk_gjni.cjs +0 -1
  207. package/dist/fonts/GeistMonoVF.woff +0 -0
  208. package/dist/fonts/GeistVF.woff +0 -0
  209. package/dist/fonts-B-Xt29pe.cjs +0 -1
  210. package/dist/fonts-DRly3Wzd.js +0 -78
  211. package/dist/get-chai-builder-tailwind-config-B9rCyiQo.cjs +0 -1
  212. package/dist/index-B-rSiAp_.cjs +0 -1
  213. package/dist/index-DF5DEvqb.cjs +0 -160
  214. package/dist/index-Dxfyt4d4.js +0 -39
  215. package/dist/index-WQwzsC7A.cjs +0 -5
  216. package/dist/index-ZuacEL1j.js +0 -4732
  217. package/dist/json-diff-viewer-D7z4zNvv.cjs +0 -8
  218. package/dist/lang-panel-DT96k1xg.cjs +0 -1
  219. package/dist/manage-design-tokens-CrmLe7UT.cjs +0 -1
  220. package/dist/mark-as-template-W3LmpiqN.cjs +0 -1
  221. package/dist/nested-path-selector-content-CoS_d3dc.cjs +0 -1
  222. package/dist/no-language-page-content-DkfeMl90.cjs +0 -1
  223. package/dist/page-creator-C4gc5NSC.cjs +0 -1
  224. package/dist/page-locked-dialog-B1FAtK92.cjs +0 -1
  225. package/dist/page-manager-new-CHDueBDk.cjs +0 -1
  226. package/dist/page-manager-new-CzX22g2n.js +0 -394
  227. package/dist/page-manager-search-and-filter-DkkRIH86.cjs +0 -1
  228. package/dist/page-revisions-content-ChY-4f2V.cjs +0 -1
  229. package/dist/plugin-3ZKK6RXm.js +0 -245
  230. package/dist/plugin-C6rgJDNQ.cjs +0 -22
  231. package/dist/publish-pages-content-x-JuSFJ9.cjs +0 -1
  232. package/dist/rte-widget-modal-BaHIuEjF.cjs +0 -1
  233. package/dist/save-to-lib-Cgpxw8-g.cjs +0 -1
  234. package/dist/selected-block-display-BgRY82CT.cjs +0 -16
  235. package/dist/seo-panel-DfAb8U7W.cjs +0 -2
  236. package/dist/shared-json-ld-DzG398hr.cjs +0 -1
  237. package/dist/slug-input-C_ijLQ_X.cjs +0 -1
  238. package/dist/take-over-request-BNxcjY2j.cjs +0 -1
  239. package/dist/theme-panel-footer-Cq9pljro.cjs +0 -1
  240. package/dist/theme-panel-footer-uBQqSJXm.js +0 -25
  241. package/dist/translation-warning-modal-BZAcwM2_.cjs +0 -1
  242. package/dist/unmark-as-template-EVvk0vmp.cjs +0 -1
  243. package/dist/unpublish-page-D4VwOlxc.js +0 -27
  244. package/dist/unpublish-page-bdSmwAVQ.cjs +0 -1
  245. package/dist/web-preview-Cio70gk5.cjs +0 -1
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("./register-chai-top-bar-DyW9GPzV.cjs"),a=require("./index-D30xvFa5.cjs"),o=require("react"),_=require("./slug-input-BdMnlYKT.cjs"),w=require("lodash-es"),N=require("lucide-react"),k=require("./index-Bzn_gpaK.cjs"),je=require("@tanstack/react-query"),J=require("sonner"),fe=require("./get-seo-defaults-Cw7vFt-B.cjs");function Ue({value:t,onChange:c,placeholder:j="Enter custom slug part",dynamicPattern:p,onValidationChange:i}){const[f,m]=o.useState(null),h=o.useRef(null),[g,T]=o.useState(p+t);o.useEffect(()=>{T(p+t)},[t,p]);const O=S=>{const C=S.target.value;if(!C.startsWith(p)){const W=C.replace(p,""),G=p+W;T(G),c(W);return}const l=C.substring(p.length).replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),n=(l.match(/\./g)||[]).length,x=n<=1;n>1?m("Invalid slug. Only one dot (.) is allowed in the slug"):m(null),i&&i(x);const y=p+l;T(y),c(l)},b=()=>{if(h.current){const S=h.current;setTimeout(()=>{const C=p.length;S.setSelectionRange(C,C)},0)}},R=S=>{const C=S.currentTarget;(C.selectionStart||0)<=p.length&&setTimeout(()=>{const l=p.length;C.setSelectionRange(l,l)},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(v.Input,{ref:h,value:g,onChange:O,onFocus:b,onClick:R,placeholder:j,className:f?"border-red-500":""}),f&&e.jsx("div",{className:"mt-1 text-xs text-red-500",children:f})]})})}const X=({children:t,onWheel:c,...j})=>{const p=i=>{try{i.preventDefault();const f=i.currentTarget;f.scrollTop+=i.deltaY}catch{i.preventDefault()}c&&c(i)};return e.jsx(a.CommandList,{...j,onWheel:p,children:t})},te=(...t)=>t.filter(Boolean).join(" ");function ze({pages:t,selectedParentId:c,onChange:j,className:p,id:i="parentPage",currentPage:f}){const[m,h]=o.useState(!1),[g,T]=o.useState(""),O=v.useChaiFeatureFlag("enable-add-page-dropdown");O||(p="w-full rounded-md border border-gray-300 px-3 py-2");const b=o.useMemo(()=>!t||t.length===0?[]:t.filter(x=>!w.isEmpty(x.slug)).filter(x=>x.slug!=="/").sort((x,y)=>x.slug.localeCompare(y.slug)),[t]),R=o.useMemo(()=>{if(!g.trim())return b;const n=g.toLowerCase();return b.filter(x=>x.name.toLowerCase().includes(n)||x.slug.toLowerCase().includes(n))},[b,g]),S=n=>Math.max(0,(n.match(/\//g)||[]).length-1),C=n=>"    ".repeat(n),d=n=>{if(n==="/")return"/";const x=n.split("/").filter(Boolean);if(x.length<=1){const y=x[0]||"";return`/${_.removeSlugExtension(y)}`}return`/${_.removeSlugExtension(x[x.length-1])}`},l=()=>{if(!c||c==="none")return"None";const n=b.find(x=>x.id===c);return n?`${n.name} (${d(n.slug)})`:"None"};return e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:i,className:"text-sm",children:"Parent"}),O?e.jsxs(a.Popover,{open:m,onOpenChange:h,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{id:i,variant:"outline",role:"combobox",className:te("w-full justify-between",p),"data-testid":"parent-page-selector",children:[l(),e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.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(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search pages...",className:"h-8 pl-8 text-xs",value:g,onChange:n=>T(n.target.value)})]})})}),e.jsxs(X,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No pages found."}),e.jsxs(a.CommandGroup,{children:[e.jsxs(a.CommandItem,{value:"none",onSelect:()=>{j(""),h(!1),T("")},className:"flex cursor-pointer items-center justify-between",children:[e.jsx("span",{children:"None"}),e.jsx(N.Check,{className:te("mr-2 h-4 w-4",c?"opacity-0":"opacity-100")})]}),R.map(n=>{const x=C(S(n.slug)),y=d(n.slug),W=e.jsxs("span",{className:"flex items-center text-sm",children:[x,n.name,e.jsxs("span",{className:"text-xs text-gray-500",children:[" (",y,")"]})]});return e.jsxs(a.CommandItem,{value:n.id,onSelect:()=>{j(n.id),h(!1),T("")},className:"flex cursor-pointer items-center justify-between whitespace-pre-wrap",children:[e.jsx("span",{children:W}),e.jsx(N.Check,{className:te("mr-2 h-4 w-4 shrink-0",c===n.id?"opacity-100":"opacity-0")})]},n.id)})]})]})]})})]}):e.jsxs("select",{id:i,value:c||"none",onChange:n=>j(n.target.value),className:p,"data-testid":"parent-page-selector",children:[e.jsx("option",{value:"none",children:"None"}),b.map(n=>{const x=S(n.slug),y=x>0?C(x):"",W=d(n.slug);return(f==null?void 0:f.id)===n.id||n.slug.startsWith(f==null?void 0:f.slug)?null:e.jsxs("option",{value:n.id,children:[y,n.name," (",W,")"]},n.id)})]})]})}const _e=(...t)=>t.filter(Boolean).join(" "),Ve=({templates:t,selectedTemplateId:c,onSelectTemplate:j,isLoading:p=!1})=>{const[i,f]=o.useState(""),[m,h]=o.useState(!1),[g,T]=o.useState(""),O=v.useChaiFeatureFlag("enable-add-page-dropdown");if(o.useEffect(()=>{if(c){const d=t.find(l=>l.id===c);o.startTransition(()=>f((d==null?void 0:d.preview)||""))}else o.startTransition(()=>f(""))},[c,t]),p)return e.jsx("div",{className:"flex h-fit items-center justify-center text-sm text-gray-500",children:"Loading templates..."});if(t.length===0)return null;const b={};t.forEach(d=>{const l=d.libraryName;b[l]||(b[l]=[]),b[l].push(d)});const R=Object.entries(b).reduce((d,[l,n])=>{const x=n.filter(y=>y.name.toLowerCase().includes(g.toLowerCase())||l.toLowerCase().includes(g.toLowerCase()));return x.length>0&&(d[l]=x),d},{}),S=t.find(d=>d.id===c),C=S?w.startCase(S.name):"No Template";return e.jsxs("div",{className:"space-y-4",children:[O?e.jsxs(a.Popover,{open:m,onOpenChange:h,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{variant:"outline",role:"combobox",className:"w-full justify-between",children:[C,e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.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(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search templates...",className:"h-8 pl-8 text-xs",value:g,onChange:d=>T(d.target.value)})]})}),e.jsxs(X,{className:"max-h-[300px] overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No templates found."}),Object.entries(R).map(([d,l])=>e.jsx(a.CommandGroup,{heading:d,children:l.map(n=>e.jsxs(a.CommandItem,{value:n.id,onSelect:()=>{j(n.id),h(!1),T("")},className:"flex cursor-pointer items-center justify-between",children:[w.startCase(n.name),e.jsx(N.Check,{className:_e("mr-2 h-4 w-4",c===n.id?"opacity-100":"opacity-0")})]},n.id))},d))]})]})})]}):e.jsxs("select",{className:"w-full rounded-md border border-gray-300 px-3 py-2",value:c,onChange:d=>j(d.target.value),children:[e.jsx("option",{value:"",children:"No Template"}),Object.entries(b).map(([d,l])=>e.jsx("optgroup",{label:d,children:l.map(n=>e.jsx("option",{value:n.id,children:w.startCase(n.name)},n.id))},d))]}),i&&e.jsxs("div",{className:"mt-3 overflow-hidden rounded border",children:[e.jsx("div",{className:"max-h-[200px] overflow-auto",children:e.jsx("img",{src:i,alt:"Template Preview",className:"w-full object-contain"})}),e.jsx("div",{className:"border-t bg-gray-50 p-2 text-xs text-gray-500",children:"Template preview"})]})]})},$e=()=>{const t=k.useApiUrl(),c=k.useFetch();return je.useQuery({queryKey:[k.ACTIONS.GET_LIBRARIES],staleTime:"static",queryFn:async()=>await c(t,{action:k.ACTIONS.GET_LIBRARIES})||[]})},Qe=t=>{const c=k.useApiUrl(),j=k.useFetch();return je.useQuery({queryKey:[k.ACTIONS.GET_TEMPLATES_BY_TYPE,t],staleTime:"static",enabled:!!t,queryFn:async()=>{const p=await j(c,{action:k.ACTIONS.GET_TEMPLATES_BY_TYPE,data:{pageType:t}});return(t?w.filter(p,{pageType:t}):p)||[]}})},Ye=t=>{const{data:c=[],isLoading:j}=Qe(t),{data:p=[],isLoading:i}=$e(),f=o.useMemo(()=>j||i?[]:c.map(h=>{const g=w.find(p,{id:h.library});return{...h,libraryName:(g==null?void 0:g.type)!=="shared"?"Site Library":(g==null?void 0:g.name)+" Library",libraryType:g==null?void 0:g.type}}),[c,p,j,i]),m=o.useMemo(()=>w.groupBy(f,"libraryName"),[f]);return{data:f,groupedData:m,isLoading:j||i}},z=(...t)=>t.filter(Boolean).join(" ");function He({addEditPage:t,close:c,closePanel:j}){var xe,ge;const{data:p}=k.usePageTypes(),i=o.useMemo(()=>p??[],[p]),f=k.useChangePage(),m=!!(t!=null&&t.id),{data:h}=k.useWebsitePages(),{mutate:g,isPending:T}=k.useCreatePage(),{mutate:O,isPending:b}=k.useUpdatePage(),[R,S]=o.useState(null),[C,d]=o.useState(!0),[l,n]=o.useState((t==null?void 0:t.pageType)??"page"),{hasPermission:x}=a.usePermissions(),y=x(k.PAGES_PERMISSIONS.CHANGE_PAGE_TYPE),[W,G]=o.useState(!1),[ye,ve]=o.useState(""),{selectedLang:Se,fallbackLang:Ce}=a.useLanguages(),ne=Se||Ce,[V,H]=o.useState(""),[ae,Q]=o.useState(!1),le=o.useMemo(()=>{const s=i.find(u=>u.key===l);return(s==null?void 0:s.hasSlug)===!1},[l,i]),[D,Ne]=o.useState((t==null?void 0:t.parent)??""),[M,re]=o.useState((t==null?void 0:t.name)??""),[F,oe]=o.useState((t==null?void 0:t.dynamic)??!1),[B,Y]=o.useState(F?"":((t==null?void 0:t.slug)??"").split("/").pop()||""),[ie,ce]=o.useState((t==null?void 0:t.dynamicSlugCustom)??""),[ue,be]=o.useState(!0),[we,P]=o.useState(!1),[E,ke]=o.useState(""),{data:me,isLoading:Le}=Ye(l),$=T||b,he=v.useChaiFeatureFlag("enable-add-page-dropdown"),ee=o.useMemo(()=>!m||!(t!=null&&t.id)||!h?null:h.find(s=>s.id===t.id),[m,t==null?void 0:t.id,h]),Te=(ee==null?void 0:ee.online)||!1,De=o.useMemo(()=>!m||!(t!=null&&t.id)||!h?!1:h.some(s=>s.parent===t.id),[m,t==null?void 0:t.id,h]),r=i.find(s=>s.key===l),U=s=>{if(m&&l!==s){ve(s),G(!0),H(""),Q(!1);return}n(s),H(""),Q(!1)},pe=()=>{n(ye),G(!1),oe(!1)},Ie=s=>{oe(s),s?Y(""):ce("")},Fe=s=>{if(Ne(s),s&&s!=="none"){const u=h==null?void 0:h.find(L=>L.id===s),q=(u==null?void 0:u.slug)||"";if(B.startsWith(q)){const L=B.slice(q.length).replace(/^\/+/,"");Y(L)}else Y(B.replace(/^\/+/,""))}else Y(B?`${B}`:"")},Be=s=>{ke(s)},qe=()=>M.trim()?F&&!w.isEmpty(B)?(S("Slug must be empty when using dynamic slug"),!1):F&&!ue?(S("Dynamic slug is invalid"),!1):!0:(J.toast.error("Name is required"),!1),Ae=()=>{const s={pageType:r==null?void 0:r.key,name:M,slug:"",hasSlug:!1};m?O({id:t==null?void 0:t.id,name:M},{onSuccess:()=>{J.toast.success((r==null?void 0:r.name)+" updated successfully"),c()}}):g(s,{onSuccess:u=>{c(),f(u.page.id,j)}})},Oe=(s,u)=>{if(!s.trim()&&!F)return S("Child page slug is required"),!1;const q=_.removeSlugExtension(u),L=_.combineParentChildSlugs(q,s);return Object.keys(k.LANGUAGES).some(Z=>L===`/${Z}`||(L==null?void 0:L.startsWith(`/${Z}/`)))?(S("Slugs cannot start with a language code for primary page"),!1):!0},We=(s,u)=>{const q=_.removeSlugExtension(u),L=_.combineParentChildSlugs(q,s),I={pageType:l,name:M,slug:L.replace(/\/$/,""),parent:D,dynamic:F,hasSlug:!0,template:E||void 0,tracking:{},seo:{},jsonLD:{}};if(F&&(I.dynamicSlugCustom=ie),m){const A=w.pick(I,["pageType","parent","name","slug","dynamic","dynamicSlugCustom"]);O({id:t==null?void 0:t.id,...A},{onSuccess:()=>{J.toast.success("Page updated successfully"),c()}})}else{const A=w.find(i,{key:l});A!=null&&A.trackingDefault&&(I.tracking=A.trackingDefault);const{seo:Z,jsonLD:Ge}=fe.getSeoDefaults(A,ne);w.set(I,"seo",Z),w.set(I,"jsonLD",Ge),g(I,{onSuccess:Me=>{c(),f(Me.page.id,j)}})}},Re=()=>{const s={pageType:l,name:M,slug:B===""?"/":`/${B.replace(/\/$/,"")}`,template:E||void 0,parent:null,tracking:{}};if(m)O({id:t==null?void 0:t.id,...s},{onSuccess:()=>{J.toast.success("Page updated successfully"),c()}});else{const u=w.find(i,{key:l});u!=null&&u.trackingDefault&&(s.tracking=u.trackingDefault);const{seo:q,jsonLD:L}=fe.getSeoDefaults(u,ne);w.set(s,"seo",q),w.set(s,"jsonLD",L),g(s,{onSuccess:I=>{var A;(A=I==null?void 0:I.page)!=null&&A.id&&f(I.page.id,j),c()}})}},de=s=>{if(s.preventDefault(),S(null),!!qe()){if(!(r!=null&&r.hasSlug)){Ae();return}if(D&&D!=="none"){const u=h==null?void 0:h.find(L=>L.id===D),q=(u==null?void 0:u.slug)||"";if(!Oe(B,q))return;We(B,q)}else Re()}},{pagesType:se,partialsType:K}=o.useMemo(()=>{const s=u=>V?u.name.toLowerCase().includes(V.toLowerCase())||u.key.toLowerCase().includes(V.toLowerCase()):!0;return{pagesType:i.filter(u=>u.hasSlug!==!1&&s(u)),partialsType:i.filter(u=>u.hasSlug===!1&&s(u))}},[i,V]);return r!=null&&r.hasSlug?e.jsxs("form",{onSubmit:de,className:"mx-auto w-full max-w-md space-y-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),he?e.jsxs(a.Popover,{open:ae,onOpenChange:Q,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{variant:"outline",role:"combobox",disabled:m&&!y,className:z("w-full justify-between",m&&!y?"cursor-not-allowed text-gray-500":""),children:[(r==null?void 0:r.name)||"Select page type",e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.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(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:V,onChange:s=>H(s.target.value)})]})}),e.jsxs(X,{className:"overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No page type found."}),m?le?e.jsx(a.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}):e.jsx(a.CommandGroup,{heading:"Pages",children:se.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}):e.jsxs(e.Fragment,{children:[se.length>0&&e.jsx(a.CommandGroup,{heading:"Pages",children:se.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))}),K.length>0&&e.jsx(a.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>U(s.key),className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))})]})]})]})})]}):e.jsx("select",{id:"pageType",value:l,disabled:m&&!y,onChange:s=>U(s.target.value),className:`w-full rounded-md border border-gray-300 px-3 py-2 ${m&&!y?"cursor-not-allowed text-gray-500":""}`,children:m?le?e.jsx("optgroup",{label:"Partials",children:i.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}):e.jsx("optgroup",{label:"Pages",children:i.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:i.filter(s=>s.hasSlug!==!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))}),e.jsx("optgroup",{label:"Partials",children:i.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})]})}),W&&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(v.Button,{variant:"outline",size:"sm",onClick:()=>G(!1),children:"Cancel"}),e.jsx(v.Button,{variant:"default",size:"sm",onClick:pe,children:"Confirm"})]})]})]}),!m&&(r==null?void 0:r.hasSlug)&&me.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(a.Label,{className:"mb-1 block text-sm",children:"Template"}),e.jsx(Ve,{templates:me,selectedTemplateId:E,onSelectTemplate:Be,isLoading:Le})]}),e.jsx(ze,{pages:h,selectedParentId:D,onChange:Fe,currentPage:t}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(v.Input,{id:"name",value:M,onChange:s=>re(s.target.value),required:!0,"aria-required":"true",placeholder:"Enter page name"})]}),(r==null?void 0:r.dynamicSegments)&&D&&D!=="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:F,onChange:s=>Ie(s.target.checked),className:"rounded border-gray-300"}),e.jsx(a.Label,{htmlFor:"useDynamicSlug",className:"text-sm",children:"Use Dynamic Slug"})]}),F&&e.jsx("div",{className:"space-y-2",children:e.jsx("div",{className:"space-y-0.5",children:e.jsx(Ue,{value:ie,onChange:ce,dynamicPattern:(r==null?void 0:r.dynamicSlug)||"{{id}}",placeholder:"Enter custom slug part (optional)",onValidationChange:be})})})]}),(!(r!=null&&r.dynamicSegments)||!F)&&e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"slug",className:"text-sm",children:"Slug"}),e.jsx(_.SlugInput,{value:B,onChange:s=>{var u;Y(s),m&&s!==(((u=t==null?void 0:t.slug)==null?void 0:u.split("/").pop())||"")?P(!!(Te||De)):P(!1)},placeholder:D&&D!=="none"?"Enter page slug":l==="page"?"Leave empty for home page":"Required - e.g. your-slug",parentSlug:D&&D!=="none"?(ge=h==null?void 0:h.find(s=>s.id===D))==null?void 0:ge.slug:void 0,onValidationChange:d}),R&&e.jsx("p",{className:"text-xs text-red-500",children:R}),we&&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(v.Button,{disabled:$||!C&&(!(r!=null&&r.dynamicSegments)||!F)||F&&!ue,type:"submit",className:"w-full",children:m?$?"Updating...":"Update page":$?"Creating...":"Create Page"})]}):e.jsxs("form",{onSubmit:de,className:"mx-auto w-full max-w-md space-y-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"pageType",className:"text-sm",children:"Type"}),he?e.jsxs(a.Popover,{open:ae,onOpenChange:Q,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(v.Button,{variant:"outline",role:"combobox",disabled:m&&!y,className:z("w-full justify-between",m&&!y?"cursor-not-allowed text-gray-500":""),children:[(r==null?void 0:r.name)||"Select page type",e.jsx(N.ChevronDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(a.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(N.Search,{strokeWidth:2,className:"absolute left-2 top-2 h-4 w-4 text-gray-400"}),e.jsx(v.Input,{placeholder:"Search page types...",className:"h-8 pl-8 text-xs",value:V,onChange:s=>H(s.target.value)})]})}),e.jsxs(X,{className:"max-h-[200px] overflow-y-auto",children:[e.jsx(a.CommandEmpty,{children:"No page type found."}),e.jsx(a.CommandGroup,{heading:"Partials",children:K.map(s=>e.jsxs(a.CommandItem,{value:s.key,onSelect:()=>{U(s.key),Q(!1)},className:"flex cursor-pointer items-center justify-between",children:[s.name,e.jsx(N.Check,{className:z("mr-2 h-4 w-4",l===s.key?"opacity-100":"opacity-0")})]},s.key))})]})]})})]}):e.jsx("select",{id:"pageType",value:l,disabled:m&&!y,onChange:s=>U(s.target.value),className:`w-full rounded-md border border-gray-300 px-3 py-2 ${m&&!y?"cursor-not-allowed text-gray-500":""}`,children:e.jsx("optgroup",{label:"Partials",children:i.filter(s=>s.hasSlug===!1).map(s=>e.jsx("option",{value:s.key,children:s.name},s.key))})}),W&&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(v.Button,{variant:"outline",size:"sm",onClick:()=>G(!1),children:"Cancel"}),e.jsx(v.Button,{variant:"default",size:"sm",onClick:pe,children:"Confirm"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:(xe=i.find(s=>s.key===l))==null?void 0:xe.helpText})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(a.Label,{htmlFor:"name",className:"text-sm",children:"Name"}),e.jsx(v.Input,{id:"name",value:M,onChange:s=>re(s.target.value),required:!0,"aria-required":"true"})]}),e.jsx(v.Button,{disabled:$,type:"submit",className:"w-full",children:m?$?"Updating...":"Update "+(r==null?void 0:r.name):$?"Creating...":"Create "+(r==null?void 0:r.name)})]})}exports.default=He;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),e=require("./index-WQwzsC7A.cjs"),E=require("@tanstack/react-query"),r=require("react"),c=r.lazy(()=>Promise.resolve().then(()=>require("./take-over-request-BNxcjY2j.cjs"))),o=r.lazy(()=>Promise.resolve().then(()=>require("./page-locked-dialog-B1FAtK92.cjs"))),l=r.lazy(()=>Promise.resolve().then(()=>require("./active-in-another-tab-B47YjQGN.cjs"))),S=r.lazy(()=>Promise.resolve().then(()=>require("./continue-editing-in-this-client-CtMYsk-A.cjs"))),s=n=>u.jsx(r.Suspense,{children:u.jsx(n,{})}),A=({isFetchingPageData:n})=>{e.useChaibuilderRealtime();const{pageStatus:t}=e.usePageLockStatus(),{pageLockMeta:a}=e.usePageLockMeta(),T=E.useQueryClient(),i=r.useRef(t);if(r.useEffect(()=>{t===e.PAGE_STATUS.EDITING&&i.current!==e.PAGE_STATUS.TAKE_OVER_REQUESTED&&T.invalidateQueries({queryKey:[e.ACTIONS.GET_DRAFT_PAGE]}),i.current=t},[t,T]),n)return null;switch(t){case e.PAGE_STATUS.EDITING:case e.PAGE_STATUS.CHECKING:case e.PAGE_STATUS.FORCE_TAKE_OVER:return a.type===e.EVENT.CONTINUE_EDITING_IN_THIS_CLIENT?s(S):null;case e.PAGE_STATUS.LOCKED:return s(o);case e.PAGE_STATUS.TAKE_OVER_REQUESTED:return s(c);case e.PAGE_STATUS.ACTIVE_IN_ANOTHER_TAB:return s(l);case e.PAGE_STATUS.CONNECTION_LOST:return u.jsx(e.BlurContainer,{children:null});default:return null}};exports.default=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),e=require("./index-Bzn_gpaK.cjs"),E=require("@tanstack/react-query"),r=require("react"),c=r.lazy(()=>Promise.resolve().then(()=>require("./take-over-request-BeHTL28z.cjs"))),o=r.lazy(()=>Promise.resolve().then(()=>require("./page-locked-dialog-b2_f-A7a.cjs"))),l=r.lazy(()=>Promise.resolve().then(()=>require("./active-in-another-tab-DV83cJ_v.cjs"))),S=r.lazy(()=>Promise.resolve().then(()=>require("./continue-editing-in-this-client-DjxpjsA8.cjs"))),s=n=>u.jsx(r.Suspense,{children:u.jsx(n,{})}),A=({isFetchingPageData:n})=>{e.useChaibuilderRealtime();const{pageStatus:t}=e.usePageLockStatus(),{pageLockMeta:a}=e.usePageLockMeta(),T=E.useQueryClient(),i=r.useRef(t);if(r.useEffect(()=>{t===e.PAGE_STATUS.EDITING&&i.current!==e.PAGE_STATUS.TAKE_OVER_REQUESTED&&T.invalidateQueries({queryKey:[e.ACTIONS.GET_DRAFT_PAGE]}),i.current=t},[t,T]),n)return null;switch(t){case e.PAGE_STATUS.EDITING:case e.PAGE_STATUS.CHECKING:case e.PAGE_STATUS.FORCE_TAKE_OVER:return a.type===e.EVENT.CONTINUE_EDITING_IN_THIS_CLIENT?s(S):null;case e.PAGE_STATUS.LOCKED:return s(o);case e.PAGE_STATUS.TAKE_OVER_REQUESTED:return s(c);case e.PAGE_STATUS.ACTIVE_IN_ANOTHER_TAB:return s(l);case e.PAGE_STATUS.CONNECTION_LOST:return u.jsx(e.BlurContainer,{children:null});default:return null}};exports.default=A;
@@ -1,8 +1,8 @@
1
1
  import { jsx as n } from "react/jsx-runtime";
2
- import { u as E, a as c, b as T, P as e, A as l, B as I, E as _ } from "./index-ZuacEL1j.js";
2
+ import { u as E, a as c, b as T, P as e, A as l, B as I, E as _ } from "./index-CA1OwKJX.js";
3
3
  import { useQueryClient as C } from "@tanstack/react-query";
4
4
  import { useRef as p, useEffect as N, Suspense as A, lazy as s } from "react";
5
- const m = s(() => import("./take-over-request-C4FeDtN_.js")), f = s(() => import("./page-locked-dialog-B6MKTRfY.js")), O = s(() => import("./active-in-another-tab-CyjngVA6.js")), S = s(() => import("./continue-editing-in-this-client-CS2aQ7yY.js")), r = (a) => /* @__PURE__ */ n(A, { children: /* @__PURE__ */ n(a, {}) }), L = ({ isFetchingPageData: a }) => {
5
+ const m = s(() => import("./take-over-request-CXjaDliJ.js")), f = s(() => import("./page-locked-dialog-BMjPVyHF.js")), O = s(() => import("./active-in-another-tab-CEWvA8SG.js")), S = s(() => import("./continue-editing-in-this-client-DDB816CQ.js")), r = (a) => /* @__PURE__ */ n(A, { children: /* @__PURE__ */ n(a, {}) }), L = ({ isFetchingPageData: a }) => {
6
6
  E();
7
7
  const { pageStatus: t } = c(), { pageLockMeta: o } = T(), u = C(), i = p(t);
8
8
  if (N(() => {
@@ -1,21 +1,24 @@
1
1
  import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
- import { W as O, X as w, Y as A, Z as S, B as p, _ as F, $ as K, a0 as I, a1 as U, a2 as V } from "./index-Ct7ElCGK.js";
3
- import { aq as q, ao as Q, a as P, ap as j, b as B, B as D, E as a, P as L } from "./index-ZuacEL1j.js";
2
+ import { U as O, V as w, W as A, X as S, Y as F, Z as K, _ as U, $ as V, a0 as I } from "./index-BFnMzGe6.js";
3
+ import { B as p } from "./register-chai-top-bar-D6GjnauV.js";
4
+ import { aq as q, ao as Q, a as P, ap as j, b as B, B as D, E as a, P as L } from "./index-CA1OwKJX.js";
4
5
  import { LockKeyhole as G, UserIcon as H, AlertCircleIcon as J, X, Edit as z, ShieldAlert as v } from "lucide-react";
5
- import { useState as f, useRef as W, useEffect as Y } from "react";
6
- import { useTranslation as Z } from "react-i18next";
7
- const ae = () => {
8
- const o = q(), x = Q(), { setPageStatus: T } = P(), { data: r, isFetching: k } = j((o == null ? void 0 : o.userId) || ""), { pageLockMeta: l, setPageLockMeta: E } = B(), { t: s } = Z(), [d, c] = f(""), [n, g] = f({}), [N, b] = f(!1), i = W(null);
6
+ import { useState as f, useRef as W, useEffect as Y, startTransition as Z } from "react";
7
+ import { useTranslation as $ } from "react-i18next";
8
+ const ie = () => {
9
+ const d = q(), x = Q(), { setPageStatus: T } = P(), { data: r, isFetching: k } = j((d == null ? void 0 : d.userId) || ""), { pageLockMeta: l, setPageLockMeta: E } = B(), { t: s } = $(), [o, i] = f(""), [n, g] = f({}), [N, b] = f(!1), c = W(null);
9
10
  Y(() => {
10
- l != null && l.type && (i.current && clearTimeout(i.current), g(l), E({}), c(""));
11
+ l != null && l.type && (c.current && clearTimeout(c.current), Z(() => {
12
+ g(l), E({}), i("");
13
+ }));
11
14
  }, [l, E]);
12
15
  const R = () => {
13
- d !== a.TAKE_OVER_REQUEST && (c(a.TAKE_OVER_REQUEST), x(a.TAKE_OVER_REQUEST), i.current = setTimeout(() => c(""), 2e4));
16
+ o !== a.TAKE_OVER_REQUEST && (i(a.TAKE_OVER_REQUEST), x(a.TAKE_OVER_REQUEST), c.current = setTimeout(() => i(""), 2e4));
14
17
  }, C = () => {
15
- d !== a.FORCE_TAKE_OVER_REQUEST && (c(a.FORCE_TAKE_OVER_REQUEST), x(a.FORCE_TAKE_OVER_REQUEST), T(L.CHECKING), i.current = setTimeout(() => c(""), 2e4));
18
+ o !== a.FORCE_TAKE_OVER_REQUEST && (i(a.FORCE_TAKE_OVER_REQUEST), x(a.FORCE_TAKE_OVER_REQUEST), T(L.CHECKING), c.current = setTimeout(() => i(""), 2e4));
16
19
  }, _ = () => {
17
- g({}), i.current && clearTimeout(i.current), c("");
18
- }, m = k ? "Loading..." : (r == null ? void 0 : r.name) || "Current editor", u = d === a.TAKE_OVER_REQUEST, h = d === a.FORCE_TAKE_OVER_REQUEST;
20
+ g({}), c.current && clearTimeout(c.current), i("");
21
+ }, m = k ? "Loading..." : (r == null ? void 0 : r.name) || "Current editor", u = o === a.TAKE_OVER_REQUEST, h = o === a.FORCE_TAKE_OVER_REQUEST;
19
22
  return /* @__PURE__ */ e(D, { children: /* @__PURE__ */ t(O, { className: "mx-auto w-full max-w-md", children: [
20
23
  /* @__PURE__ */ e(w, { className: "space-y-1 border-b pb-3", children: /* @__PURE__ */ t(A, { className: "flex items-center gap-2 text-xl", children: [
21
24
  /* @__PURE__ */ e(G, { className: "h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500" }),
@@ -30,7 +33,7 @@ const ae = () => {
30
33
  {
31
34
  src: r.avatar,
32
35
  alt: r.name,
33
- className: "h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"
36
+ className: "h-12 w-12 flex-shrink-0 rounded-full bg-black text-white"
34
37
  }
35
38
  ) : /* @__PURE__ */ e(H, { className: "h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white" }),
36
39
  /* @__PURE__ */ t("div", { className: "flex-1 space-y-0", children: [
@@ -76,19 +79,19 @@ const ae = () => {
76
79
  u && /* @__PURE__ */ e("p", { className: "mt-2 text-xs text-muted-foreground", children: s("Request sent. If no response, try again or use force take over.") })
77
80
  ] }),
78
81
  /* @__PURE__ */ e(K, { type: "single", collapsible: !0, className: "w-full", children: /* @__PURE__ */ t(
79
- I,
82
+ U,
80
83
  {
81
84
  value: "force-takeover",
82
85
  className: "rounded-md border border-destructive/40 bg-destructive/5",
83
86
  children: [
84
- /* @__PURE__ */ e(U, { className: "px-3 py-2 hover:no-underline", children: /* @__PURE__ */ e("div", { className: "flex items-center gap-2 text-left", children: /* @__PURE__ */ t("div", { children: [
87
+ /* @__PURE__ */ e(V, { className: "px-3 py-2 hover:no-underline", children: /* @__PURE__ */ e("div", { className: "flex items-center gap-2 text-left", children: /* @__PURE__ */ t("div", { children: [
85
88
  /* @__PURE__ */ t("p", { className: "flex items-center gap-x-2 text-sm font-medium text-destructive", children: [
86
89
  /* @__PURE__ */ e(v, { className: "h-4 w-4 text-destructive" }),
87
90
  s("Force Take Over")
88
91
  ] }),
89
92
  /* @__PURE__ */ e("p", { className: "pl-6 text-xs font-normal leading-tight text-muted-foreground", children: s("Immediately take control (use with caution)") })
90
93
  ] }) }) }),
91
- /* @__PURE__ */ e(V, { className: "px-3 pb-3", children: /* @__PURE__ */ t("div", { className: "space-y-3", children: [
94
+ /* @__PURE__ */ e(I, { className: "px-3 pb-3", children: /* @__PURE__ */ t("div", { className: "space-y-3", children: [
92
95
  /* @__PURE__ */ t("div", { className: "flex items-start gap-2 rounded-md border border-destructive/40 bg-background p-2", children: [
93
96
  /* @__PURE__ */ e(
94
97
  "input",
@@ -129,5 +132,5 @@ const ae = () => {
129
132
  ] }) });
130
133
  };
131
134
  export {
132
- ae as default
135
+ ie as default
133
136
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-D30xvFa5.cjs"),p=require("./register-chai-top-bar-DyW9GPzV.cjs"),t=require("./index-Bzn_gpaK.cjs"),c=require("lucide-react"),d=require("react"),O=require("react-i18next"),_=()=>{const m=t.useCurrentPageOwner(),f=t.useSendRealtimeEvent(),{setPageStatus:j}=t.usePageLockStatus(),{data:s,isFetching:v}=t.useChaiUserInfo((m==null?void 0:m.userId)||""),{pageLockMeta:o,setPageLockMeta:g}=t.usePageLockMeta(),{t:r}=O.useTranslation(),[u,i]=d.useState(""),[a,N]=d.useState({}),[T,k]=d.useState(!1),l=d.useRef(null);d.useEffect(()=>{o!=null&&o.type&&(l.current&&clearTimeout(l.current),d.startTransition(()=>{N(o),g({}),i("")}))},[o,g]);const b=()=>{u!==t.EVENT.TAKE_OVER_REQUEST&&(i(t.EVENT.TAKE_OVER_REQUEST),f(t.EVENT.TAKE_OVER_REQUEST),l.current=setTimeout(()=>i(""),2e4))},R=()=>{u!==t.EVENT.FORCE_TAKE_OVER_REQUEST&&(i(t.EVENT.FORCE_TAKE_OVER_REQUEST),f(t.EVENT.FORCE_TAKE_OVER_REQUEST),j(t.PAGE_STATUS.CHECKING),l.current=setTimeout(()=>i(""),2e4))},y=()=>{N({}),l.current&&clearTimeout(l.current),i("")},x=v?"Loading...":(s==null?void 0:s.name)||"Current editor",h=u===t.EVENT.TAKE_OVER_REQUEST,E=u===t.EVENT.FORCE_TAKE_OVER_REQUEST;return e.jsx(t.BlurContainer,{children:e.jsxs(n.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(n.CardHeader,{className:"space-y-1 border-b pb-3",children:e.jsxs(n.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(c.LockKeyhole,{className:"h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500"}),e.jsx("span",{children:r("Page Locked for Editing")})]})}),e.jsxs(n.CardContent,{className:"space-y-4 p-4",children:[e.jsxs("div",{className:"relative rounded-md border border-green-500 px-2 pb-2 pt-4",children:[e.jsx("div",{className:"absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white",children:"Current Editor"}),e.jsxs("div",{className:"flex items-center space-x-4 p-1",children:[s!=null&&s.avatar?e.jsx("img",{src:s.avatar,alt:s.name,className:"h-12 w-12 flex-shrink-0 rounded-full bg-black text-white"}):e.jsx(c.UserIcon,{className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"}),e.jsxs("div",{className:"flex-1 space-y-0",children:[e.jsx("div",{className:"truncate font-medium leading-tight text-black",children:x}),(s==null?void 0:s.email)&&e.jsx("p",{className:"truncate text-sm leading-tight text-muted-foreground",children:s.email})]})]})]}),((a==null?void 0:a.type)===t.EVENT.TAKE_OVER_REJECTED||(a==null?void 0:a.type)===t.EVENT.FORCE_TAKE_OVER_REQUEST)&&e.jsx("section",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between gap-x-2 rounded border border-red-500 bg-red-500/10 py-2 pl-3 pr-2 text-sm font-medium text-red-500",children:[e.jsxs("div",{className:"flex items-start gap-x-2",children:[e.jsx(c.AlertCircleIcon,{className:"mt-px flex h-4 w-4 shrink-0"}),e.jsxs("div",{className:"font-light leading-tight",children:[e.jsx("span",{className:"font-medium",children:(s==null?void 0:s.name)||"The current editor"}),(a==null?void 0:a.type)===t.EVENT.TAKE_OVER_REJECTED?" rejected your take over request.":" forcefully took over this page."]})]}),e.jsx(p.Button,{size:"icon",variant:"ghost",onClick:y,className:"flex-shrink-0",children:e.jsx(c.X,{className:"h-4 w-4"})})]})})]}),e.jsx(n.CardFooter,{className:"flex flex-col gap-3 border-t pt-3",children:e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:r("Take Over Options")}),e.jsxs("div",{className:"rounded-md border bg-muted/40 p-3",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("p",{className:"text-sm font-medium",children:r("Take Over Request:")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:r("Send a request to {{currentEditorName}} asking them to release the page. They can accept or decline your request.",{currentEditorName:x})})]}),e.jsxs(p.Button,{disabled:h,variant:"default",onClick:b,className:"mt-3 w-full gap-2",children:[e.jsx(c.Edit,{className:"h-4 w-4"}),h?"Take over request sent":"Send Take Over Request"]}),h&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:r("Request sent. If no response, try again or use force take over.")})]}),e.jsx(n.Accordion,{type:"single",collapsible:!0,className:"w-full",children:e.jsxs(n.AccordionItem,{value:"force-takeover",className:"rounded-md border border-destructive/40 bg-destructive/5",children:[e.jsx(n.AccordionTrigger,{className:"px-3 py-2 hover:no-underline",children:e.jsx("div",{className:"flex items-center gap-2 text-left",children:e.jsxs("div",{children:[e.jsxs("p",{className:"flex items-center gap-x-2 text-sm font-medium text-destructive",children:[e.jsx(c.ShieldAlert,{className:"h-4 w-4 text-destructive"}),r("Force Take Over")]}),e.jsx("p",{className:"pl-6 text-xs font-normal leading-tight text-muted-foreground",children:r("Immediately take control (use with caution)")})]})})}),e.jsx(n.AccordionContent,{className:"px-3 pb-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-destructive/40 bg-background p-2",children:[e.jsx("input",{type:"checkbox",id:"force-takeover",checked:T,onChange:C=>k(C.target.checked),className:"mt-0.5 h-4 w-4 rounded border-gray-300"}),e.jsx("label",{htmlFor:"force-takeover",className:"flex-1 text-xs text-muted-foreground",children:r("I understand this will immediately close the editor for {{currentEditorName}}. I am using this option with caution.",{currentEditorName:x})})]}),e.jsxs(p.Button,{disabled:!T||E,variant:"destructive",onClick:R,className:"w-full gap-2",children:[e.jsx(c.ShieldAlert,{className:"h-4 w-4"}),r(E?"Take over page...":"Force Take Over")]}),E&&e.jsx("p",{className:"text-xs text-muted-foreground",children:r("Attempting to forcefully take over this page. Please wait while we update the editing session.")})]})})]})})]})})]})})};exports.default=_;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),J=require("./index-D30xvFa5.cjs"),p=require("./index-Bzn_gpaK.cjs"),O=require("./use-page-expand-manager-B6XTvk0E.cjs"),n=require("lodash-es"),R=require("jotai"),v=require("lucide-react"),l=require("react"),re=require("react-i18next"),ae=require("./register-chai-top-bar-DyW9GPzV.cjs"),K=(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 i=c;for(;i.parent&&s[i.parent];)a.add(i.parent),i=s[i.parent]}),Array.from(a).map(c=>s[c])},B=(e,r,a)=>n.isEmpty(r)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?B(s.children,r,a):[]};const c=s.children&&s.children.some(i=>n.includes(n.toLower(i.name||""),n.toLower(r))||n.includes(n.toLower(i.slug||""),n.toLower(r)));return{...s,shouldExpandOnSearch:c,children:s.children?B(s.children,r,a):[]}}),ie=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},Z=e=>!e||!e.length?[]:[...e].sort((a,s)=>(a.name||"").localeCompare(s.name||"")).map(a=>({...a,children:a.children?Z(a.children):[]})),oe=(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=K(c,r);else{const f=K(c,r),u=le(e,f);c=n.uniqBy([...f,...u],"id")}const i=Z(ie(c)),y=B(i,r,s),k=n.filter(y,f=>s(f.pageType)).sort((f,u)=>(f.name||"").localeCompare(u.name||"")),m=n.filter(y,f=>!s(f.pageType));let P=[];if(a==="all"){const f=n.keyBy(m,"pageType");P=Object.values(n.mapValues(f,(u,g)=>({...u,id:g,name:n.startCase(g),isPartialGroup:!0,children:y.filter(w=>w.pageType===g)})))}else P=m.sort((f,u)=>(f.name||"").localeCompare(u.name||""));return[...k,...P]},ce=R.atom({pageId:null,position:{x:0,y:0}}),de=({pageId:e,children:r})=>{const[a,s]=R.useAtom(ce),c=l.useRef(null),i=a.pageId===e;l.useEffect(()=>{const m=()=>s({pageId:null,position:{x:0,y:0}});if(i)return document.addEventListener("click",m),()=>document.removeEventListener("click",m)},[i,s]);const y=m=>{m.preventDefault(),m.stopPropagation(),s({pageId:e,position:{x:m.clientX,y:m.clientY}})},k=()=>{const m=`${window.location.pathname}?page=${e}`;window.open(m,"_blank"),s({pageId:null,position:{x:0,y:0}})};return t.jsxs(t.Fragment,{children:[t.jsx("span",{onContextMenu:y,children:r}),i&&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(ae.Button,{variant:"ghost",onClick:k,className:"w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",children:[t.jsx(v.ExternalLink,{className:"h-4 w-4"}),"Open in new tab"]})})})]})},ue=({page:e})=>{var s,c;const{isExpanded:r,toggleExpanded:a}=O.usePageExpandManager(e==null?void 0:e.id);return t.jsx("button",{onClick:i=>{i.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(v.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${r?"rotate-90":""}`})})},me=({page:e,pageType:r})=>t.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?t.jsx(v.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(v.File,{size:12,className:"stroke-[1] text-slate-500"}):t.jsx(v.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),he=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),xe=({page:e,pageTypes:r,currentPage:a,onClickAction:s,languagePages:c,selectedLanguage:i,showUntranslatedPages:y})=>{const k=p.useUserId(),{pageToUser:m}=p.usePageToUser(),P=n.get(m,[e==null?void 0:e.id,"userId"]),{data:f}=p.useChaiUserInfo(P),u=f&&k!==P?f==null?void 0:f.name:null,g=p.useFallbackLang(),w=a===e.id,F=!!e.isTemplate,j=l.useMemo(()=>n.find(r,{key:e.pageType}),[r,e.pageType]);let h=n.get(c,e==null?void 0:e.id);h=n.get(h,"lang")===i?h:null;const E=i===g||!!h,L=(h==null?void 0:h.name)||(e==null?void 0:e.name)||"No name";let S=(h==null?void 0:h.slug)||(e==null?void 0:e.slug)||"";const M=S+(e!=null&&e.dynamic?`/${j==null?void 0:j.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(S.startsWith("/")&&!y){const d=S.split("/").pop();S=S.endsWith(d)&&e.dynamic?"":`/${d}`}const q=l.useMemo(()=>{const d="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=`${w?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${d} ${C} ${u?"opacity-60":""}`:`${d} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,w,u]),z=l.useMemo(()=>{if(e.isPartialGroup)return!1;if(h){if(!h.online||n.isEmpty(h.changes))return!1}else if(e&&(!e.online||n.isEmpty(e.changes)))return!1;return!0},[h,e]);return t.jsxs("div",{className:"group relative",children:[t.jsx(de,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:q,children:[t.jsx(ue,{page:e}),!e.isPartialGroup&&t.jsx(he,{isOnline:h?h.online:e.online}),!e.isPartialGroup&&t.jsx(me,{page:e,pageType:j}),t.jsx(p.Tooltip,{content:L,side:"top",showTooltip:L.length>35,children:t.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:L})}),(S||e.dynamic)&&t.jsx(p.Tooltip,{content:M,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]})]})}),z&&t.jsx(p.Tooltip,{content:"Has unpublished changes",side:"top",children:t.jsx("span",{className:"text-amber-500",children:t.jsx(v.Pencil,{size:12,className:"stroke-[2]"})})}),F&&t.jsx(p.Tooltip,{content:"Template",side:"top",children:t.jsx("span",{className:"text-blue-500",children:t.jsx(v.NotepadText,{size:16})})}),!e.isPartialGroup&&E&&!u?t.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:t.jsx(p.PageActionsDropdown,{isLanguagePage:!!h,page:h||e,setDuplicatePage:d=>s("duplicate",d),setAddEditPage:d=>s("edit",h||d),setUnpublishPage:d=>s("unpublish",d),setDeletePage:d=>s("delete",h||d),setMarkAsTemplate:d=>s("markAsTemplate",d),setUnmarkAsTemplate:d=>s("unmarkAsTemplate",d),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(v.MoreHorizontal,{className:"h-4 w-4",onClick:d=>d.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(v.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(v.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:d=>{d.stopPropagation(),s("addLanguagePage",{language:i,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(v.Plus,{size:12,className:"stroke-[3]"})," ",t.jsxs("span",{className:"text-[10px]",children:["Add ",n.get(p.LANGUAGES,i)," Page"]})]})})]})},ee=({pages:e,tier:r,pageTypes:a,currentPage:s,onClickAction:c,languagePages:i,selectedLanguage:y,showUntranslatedPages:k})=>{const{expandedPages:m}=O.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(xe,{page:P,pageTypes:a,currentPage:s,onClickAction:c,languagePages:i,selectedLanguage:y,showUntranslatedPages:k}),P.children&&P.children.length>0&&(m==null?void 0:m.includes(P.id))&&t.jsx(ee,{pages:P.children,tier:r+1,pageTypes:a,currentPage:s,onClickAction:c,languagePages:i,selectedLanguage:y,showUntranslatedPages:k})]},P.id))})},fe=l.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-D0ZXojiu.cjs"))),pe=l.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-BOE-xwBc.cjs"))),ye=l.lazy(()=>Promise.resolve().then(()=>require("./delete-page-BHPlx8ec.cjs"))),Pe=l.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-BvggF83O.cjs"))),ge=l.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-CT-hLGIW.cjs"))),je=l.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-D2bvjGKt.cjs"))),be=l.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-CPjHmtSM.cjs"))),ve=({close:e})=>{const{t:r}=re.useTranslation(),{languages:a,setSelectedLang:s}=J.useLanguages(),{data:c}=p.usePageTypes(),{data:i,isFetching:y}=p.useWebsitePages(),[k,m]=p.useSearchParams(),{updateForSelectedPage:P,expandPagesOnSearch:f}=O.usePageExpandManager(null),u=p.useFallbackLang(),g=k.get("page"),[w,F]=l.useState(""),[j,h]=l.useState(null),[E,L]=l.useState(null),[S,M]=l.useState(null),[q,z]=l.useState(null),[d,C]=l.useState(""),[G,D]=l.useState(null),[W,H]=l.useState(null),[b,I]=l.useState(u),[te,se]=l.useState(!1),_=R.useSetAtom(p.addNewLangAtom),U=te&&b!==u,{data:A,isFetching:ne}=p.useWebsiteLanguagePages(b),V=l.useCallback(x=>{var o;return(o=n.find(c,{key:x}))==null?void 0:o.hasSlug},[c]),N=l.useMemo(()=>i?U?n.filter(i,x=>!(A!=null&&A[x.id])):oe(i,w,d,V):[],[i,V,w,d,A,U]);l.useEffect(()=>{s(u)},[u,s]),l.useEffect(()=>{const x=k.get("lang");if(x){const o=a,T=a[0]??u,Y=o.includes(x);l.startTransition(()=>{Y&&b!==x?I(x):!Y&&b!==T&&I(T)})}},[]),l.useEffect(()=>{if(!n.isEmpty(d))return;const x=sessionStorage.getItem("pageTypeFilter")||"all";!n.isEmpty(c)&&x&&(n.find(c,{key:x})?C(x):C("all"))},[c,d]),l.useEffect(()=>{if(g&&!y&&!n.find(i,{id:g})){const o=n.find(i,{slug:"/"});if(o){const T=new URLSearchParams({page:o.id});p.navigateToPage(T,m)}else p.navigateToPage(new URLSearchParams({}),m,!0)}},[i,g,y,m]),l.useEffect(()=>{g&&!y&&!n.isEmpty(N)&&P(N,g)},[g,y,N,P]),l.useEffect(()=>{!n.isEmpty(w)&&!n.isEmpty(N)&&f(N)},[w,N,f]);const{setSelectedLang:$}=J.useLanguages(),Q=l.useCallback(x=>{const o=new URLSearchParams({page:x});b!==u?(o.set("lang",b),$(b)):$(""),p.navigateToPage(o,m),e()},[e,m,$,b,u]),X=(x,o)=>{var T;if(o)switch(x){case"add":L(o);break;case"select":Q(o);break;case"edit":b!==u?_({edit:!0,id:o==null?void 0:o.id,primaryPage:o==null?void 0:o.primaryPage}):L(o);break;case"delete":h(o);break;case"unpublish":M(o);break;case"markAsTemplate":z(o);break;case"unmarkAsTemplate":H(o);break;case"duplicate":D(o);break;case"addLanguagePage":_({edit:!1,primaryPage:((T=o==null?void 0:o.page)==null?void 0:T.id)||"",preselectedLang:(o==null?void 0:o.language)||b});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(fe,{pages:N,search:w,setSearch:F,languages:[u,...a],selectedLanguage:b,setSelectedLanguage:I,selectedPageType:d,setSelectedPageType:C,onAddPage:x=>X("add",x),showUntranslatedPages:U,setShowUntranslatedPages:se})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:y||ne?t.jsx("div",{className:"space-y-2",children:n.map([...Array(15).keys()],x=>t.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},x))}):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(v.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(ee,{tier:0,pages:N,pageTypes:c,currentPage:g||"",onClickAction:X,languagePages:A,selectedLanguage:b,showUntranslatedPages:U})})]}),E&&t.jsx(l.Suspense,{children:t.jsx(pe,{closePanel:e,editPage:Q,addEditPage:E,setAddEditPage:L})}),j&&t.jsx(l.Suspense,{children:t.jsx(ye,{page:j,onClose:()=>h(null)})}),S&&t.jsx(l.Suspense,{children:t.jsx(be,{page:S,onClose:()=>M(null)})}),q&&t.jsx(l.Suspense,{children:t.jsx(ge,{page:q,onClose:()=>z(null)})}),W&&t.jsx(l.Suspense,{children:t.jsx(je,{page:W,onClose:()=>H(null)})}),G&&t.jsx(l.Suspense,{children:t.jsx(Pe,{page:G,onClose:()=>D(null),closePanel:e})})]})};exports.default=ve;
@@ -0,0 +1,411 @@
1
+ import { jsxs as b, Fragment as F, jsx as t } from "react/jsx-runtime";
2
+ import { d as oe } from "./index-BFnMzGe6.js";
3
+ import { aB as ye, aC as ge, ap as ke, k as de, T as D, aR as Ne, L as we, m as ve, g as Se, c as Le, av as Te, aS as Ae, aT as X } from "./index-CA1OwKJX.js";
4
+ import { u as J } from "./use-page-expand-manager-Cf4MUEJw.js";
5
+ import { compact as ue, filter as B, isEmpty as k, uniqBy as Ce, keyBy as me, mapValues as Ee, startCase as Me, toLower as M, includes as _, get as W, find as z, map as Ue } from "lodash-es";
6
+ import { atom as Ie, useAtom as $e, useSetAtom as ze } from "jotai";
7
+ import { ExternalLink as Be, Pencil as Fe, NotepadText as Oe, MoreHorizontal as je, Lock as Ge, Edit as Re, Plus as De, ChevronRight as We, StarsIcon as He, Hash as _e, File as he } from "lucide-react";
8
+ import { useRef as qe, useEffect as E, useMemo as H, useState as v, useCallback as ie, startTransition as Ve, Suspense as C, lazy as U } 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
+ B(e, (r) => {
13
+ const n = M(s);
14
+ return _(M((r == null ? void 0 : r.name) || ""), n) || _(M((r == null ? void 0 : r.slug) || ""), n);
15
+ })
16
+ ), Ye = (e, s) => {
17
+ const r = /* @__PURE__ */ new Set(), n = me(e, "id");
18
+ return s.forEach((o) => {
19
+ let a = o;
20
+ for (; a.parent && n[a.parent]; )
21
+ r.add(a.parent), a = n[a.parent];
22
+ }), Array.from(r).map((o) => n[o]);
23
+ }, Y = (e, s, r) => k(s) ? e : e.map((n) => {
24
+ if (!r(n.pageType))
25
+ return {
26
+ ...n,
27
+ shouldExpandOnSearch: !0,
28
+ children: n.children ? Y(n.children, s, r) : []
29
+ };
30
+ const o = n.children && n.children.some(
31
+ (a) => _(M(a.name || ""), M(s)) || _(M(a.slug || ""), M(s))
32
+ );
33
+ return {
34
+ ...n,
35
+ shouldExpandOnSearch: o,
36
+ children: n.children ? Y(n.children, s, r) : []
37
+ };
38
+ }), Je = (e) => {
39
+ if (!e || !e.length) return [];
40
+ const s = {};
41
+ e.forEach((n) => {
42
+ s[n.id] = { ...n, children: [] };
43
+ });
44
+ const r = [];
45
+ return Object.values(s).forEach((n) => {
46
+ n.parent && s[n.parent] ? s[n.parent].children.push(n) : r.push(n);
47
+ }), r;
48
+ }, fe = (e) => !e || !e.length ? [] : [...e].sort((r, n) => (r.name || "").localeCompare(n.name || "")).map((r) => ({
49
+ ...r,
50
+ children: r.children ? fe(r.children) : []
51
+ })), Ke = (e, s, r, n) => {
52
+ if (!e || !e.length) return [];
53
+ let o = e;
54
+ if (r !== "all" && (o = ue(B(e, { pageType: r }))), k(s))
55
+ o = ce(o, s);
56
+ else {
57
+ const h = ce(o, s), c = Ye(e, h);
58
+ o = Ce([...h, ...c], "id");
59
+ }
60
+ const a = fe(Je(o)), f = Y(a, s, n), g = B(f, (h) => n(h.pageType)).sort(
61
+ (h, c) => (h.name || "").localeCompare(c.name || "")
62
+ ), d = B(f, (h) => !n(h.pageType));
63
+ let x = [];
64
+ if (r === "all") {
65
+ const h = me(d, "pageType");
66
+ x = Object.values(
67
+ Ee(h, (c, p) => ({
68
+ ...c,
69
+ id: p,
70
+ name: Me(p),
71
+ isPartialGroup: !0,
72
+ children: f.filter((N) => N.pageType === p)
73
+ }))
74
+ );
75
+ } else
76
+ x = d.sort((h, c) => (h.name || "").localeCompare(c.name || ""));
77
+ return [...g, ...x];
78
+ }, Ze = Ie({
79
+ pageId: null,
80
+ position: { x: 0, y: 0 }
81
+ }), et = ({ pageId: e, children: s }) => {
82
+ const [r, n] = $e(Ze), o = qe(null), a = r.pageId === e;
83
+ E(() => {
84
+ const d = () => n({ pageId: null, position: { x: 0, y: 0 } });
85
+ if (a)
86
+ return document.addEventListener("click", d), () => document.removeEventListener("click", d);
87
+ }, [a, n]);
88
+ const f = (d) => {
89
+ d.preventDefault(), d.stopPropagation(), n({ pageId: e, position: { x: d.clientX, y: d.clientY } });
90
+ }, g = () => {
91
+ const d = `${window.location.pathname}?page=${e}`;
92
+ window.open(d, "_blank"), n({ pageId: null, position: { x: 0, y: 0 } });
93
+ };
94
+ return /* @__PURE__ */ b(F, { children: [
95
+ /* @__PURE__ */ t("span", { onContextMenu: f, children: s }),
96
+ a && /* @__PURE__ */ t(
97
+ "div",
98
+ {
99
+ ref: o,
100
+ className: "fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",
101
+ style: { top: r.position.y, left: r.position.x },
102
+ children: /* @__PURE__ */ t("div", { className: "", children: /* @__PURE__ */ b(
103
+ Xe,
104
+ {
105
+ variant: "ghost",
106
+ onClick: g,
107
+ className: "w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",
108
+ children: [
109
+ /* @__PURE__ */ t(Be, { className: "h-4 w-4" }),
110
+ "Open in new tab"
111
+ ]
112
+ }
113
+ ) })
114
+ }
115
+ )
116
+ ] });
117
+ }, tt = ({ page: e }) => {
118
+ var n, o;
119
+ const { isExpanded: s, toggleExpanded: r } = J(e == null ? void 0 : e.id);
120
+ return /* @__PURE__ */ t(
121
+ "button",
122
+ {
123
+ onClick: (a) => {
124
+ a.stopPropagation(), r();
125
+ },
126
+ disabled: !((n = e == null ? void 0 : e.children) != null && n.length),
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 ${(o = e == null ? void 0 : e.children) != null && o.length ? "hover:text-blue-400" : "opacity-0"}`,
128
+ children: /* @__PURE__ */ t(
129
+ We,
130
+ {
131
+ size: 12,
132
+ className: `stroke-[4] transition-transform duration-200 ${s ? "rotate-90" : ""}`
133
+ }
134
+ )
135
+ }
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(
138
+ "div",
139
+ {
140
+ className: "flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",
141
+ dangerouslySetInnerHTML: { __html: s.icon }
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"}` }), rt = ({
144
+ page: e,
145
+ pageTypes: s,
146
+ currentPage: r,
147
+ onClickAction: n,
148
+ languagePages: o,
149
+ selectedLanguage: a,
150
+ showUntranslatedPages: f
151
+ }) => {
152
+ const g = ye(), { pageToUser: d } = ge(), x = W(d, [e == null ? void 0 : e.id, "userId"]), { data: h } = ke(x), c = h && g !== x ? h == null ? void 0 : h.name : null, p = de(), N = r === e.id, q = !!e.isTemplate, P = H(() => z(s, { key: e.pageType }), [s, e.pageType]);
153
+ let u = W(o, e == null ? void 0 : e.id);
154
+ u = W(u, "lang") === a ? u : null;
155
+ const L = a === p || !!u, T = (u == null ? void 0 : u.name) || (e == null ? void 0 : e.name) || "No name";
156
+ let w = (u == null ? void 0 : u.slug) || (e == null ? void 0 : e.slug) || "";
157
+ const O = w + (e != null && e.dynamic ? `/${P == null ? void 0 : P.dynamicSlug}` : "") + (e != null && e.dynamicSlugCustom ? `${e.dynamicSlugCustom}` : "");
158
+ if (w.startsWith("/") && !f) {
159
+ const i = w.split("/").pop();
160
+ w = w.endsWith(i) && e.dynamic ? "" : `/${i}`;
161
+ }
162
+ const j = H(() => {
163
+ const i = "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]", I = `${N ? "border-primary/30 bg-primary/5" : "border-transparent hover:border-gray-200 hover:bg-gray-100"}`;
164
+ return L ? `${i} ${I} ${c ? "opacity-60" : ""}` : `${i} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`;
165
+ }, [L, N, c]), G = H(() => {
166
+ if (e.isPartialGroup) return !1;
167
+ if (u) {
168
+ if (!u.online || k(u.changes)) return !1;
169
+ } else if (e && (!e.online || k(e.changes)))
170
+ return !1;
171
+ return !0;
172
+ }, [u, e]);
173
+ return /* @__PURE__ */ b("div", { className: "group relative", children: [
174
+ /* @__PURE__ */ t(et, { pageId: e.id, children: /* @__PURE__ */ b(
175
+ "div",
176
+ {
177
+ onClick: () => !e.isPartialGroup && L && n("select", e == null ? void 0 : e.id),
178
+ className: j,
179
+ children: [
180
+ /* @__PURE__ */ t(tt, { page: e }),
181
+ !e.isPartialGroup && /* @__PURE__ */ t(st, { isOnline: u ? u.online : e.online }),
182
+ !e.isPartialGroup && /* @__PURE__ */ t(nt, { page: e, pageType: P }),
183
+ /* @__PURE__ */ t(D, { content: T, side: "top", showTooltip: T.length > 35, children: /* @__PURE__ */ t("span", { className: "max-w-[40%] truncate font-medium text-black", children: T }) }),
184
+ (w || e.dynamic) && /* @__PURE__ */ t(D, { content: O, side: "top", showTooltip: !0, children: /* @__PURE__ */ b("span", { className: "max-w-[40%] truncate font-mono text-xs text-muted-foreground", children: [
185
+ w,
186
+ e.dynamic && (P == null ? void 0 : P.dynamicSlug) && /* @__PURE__ */ b("span", { className: "text-xs text-gray-500", children: [
187
+ "/",
188
+ P == null ? void 0 : P.dynamicSlug,
189
+ e.dynamicSlugCustom
190
+ ] })
191
+ ] }) }),
192
+ G && /* @__PURE__ */ t(D, { content: "Has unpublished changes", side: "top", children: /* @__PURE__ */ t("span", { className: "text-amber-500", children: /* @__PURE__ */ t(Fe, { size: 12, className: "stroke-[2]" }) }) }),
193
+ q && /* @__PURE__ */ t(D, { content: "Template", side: "top", children: /* @__PURE__ */ t("span", { className: "text-blue-500", children: /* @__PURE__ */ t(Oe, { size: 16 }) }) }),
194
+ !e.isPartialGroup && L && !c ? /* @__PURE__ */ t("div", { className: "duration absolute right-0.5 top-[3px]", children: /* @__PURE__ */ t(
195
+ Ne,
196
+ {
197
+ isLanguagePage: !!u,
198
+ page: u || e,
199
+ setDuplicatePage: (i) => n("duplicate", i),
200
+ setAddEditPage: (i) => n("edit", u || i),
201
+ setUnpublishPage: (i) => n("unpublish", i),
202
+ setDeletePage: (i) => n("delete", u || i),
203
+ setMarkAsTemplate: (i) => n("markAsTemplate", i),
204
+ setUnmarkAsTemplate: (i) => n("unmarkAsTemplate", i),
205
+ 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(je, { className: "h-4 w-4", onClick: (i) => i.stopPropagation() }) })
206
+ }
207
+ ) }) : c ? /* @__PURE__ */ t("span", { className: "duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500", children: /* @__PURE__ */ t(Ge, { className: "h-3.5 w-3.5 fill-red-200 text-red-500" }) }) : null
208
+ ]
209
+ }
210
+ ) }),
211
+ /* @__PURE__ */ t(F, { children: c && /* @__PURE__ */ b("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: [
212
+ /* @__PURE__ */ t(Re, { size: 12, className: "stroke-[3]" }),
213
+ " ",
214
+ /* @__PURE__ */ t("span", { className: "font-medium", children: c }),
215
+ " is editing this page"
216
+ ] }) }),
217
+ /* @__PURE__ */ t(F, { children: !L && !e.isPartialGroup && !c && /* @__PURE__ */ b(
218
+ "button",
219
+ {
220
+ onClick: (i) => {
221
+ i.stopPropagation(), n("addLanguagePage", { language: a, page: e });
222
+ },
223
+ 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",
224
+ children: [
225
+ /* @__PURE__ */ t(De, { size: 12, className: "stroke-[3]" }),
226
+ " ",
227
+ /* @__PURE__ */ b("span", { className: "text-[10px]", children: [
228
+ "Add ",
229
+ W(we, a),
230
+ " Page"
231
+ ] })
232
+ ]
233
+ }
234
+ ) })
235
+ ] });
236
+ }, xe = ({
237
+ pages: e,
238
+ tier: s,
239
+ pageTypes: r,
240
+ currentPage: n,
241
+ onClickAction: o,
242
+ languagePages: a,
243
+ selectedLanguage: f,
244
+ showUntranslatedPages: g
245
+ }) => {
246
+ const { expandedPages: d } = J();
247
+ return /* @__PURE__ */ t("div", { className: "space-y-0.5", style: { paddingLeft: `${s * 10}px` }, children: e.map((x) => /* @__PURE__ */ b(F, { children: [
248
+ /* @__PURE__ */ t(
249
+ rt,
250
+ {
251
+ page: x,
252
+ pageTypes: r,
253
+ currentPage: n,
254
+ onClickAction: o,
255
+ languagePages: a,
256
+ selectedLanguage: f,
257
+ showUntranslatedPages: g
258
+ }
259
+ ),
260
+ x.children && x.children.length > 0 && (d == null ? void 0 : d.includes(x.id)) && /* @__PURE__ */ t(
261
+ xe,
262
+ {
263
+ pages: x.children,
264
+ tier: s + 1,
265
+ pageTypes: r,
266
+ currentPage: n,
267
+ onClickAction: o,
268
+ languagePages: a,
269
+ selectedLanguage: f,
270
+ showUntranslatedPages: g
271
+ }
272
+ )
273
+ ] }, x.id)) });
274
+ }, at = U(() => import("./page-manager-search-and-filter-DCcYyoPO.js")), lt = U(() => import("./add-new-page-DsvGVrR8.js")), ot = U(() => import("./delete-page-41tvYcEw.js")), it = U(() => import("./duplicate-page-DMmDdmfS.js")), ct = U(() => import("./mark-as-template-raTtKmQ9.js")), dt = U(() => import("./unmark-as-template-vFgMIdxN.js")), ut = U(() => import("./unpublish-page-CxkjTzBB.js")), Nt = ({ close: e }) => {
275
+ const { t: s } = Qe(), { languages: r, setSelectedLang: n } = oe(), { data: o } = ve(), { data: a, isFetching: f } = Se(), [g, d] = Le(), { updateForSelectedPage: x, expandPagesOnSearch: h } = J(null), c = de(), p = g.get("page"), [N, q] = v(""), [P, u] = v(null), [L, T] = v(null), [w, O] = v(null), [j, G] = v(null), [i, I] = v(""), [K, Z] = v(null), [ee, te] = v(null), [y, V] = v(c), [pe, Pe] = v(!1), ne = ze(Te), R = pe && y !== c, { data: $, isFetching: be } = Ae(y), se = ie(
276
+ (m) => {
277
+ var l;
278
+ return (l = z(o, { key: m })) == null ? void 0 : l.hasSlug;
279
+ },
280
+ [o]
281
+ ), S = H(() => a ? R ? B(a, (m) => !($ != null && $[m.id])) : Ke(a, N, i, se) : [], [a, se, N, i, $, R]);
282
+ E(() => {
283
+ n(c);
284
+ }, [c, n]), E(() => {
285
+ const m = g.get("lang");
286
+ if (m) {
287
+ const l = r, A = r[0] ?? c, le = l.includes(m);
288
+ Ve(() => {
289
+ le && y !== m ? V(m) : !le && y !== A && V(A);
290
+ });
291
+ }
292
+ }, []), E(() => {
293
+ if (!k(i)) return;
294
+ const m = sessionStorage.getItem("pageTypeFilter") || "all";
295
+ !k(o) && m && (z(o, { key: m }) ? I(m) : I("all"));
296
+ }, [o, i]), E(() => {
297
+ if (p && !f && !z(a, { id: p })) {
298
+ const l = z(a, { slug: "/" });
299
+ if (l) {
300
+ const A = new URLSearchParams({ page: l.id });
301
+ X(A, d);
302
+ } else
303
+ X(new URLSearchParams({}), d, !0);
304
+ }
305
+ }, [a, p, f, d]), E(() => {
306
+ p && !f && !k(S) && x(S, p);
307
+ }, [p, f, S, x]), E(() => {
308
+ !k(N) && !k(S) && h(S);
309
+ }, [N, S, h]);
310
+ const { setSelectedLang: Q } = oe(), re = ie(
311
+ (m) => {
312
+ const l = new URLSearchParams({ page: m });
313
+ y !== c ? (l.set("lang", y), Q(y)) : Q(""), X(l, d), e();
314
+ },
315
+ [e, d, Q, y, c]
316
+ ), ae = (m, l) => {
317
+ var A;
318
+ if (l)
319
+ switch (m) {
320
+ case "add":
321
+ T(l);
322
+ break;
323
+ case "select":
324
+ re(l);
325
+ break;
326
+ case "edit":
327
+ y !== c ? ne({
328
+ edit: !0,
329
+ id: l == null ? void 0 : l.id,
330
+ primaryPage: l == null ? void 0 : l.primaryPage
331
+ }) : T(l);
332
+ break;
333
+ case "delete":
334
+ u(l);
335
+ break;
336
+ case "unpublish":
337
+ O(l);
338
+ break;
339
+ case "markAsTemplate":
340
+ G(l);
341
+ break;
342
+ case "unmarkAsTemplate":
343
+ te(l);
344
+ break;
345
+ case "duplicate":
346
+ Z(l);
347
+ break;
348
+ case "addLanguagePage":
349
+ ne({
350
+ edit: !1,
351
+ primaryPage: ((A = l == null ? void 0 : l.page) == null ? void 0 : A.id) || "",
352
+ preselectedLang: (l == null ? void 0 : l.language) || y
353
+ });
354
+ break;
355
+ }
356
+ };
357
+ return /* @__PURE__ */ b(F, { children: [
358
+ /* @__PURE__ */ b("div", { className: "flex h-full flex-col justify-between", children: [
359
+ /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(
360
+ at,
361
+ {
362
+ pages: S,
363
+ search: N,
364
+ setSearch: q,
365
+ languages: [c, ...r],
366
+ selectedLanguage: y,
367
+ setSelectedLanguage: V,
368
+ selectedPageType: i,
369
+ setSelectedPageType: I,
370
+ onAddPage: (m) => ae("add", m),
371
+ showUntranslatedPages: R,
372
+ setShowUntranslatedPages: Pe
373
+ }
374
+ ) }),
375
+ /* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto px-4 pb-6 pt-2", children: f || be ? /* @__PURE__ */ t("div", { className: "space-y-2", children: Ue([...Array(15).keys()], (m) => /* @__PURE__ */ t("div", { className: "h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200" }, m)) }) : k(S) ? /* @__PURE__ */ b("div", { className: "flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500", children: [
376
+ /* @__PURE__ */ t(he, { className: "h-6 w-6 stroke-[1]" }),
377
+ s("Empty List!"),
378
+ /* @__PURE__ */ t("span", { className: "font-light", children: s("Add new page to start") })
379
+ ] }) : /* @__PURE__ */ t(
380
+ xe,
381
+ {
382
+ tier: 0,
383
+ pages: S,
384
+ pageTypes: o,
385
+ currentPage: p || "",
386
+ onClickAction: ae,
387
+ languagePages: $,
388
+ selectedLanguage: y,
389
+ showUntranslatedPages: R
390
+ }
391
+ ) })
392
+ ] }),
393
+ L && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(
394
+ lt,
395
+ {
396
+ closePanel: e,
397
+ editPage: re,
398
+ addEditPage: L,
399
+ setAddEditPage: T
400
+ }
401
+ ) }),
402
+ P && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(ot, { page: P, onClose: () => u(null) }) }),
403
+ w && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(ut, { page: w, onClose: () => O(null) }) }),
404
+ j && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(ct, { page: j, onClose: () => G(null) }) }),
405
+ ee && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(dt, { page: ee, onClose: () => te(null) }) }),
406
+ K && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(it, { page: K, onClose: () => Z(null), closePanel: e }) })
407
+ ] });
408
+ };
409
+ export {
410
+ Nt as default
411
+ };