@chaibuilder/pages 0.14.4 → 0.15.1

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 (69) hide show
  1. package/dist/{2AITGKQY-DWDDkd18.cjs → 2AITGKQY-GcbF_G3s.cjs} +1 -1
  2. package/dist/{2AITGKQY-DtQPkxBe.js → 2AITGKQY-a-BJOrVj.js} +2 -2
  3. package/dist/{NCMVHL6D-CksZXXOw.js → NCMVHL6D-CCFQEIik.js} +4 -4
  4. package/dist/{NCMVHL6D-6CkVnw0a.cjs → NCMVHL6D-fz7uxKMS.cjs} +1 -1
  5. package/dist/{ZDWCUMSJ-BXQ01VPt.js → ZDWCUMSJ-B87y4E-s.js} +1 -1
  6. package/dist/{ZDWCUMSJ-DoM-AA0C.cjs → ZDWCUMSJ-D40Aht5l.cjs} +1 -1
  7. package/dist/{add-new-language-page-D8iXtyLA.js → add-new-language-page-CxNpkd0L.js} +2 -2
  8. package/dist/{add-new-language-page-BA73lQnm.cjs → add-new-language-page-Dyh26P7i.cjs} +1 -1
  9. package/dist/{add-new-page-DESlqvED.js → add-new-page-DGQqN1GO.js} +1 -1
  10. package/dist/{add-new-page-EOMgMSeq.cjs → add-new-page-jWn3_pZ4.cjs} +1 -1
  11. package/dist/{delete-page-ZvnuEow6.cjs → delete-page-Bxl1t_Ue.cjs} +1 -1
  12. package/dist/{delete-page-BP1Df8QL.js → delete-page-WnsCggnJ.js} +1 -1
  13. package/dist/{digital-asset-manager-Bb81T3mS.js → digital-asset-manager-ClyooOJY.js} +135 -135
  14. package/dist/{digital-asset-manager-BxWb1j_y.cjs → digital-asset-manager-DrXotZ_n.cjs} +1 -1
  15. package/dist/{duplicate-page-W5xbmPSC.cjs → duplicate-page-CDtfdgyJ.cjs} +1 -1
  16. package/dist/{duplicate-page-B1j0H7gP.js → duplicate-page-DOloolXy.js} +8 -8
  17. package/dist/{dynamic-page-selector-Crjyco6l.js → dynamic-page-selector-B-8TUdTG.js} +1 -1
  18. package/dist/{dynamic-page-selector-BZKJmSx5.cjs → dynamic-page-selector-CcYIfKlO.cjs} +1 -1
  19. package/dist/index-CffopOpP.cjs +5 -0
  20. package/dist/{index-DFvsMFVH.js → index-CguzNa4U.js} +1710 -1938
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.d.ts +10 -14
  23. package/dist/index.js +12 -13
  24. package/dist/{json-diff-viewer-BGGSLqtx.js → json-diff-viewer-CxFGgqa_.js} +6 -6
  25. package/dist/{json-diff-viewer-DRkE-x_z.cjs → json-diff-viewer-DcR1gbkd.cjs} +1 -1
  26. package/dist/{lang-panel-B3tr2uhr.js → lang-panel-Bi427DLp.js} +2 -2
  27. package/dist/{lang-panel-9T8dIx2p.cjs → lang-panel-XonHaLBn.cjs} +1 -1
  28. package/dist/{mark-as-template-DPVPRgbi.cjs → mark-as-template-BtI1QfuI.cjs} +1 -1
  29. package/dist/{mark-as-template-L9cHzL84.js → mark-as-template-CS68JVP8.js} +1 -1
  30. package/dist/{no-language-page-content-DP7gmy0s.js → no-language-page-content-C5t9cDI4.js} +1 -1
  31. package/dist/{no-language-page-content-Cy_D-3jE.cjs → no-language-page-content-DMqw1cTK.cjs} +1 -1
  32. package/dist/{page-creator-Ctn5ixJE.js → page-creator-BY2w99Ez.js} +2 -2
  33. package/dist/{page-creator-DDaI1HYj.cjs → page-creator-BkKT_Xy1.cjs} +1 -1
  34. package/dist/{page-lock-request-BKrxnEtQ.cjs → page-lock-request-CIRTswpw.cjs} +1 -1
  35. package/dist/{page-lock-request-CjJFJKL2.js → page-lock-request-Z1sTGi6N.js} +10 -10
  36. package/dist/{page-locked-by-dialog-DmsSmAY2.js → page-locked-by-dialog-B2C1M_bK.js} +1 -1
  37. package/dist/{page-locked-by-dialog-b25_rn2m.cjs → page-locked-by-dialog-DpBpQ0oI.cjs} +1 -1
  38. package/dist/{page-manager-new-EsIg6iQn.js → page-manager-new-CSqFLJBd.js} +46 -46
  39. package/dist/{page-manager-new-DiZVY7Me.cjs → page-manager-new-tWV46glN.cjs} +1 -1
  40. package/dist/{page-manager-search-and-filter-Bt4T_dnB.js → page-manager-search-and-filter-B9VZzJQd.js} +2 -2
  41. package/dist/{page-manager-search-and-filter-CgY2qiXU.cjs → page-manager-search-and-filter-CwuukvKn.cjs} +1 -1
  42. package/dist/{page-revisions-content-DtI8CmtR.cjs → page-revisions-content-BWhJz0_7.cjs} +1 -1
  43. package/dist/{page-revisions-content-CsT6aF2I.js → page-revisions-content-WoIu0uan.js} +18 -18
  44. package/dist/{publish-pages-content-DpC7RcTw.cjs → publish-pages-content-BHDTLdGv.cjs} +1 -1
  45. package/dist/{publish-pages-content-KAuhOPv0.js → publish-pages-content-CkWvQGbm.js} +12 -12
  46. package/dist/{save-to-lib-CeWaSQdB.js → save-to-lib-AkbnWUxR.js} +13 -13
  47. package/dist/{save-to-lib-BGpWGHJo.cjs → save-to-lib-C0ZfwiAE.cjs} +1 -1
  48. package/dist/{seo-panel-JDQ_7bOx.cjs → seo-panel-CiKkn5Jp.cjs} +1 -1
  49. package/dist/{seo-panel-Dhhpe_7z.js → seo-panel-Gu3HZveQ.js} +34 -34
  50. package/dist/shared-json-ld-BPaeG1gf.cjs +1 -0
  51. package/dist/shared-json-ld-CsyZjZdT.js +557 -0
  52. package/dist/{slug-input-QxBMijHP.cjs → slug-input-B4w0Ihxn.cjs} +1 -1
  53. package/dist/{slug-input-hJdU8DaF.js → slug-input-BXNj3cZf.js} +1 -1
  54. package/dist/{theme-panel-footer-D2B7iYW2.js → theme-panel-footer-68bQaQeh.js} +1 -1
  55. package/dist/{theme-panel-footer-BZnPvTkM.cjs → theme-panel-footer-DnZs9SzB.cjs} +1 -1
  56. package/dist/{unmark-as-template-Byn2RRAp.cjs → unmark-as-template-DFxmzyx4.cjs} +1 -1
  57. package/dist/{unmark-as-template-Dcpkj7EZ.js → unmark-as-template-MpXMyb0Q.js} +1 -1
  58. package/dist/{unpublish-page-CPLlsfm4.js → unpublish-page-Bzouoco9.js} +1 -1
  59. package/dist/{unpublish-page-5Fi1wKXb.cjs → unpublish-page-CCPyMoaC.cjs} +1 -1
  60. package/dist/use-page-expand-manager-2KjeYfVS.cjs +1 -0
  61. package/dist/use-page-expand-manager-D6T75I11.js +184 -0
  62. package/dist/{web-preview-CVvxe5Ll.cjs → web-preview-B3-o8BoT.cjs} +1 -1
  63. package/dist/{web-preview-YuuoRaZn.js → web-preview-D9PcexXy.js} +1 -1
  64. package/package.json +1 -1
  65. package/dist/index-Qnh8Lkr0.cjs +0 -5
  66. package/dist/shared-json-ld-BYbdMttx.cjs +0 -1
  67. package/dist/shared-json-ld-BliIbNv9.js +0 -337
  68. package/dist/use-page-expand-manager-DkyBiNpx.js +0 -85
  69. package/dist/use-page-expand-manager-To-SsGy3.cjs +0 -1
