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

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 (186) hide show
  1. package/dist/{2SSKDMRQ-BnsZi3K3.cjs → 2SSKDMRQ-BIryEtW-.cjs} +1 -1
  2. package/dist/{2SSKDMRQ-CnSDkQcy.js → 2SSKDMRQ-trME0kvt.js} +2 -2
  3. package/dist/{AP7HFJJL-B31839PG.cjs → AP7HFJJL-5ZR38Hyh.cjs} +1 -1
  4. package/dist/{AP7HFJJL-CymCmW14.js → AP7HFJJL-CAGB9iMp.js} +1 -1
  5. package/dist/IconPicker-CQ-BgNNU.cjs +1 -0
  6. package/dist/{IconPicker-B1rWC-Ex.js → IconPicker-Mu75ni5T.js} +8 -7
  7. package/dist/{WDYDFRGG-BUVnbAci.js → WDYDFRGG-Cd4hRWj-.js} +2 -2
  8. package/dist/{WDYDFRGG-BxhOCHc3.cjs → WDYDFRGG-n8sBZVFG.cjs} +1 -1
  9. package/dist/{actions-registery-YnFmU21O.cjs → actions-registery-JdxhXhT6.cjs} +1 -1
  10. package/dist/{actions-registery-CZ1w0NKa.js → actions-registery-y_ENc8zj.js} +2 -2
  11. package/dist/actions.cjs +1 -1
  12. package/dist/actions.js +2 -2
  13. package/dist/active-in-another-tab-CZLV-uAW.cjs +1 -0
  14. package/dist/active-in-another-tab-Cb6tnX9u.js +35 -0
  15. package/dist/{add-new-language-page-WmlCnytQ.js → add-new-language-page-BKcBaqZu.js} +54 -53
  16. package/dist/add-new-language-page-C3UzNV7W.cjs +1 -0
  17. package/dist/{add-new-page-soZ8GAkN.cjs → add-new-page-mULv9r3z.cjs} +1 -1
  18. package/dist/{add-new-page-VW2wAYZp.js → add-new-page-pH3PwqJe.js} +2 -2
  19. package/dist/ai-panel-content-BPgRdgye.cjs +1 -0
  20. package/dist/{ai-panel-content-D_o7Q_A-.js → ai-panel-content-CNxN84pv.js} +12 -11
  21. package/dist/{ai-panel-default-lang-DnElspF0.js → ai-panel-default-lang-CYcHjk8U.js} +40 -40
  22. package/dist/{ai-panel-default-lang-COYaxNwn.cjs → ai-panel-default-lang-DhTPtPgD.cjs} +2 -2
  23. package/dist/{ai-panel-other-lang-CkynNlAU.cjs → ai-panel-other-lang-CGNU3-FI.cjs} +1 -1
  24. package/dist/{ai-panel-other-lang-Dp0E9_Hx.js → ai-panel-other-lang-D8Ofvj8F.js} +8 -8
  25. package/dist/ai-prompt-input-CUutJjlf.cjs +1 -0
  26. package/dist/{ai-prompt-input-Bhc0ds7X.js → ai-prompt-input-Ceuy5bs3.js} +68 -67
  27. package/dist/{ai-translation-prompt-CZ55HQmo.js → ai-translation-prompt-BiepZRcN.js} +2 -2
  28. package/dist/ai-translation-prompt-CoCPLEed.cjs +1 -0
  29. package/dist/{apply-binding-6iwlED02.js → apply-binding-BvWfJCSZ.js} +204 -196
  30. package/dist/apply-binding-IsUf6UWJ.cjs +1 -0
  31. package/dist/{code-display-DhD_RBcg.js → code-display-Ck81Id9K.js} +1 -1
  32. package/dist/code-display-DloSPyPr.cjs +1 -0
  33. package/dist/code-editor-C1ewJzDJ.cjs +1 -0
  34. package/dist/{code-editor-DRIAnNbb.js → code-editor-Z14ByBIv.js} +11 -10
  35. package/dist/{continue-editing-in-this-client-CS2aQ7yY.js → continue-editing-in-this-client-Byi6ER3L.js} +10 -9
  36. package/dist/continue-editing-in-this-client-k9Ab5E63.cjs +1 -0
  37. package/dist/core-Dr7QYemB.js +56 -0
  38. package/dist/core-Y0lXLwkq.cjs +1 -0
  39. package/dist/core.cjs +1 -1
  40. package/dist/core.d.ts +3 -3
  41. package/dist/core.js +32 -31
  42. package/dist/css-import-modal--bSJR-_y.cjs +13 -0
  43. package/dist/{css-import-modal-Byg6wV0O.js → css-import-modal-De7Kvg5C.js} +4 -3
  44. package/dist/{delete-design-token-BRZZiWtQ.js → delete-design-token-B97CnFDU.js} +1 -1
  45. package/dist/{delete-design-token-DkVs1oBf.cjs → delete-design-token-C6s-ESB_.cjs} +1 -1
  46. package/dist/delete-page-Djn97HiP.cjs +1 -0
  47. package/dist/{delete-page-BzyX9TN-.js → delete-page-Dnf97ZHP.js} +11 -10
  48. package/dist/{design-token-usage-xQs6SlaJ.js → design-token-usage-B-SykAjD.js} +14 -13
  49. package/dist/design-token-usage-OTd93kS8.cjs +1 -0
  50. package/dist/digital-asset-manager-DHYRXaaq.cjs +1 -0
  51. package/dist/{digital-asset-manager-DbtwzxRz.js → digital-asset-manager-b8gDuLnI.js} +6 -5
  52. package/dist/{duplicate-page-BR7Dlo9d.js → duplicate-page-Bdtpl7_R.js} +19 -18
  53. package/dist/duplicate-page-C4Ovp8Ff.cjs +1 -0
  54. package/dist/dynamic-page-selector-B8DdnfrF.cjs +1 -0
  55. package/dist/{dynamic-page-selector-Cb5r_W8s.js → dynamic-page-selector-BVnIM1Rq.js} +15 -14
  56. package/dist/get-chai-builder-tailwind-config-DNp8Vhme.cjs +1 -0
  57. package/dist/{get-chai-builder-tailwind-config-DjoVOuAf.js → get-chai-builder-tailwind-config-k8l5sdcw.js} +5 -5
  58. package/dist/{get-chai-builder-theme-Dl72X7cz.cjs → get-chai-builder-theme-BApShjRz.cjs} +1 -1
  59. package/dist/{get-chai-builder-theme-BYtp20KD.js → get-chai-builder-theme-DDVRJQ6Z.js} +1 -1
  60. package/dist/{image-editor-G-K28aTS.cjs → image-editor-C2zOHeKv.cjs} +1 -1
  61. package/dist/{image-editor-DV8kUKhl.js → image-editor-cckqPmk5.js} +1 -1
  62. package/dist/index-B0e71wJ1.cjs +160 -0
  63. package/dist/{index-ZuacEL1j.js → index-Bn0fFN58.js} +665 -663
  64. package/dist/{index-Ct7ElCGK.js → index-CAhEmHYP.js} +3744 -3920
  65. package/dist/index-DKuwxj1x.cjs +5 -0
  66. package/dist/{json-diff-viewer-D7z4zNvv.cjs → json-diff-viewer-D9DVIBz4.cjs} +3 -3
  67. package/dist/{json-diff-viewer-krslPepD.js → json-diff-viewer-DNizzMnu.js} +5 -4
  68. package/dist/lang-panel-C1dbn163.cjs +1 -0
  69. package/dist/{lang-panel-BwIewMyw.js → lang-panel-DL_BtSRD.js} +15 -14
  70. package/dist/manage-design-tokens-CXjYkarE.cjs +1 -0
  71. package/dist/{manage-design-tokens-Caz_20VK.js → manage-design-tokens-xxMO_RYg.js} +12 -11
  72. package/dist/{mark-as-template-D295ZQtU.js → mark-as-template-Ba2bmVd9.js} +17 -16
  73. package/dist/mark-as-template-DF1KIMr0.cjs +1 -0
  74. package/dist/{nested-path-selector-content-CKYYK-C5.js → nested-path-selector-content-Br1IWhK5.js} +24 -23
  75. package/dist/nested-path-selector-content-Cuk7NB-u.cjs +1 -0
  76. package/dist/{no-language-page-content-BvqRBP6y.js → no-language-page-content-9B2Fm-on.js} +10 -9
  77. package/dist/no-language-page-content-CxTp-LIM.cjs +1 -0
  78. package/dist/{no-language-page-dialog-PjNqTUpl.js → no-language-page-dialog-CPlKMyb8.js} +2 -2
  79. package/dist/{no-language-page-dialog-BcEoqyQB.cjs → no-language-page-dialog-DynACvgV.cjs} +1 -1
  80. package/dist/{page-creator-DiOITEMw.js → page-creator-BtyJz2sx.js} +115 -114
  81. package/dist/page-creator-Cbfv9N0P.cjs +1 -0
  82. package/dist/{page-lock-Bfbs6RgL.js → page-lock-CzsxrmN5.js} +2 -2
  83. package/dist/{page-lock-BdYmCks0.cjs → page-lock-fRos9wRU.cjs} +1 -1
  84. package/dist/{page-locked-dialog-B6MKTRfY.js → page-locked-dialog-D2q9qkPk.js} +18 -15
  85. package/dist/page-locked-dialog-D57d2gvn.cjs +1 -0
  86. package/dist/{page-manager-new-CzX22g2n.js → page-manager-new-D6DVIx2S.js} +30 -29
  87. package/dist/page-manager-new-aE198gKS.cjs +1 -0
  88. package/dist/{page-manager-search-and-filter-CM0UMb6U.js → page-manager-search-and-filter-CuZkQaZg.js} +13 -12
  89. package/dist/page-manager-search-and-filter-DGQEgKzy.cjs +1 -0
  90. package/dist/{page-revisions-content-NH9JK4Ey.js → page-revisions-content-5rbicFbD.js} +34 -31
  91. package/dist/page-revisions-content-CefqOvKX.cjs +1 -0
  92. package/dist/pages.cjs +1 -1
  93. package/dist/pages.d.ts +4 -4
  94. package/dist/pages.js +1 -1
  95. package/dist/{plugin-C6rgJDNQ.cjs → plugin-BGlQf0iy.cjs} +1 -1
  96. package/dist/{plugin-3ZKK6RXm.js → plugin-C-ht41UZ.js} +1 -1
  97. package/dist/publish-pages-content-DBb8M3TG.cjs +1 -0
  98. package/dist/{publish-pages-content-D9aixMN5.js → publish-pages-content-WeGk-YLC.js} +66 -65
  99. package/dist/register-chai-top-bar-BqwKw4uy.cjs +1 -0
  100. package/dist/register-chai-top-bar-ESJHs5s-.js +237 -0
  101. package/dist/render.cjs +2 -2
  102. package/dist/render.d.ts +2 -2
  103. package/dist/render.js +87 -80
  104. package/dist/rte-widget-modal-DBoPRXq-.cjs +1 -0
  105. package/dist/{rte-widget-modal-DOJEXLIf.js → rte-widget-modal-J-_AytmK.js} +15 -14
  106. package/dist/runtime.cjs +1 -1
  107. package/dist/runtime.d.ts +168 -4
  108. package/dist/runtime.js +68 -38
  109. package/dist/save-to-lib-0ysmXVbI.cjs +1 -0
  110. package/dist/{save-to-lib-eiOc_SSN.js → save-to-lib-CQQxoovF.js} +39 -38
  111. package/dist/sdk.css +1 -1
  112. package/dist/selected-block-display-BWupQFoQ.cjs +16 -0
  113. package/dist/{selected-block-display-CBFePS19.js → selected-block-display-CgoXS8Hr.js} +37 -36
  114. package/dist/{seo-panel-C1-iMOR1.js → seo-panel-B798Myp_.js} +12 -11
  115. package/dist/seo-panel-BkFbXIL0.cjs +2 -0
  116. package/dist/{shared-json-ld-B4PxAM_0.js → shared-json-ld-Clg_UEhd.js} +68 -67
  117. package/dist/shared-json-ld-Cn3MCW6I.cjs +1 -0
  118. package/dist/slug-input-BHyD8cxk.cjs +1 -0
  119. package/dist/{slug-input-AwNJs9im.js → slug-input-hX5VaZpj.js} +9 -8
  120. package/dist/supabase-actions.cjs +1 -1
  121. package/dist/supabase-actions.d.ts +1 -1
  122. package/dist/supabase-actions.js +1 -1
  123. package/dist/take-over-request-Dzczo20q.cjs +1 -0
  124. package/dist/{take-over-request-C4FeDtN_.js → take-over-request-s1L5Yofb.js} +17 -16
  125. package/dist/theme-panel-footer-NTNCL0SW.cjs +1 -0
  126. package/dist/{theme-panel-footer-uBQqSJXm.js → theme-panel-footer-sK6bYhEb.js} +11 -10
  127. package/dist/translation-warning-modal-BfM4HGck.cjs +1 -0
  128. package/dist/{translation-warning-modal-B64YqlbI.js → translation-warning-modal-Jadkcver.js} +9 -8
  129. package/dist/unmark-as-template-CqkHI3gR.cjs +1 -0
  130. package/dist/{unmark-as-template-CZ9sQp_P.js → unmark-as-template-D5b775eR.js} +11 -10
  131. package/dist/unpublish-page-BT5bCfs6.cjs +1 -0
  132. package/dist/unpublish-page-DLLLgY43.js +28 -0
  133. package/dist/utils.cjs +1 -1
  134. package/dist/utils.d.ts +3 -0
  135. package/dist/utils.js +2 -2
  136. package/dist/web-blocks.cjs +1 -1
  137. package/dist/web-blocks.js +5 -5
  138. package/dist/{web-preview-Djy6WIyj.js → web-preview-C_yFwxEe.js} +2 -2
  139. package/dist/web-preview-DU1MgppY.cjs +1 -0
  140. package/package.json +4 -2
  141. package/dist/IconPicker-DREyo007.cjs +0 -1
  142. package/dist/active-in-another-tab-B47YjQGN.cjs +0 -1
  143. package/dist/active-in-another-tab-CyjngVA6.js +0 -34
  144. package/dist/add-new-language-page-88xzrUy8.cjs +0 -1
  145. package/dist/ai-panel-content-7zCil042.cjs +0 -1
  146. package/dist/ai-prompt-input-CThbVp0_.cjs +0 -1
  147. package/dist/ai-translation-prompt-C2kJQFDX.cjs +0 -1
  148. package/dist/apply-binding-KKp5PnpZ.cjs +0 -1
  149. package/dist/code-display-BnqzqzoP.cjs +0 -1
  150. package/dist/code-editor-o3___nu2.cjs +0 -1
  151. package/dist/continue-editing-in-this-client-CtMYsk-A.cjs +0 -1
  152. package/dist/core-BoRDjj4h.cjs +0 -1
  153. package/dist/core-yvI6kCyw.js +0 -56
  154. package/dist/css-import-modal-CyqkXWCO.cjs +0 -13
  155. package/dist/delete-page-DxX7PFIE.cjs +0 -1
  156. package/dist/design-token-usage-CAHzEGgJ.cjs +0 -1
  157. package/dist/digital-asset-manager--uO8Agia.cjs +0 -1
  158. package/dist/duplicate-page-CaNAbXwV.cjs +0 -1
  159. package/dist/dynamic-page-selector-Cxk_gjni.cjs +0 -1
  160. package/dist/get-chai-builder-tailwind-config-B9rCyiQo.cjs +0 -1
  161. package/dist/index-DF5DEvqb.cjs +0 -160
  162. package/dist/index-WQwzsC7A.cjs +0 -5
  163. package/dist/lang-panel-DT96k1xg.cjs +0 -1
  164. package/dist/manage-design-tokens-CrmLe7UT.cjs +0 -1
  165. package/dist/mark-as-template-W3LmpiqN.cjs +0 -1
  166. package/dist/nested-path-selector-content-CoS_d3dc.cjs +0 -1
  167. package/dist/no-language-page-content-DkfeMl90.cjs +0 -1
  168. package/dist/page-creator-C4gc5NSC.cjs +0 -1
  169. package/dist/page-locked-dialog-B1FAtK92.cjs +0 -1
  170. package/dist/page-manager-new-CHDueBDk.cjs +0 -1
  171. package/dist/page-manager-search-and-filter-DkkRIH86.cjs +0 -1
  172. package/dist/page-revisions-content-ChY-4f2V.cjs +0 -1
  173. package/dist/publish-pages-content-x-JuSFJ9.cjs +0 -1
  174. package/dist/rte-widget-modal-BaHIuEjF.cjs +0 -1
  175. package/dist/save-to-lib-Cgpxw8-g.cjs +0 -1
  176. package/dist/selected-block-display-BgRY82CT.cjs +0 -16
  177. package/dist/seo-panel-DfAb8U7W.cjs +0 -2
  178. package/dist/shared-json-ld-DzG398hr.cjs +0 -1
  179. package/dist/slug-input-C_ijLQ_X.cjs +0 -1
  180. package/dist/take-over-request-BNxcjY2j.cjs +0 -1
  181. package/dist/theme-panel-footer-Cq9pljro.cjs +0 -1
  182. package/dist/translation-warning-modal-BZAcwM2_.cjs +0 -1
  183. package/dist/unmark-as-template-EVvk0vmp.cjs +0 -1
  184. package/dist/unpublish-page-D4VwOlxc.js +0 -27
  185. package/dist/unpublish-page-bdSmwAVQ.cjs +0 -1
  186. package/dist/web-preview-Cio70gk5.cjs +0 -1
