@openrails/contentkit-ui 0.99.2 → 0.100.0

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.
@@ -1,224 +1,318 @@
1
1
  import { useLanguageName as e, useMessages as t } from "../../i18n/context.js";
2
2
  import { useContentKitClient as n } from "../../react/context.js";
3
- import { useKinds as r } from "../../react/groups.js";
4
- import { useMediaRead as i } from "../../react/read.js";
5
- import { usePresets as a } from "../../react/public.js";
6
- import { Button as o } from "../../ui/button.js";
7
- import { SortableList as s } from "../sortable-list.js";
8
- import { MediaFolderEditor as c } from "../media-folder-editor.js";
9
- import { Badge as l } from "../../ui/badge.js";
10
- import { Input as u } from "../../ui/input.js";
11
- import { Label as d } from "../../ui/label.js";
12
- import { Select as f, SelectContent as p, SelectItem as m, SelectTrigger as h, SelectValue as g } from "../../ui/select.js";
13
- import { Skeleton as _ } from "../../ui/skeleton.js";
14
- import { ErrorLine as v, useAction as y } from "../social/parts.js";
15
- import { Switch as b } from "../../ui/switch.js";
16
- import { fromLocalInput as x, parseAttributes as S, toLocalInput as C } from "../../client/group-fields.js";
17
- import { GroupPicker as w, labelOf as T, useGroupNames as E } from "../groups/parts.js";
18
- import { OfferFields as D } from "./offer-fields.js";
19
- import { AttributeFields as O, formOf as k } from "../groups/fields.js";
20
- import { MembershipEditor as A } from "../groups/memberships.js";
21
- import { ReaderManifestEditor as j } from "../admin/reader-manifest.js";
3
+ import { useContentScope as r } from "../../react/use-resource.js";
4
+ import { useKinds as i } from "../../react/groups.js";
5
+ import { useMediaRead as a } from "../../react/read.js";
6
+ import { usePresets as o } from "../../react/public.js";
7
+ import { Button as s } from "../../ui/button.js";
8
+ import { SortableList as c } from "../sortable-list.js";
9
+ import { MediaFolderEditor as l } from "../media-folder-editor.js";
10
+ import { Badge as u } from "../../ui/badge.js";
11
+ import { Input as d } from "../../ui/input.js";
12
+ import { Label as f } from "../../ui/label.js";
13
+ import { Select as p, SelectContent as m, SelectItem as h, SelectTrigger as g, SelectValue as _ } from "../../ui/select.js";
14
+ import { Skeleton as v } from "../../ui/skeleton.js";
15
+ import { ErrorLine as y, useAction as b } from "../social/parts.js";
16
+ import { Switch as x } from "../../ui/switch.js";
17
+ import { fromLocalInput as S, parseAttributes as C, toLocalInput as w } from "../../client/group-fields.js";
18
+ import { GroupPicker as T, labelOf as E, useGroupNames as D } from "../groups/parts.js";
19
+ import { OfferFields as O } from "./offer-fields.js";
20
+ import { AttributeFields as k, formOf as A } from "../groups/fields.js";
21
+ import { MembershipEditor as j } from "../groups/memberships.js";
22
+ import { ReaderManifestEditor as ee } from "../admin/reader-manifest.js";
22
23
  import { PageReview as M } from "../admin/page-review.js";
23
- import { VideoMediaEditor as N, videoPaths as P } from "../admin/media-item-panel.js";
24
- import { useEffect as F, useId as I, useMemo as L, useRef as R, useState as z } from "react";
25
- import { Fragment as B, jsx as V, jsxs as H } from "react/jsx-runtime";
26
- import { cn as U } from "cn";
24
+ import { VideoMediaEditor as N, videoPaths as te } from "../admin/media-item-panel.js";
25
+ import { useEffect as P, useId as ne, useMemo as F, useRef as I, useState as L } from "react";
26
+ import { Fragment as R, jsx as z, jsxs as B } from "react/jsx-runtime";
27
+ import { cn as V } from "cn";
27
28
  //#region src/components/content/editors.tsx