@@ -0,0 +1,557 @@
1
+ import { jsx as e, jsxs as a, Fragment as $ } from "react/jsx-runtime";
2
+ import { useLanguages as oe } from "@chaibuilder/sdk";
3
+ import { useQuery as re } from "@tanstack/react-query";
4
+ import { al as me, am as he, A as Q, aq as X, av as ue, aw as Y, ax as k, ay as pe, az as ge, aA as fe, g as xe, aB as ve } from "./index-CguzNa4U.js";
5
+ import { Dialog as Z, DialogContent as ee, DialogHeader as ae, DialogTitle as ne, Label as N, Input as I, Tabs as te, TabsList as le, TabsTrigger as j, Button as v, TabsContent as B, Textarea as O, Switch as G, AlertDialog as R, AlertDialogContent as U, AlertDialogHeader as V, AlertDialogTitle as _, AlertDialogDescription as M, AlertDialogFooter as q, AlertDialogCancel as H, AlertDialogAction as K, Tooltip as Ne, TooltipTrigger as be, TooltipContent as ye, ScrollArea as we, Card as Se, CardHeader as Ae, CardTitle as Ce, AlertDialogTrigger as De, CardContent as Te } from "@chaibuilder/sdk/ui";
6
+ import { Code as se, Eye as ie, Loader as P, Plus as Le, Edit as Je, Trash as Pe } from "lucide-react";
7
+ import { useState as h, useEffect as F, useMemo as W } from "react";
8
+ import { toast as z } from "sonner";
9
+ const de = () => {
10
+ const i = me(), o = he();
11
+ return re({
12
+ queryKey: [Q.GET_GLOBAL_JSONLD_ITEMS],
13
+ queryFn: async () => o(i, { action: Q.GET_GLOBAL_JSONLD_ITEMS })
14
+ });
15
+ }, Oe = ({
16
+ show: i,
17
+ onClose: o,
18
+ initialData: r
19
+ }) => /* @__PURE__ */ e(Z, { open: i, onOpenChange: () => o(), children: i && /* @__PURE__ */ e(Fe, { show: i, onClose: o, initialData: r }) }), Fe = ({
20
+ show: i,
21
+ onClose: o,
22
+ initialData: r
23
+ }) => {
24
+ const [b, u] = h("edit"), [p, l] = h(""), [t, m] = h({
25
+ name: "",
26
+ content: "",
27
+ description: "",
28
+ enabledByDefaultForNewPages: !1
29
+ }), [g, y] = h(!1), { data: s } = X(), { mutateAsync: f, isPending: S } = ue(), { mutateAsync: A } = Y();
30
+ F(() => {
31
+ u("edit"), m(r ? {
32
+ name: r.name,
33
+ description: r.description,
34
+ content: JSON.stringify(r.jsonld, null, 2),
35
+ enabledByDefaultForNewPages: !1
36
+ } : { name: "", description: "", content: "", enabledByDefaultForNewPages: !1 }), y(!1);
37
+ }, [i, r]), F(() => {
38
+ const d = k(t.content);
39
+ l(d.isValid ? JSON.stringify(d.parsed, null, 2) : "");
40
+ }, [t.content]);
41
+ const w = async () => {
42
+ if (!t.name || !t.content) {
43
+ z.error("Please enter a name and content");
44
+ return;
45
+ }
46
+ const d = k(t.content);
47
+ if (!d.isValid) {
48
+ z.error("Invalid JSON-LD content");
49
+ return;
50
+ }
51
+ const C = {
52
+ name: t.name,
53
+ jsonld: d.parsed,
54
+ addToExistingPages: g,
55
+ addToNewPages: t.enabledByDefaultForNewPages,
56
+ description: t.description
57
+ }, x = await f(C);
58
+ s != null && s.id && (x != null && x.id) && await A({
59
+ schemaId: x.id,
60
+ pageId: s.id,
61
+ enabled: !0
62
+ }), o();
63
+ };
64
+ return /* @__PURE__ */ a(ee, { className: "flex max-w-xl flex-col overflow-y-auto", children: [
65
+ /* @__PURE__ */ e(ae, { children: /* @__PURE__ */ a(ne, { children: [
66
+ "Add New Shared JSON-LD Schema",
67
+ (r == null ? void 0 : r.languageCode) && /* @__PURE__ */ a("span", { className: "ml-2 text-sm font-normal text-muted-foreground", children: [
68
+ "(",
69
+ r.languageCode,
70
+ ")"
71
+ ] })
72
+ ] }) }),
73
+ /* @__PURE__ */ a("div", { className: "flex max-h-[75vh] flex-col space-y-2 overflow-y-auto", children: [
74
+ /* @__PURE__ */ a("div", { children: [
75
+ /* @__PURE__ */ e(N, { htmlFor: "new-name", children: "Schema Name" }),
76
+ /* @__PURE__ */ e(
77
+ I,
78
+ {
79
+ id: "new-name",
80
+ value: t.name,
81
+ onChange: (d) => m({ ...t, name: d.target.value }),
82
+ placeholder: "e.g., Product Schema",
83
+ className: "text-xs"
84
+ }
85
+ )
86
+ ] }),
87
+ /* @__PURE__ */ a("div", { children: [
88
+ /* @__PURE__ */ e(N, { htmlFor: "new-description", children: "Description" }),
89
+ /* @__PURE__ */ e(
90
+ I,
91
+ {
92
+ id: "new-description",
93
+ value: t.description || "",
94
+ onChange: (d) => m({ ...t, description: d.target.value }),
95
+ placeholder: "Brief description of this schema"
96
+ }
97
+ )
98
+ ] }),
99
+ /* @__PURE__ */ a("div", { children: [
100
+ /* @__PURE__ */ e(N, { htmlFor: "new-content", children: "JSON-LD Content" }),
101
+ /* @__PURE__ */ a(te, { value: b, onValueChange: u, className: "w-full", children: [
102
+ /* @__PURE__ */ a("div", { className: "mb-2 flex w-full items-center justify-between", children: [
103
+ /* @__PURE__ */ a(le, { className: "w-max", children: [
104
+ /* @__PURE__ */ a(j, { value: "edit", className: "flex items-center gap-1", children: [
105
+ /* @__PURE__ */ e(se, { className: "h-4 w-4" }),
106
+ /* @__PURE__ */ e("span", { children: "Edit" })
107
+ ] }),
108
+ /* @__PURE__ */ a(j, { value: "preview", className: "flex items-center gap-1", disabled: !p, children: [
109
+ /* @__PURE__ */ e(ie, { className: "h-4 w-4" }),
110
+ /* @__PURE__ */ e("span", { children: "Preview" })
111
+ ] })
112
+ ] }),
113
+ /* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: b === "edit" && /* @__PURE__ */ e(
114
+ v,
115
+ {
116
+ type: "button",
117
+ variant: "outline",
118
+ size: "sm",
119
+ onClick: () => m({ ...t, content: p }),
120
+ disabled: !p,
121
+ children: "Format"
122
+ }
123
+ ) })
124
+ ] }),
125
+ /* @__PURE__ */ a(B, { value: "edit", children: [
126
+ /* @__PURE__ */ e(
127
+ O,
128
+ {
129
+ id: "new-content",
130
+ value: t.content || "{}",
131
+ onChange: (d) => m({ ...t, content: d.target.value }),
132
+ className: "font-mono text-sm",
133
+ placeholder: "Enter JSON-LD markup...",
134
+ rows: 10
135
+ }
136
+ ),
137
+ !p && t.content ? /* @__PURE__ */ e("p", { className: "pt-px text-xs text-red-500", children: "Invalid JSON-LD" }) : /* @__PURE__ */ e("p", {})
138
+ ] }),
139
+ /* @__PURE__ */ e(B, { value: "preview", children: /* @__PURE__ */ e(
140
+ O,
141
+ {
142
+ id: "new-content",
143
+ value: p || "{}",
144
+ className: "bg-muted font-mono text-sm",
145
+ placeholder: "{}",
146
+ rows: 10,
147
+ readOnly: !0
148
+ }
149
+ ) })
150
+ ] })
151
+ ] }),
152
+ !r && /* @__PURE__ */ a("div", { className: "flex flex-col gap-3 pt-2", children: [
153
+ /* @__PURE__ */ a("div", { className: "flex items-center space-x-2", children: [
154
+ /* @__PURE__ */ e(
155
+ G,
156
+ {
157
+ id: "add-to-all-existing",
158
+ checked: g,
159
+ onCheckedChange: (d) => y(d)
160
+ }
161
+ ),
162
+ /* @__PURE__ */ a(N, { htmlFor: "add-to-all-existing", children: [
163
+ /* @__PURE__ */ e("div", { children: "Add to all existing pages" }),
164
+ /* @__PURE__ */ e("div", { className: "text-xs font-light text-muted-foreground", children: "This schema will be added to all existing pages on your site" })
165
+ ] })
166
+ ] }),
167
+ /* @__PURE__ */ a("div", { className: "flex items-center space-x-2", children: [
168
+ /* @__PURE__ */ e(
169
+ G,
170
+ {
171
+ id: "new-enabled",
172
+ checked: t.enabledByDefaultForNewPages,
173
+ onCheckedChange: (d) => m({ ...t, enabledByDefaultForNewPages: d })
174
+ }
175
+ ),
176
+ /* @__PURE__ */ a(N, { htmlFor: "new-enabled", children: [
177
+ /* @__PURE__ */ e("div", { children: "Enabled by default for new pages" }),
178
+ /* @__PURE__ */ e("div", { className: "text-xs font-light text-muted-foreground", children: "New pages will automatically include this schema" })
179
+ ] })
180
+ ] })
181
+ ] }),
182
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-between pt-2", children: [
183
+ /* @__PURE__ */ e("div", {}),
184
+ /* @__PURE__ */ a("div", { className: "flex gap-2", children: [
185
+ /* @__PURE__ */ e(v, { disabled: S, variant: "outline", type: "button", size: "sm", onClick: () => o(), children: "Cancel" }),
186
+ /* @__PURE__ */ e(v, { disabled: S || !p, type: "button", size: "sm", onClick: w, children: S ? /* @__PURE__ */ a($, { children: [
187
+ /* @__PURE__ */ e(P, { className: "h-4 w-4 animate-spin" }),
188
+ " Adding"
189
+ ] }) : "Add Schema" })
190
+ ] })
191
+ ] })
192
+ ] })
193
+ ] });
194
+ }, Ee = ({ id: i, onClose: o }) => /* @__PURE__ */ e(Z, { open: !!i, onOpenChange: () => o(), children: i && /* @__PURE__ */ e(ke, { id: i, onClose: o }) }), ke = ({ id: i, onClose: o }) => {
195
+ const [r, b] = h("edit"), [u, p] = h(""), [l, t] = h({
196
+ name: "",
197
+ content: "",
198
+ description: "",
199
+ enabledByDefaultForNewPages: !1
200
+ }), [m, g] = h(!1), [y, s] = h(!1), { data: f } = de(), { mutateAsync: S, isPending: A } = pe(), { mutateAsync: w } = ge(), { mutateAsync: d } = fe();
201
+ F(() => {
202
+ var c, T;
203
+ if (b("edit"), i && f) {
204
+ const n = f.find((L) => L.id === i);
205
+ n && t({
206
+ name: n.name,
207
+ description: ((c = n.metadata) == null ? void 0 : c.description) || "",
208
+ content: JSON.stringify(n.jsonld, null, 2),
209
+ enabledByDefaultForNewPages: ((T = n.metadata) == null ? void 0 : T.addToNewPages) || !1
210
+ });
211
+ }
212
+ }, [i, f]), F(() => {
213
+ const c = k(l.content);
214
+ p(c.isValid ? JSON.stringify(c.parsed, null, 2) : "");
215
+ }, [l.content]);
216
+ const C = async () => {
217
+ if (!l.name || !l.content) {
218
+ z.error("Please enter a name and content");
219
+ return;
220
+ }
221
+ const c = k(l.content);
222
+ if (!c.isValid) {
223
+ z.error("Invalid JSON-LD content");
224
+ return;
225
+ }
226
+ const T = {
227
+ id: i,
228
+ name: l.name,
229
+ jsonld: c.parsed,
230
+ addToNewPages: l.enabledByDefaultForNewPages,
231
+ description: l.description
232
+ };
233
+ await S(T), o();
234
+ }, x = async () => {
235
+ try {
236
+ await w(i);
237
+ } finally {
238
+ g(!1);
239
+ }
240
+ }, D = async () => {
241
+ try {
242
+ await d(i);
243
+ } finally {
244
+ s(!1);
245
+ }
246
+ };
247
+ return /* @__PURE__ */ a(ee, { className: "flex max-w-xl flex-col overflow-y-auto", children: [
248
+ /* @__PURE__ */ e(ae, { children: /* @__PURE__ */ e(ne, { children: "Edit Shared JSON-LD Schema" }) }),
249
+ /* @__PURE__ */ a("div", { className: "flex max-h-[75vh] flex-col space-y-2 overflow-y-auto", children: [
250
+ /* @__PURE__ */ a("div", { children: [
251
+ /* @__PURE__ */ e(N, { htmlFor: "edit-name", children: "Schema Name" }),
252
+ /* @__PURE__ */ e(
253
+ I,
254
+ {
255
+ id: "edit-name",
256
+ value: l.name,
257
+ onChange: (c) => t({ ...l, name: c.target.value }),
258
+ placeholder: "e.g., Product Schema",
259
+ className: "text-xs"
260
+ }
261
+ )
262
+ ] }),
263
+ /* @__PURE__ */ a("div", { children: [
264
+ /* @__PURE__ */ e(N, { htmlFor: "edit-description", children: "Description" }),
265
+ /* @__PURE__ */ e(
266
+ I,
267
+ {
268
+ id: "edit-description",
269
+ value: l.description || "",
270
+ onChange: (c) => t({ ...l, description: c.target.value }),
271
+ placeholder: "Brief description of this schema"
272
+ }
273
+ )
274
+ ] }),
275
+ /* @__PURE__ */ a("div", { children: [
276
+ /* @__PURE__ */ e(N, { htmlFor: "edit-content", children: "JSON-LD Content" }),
277
+ /* @__PURE__ */ a(te, { value: r, onValueChange: b, className: "w-full", children: [
278
+ /* @__PURE__ */ a("div", { className: "mb-2 flex w-full items-center justify-between", children: [
279
+ /* @__PURE__ */ a(le, { className: "w-max", children: [
280
+ /* @__PURE__ */ a(j, { value: "edit", className: "flex items-center gap-1", children: [
281
+ /* @__PURE__ */ e(se, { className: "h-4 w-4" }),
282
+ /* @__PURE__ */ e("span", { children: "Edit" })
283
+ ] }),
284
+ /* @__PURE__ */ a(j, { value: "preview", className: "flex items-center gap-1", disabled: !u, children: [
285
+ /* @__PURE__ */ e(ie, { className: "h-4 w-4" }),
286
+ /* @__PURE__ */ e("span", { children: "Preview" })
287
+ ] })
288
+ ] }),
289
+ /* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: r === "edit" && /* @__PURE__ */ e(
290
+ v,
291
+ {
292
+ type: "button",
293
+ variant: "outline",
294
+ size: "sm",
295
+ onClick: () => t({ ...l, content: u }),
296
+ disabled: !u,
297
+ children: "Format"
298
+ }
299
+ ) })
300
+ ] }),
301
+ /* @__PURE__ */ a(B, { value: "edit", children: [
302
+ /* @__PURE__ */ e(
303
+ O,
304
+ {
305
+ id: "edit-content",
306
+ value: l.content || "{}",
307
+ onChange: (c) => t({ ...l, content: c.target.value }),
308
+ className: "font-mono text-sm",
309
+ placeholder: "Enter JSON-LD markup...",
310
+ rows: 10
311
+ }
312
+ ),
313
+ !u && l.content ? /* @__PURE__ */ e("p", { className: "pt-px text-xs text-red-500", children: "Invalid JSON-LD" }) : /* @__PURE__ */ e("p", {})
314
+ ] }),
315
+ /* @__PURE__ */ e(B, { value: "preview", children: /* @__PURE__ */ e(
316
+ O,
317
+ {
318
+ id: "edit-content-preview",
319
+ value: u || "{}",
320
+ className: "bg-muted font-mono text-sm",
321
+ placeholder: "{}",
322
+ rows: 10,
323
+ readOnly: !0
324
+ }
325
+ ) })
326
+ ] })
327
+ ] }),
328
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-between rounded-lg border border-blue-300 bg-blue-500/10 p-2", children: [
329
+ /* @__PURE__ */ a("div", { children: [
330
+ /* @__PURE__ */ e("div", { className: "text-sm font-medium text-blue-900", children: "Manage Existing Pages" }),
331
+ /* @__PURE__ */ e("div", { className: "text-xs text-blue-700", children: "Add or remove this schema from all existing pages on your site" })
332
+ ] }),
333
+ /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
334
+ /* @__PURE__ */ e(v, { size: "sm", variant: "outline", onClick: () => g(!0), children: "Add to all existing" }),
335
+ /* @__PURE__ */ e(v, { size: "sm", variant: "ghost", onClick: () => s(!0), children: "Remove from all" })
336
+ ] })
337
+ ] }),
338
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-between pt-2", children: [
339
+ /* @__PURE__ */ a("div", { className: "flex items-center space-x-2", children: [
340
+ /* @__PURE__ */ e(
341
+ G,
342
+ {
343
+ id: "edit-enabled",
344
+ checked: l.enabledByDefaultForNewPages,
345
+ onCheckedChange: (c) => t({ ...l, enabledByDefaultForNewPages: c })
346
+ }
347
+ ),
348
+ /* @__PURE__ */ a(N, { htmlFor: "edit-enabled", children: [
349
+ /* @__PURE__ */ e("div", { children: "Enabled by default for new pages" }),
350
+ /* @__PURE__ */ e("div", { className: "text-xs font-light text-muted-foreground", children: "New pages will automatically include this schema" })
351
+ ] })
352
+ ] }),
353
+ /* @__PURE__ */ a("div", { className: "flex gap-2", children: [
354
+ /* @__PURE__ */ e(v, { disabled: A, variant: "outline", type: "button", size: "sm", onClick: () => o(), children: "Cancel" }),
355
+ /* @__PURE__ */ e(v, { disabled: A || !u, type: "button", size: "sm", onClick: C, children: A ? /* @__PURE__ */ a($, { children: [
356
+ /* @__PURE__ */ e(P, { className: "h-4 w-4 animate-spin" }),
357
+ " Updating"
358
+ ] }) : "Update Schema" })
359
+ ] })
360
+ ] })
361
+ ] }),
362
+ /* @__PURE__ */ e(R, { open: m, onOpenChange: g, children: /* @__PURE__ */ a(U, { children: [
363
+ /* @__PURE__ */ a(V, { children: [
364
+ /* @__PURE__ */ e(_, { children: "Add to All Existing Pages?" }),
365
+ /* @__PURE__ */ a(M, { children: [
366
+ "This will add the schema ",
367
+ /* @__PURE__ */ e("span", { className: "font-medium", children: l.name }),
368
+ " to all existing pages on your site. This action cannot be undone automatically."
369
+ ] })
370
+ ] }),
371
+ /* @__PURE__ */ a(q, { children: [
372
+ /* @__PURE__ */ e(H, { children: "Cancel" }),
373
+ /* @__PURE__ */ e(K, { onClick: x, children: "Add to All" })
374
+ ] })
375
+ ] }) }),
376
+ /* @__PURE__ */ e(R, { open: y, onOpenChange: s, children: /* @__PURE__ */ a(U, { children: [
377
+ /* @__PURE__ */ a(V, { children: [
378
+ /* @__PURE__ */ e(_, { children: "Remove from All Pages?" }),
379
+ /* @__PURE__ */ a(M, { children: [
380
+ "This will remove the schema ",
381
+ /* @__PURE__ */ e("span", { className: "font-medium", children: l.name }),
382
+ " from all existing pages on your site. This action cannot be undone automatically."
383
+ ] })
384
+ ] }),
385
+ /* @__PURE__ */ a(q, { children: [
386
+ /* @__PURE__ */ e(H, { children: "Cancel" }),
387
+ /* @__PURE__ */ e(K, { onClick: D, className: "bg-red-500 hover:bg-red-600", children: "Remove from All" })
388
+ ] })
389
+ ] }) })
390
+ ] });
391
+ };
392
+ function _e() {
393
+ const [i, o] = h(!1), [r, b] = h(void 0), [u, p] = h(null), [l, t] = h(null), { data: m, isLoading: g } = de(), { selectedLang: y } = oe(), { data: s } = X(), { data: f } = xe(), { mutateAsync: S } = ve(), { mutateAsync: A } = Y(), w = W(() => f == null ? void 0 : f.find((n) => n.primaryPage === !0), [f]), d = W(() => (w == null ? void 0 : w.globalJsonLds) || [], [w]), [C, x] = h([]), D = C.length > 0 ? C : (s == null ? void 0 : s.globalJsonLds) || [];
394
+ F(() => {
395
+ s != null && s.globalJsonLds && x(s.globalJsonLds);
396
+ }, [s == null ? void 0 : s.globalJsonLds]);
397
+ const c = async (n) => {
398
+ if (!(s != null && s.id)) return;
399
+ t(n);
400
+ const L = D.includes(n), J = L ? D.filter((E) => E !== n) : [...D, n];
401
+ x(J);
402
+ try {
403
+ await A({
404
+ schemaId: n,
405
+ pageId: s.id,
406
+ enabled: !L
407
+ });
408
+ } catch {
409
+ x(s.globalJsonLds);
410
+ } finally {
411
+ t(null);
412
+ }
413
+ }, T = async (n) => {
414
+ t(n);
415
+ try {
416
+ await S(n);
417
+ } finally {
418
+ t(null);
419
+ }
420
+ };
421
+ return /* @__PURE__ */ a("div", { className: "rounded border bg-muted p-2", children: [
422
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-between pb-2", children: [
423
+ /* @__PURE__ */ a("div", { children: [
424
+ /* @__PURE__ */ e("div", { className: "text-xs font-medium", children: "Shared JSON-LD Templates" }),
425
+ /* @__PURE__ */ e("div", { className: "w-full text-xs text-gray-500", children: "Manage reusable JSON-LD schemas that can be applied across multiple pages" })
426
+ ] }),
427
+ !y && /* @__PURE__ */ a(Ne, { delayDuration: 0, children: [
428
+ /* @__PURE__ */ e(
429
+ be,
430
+ {
431
+ type: "button",
432
+ disabled: g,
433
+ className: "rounded-full bg-primary p-1 text-primary-foreground hover:bg-primary/80",
434
+ onClick: (n) => {
435
+ n.stopPropagation(), o(!0);
436
+ },
437
+ children: g ? /* @__PURE__ */ e(P, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ e(Le, { className: "h-4 w-4" })
438
+ }
439
+ ),
440
+ /* @__PURE__ */ e(ye, { children: "Add new schema" })
441
+ ] })
442
+ ] }),
443
+ /* @__PURE__ */ a(we, { className: "max-h-96 overflow-y-auto", children: [
444
+ /* @__PURE__ */ a("div", { className: "space-y-2", children: [
445
+ (!m || (m == null ? void 0 : m.length) === 0) && !g && /* @__PURE__ */ e("div", { className: "flex items-center justify-center px-2 py-4 text-xs", children: "No shared JSON-LD found" }),
446
+ m == null ? void 0 : m.map((n) => {
447
+ const L = n.jsonld, J = !y, E = D.includes(n.id), ce = d.includes(n.id);
448
+ return /* @__PURE__ */ a(
449
+ Se,
450
+ {
451
+ className: `relative border-gray-300 p-0 shadow-none transition-all ${l === n.id ? "pointer-events-none" : ""}`,
452
+ children: [
453
+ l === n.id && /* @__PURE__ */ e("div", { className: "absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80", children: /* @__PURE__ */ e(P, { className: "h-5 w-5 animate-spin text-primary" }) }),
454
+ /* @__PURE__ */ e(Ae, { className: "p-2", children: /* @__PURE__ */ a("div", { className: "flex items-center justify-between", children: [
455
+ /* @__PURE__ */ a("div", { className: "flex items-center gap-3", children: [
456
+ J && /* @__PURE__ */ e(G, { checked: E, onCheckedChange: () => c(n.id) }),
457
+ /* @__PURE__ */ a("div", { children: [
458
+ /* @__PURE__ */ e(Ce, { className: "flex items-center gap-2 text-sm leading-none", children: n.name }),
459
+ (n == null ? void 0 : n.description) && /* @__PURE__ */ e("p", { className: "mt-1 text-xs leading-none text-muted-foreground", children: n == null ? void 0 : n.description })
460
+ ] })
461
+ ] }),
462
+ J && /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
463
+ /* @__PURE__ */ e(
464
+ v,
465
+ {
466
+ type: "button",
467
+ variant: "ghost",
468
+ size: "icon",
469
+ className: "h-5 w-5 p-0",
470
+ onClick: () => p(n.id),
471
+ children: /* @__PURE__ */ e(Je, { className: "h-4 w-4" })
472
+ }
473
+ ),
474
+ /* @__PURE__ */ a(R, { children: [
475
+ /* @__PURE__ */ e(De, { className: "flex h-5 w-5 items-center justify-center rounded-md text-red-500 hover:bg-red-100 hover:text-red-800", children: /* @__PURE__ */ e(Pe, { className: "h-4 w-4" }) }),
476
+ /* @__PURE__ */ a(U, { children: [
477
+ /* @__PURE__ */ a(V, { children: [
478
+ /* @__PURE__ */ e(_, { children: "Delete Schema" }),
479
+ /* @__PURE__ */ a(M, { children: [
480
+ "Are you sure you want to delete ",
481
+ /* @__PURE__ */ e("span", { className: "font-medium", children: n.name }),
482
+ "? This action cannot be undone."
483
+ ] })
484
+ ] }),
485
+ /* @__PURE__ */ a(q, { children: [
486
+ /* @__PURE__ */ e(H, { type: "button", children: "Cancel" }),
487
+ /* @__PURE__ */ e(
488
+ K,
489
+ {
490
+ type: "button",
491
+ onClick: () => T(n.id),
492
+ className: "bg-red-500 text-white hover:bg-red-600",
493
+ children: "Delete"
494
+ }
495
+ )
496
+ ] })
497
+ ] })
498
+ ] })
499
+ ] })
500
+ ] }) }),
501
+ /* @__PURE__ */ e(Te, { className: "px-2 pb-2", children: J ? /* @__PURE__ */ e(
502
+ O,
503
+ {
504
+ id: n.id,
505
+ rows: 1,
506
+ readOnly: !0,
507
+ value: JSON.stringify(L, null, 2),
508
+ className: "no-scrollbar cursor-text overflow-hidden rounded-md border-none bg-gray-100/80 text-xs"
509
+ }
510
+ ) : /* @__PURE__ */ a("div", { className: "flex h-20 w-full flex-col items-center justify-center rounded-lg border bg-gray-100", children: [
511
+ /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
512
+ /* @__PURE__ */ e("div", { className: "max-w-xl text-center text-xs text-gray-500", children: "Not available in selected language, but available in default language." }),
513
+ ce && /* @__PURE__ */ e("span", { className: "rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-700", children: "Enabled in default" })
514
+ ] }),
515
+ /* @__PURE__ */ e(
516
+ v,
517
+ {
518
+ type: "button",
519
+ size: "sm",
520
+ variant: "outline",
521
+ className: "mt-2",
522
+ onClick: () => {
523
+ b({
524
+ name: n.name,
525
+ description: n.description || "",
526
+ jsonld: n.jsonld,
527
+ languageCode: y
528
+ }), o(!0);
529
+ },
530
+ children: "Copy & Edit from default language"
531
+ }
532
+ )
533
+ ] }) })
534
+ ]
535
+ },
536
+ n.id
537
+ );
538
+ })
539
+ ] }),
540
+ g && /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-4", children: /* @__PURE__ */ e(P, { className: "h-5 w-5 animate-spin" }) })
541
+ ] }),
542
+ /* @__PURE__ */ e(
543
+ Oe,
544
+ {
545
+ show: i,
546
+ onClose: () => {
547
+ o(!1), b(void 0);
548
+ },
549
+ initialData: r
550
+ }
551
+ ),
552
+ /* @__PURE__ */ e(Ee, { id: u, onClose: () => p(null) })
553
+ ] });
554
+ }
555
+ export {
556
+ _e as default
557
+ };
@@ -1 +1 @@
1
- "use strict";const s=require("react/jsx-runtime"),u=require("./index-Qnh8Lkr0.cjs"),b=require("@chaibuilder/sdk/ui"),d=require("react"),j=e=>{if(!e)return{base:e,extension:null};const n=e.lastIndexOf(".");if(n<=0)return{base:e,extension:null};const t=e.substring(n);return{base:e.substring(0,n),extension:t}},x=e=>{if(!e)return e;const{base:n}=j(e);return n};function E(e,n){const t=(e||"").split("/").filter(Boolean);let r="",a=!0;if(n.slug==="/"){const i=t.pop()||"";if(u.LANGUAGES[i])a=!0;else{r=i;const l=t.pop()||"";a=!!u.LANGUAGES[l]}}else if(n.parent)t.length&&(r=t.pop()||"");else if(t.length){r=t.pop()||"";const i=t.pop()||"";a=!!u.LANGUAGES[i]}return{initSlug:r,prefix:a}}const v=e=>e&&x(e),C=(e,n)=>{const t=x(e||"");return!t||t==="/"?`/${n}`:`${t}/${n}`};function A({value:e,onChange:n,placeholder:t,parentSlug:r,onValidationChange:a,disabled:i=!1,fullSlug:l}){const[g,p]=d.useState(e),[o,f]=d.useState(null);d.useEffect(()=>{p(e)},[e]);const h=S=>{const c=S.target.value.replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),m=(c.match(/\./g)||[]).length,N=m<=1;m>1?f("Invalid slug. Only one dot (.) is allowed in the slug"):f(null),a&&a(N),p(c),n(c)};return s.jsxs("div",{children:[r&&s.jsx("div",{className:"mb-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Parent: ",s.jsx("span",{className:"font-mono text-gray-900",children:v(r)})]})}),s.jsxs("div",{className:"relative",children:[s.jsx(b.Input,{disabled:i,value:g,onChange:h,placeholder:t,className:o?"border-red-500":""}),o&&s.jsx("div",{className:"mt-1 text-xs text-red-500",children:o})]}),l&&l!=="undefined"&&s.jsx("div",{className:"mt-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Complete Slug: ",s.jsx("span",{className:"font-mono text-gray-900",children:l})]})})]})}exports.SlugInput=A;exports.combineParentChildSlugs=C;exports.parseSlugForEdit=E;exports.removeSlugExtension=x;
1
+ "use strict";const s=require("react/jsx-runtime"),u=require("./index-CffopOpP.cjs"),b=require("@chaibuilder/sdk/ui"),d=require("react"),j=e=>{if(!e)return{base:e,extension:null};const n=e.lastIndexOf(".");if(n<=0)return{base:e,extension:null};const t=e.substring(n);return{base:e.substring(0,n),extension:t}},x=e=>{if(!e)return e;const{base:n}=j(e);return n};function E(e,n){const t=(e||"").split("/").filter(Boolean);let r="",a=!0;if(n.slug==="/"){const i=t.pop()||"";if(u.LANGUAGES[i])a=!0;else{r=i;const l=t.pop()||"";a=!!u.LANGUAGES[l]}}else if(n.parent)t.length&&(r=t.pop()||"");else if(t.length){r=t.pop()||"";const i=t.pop()||"";a=!!u.LANGUAGES[i]}return{initSlug:r,prefix:a}}const v=e=>e&&x(e),C=(e,n)=>{const t=x(e||"");return!t||t==="/"?`/${n}`:`${t}/${n}`};function A({value:e,onChange:n,placeholder:t,parentSlug:r,onValidationChange:a,disabled:i=!1,fullSlug:l}){const[g,p]=d.useState(e),[o,f]=d.useState(null);d.useEffect(()=>{p(e)},[e]);const h=S=>{const c=S.target.value.replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),m=(c.match(/\./g)||[]).length,N=m<=1;m>1?f("Invalid slug. Only one dot (.) is allowed in the slug"):f(null),a&&a(N),p(c),n(c)};return s.jsxs("div",{children:[r&&s.jsx("div",{className:"mb-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Parent: ",s.jsx("span",{className:"font-mono text-gray-900",children:v(r)})]})}),s.jsxs("div",{className:"relative",children:[s.jsx(b.Input,{disabled:i,value:g,onChange:h,placeholder:t,className:o?"border-red-500":""}),o&&s.jsx("div",{className:"mt-1 text-xs text-red-500",children:o})]}),l&&l!=="undefined"&&s.jsx("div",{className:"mt-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Complete Slug: ",s.jsx("span",{className:"font-mono text-gray-900",children:l})]})})]})}exports.SlugInput=A;exports.combineParentChildSlugs=C;exports.parseSlugForEdit=E;exports.removeSlugExtension=x;
@@ -1,5 +1,5 @@
1
1
  import { jsxs as i, jsx as o } from "react/jsx-runtime";