@@ -1,13 +1,14 @@
1
1
  import { jsxs as a, Fragment as p, jsx as e } from "react/jsx-runtime";
2
- import { n as le, ac as re, ad as ie, a5 as de, ae as y, B as g, V 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, af as he } from "./index-Ct7ElCGK.js";
3
- 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-ZuacEL1j.js";
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";
4
5
  import { useQuery as pe, useQueryClient as O, useMutation as H } from "@tanstack/react-query";
5
6
  import { format as D, formatDistanceToNow as xe } from "date-fns";
6
7
  import { isEmpty as ge } from "lodash-es";
7
- import { FileJson as Ne, CloudOff as be, Undo2 as J, Trash as Q, 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 Q, Trash as J, X as ye, Rocket as ve, Save as we, MoreHorizontal as De } from "lucide-react";
8
9
  import * as v from "react";
9
- import { useEffect as F, useState as Se, Suspense as Ee, lazy as Ce } from "react";
10
- function Re(t) {
10
+ import { useEffect as F, startTransition as Se, useState as Ee, Suspense as Ce, lazy as Re } from "react";
11
+ function Ae(t) {
11
12
  const s = R(), n = A();
12
13
  return pe({
13
14
  queryKey: [b.GET_PAGE_REVISIONS, t],
@@ -19,7 +20,7 @@ function Re(t) {
19
20
  refetchOnMount: !0
20
21
  });
21
22
  }
22
- const Ae = () => {
23
+ const Ie = () => {
23
24
  const t = R(), s = A(), n = O();
24
25
  return H({
25
26
  mutationFn: async (i) => await s(t, {
@@ -32,7 +33,7 @@ const Ae = () => {
32
33
  });
33
34
  }
34
35
  });
35
- }, Ie = () => {
36
+ }, Oe = () => {
36
37
  const t = R(), s = A(), n = O();
37
38
  return H({
38
39
  mutationFn: async ({ revisionId: i, discardCurrent: l }) => await s(t, {
@@ -45,7 +46,7 @@ const Ae = () => {
45
46
  });
46
47
  }
47
48
  });
48
- }, Oe = Ce(() => import("./json-diff-viewer-krslPepD.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: [
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: [
49
50
  /* @__PURE__ */ a("span", { className: "relative flex h-2 w-2", children: [
50
51
  /* @__PURE__ */ e("span", { className: "absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75" }),
51
52
  /* @__PURE__ */ e("span", { className: "relative inline-flex h-2 w-2 rounded-full bg-amber-500" })
@@ -64,7 +65,7 @@ const Ae = () => {
64
65
  /* @__PURE__ */ e(we, { className: "h-3 w-3" }),
65
66
  /* @__PURE__ */ e("span", { className: "text-[11px] leading-tight", children: "Unsaved changes" })
66
67
  ] }) : /* @__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 });
67
- function ke({ compare: t, setCompare: s }) {
68
+ function Me({ compare: t, setCompare: s }) {
68
69
  const { data: n } = $(), { saveState: i } = ce(), [l] = fe();
69
70
  if (!n) return null;
70
71
  const d = !!t.find((o) => {
@@ -101,7 +102,7 @@ function ke({ compare: t, setCompare: s }) {
101
102
  )
102
103
  ] });
103
104
  }
104
- function Me() {
105
+ function Te() {
105
106
  return /* @__PURE__ */ e("div", { className: "mt-2 space-y-2", children: Array.from({ length: 5 }).map((t, s) => /* @__PURE__ */ a("div", { className: "flex items-start gap-3 rounded-md border p-2", children: [
106
107
  /* @__PURE__ */ a("div", { className: "flex-1 space-y-1", children: [
107
108
  /* @__PURE__ */ e(y, { className: "h-4 w-3/4" }),
@@ -138,7 +139,7 @@ function V({
138
139
  /* @__PURE__ */ e("div", { className: "flex items-center text-[10px] text-muted-foreground", children: /* @__PURE__ */ e("span", { className: "leading-tight", children: D(t.createdAt, "MMM d, h:mm a") }) })
139
140
  ] })
140
141
  ] }),
141
- /* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ e(C, { permissions: [w.RESTORE_REVISION, w.DELETE_REVISION], children: /* @__PURE__ */ e(_e, { revision: t, onRestore: n, onDelete: i }) }) }),
142
+ /* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ e(C, { permissions: [w.RESTORE_REVISION, w.DELETE_REVISION], children: /* @__PURE__ */ e(Ue, { revision: t, onRestore: n, onDelete: i }) }) }),
142
143
  /* @__PURE__ */ e(
143
144
  K,
144
145
  {
@@ -160,8 +161,8 @@ function V({
160
161
  )
161
162
  ] });
162
163
  }
163
- function Te({ compare: t, setCompare: s, pageId: n }) {
164
- const [i, l] = Se(!1), [d, u] = t;
164
+ function _e({ compare: t, setCompare: s, pageId: n }) {
165
+ const [i, l] = Ee(!1), [d, u] = t;
165
166
  if (t.length === 0) return null;
166
167
  const m = ({ tab: o }) => /* @__PURE__ */ a("span", { className: "flex items-center justify-between rounded border border-blue-100 p-1 font-medium", children: [
167
168
  /* @__PURE__ */ e(N, { tag: o.label }),
@@ -210,10 +211,10 @@ function Te({ compare: t, setCompare: s, pageId: n }) {
210
211
  )
211
212
  ] }),
212
213
  i && (t == null ? void 0 : t.length) > 1 && n && /* @__PURE__ */ e(
213
- Ee,
214
+ Ce,
214
215
  {
215
216
  fallback: /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-4", children: /* @__PURE__ */ e("span", { className: "text-sm", children: "Loading diff viewer..." }) }),
216
- children: /* @__PURE__ */ e(Oe, { open: i, onOpenChange: l, compare: t })
217
+ children: /* @__PURE__ */ e(ke, { open: i, onOpenChange: l, compare: t })
217
218
  }
218
219
  )
219
220
  ] });
@@ -233,7 +234,7 @@ function K({ checked: t, disabled: s, onChange: n, label: i = "Compare" }) {
233
234
  /* @__PURE__ */ e("span", { className: "select-none leading-tight", children: i })
234
235
  ] }) });
