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