2
- import { L as d } from "./index-DFvsMFVH.js";
2
+ import { L as d } from "./index-CguzNa4U.js";
3
3
  import { Input as v } from "@chaibuilder/sdk/ui";
4
4
  import { useState as x, useEffect as C } from "react";
5
5
  const y = (e) => {
@@ -1,5 +1,5 @@
1
1
  import { jsxs as h, jsx as n } from "react/jsx-runtime";
2
- import { u as l, a as m, t as r } from "./index-DFvsMFVH.js";
2
+ import { u as l, a as m, t as r } from "./index-CguzNa4U.js";
3
3
  import { useTheme as d } from "@chaibuilder/sdk";
4
4
  import { Button as a } from "@chaibuilder/sdk/ui";
5
5
  const P = () => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-Qnh8Lkr0.cjs"),d=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),l=()=>{const[t]=d.useTheme(),{mutate:o,isPending:i}=s.usePublishPages(),{mutateAsync:n,isPending:u}=s.useUpdateWebsiteSettings(),r=()=>{n({settings:{theme:t}})},c=async()=>{await n({settings:{theme:t}}),o({ids:["THEME"]},{onSuccess:()=>{s.throwConfetti("BOTTOM_RIGHT")}})};return e.jsxs("div",{className:"flex items-center justify-center gap-x-3 border-t bg-white py-3",children:[e.jsx(a.Button,{size:"sm",variant:"outline",disabled:i||u,onClick:r,children:"Save draft"}),e.jsx(a.Button,{size:"sm",disabled:i||u,onClick:c,children:"Publish"})]})};exports.default=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-CffopOpP.cjs"),d=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),l=()=>{const[t]=d.useTheme(),{mutate:o,isPending:i}=s.usePublishPages(),{mutateAsync:n,isPending:u}=s.useUpdateWebsiteSettings(),r=()=>{n({settings:{theme:t}})},c=async()=>{await n({settings:{theme:t}}),o({ids:["THEME"]},{onSuccess:()=>{s.throwConfetti("BOTTOM_RIGHT")}})};return e.jsxs("div",{className:"flex items-center justify-center gap-x-3 border-t bg-white py-3",children:[e.jsx(a.Button,{size:"sm",variant:"outline",disabled:i||u,onClick:r,children:"Save draft"}),e.jsx(a.Button,{size:"sm",disabled:i||u,onClick:c,children:"Publish"})]})};exports.default=l;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("./index-Qnh8Lkr0.cjs"),t=require("@chaibuilder/sdk/ui"),u=require("react"),d=({page:i,onClose:a})=>{const[s,n]=u.useState(!1),r=c.useUnmarkAsTemplate(),o=()=>{n(!0),r.mutate(i,{onSuccess:()=>{n(!1),a()},onError:()=>{n(!1)}})};return e.jsx(t.Dialog,{open:!0,onOpenChange:a,children:e.jsxs(t.DialogContent,{children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Unmark as template"}),e.jsx(t.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:"Are you sure you want to unmark this page as a template?"})]}),e.jsxs(t.DialogFooter,{className:s?"pointer-events-none opacity-75":"",children:[e.jsx(t.Button,{variant:"outline",onClick:l=>{l.stopPropagation(),a()},children:"Cancel"}),e.jsx(t.Button,{variant:"default",disabled:s,onClick:o,children:"Unmark as template"})]})]})})};exports.default=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("./index-CffopOpP.cjs"),t=require("@chaibuilder/sdk/ui"),u=require("react"),d=({page:i,onClose:a})=>{const[s,n]=u.useState(!1),r=c.useUnmarkAsTemplate(),o=()=>{n(!0),r.mutate(i,{onSuccess:()=>{n(!1),a()},onError:()=>{n(!1)}})};return e.jsx(t.Dialog,{open:!0,onOpenChange:a,children:e.jsxs(t.DialogContent,{children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Unmark as template"}),e.jsx(t.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:"Are you sure you want to unmark this page as a template?"})]}),e.jsxs(t.DialogFooter,{className:s?"pointer-events-none opacity-75":"",children:[e.jsx(t.Button,{variant:"outline",onClick:l=>{l.stopPropagation(),a()},children:"Cancel"}),e.jsx(t.Button,{variant:"default",disabled:s,onClick:o,children:"Unmark as template"})]})]})})};exports.default=d;