235
236
  }
236
- function _e({ revision: t, onRestore: s, onDelete: n }) {
237
+ function Ue({ revision: t, onRestore: s, onDelete: n }) {
237
238
  return /* @__PURE__ */ a(oe, { children: [
238
239
  /* @__PURE__ */ e(ue, { asChild: !0, children: /* @__PURE__ */ a(g, { variant: "ghost", size: "icon", className: "h-5 w-5", children: [
239
240
  /* @__PURE__ */ e(De, { className: "h-4 w-4" }),
@@ -241,20 +242,20 @@ function _e({ revision: t, onRestore: s, onDelete: n }) {
241
242
  ] }) }),
242
243
  /* @__PURE__ */ a(me, { align: "end", className: "text-xs", children: [
243
244
  /* @__PURE__ */ e(C, { permission: w.RESTORE_REVISION, children: /* @__PURE__ */ a(U, { onClick: s, className: "cursor-pointer text-sm", children: [
244
- /* @__PURE__ */ e(J, { className: "mr-2 h-4 w-4" }),
245
+ /* @__PURE__ */ e(Q, { className: "mr-2 h-4 w-4" }),
245
246
  /* @__PURE__ */ e("span", { children: "Restore this version" })
246
247
  ] }) }),
247
248
  /* @__PURE__ */ e(C, { permission: w.DELETE_REVISION, children: t.uid !== "current" && /* @__PURE__ */ a(p, { children: [
248
249
  /* @__PURE__ */ e(he, {}),
249
250
  /* @__PURE__ */ a(U, { onClick: n, className: "cursor-pointer text-destructive", children: [
250
- /* @__PURE__ */ e(Q, { className: "mr-2 h-4 w-4" }),
251
+ /* @__PURE__ */ e(J, { className: "mr-2 h-4 w-4" }),
251
252
  /* @__PURE__ */ e("span", { children: "Delete this version" })
252
253
  ] })
253
254
  ] }) })
254
255
  ] })
255
256
  ] });
256
257
  }
257
- function Ue({
258
+ function Fe({
258
259
  open: t,
259
260
  onOpenChange: s,
260
261
  revision: n,
@@ -295,7 +296,7 @@ function Ue({
295
296
  /* @__PURE__ */ e("span", { className: "mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }),
296
297
  "Discarding current..."
297
298
  ] }) : /* @__PURE__ */ a(p, { children: [
298
- /* @__PURE__ */ e(J, { className: "mr-2 h-4 w-4" }),
299
+ /* @__PURE__ */ e(Q, { className: "mr-2 h-4 w-4" }),
299
300
  "Discard current"
300
301
  ] }) })
301
302
  ] })
@@ -303,7 +304,7 @@ function Ue({
303
304
  }
304
305
  ) : null;
305
306
  }
306
- function Fe({
307
+ function Ve({
307
308
  open: t,
308
309
  onOpenChange: s,
309
310
  revision: n,
@@ -338,7 +339,7 @@ function Fe({
338
339
  /* @__PURE__ */ e("span", { className: "mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }),
339
340
  "Deleting..."
340
341
  ] }) : /* @__PURE__ */ a(p, { children: [
341
- /* @__PURE__ */ e(Q, { className: "mr-2 h-4 w-4" }),
342
+ /* @__PURE__ */ e(J, { className: "mr-2 h-4 w-4" }),
342
343
  "Delete Revision"
343
344
  ] }) })
344
345
  ] })
@@ -346,10 +347,12 @@ function Fe({
346
347
  }
347
348
  ) : null;
348
349
  }
349
- function He({ isOpen: t }) {
350
+ function Je({ isOpen: t }) {
350
351
  var T, _;
351
- 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 } = Re(r == null ? void 0 : r.id), { mutate: B, isPending: W } = Ae(), { mutate: Y, isPending: X } = Ie(), Z = O(), { selectedLang: ee, fallbackLang: te } = le(), ae = ee || te;
352
- F(() => n([]), [r == null ? void 0 : r.id]);
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;
353
+ F(() => {
354
+ Se(() => n([]));
355
+ }, [r == null ? void 0 : r.id]);
353
356
  const ne = (c) => {
354
357
  i && Y(
355
358
  { revisionId: i.uid, discardCurrent: c },
@@ -386,9 +389,9 @@ function He({ isOpen: t }) {
386
389
  D(new Date(r.createdAt), "MMM d, yyyy 'at' h:mm a")
387
390
  ] })
388
391
  ] }),