28
- var W = "__none__", ee = [
29
+ var H = "__none__", re = [
29
30
  "listed",
30
31
  "members",
31
32
  "unlisted"
32
- ], te = [
33
+ ], ie = [
33
34
  "open",
34
35
  "closed",
35
36
  "hidden"
36
- ], ne = [
37
+ ], ae = [
37
38
  "public",
38
39
  "tier",
39
40
  "ppv",
40
41
  "group",
41
42
  "group_ppv"
42
- ], G = (e) => e === "group" || e === "group_ppv";
43
- function K({ title: e, ckui: t, children: n }) {
44
- return /* @__PURE__ */ H("section", {
43
+ ], U = (e) => e === "group" || e === "group_ppv";
44
+ function W({ title: e, ckui: t, children: n }) {
45
+ return /* @__PURE__ */ B("section", {
45
46
  className: "grid gap-3 border-t border-border pt-4",
46
47
  "data-ckui": t,
47
- children: [/* @__PURE__ */ V("h3", {
48
+ children: [/* @__PURE__ */ z("h3", {
48
49
  className: "font-medium",
49
50
  children: e
50
51
  }), n]
51
52
  });
52
53
  }
53
- function q({ show: e }) {
54
+ function G({ show: e }) {
54
55
  let { t: n } = t();
55
- return e ? /* @__PURE__ */ V("span", {
56
+ return e ? /* @__PURE__ */ z("span", {
56
57
  role: "status",
57
58
  className: "text-muted-foreground",
58
59
  children: n("contentEditor.saved")
59
60
  }) : null;
60
61
  }
61
- function J(e, t) {
62
- let { kinds: n } = r({ client: t });
62
+ function K(e, t) {
63
+ let { kinds: n } = i({ client: t });
63
64
  return {
64
65
  model: n,
65
66
  spec: n?.kinds[e]
66
67
  };
67
68
  }
68
- function Y({ content: e, ...r }) {
69
- let { t: i } = t(), a = n(r.client), { spec: s } = J(e.kind, r.client), c = L(() => s?.attributes ?? {}, [s]), [l, u] = z(e.listing), [_, b] = z(e.comments), [x, C] = z({});
70
- F(() => {
71
- u(e.listing), b(e.comments), C(k(c, e.attributes));
72
- }, [
73
- e.revision,
74
- e.listing,
75
- e.comments,
76
- e.attributes,
77
- c
78
- ]);
79
- let [w, T] = z(null), [E, D] = z(!1), A = y("content.save", r.onError);
80
- return /* @__PURE__ */ V(K, {
69
+ function q(e) {
70
+ let [t, n] = L(e), r = I({
71
+ value: e,
72
+ dirty: /* @__PURE__ */ new Set(),
73
+ edits: /* @__PURE__ */ new Map()
74
+ });
75
+ return P(() => {
76
+ let t = { ...e };
77
+ for (let e of r.current.dirty) t[e] = r.current.value[e];
78
+ r.current.value = t, n(t);
79
+ }, [e]), {
80
+ value: t,
81
+ edit: (e) => {
82
+ let t = r.current, i = typeof e == "function" ? e(t.value) : e;
83
+ for (let e of /* @__PURE__ */ new Set([...Object.keys(t.value), ...Object.keys(i)])) Object.is(t.value[e], i[e]) || (t.dirty.add(e), t.edits.set(e, (t.edits.get(e) ?? 0) + 1));
84
+ t.value = i, n(i);
85
+ },
86
+ checkpoint: () => {
87
+ let e = new Map(r.current.edits);
88
+ return (t) => {
89
+ let i = r.current, a = { ...t };
90
+ for (let n of /* @__PURE__ */ new Set([...Object.keys(i.value), ...Object.keys(t)])) i.edits.get(n) === e.get(n) ? i.dirty.delete(n) : a[n] = i.value[n];
91
+ return i.value = a, n(a), i.dirty.size === 0;
92
+ };
93
+ }
94
+ };
95
+ }
96
+ function J(e, t, n) {
97
+ let [r, i] = L({
98
+ id: e,
99
+ client: t,
100
+ scope: n,
101
+ key: 0
102
+ });
103
+ if (r.id !== e || r.client !== t || r.scope !== n) {
104
+ let a = {
105
+ id: e,
106
+ client: t,
107
+ scope: n,
108
+ key: r.key + 1
109
+ };
110
+ return i(a), a.key;
111
+ }
112
+ return r.key;
113
+ }
114
+ function Y(e, t) {
115
+ let { client: n, store: i, scope: a, language: o } = r(t), s = I(!0);
116
+ return P(() => (s.current = !0, () => {
117
+ s.current = !1;
118
+ }), []), async () => {
119
+ let t = await n.contents.get(e.id, o ?? e.language);
120
+ return s.current && i.patch((t) => t.type === "content" && t.id === e.id && (t.readScope ?? "{}") === a, (e) => (e && e.revision > t.revision && (t = e), t)), t;
121
+ };
122
+ }
123
+ function X(e) {
124
+ let { client: t, scope: n } = r(e.client), i = J(e.content.id, t, n);
125
+ return /* @__PURE__ */ z(oe, {
126
+ ...e,
127
+ client: t
128
+ }, i);
129
+ }
130
+ function oe({ content: e, ...r }) {
131
+ let { t: i } = t(), a = n(r.client), { spec: o } = K(e.kind, r.client), c = F(() => o?.attributes ?? {}, [o]), l = q(F(() => ({
132
+ listing: e.listing,
133
+ comments: e.comments
134
+ }), [e.listing, e.comments])), u = q(F(() => A(c, e.attributes), [c, e.attributes])), { listing: d, comments: v } = l.value, x = Y(e, r.client), [S, w] = L(null), [T, E] = L(!1), D = b("content.save", r.onError);
135
+ return /* @__PURE__ */ z(W, {
81
136
  title: i("contentEditor.details"),
82
137
  ckui: "content-details",
83
- children: /* @__PURE__ */ H("form", {
138
+ children: /* @__PURE__ */ B("form", {
84
139
  className: "grid gap-3",
85
140
  onSubmit: (t) => {
86
- t.preventDefault(), T(null), D(!1);
141
+ t.preventDefault(), w(null), E(!1);
87
142
  let n;
88
143
  try {
89
- n = S(c, x);
144
+ n = C(c, u.value);
90
145
  } catch (e) {
91
- return T(e.message);
146
+ return w(e.message);
92
147
  }
93
- A.run(() => a.contents.update(e.id, {
94
- listing: l,
95
- comments: _,
148
+ let r = l.checkpoint(), i = u.checkpoint();
149
+ D.run(() => a.contents.update(e.id, {
150
+ listing: d,
151
+ comments: v,
96
152
  attributes: n,
97
153
  revision: e.revision
98
- })).then((e) => e && D(!0));
154
+ })).then((e) => {
155
+ if (!e) return;
156
+ let t = r({
157
+ listing: e.listing,
158
+ comments: e.comments
159
+ }), n = i(A(c, e.attributes));
160
+ E(t && n);
161
+ });
99
162
  },
100
163
  children: [
101
- /* @__PURE__ */ H("div", {
164
+ /* @__PURE__ */ B("div", {
102
165
  className: "grid gap-1.5 sm:max-w-xs",
103
- children: [/* @__PURE__ */ V(d, { children: i("contentEditor.listing") }), /* @__PURE__ */ H(f, {
104
- value: l,
105
- onValueChange: (e) => u(e),
106
- children: [/* @__PURE__ */ V(h, {
166
+ children: [/* @__PURE__ */ z(f, { children: i("contentEditor.listing") }), /* @__PURE__ */ B(p, {
167
+ value: d,
168
+ onValueChange: (e) => {
169
+ l.edit((t) => ({
170
+ ...t,
171
+ listing: e
172
+ })), E(!1);
173
+ },
174
+ children: [/* @__PURE__ */ z(g, {
107
175
  size: "sm",
108
176
  "aria-label": i("contentEditor.listing"),
109
- children: /* @__PURE__ */ V(g, { children: (e) => i(`contentEditor.listing_${e}`) })
110
- }), /* @__PURE__ */ V(p, { children: ee.map((e) => /* @__PURE__ */ V(m, {
177
+ children: /* @__PURE__ */ z(_, { children: (e) => i(`contentEditor.listing_${e}`) })
178
+ }), /* @__PURE__ */ z(m, { children: re.map((e) => /* @__PURE__ */ z(h, {
111
179
  value: e,
112
180
  children: i(`contentEditor.listing_${e}`)
113
181
  }, e)) })]
114
182
  })]
115
183
  }),
116
- /* @__PURE__ */ H("div", {
184
+ /* @__PURE__ */ B("div", {
117
185
  className: "grid gap-1.5 sm:max-w-xs",
118
- children: [/* @__PURE__ */ V(d, { children: i("contentEditor.comments") }), /* @__PURE__ */ H(f, {
119
- value: _,
120
- onValueChange: (e) => b(e),
121
- children: [/* @__PURE__ */ V(h, {
186
+ children: [/* @__PURE__ */ z(f, { children: i("contentEditor.comments") }), /* @__PURE__ */ B(p, {
187
+ value: v,
188
+ onValueChange: (e) => {
189
+ l.edit((t) => ({
190
+ ...t,
191
+ comments: e
192
+ })), E(!1);
193
+ },
194
+ children: [/* @__PURE__ */ z(g, {
122
195
  size: "sm",
123
196
  "aria-label": i("contentEditor.comments"),
124
- children: /* @__PURE__ */ V(g, { children: (e) => i(`contentEditor.comments_${e}`) })
125
- }), /* @__PURE__ */ V(p, { children: te.map((e) => /* @__PURE__ */ V(m, {
197
+ children: /* @__PURE__ */ z(_, { children: (e) => i(`contentEditor.comments_${e}`) })
198
+ }), /* @__PURE__ */ z(m, { children: ie.map((e) => /* @__PURE__ */ z(h, {
126
199
  value: e,
127
200
  children: i(`contentEditor.comments_${e}`)
128
201
  }, e)) })]
129
202
  })]
130
203
  }),
131
- /* @__PURE__ */ V(O, {
204
+ /* @__PURE__ */ z(k, {
132
205
  declared: c,
133
- form: x,
134
- onChange: (e, t) => C((n) => ({
135
- ...n,
136
- [e]: t
137
- })),
206
+ form: u.value,
207
+ onChange: (e, t) => {
208
+ u.edit((n) => ({
209
+ ...n,
210
+ [e]: t
211
+ })), E(!1);
212
+ },
138
213
  labels: r.labels
139
214
  }),
140
- w && /* @__PURE__ */ V(v, { children: w }),
141
- /* @__PURE__ */ V(v, { error: A.error }),
142
- /* @__PURE__ */ H("div", {
215
+ S && /* @__PURE__ */ z(y, { children: S }),
216
+ /* @__PURE__ */ z(y, { error: D.error }),
217
+ /* @__PURE__ */ B("div", {
143
218
  className: "flex items-center gap-3",
144
- children: [/* @__PURE__ */ V(o, {
145
- type: "submit",
146
- size: "sm",
147
- disabled: A.pending,
148
- children: A.pending ? i("common.saving") : i("common.save")
149
- }), /* @__PURE__ */ V(q, { show: E })]
219
+ children: [
220
+ /* @__PURE__ */ z(s, {
221
+ type: "submit",
222
+ size: "sm",
223
+ disabled: D.pending,
224
+ children: D.pending ? i("common.saving") : i("common.save")
225
+ }),
226
+ /* @__PURE__ */ z(s, {
227
+ type: "button",
228
+ variant: "ghost",
229
+ size: "sm",
230
+ disabled: D.pending,
231
+ onClick: () => {
232
+ let e = l.checkpoint(), t = u.checkpoint();
233
+ D.run(x).then((n) => {
234
+ n && (e({
235
+ listing: n.listing,
236
+ comments: n.comments
237
+ }), t(A(c, n.attributes)), w(null), E(!1));
238
+ });
239
+ },
240
+ children: i("common.cancel")
241
+ }),
242
+ /* @__PURE__ */ z(G, { show: T })
243
+ ]
150
244
  })
151
245
  ]
152
246
  })
153
247
  });
154
248
  }
155
- function X({ value: e, onChange: n, model: r, kind: i, owner: a, labels: o, client: s }) {
156
- let { t: c } = t(), l = I(), _ = r?.tiers ?? [], v = r?.kinds[i], y = Object.entries(r?.entity_kinds ?? {}).filter(([, e]) => e.sellable || e.auth_scope).map(([e]) => e), [S, D] = z(), O = S ?? y[0] ?? "", k = E(e.group_id ? [e.group_id] : [], { client: s }), A = e.group_id ? k.get(e.group_id) : void 0, j = (t) => n({
249
+ function se({ value: e, onChange: n, model: r, kind: i, owner: a, labels: o, client: s }) {
250
+ let { t: c } = t(), l = ne(), u = r?.tiers ?? [], v = r?.kinds[i], y = Object.entries(r?.entity_kinds ?? {}).filter(([, e]) => e.sellable || e.auth_scope).map(([e]) => e), [b, C] = L(), O = b ?? y[0] ?? "", k = D(e.group_id ? [e.group_id] : [], { client: s }), A = e.group_id ? k.get(e.group_id) : void 0, j = (t) => n({
157
251
  ...e,
158
252
  ...t
159
- }), M = v?.presentation === "reader", N = !!v?.segments;
160
- return /* @__PURE__ */ H("div", {
253
+ }), ee = v?.presentation === "reader", M = !!v?.segments;
254
+ return /* @__PURE__ */ B("div", {
161
255
  className: "grid gap-3",
162
256
  "data-ckui": "rule-fields",
163
257
  children: [
164
- /* @__PURE__ */ H("div", {
258
+ /* @__PURE__ */ B("div", {
165
259
  className: "grid gap-1.5 sm:max-w-xs",
166
- children: [/* @__PURE__ */ V(d, { children: c("contentEditor.access") }), /* @__PURE__ */ H(f, {
260
+ children: [/* @__PURE__ */ z(f, { children: c("contentEditor.access") }), /* @__PURE__ */ B(p, {
167
261
  value: e.level,
168
262
  onValueChange: (t) => {
169
263
  let r = t;
170
264
  n({
171
265
  level: r,
172
- group_id: G(r) ? e.group_id || a : void 0,
266
+ group_id: U(r) ? e.group_id || a : void 0,
173
267
  preview: e.preview,
174
268
  free_after: e.free_after
175
269
  });
176
270
  },
177
- children: [/* @__PURE__ */ V(h, {
271
+ children: [/* @__PURE__ */ z(g, {
178
272
  size: "sm",
179
273
  "aria-label": c("contentEditor.access"),
180
- children: /* @__PURE__ */ V(g, { children: (e) => c(`contentEditor.level_${e}`) })
181
- }), /* @__PURE__ */ V(p, { children: ne.filter((e) => (e !== "tier" || _.length) && (!e.startsWith("group") || y.length)).map((e) => /* @__PURE__ */ V(m, {
274
+ children: /* @__PURE__ */ z(_, { children: (e) => c(`contentEditor.level_${e}`) })
275
+ }), /* @__PURE__ */ z(m, { children: ae.filter((e) => (e !== "tier" || u.length) && (!e.startsWith("group") || y.length)).map((e) => /* @__PURE__ */ z(h, {
182
276
  value: e,
183
277
  children: c(`contentEditor.level_${e}`)
184
278
  }, e)) })]
185
279
  })]
186
280
  }),
187
- e.level === "tier" && /* @__PURE__ */ H("fieldset", {
281
+ e.level === "tier" && /* @__PURE__ */ B("fieldset", {
188
282
  className: "flex flex-wrap gap-3",
189
- children: [/* @__PURE__ */ V("legend", {
283
+ children: [/* @__PURE__ */ z("legend", {
190
284
  className: "sr-only",
191
285
  children: c("contentEditor.tiers")
192
- }), _.map((t) => /* @__PURE__ */ H("label", {
286
+ }), u.map((t) => /* @__PURE__ */ B("label", {
193
287
  className: "flex items-center gap-2",
194
- children: [/* @__PURE__ */ V(b, {
288
+ children: [/* @__PURE__ */ z(x, {
195
289
  checked: e.tiers?.includes(t) ?? !1,
196
290
  onCheckedChange: (n) => j({ tiers: n ? [...e.tiers ?? [], t] : (e.tiers ?? []).filter((e) => e !== t) }),
197
- "aria-label": T(o, t)
198
- }), T(o, t)]
291
+ "aria-label": E(o, t)
292
+ }), E(o, t)]
199
293
  }, t))]
200
294
  }),
201
- G(e.level) && /* @__PURE__ */ H("div", {
295
+ U(e.level) && /* @__PURE__ */ B("div", {
202
296
  className: "flex flex-wrap items-end gap-2",
203
297
  children: [
204
- A || e.group_id ? /* @__PURE__ */ V("span", {
298
+ A || e.group_id ? /* @__PURE__ */ z("span", {
205
299
  className: "rounded-md border border-border px-2 py-0.5",
206
300
  "data-ckui": "rule-group",
207
301
  children: A ? A.name || A.slug : e.group_id
208
302
  }) : null,
209
- y.length > 1 && /* @__PURE__ */ H(f, {
303
+ y.length > 1 && /* @__PURE__ */ B(p, {
210
304
  value: O,
211
- onValueChange: (e) => D(String(e)),
212
- children: [/* @__PURE__ */ V(h, {
305
+ onValueChange: (e) => C(String(e)),
306
+ children: [/* @__PURE__ */ z(g, {
213
307
  size: "sm",
214
308
  "aria-label": c("groupEditor.edgeKind"),
215
- children: /* @__PURE__ */ V(g, { children: (e) => T(o, e) })
216
- }), /* @__PURE__ */ V(p, { children: y.map((e) => /* @__PURE__ */ V(m, {
309
+ children: /* @__PURE__ */ z(_, { children: (e) => E(o, e) })
310
+ }), /* @__PURE__ */ z(m, { children: y.map((e) => /* @__PURE__ */ z(h, {
217
311
  value: e,
218
- children: T(o, e)
312
+ children: E(o, e)
219
313
  }, e)) })]
220
314
  }),
221
- O && /* @__PURE__ */ V(w, {
315
+ O && /* @__PURE__ */ z(T, {
222
316
  kind: O,
223
317
  label: c("contentEditor.group"),
224
318
  client: s,
@@ -226,15 +320,15 @@ function X({ value: e, onChange: n, model: r, kind: i, owner: a, labels: o, clie
226
320
  }, O)
227
321
  ]
228
322
  }),
229
- e.level !== "public" && /* @__PURE__ */ H("div", {
323
+ e.level !== "public" && /* @__PURE__ */ B("div", {
230
324
  className: "grid gap-3 sm:grid-cols-3",
231
325
  children: [
232
- M && /* @__PURE__ */ H("div", {
326
+ ee && /* @__PURE__ */ B("div", {
233
327
  className: "grid gap-1.5",
234
- children: [/* @__PURE__ */ V(d, {
328
+ children: [/* @__PURE__ */ z(f, {
235
329
  htmlFor: `${l}-pages`,
236
330
  children: c("contentEditor.previewPages")
237
- }), /* @__PURE__ */ V(u, {
331
+ }), /* @__PURE__ */ z(d, {
238
332
  id: `${l}-pages`,
239
333
  className: "h-8",
240
334
  type: "number",
@@ -246,12 +340,12 @@ function X({ value: e, onChange: n, model: r, kind: i, owner: a, labels: o, clie
246
340
  } })
247
341
  })]
248
342
  }),
249
- N && /* @__PURE__ */ H("div", {
343
+ M && /* @__PURE__ */ B("div", {
250
344
  className: "grid gap-1.5",
251
- children: [/* @__PURE__ */ V(d, {
345
+ children: [/* @__PURE__ */ z(f, {
252
346
  htmlFor: `${l}-segments`,
253
347
  children: c("contentEditor.previewSegments")
254
- }), /* @__PURE__ */ V(u, {
348
+ }), /* @__PURE__ */ z(d, {
255
349
  id: `${l}-segments`,
256
350
  className: "h-8",
257
351
  type: "number",
@@ -263,17 +357,17 @@ function X({ value: e, onChange: n, model: r, kind: i, owner: a, labels: o, clie
263
357
  } })
264
358
  })]
265
359
  }),
266
- /* @__PURE__ */ H("div", {
360
+ /* @__PURE__ */ B("div", {
267
361
  className: "grid gap-1.5",
268
- children: [/* @__PURE__ */ V(d, {
362
+ children: [/* @__PURE__ */ z(f, {
269
363
  htmlFor: `${l}-free`,
270
364
  children: c("contentEditor.freeAfter")
271
- }), /* @__PURE__ */ V(u, {
365
+ }), /* @__PURE__ */ z(d, {
272
366
  id: `${l}-free`,
273
367
  className: "h-8",
274
368
  type: "datetime-local",
275
- value: C(e.free_after),
276
- onChange: (e) => j({ free_after: x(e.target.value) })
369
+ value: w(e.free_after),
370
+ onChange: (e) => j({ free_after: S(e.target.value) })
277
371
  })]
278
372
  })
279
373
  ]
@@ -281,8 +375,8 @@ function X({ value: e, onChange: n, model: r, kind: i, owner: a, labels: o, clie
281
375
  ]
282
376
  });
283
377
  }
284
- var Z = (e) => !G(e.level) || !!e.group_id;
285
- function re(e) {
378
+ var ce = (e) => !U(e.level) || !!e.group_id;
379
+ function le(e) {
286
380
  let t = e.preview && (e.preview.pages || e.preview.segments) ? {
287
381
  pages: e.preview.pages || void 0,
288
382
  segments: e.preview.segments || void 0
@@ -295,70 +389,95 @@ function re(e) {
295
389
  free_after: e.level === "public" ? void 0 : e.free_after
296
390
  };
297
391
  }
298
- function ie({ content: e, ...r }) {
299
- let { t: i } = t(), a = n(r.client), { model: s } = J(e.kind, r.client), [c, l] = z(e.access);
300
- F(() => l(e.access), [e.revision, e.access]);
301
- let [u, d] = z(!1), f = y("content.save", r.onError), p = y("offer.save", r.onError);
302
- return /* @__PURE__ */ H(K, {
392
+ function ue(e) {
393
+ let { client: t, scope: n } = r(e.client), i = J(e.content.id, t, n);
394
+ return /* @__PURE__ */ z(de, {
395
+ ...e,
396
+ client: t
397
+ }, i);
398
+ }
399
+ function de({ content: e, ...r }) {
400
+ let { t: i } = t(), a = n(r.client), { model: o } = K(e.kind, r.client), c = q(e.access), l = Y(e, r.client), [u, d] = L(!1), f = b("content.save", r.onError), p = b("offer.save", r.onError);
401
+ return /* @__PURE__ */ B(W, {
303
402
  title: i("contentEditor.accessTitle"),
304
403
  ckui: "access-editor",
305
404
  children: [
306
- /* @__PURE__ */ H("form", {
405
+ /* @__PURE__ */ B("form", {
307
406
  className: "grid gap-3",
308
407
  onSubmit: (t) => {
309
- t.preventDefault(), d(!1), f.run(() => a.contents.update(e.id, {
310
- access: re(c),
408
+ t.preventDefault(), d(!1);
409
+ let n = c.checkpoint();
410
+ f.run(() => a.contents.update(e.id, {
411
+ access: le(c.value),
311
412
  revision: e.revision
312
- })).then((e) => e && d(!0));
413
+ })).then((e) => e && d(n(e.access)));
313
414
  },
314
415
  children: [
315
- /* @__PURE__ */ V(X, {
316
- value: c,
317
- onChange: l,
318
- model: s,
416
+ /* @__PURE__ */ z(se, {
417
+ value: c.value,
418
+ onChange: (e) => {
419
+ c.edit(e), d(!1);
420
+ },
421
+ model: o,
319
422
  kind: e.kind,
320
423
  owner: e.owner_group_id,
321
424
  labels: r.labels,
322
425
  client: a
323
426
  }),
324
- /* @__PURE__ */ V(v, { error: f.error }),
325
- /* @__PURE__ */ H("div", {
427
+ /* @__PURE__ */ z(y, { error: f.error }),
428
+ /* @__PURE__ */ B("div", {
326
429
  className: "flex items-center gap-3",
327
- children: [/* @__PURE__ */ V(o, {
328
- type: "submit",
329
- size: "sm",
330
- disabled: f.pending || !Z(c),
331
- children: f.pending ? i("common.saving") : i("common.save")
332
- }), /* @__PURE__ */ V(q, { show: u })]
430
+ children: [
431
+ /* @__PURE__ */ z(s, {
432
+ type: "submit",
433
+ size: "sm",
434
+ disabled: f.pending || !ce(c.value),
435
+ children: f.pending ? i("common.saving") : i("common.save")
436
+ }),
437
+ /* @__PURE__ */ z(s, {
438
+ type: "button",
439
+ variant: "ghost",
440
+ size: "sm",
441
+ disabled: f.pending,
442
+ onClick: () => {
443
+ let e = c.checkpoint();
444
+ f.run(l).then((t) => {
445
+ t && (e(t.access), d(!1));
446
+ });
447
+ },
448
+ children: i("common.cancel")
449
+ }),
450
+ /* @__PURE__ */ z(G, { show: u })
451
+ ]
333
452
  })
334
453
  ]
335
454
  }),
336
- /* @__PURE__ */ V(D, {
455
+ /* @__PURE__ */ z(O, {
337
456
  offer: e.offer,
338
457
  pending: p.pending,
339
458
  onSell: (t) => void p.run(() => a.offers.sell({ content: e.id }, t)),
340
459
  onWithdraw: () => void p.run(() => a.offers.withdraw({ content: e.id }))
341
460
  }),
342
- /* @__PURE__ */ V(v, { error: p.error })
461
+ /* @__PURE__ */ z(y, { error: p.error })
343
462
  ]
344
463
  });
345
464
  }
346
- function Q(e, t, n) {
347
- return e.label || [...e.languages.map(t), ...e.traits.map((e) => T(n, e))].join(" · ");
465
+ function Z(e, t, n) {
466
+ return e.label || [...e.languages.map(t), ...e.traits.map((e) => E(n, e))].join(" · ");
348
467
  }
349
- function ae({ content: r, media: i = !0, ...a }) {
350
- let { t: c } = t(), u = n(a.client), d = e(), { model: f, spec: p } = J(r.kind, a.client), m = y("content.save", a.onError), h = y("content.save", a.onError), [g, _] = z(null), b = L(() => [...r.versions].sort((e, t) => e.position - t.position), [r.versions]);
468
+ function fe({ content: r, media: i = !0, ...a }) {
469
+ let { t: o } = t(), l = n(a.client), d = e(), { model: f, spec: p } = K(r.kind, a.client), m = b("content.save", a.onError), h = b("content.save", a.onError), [g, _] = L(null), v = F(() => [...r.versions].sort((e, t) => e.position - t.position), [r.versions]);
351
470
  if (!p) return null;
352
471
  if (p.versions.hidden) {
353
- let e = b[0];
354
- return !e || !i && !p.segments ? null : /* @__PURE__ */ H(K, {
355
- title: c("contentEditor.media"),
472
+ let e = v[0];
473
+ return !e || !i && !p.segments ? null : /* @__PURE__ */ B(W, {
474
+ title: o("contentEditor.media"),
356
475
  ckui: "version-media",
357
- children: [p.segments && /* @__PURE__ */ V($, {
476
+ children: [p.segments && /* @__PURE__ */ z($, {
358
477
  content: r,
359
478
  version: e,
360
479
  ...a
361
- }), i && /* @__PURE__ */ V(ue, {
480
+ }), i && /* @__PURE__ */ z(ge, {
362
481
  content: r,
363
482
  version: e,
364
483
  model: f,
@@ -367,54 +486,54 @@ function ae({ content: r, media: i = !0, ...a }) {
367
486
  });
368
487
  }
369
488
  let x = f?.languages ?? [];
370
- return /* @__PURE__ */ H(K, {
371
- title: c("contentEditor.versions"),
489
+ return /* @__PURE__ */ B(W, {
490
+ title: o("contentEditor.versions"),
372
491
  ckui: "versions-editor",
373
492
  children: [
374
- /* @__PURE__ */ V(s, {
375
- items: b,
493
+ /* @__PURE__ */ z(c, {
494
+ items: v,
376
495
  id: (e) => e.id,
377
- name: (e) => Q(e, d, a.labels),
378
- label: c("contentEditor.versions"),
379
- disabled: m.pending || b.length < 2,
496
+ name: (e) => Z(e, d, a.labels),
497
+ label: o("contentEditor.versions"),
498
+ disabled: m.pending || v.length < 2,
380
499
  onMove: (e, t) => {
381
- let n = b.map((e) => e.id), [i] = n.splice(e, 1);
382
- n.splice(t, 0, i), m.run(() => u.contents.orderVersions(r.id, n));
500
+ let n = v.map((e) => e.id), [i] = n.splice(e, 1);
501
+ n.splice(t, 0, i), m.run(() => l.contents.orderVersions(r.id, n));
383
502
  },
384
- children: (e, t) => /* @__PURE__ */ H("div", {
503
+ children: (e, t) => /* @__PURE__ */ B("div", {
385
504
  className: "grid gap-2 rounded-md border border-border p-2",
386
505
  "data-ckui": "version-row",
387
506
  "data-version": e.id,
388
- children: [/* @__PURE__ */ H("div", {
507
+ children: [/* @__PURE__ */ B("div", {
389
508
  className: "flex flex-wrap items-center gap-2",
390
509
  children: [
391
- b.length > 1 && t,
392
- /* @__PURE__ */ V("span", {
510
+ v.length > 1 && t,
511
+ /* @__PURE__ */ z("span", {
393
512
  className: "min-w-0 flex-1 font-medium break-words",
394
- children: Q(e, d, a.labels)
513
+ children: Z(e, d, a.labels)
395
514
  }),
396
- /* @__PURE__ */ V(l, {
515
+ /* @__PURE__ */ z(u, {
397
516
  variant: e.live ? "default" : "outline",
398
- children: c(e.live ? "contentEditor.live" : e.state === "draft" ? "contentManager.draft" : "contentManager.scheduled")
517
+ children: o(e.live ? "contentEditor.live" : e.state === "draft" ? "contentManager.draft" : "contentManager.scheduled")
399
518
  }),
400
- e.access && /* @__PURE__ */ V(l, {
519
+ e.access && /* @__PURE__ */ z(u, {
401
520
  variant: "secondary",
402
- children: c(`contentEditor.level_${e.access.level}`)
521
+ children: o(`contentEditor.level_${e.access.level}`)
403
522
  }),
404
- e.pages ? /* @__PURE__ */ V("span", {
523
+ e.pages ? /* @__PURE__ */ z("span", {
405
524
  className: "text-xs text-muted-foreground",
406
- children: c("contentEditor.pageCount", { count: e.pages })
525
+ children: o("contentEditor.pageCount", { count: e.pages })
407
526
  }) : null,
408
- /* @__PURE__ */ V(o, {
527
+ /* @__PURE__ */ z(s, {
409
528
  type: "button",
410
529
  size: "xs",
411
530
  variant: "ghost",
412
531
  "aria-expanded": g === e.id,
413
532
  onClick: () => _(g === e.id ? null : e.id),
414
- children: c(g === e.id ? "contentEditor.close" : "contentEditor.edit")
533
+ children: o(g === e.id ? "contentEditor.close" : "contentEditor.edit")
415
534
  })
416
535
  ]
417
- }), g === e.id && /* @__PURE__ */ V(ce, {
536
+ }), g === e.id && /* @__PURE__ */ z(me, {
418
537
  content: r,
419
538
  version: e,
420
539
  model: f,
@@ -423,126 +542,126 @@ function ae({ content: r, media: i = !0, ...a }) {
423
542
  })]
424
543
  })
425
544
  }),
426
- /* @__PURE__ */ V(v, { error: m.error }),
427
- /* @__PURE__ */ V(se, {
545
+ /* @__PURE__ */ z(y, { error: m.error }),
546
+ /* @__PURE__ */ z(pe, {
428
547
  languages: x,
429
548
  many: p?.versions.languages === "many",
430
549
  pending: h.pending,
431
- onAdd: (e) => void h.run(() => u.contents.addVersion(r.id, e)).then((e) => e && _(e.id))
550
+ onAdd: (e) => void h.run(() => l.contents.addVersion(r.id, e)).then((e) => e && _(e.id))
432
551
  }),
433
- /* @__PURE__ */ V(v, { error: h.error })
552
+ /* @__PURE__ */ z(y, { error: h.error })
434
553
  ]
435
554
  });
436
555
  }
437
- function oe({ languages: n, value: r, many: i, onChange: a }) {
556
+ function Q({ languages: n, value: r, many: i, onChange: a }) {
438
557
  let { t: o } = t(), s = e();
439
- return i ? /* @__PURE__ */ H("fieldset", {
558
+ return i ? /* @__PURE__ */ B("fieldset", {
440
559
  className: "flex flex-wrap gap-3",
441
- children: [/* @__PURE__ */ V("legend", {
560
+ children: [/* @__PURE__ */ z("legend", {
442
561
  className: "sr-only",
443
562
  children: o("contentEditor.versionLanguages")
444
- }), n.map((e) => /* @__PURE__ */ H("label", {
563
+ }), n.map((e) => /* @__PURE__ */ B("label", {
445
564
  className: "flex items-center gap-1.5",
446
- children: [/* @__PURE__ */ V(b, {
565
+ children: [/* @__PURE__ */ z(x, {
447
566
  size: "sm",
448
567
  checked: r.includes(e),
449
568
  onCheckedChange: (t) => a(t ? [...r, e] : r.filter((t) => t !== e)),
450
569
  "aria-label": s(e)
451
570
  }), s(e)]
452
571
  }, e))]
453
- }) : /* @__PURE__ */ H(f, {
454
- value: r[0] ?? W,
455
- onValueChange: (e) => a(e === W ? [] : [String(e)]),
456
- children: [/* @__PURE__ */ V(h, {
572
+ }) : /* @__PURE__ */ B(p, {
573
+ value: r[0] ?? H,
574
+ onValueChange: (e) => a(e === H ? [] : [String(e)]),
575
+ children: [/* @__PURE__ */ z(g, {
457
576
  size: "sm",
458
577
  "aria-label": o("contentEditor.versionLanguage"),
459
- children: /* @__PURE__ */ V(g, { children: (e) => e === W ? o("contentEditor.chooseLanguage") : s(e) })
460
- }), /* @__PURE__ */ V(p, { children: n.map((e) => /* @__PURE__ */ V(m, {
578
+ children: /* @__PURE__ */ z(_, { children: (e) => e === H ? o("contentEditor.chooseLanguage") : s(e) })
579
+ }), /* @__PURE__ */ z(m, { children: n.map((e) => /* @__PURE__ */ z(h, {
461
580
  value: e,
462
581
  children: s(e)
463
582
  }, e)) })]
464
583
  });
465
584
  }
466
- function se({ languages: e, many: n, pending: r, onAdd: i }) {
467
- let { t: a } = t(), [s, c] = z([]);
468
- return /* @__PURE__ */ H("div", {
585
+ function pe({ languages: e, many: n, pending: r, onAdd: i }) {
586
+ let { t: a } = t(), [o, c] = L([]);
587
+ return /* @__PURE__ */ B("div", {
469
588
  className: "flex flex-wrap items-center gap-2",
470
589
  "data-ckui": "add-version",
471
- children: [/* @__PURE__ */ V(oe, {
590
+ children: [/* @__PURE__ */ z(Q, {
472
591
  languages: e,
473
- value: s,
592
+ value: o,
474
593
  many: n,
475
594
  onChange: c
476
- }), /* @__PURE__ */ V(o, {
595
+ }), /* @__PURE__ */ z(s, {
477
596
  type: "button",
478
597
  size: "sm",
479
598
  variant: "outline",
480
- disabled: r || !s.length,
599
+ disabled: r || !o.length,
481
600
  onClick: () => {
482
- i({ languages: s }), c([]);
601
+ i({ languages: o }), c([]);
483
602
  },
484
603
  children: a("contentEditor.addVersion")
485
604
  })]
486
605
  });
487
606
  }
488
- function ce({ content: e, version: r, model: i, media: a, ...s }) {
489
- let { t: c } = t(), l = I(), f = n(s.client), p = i?.kinds[e.kind], [m, h] = z(r.languages), [g, _] = z(r.traits), [S, w] = z(r.label ?? ""), [E, O] = z(r.state === "draft"), [k, A] = z(C(r.publish_at)), [M, N] = z(!!r.access), [P, F] = z(r.access ?? e.access), [L, R] = z(!1), B = y("content.save", s.onError), U = y("content.save", s.onError), W = y("offer.save", s.onError);
490
- return /* @__PURE__ */ H("div", {
607
+ function me({ content: e, version: r, model: i, media: a, ...o }) {
608
+ let { t: c } = t(), l = ne(), u = n(o.client), p = i?.kinds[e.kind], [m, h] = L(r.languages), [g, _] = L(r.traits), [v, C] = L(r.label ?? ""), [T, D] = L(r.state === "draft"), [k, A] = L(w(r.publish_at)), [j, M] = L(!!r.access), [N, te] = L(r.access ?? e.access), [P, F] = L(!1), I = b("content.save", o.onError), R = b("content.save", o.onError), V = b("offer.save", o.onError);
609
+ return /* @__PURE__ */ B("div", {
491
610
  className: "grid gap-4 pt-2",
492
611
  children: [
493
- /* @__PURE__ */ H("form", {
612
+ /* @__PURE__ */ B("form", {
494
613
  className: "grid gap-3",
495
614
  onSubmit: (t) => {
496
- t.preventDefault(), R(!1), B.run(() => f.contents.updateVersion(e.id, r.id, {
615
+ t.preventDefault(), F(!1), I.run(() => u.contents.updateVersion(e.id, r.id, {
497
616
  languages: m,
498
617
  traits: g,
499
- label: S.trim(),
500
- state: E ? "draft" : "published",
501
- publish_at: x(k),
502
- ...M ? { access: re(P) } : { clear_access: !!r.access }
503
- })).then((e) => e && R(!0));
618
+ label: v.trim(),
619
+ state: T ? "draft" : "published",
620
+ publish_at: S(k),
621
+ ...j ? { access: le(N) } : { clear_access: !!r.access }
622
+ })).then((e) => e && F(!0));
504
623
  },
505
624
  children: [
506
- /* @__PURE__ */ V(oe, {
625
+ /* @__PURE__ */ z(Q, {
507
626
  languages: i?.languages ?? [],
508
627
  value: m,
509
628
  many: p?.versions.languages === "many",
510
629
  onChange: h
511
630
  }),
512
- !!p?.versions.traits?.length && /* @__PURE__ */ H("fieldset", {
631
+ !!p?.versions.traits?.length && /* @__PURE__ */ B("fieldset", {
513
632
  className: "flex flex-wrap gap-3",
514
- children: [/* @__PURE__ */ V("legend", {
633
+ children: [/* @__PURE__ */ z("legend", {
515
634
  className: "sr-only",
516
635
  children: c("contentEditor.traits")
517
- }), p.versions.traits.map((e) => /* @__PURE__ */ H("label", {
636
+ }), p.versions.traits.map((e) => /* @__PURE__ */ B("label", {
518
637
  className: "flex items-center gap-1.5",
519
- children: [/* @__PURE__ */ V(b, {
638
+ children: [/* @__PURE__ */ z(x, {
520
639
  size: "sm",
521
640
  checked: g.includes(e),
522
641
  onCheckedChange: (t) => _(t ? [...g, e] : g.filter((t) => t !== e)),
523
- "aria-label": T(s.labels, e)
524
- }), T(s.labels, e)]
642
+ "aria-label": E(o.labels, e)
643
+ }), E(o.labels, e)]
525
644
  }, e))]
526
645
  }),
527
- /* @__PURE__ */ H("div", {
646
+ /* @__PURE__ */ B("div", {
528
647
  className: "grid gap-3 sm:grid-cols-2",
529
- children: [/* @__PURE__ */ H("div", {
648
+ children: [/* @__PURE__ */ B("div", {
530
649
  className: "grid gap-1.5",
531
- children: [/* @__PURE__ */ V(d, {
650
+ children: [/* @__PURE__ */ z(f, {
532
651
  htmlFor: `${l}-label`,
533
652
  children: c("contentEditor.versionLabel")
534
- }), /* @__PURE__ */ V(u, {
653
+ }), /* @__PURE__ */ z(d, {
535
654
  id: `${l}-label`,
536
655
  className: "h-8",
537
- value: S,
538
- onChange: (e) => w(e.target.value)
656
+ value: v,
657
+ onChange: (e) => C(e.target.value)
539
658
  })]
540
- }), /* @__PURE__ */ H("div", {
659
+ }), /* @__PURE__ */ B("div", {
541
660
  className: "grid gap-1.5",
542
- children: [/* @__PURE__ */ V(d, {
661
+ children: [/* @__PURE__ */ z(f, {
543
662
  htmlFor: `${l}-at`,
544
663
  children: c("contentEditor.versionPublishAt")
545
- }), /* @__PURE__ */ V(u, {
664
+ }), /* @__PURE__ */ z(d, {
546
665
  id: `${l}-at`,
547
666
  className: "h-8",
548
667
  type: "datetime-local",
@@ -551,97 +670,97 @@ function ce({ content: e, version: r, model: i, media: a, ...s }) {
551
670
  })]
552
671
  })]
553
672
  }),
554
- /* @__PURE__ */ H("label", {
673
+ /* @__PURE__ */ B("label", {
555
674
  className: "flex items-center gap-2",
556
- children: [/* @__PURE__ */ V(b, {
675
+ children: [/* @__PURE__ */ z(x, {
557
676
  size: "sm",
558
- checked: E,
559
- onCheckedChange: O
677
+ checked: T,
678
+ onCheckedChange: D
560
679
  }), c("contentEditor.versionDraft")]
561
680
  }),
562
- /* @__PURE__ */ H("label", {
681
+ /* @__PURE__ */ B("label", {
563
682
  className: "flex items-center gap-2",
564
- children: [/* @__PURE__ */ V(b, {
683
+ children: [/* @__PURE__ */ z(x, {
565
684
  size: "sm",
566
- checked: M,
567
- onCheckedChange: N
685
+ checked: j,
686
+ onCheckedChange: M
568
687
  }), c("contentEditor.ownAccess")]
569
688
  }),
570
- M && /* @__PURE__ */ V(X, {
571
- value: P,
572
- onChange: F,
689
+ j && /* @__PURE__ */ z(se, {
690
+ value: N,
691
+ onChange: te,
573
692
  model: i,
574
693
  kind: e.kind,
575
694
  owner: e.owner_group_id,
576
- labels: s.labels,
577
- client: f
695
+ labels: o.labels,
696
+ client: u
578
697
  }),
579
- /* @__PURE__ */ V(v, { error: B.error }),
580
- /* @__PURE__ */ H("div", {
698
+ /* @__PURE__ */ z(y, { error: I.error }),
699
+ /* @__PURE__ */ B("div", {
581
700
  className: "flex flex-wrap items-center gap-3",
582
701
  children: [
583
- /* @__PURE__ */ V(o, {
702
+ /* @__PURE__ */ z(s, {
584
703
  type: "submit",
585
704
  size: "sm",
586
- disabled: B.pending || !m.length || M && !Z(P),
587
- children: B.pending ? c("common.saving") : c("common.save")
705
+ disabled: I.pending || !m.length || j && !ce(N),
706
+ children: I.pending ? c("common.saving") : c("common.save")
588
707
  }),
589
- /* @__PURE__ */ V(q, { show: L }),
590
- /* @__PURE__ */ V(o, {
708
+ /* @__PURE__ */ z(G, { show: P }),
709
+ /* @__PURE__ */ z(s, {
591
710
  type: "button",
592
711
  size: "sm",
593
712
  variant: "destructive",
594
713
  className: "ms-auto",
595
- disabled: U.pending,
596
- onClick: () => void U.run(() => f.contents.removeVersion(e.id, r.id)),
714
+ disabled: R.pending,
715
+ onClick: () => void R.run(() => u.contents.removeVersion(e.id, r.id)),
597
716
  children: c("contentEditor.deleteVersion")
598
717
  })
599
718
  ]
600
719
  }),
601
- /* @__PURE__ */ V(v, { error: U.error })
720
+ /* @__PURE__ */ z(y, { error: R.error })
602
721
  ]
603
722
  }),
604
- /* @__PURE__ */ V(D, {
723
+ /* @__PURE__ */ z(O, {
605
724
  offer: r.offer,
606
- pending: W.pending,
607
- onSell: (t) => void W.run(() => f.offers.sell({
725
+ pending: V.pending,
726
+ onSell: (t) => void V.run(() => u.offers.sell({
608
727
  content: e.id,
609
728
  version: r.id
610
729
  }, t)),
611
- onWithdraw: () => void W.run(() => f.offers.withdraw({
730
+ onWithdraw: () => void V.run(() => u.offers.withdraw({
612
731
  content: e.id,
613
732
  version: r.id
614
733
  }))
615
734
  }),
616
- /* @__PURE__ */ V(v, { error: W.error }),
617
- p?.segments && /* @__PURE__ */ V($, {
735
+ /* @__PURE__ */ z(y, { error: V.error }),
736
+ p?.segments && /* @__PURE__ */ z($, {
618
737
  content: e,
619
738
  version: r,
620
- ...s
739
+ ...o
621
740
  }),
622
- a && /* @__PURE__ */ V(le, {
741
+ a && /* @__PURE__ */ z(he, {
623
742
  content: e,
624
743
  version: r,
625
- ...s
744
+ ...o
626
745
  }),
627
- a && /* @__PURE__ */ V(ue, {
746
+ a && /* @__PURE__ */ z(ge, {
628
747
  content: e,
629
748
  version: r,
630
749
  model: i,
631
- ...s
750
+ ...o
632
751
  }),
633
- a && p?.presentation === "reader" && /* @__PURE__ */ V(j, {
752
+ a && p?.presentation === "reader" && /* @__PURE__ */ z(ee, {
634
753
  content: e.id,
635
754
  version: r.id,
636
- client: s.client,
637
- onError: s.onError
755
+ client: o.client,
756
+ onError: o.onError
638
757
  })
639
758
  ]
640
759
  });
641
760
  }
642
- function le({ content: e, version: r, ...i }) {
643
- let { t: s } = t(), c = n(i.client), { presets: l } = a({ client: c }), u = y("content.save", i.onError), d = R(null), [f, p] = z(null);
644
- if (F(() => () => void (f && URL.revokeObjectURL(f)), [f]), !l.some((t) => t.kind === e.kind && t.name === "cover")) return null;
761
+ function he({ content: e, version: r, ...i }) {
762
+ let { t: a } = t(), c = n(i.client), { presets: l } = o({ client: c }), u = b("content.save", i.onError), d = I(null), [f, p] = L(null);
763
+ if (P(() => () => void (f && URL.revokeObjectURL(f)), [f]), !l.some((t) => t.kind === e.kind && t.name === "cover")) return null;
645
764
  let m = f ?? r.cover?.url, h = (t) => void u.run(async () => {
646
765
  if (!t) return p(null), c.contents.setCover(e.id, r.id, null);
647
766
  let n = {
@@ -651,47 +770,47 @@ function le({ content: e, version: r, ...i }) {
651
770
  }, i = await c.media.uploadNamed(n, t, { path: await c.media.presetPath(e.kind, "cover", t) }), a = await c.contents.setCover(e.id, r.id, i.name);
652
771
  return typeof URL.createObjectURL == "function" && p(URL.createObjectURL(t)), a;
653
772
  });
654
- return /* @__PURE__ */ H("div", {
773
+ return /* @__PURE__ */ B("div", {
655
774
  className: "grid gap-1.5",
656
775
  "data-ckui": "version-cover",
657
776
  children: [
658
- /* @__PURE__ */ V("span", {
777
+ /* @__PURE__ */ z("span", {
659
778
  className: "text-sm font-medium",
660
- children: s("contentManager.cover")
779
+ children: a("contentManager.cover")
661
780
  }),
662
- /* @__PURE__ */ H("div", {
781
+ /* @__PURE__ */ B("div", {
663
782
  className: "flex flex-wrap items-center gap-3",
664
783
  children: [
665
- m ? /* @__PURE__ */ V("img", {
784
+ m ? /* @__PURE__ */ z("img", {
666
785
  src: m,
667
786
  alt: "",
668
787
  className: "h-20 w-36 rounded-md border border-border object-cover"
669
- }) : /* @__PURE__ */ V("span", {
788
+ }) : /* @__PURE__ */ z("span", {
670
789
  className: "text-muted-foreground",
671
- children: s("contentManager.noCover")
790
+ children: a("contentManager.noCover")
672
791
  }),
673
- /* @__PURE__ */ V(o, {
792
+ /* @__PURE__ */ z(s, {
674
793
  type: "button",
675
794
  size: "sm",
676
795
  variant: "outline",
677
796
  disabled: u.pending,
678
797
  onClick: () => d.current?.click(),
679
- children: s(m ? "pollEditor.replaceImage" : "contentManager.addCover")
798
+ children: a(m ? "pollEditor.replaceImage" : "contentManager.addCover")
680
799
  }),
681
- r.cover?.image && /* @__PURE__ */ V(o, {
800
+ r.cover?.image && /* @__PURE__ */ z(s, {
682
801
  type: "button",
683
802
  size: "sm",
684
803
  variant: "ghost",
685
804
  disabled: u.pending,
686
805
  onClick: () => h(null),
687
- children: s("pollEditor.removeImage")
806
+ children: a("pollEditor.removeImage")
688
807
  }),
689
- /* @__PURE__ */ V("input", {
808
+ /* @__PURE__ */ z("input", {
690
809
  ref: d,
691
810
  type: "file",
692
811
  accept: "image/*",
693
812
  hidden: !0,
694
- "aria-label": s("contentManager.cover"),
813
+ "aria-label": a("contentManager.cover"),
695
814
  onChange: (e) => {
696
815
  let t = e.target.files?.[0];
697
816
  e.target.value = "", t && h(t);
@@ -699,12 +818,12 @@ function le({ content: e, version: r, ...i }) {
699
818
  })
700
819
  ]
701
820
  }),
702
- /* @__PURE__ */ V(v, { error: u.error })
821
+ /* @__PURE__ */ z(y, { error: u.error })
703
822
  ]
704
823
  });
705
824
  }
706
- function ue({ content: n, version: r, model: a, ...o }) {
707
- let { t: s } = t(), l = e(), u = L(() => ({
825
+ function ge({ content: n, version: r, model: i, ...o }) {
826
+ let { t: s } = t(), c = e(), u = F(() => ({
708
827
  kind: n.kind,
709
828
  id: n.id,
710
829
  version: r.id
@@ -712,25 +831,25 @@ function ue({ content: n, version: r, model: a, ...o }) {
712
831
  n.kind,
713
832
  n.id,
714
833
  r.id
715
- ]), d = i(u, {
834
+ ]), d = a(u, {
716
835
  editor: !0,
717
836
  client: o.client
718
- }), f = L(() => (a?.languages ?? []).map((e) => ({
837
+ }), f = F(() => (i?.languages ?? []).map((e) => ({
719
838
  value: e,
720
- label: l(e)
721
- })), [a, l]);
722
- return !d.read && d.loading ? /* @__PURE__ */ V(_, { className: "h-24 w-full" }) : d.read?.uploads && P(d.read.uploads).source ? /* @__PURE__ */ V(N, {
839
+ label: c(e)
840
+ })), [i, c]);
841
+ return !d.read && d.loading ? /* @__PURE__ */ z(v, { className: "h-24 w-full" }) : d.read?.uploads && te(d.read.uploads).source ? /* @__PURE__ */ z(N, {
723
842
  item: u,
724
843
  languages: f,
725
844
  client: o.client,
726
845
  onError: o.onError
727
- }) : /* @__PURE__ */ H(B, { children: [/* @__PURE__ */ V(c, {
846
+ }) : /* @__PURE__ */ B(R, { children: [/* @__PURE__ */ z(l, {
728
847
  item: u,
729
848
  commit: r.live ? "manual" : "auto",
730
849
  label: s("contentEditor.media"),
731
850
  client: o.client,
732
851
  onError: o.onError
733
- }), a?.kinds[n.kind]?.presentation === "reader" && /* @__PURE__ */ V(M, {
852
+ }), i?.kinds[n.kind]?.presentation === "reader" && /* @__PURE__ */ z(M, {
734
853
  content: n.id,
735
854
  version: r.id,
736
855
  client: o.client,
@@ -738,47 +857,47 @@ function ue({ content: n, version: r, model: a, ...o }) {
738
857
  })] });
739
858
  }
740
859
  function $({ content: e, version: r, ...i }) {
741
- let { t: a } = t(), s = n(i.client), c = () => r.segments.map((e) => ({
860
+ let { t: a } = t(), o = n(i.client), c = () => r.segments.map((e) => ({
742
861
  title: e.title ?? "",
743
862
  start: String(e.start),
744
863
  end: String(e.end),
745
- release: C(e.release_at)
746
- })), [l, d] = z(c);
747
- F(() => d(c()), [JSON.stringify(r.segments)]);
748
- let [f, p] = z(!1), m = y("content.save", i.onError), h = (e, t) => {
749
- p(!1), d((n) => n.map((n, r) => r === e ? {
864
+ release: w(e.release_at)
865
+ })), [l, u] = L(c);
866
+ P(() => u(c()), [JSON.stringify(r.segments)]);
867
+ let [f, p] = L(!1), m = b("content.save", i.onError), h = (e, t) => {
868
+ p(!1), u((n) => n.map((n, r) => r === e ? {
750
869
  ...n,
751
870
  ...t
752
871
  } : n));
753
872
  }, g = l.every((e) => /^\d+$/.test(e.start) && /^\d+$/.test(e.end) && Number(e.end) > Number(e.start));
754
- return /* @__PURE__ */ H("div", {
873
+ return /* @__PURE__ */ B("div", {
755
874
  className: "grid gap-2",
756
875
  "data-ckui": "segments-editor",
757
876
  children: [
758
- /* @__PURE__ */ V("h4", {
877
+ /* @__PURE__ */ z("h4", {
759
878
  className: "text-sm font-medium",
760
879
  children: a("contentEditor.segments")
761
880
  }),
762
- l.length === 0 && /* @__PURE__ */ V("p", {
881
+ l.length === 0 && /* @__PURE__ */ z("p", {
763
882
  className: "text-muted-foreground",
764
883
  children: a("contentEditor.noSegments")
765
884
  }),
766
- l.map((e, t) => /* @__PURE__ */ H("div", {
885
+ l.map((e, t) => /* @__PURE__ */ B("div", {
767
886
  className: "flex flex-wrap items-center gap-2",
768
887
  "data-ckui": "segment-row",
769
888
  children: [
770
- /* @__PURE__ */ V("span", {
889
+ /* @__PURE__ */ z("span", {
771
890
  className: "w-6 text-xs text-muted-foreground tabular-nums",
772
891
  children: t + 1
773
892
  }),
774
- /* @__PURE__ */ V(u, {
893
+ /* @__PURE__ */ z(d, {
775
894
  className: "h-8 w-40",
776
895
  "aria-label": a("contentEditor.segmentTitle", { n: t + 1 }),
777
896
  placeholder: a("contentEditor.segmentTitlePlaceholder"),
778
897
  value: e.title,
779
898
  onChange: (e) => h(t, { title: e.target.value })
780
899
  }),
781
- /* @__PURE__ */ V(u, {
900
+ /* @__PURE__ */ z(d, {
782
901
  className: "h-8 w-20",
783
902
  type: "number",
784
903
  min: 0,
@@ -786,11 +905,11 @@ function $({ content: e, version: r, ...i }) {
786
905
  value: e.start,
787
906
  onChange: (e) => h(t, { start: e.target.value })
788
907
  }),
789
- /* @__PURE__ */ V("span", {
908
+ /* @__PURE__ */ z("span", {
790
909
  "aria-hidden": !0,
791
910
  children: "–"
792
911
  }),
793
- /* @__PURE__ */ V(u, {
912
+ /* @__PURE__ */ z(d, {
794
913
  className: "h-8 w-20",
795
914
  type: "number",
796
915
  min: 1,
@@ -798,32 +917,32 @@ function $({ content: e, version: r, ...i }) {
798
917
  value: e.end,
799
918
  onChange: (e) => h(t, { end: e.target.value })
800
919
  }),
801
- /* @__PURE__ */ V(u, {
920
+ /* @__PURE__ */ z(d, {
802
921
  className: "h-8 w-48",
803
922
  type: "datetime-local",
804
923
  "aria-label": a("contentEditor.segmentRelease", { n: t + 1 }),
805
924
  value: e.release,
806
925
  onChange: (e) => h(t, { release: e.target.value })
807
926
  }),
808
- /* @__PURE__ */ V(o, {
927
+ /* @__PURE__ */ z(s, {
809
928
  type: "button",
810
929
  size: "xs",
811
930
  variant: "ghost",
812
- onClick: () => d((e) => e.filter((e, n) => n !== t)),
931
+ onClick: () => u((e) => e.filter((e, n) => n !== t)),
813
932
  children: a("common.remove")
814
933
  })
815
934
  ]
816
935
  }, t)),
817
- /* @__PURE__ */ H("div", {
936
+ /* @__PURE__ */ B("div", {
818
937
  className: "flex flex-wrap items-center gap-2",
819
938
  children: [
820
- /* @__PURE__ */ V(o, {
939
+ /* @__PURE__ */ z(s, {
821
940
  type: "button",
822
941
  size: "sm",
823
942
  variant: "outline",
824
943
  onClick: () => {
825
944
  let e = l.at(-1), t = e && Number(e.end) || 0;
826
- d((e) => [...e, {
945
+ u((e) => [...e, {
827
946
  title: "",
828
947
  start: String(t),
829
948
  end: String(t + 1),
@@ -832,7 +951,7 @@ function $({ content: e, version: r, ...i }) {
832
951
  },
833
952
  children: a("contentEditor.addSegment")
834
953
  }),
835
- /* @__PURE__ */ V(o, {
954
+ /* @__PURE__ */ z(s, {
836
955
  type: "button",
837
956
  size: "sm",
838
957
  disabled: m.pending || !g,
@@ -843,49 +962,49 @@ function $({ content: e, version: r, ...i }) {
843
962
  title: e.title.trim() || void 0,
844
963
  start: Number(e.start),
845
964
  end: Number(e.end),
846
- release_at: x(e.release),
965
+ release_at: S(e.release),
847
966
  released: !1
848
967
  }));
849
- m.run(() => s.contents.setSegments(e.id, r.id, t)).then((e) => e && p(!0));
968
+ m.run(() => o.contents.setSegments(e.id, r.id, t)).then((e) => e && p(!0));
850
969
  },
851
970
  children: a("contentEditor.saveSegments")
852
971
  }),
853
- /* @__PURE__ */ V(q, { show: f })
972
+ /* @__PURE__ */ z(G, { show: f })
854
973
  ]
855
974
  }),
856
- /* @__PURE__ */ V(v, { error: m.error })
975
+ /* @__PURE__ */ z(y, { error: m.error })
857
976
  ]
858
977
  });
859
978
  }
860
- function de({ content: t, ...n }) {
861
- let r = e(), i = L(() => t.versions.map((e) => ({
979
+ function _e({ content: t, ...n }) {
980
+ let r = e(), i = F(() => t.versions.map((e) => ({
862
981
  id: e.id,
863
- label: Q(e, r, n.labels)
982
+ label: Z(e, r, n.labels)
864
983
  })), [
865
984
  t.versions,
866
985
  r,
867
986
  n.labels
868
- ]), { spec: a } = J(t.kind, n.client);
869
- return /* @__PURE__ */ H("div", {
870
- className: U("grid gap-6", n.className),
987
+ ]), { spec: a } = K(t.kind, n.client);
988
+ return /* @__PURE__ */ B("div", {
989
+ className: V("grid gap-6", n.className),
871
990
  "data-ckui": "content-sections",
872
991
  children: [
873
- /* @__PURE__ */ V(Y, {
992
+ /* @__PURE__ */ z(X, {
874
993
  content: t,
875
994
  ...n
876
995
  }),
877
- /* @__PURE__ */ V(ie, {
996
+ /* @__PURE__ */ z(ue, {
878
997
  content: t,
879
998
  ...n
880
999
  }),
881
- /* @__PURE__ */ V(ae, {
1000
+ /* @__PURE__ */ z(fe, {
882
1001
  content: t,
883
1002
  ...n
884
1003
  }),
885
- !!a?.entities?.length && /* @__PURE__ */ V("section", {
1004
+ !!a?.entities?.length && /* @__PURE__ */ z("section", {
886
1005
  className: "grid gap-3 border-t border-border pt-4",
887
1006
  "data-ckui": "content-groups",
888
- children: /* @__PURE__ */ V(A, {
1007
+ children: /* @__PURE__ */ z(j, {
889
1008
  management: n.management,
890
1009
  content: t.id,
891
1010
  contentKind: t.kind,
@@ -899,6 +1018,6 @@ function de({ content: t, ...n }) {
899
1018
  });
900
1019
  }
901
1020
  //#endregion
902
- export { ie as AccessEditor, Y as ContentDetailsEditor, de as ContentSections, $ as SegmentsEditor, le as VersionCover, ae as VersionsEditor, Q as versionLabel };
1021
+ export { ue as AccessEditor, X as ContentDetailsEditor, _e as ContentSections, $ as SegmentsEditor, he as VersionCover, fe as VersionsEditor, Z as versionLabel };
903
1022
 
904
1023
  //# sourceMappingURL=editors.js.map