@@ -1,5 +1,5 @@
1
1
  import { jsx as e, jsxs as n } from "react/jsx-runtime";
2
- import { o as c } from "./index-DFvsMFVH.js";
2
+ import { o as c } from "./index-CguzNa4U.js";
3
3
  import { Dialog as m, DialogContent as p, DialogHeader as d, DialogTitle as u, DialogDescription as h, DialogFooter as g, Button as r } from "@chaibuilder/sdk/ui";
4
4
  import { useState as f } from "react";
5
5
  const T = ({ page: i, onClose: a }) => {
@@ -1,5 +1,5 @@
1
1
  import { jsx as n, jsxs as l } from "react/jsx-runtime";
2
- import { l as d, C as r } from "./index-DFvsMFVH.js";
2
+ import { l as d, C as r } from "./index-CguzNa4U.js";
3
3
  import { Dialog as h, DialogContent as a, DialogHeader as u, DialogTitle as m, DialogDescription as U, DialogFooter as D, Button as e } from "@chaibuilder/sdk/ui";
4
4
  const f = ({ page: i, onClose: o }) => {
5
5
  const { mutate: s, isPending: t } = d(), c = async () => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),s=require("./index-Qnh8Lkr0.cjs"),e=require("@chaibuilder/sdk/ui"),o=({page:i,onClose:t})=>{const{mutate:r,isPending:l}=s.useUnpublishPage(),c=async()=>{r(i,{onSuccess:t})};return n.jsx(e.Dialog,{open:!!i,onOpenChange:t,children:n.jsxs(e.DialogContent,{children:[n.jsxs(e.DialogHeader,{children:[n.jsx(e.DialogTitle,{children:"Confirm action"}),n.jsxs(e.DialogDescription,{children:[s.CONTENT.UNPUBLISH_MSG," ",n.jsx("b",{children:(i==null?void 0:i.name)??(i==null?void 0:i.slug)}),"?"]})]}),n.jsxs(e.DialogFooter,{children:[n.jsx(e.Button,{variant:"outline",onClick:t,children:"Cancel"}),n.jsx(e.Button,{variant:"destructive",disabled:l,onClick:c,children:l?s.CONTENT.UPDATING:s.CONTENT.UNPUBLISH})]})]})})};exports.default=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),s=require("./index-CffopOpP.cjs"),e=require("@chaibuilder/sdk/ui"),o=({page:i,onClose:t})=>{const{mutate:r,isPending:l}=s.useUnpublishPage(),c=async()=>{r(i,{onSuccess:t})};return n.jsx(e.Dialog,{open:!!i,onOpenChange:t,children:n.jsxs(e.DialogContent,{children:[n.jsxs(e.DialogHeader,{children:[n.jsx(e.DialogTitle,{children:"Confirm action"}),n.jsxs(e.DialogDescription,{children:[s.CONTENT.UNPUBLISH_MSG," ",n.jsx("b",{children:(i==null?void 0:i.name)??(i==null?void 0:i.slug)}),"?"]})]}),n.jsxs(e.DialogFooter,{children:[n.jsx(e.Button,{variant:"outline",onClick:t,children:"Cancel"}),n.jsx(e.Button,{variant:"destructive",disabled:l,onClick:c,children:l?s.CONTENT.UPDATING:s.CONTENT.UNPUBLISH})]})]})})};exports.default=o;