389
- S ? /* @__PURE__ */ e(Me, {}) : 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: [
390
- /* @__PURE__ */ e(Te, { lang: ae, compare: s, setCompare: n, pageId: r == null ? void 0 : r.id }),
391
- /* @__PURE__ */ e(ke, { compare: s, setCompare: n }),
392
+ 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 }),
394
+ /* @__PURE__ */ e(Me, { compare: s, setCompare: n }),
392
395
  (T = f == null ? void 0 : f.filter((c) => c.uid === "current")) == null ? void 0 : T.map((c, E) => /* @__PURE__ */ e(
393
396
  V,
394
397
  {
@@ -419,7 +422,7 @@ function He({ isOpen: t }) {
419
422
  )) }) })
420
423
  ] }),
421
424
  /* @__PURE__ */ e(
422
- Ue,
425
+ Fe,
423
426
  {
424
427
  open: d,
425
428
  onOpenChange: u,
@@ -429,7 +432,7 @@ function He({ isOpen: t }) {
429
432
  }
430
433
  ),
431
434
  /* @__PURE__ */ e(
432
- Fe,
435
+ Ve,
433
436
  {
434
437
  open: m,
435
438
  onOpenChange: o,
@@ -441,5 +444,5 @@ function He({ isOpen: t }) {
441
444
  ] });
442
445
  }
443
446
  export {
444
- He as default
447
+ Je as default
445
448
  };
@@ -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-BqwKw4uy.cjs"),l=require("./index-B0e71wJ1.cjs"),d=require("./index-DKuwxj1x.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 a=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(n,t,a.get?a:{enumerable:!0,get:()=>s[t]})}}return n.default=s,Object.freeze(n)}const S=L(g);function Q(s){const n=d.useApiUrl(),t=d.useFetch();return y.useQuery({queryKey:[d.ACTIONS.GET_PAGE_REVISIONS,s],queryFn:async()=>await t(n,{action:d.ACTIONS.GET_PAGE_REVISIONS,data:{pageId:s}}),enabled:!!s,refetchOnMount:!0})}const z=()=>{const s=d.useApiUrl(),n=d.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async a=>await n(s,{action:d.ACTIONS.DELETE_PAGE_REVISION,data:{revisionId:a}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},H=()=>{const s=d.useApiUrl(),n=d.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async({revisionId:a,discardCurrent:r})=>await n(s,{action:d.ACTIONS.RESTORE_PAGE_REVISION,data:{revisionId:a,discardCurrent:r}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},$=g.lazy(()=>Promise.resolve().then(()=>require("./json-diff-viewer-D9DVIBz4.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}=d.useChaiCurrentPage(),{saveState:a}=l.useSavePage(),[r]=d.usePageEditInfo();if(!t)return null;const c=!!s.find(u=>{var i;return(i=u==null?void 0:u.uid)==null?void 0:i.startsWith("draft:")}),x=s.length>=2&&!c,m=a==="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:c,disabled:x,onChange:()=>{n(c?s.filter(u=>u.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(l.Skeleton,{className:"h-4 w-3/4"}),e.jsx(l.Skeleton,{className:"h-3 w-1/2"}),e.jsx(l.Skeleton,{className:"mt-1 h-5 w-20"})]}),e.jsx(l.Skeleton,{className:"h-8 w-8 rounded-full"})]},n))})}function O({revision:s,isLatest:n,onRestore:t,onDelete:a,revisionNumber:r,compare:c,setCompare:x,pageId:m}){const{data:u}=d.useChaiUserInfo(s.currentEditor),i=(u==null?void 0:u.name)||"Unknown",f=!!c.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=c.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:i})]})}),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(d.PermissionChecker,{permissions:[d.PAGES_PERMISSIONS.RESTORE_REVISION,d.PAGES_PERMISSIONS.DELETE_REVISION],children:e.jsx(Y,{revision:s,onRestore:t,onDelete:a})})}),e.jsx(A,{checked:f,disabled:w,onChange:()=>{x(f?c.filter(h=>n?h.uid!==`live:${m}`:h.uid!==s.uid):[...c,{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[a,r]=g.useState(!1),[c,x]=s;if(s.length===0)return null;const m=({tab:u})=>e.jsxs("span",{className:"flex items-center justify-between rounded border border-blue-100 p-1 font-medium",children:[e.jsx(b,{tag:u.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(i=>i.uid!==u.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"}),c&&e.jsx(m,{tab:c}),e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"with"}),x?e.jsx(m,{tab:x}):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"})]})]}),a&&(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:a,onOpenChange:r,compare:s})})]})}function A({checked:s,disabled:n,onChange:t,label:a="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:a})]})})}function Y({revision:s,onRestore:n,onDelete:t}){return e.jsxs(l.DropdownMenu,{children:[e.jsx(l.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(l.DropdownMenuContent,{align:"end",className:"text-xs",children:[e.jsx(d.PermissionChecker,{permission:d.PAGES_PERMISSIONS.RESTORE_REVISION,children:e.jsxs(l.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(d.PermissionChecker,{permission:d.PAGES_PERMISSIONS.DELETE_REVISION,children:s.uid!=="current"&&e.jsxs(e.Fragment,{children:[e.jsx(l.DropdownMenuSeparator,{}),e.jsxs(l.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:a,isRestoring:r}){const{data:c}=d.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),x=(c==null?void 0:c.name)||"Unknown";return t?e.jsx(l.Dialog,{open:s,onOpenChange:m=>{r||n(m)},children:e.jsxs(l.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(l.DialogHeader,{children:[e.jsx(l.DialogTitle,{children:"Restore Revision"}),e.jsxs(l.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 ",x]})]}),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(l.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(N.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>a(!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:()=>a(!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:a,isDeleting:r}){const{data:c}=d.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),x=(c==null?void 0:c.name)||"Unknown";return t?e.jsx(l.Dialog,{open:s,onOpenChange:m=>{r||n(m)},children:e.jsxs(l.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(l.DialogHeader,{children:[e.jsx(l.DialogTitle,{children:"Delete Revision"}),e.jsxs(l.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 ",x]})]}),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(l.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:a,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([]),[a,r]=S.useState(null),[c,x]=S.useState(!1),[m,u]=S.useState(!1),{data:i}=d.useChaiCurrentPage(),{data:f,isFetching:w,error:h,refetch:j}=Q(i==null?void 0:i.id),{mutate:T,isPending:M}=z(),{mutate:k,isPending:F}=H(),_=y.useQueryClient(),{selectedLang:P,fallbackLang:q}=l.useLanguages(),U=P||q;g.useEffect(()=>{g.startTransition(()=>t([]))},[i==null?void 0:i.id]);const G=o=>{a&&k({revisionId:a.uid,discardCurrent:o},{onSuccess:()=>{x(!1),r(null),_.invalidateQueries({queryKey:[d.ACTIONS.GET_DRAFT_PAGE]})}})},C=o=>{r(o),x(!0)},E=o=>{r(o),u(!0)},V=()=>{a&&T(a.uid,{onSuccess:()=>{u(!1),r(null)}})};return g.useEffect(()=>{s&&j()},[s,j]),e.jsxs(e.Fragment,{children:[e.jsxs(l.SheetHeader,{children:[e.jsx(l.SheetTitle,{children:"Revision History"}),(i==null?void 0:i.createdAt)&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Page created on ",v.format(new Date(i.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:i==null?void 0:i.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:i==null?void 0:i.id,revision:o,isLatest:!0,onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:D,compare:n,setCompare:t},o.uid)),e.jsx(l.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:i==null?void 0:i.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:c,onOpenChange:x,revision:a,onRestore:G,isRestoring:F}),e.jsx(Z,{open:m,onOpenChange:u,revision:a,onDelete:V,isDeleting:M})]})}exports.default=ee;
package/dist/pages.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-WQwzsC7A.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-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;
package/dist/pages.d.ts CHANGED
@@ -54,7 +54,7 @@ declare interface ChaiBuilderEditorProps {
54
54
  /**
55
55
  * Permissions
56
56
  */
57
- permissions?: string[];
57
+ permissions?: string[] | null;
58
58
  /**
59
59
  * Optional pageId. If not provided, a random pageId will be generated
60
60
  */
@@ -332,7 +332,7 @@ export declare const LanguageSwitcher: ({ showAdd, variant, goToDefaultLang, }:
332
332
  showAdd?: boolean;
333
333
  variant?: "ghost" | "outline";
334
334
  goToDefaultLang?: boolean;
335
- }) => JSX.Element;
335
+ }) => JSX.Element | null;
336
336
 
337
337
  declare type LoggedInUser = {
338
338
  id: string;
@@ -463,7 +463,7 @@ export declare const useClearAll: () => () => void;
463
463
 
464
464
  export declare const useFallbackLang: () => string;
465
465
 
466
- export declare const useFetch: () => (url: string, body: {
466
+ export declare const useFetch: () => (url: string | undefined, body: {
467
467
  action: string;
468
468
  data?: any;
469
469
  }, headers?: Record<string, string>, streamResponse?: boolean) => Promise<any>;
@@ -472,7 +472,7 @@ export declare const useGotoPage: () => ({ pageId }: {
472
472
  pageId: string;
473
473
  }) => void;
474
474
 
475
- export declare const useLanguagePages: (pageId?: string | undefined) => UseQueryResult<any[], Error>;
475
+ export declare const useLanguagePages: (pageId?: string | undefined) => UseQueryResult<any[] | null, Error>;
476
476
 
477
477
  export declare const usePageTypes: () => UseQueryResult<any, Error>;
478
478
 
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-ZuacEL1j.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-Bn0fFN58.js";
2
2
  export {
3
3
  s as ChaiJsonInput,
4
4
  u as ChaiWebsiteBuilder,
@@ -1,4 +1,4 @@
1
- "use strict";const a=require("lodash-es"),h=require("./fonts-B-Xt29pe.cjs"),b=require("./_commonjsHelpers-DwGv2jUC.cjs"),B={fontFamily:{"font-heading":"Inter","font-body":"Inter"},borderRadius:"10px",colors:[{group:"Body",items:{background:["#FFFFFF","#121212"],foreground:["#121212","#FFFFFF"]}},{group:"Primary",items:{primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"]}},{group:"Secondary",items:{secondary:["#F3F4F6","#374151"],"secondary-foreground":["#1F2937","#F9FAFB"]}},{group:"Border, Input & Ring",items:{border:["#E5E7EB","#374151"],input:["#E5E7EB","#374151"],ring:["#2563EB","#3B82F6"]}},{group:"Card",items:{card:["#FFFFFF","#1F2937"],"card-foreground":["#121212","#FFFFFF"]}},{group:"Popover",items:{popover:["#FFFFFF","#1F2937"],"popover-foreground":["#121212","#FFFFFF"]}},{group:"Muted",items:{muted:["#F3F4F6","#374151"],"muted-foreground":["#6B7280","#9CA3AF"]}},{group:"Accent",items:{accent:["#F3F4F6","#374151"],"accent-foreground":["#1F2937","#FFFFFF"]}},{group:"Destructive",items:{destructive:["#DC2626","#EF4444"],"destructive-foreground":["#FFFFFF","#FFFFFF"]}}]},v={fontFamily:{heading:"Inter",body:"Inter"},borderRadius:"6px",colors:{background:["#FFFFFF","#09090B"],foreground:["#09090B","#FFFFFF"],primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"],secondary:["#F4F4F5","#27272A"],"secondary-foreground":["#09090B","#FFFFFF"],muted:["#F4F4F5","#27272A"],"muted-foreground":["#71717A","#A1A1AA"],accent:["#F4F4F5","#27272A"],"accent-foreground":["#09090B","#FFFFFF"],destructive:["#EF4444","#7F1D1D"],"destructive-foreground":["#FFFFFF","#FFFFFF"],border:["#E4E4E7","#27272A"],input:["#E4E4E7","#27272A"],ring:["#2563EB","#3B82F6"],card:["#FFFFFF","#09090B"],"card-foreground":["#09090B","#FFFFFF"],popover:["#FFFFFF","#09090B"],"popover-foreground":["#09090B","#FFFFFF"]}},_=e=>({fontFamily:e.fontFamily?a.keys(e.fontFamily).reduce((r,n)=>({...r,[n.replace("font-","")]:`var(--${n})`}),{}):{},borderRadius:e.borderRadius?{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"}:{},colors:e.colors?a.flatten(e.colors.map(r=>Object.entries(r.items))).reduce((r,[n])=>({...r,[n]:`hsl(var(--${n}))`}),{}):{}});function m(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);let r=parseInt(t[1],16),n=parseInt(t[2],16),F=parseInt(t[3],16);r/=255,n/=255,F/=255;const o=Math.max(r,n,F),u=Math.min(r,n,F);let i,l;const g=(o+u)/2;if(o==u)i=l=0;else{const s=o-u;switch(l=g>.5?s/(2-o-u):s/(o+u),o){case r:i=(n-F)/s+(n<F?6:0);break;case n:i=(F-r)/s+2;break;case F:i=(r-n)/s+4;break}i/=6}return`${Math.round(i*360)} ${Math.round(l*100)}% ${Math.round(g*100)}%`}const E=e=>{const r=h.getAllRegisteredFonts().find(n=>n.family===e);return`"${e}", ${a.get(r,"fallback","")}`},C=e=>`:root {
1
+ "use strict";const a=require("lodash-es"),h=require("./fonts-B-Xt29pe.cjs"),b=require("./_commonjsHelpers-DwGv2jUC.cjs"),B={fontFamily:{"font-heading":"Inter","font-body":"Inter"},borderRadius:"10px",colors:[{group:"Body",items:{background:["#FFFFFF","#121212"],foreground:["#121212","#FFFFFF"]}},{group:"Primary",items:{primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"]}},{group:"Secondary",items:{secondary:["#F3F4F6","#374151"],"secondary-foreground":["#1F2937","#F9FAFB"]}},{group:"Border, Input & Ring",items:{border:["#E5E7EB","#374151"],input:["#E5E7EB","#374151"],ring:["#2563EB","#3B82F6"]}},{group:"Card",items:{card:["#FFFFFF","#1F2937"],"card-foreground":["#121212","#FFFFFF"]}},{group:"Popover",items:{popover:["#FFFFFF","#1F2937"],"popover-foreground":["#121212","#FFFFFF"]}},{group:"Muted",items:{muted:["#F3F4F6","#374151"],"muted-foreground":["#6B7280","#9CA3AF"]}},{group:"Accent",items:{accent:["#F3F4F6","#374151"],"accent-foreground":["#1F2937","#FFFFFF"]}},{group:"Destructive",items:{destructive:["#DC2626","#EF4444"],"destructive-foreground":["#FFFFFF","#FFFFFF"]}}]},v={fontFamily:{heading:"Inter",body:"Inter"},borderRadius:"6px",colors:{background:["#FFFFFF","#09090B"],foreground:["#09090B","#FFFFFF"],primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"],secondary:["#F4F4F5","#27272A"],"secondary-foreground":["#09090B","#FFFFFF"],muted:["#F4F4F5","#27272A"],"muted-foreground":["#71717A","#A1A1AA"],accent:["#F4F4F5","#27272A"],"accent-foreground":["#09090B","#FFFFFF"],destructive:["#EF4444","#7F1D1D"],"destructive-foreground":["#FFFFFF","#FFFFFF"],border:["#E4E4E7","#27272A"],input:["#E4E4E7","#27272A"],ring:["#2563EB","#3B82F6"],card:["#FFFFFF","#09090B"],"card-foreground":["#09090B","#FFFFFF"],popover:["#FFFFFF","#09090B"],"popover-foreground":["#09090B","#FFFFFF"]}},_=e=>({fontFamily:e.fontFamily?a.keys(e.fontFamily).reduce((r,n)=>({...r,[n.replace("font-","")]:`var(--${n})`}),{}):{},borderRadius:e.borderRadius?{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"}:{},colors:e.colors?a.flatten(e.colors.map(r=>Object.entries(r.items))).reduce((r,[n])=>({...r,[n]:`hsl(var(--${n}))`}),{}):{}});function m(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);let r=parseInt(t[1],16),n=parseInt(t[2],16),F=parseInt(t[3],16);r/=255,n/=255,F/=255;const o=Math.max(r,n,F),u=Math.min(r,n,F);let i=0,l=0;const g=(o+u)/2;if(o==u)i=l=0;else{const s=o-u;switch(l=g>.5?s/(2-o-u):s/(o+u),o){case r:i=(n-F)/s+(n<F?6:0);break;case n:i=(F-r)/s+2;break;case F:i=(r-n)/s+4;break}i/=6}return`${Math.round(i*360)} ${Math.round(l*100)}% ${Math.round(g*100)}%`}const E=e=>{const r=h.getAllRegisteredFonts().find(n=>n.family===e);return`"${e}", ${a.get(r,"fallback","")}`},C=e=>`:root {
2
2
  ${e.fontFamily&&Object.entries(e.fontFamily).map(([t,r])=>`--font-${t}: ${E(r)};`).join(`
3
3
  `)}
4
4
  ${e.borderRadius&&`--radius: ${e.borderRadius};`}
@@ -123,7 +123,7 @@ function m(r) {
123
123
  let e = parseInt(t[1], 16), n = parseInt(t[2], 16), F = parseInt(t[3], 16);
124
124
  e /= 255, n /= 255, F /= 255;
125
125
  const o = Math.max(e, n, F), u = Math.min(e, n, F);
126
- let a, d;
126
+ let a = 0, d = 0;
127
127
  const g = (o + u) / 2;
128
128
  if (o == u)
129
129
  a = d = 0;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),q=require("./register-chai-top-bar-BqwKw4uy.cjs"),f=require("./index-B0e71wJ1.cjs"),r=require("./index-DKuwxj1x.cjs"),U=require("./page-manager-search-and-filter-DGQEgKzy.cjs"),F=require("@tanstack/react-query"),t=require("lodash-es"),b=require("lucide-react"),a=require("react"),M=()=>{const l=r.useApiUrl(),d=r.useFetch();return F.useQuery({queryKey:[r.ACTIONS.GET_CHANGES],queryFn:async()=>d(l,{action:r.ACTIONS.GET_CHANGES})})},G=({page:l,selectedPages:d,handleCheckboxChange:N,getPageType:y,hasSlug:h,currentOwnerId:c})=>{const x=r.useUserId(),{data:u}=r.useChaiUserInfo(c),o=c===x?null:u==null?void 0:u.name;return e.jsxs("tr",{className:"group relative border-b last:border-b-0 hover:bg-gray-50",children:[e.jsxs("td",{scope:"row",className:`flex items-center gap-x-1 whitespace-nowrap px-6 py-2 text-gray-900 dark:text-white ${o?"opacity-50":""}`,children:[o?e.jsx(b.Lock,{className:"h-4 w-4 fill-red-200 text-red-500"}):e.jsx("input",{checked:t.includes(d,l==null?void 0:l.id),onClick:p=>{p.stopPropagation(),N(l==null?void 0:l.id)},type:"checkbox",className:"cursor-pointer rounded focus:outline-none focus:ring-0"})," ",h(l.pageType)?e.jsx(b.File,{className:"h-4 w-4"}):e.jsx(b.GlobeIcon,{className:"h-4 w-4"}),e.jsx(r.Tooltip,{content:l.name,side:"top",showTooltip:l.name.length>25,children:e.jsx("span",{className:"max-w-[200px] truncate font-medium text-black",children:l.name})}),l.slug&&e.jsx(r.Tooltip,{content:l.slug,side:"top",showTooltip:l.slug.length>25,children:e.jsx("span",{className:"max-w-[200px] truncate font-mono text-xs text-muted-foreground",children:l.slug})})]}),e.jsx("td",{className:"px-2",children:y(l==null?void 0:l.pageType)}),e.jsx("td",{className:"px-4 text-right",children:t.first(l.changes)||""}),e.jsx(e.Fragment,{children:o&&e.jsxs("button",{className:"absolute right-0 top-0 flex h-full items-center gap-x-1 rounded bg-red-50 px-2 py-0.5 text-xs font-light text-red-500 opacity-0 group-hover:opacity-100",children:[e.jsx(b.Edit,{size:12,className:"stroke-[3]"})," ",e.jsx("span",{className:"font-medium",children:o})," is editing this page"]})})]},l==null?void 0:l.id)},O=({onClose:l=()=>{},isPending:d,publishPage:N})=>{const y=r.useUserId(),{pageToUser:h}=r.usePageToUser(),[c,x]=a.useState([]),u=r.useFallbackLang(),[o,p]=a.useState(u),{data:T,isFetching:C}=M(),{data:m}=r.usePageTypes(),k=a.useCallback(s=>{var n;return(n=t.find(m,{key:s}))==null?void 0:n.hasSlug},[m]),j=a.useMemo(()=>t.filter(m,s=>!k(s.key)).map(s=>s.key),[k,m]),P=t.uniq(t.map(T,"lang")).filter(Boolean),i=a.useMemo(()=>t.filter(T,s=>s.pageType==="theme"?!1:o===u?s.lang===o||s.lang==="":s.lang===o),[T,o,u]),w=a.useMemo(()=>t.filter(i,s=>!j.includes(s.pageType)),[i,j]),S=a.useMemo(()=>t.filter(i,s=>j.includes(s.pageType)),[i,j]);a.useEffect(()=>{const s=t.map(t.filter(i,{online:!0}),"id");a.startTransition(()=>x(s))},[i]),a.useEffect(()=>{const s=t.filter(t.keys(h),n=>t.get(h,[n,"userId"])!==y);a.startTransition(()=>x(n=>t.filter(n,g=>!t.includes(s,g))))},[h,y]);const v=c.length===(i==null?void 0:i.length),E=s=>{x(n=>t.includes(n,s)?t.filter(n,g=>g!==s):t.concat(n,s))},B=()=>{x(v?[]:t.map(i,"id"))},I=()=>{N({ids:t.uniq(c)},{onSuccess:()=>{l(),r.throwConfetti("CENTER_CENTER"),p(u)}})},A=s=>{if(s==="theme")return"Theme";const n=t.find(m,{key:s});return n?n==null?void 0:n.name:s},L=a.useMemo(()=>{const s=[{label:"Updated",top:"pt-2"},...t.orderBy(t.filter(w,{online:!0}),"pageType"),...t.orderBy(t.filter(S,{online:!0}),"pageType")].filter(g=>g.pageType!=="theme"),n=[{label:"Offline",top:"pt-6"},...t.orderBy(t.filter(w,{online:!1}),"pageType"),...t.orderBy(t.filter(S,{online:!1}),"pageType")];return[...s,...n]},[w,S]);return e.jsxs(f.DialogContent,{className:"flex max-h-[80%] max-w-4xl flex-col",children:[e.jsxs(f.DialogHeader,{children:[e.jsx(f.DialogTitle,{children:"Publish changes"}),e.jsx(f.DialogDescription,{className:"text-xs",children:"Select the pages you want to publish. Click publish when you're done."})]}),P.length>0&&e.jsx("div",{className:"my-[2px] mt-0",children:e.jsx(U.LanguageSelector,{languages:[u,...P],selectedLanguage:o,setSelectedLanguage:p})}),e.jsx("div",{className:"no-scrollbar relative -mx-4 -mt-4 h-full max-h-full overflow-y-auto",children:C?e.jsxs("div",{className:"space-y-2 px-1",children:[e.jsx("div",{className:"mt-2 h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"})]}):e.jsxs("table",{className:"w-full text-left text-xs text-gray-500 dark:text-gray-400 rtl:text-right",children:[e.jsx("thead",{className:"sticky top-0 z-10 border-b bg-gray-50 text-gray-700 dark:bg-gray-700 dark:text-gray-400",children:e.jsxs("tr",{children:[e.jsxs("th",{scope:"col",className:"w-[1 50px] flex items-center gap-x-2 px-6 py-3",children:[e.jsx("input",{checked:v,onClick:s=>{s.stopPropagation(),B()},type:"checkbox",className:"mt-1 cursor-pointer rounded focus:outline-none focus:ring-0"}),"Name"]}),e.jsx("th",{scope:"col",className:"w-[150px] px-2 py-3",children:"Type"}),e.jsx("th",{scope:"col",className:"w-[150px] px-4 py-3 text-right",children:"Status"})]})}),e.jsx("tbody",{children:t.map(L,s=>s.label?e.jsx("tr",{children:e.jsxs("td",{colSpan:3,className:`relative px-6 py-2 text-xs font-medium text-gray-800 ${s.top}`,children:[e.jsx("div",{className:"absolute inset-0 left-6 flex items-center",children:e.jsx("div",{className:"order-gray-300 w-full"})}),e.jsx("div",{className:"relative flex justify-start",children:e.jsx("span",{className:"bg-gray-50 pr-2",children:s.label})})]})},"separator"):e.jsx(G,{page:s,selectedPages:c,handleCheckboxChange:E,getPageType:A,hasSlug:k,currentOwnerId:t.get(h,[(s==null?void 0:s.primaryPage)||(s==null?void 0:s.id),"userId"])}))})]})}),e.jsxs(f.DialogFooter,{className:"mt-10 flex items-center justify-center",children:[c.length>0&&e.jsxs("span",{className:"text-center text-sm text-muted-foreground",children:[c.length," Page",c.length!==1?"s":""," Selected"]}),e.jsx(q.Button,{disabled:d,variant:"outline",onClick:l,children:"Cancel"}),e.jsx(q.Button,{disabled:d||C||t.isEmpty(c),onClick:I,children:d?"Publishing...":"Publish Selected"})]})]})};exports.default=O;
@@ -1,122 +1,123 @@
1
- import { jsxs as n, jsx as t, Fragment as _ } from "react/jsx-runtime";
2
- import { d as $, e as K, f as Q, p as J, q as V, B as L } from "./index-Ct7ElCGK.js";
3
- import { LanguageSelector as W } from "./page-manager-search-and-filter-CM0UMb6U.js";
4
- import { ar as X, as as Y, A as I, aA as q, aB as Z, k as ee, m as te, ap as se, T as U, t as le } from "./index-ZuacEL1j.js";
5
- import { useQuery as ae } from "@tanstack/react-query";
6
- import { find as B, filter as a, map as b, keys as ne, get as F, includes as C, orderBy as N, isEmpty as re, uniq as G, first as ce, concat as oe } from "lodash-es";
7
- import { Lock as ie, GlobeIcon as de, File as ue, Edit as he } from "lucide-react";
8
- import { useState as D, useCallback as me, useMemo as p, useEffect as j } from "react";
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";
6
+ import { useQuery as ne } from "@tanstack/react-query";
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
+ import { Lock as de, GlobeIcon as ue, File as me, Edit as he } from "lucide-react";
9
+ import { useState as D, useCallback as pe, useMemo as g, useEffect as j, startTransition as q } from "react";
9
10
  const ge = () => {
10
11
  const s = X(), d = Y();
11
- return ae({
12
+ return ne({
12
13
  queryKey: [I.GET_CHANGES],
13
14
  queryFn: async () => d(s, { action: I.GET_CHANGES })
14
15
  });
15
- }, pe = ({ page: s, selectedPages: d, handleCheckboxChange: k, getPageType: x, hasSlug: h, currentOwnerId: r }) => {
16
- const u = q(), { data: i } = se(r), c = r === u ? null : i == null ? void 0 : i.name;
16
+ }, fe = ({ page: s, selectedPages: d, handleCheckboxChange: k, getPageType: f, hasSlug: m, currentOwnerId: r }) => {
17
+ const u = O(), { data: i } = se(r), o = r === u ? null : i == null ? void 0 : i.name;
17
18
  return /* @__PURE__ */ n("tr", { className: "group relative border-b last:border-b-0 hover:bg-gray-50", children: [
18
19
  /* @__PURE__ */ n(
19
20
  "td",
20
21
  {
21
22
  scope: "row",
22
- className: `flex items-center gap-x-1 whitespace-nowrap px-6 py-2 text-gray-900 dark:text-white ${c ? "opacity-50" : ""}`,
23
+ className: `flex items-center gap-x-1 whitespace-nowrap px-6 py-2 text-gray-900 dark:text-white ${o ? "opacity-50" : ""}`,
23
24
  children: [
24
- c ? /* @__PURE__ */ t(ie, { className: "h-4 w-4 fill-red-200 text-red-500" }) : /* @__PURE__ */ t(
25
+ o ? /* @__PURE__ */ t(de, { className: "h-4 w-4 fill-red-200 text-red-500" }) : /* @__PURE__ */ t(
25
26
  "input",
26
27
  {
27
28
  checked: C(d, s == null ? void 0 : s.id),
28
- onClick: (f) => {
29
- f.stopPropagation(), k(s == null ? void 0 : s.id);
29
+ onClick: (x) => {
30
+ x.stopPropagation(), k(s == null ? void 0 : s.id);
30
31
  },
31
32
  type: "checkbox",
32
33
  className: "cursor-pointer rounded focus:outline-none focus:ring-0"
33
34
  }
34
35
  ),
35
36
  " ",
36
- h(s.pageType) ? /* @__PURE__ */ t(ue, { className: "h-4 w-4" }) : /* @__PURE__ */ t(de, { className: "h-4 w-4" }),
37
+ m(s.pageType) ? /* @__PURE__ */ t(me, { className: "h-4 w-4" }) : /* @__PURE__ */ t(ue, { className: "h-4 w-4" }),
37
38
  /* @__PURE__ */ t(U, { content: s.name, side: "top", showTooltip: s.name.length > 25, children: /* @__PURE__ */ t("span", { className: "max-w-[200px] truncate font-medium text-black", children: s.name }) }),
38
39
  s.slug && /* @__PURE__ */ t(U, { content: s.slug, side: "top", showTooltip: s.slug.length > 25, children: /* @__PURE__ */ t("span", { className: "max-w-[200px] truncate font-mono text-xs text-muted-foreground", children: s.slug }) })
39
40
  ]
40
41
  }
41
42
  ),
42
- /* @__PURE__ */ t("td", { className: "px-2", children: x(s == null ? void 0 : s.pageType) }),
43
+ /* @__PURE__ */ t("td", { className: "px-2", children: f(s == null ? void 0 : s.pageType) }),
43
44
  /* @__PURE__ */ t("td", { className: "px-4 text-right", children: ce(s.changes) || "" }),
44
- /* @__PURE__ */ t(_, { children: c && /* @__PURE__ */ n("button", { className: "absolute right-0 top-0 flex h-full items-center gap-x-1 rounded bg-red-50 px-2 py-0.5 text-xs font-light text-red-500 opacity-0 group-hover:opacity-100", children: [
45
+ /* @__PURE__ */ t($, { children: o && /* @__PURE__ */ n("button", { className: "absolute right-0 top-0 flex h-full items-center gap-x-1 rounded bg-red-50 px-2 py-0.5 text-xs font-light text-red-500 opacity-0 group-hover:opacity-100", children: [
45
46
  /* @__PURE__ */ t(he, { size: 12, className: "stroke-[3]" }),
46
47
  " ",
47
- /* @__PURE__ */ t("span", { className: "font-medium", children: c }),
48
+ /* @__PURE__ */ t("span", { className: "font-medium", children: o }),
48
49
  " is editing this page"
49
50
  ] }) })
50
51
  ] }, s == null ? void 0 : s.id);
51
- }, Pe = ({
52
+ }, ve = ({
52
53
  onClose: s = () => {
53
54
  },
54
55
  isPending: d,
55
56
  publishPage: k
56
57
  }) => {
57
- const x = q(), { pageToUser: h } = Z(), [r, u] = D([]), i = ee(), [c, f] = D(i), { data: w, isFetching: v } = ge(), { data: m } = te(), T = me((e) => {
58
+ const f = O(), { pageToUser: m } = Z(), [r, u] = D([]), i = ee(), [o, x] = D(i), { data: w, isFetching: v } = ge(), { data: h } = te(), T = pe((e) => {
58
59
  var l;
59
- return (l = B(m, { key: e })) == null ? void 0 : l.hasSlug;
60
- }, [m]), y = p(
61
- () => a(m, (e) => !T(e.key)).map((e) => e.key),
62
- [T, m]
63
- ), E = G(b(w, "lang")).filter(Boolean), o = p(
64
- () => a(w, (e) => e.pageType === "theme" ? !1 : c === i ? e.lang === c || e.lang === "" : e.lang === c),
65
- [w, c, i]
66
- ), S = p(
67
- () => a(o, (e) => !y.includes(e.pageType)),
68
- [o, y]
69
- ), P = p(
70
- () => a(o, (e) => y.includes(e.pageType)),
71
- [o, y]
60
+ return (l = B(h, { key: e })) == null ? void 0 : l.hasSlug;
61
+ }, [h]), y = g(
62
+ () => a(h, (e) => !T(e.key)).map((e) => e.key),
63
+ [T, h]
64
+ ), E = G(b(w, "lang")).filter(Boolean), c = g(
65
+ () => a(w, (e) => e.pageType === "theme" ? !1 : o === i ? e.lang === o || e.lang === "" : e.lang === o),
66
+ [w, o, i]
67
+ ), S = g(
68
+ () => a(c, (e) => !y.includes(e.pageType)),
69
+ [c, y]
70
+ ), P = g(
71
+ () => a(c, (e) => y.includes(e.pageType)),
72
+ [c, y]
72
73
  );
73
74
  j(() => {
74
- const e = b(a(o, { online: !0 }), "id");
75
- u(e);
76
- }, [o]), j(() => {
77
- const e = a(ne(h), (l) => F(h, [l, "userId"]) !== x);
78
- u((l) => a(l, (g) => !C(e, g)));
79
- }, [h, x]);
80
- const A = r.length === (o == null ? void 0 : o.length), O = (e) => {
81
- u((l) => C(l, e) ? a(l, (g) => g !== e) : oe(l, e));
82
- }, H = () => {
83
- u(A ? [] : b(o, "id"));
75
+ const e = b(a(c, { online: !0 }), "id");
76
+ q(() => u(e));
77
+ }, [c]), j(() => {
78
+ const e = a(re(m), (l) => F(m, [l, "userId"]) !== f);
79
+ q(() => u((l) => a(l, (p) => !C(e, p))));
80
+ }, [m, f]);
81
+ const A = r.length === (c == null ? void 0 : c.length), H = (e) => {
82
+ u((l) => C(l, e) ? a(l, (p) => p !== e) : ie(l, e));
84
83
  }, z = () => {
84
+ u(A ? [] : b(c, "id"));
85
+ }, M = () => {
85
86
  k(
86
87
  { ids: G(r) },
87
88
  {
88
89
  onSuccess: () => {
89
- s(), le("CENTER_CENTER"), f(i);
90
+ s(), le("CENTER_CENTER"), x(i);
90
91
  }
91
92
  }
92
93
  );
93
- }, M = (e) => {
94
+ }, R = (e) => {
94
95
  if (e === "theme") return "Theme";
95
- const l = B(m, { key: e });
96
+ const l = B(h, { key: e });
96
97
  return l ? l == null ? void 0 : l.name : e;
97
- }, R = p(() => {
98
+ }, _ = g(() => {
98
99
  const e = [
99
100
  { label: "Updated", top: "pt-2" },
100
101
  ...N(a(S, { online: !0 }), "pageType"),
101
102
  ...N(a(P, { online: !0 }), "pageType")
102
- ].filter((g) => g.pageType !== "theme"), l = [
103
+ ].filter((p) => p.pageType !== "theme"), l = [
103
104
  { label: "Offline", top: "pt-6" },
104
105
  ...N(a(S, { online: !1 }), "pageType"),
105
106
  ...N(a(P, { online: !1 }), "pageType")
106
107
  ];
107
108
  return [...e, ...l];
108
109
  }, [S, P]);
109
- return /* @__PURE__ */ n($, { className: "flex max-h-[80%] max-w-4xl flex-col", children: [
110
- /* @__PURE__ */ n(K, { children: [
111
- /* @__PURE__ */ t(Q, { children: "Publish changes" }),
112
- /* @__PURE__ */ t(J, { className: "text-xs", children: "Select the pages you want to publish. Click publish when you're done." })
110
+ return /* @__PURE__ */ n(K, { className: "flex max-h-[80%] max-w-4xl flex-col", children: [
111
+ /* @__PURE__ */ n(Q, { children: [
112
+ /* @__PURE__ */ t(J, { children: "Publish changes" }),
113
+ /* @__PURE__ */ t(V, { className: "text-xs", children: "Select the pages you want to publish. Click publish when you're done." })
113
114
  ] }),
114
115
  E.length > 0 && /* @__PURE__ */ t("div", { className: "my-[2px] mt-0", children: /* @__PURE__ */ t(
115
- W,
116
+ ae,
116
117
  {
117
118
  languages: [i, ...E],
118
- selectedLanguage: c,
119
- setSelectedLanguage: f
119
+ selectedLanguage: o,
120
+ setSelectedLanguage: x
120
121
  }
121
122
  ) }),
122
123
  /* @__PURE__ */ t("div", { className: "no-scrollbar relative -mx-4 -mt-4 h-full max-h-full overflow-y-auto", children: v ? /* @__PURE__ */ n("div", { className: "space-y-2 px-1", children: [
@@ -132,7 +133,7 @@ const ge = () => {
132
133
  {
133
134
  checked: A,
134
135
  onClick: (e) => {
135
- e.stopPropagation(), H();
136
+ e.stopPropagation(), z();
136
137
  },
137
138
  type: "checkbox",
138
139
  className: "mt-1 cursor-pointer rounded focus:outline-none focus:ring-0"
@@ -144,24 +145,24 @@ const ge = () => {
144
145
  /* @__PURE__ */ t("th", { scope: "col", className: "w-[150px] px-4 py-3 text-right", children: "Status" })
145
146
  ] }) }),
146
147
  /* @__PURE__ */ t("tbody", { children: b(
147
- R,
148
+ _,
148
149
  (e) => e.label ? /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ n("td", { colSpan: 3, className: `relative px-6 py-2 text-xs font-medium text-gray-800 ${e.top}`, children: [
149
150
  /* @__PURE__ */ t("div", { className: "absolute inset-0 left-6 flex items-center", children: /* @__PURE__ */ t("div", { className: "order-gray-300 w-full" }) }),
150
151
  /* @__PURE__ */ t("div", { className: "relative flex justify-start", children: /* @__PURE__ */ t("span", { className: "bg-gray-50 pr-2", children: e.label }) })
151
152
  ] }) }, "separator") : /* @__PURE__ */ t(
152
- pe,
153
+ fe,
153
154
  {
154
155
  page: e,
155
156
  selectedPages: r,
156
- handleCheckboxChange: O,
157
- getPageType: M,
157
+ handleCheckboxChange: H,
158
+ getPageType: R,
158
159
  hasSlug: T,
159
- currentOwnerId: F(h, [(e == null ? void 0 : e.primaryPage) || (e == null ? void 0 : e.id), "userId"])
160
+ currentOwnerId: F(m, [(e == null ? void 0 : e.primaryPage) || (e == null ? void 0 : e.id), "userId"])
160
161
  }
161
162
  )
162
163
  ) })
163
164
  ] }) }),
164
- /* @__PURE__ */ n(V, { className: "mt-10 flex items-center justify-center", children: [
165
+ /* @__PURE__ */ n(W, { className: "mt-10 flex items-center justify-center", children: [
165
166
  r.length > 0 && /* @__PURE__ */ n("span", { className: "text-center text-sm text-muted-foreground", children: [
166
167
  r.length,
167
168
  " Page",
@@ -169,10 +170,10 @@ const ge = () => {
169
170
  " Selected"
170
171
  ] }),
171
172
  /* @__PURE__ */ t(L, { disabled: d, variant: "outline", onClick: s, children: "Cancel" }),
172
- /* @__PURE__ */ t(L, { disabled: d || v || re(r), onClick: z, children: d ? "Publishing..." : "Publish Selected" })
173
+ /* @__PURE__ */ t(L, { disabled: d || v || oe(r), onClick: M, children: d ? "Publishing..." : "Publish Selected" })
173
174
  ] })
174
175
  ] });
175
176
  };
176
177
  export {
177
- Pe as default
178
+ ve as default
178
179
  };
@@ -0,0 +1 @@
1
+ "use strict";const i=require("lodash-es"),n=require("react"),B=require("jotai"),P=require("jotai/utils"),s=require("react/jsx-runtime"),L=require("class-variance-authority"),D=require("clsx"),q=require("tailwind-merge"),H=require("@radix-ui/react-slot"),V=require("@radix-ui/react-icons"),U=require("react-i18next");function $(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const u=$(n);function o(...e){return q.twMerge(D.clsx(e))}const d={},z=(e,t)=>{d[e]={id:e,component:t,type:"widget"}},G=(e,t)=>{d[e]={id:e,component:t,type:"field"}},W=(e,t)=>{d[e]={id:e,component:t,type:"template"}},J=e=>Object.values(d).filter(t=>t.type===e).reduce((t,r)=>(t[r.id]=r.component,t),{}),p={},K=(e,t)=>{i.has(p,e)&&console.warn(`Add block tab with id ${e} already registered`),i.set(p,e,{id:e,...t})},X=()=>n.useMemo(()=>i.values(p),[]),m={},M=(e,t)=>{if(m[e])throw new Error(`Flag ${e} already exists`);m[e]={key:e,value:!1,...t}},Y=e=>{Object.entries(e).forEach(([t,r])=>{if(m[t])throw new Error(`Flag ${t} already exists`);M(t,r)})},Q=()=>m,_=P.atomWithStorage("chai-feature-flags",[]),j=e=>{const[t]=B.useAtom(_);return t.includes(e)},Z=e=>{const[t,r]=B.useAtom(_);return()=>{t.includes(e)?r(t.filter(l=>l!==e)):r([...t,e])}},ee=({flagKey:e,children:t})=>j(e)?t:null;let y={};const te=(e,t)=>{y[e]={...t,id:e}},re=e=>y[e],se=()=>i.values(y),ae=L.cva("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),S=u.forwardRef(({className:e,variant:t,...r},a)=>s.jsx("div",{ref:a,role:"alert",className:o(ae({variant:t}),e),...r}));S.displayName="Alert";const ne=u.forwardRef(({className:e,...t},r)=>s.jsx("h5",{ref:r,className:o("mb-1 font-medium leading-none tracking-tight",e),...t}));ne.displayName="AlertTitle";const T=u.forwardRef(({className:e,...t},r)=>s.jsx("div",{ref:r,className:o("text-sm [&_p]:leading-relaxed",e),...t}));T.displayName="AlertDescription";const E=L.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),v=u.forwardRef(({className:e,variant:t,size:r,asChild:a=!1,...l},b)=>{const g=a?H.Slot:"button";return s.jsx(g,{className:o(E({variant:t,size:r,className:e})),ref:b,...l})});v.displayName="Button";const A=u.forwardRef(({className:e,type:t,...r},a)=>s.jsx("input",{type:t,className:o("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:a,...r}));A.displayName="Input";const ie=({close:e,onSelect:t,mode:r="image"})=>{const[a,l]=n.useState(""),[b,g]=n.useState(!1),[k,x]=n.useState(!1),[w,f]=n.useState(null),O=async C=>{if(!C.trim()){x(!1),f("Please enter a URL");return}try{g(!0),f(null),x(!0),f(null)}catch{x(!1),f("Error validating URL")}finally{g(!1)}},{t:h}=U.useTranslation();return s.jsxs("div",{className:"flex w-96 flex-col gap-4 p-4",children:[s.jsx("h2",{className:"text-xl font-semibold",children:h(`${r.charAt(0).toUpperCase()+r.slice(1)} Manager`)}),w&&s.jsxs(S,{variant:"destructive",children:[s.jsx(V.ExclamationTriangleIcon,{className:"h-4 w-4"}),s.jsx(T,{children:w})]}),s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsx(A,{placeholder:h(`Enter ${r} URL`),value:a,onChange:C=>l(C.target.value),onKeyUp:()=>O(a)}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(v,{variant:"outline",onClick:e,children:h("Cancel")}),s.jsx(v,{onClick:()=>t({id:"dam-id",url:a,width:600,height:400,description:"This is image description"}),disabled:!k||b,children:h("Insert")})]})]})]})},I={component:ie},oe=e=>{I.component=e},le=()=>n.useMemo(()=>I.component,[]);let N=async e=>e;const ce=e=>{N=e},ue=async e=>await N(e);let F=null;const de=e=>{F=e},ge=()=>n.useMemo(()=>F,[]),fe=()=>{F=null},c={},he=(e,t)=>{i.has(c,e)&&console.warn(`Panel ${e} already registered. Overriding...`),i.set(c,e,{id:e,...t})},pe=e=>n.useMemo(()=>i.filter(i.values(c),t=>t.position===e),[e,c]),me=()=>s.jsx("div",{}),R={component:me},ve=e=>{R.component=e},be=()=>n.useMemo(()=>R.component,[]);exports.ADD_BLOCK_TABS=p;exports.Alert=S;exports.AlertDescription=T;exports.Button=v;exports.CHAI_BUILDER_PANELS=c;exports.IfChaiFeatureFlag=ee;exports.Input=A;exports.RJSF_EXTENSIONS=d;exports.buttonVariants=E;exports.cn=o;exports.getChaiLibrary=re;exports.getPreImportHTML=ue;exports.registerBlockSettingField=G;exports.registerBlockSettingTemplate=W;exports.registerBlockSettingWidget=z;exports.registerChaiAddBlockTab=K;exports.registerChaiFeatureFlag=M;exports.registerChaiFeatureFlags=Y;exports.registerChaiLibrary=te;exports.registerChaiMediaManager=oe;exports.registerChaiPreImportHTMLHook=ce;exports.registerChaiSaveToLibrary=de;exports.registerChaiSidebarPanel=he;exports.registerChaiTopBar=ve;exports.resetSaveToLibrary=fe;exports.useBlockSettingComponents=J;exports.useChaiAddBlockTabs=X;exports.useChaiFeatureFlag=j;exports.useChaiFeatureFlags=Q;exports.useChaiLibraries=se;exports.useChaiSidebarPanels=pe;exports.useMediaManagerComponent=le;exports.useSaveToLibraryComponent=ge;exports.useToggleChaiFeatureFlag=Z;exports.useTopBarComponent=be;