@@ -0,0 +1 @@
1
+ "use strict";const w=require("jotai"),E=require("react"),d=require("lodash-es");let x=0;function b(t,n){const e=`atom${++x}`,o={toString(){return e}};return typeof t=="function"?o.read=t:(o.init=t,o.read=S,o.write=A),n&&(o.write=n),o}function S(t){return t(this)}function A(t,n,e){return n(this,typeof e=="function"?e(t(this)):e)}const I=Symbol(""),v=t=>typeof(t==null?void 0:t.then)=="function";function C(t=()=>{try{return window.localStorage}catch{return}},n){var e;let o,a;const c={getItem:(l,r)=>{var s,f;const m=p=>{if(p=p||"",o!==p){try{a=JSON.parse(p,n==null?void 0:n.reviver)}catch{return r}o=p}return a},h=(f=(s=t())==null?void 0:s.getItem(l))!=null?f:null;return v(h)?h.then(m):m(h)},setItem:(l,r)=>{var s;return(s=t())==null?void 0:s.setItem(l,JSON.stringify(r,void 0))},removeItem:l=>{var r;return(r=t())==null?void 0:r.removeItem(l)}},u=l=>(r,s,f)=>l(r,m=>{let h;try{h=JSON.parse(m||"")}catch{h=f}s(h)});let i;try{i=(e=t())==null?void 0:e.subscribe}catch{}return!i&&typeof window<"u"&&typeof window.addEventListener=="function"&&window.Storage&&(i=(l,r)=>{if(!(t()instanceof window.Storage))return()=>{};const s=f=>{f.storageArea===t()&&f.key===l&&r(f.newValue)};return window.addEventListener("storage",s),()=>{window.removeEventListener("storage",s)}}),i&&(c.subscribe=u(i)),c}const g=C();function O(t,n,e=g,o){const a=b(n);return a.onMount=u=>{u(e.getItem(t,n));let i;return e.subscribe&&(i=e.subscribe(t,u,n)),i},b(u=>u(a),(u,i,l)=>{const r=typeof l=="function"?l(u(a)):l;return r===I?(i(a,n),e.removeItem(t)):v(r)?r.then(s=>(i(a,s),e.setItem(t,s))):(i(a,r),e.setItem(t,r))})}const k=O("expandedPagesState",[]),y=t=>d.flatMap(t,n=>[n,...n.children?y(n.children):[]]),M=(t,n)=>{const e=(o,a=[])=>{for(const c of o){const u=[...a,c.id];if(c.id===n)return u;if(c.children&&c.children.length>0){const i=e(c.children,u);if(i)return i}}return null};return e(t)||[]},P=(t,n)=>{if(!n)return[];const e=y(t),o=d.find(e,a=>a.id===n);if(o){if(o.parent)return[...P(t,o.parent),n];const a=M(t,n);if(!d.isEmpty(a))return a}return[n]},N=t=>{const n=new Set,e=(o,a=[])=>{o.forEach(c=>{const u=[...a,c.id];c.shouldExpandOnSearch&&u.forEach(i=>n.add(i)),c.children&&!d.isEmpty(c.children)&&e(c.children,u)})};return e(t),Array.from(n)},_=t=>{const[n,e]=w.useAtom(k),o=t?d.includes(n,t):!1,a=E.useCallback(()=>{e(r=>o?d.filter(r,s=>s!==t):[...r,t])},[e,o,t]),c=E.useCallback((r,s)=>{if(!s||d.isEmpty(r))return;const f=y(r),m=P(f,s);if(!Array.isArray(m)||d.isEmpty(m))return;const h=m.slice(0,-1);d.isEmpty(h)||e(p=>d.uniq([...p,...h]))},[e]),u=E.useCallback(r=>{if(d.isEmpty(r))return;const s=N(r);d.isEmpty(s)||e(f=>d.union(f,s))},[e]),i=E.useCallback(r=>{if(d.isEmpty(r))return;const s=d.flatMap(r,f=>{const m=h=>[h.id,...h.children?d.flatMap(h.children,m):[]];return m(f)});e(s)},[e]),l=E.useCallback(()=>{e([])},[e]);return{isExpanded:o,toggleExpanded:a,updateForSelectedPage:c,expandedPages:n,expandPagesOnSearch:u,setExpandedPages:e,expandAll:i,collapseAll:l}};exports.usePageExpandManager=_;