@vespercms/admin 0.0.0-stage → 0.1.0-next.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 (207) hide show
  1. package/README.md +119 -2
  2. package/dist/BodyEditor-_mkh0BSQ.js +3047 -0
  3. package/dist/a11y/FieldNotes.d.ts +23 -0
  4. package/dist/a11y/NotesDrawer.d.ts +23 -0
  5. package/dist/a11y/pdf.d.ts +3 -0
  6. package/dist/a11y/run.d.ts +3 -0
  7. package/dist/a11y/useNotes.d.ts +28 -0
  8. package/dist/app/App.d.ts +2 -0
  9. package/dist/app/Screen.d.ts +88 -0
  10. package/dist/app/UserMenu.d.ts +7 -0
  11. package/dist/app/api.d.ts +75 -0
  12. package/dist/app/appearance.d.ts +10 -0
  13. package/dist/app/browser-api.d.ts +17 -0
  14. package/dist/app/collection-icon.d.ts +12 -0
  15. package/dist/app/context.d.ts +23 -0
  16. package/dist/app/entries-changed.d.ts +11 -0
  17. package/dist/app/file-url.d.ts +13 -0
  18. package/dist/app/format.d.ts +4 -0
  19. package/dist/app/idb.d.ts +7 -0
  20. package/dist/app/load.d.ts +16 -0
  21. package/dist/app/media.d.ts +5 -0
  22. package/dist/app/navigation.d.ts +4 -0
  23. package/dist/app/pane-context.d.ts +19 -0
  24. package/dist/app/panes.d.ts +14 -0
  25. package/dist/app/router.d.ts +62 -0
  26. package/dist/body/BodyEditor.d.ts +42 -0
  27. package/dist/body/TableView.d.ts +2 -0
  28. package/dist/body/catalog.d.ts +47 -0
  29. package/dist/body/checks.d.ts +15 -0
  30. package/dist/body/chips.d.ts +31 -0
  31. package/dist/body/commands.d.ts +31 -0
  32. package/dist/body/document.d.ts +42 -0
  33. package/dist/body/insert.d.ts +69 -0
  34. package/dist/body/nodes.d.ts +38 -0
  35. package/dist/body/reveal.d.ts +13 -0
  36. package/dist/body/scroll.d.ts +16 -0
  37. package/dist/body/settings.d.ts +19 -0
  38. package/dist/body/shortcuts.d.ts +13 -0
  39. package/dist/body/table.d.ts +31 -0
  40. package/dist/body/ui.d.ts +30 -0
  41. package/dist/body/views.d.ts +9 -0
  42. package/dist/checks-C-0xDu-I.js +57 -0
  43. package/dist/cloud/CloudGate.d.ts +14 -0
  44. package/dist/cloud/access.d.ts +14 -0
  45. package/dist/cloud/changes.d.ts +26 -0
  46. package/dist/cloud/connection.d.ts +100 -0
  47. package/dist/cloud/editor.d.ts +44 -0
  48. package/dist/cloud/session.d.ts +62 -0
  49. package/dist/cloud/storage.d.ts +45 -0
  50. package/dist/editor/Field.d.ts +24 -0
  51. package/dist/editor/PagePicker.d.ts +20 -0
  52. package/dist/editor/arrange.d.ts +13 -0
  53. package/dist/editor/context.d.ts +23 -0
  54. package/dist/editor/copy.d.ts +9 -0
  55. package/dist/editor/reveal.d.ts +7 -0
  56. package/dist/editor/target.d.ts +21 -0
  57. package/dist/editor/values.d.ts +18 -0
  58. package/dist/geo-map-CT3OGD7O.js +110 -0
  59. package/dist/github/GitHubGate.d.ts +15 -0
  60. package/dist/github/api.d.ts +20 -0
  61. package/dist/github/cache.d.ts +2 -0
  62. package/dist/github/session.d.ts +35 -0
  63. package/dist/index.d.ts +3 -0
  64. package/dist/markdown-4fVeej3c.js +211 -0
  65. package/dist/media/MediaPicker.d.ts +28 -0
  66. package/dist/media/file-icon.d.ts +3 -0
  67. package/dist/media/formats.d.ts +23 -0
  68. package/dist/media/hygiene.d.ts +37 -0
  69. package/dist/media/upload.d.ts +31 -0
  70. package/dist/mount.d.ts +3 -0
  71. package/dist/pdf-m5s_uXJ3.js +24 -0
  72. package/dist/run-y4XRkg17.js +7 -0
  73. package/dist/schedule/ScheduleDialog.d.ts +28 -0
  74. package/dist/schedule/ScheduleSummary.d.ts +12 -0
  75. package/dist/schedule/ScheduledView.d.ts +8 -0
  76. package/dist/schedule/cloud.d.ts +21 -0
  77. package/dist/schedule/now.d.ts +5 -0
  78. package/dist/schedule/times.d.ts +35 -0
  79. package/dist/screens/EntryEditor.d.ts +13 -0
  80. package/dist/screens/EntryList.d.ts +16 -0
  81. package/dist/screens/Home.d.ts +6 -0
  82. package/dist/screens/ListPane.d.ts +6 -0
  83. package/dist/screens/MediaBrowser.d.ts +7 -0
  84. package/dist/screens/NotFound.d.ts +3 -0
  85. package/dist/screens/PageTree.d.ts +10 -0
  86. package/dist/screens/Redirects.d.ts +1 -0
  87. package/dist/screens/Unavailable.d.ts +8 -0
  88. package/dist/screens/status.d.ts +36 -0
  89. package/dist/shortcuts-CarKeDqp.js +4666 -0
  90. package/dist/studio.css +3 -0
  91. package/dist/studio.js +6449 -0
  92. package/dist/types.d.ts +76 -0
  93. package/dist/widgets/basic.d.ts +25 -0
  94. package/dist/widgets/blank-date.d.ts +8 -0
  95. package/dist/widgets/crops.d.ts +43 -0
  96. package/dist/widgets/focal-point.d.ts +15 -0
  97. package/dist/widgets/geo-map.d.ts +10 -0
  98. package/dist/widgets/geo.d.ts +16 -0
  99. package/dist/widgets/group.d.ts +41 -0
  100. package/dist/widgets/icon.d.ts +9 -0
  101. package/dist/widgets/image.d.ts +16 -0
  102. package/dist/widgets/markdown-lazy.d.ts +2 -0
  103. package/dist/widgets/markdown.d.ts +2 -0
  104. package/dist/widgets/reference.d.ts +12 -0
  105. package/dist/widgets/registry.d.ts +32 -0
  106. package/dist/widgets/special.d.ts +20 -0
  107. package/dist/widgets/union.d.ts +36 -0
  108. package/package.json +63 -4
  109. package/src/a11y/FieldNotes.tsx +56 -0
  110. package/src/a11y/NotesDrawer.tsx +81 -0
  111. package/src/a11y/pdf.ts +45 -0
  112. package/src/a11y/run.ts +12 -0
  113. package/src/a11y/useNotes.ts +139 -0
  114. package/src/app/App.tsx +156 -0
  115. package/src/app/Screen.tsx +416 -0
  116. package/src/app/UserMenu.tsx +95 -0
  117. package/src/app/api.ts +176 -0
  118. package/src/app/appearance.ts +54 -0
  119. package/src/app/browser-api.ts +173 -0
  120. package/src/app/collection-icon.ts +15 -0
  121. package/src/app/context.tsx +32 -0
  122. package/src/app/entries-changed.ts +48 -0
  123. package/src/app/file-url.tsx +44 -0
  124. package/src/app/format.ts +39 -0
  125. package/src/app/idb.ts +82 -0
  126. package/src/app/load.ts +40 -0
  127. package/src/app/media.ts +20 -0
  128. package/src/app/navigation.ts +4 -0
  129. package/src/app/pane-context.ts +25 -0
  130. package/src/app/panes.tsx +513 -0
  131. package/src/app/router.ts +158 -0
  132. package/src/body/BodyEditor.tsx +1139 -0
  133. package/src/body/TableView.tsx +700 -0
  134. package/src/body/catalog.ts +198 -0
  135. package/src/body/checks.ts +83 -0
  136. package/src/body/chips.ts +150 -0
  137. package/src/body/commands.ts +191 -0
  138. package/src/body/document.ts +388 -0
  139. package/src/body/insert.tsx +301 -0
  140. package/src/body/nodes.ts +287 -0
  141. package/src/body/reveal.ts +93 -0
  142. package/src/body/scroll.ts +53 -0
  143. package/src/body/settings.tsx +510 -0
  144. package/src/body/shortcuts.ts +31 -0
  145. package/src/body/table.ts +192 -0
  146. package/src/body/ui.ts +77 -0
  147. package/src/body/views.tsx +268 -0
  148. package/src/build.ts +6 -0
  149. package/src/cloud/CloudGate.tsx +245 -0
  150. package/src/cloud/access.ts +52 -0
  151. package/src/cloud/changes.tsx +474 -0
  152. package/src/cloud/connection.ts +281 -0
  153. package/src/cloud/editor.tsx +250 -0
  154. package/src/cloud/session.ts +289 -0
  155. package/src/cloud/storage.ts +212 -0
  156. package/src/editor/Field.tsx +182 -0
  157. package/src/editor/PagePicker.tsx +102 -0
  158. package/src/editor/arrange.ts +98 -0
  159. package/src/editor/context.tsx +31 -0
  160. package/src/editor/copy.ts +30 -0
  161. package/src/editor/reveal.ts +38 -0
  162. package/src/editor/target.ts +104 -0
  163. package/src/editor/values.ts +71 -0
  164. package/src/github/GitHubGate.tsx +298 -0
  165. package/src/github/api.ts +81 -0
  166. package/src/github/cache.ts +64 -0
  167. package/src/github/session.ts +146 -0
  168. package/src/index.ts +10 -0
  169. package/src/media/MediaPicker.tsx +302 -0
  170. package/src/media/file-icon.ts +17 -0
  171. package/src/media/formats.ts +262 -0
  172. package/src/media/hygiene.ts +220 -0
  173. package/src/media/upload.ts +47 -0
  174. package/src/mount.tsx +20 -0
  175. package/src/schedule/ScheduleDialog.tsx +303 -0
  176. package/src/schedule/ScheduleSummary.tsx +59 -0
  177. package/src/schedule/ScheduledView.tsx +294 -0
  178. package/src/schedule/cloud.ts +66 -0
  179. package/src/schedule/now.ts +18 -0
  180. package/src/schedule/times.ts +122 -0
  181. package/src/screens/EntryEditor.tsx +1817 -0
  182. package/src/screens/EntryList.tsx +272 -0
  183. package/src/screens/Home.tsx +131 -0
  184. package/src/screens/ListPane.tsx +477 -0
  185. package/src/screens/MediaBrowser.tsx +253 -0
  186. package/src/screens/NotFound.tsx +19 -0
  187. package/src/screens/PageTree.tsx +738 -0
  188. package/src/screens/Redirects.tsx +522 -0
  189. package/src/screens/Unavailable.tsx +27 -0
  190. package/src/screens/status.tsx +104 -0
  191. package/src/studio.css +168 -0
  192. package/src/types.ts +82 -0
  193. package/src/widgets/basic.tsx +315 -0
  194. package/src/widgets/blank-date.ts +32 -0
  195. package/src/widgets/crops.tsx +399 -0
  196. package/src/widgets/focal-point.tsx +240 -0
  197. package/src/widgets/geo-map.tsx +160 -0
  198. package/src/widgets/geo.tsx +170 -0
  199. package/src/widgets/group.tsx +827 -0
  200. package/src/widgets/icon.tsx +47 -0
  201. package/src/widgets/image.tsx +407 -0
  202. package/src/widgets/markdown-lazy.tsx +22 -0
  203. package/src/widgets/markdown.tsx +267 -0
  204. package/src/widgets/reference.tsx +196 -0
  205. package/src/widgets/registry.ts +104 -0
  206. package/src/widgets/special.tsx +290 -0
  207. package/src/widgets/union.tsx +233 -0
@@ -0,0 +1,4666 @@
1
+ import { Component as e, Suspense as t, createContext as n, createElement as r, lazy as i, useCallback as a, useContext as o, useEffect as s, useLayoutEffect as c, useMemo as l, useRef as u, useState as d } from "react";
2
+ import { Button as f, Cell as p, CheckboxButton as m, CheckboxField as h, Collection as g, Column as _, ComboBox as v, Dialog as y, Disclosure as b, DisclosurePanel as x, FieldError as S, FileTrigger as C, Header as w, Heading as T, Input as E, Label as ee, Link as te, ListBox as D, ListBoxItem as O, Menu as ne, MenuItem as k, MenuSection as A, MenuTrigger as re, Modal as j, ModalOverlay as M, Popover as N, RadioButton as P, RadioField as ie, RadioGroup as F, Row as ae, Select as oe, SelectValue as se, Separator as ce, SubmenuTrigger as le, SwitchButton as ue, SwitchField as I, Tab as de, TabList as fe, TabPanel as pe, Table as me, TableBody as he, TableHeader as ge, Tabs as _e, Tag as ve, TagGroup as ye, TagList as be, Text as xe, TextArea as Se, TextField as Ce, ToggleButton as we, Toolbar as Te, Tooltip as Ee, TooltipTrigger as De, Tree as Oe, TreeItem as ke, TreeItemContent as Ae, useDrag as je, useDragAndDrop as Me, useDrop as Ne } from "react-aria-components";
3
+ import { Fragment as L, jsx as R, jsxs as z } from "react/jsx-runtime";
4
+ import { CENTER as Pe, UPLOAD_MAX_BYTES as Fe, UPLOAD_WARN_BYTES as Ie, cropForRatio as Le, dirOf as Re, dragCorner as ze, extensionOf as Be, formatYamlSnippet as Ve, fromWallTime as He, gitBlobSha as Ue, humanize as We, imageValueOf as Ge, isImagePath as Ke, isPlainObject as B, isoWithOffset as qe, mediaReference as Je, moveRect as Ye, offsetOf as Xe, parseYamlSnippet as Ze, ratioLabel as Qe, resizeRect as $e, resolveMediaPath as et, resolveTimeZone as tt, roundFocus as nt, roundRect as rt, siteRatios as it, slugify as at, variantFor as ot, wallTime as st, zoneName as ct } from "@vespercms/core";
5
+ import lt from "dompurify";
6
+ //#region ../../node_modules/lucide/dist/esm/icons/accessibility.mjs
7
+ var ut = [
8
+ ["circle", {
9
+ cx: "16",
10
+ cy: "4",
11
+ r: "1"
12
+ }],
13
+ ["path", { d: "m18 19 1-7-6 1" }],
14
+ ["path", { d: "m5 8 3-3 5.5 3-2.36 3.5" }],
15
+ ["path", { d: "M4.24 14.5a5 5 0 0 0 6.88 6" }],
16
+ ["path", { d: "M13.76 17.5a5 5 0 0 0-6.88-6" }]
17
+ ], dt = [["path", { d: "M12 5v14" }], ["path", { d: "m19 12-7 7-7-7" }]], ft = [["path", { d: "m12 19-7-7 7-7" }], ["path", { d: "M19 12H5" }]], pt = [
18
+ ["path", { d: "m16 3 4 4-4 4" }],
19
+ ["path", { d: "M20 7H4" }],
20
+ ["path", { d: "m8 21-4-4 4-4" }],
21
+ ["path", { d: "M4 17h16" }]
22
+ ], mt = [["path", { d: "m5 12 7-7 7 7" }], ["path", { d: "M12 19V5" }]], ht = [["path", { d: "M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" }]], gt = [
23
+ ["path", { d: "M16 14v2.2l1.6 1" }],
24
+ ["path", { d: "M16 2v3" }],
25
+ ["path", { d: "M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338" }],
26
+ ["path", { d: "M3 9h5.859" }],
27
+ ["path", { d: "M8 2v3" }],
28
+ ["circle", {
29
+ cx: "16",
30
+ cy: "16",
31
+ r: "6"
32
+ }]
33
+ ], _t = [
34
+ ["path", { d: "M8 2v3" }],
35
+ ["path", { d: "M16 2v3" }],
36
+ ["rect", {
37
+ x: "3",
38
+ y: "3",
39
+ width: "18",
40
+ height: "18",
41
+ rx: "2"
42
+ }],
43
+ ["path", { d: "M3 9h18" }],
44
+ ["path", { d: "m14 13-4 4" }],
45
+ ["path", { d: "m10 13 4 4" }]
46
+ ], vt = [["path", { d: "M20 6 9 17l-5-5" }]], yt = [["path", { d: "m6 9 6 6 6-6" }]], bt = [
47
+ ["circle", {
48
+ cx: "12",
49
+ cy: "12",
50
+ r: "10"
51
+ }],
52
+ ["line", {
53
+ x1: "12",
54
+ x2: "12",
55
+ y1: "8",
56
+ y2: "12"
57
+ }],
58
+ ["line", {
59
+ x1: "12",
60
+ x2: "12.01",
61
+ y1: "16",
62
+ y2: "16"
63
+ }]
64
+ ], xt = [["path", { d: "m16 18 6-6-6-6" }], ["path", { d: "m8 6-6 6 6 6" }]], St = [["rect", {
65
+ width: "14",
66
+ height: "14",
67
+ x: "8",
68
+ y: "8",
69
+ rx: "2",
70
+ ry: "2"
71
+ }], ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" }]], Ct = [
72
+ ["circle", {
73
+ cx: "12",
74
+ cy: "12",
75
+ r: "1"
76
+ }],
77
+ ["circle", {
78
+ cx: "19",
79
+ cy: "12",
80
+ r: "1"
81
+ }],
82
+ ["circle", {
83
+ cx: "5",
84
+ cy: "12",
85
+ r: "1"
86
+ }]
87
+ ], wt = [
88
+ ["path", { d: "M15 3h6v6" }],
89
+ ["path", { d: "M10 14 21 3" }],
90
+ ["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }]
91
+ ], Tt = [
92
+ ["path", { d: "M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5" }],
93
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5" }],
94
+ ["path", { d: "M8 12v-1" }],
95
+ ["path", { d: "M8 18v-2" }],
96
+ ["path", { d: "M8 7V6" }],
97
+ ["circle", {
98
+ cx: "8",
99
+ cy: "20",
100
+ r: "2"
101
+ }]
102
+ ], Et = [
103
+ ["path", { d: "M11.65 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v10.35" }],
104
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5" }],
105
+ ["path", { d: "M8 20v-7l3 1.474" }],
106
+ ["circle", {
107
+ cx: "6",
108
+ cy: "20",
109
+ r: "2"
110
+ }]
111
+ ], Dt = [
112
+ ["path", { d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" }],
113
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5" }],
114
+ ["path", { d: "M15.033 13.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56v-4.704a.645.645 0 0 1 .967-.56z" }]
115
+ ], Ot = [
116
+ ["path", { d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" }],
117
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5" }],
118
+ ["path", { d: "M9 15h6" }],
119
+ ["path", { d: "M12 18v-6" }]
120
+ ], kt = [
121
+ ["path", { d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" }],
122
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5" }],
123
+ ["path", { d: "M8 13h2" }],
124
+ ["path", { d: "M14 13h2" }],
125
+ ["path", { d: "M8 17h2" }],
126
+ ["path", { d: "M14 17h2" }]
127
+ ], At = [
128
+ ["path", { d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" }],
129
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5" }],
130
+ ["path", { d: "M10 9H8" }],
131
+ ["path", { d: "M16 13H8" }],
132
+ ["path", { d: "M16 17H8" }]
133
+ ], jt = [
134
+ ["path", { d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" }],
135
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5" }],
136
+ ["path", { d: "M12 12v6" }],
137
+ ["path", { d: "m15 15-3-3-3 3" }]
138
+ ], Mt = [["path", { d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" }], ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5" }]], Nt = [
139
+ ["path", { d: "M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1" }],
140
+ ["path", { d: "M2 13h10" }],
141
+ ["path", { d: "m9 16 3-3-3-3" }]
142
+ ], Pt = [
143
+ ["path", { d: "M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z" }],
144
+ ["path", { d: "M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z" }],
145
+ ["path", { d: "M3 5a2 2 0 0 0 2 2h3" }],
146
+ ["path", { d: "M3 3v13a2 2 0 0 0 2 2h3" }]
147
+ ], Ft = [
148
+ ["circle", {
149
+ cx: "9",
150
+ cy: "12",
151
+ r: "1"
152
+ }],
153
+ ["circle", {
154
+ cx: "9",
155
+ cy: "5",
156
+ r: "1"
157
+ }],
158
+ ["circle", {
159
+ cx: "9",
160
+ cy: "19",
161
+ r: "1"
162
+ }],
163
+ ["circle", {
164
+ cx: "15",
165
+ cy: "12",
166
+ r: "1"
167
+ }],
168
+ ["circle", {
169
+ cx: "15",
170
+ cy: "5",
171
+ r: "1"
172
+ }],
173
+ ["circle", {
174
+ cx: "15",
175
+ cy: "19",
176
+ r: "1"
177
+ }]
178
+ ], It = [
179
+ ["rect", {
180
+ width: "18",
181
+ height: "18",
182
+ x: "3",
183
+ y: "3",
184
+ rx: "2",
185
+ ry: "2"
186
+ }],
187
+ ["circle", {
188
+ cx: "9",
189
+ cy: "9",
190
+ r: "2"
191
+ }],
192
+ ["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" }]
193
+ ], Lt = [
194
+ ["path", { d: "M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21" }],
195
+ ["path", { d: "m14 19.5 3-3 3 3" }],
196
+ ["path", { d: "M17 22v-5.5" }],
197
+ ["circle", {
198
+ cx: "9",
199
+ cy: "9",
200
+ r: "2"
201
+ }]
202
+ ], Rt = [
203
+ ["path", { d: "m22 11-1.296-1.296a2.4 2.4 0 0 0-3.408 0L11 16" }],
204
+ ["path", { d: "M4 8a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2" }],
205
+ ["circle", {
206
+ cx: "13",
207
+ cy: "7",
208
+ r: "1",
209
+ fill: "currentColor"
210
+ }],
211
+ ["rect", {
212
+ x: "8",
213
+ y: "2",
214
+ width: "14",
215
+ height: "14",
216
+ rx: "2"
217
+ }]
218
+ ], zt = [
219
+ ["line", {
220
+ x1: "19",
221
+ x2: "10",
222
+ y1: "4",
223
+ y2: "4"
224
+ }],
225
+ ["line", {
226
+ x1: "14",
227
+ x2: "5",
228
+ y1: "20",
229
+ y2: "20"
230
+ }],
231
+ ["line", {
232
+ x1: "15",
233
+ x2: "9",
234
+ y1: "4",
235
+ y2: "20"
236
+ }]
237
+ ], Bt = [["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }], ["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" }]], Vt = [
238
+ ["path", { d: "M11 5h10" }],
239
+ ["path", { d: "M11 12h10" }],
240
+ ["path", { d: "M11 19h10" }],
241
+ ["path", { d: "M4 4h1v5" }],
242
+ ["path", { d: "M4 9h2" }],
243
+ ["path", { d: "M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02" }]
244
+ ], Ht = [
245
+ ["path", { d: "M3 5h.01" }],
246
+ ["path", { d: "M3 12h.01" }],
247
+ ["path", { d: "M3 19h.01" }],
248
+ ["path", { d: "M8 5h13" }],
249
+ ["path", { d: "M8 12h13" }],
250
+ ["path", { d: "M8 19h13" }]
251
+ ], Ut = [
252
+ ["rect", {
253
+ width: "18",
254
+ height: "18",
255
+ x: "3",
256
+ y: "3",
257
+ rx: "2"
258
+ }],
259
+ ["path", { d: "M9 3v18" }],
260
+ ["path", { d: "m16 15-3-3 3-3" }]
261
+ ], Wt = [
262
+ ["rect", {
263
+ width: "18",
264
+ height: "18",
265
+ x: "3",
266
+ y: "3",
267
+ rx: "2"
268
+ }],
269
+ ["path", { d: "M9 3v18" }],
270
+ ["path", { d: "m14 9 3 3-3 3" }]
271
+ ], Gt = [["rect", {
272
+ width: "18",
273
+ height: "18",
274
+ x: "3",
275
+ y: "3",
276
+ rx: "2"
277
+ }], ["path", { d: "M9 3v18" }]], Kt = [["path", { d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" }], ["path", { d: "m15 5 4 4" }]], qt = [["path", { d: "M5 12h14" }], ["path", { d: "M12 5v14" }]], Jt = [["path", { d: "M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z" }], ["path", { d: "M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z" }]], Yt = [
278
+ ["path", { d: "M14 4a1 1 0 0 1 1-1" }],
279
+ ["path", { d: "M15 10a1 1 0 0 1-1-1" }],
280
+ ["path", { d: "M21 4a1 1 0 0 0-1-1" }],
281
+ ["path", { d: "M21 9a1 1 0 0 1-1 1" }],
282
+ ["path", { d: "m3 7 3 3 3-3" }],
283
+ ["path", { d: "M6 10V5a2 2 0 0 1 2-2h2" }],
284
+ ["rect", {
285
+ x: "3",
286
+ y: "14",
287
+ width: "7",
288
+ height: "7",
289
+ rx: "1"
290
+ }]
291
+ ], Xt = [["path", { d: "m21 21-4.34-4.34" }], ["circle", {
292
+ cx: "11",
293
+ cy: "11",
294
+ r: "8"
295
+ }]], Zt = [["path", { d: "M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z" }], ["path", { d: "m21.854 2.147-10.94 10.939" }]], Qt = [
296
+ ["path", { d: "M10 5H3" }],
297
+ ["path", { d: "M12 19H3" }],
298
+ ["path", { d: "M14 3v4" }],
299
+ ["path", { d: "M16 17v4" }],
300
+ ["path", { d: "M21 12h-9" }],
301
+ ["path", { d: "M21 19h-5" }],
302
+ ["path", { d: "M21 5h-7" }],
303
+ ["path", { d: "M8 10v4" }],
304
+ ["path", { d: "M8 12H3" }]
305
+ ], $t = [["path", { d: "M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" }], ["path", { d: "M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z" }]], en = [
306
+ ["path", { d: "M10 11v6" }],
307
+ ["path", { d: "M14 11v6" }],
308
+ ["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" }],
309
+ ["path", { d: "M3 6h18" }],
310
+ ["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }]
311
+ ], tn = [
312
+ ["path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" }],
313
+ ["path", { d: "M12 9v4" }],
314
+ ["path", { d: "M12 17h.01" }]
315
+ ], nn = [
316
+ ["path", { d: "M12 3v12" }],
317
+ ["path", { d: "m17 8-5-5-5 5" }],
318
+ ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }]
319
+ ], rn = [["path", { d: "M18 6 6 18" }], ["path", { d: "m6 6 12 12" }]];
320
+ //#endregion
321
+ //#region ../ui/src/components/shared.tsx
322
+ function V(...e) {
323
+ return e.filter(Boolean).join(" ");
324
+ }
325
+ var H = V("outline-none data-[focus-visible]:outline-2 data-[focus-visible]:outline-solid data-[focus-visible]:outline-offset-2 data-[focus-visible]:outline-focus", "data-[focus-visible]:ring-6 data-[focus-visible]:ring-(color:--glow-focus)"), U = "transition-[color,background-color,border-color] duration-120 ease-out", an = V("min-h-10 w-full rounded-md border border-border-strong bg-surface-sunken px-3 py-2 text-body text-content", "outline-none data-[focused]:outline-2 data-[focused]:outline-solid data-[focused]:outline-offset-2 data-[focused]:outline-focus", "data-[focused]:ring-6 data-[focused]:ring-(color:--glow-focus)", "data-[invalid]:border-danger data-[disabled]:opacity-60");
326
+ function on({ label: e, isOptional: t }) {
327
+ return e ? /* @__PURE__ */ z(ee, {
328
+ className: "block text-label text-content",
329
+ children: [e, t && /* @__PURE__ */ R(sn, {})]
330
+ }) : null;
331
+ }
332
+ function sn() {
333
+ return /* @__PURE__ */ z(L, { children: [" ", /* @__PURE__ */ R("span", {
334
+ className: "font-normal text-content-muted",
335
+ children: "(optional)"
336
+ })] });
337
+ }
338
+ function W({ description: e, errorMessage: t }) {
339
+ return /* @__PURE__ */ z(L, { children: [e && /* @__PURE__ */ R(xe, {
340
+ slot: "description",
341
+ className: "block text-small text-content-muted",
342
+ children: e
343
+ }), /* @__PURE__ */ R(S, {
344
+ className: "block text-small text-danger",
345
+ children: t
346
+ })] });
347
+ }
348
+ //#endregion
349
+ //#region ../ui/src/components/Icon.tsx
350
+ var cn = {
351
+ close: rn,
352
+ more: Ct,
353
+ drag: Ft,
354
+ chevron: yt,
355
+ check: vt,
356
+ bold: ht,
357
+ italic: zt,
358
+ bullets: Ht,
359
+ numbers: Vt,
360
+ quote: Jt,
361
+ code: xt,
362
+ link: Bt,
363
+ image: It,
364
+ add: qt,
365
+ upload: nn,
366
+ import: jt,
367
+ "replace-image": Lt,
368
+ back: ft,
369
+ "move-up": mt,
370
+ "move-down": dt,
371
+ "move-to": Nt,
372
+ duplicate: St,
373
+ "change-kind": Yt,
374
+ "list-pane": Gt,
375
+ "pane-collapse": Ut,
376
+ "pane-expand": Wt,
377
+ details: Qt,
378
+ "view-on-site": wt,
379
+ schedule: gt,
380
+ "publish-now": Zt,
381
+ unschedule: _t,
382
+ open: $t,
383
+ edit: Kt,
384
+ "add-child": Ot,
385
+ delete: en,
386
+ warning: tn,
387
+ accessibility: ut,
388
+ error: bt,
389
+ search: Xt,
390
+ media: Rt,
391
+ redirects: pt,
392
+ collection: At,
393
+ tree: Pt,
394
+ singleton: Qt,
395
+ "file-text": At,
396
+ "file-sheet": kt,
397
+ "file-archive": Tt,
398
+ "file-video": Dt,
399
+ "file-audio": Et,
400
+ file: Mt
401
+ }, ln = /* @__PURE__ */ new Set([
402
+ "path",
403
+ "circle",
404
+ "rect",
405
+ "line",
406
+ "polyline",
407
+ "polygon",
408
+ "ellipse"
409
+ ]), un = /* @__PURE__ */ new Set([
410
+ "d",
411
+ "cx",
412
+ "cy",
413
+ "r",
414
+ "rx",
415
+ "ry",
416
+ "x",
417
+ "y",
418
+ "x1",
419
+ "x2",
420
+ "y1",
421
+ "y2",
422
+ "width",
423
+ "height",
424
+ "points"
425
+ ]);
426
+ function G({ name: e, node: t, size: n = 20, className: i }) {
427
+ let a = t ?? (e ? cn[e] : []);
428
+ return /* @__PURE__ */ R("svg", {
429
+ xmlns: "http://www.w3.org/2000/svg",
430
+ viewBox: "0 0 24 24",
431
+ width: n,
432
+ height: n,
433
+ fill: "none",
434
+ stroke: "currentColor",
435
+ strokeWidth: 42 / n,
436
+ strokeLinecap: "round",
437
+ strokeLinejoin: "round",
438
+ "aria-hidden": "true",
439
+ focusable: "false",
440
+ className: V("shrink-0", i),
441
+ children: a.map(([e, t], n) => ln.has(e) ? r(e, {
442
+ key: n,
443
+ ...Object.fromEntries(Object.entries(t).filter(([e, t]) => un.has(e) && (typeof t == "string" || typeof t == "number")))
444
+ }) : null)
445
+ });
446
+ }
447
+ //#endregion
448
+ //#region ../ui/src/components/Button.tsx
449
+ var dn = {
450
+ primary: V("border-transparent bg-accent text-on-accent data-[hovered]:bg-accent-hover", "data-[hovered]:shadow-glow-accent data-[focus-visible]:shadow-glow-accent", U, "data-[hovered]:transition-[background-color,box-shadow] data-[hovered]:duration-180"),
451
+ secondary: V("border-border-strong bg-surface text-content data-[hovered]:bg-surface-sunken", U),
452
+ quiet: V("border-transparent text-accent data-[hovered]:bg-accent-subtle", U),
453
+ danger: V("border-transparent bg-danger text-on-accent data-[hovered]:opacity-90", U)
454
+ }, fn = V("inline-flex min-h-10 items-center justify-center gap-2 rounded-md border px-4 text-label", "data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[pending]:cursor-progress", H);
455
+ function K({ variant: e = "secondary", className: t, children: n, pulse: r = 0, icon: i, ...a }) {
456
+ let o = u(null);
457
+ return s(() => {
458
+ let e = o.current;
459
+ if (r === 0 || !e) return;
460
+ e.classList.remove("animate-glow-pulse"), e.getBoundingClientRect(), e.classList.add("animate-glow-pulse");
461
+ let t = () => {
462
+ e.classList.remove("animate-glow-pulse");
463
+ };
464
+ return e.addEventListener("animationend", t, { once: !0 }), () => {
465
+ e.removeEventListener("animationend", t);
466
+ };
467
+ }, [r]), /* @__PURE__ */ z(f, {
468
+ ...a,
469
+ ref: o,
470
+ className: V(fn, dn[e], t),
471
+ children: [i && /* @__PURE__ */ R(G, {
472
+ name: i,
473
+ size: 18
474
+ }), n]
475
+ });
476
+ }
477
+ function pn({ variant: e = "secondary", className: t, children: n, icon: r, ...i }) {
478
+ return /* @__PURE__ */ z(te, {
479
+ ...i,
480
+ className: V(fn, "no-underline", dn[e], t),
481
+ children: [r && /* @__PURE__ */ R(G, {
482
+ name: r,
483
+ size: 18
484
+ }), n]
485
+ });
486
+ }
487
+ function mn({ icon: e, label: t, className: n, ...r }) {
488
+ return /* @__PURE__ */ R(f, {
489
+ ...r,
490
+ "aria-label": t,
491
+ className: V("inline-flex size-10 shrink-0 items-center justify-center rounded-md border border-transparent text-content-muted", "data-[hovered]:bg-surface-sunken data-[hovered]:text-content data-[disabled]:opacity-50", U, H, n),
492
+ children: /* @__PURE__ */ R(G, { name: e })
493
+ });
494
+ }
495
+ function hn({ className: e, variant: t = "inline", icon: n, children: r, ...i }) {
496
+ return /* @__PURE__ */ R(te, {
497
+ ...i,
498
+ className: V("cursor-pointer rounded-sm underline-offset-2", n && "inline-flex items-center gap-1", t === "inline" ? "text-accent underline data-[hovered]:text-accent-hover" : "font-semibold text-content no-underline data-[hovered]:text-accent data-[hovered]:underline", U, H, e),
499
+ children: (e) => /* @__PURE__ */ z(L, { children: [n && /* @__PURE__ */ R(G, {
500
+ name: n,
501
+ size: 16
502
+ }), typeof r == "function" ? r(e) : r] })
503
+ });
504
+ }
505
+ function gn({ accept: e, onSelect: t, children: n, variant: r = "secondary", icon: i }) {
506
+ return /* @__PURE__ */ R(C, {
507
+ acceptedFileTypes: e,
508
+ onSelect: (e) => {
509
+ let n = e?.[0];
510
+ n && t(n);
511
+ },
512
+ children: /* @__PURE__ */ R(K, {
513
+ variant: r,
514
+ ...i ? { icon: i } : {},
515
+ children: n
516
+ })
517
+ });
518
+ }
519
+ //#endregion
520
+ //#region ../ui/src/components/TextField.tsx
521
+ function _n({ label: e, description: t, errorMessage: n, placeholder: r, className: i, inputClassName: a, icon: o, ...s }) {
522
+ let c = /* @__PURE__ */ R(E, {
523
+ placeholder: r,
524
+ className: V(an, o && "pl-10", a)
525
+ });
526
+ return /* @__PURE__ */ z(Ce, {
527
+ ...s,
528
+ className: V("flex flex-col gap-2", i),
529
+ children: [
530
+ /* @__PURE__ */ R(on, { label: e }),
531
+ o ? /* @__PURE__ */ z("div", {
532
+ className: "relative",
533
+ children: [/* @__PURE__ */ R(G, {
534
+ name: o,
535
+ size: 18,
536
+ className: "pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-content-muted"
537
+ }), c]
538
+ }) : c,
539
+ /* @__PURE__ */ R(W, {
540
+ description: t,
541
+ errorMessage: n
542
+ })
543
+ ]
544
+ });
545
+ }
546
+ function vn({ label: e, description: t, errorMessage: n, placeholder: r, rows: i = 4, className: a, inputClassName: o, ...s }) {
547
+ return /* @__PURE__ */ z(Ce, {
548
+ ...s,
549
+ className: V("flex flex-col gap-2", a),
550
+ children: [
551
+ /* @__PURE__ */ R(on, { label: e }),
552
+ /* @__PURE__ */ R(Se, {
553
+ rows: i,
554
+ placeholder: r,
555
+ className: V(an, "min-h-24 resize-y", o)
556
+ }),
557
+ /* @__PURE__ */ R(W, {
558
+ description: t,
559
+ errorMessage: n
560
+ })
561
+ ]
562
+ });
563
+ }
564
+ //#endregion
565
+ //#region ../ui/src/components/overlays.tsx
566
+ var yn = "scrim fixed inset-0 z-50 data-[entering]:animate-none", bn = "glass-raised shadow-glass-overlay", xn = V("rounded-lg p-1", bn);
567
+ function Sn({ title: e, isOpen: t, onOpenChange: n, children: r, isDismissable: i = !0, role: a = "dialog", size: o = "default" }) {
568
+ return /* @__PURE__ */ R(M, {
569
+ isOpen: t,
570
+ onOpenChange: n,
571
+ isDismissable: i,
572
+ className: V(yn, "flex items-center justify-center p-4"),
573
+ children: /* @__PURE__ */ R(j, {
574
+ className: V("max-h-full w-full overflow-y-auto rounded-lg", bn, o === "wide" ? "max-w-3xl" : "max-w-lg"),
575
+ children: /* @__PURE__ */ R(y, {
576
+ role: a,
577
+ className: "flex flex-col gap-4 p-6 outline-none",
578
+ children: ({ close: t }) => /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ z("div", {
579
+ className: "flex items-start justify-between gap-4",
580
+ children: [/* @__PURE__ */ R(T, {
581
+ slot: "title",
582
+ className: "text-heading-2 text-content",
583
+ children: e
584
+ }), /* @__PURE__ */ R(mn, {
585
+ icon: "close",
586
+ label: "Close",
587
+ onPress: t,
588
+ className: "-mr-2 -mt-2"
589
+ })]
590
+ }), typeof r == "function" ? r(t) : r] })
591
+ })
592
+ })
593
+ });
594
+ }
595
+ function Cn({ title: e, isOpen: t, onOpenChange: n, children: r }) {
596
+ return /* @__PURE__ */ R(M, {
597
+ isOpen: t,
598
+ onOpenChange: n,
599
+ isDismissable: !0,
600
+ className: yn,
601
+ children: /* @__PURE__ */ R(j, {
602
+ className: V("fixed inset-y-0 right-0 flex w-full max-w-drawer flex-col rounded-l-lg", bn),
603
+ children: /* @__PURE__ */ R(y, {
604
+ className: "flex h-full flex-col outline-none",
605
+ children: ({ close: t }) => /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ z("div", {
606
+ className: "flex items-center justify-between gap-4 px-6 pt-6 pb-4",
607
+ children: [/* @__PURE__ */ R(T, {
608
+ slot: "title",
609
+ className: "text-heading-2 text-content",
610
+ children: e
611
+ }), /* @__PURE__ */ R(mn, {
612
+ icon: "close",
613
+ label: "Close",
614
+ onPress: t,
615
+ className: "-mr-2"
616
+ })]
617
+ }), /* @__PURE__ */ R("div", {
618
+ className: "flex-1 overflow-y-auto px-6 pb-6",
619
+ children: typeof r == "function" ? r(t) : r
620
+ })] })
621
+ })
622
+ })
623
+ });
624
+ }
625
+ function q({ className: e }) {
626
+ return /* @__PURE__ */ R(G, {
627
+ name: "chevron",
628
+ size: 16,
629
+ className: V("text-content-muted", e)
630
+ });
631
+ }
632
+ function wn({ text: e, children: t }) {
633
+ return /* @__PURE__ */ z(De, {
634
+ delay: 400,
635
+ closeDelay: 0,
636
+ children: [t, /* @__PURE__ */ R(Ee, {
637
+ offset: 6,
638
+ className: V("rounded-md px-2 py-1 text-small text-content", bn),
639
+ children: e
640
+ })]
641
+ });
642
+ }
643
+ var Tn = V("flex min-h-9 cursor-default items-center rounded-md px-3 text-body outline-none", "data-[focused]:bg-accent-subtle data-[disabled]:opacity-50", "data-[focus-visible]:outline-2 data-[focus-visible]:outline-solid data-[focus-visible]:-outline-offset-2 data-[focus-visible]:outline-focus"), En = "relative mt-2 before:pointer-events-none before:absolute before:inset-x-2 before:-top-1 before:border-t before:border-border before:content-['']";
644
+ function Dn(e, t, n, r) {
645
+ let i = e.indexOf(t), a = t.isDanger === !0 && i > 0 && !e[i - 1]?.isDanger || n && i === 0, o = t.items, s = /* @__PURE__ */ z(k, {
646
+ ...o ? {} : { id: t.id },
647
+ textValue: t.label,
648
+ className: V(Tn, t.isDanger ? "text-danger" : "text-content", t.isCurrent && "bg-accent-subtle shadow-glow-selected", a && En),
649
+ children: [
650
+ t.icon && /* @__PURE__ */ R(G, {
651
+ ...typeof t.icon == "string" ? { name: t.icon } : { node: t.icon },
652
+ size: 18,
653
+ className: V("mr-2", !t.isDanger && "text-content-muted")
654
+ }),
655
+ t.description ? /* @__PURE__ */ z("span", {
656
+ className: "flex min-w-0 flex-col py-1",
657
+ children: [/* @__PURE__ */ R(xe, {
658
+ slot: "label",
659
+ children: t.label
660
+ }), /* @__PURE__ */ R(xe, {
661
+ slot: "description",
662
+ className: "text-small text-content-muted",
663
+ children: t.description
664
+ })]
665
+ }) : t.label,
666
+ t.items && /* @__PURE__ */ R(q, { className: "ml-auto -rotate-90 pl-2" })
667
+ ]
668
+ });
669
+ return o ? /* @__PURE__ */ z(le, { children: [s, /* @__PURE__ */ R(N, {
670
+ offset: -4,
671
+ className: V("max-w-sm min-w-56", xn),
672
+ children: /* @__PURE__ */ R(ne, {
673
+ "aria-label": t.label,
674
+ onAction: (e) => {
675
+ r(String(e));
676
+ },
677
+ items: o,
678
+ disabledKeys: o.filter((e) => e.isDisabled).map((e) => e.id),
679
+ className: "outline-none",
680
+ children: (e) => Dn(o, e, !1, r)
681
+ })
682
+ })] }) : s;
683
+ }
684
+ function On({ label: e, items: t, onAction: n, triggerText: r, triggerIcon: i, triggerPicture: a, trigger: o, header: c, choice: l, isOpen: p, onOpenChange: m }) {
685
+ let h = new Set(l?.options.map((e) => e.id)), _ = u(null), [v, y] = d(!1), b = u(null), x = (e) => {
686
+ b.current = e;
687
+ };
688
+ s(() => {
689
+ let e = b.current;
690
+ v || e === null || (b.current = null, _.current?.querySelector("button")?.focus(), h.has(e) ? l?.onClosed?.() : n(e));
691
+ });
692
+ let S = l ? [{
693
+ id: "choice",
694
+ choice: l
695
+ }, ...t.length > 0 ? [{
696
+ id: "items",
697
+ items: t
698
+ }] : []] : [];
699
+ return /* @__PURE__ */ z(re, {
700
+ ...p === void 0 ? {} : { isOpen: p },
701
+ onOpenChange: (e) => {
702
+ y(e), m?.(e);
703
+ },
704
+ children: [/* @__PURE__ */ R("span", {
705
+ ref: _,
706
+ className: "contents",
707
+ children: o ?? (r ? /* @__PURE__ */ z(f, {
708
+ className: V("inline-flex min-h-10 min-w-0 items-center gap-1 rounded-md border border-transparent text-body text-content data-[hovered]:bg-surface-sunken", a ? "px-2" : "px-3", "transition-[color,background-color,border-color] duration-120 ease-out", H),
709
+ children: [a ? /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R("span", {
710
+ className: "flex",
711
+ children: a
712
+ }), /* @__PURE__ */ R("span", {
713
+ className: "sr-only",
714
+ children: r
715
+ })] }) : /* @__PURE__ */ z(L, { children: [i && /* @__PURE__ */ R(G, {
716
+ name: i,
717
+ size: 18
718
+ }), /* @__PURE__ */ R("span", {
719
+ className: "min-w-0 truncate",
720
+ children: r
721
+ })] }), /* @__PURE__ */ R(q, {})]
722
+ }) : /* @__PURE__ */ R(mn, {
723
+ icon: "more",
724
+ label: e
725
+ }))
726
+ }), /* @__PURE__ */ z(N, {
727
+ placement: o ? "bottom start" : "bottom end",
728
+ className: V("min-w-56", xn),
729
+ children: [c && /* @__PURE__ */ R("div", {
730
+ "aria-hidden": "true",
731
+ className: "mb-1 border-b border-border px-3 pt-2 pb-3",
732
+ children: c
733
+ }), l ? /* @__PURE__ */ R(ne, {
734
+ "aria-label": e,
735
+ onAction: (e) => {
736
+ x(String(e));
737
+ },
738
+ items: S,
739
+ disabledKeys: t.filter((e) => e.isDisabled).map((e) => e.id),
740
+ className: "outline-none",
741
+ children: (t) => t.id === "choice" ? /* @__PURE__ */ z(A, {
742
+ id: "choice",
743
+ selectionMode: "single",
744
+ disallowEmptySelection: !0,
745
+ selectedKeys: [t.choice.selected],
746
+ onSelectionChange: (e) => {
747
+ if (e === "all") return;
748
+ let [n] = [...e];
749
+ n !== void 0 && t.choice.onChange(String(n));
750
+ },
751
+ children: [/* @__PURE__ */ R(w, {
752
+ className: "px-3 pt-1 pb-1 text-small text-content-muted",
753
+ children: t.choice.title
754
+ }), /* @__PURE__ */ R(g, {
755
+ items: t.choice.options,
756
+ children: (e) => /* @__PURE__ */ R(k, {
757
+ id: e.id,
758
+ textValue: e.label,
759
+ className: V(Tn, "gap-2 text-content"),
760
+ children: ({ isSelected: t }) => /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R(G, {
761
+ name: "check",
762
+ size: 18,
763
+ className: V("text-accent", !t && "invisible")
764
+ }), e.label] })
765
+ })
766
+ })]
767
+ }) : /* @__PURE__ */ R(A, {
768
+ id: "items",
769
+ "aria-label": e,
770
+ items: t.items,
771
+ children: (e) => Dn(t.items, e, !0, x)
772
+ })
773
+ }) : /* @__PURE__ */ R(ne, {
774
+ "aria-label": e,
775
+ onAction: (e) => {
776
+ x(String(e));
777
+ },
778
+ items: t,
779
+ disabledKeys: t.filter((e) => e.isDisabled).map((e) => e.id),
780
+ className: "outline-none",
781
+ children: (e) => Dn(t, e, !1, x)
782
+ })]
783
+ })]
784
+ });
785
+ }
786
+ function kn({ title: e, children: t, level: n = 2, ...r }) {
787
+ return /* @__PURE__ */ z(b, {
788
+ ...r,
789
+ className: "vesper-disclosure group border-y border-border [.vesper-disclosure+&]:border-t-0",
790
+ children: [/* @__PURE__ */ R(T, {
791
+ level: n,
792
+ className: "m-0",
793
+ children: /* @__PURE__ */ z(f, {
794
+ slot: "trigger",
795
+ className: V("flex min-h-12 w-full items-center gap-2 rounded-md text-left text-heading-3 text-content", H),
796
+ children: [/* @__PURE__ */ R(q, { className: "-rotate-90 group-data-[expanded]:rotate-0" }), e]
797
+ })
798
+ }), /* @__PURE__ */ R(x, { children: /* @__PURE__ */ R("div", {
799
+ className: "pb-6",
800
+ children: t
801
+ }) })]
802
+ });
803
+ }
804
+ //#endregion
805
+ //#region ../ui/src/components/choices.tsx
806
+ var An = V("group flex min-h-9 cursor-default items-center gap-2 rounded-md px-3 py-1 text-body text-content outline-none", "data-[focused]:bg-accent-subtle data-[selected]:bg-accent-subtle data-[selected]:shadow-glow-selected", "data-[focus-visible]:outline-2 data-[focus-visible]:outline-solid data-[focus-visible]:-outline-offset-2 data-[focus-visible]:outline-focus"), jn = V("min-w-[var(--trigger-width)]", xn);
807
+ function Mn() {
808
+ return /* @__PURE__ */ R(G, {
809
+ name: "check",
810
+ size: 16,
811
+ className: "invisible ml-auto text-accent group-data-[selected]:visible"
812
+ });
813
+ }
814
+ function Nn({ label: e, description: t, errorMessage: n, options: r, value: i, onChange: a, placeholder: o, className: s, ...c }) {
815
+ return /* @__PURE__ */ z(oe, {
816
+ ...c,
817
+ value: i,
818
+ onChange: (e) => {
819
+ a(e === null ? null : String(e));
820
+ },
821
+ placeholder: o ?? "Choose…",
822
+ className: V("flex flex-col gap-2", s),
823
+ children: [
824
+ /* @__PURE__ */ R(on, { label: e }),
825
+ /* @__PURE__ */ z(f, {
826
+ className: V(an, "flex items-center justify-between text-left", H),
827
+ children: [/* @__PURE__ */ R(se, {
828
+ className: "truncate data-[placeholder]:text-content-muted",
829
+ children: ({ isPlaceholder: e, selectedText: t, defaultChildren: n }) => e ? n : t
830
+ }), /* @__PURE__ */ R(q, {})]
831
+ }),
832
+ /* @__PURE__ */ R(W, {
833
+ description: t,
834
+ errorMessage: n
835
+ }),
836
+ /* @__PURE__ */ R(N, {
837
+ className: jn,
838
+ children: /* @__PURE__ */ R(D, {
839
+ className: "max-h-72 overflow-auto outline-none",
840
+ items: r,
841
+ children: (e) => /* @__PURE__ */ z(O, {
842
+ id: e.value,
843
+ textValue: e.label,
844
+ className: An,
845
+ children: [e.label, /* @__PURE__ */ R(Mn, {})]
846
+ })
847
+ })
848
+ })
849
+ ]
850
+ });
851
+ }
852
+ function Pn({ label: e, description: t, errorMessage: n, options: r, value: i, onChange: a, placeholder: o, className: s, ...c }) {
853
+ let l = r.find((e) => e.value === i)?.prefix;
854
+ return /* @__PURE__ */ z(v, {
855
+ ...c,
856
+ defaultItems: r,
857
+ value: i,
858
+ onChange: (e) => {
859
+ a(e === null ? null : String(e));
860
+ },
861
+ menuTrigger: "focus",
862
+ validationBehavior: "aria",
863
+ className: V("group/combobox flex flex-col gap-2", s),
864
+ children: [
865
+ /* @__PURE__ */ R(on, { label: e }),
866
+ /* @__PURE__ */ z("div", {
867
+ className: "relative",
868
+ children: [
869
+ l && /* @__PURE__ */ R("span", {
870
+ "aria-hidden": "true",
871
+ className: "pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3 group-data-[disabled]/combobox:opacity-60",
872
+ children: l
873
+ }),
874
+ /* @__PURE__ */ R(E, {
875
+ placeholder: o,
876
+ className: V(an, "pr-10", l ? "pl-10" : void 0)
877
+ }),
878
+ /* @__PURE__ */ R(f, {
879
+ "aria-label": "Show options",
880
+ className: V("absolute inset-y-0 right-0 flex items-center rounded-md px-3 text-content-muted", H),
881
+ children: /* @__PURE__ */ R(q, {})
882
+ })
883
+ ]
884
+ }),
885
+ /* @__PURE__ */ R(W, {
886
+ description: t,
887
+ errorMessage: n
888
+ }),
889
+ /* @__PURE__ */ R(N, {
890
+ className: jn,
891
+ children: /* @__PURE__ */ R(D, {
892
+ className: "max-h-72 overflow-auto outline-none",
893
+ children: (e) => /* @__PURE__ */ z(O, {
894
+ id: e.value,
895
+ textValue: e.label,
896
+ className: An,
897
+ children: [
898
+ e.prefix && /* @__PURE__ */ R("span", {
899
+ "aria-hidden": "true",
900
+ className: "flex shrink-0",
901
+ children: e.prefix
902
+ }),
903
+ e.label,
904
+ /* @__PURE__ */ R(Mn, {})
905
+ ]
906
+ })
907
+ })
908
+ })
909
+ ]
910
+ });
911
+ }
912
+ function Fn({ label: e, description: t, errorMessage: n, options: r, values: i, onChange: a, allowsCustomValue: o = !1, itemName: s = "item", className: c, isDisabled: u, isInvalid: p, ...m }) {
913
+ let [h, g] = d(""), _ = l(() => new Map(r.map((e) => [e.value, e])), [r]), y = r.filter((e) => !i.includes(e.value)), b = (e) => {
914
+ let t = e.trim();
915
+ t === "" || i.includes(t) || (o || _.has(t)) && (a([...i, t]), g(""));
916
+ }, x = (e) => _.get(e)?.label ?? e;
917
+ return /* @__PURE__ */ z("div", {
918
+ className: V("flex flex-col gap-2", c),
919
+ onKeyDownCapture: (e) => {
920
+ if (!(e.target instanceof HTMLInputElement)) return;
921
+ let t = e.target.value;
922
+ e.key === "Enter" && o && t.trim() !== "" && !e.target.getAttribute("aria-activedescendant") && (e.preventDefault(), e.stopPropagation(), b(t)), e.key === "Backspace" && t === "" && i.length > 0 && a(i.slice(0, -1));
923
+ },
924
+ children: [/* @__PURE__ */ z(v, {
925
+ ...m,
926
+ items: y.filter((e) => e.label.toLowerCase().includes(h.toLowerCase())),
927
+ inputValue: h,
928
+ onInputChange: g,
929
+ value: null,
930
+ onChange: (e) => {
931
+ e !== null && b(String(e));
932
+ },
933
+ allowsCustomValue: o,
934
+ isDisabled: u,
935
+ isInvalid: p,
936
+ menuTrigger: "focus",
937
+ className: "flex flex-col gap-1",
938
+ children: [
939
+ /* @__PURE__ */ R(on, { label: e }),
940
+ /* @__PURE__ */ R(E, { className: an }),
941
+ /* @__PURE__ */ R(W, {
942
+ description: t,
943
+ errorMessage: n
944
+ }),
945
+ /* @__PURE__ */ R(N, {
946
+ className: jn,
947
+ children: /* @__PURE__ */ R(D, {
948
+ className: "max-h-72 overflow-auto outline-none",
949
+ renderEmptyState: () => /* @__PURE__ */ R("p", {
950
+ className: "px-3 py-2 text-small text-content-muted",
951
+ children: o ? "Press Enter to add it" : "No matches"
952
+ }),
953
+ children: (e) => /* @__PURE__ */ R(O, {
954
+ id: e.value,
955
+ textValue: e.label,
956
+ className: An,
957
+ children: e.label
958
+ })
959
+ })
960
+ })
961
+ ]
962
+ }), i.length > 0 && /* @__PURE__ */ R(ye, {
963
+ "aria-label": typeof e == "string" ? `Selected ${e.toLowerCase()}` : "Selected",
964
+ onRemove: (e) => {
965
+ a(i.filter((t) => !e.has(t)));
966
+ },
967
+ children: /* @__PURE__ */ R(be, {
968
+ className: "flex flex-wrap gap-2",
969
+ children: i.map((e) => /* @__PURE__ */ z(ve, {
970
+ id: e,
971
+ textValue: x(e),
972
+ className: V("inline-flex items-center gap-1 rounded-sm border border-border bg-surface py-0.5 pr-0.5 pl-2 text-small text-content", H),
973
+ children: [x(e), /* @__PURE__ */ R(f, {
974
+ slot: "remove",
975
+ "aria-label": `Remove ${s}`,
976
+ className: V("inline-flex size-6 items-center justify-center rounded-sm text-content-muted data-[hovered]:bg-surface-sunken data-[hovered]:text-content", H),
977
+ children: /* @__PURE__ */ R(G, {
978
+ name: "close",
979
+ size: 16
980
+ })
981
+ })]
982
+ }, e))
983
+ })
984
+ })]
985
+ });
986
+ }
987
+ var In = V("group-data-[focus-visible]:outline-2 group-data-[focus-visible]:outline-solid group-data-[focus-visible]:outline-offset-2 group-data-[focus-visible]:outline-focus", "group-data-[focus-visible]:ring-6 group-data-[focus-visible]:ring-(color:--glow-focus)");
988
+ function Ln({ children: e, className: t, ...n }) {
989
+ return /* @__PURE__ */ R(h, {
990
+ ...n,
991
+ className: t,
992
+ children: /* @__PURE__ */ z(m, {
993
+ className: "group inline-flex items-start gap-2 text-body text-content",
994
+ children: [/* @__PURE__ */ R("span", {
995
+ "aria-hidden": "true",
996
+ className: V("mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-sm border border-border-strong bg-surface", "group-data-[selected]:border-accent group-data-[selected]:bg-accent group-data-[selected]:text-on-accent", In),
997
+ children: /* @__PURE__ */ R("svg", {
998
+ viewBox: "0 0 16 16",
999
+ className: "hidden size-4 group-data-[selected]:block",
1000
+ fill: "none",
1001
+ stroke: "currentColor",
1002
+ strokeWidth: "2",
1003
+ children: /* @__PURE__ */ R("path", { d: "M3 8l3 3 7-7" })
1004
+ })
1005
+ }), e]
1006
+ })
1007
+ });
1008
+ }
1009
+ function Rn({ children: e, className: t, ...n }) {
1010
+ return /* @__PURE__ */ R(I, {
1011
+ ...n,
1012
+ className: t,
1013
+ children: /* @__PURE__ */ z(ue, {
1014
+ className: "group inline-flex items-center gap-3 text-body text-content",
1015
+ children: [
1016
+ /* @__PURE__ */ R("span", {
1017
+ "aria-hidden": "true",
1018
+ className: V("flex h-6 w-10 shrink-0 items-center rounded-full border border-border-strong bg-surface-sunken p-0.5", "transition-[background-color,border-color] duration-120 ease-out", "group-data-[selected]:border-accent group-data-[selected]:bg-accent", In),
1019
+ children: /* @__PURE__ */ R("span", { className: "size-4 rounded-full bg-content-muted transition-transform duration-180 ease-out group-data-[selected]:translate-x-4 group-data-[selected]:bg-on-accent forced-colors:bg-[CanvasText]" })
1020
+ }),
1021
+ e,
1022
+ /* @__PURE__ */ z("span", {
1023
+ "aria-hidden": "true",
1024
+ className: "text-small text-content-muted",
1025
+ children: [/* @__PURE__ */ R("span", {
1026
+ className: "group-data-[selected]:hidden",
1027
+ children: "Off"
1028
+ }), /* @__PURE__ */ R("span", {
1029
+ className: "hidden group-data-[selected]:inline",
1030
+ children: "On"
1031
+ })]
1032
+ })
1033
+ ]
1034
+ })
1035
+ });
1036
+ }
1037
+ function zn({ label: e, description: t, errorMessage: n, options: r, value: i, onChange: a, className: o, orientation: s = "vertical", ...c }) {
1038
+ return /* @__PURE__ */ z(F, {
1039
+ ...c,
1040
+ value: i,
1041
+ onChange: a,
1042
+ orientation: s,
1043
+ className: V("flex flex-col gap-2", o),
1044
+ children: [
1045
+ e && /* @__PURE__ */ R(ee, {
1046
+ className: "text-label text-content",
1047
+ children: e
1048
+ }),
1049
+ /* @__PURE__ */ R("div", {
1050
+ className: V("flex gap-x-6 gap-y-2", s === "vertical" ? "flex-col" : "flex-row flex-wrap"),
1051
+ children: r.map((e) => /* @__PURE__ */ R(ie, {
1052
+ value: e.value,
1053
+ children: /* @__PURE__ */ z(P, {
1054
+ className: "group inline-flex items-center gap-2 text-body text-content",
1055
+ children: [
1056
+ /* @__PURE__ */ R("span", {
1057
+ "aria-hidden": "true",
1058
+ className: V("flex size-5 shrink-0 items-center justify-center rounded-full border border-border-strong bg-surface", "group-data-[selected]:border-accent", In),
1059
+ children: /* @__PURE__ */ R("span", { className: "hidden size-2.5 rounded-full bg-accent group-data-[selected]:block forced-colors:bg-[CanvasText]" })
1060
+ }),
1061
+ e.prefix && /* @__PURE__ */ R("span", {
1062
+ "aria-hidden": "true",
1063
+ children: e.prefix
1064
+ }),
1065
+ e.label
1066
+ ]
1067
+ })
1068
+ }, e.value))
1069
+ }),
1070
+ /* @__PURE__ */ R(W, {
1071
+ description: t,
1072
+ errorMessage: n
1073
+ })
1074
+ ]
1075
+ });
1076
+ }
1077
+ function Bn({ label: e, description: t, errorMessage: n, value: r, onChange: i, suggestions: a, placeholder: o, className: s, inputMode: c = "text", ...u }) {
1078
+ let d = r.trim().toLowerCase(), f = l(() => (d === "" ? a : a.filter((e) => e.label.toLowerCase().includes(d) || e.value.toLowerCase().includes(d))).slice(0, 50), [d, a]);
1079
+ return /* @__PURE__ */ z(v, {
1080
+ ...u,
1081
+ allowsCustomValue: !0,
1082
+ allowsEmptyCollection: !0,
1083
+ items: f,
1084
+ inputValue: r,
1085
+ onInputChange: i,
1086
+ menuTrigger: "input",
1087
+ className: V("flex flex-col gap-2", s),
1088
+ children: [
1089
+ /* @__PURE__ */ R(on, { label: e }),
1090
+ /* @__PURE__ */ R(E, {
1091
+ placeholder: o,
1092
+ inputMode: c,
1093
+ className: an
1094
+ }),
1095
+ /* @__PURE__ */ R(W, {
1096
+ description: t,
1097
+ errorMessage: n
1098
+ }),
1099
+ /* @__PURE__ */ R(N, {
1100
+ className: jn,
1101
+ children: /* @__PURE__ */ R(D, {
1102
+ className: "max-h-72 overflow-auto outline-none",
1103
+ children: (e) => /* @__PURE__ */ z(O, {
1104
+ id: e.value,
1105
+ textValue: e.value,
1106
+ className: V(An, "flex-col items-start gap-0"),
1107
+ children: [/* @__PURE__ */ R("span", {
1108
+ className: "block",
1109
+ children: e.label
1110
+ }), e.detail && /* @__PURE__ */ R("span", {
1111
+ className: "block text-small text-content-muted",
1112
+ children: e.detail
1113
+ })]
1114
+ })
1115
+ })
1116
+ })
1117
+ ]
1118
+ });
1119
+ }
1120
+ //#endregion
1121
+ //#region ../ui/src/components/data.tsx
1122
+ function Vn({ label: e, columns: t, rows: n, renderCell: r, sort: i, onSortChange: a, emptyState: o, rowHref: s }) {
1123
+ return /* @__PURE__ */ R("div", {
1124
+ className: "overflow-x-auto",
1125
+ children: /* @__PURE__ */ z(me, {
1126
+ "aria-label": e,
1127
+ ...i ? { sortDescriptor: i } : {},
1128
+ ...a ? { onSortChange: a } : {},
1129
+ className: "w-full border-separate border-spacing-0 text-left text-body",
1130
+ children: [/* @__PURE__ */ R(ge, { children: t.map((e) => /* @__PURE__ */ R(_, {
1131
+ id: e.id,
1132
+ isRowHeader: e.isRowHeader ?? !1,
1133
+ allowsSorting: e.allowsSorting ?? !1,
1134
+ className: V("bg-surface-sunken px-3 py-2 text-label text-content-muted first:rounded-l-md last:rounded-r-md", "data-[allows-sorting]:cursor-pointer", H),
1135
+ children: ({ sortDirection: t }) => /* @__PURE__ */ z("span", {
1136
+ className: "inline-flex items-center gap-1",
1137
+ children: [e.label, t && /* @__PURE__ */ R("span", {
1138
+ "aria-hidden": "true",
1139
+ children: t === "ascending" ? "↑" : "↓"
1140
+ })]
1141
+ })
1142
+ }, e.id)) }), /* @__PURE__ */ R(he, {
1143
+ items: n,
1144
+ renderEmptyState: () => /* @__PURE__ */ R("p", {
1145
+ className: "px-3 py-6 text-content-muted",
1146
+ children: o ?? "Nothing here yet."
1147
+ }),
1148
+ children: (e) => /* @__PURE__ */ R(ae, {
1149
+ id: e.id,
1150
+ ...s ? { href: s(e) } : {},
1151
+ className: V("data-[hovered]:bg-accent-subtle data-[href]:cursor-pointer", U, "outline-none data-[focus-visible]:outline-2 data-[focus-visible]:outline-solid data-[focus-visible]:-outline-offset-2 data-[focus-visible]:outline-focus"),
1152
+ children: t.map((t) => /* @__PURE__ */ R(p, {
1153
+ className: V("border-b border-border px-3 py-3 align-top", "outline-none data-[focus-visible]:outline-2 data-[focus-visible]:outline-solid data-[focus-visible]:-outline-offset-2 data-[focus-visible]:outline-focus"),
1154
+ children: r(e, t.id)
1155
+ }, t.id))
1156
+ })
1157
+ })]
1158
+ })
1159
+ });
1160
+ }
1161
+ function Hn({ children: e, dot: t = !1, busy: n = !1, live: r = !0, tone: i = "neutral", className: a }) {
1162
+ return /* @__PURE__ */ z("p", {
1163
+ role: r ? "status" : void 0,
1164
+ className: V("inline-flex items-center gap-2 text-small", i === "error" ? "text-danger" : "text-content-muted", a),
1165
+ children: [t && /* @__PURE__ */ R("span", {
1166
+ "aria-hidden": "true",
1167
+ "data-busy": n || void 0,
1168
+ className: V("size-2 shrink-0 rounded-full", i === "error" ? "bg-danger" : n ? "animate-status-pulse bg-accent" : "bg-content-muted")
1169
+ }), e]
1170
+ });
1171
+ }
1172
+ function Un({ children: e, tone: t, className: n }) {
1173
+ return /* @__PURE__ */ R("span", {
1174
+ className: V("inline-flex shrink-0 items-center rounded-full px-2 align-top text-caption font-semibold", "outline -outline-offset-1", t === "live" ? "bg-live-subtle text-live outline-transparent" : t === "scheduled" ? "bg-scheduled-subtle text-scheduled outline-transparent" : "bg-surface-sunken text-content-muted outline-border", n),
1175
+ children: e
1176
+ });
1177
+ }
1178
+ function Wn({ title: e = "There is a problem", errors: t, focusOnMount: n = !0, focusKey: r, onGo: i }) {
1179
+ let a = u(null), o = r ?? t.length, c = t.length > 0;
1180
+ return s(() => {
1181
+ n && c && a.current?.focus();
1182
+ }, [n, o]), t.length === 0 ? null : /* @__PURE__ */ z("div", {
1183
+ ref: a,
1184
+ tabIndex: -1,
1185
+ role: "alert",
1186
+ "aria-labelledby": "vesper-error-summary-title",
1187
+ className: "rounded-md border border-danger bg-surface p-4 outline-none focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-focus",
1188
+ children: [/* @__PURE__ */ z("h2", {
1189
+ id: "vesper-error-summary-title",
1190
+ className: "flex items-center gap-2 text-heading-3 text-content",
1191
+ children: [/* @__PURE__ */ R(G, {
1192
+ name: "error",
1193
+ className: "text-danger"
1194
+ }), e]
1195
+ }), /* @__PURE__ */ R("ul", {
1196
+ className: "mt-2 list-disc space-y-1 pl-6 text-danger",
1197
+ children: t.map((e, t) => /* @__PURE__ */ R("li", { children: /* @__PURE__ */ R("a", {
1198
+ href: `#${e.fieldId}`,
1199
+ onClick: (t) => {
1200
+ if (i) {
1201
+ t.preventDefault(), i(e.fieldId);
1202
+ return;
1203
+ }
1204
+ let n = document.getElementById(e.fieldId);
1205
+ n && (t.preventDefault(), n.focus());
1206
+ },
1207
+ className: "text-danger underline underline-offset-2",
1208
+ children: e.message
1209
+ }) }, `${e.fieldId}:${String(t)}`))
1210
+ })]
1211
+ });
1212
+ }
1213
+ //#endregion
1214
+ //#region ../ui/src/components/Mark.tsx
1215
+ function Gn({ size: e = 20, className: t }) {
1216
+ let n = e <= 24;
1217
+ return /* @__PURE__ */ z("svg", {
1218
+ viewBox: "0 0 64 64",
1219
+ width: e,
1220
+ height: e,
1221
+ "aria-hidden": "true",
1222
+ focusable: "false",
1223
+ className: V("shrink-0", t),
1224
+ children: [
1225
+ /* @__PURE__ */ R("path", {
1226
+ d: n ? "M11 14 L29 50 L42 25" : "M12 14 L30 50 L43 25",
1227
+ fill: "none",
1228
+ stroke: "currentColor",
1229
+ strokeWidth: n ? 11 : 9,
1230
+ strokeLinecap: "round",
1231
+ strokeLinejoin: "round"
1232
+ }),
1233
+ !n && /* @__PURE__ */ R("circle", {
1234
+ cx: "51",
1235
+ cy: "12",
1236
+ r: "10",
1237
+ className: "fill-accent opacity-20 forced-colors:hidden"
1238
+ }),
1239
+ /* @__PURE__ */ R("circle", {
1240
+ cx: n ? 52 : 51,
1241
+ cy: n ? 11 : 12,
1242
+ r: n ? 7 : 5.5,
1243
+ className: "fill-accent forced-colors:fill-[CanvasText]"
1244
+ })
1245
+ ]
1246
+ });
1247
+ }
1248
+ //#endregion
1249
+ //#region ../ui/src/components/Avatar.tsx
1250
+ function Kn(e) {
1251
+ return e.replace(/^@/, "").trim().split(/\s+/).filter(Boolean).slice(0, 2).map((e) => Array.from(e)[0] ?? "").join("").toLocaleUpperCase();
1252
+ }
1253
+ function qn({ name: e, src: t, size: n = 24, className: r }) {
1254
+ let [i, a] = d(null), o = t !== void 0 && t !== "" && i !== t;
1255
+ return /* @__PURE__ */ R("span", {
1256
+ "aria-hidden": "true",
1257
+ className: V("inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-accent-subtle font-semibold text-accent", n === 32 ? "size-8 text-small" : "size-6 text-caption", r),
1258
+ children: o ? /* @__PURE__ */ R("img", {
1259
+ src: t,
1260
+ alt: "",
1261
+ width: n,
1262
+ height: n,
1263
+ referrerPolicy: "no-referrer",
1264
+ className: "size-full object-cover",
1265
+ onError: () => {
1266
+ a(t);
1267
+ }
1268
+ }) : Kn(e)
1269
+ });
1270
+ }
1271
+ //#endregion
1272
+ //#region ../ui/src/components/Tabs.tsx
1273
+ function Jn({ label: e, tabs: t, selected: n, onSelectedChange: r }) {
1274
+ return /* @__PURE__ */ z(_e, {
1275
+ selectedKey: n,
1276
+ onSelectionChange: (e) => {
1277
+ r(String(e));
1278
+ },
1279
+ className: "flex flex-col gap-6",
1280
+ children: [/* @__PURE__ */ R(fe, {
1281
+ "aria-label": e,
1282
+ className: "flex flex-wrap gap-x-6 border-b border-border",
1283
+ children: t.map((e) => /* @__PURE__ */ R(de, {
1284
+ id: e.id,
1285
+ className: V("relative -mb-px flex min-h-10 cursor-default items-center rounded-sm text-label text-content-muted outline-none", "after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:rounded-full after:content-['']", "data-[hovered]:text-content data-[hovered]:after:bg-border-strong", "data-[selected]:text-content data-[selected]:after:bg-accent", "data-[focus-visible]:outline-2 data-[focus-visible]:outline-solid data-[focus-visible]:outline-offset-2 data-[focus-visible]:outline-focus", U),
1286
+ children: e.label
1287
+ }, e.id))
1288
+ }), t.map((e) => /* @__PURE__ */ R(pe, {
1289
+ id: e.id,
1290
+ shouldForceMount: !0,
1291
+ className: "outline-none data-[inert]:hidden",
1292
+ children: /* @__PURE__ */ R("div", {
1293
+ "data-tab": e.id,
1294
+ hidden: e.id !== n,
1295
+ className: "flex flex-col gap-6",
1296
+ children: e.children
1297
+ })
1298
+ }, e.id))]
1299
+ });
1300
+ }
1301
+ //#endregion
1302
+ //#region ../ui/src/components/Toolbar.tsx
1303
+ function Yn({ label: e, children: t, className: n }) {
1304
+ return /* @__PURE__ */ R(Te, {
1305
+ "aria-label": e,
1306
+ className: V("flex flex-wrap items-center gap-1", n),
1307
+ children: t
1308
+ });
1309
+ }
1310
+ var Xn = V("inline-flex min-h-8 min-w-8 items-center justify-center rounded-sm border border-transparent px-2 text-small font-semibold text-content", "data-[hovered]:bg-surface-sunken data-[disabled]:opacity-50", U, H);
1311
+ function Zn() {
1312
+ return /* @__PURE__ */ R(ce, {
1313
+ orientation: "vertical",
1314
+ className: "mx-1 h-5 self-center border-l border-border"
1315
+ });
1316
+ }
1317
+ function Qn(e) {
1318
+ return e.icon ? {
1319
+ inside: /* @__PURE__ */ R(G, {
1320
+ name: e.icon,
1321
+ size: 18
1322
+ }),
1323
+ named: { "aria-label": e.label },
1324
+ tooltip: e.shortcut ? `${e.label} · ${e.shortcut.text}` : e.label
1325
+ } : {
1326
+ inside: e.children,
1327
+ named: {},
1328
+ tooltip: null
1329
+ };
1330
+ }
1331
+ var $n = "size-8 px-0";
1332
+ function er(e) {
1333
+ let t = u(null), n = e?.aria;
1334
+ return s(() => {
1335
+ n ? t.current?.setAttribute("aria-keyshortcuts", n) : t.current?.removeAttribute("aria-keyshortcuts");
1336
+ }, [n]), t;
1337
+ }
1338
+ function tr({ children: e, icon: t, label: n, shortcut: r, className: i, ...a }) {
1339
+ let { inside: o, named: s, tooltip: c } = Qn({
1340
+ children: e,
1341
+ icon: t,
1342
+ label: n,
1343
+ shortcut: r
1344
+ }), l = er(r), u = /* @__PURE__ */ R(we, {
1345
+ ...a,
1346
+ ...s,
1347
+ ref: l,
1348
+ className: V(Xn, c !== null && $n, "data-[selected]:bg-accent-subtle data-[selected]:text-accent", i),
1349
+ children: o
1350
+ });
1351
+ return c === null ? u : /* @__PURE__ */ R(wn, {
1352
+ text: c,
1353
+ children: u
1354
+ });
1355
+ }
1356
+ function nr({ children: e, icon: t, label: n, shortcut: r, className: i, ...a }) {
1357
+ let { inside: o, named: s, tooltip: c } = Qn({
1358
+ children: e,
1359
+ icon: t,
1360
+ label: n,
1361
+ shortcut: r
1362
+ }), l = er(r), u = /* @__PURE__ */ R(f, {
1363
+ ...a,
1364
+ ...s,
1365
+ ref: l,
1366
+ className: V(Xn, c !== null && $n, i),
1367
+ children: o
1368
+ });
1369
+ return c === null ? u : /* @__PURE__ */ R(wn, {
1370
+ text: c,
1371
+ children: u
1372
+ });
1373
+ }
1374
+ //#endregion
1375
+ //#region ../ui/src/components/Tree.tsx
1376
+ function rr({ label: e, items: t, textValue: n, renderRow: r, onAction: i, expandedKeys: a, onExpandedChange: o, dragAndDropHooks: s, onRowKeyDown: c, emptyState: l, currentKey: u, inset: d = 1 }) {
1377
+ let p = /* @__PURE__ */ new Map(), m = (e) => {
1378
+ for (let t of e) p.set(t.id, t), m(t.children);
1379
+ };
1380
+ m(t);
1381
+ let h = t.some((e) => e.children.length > 0), _ = (e) => {
1382
+ if (!c) return;
1383
+ let t = e.target.closest("[role=\"row\"]");
1384
+ if (t !== e.target) return;
1385
+ let n = p.get(t.getAttribute("data-key") ?? "");
1386
+ n && c(n, e);
1387
+ }, v = (e) => /* @__PURE__ */ z(ke, {
1388
+ id: e.id,
1389
+ textValue: n(e),
1390
+ ...i ? { onAction: () => {
1391
+ i(e);
1392
+ } } : {},
1393
+ className: V("group text-body outline-none", "data-[focus-visible]:outline-2 data-[focus-visible]:outline-solid data-[focus-visible]:-outline-offset-2 data-[focus-visible]:outline-focus", "data-[drop-target]:bg-accent-subtle data-[dragging]:opacity-50", e.id === u ? "bg-accent-subtle data-[hovered]:bg-accent-subtle-hover" : "data-[hovered]:bg-surface-sunken", U),
1394
+ children: [/* @__PURE__ */ R(Ae, { children: ({ isExpanded: t, hasChildItems: n, level: i, allowsDragging: a }) => /* @__PURE__ */ z("div", {
1395
+ className: "flex min-h-12 items-center gap-1 py-1",
1396
+ style: {
1397
+ paddingInlineStart: `calc(var(--spacing) * ${String(6 * (i - 1) + d)})`,
1398
+ paddingInlineEnd: `calc(var(--spacing) * ${String(d)})`
1399
+ },
1400
+ children: [
1401
+ a && /* @__PURE__ */ R(f, {
1402
+ slot: "drag",
1403
+ className: V("inline-flex size-8 shrink-0 cursor-grab items-center justify-center rounded-md text-content-muted data-[hovered]:text-content", "data-[disabled]:invisible", H),
1404
+ children: /* @__PURE__ */ R(G, { name: "drag" })
1405
+ }),
1406
+ n ? /* @__PURE__ */ R(f, {
1407
+ slot: "chevron",
1408
+ className: V("inline-flex size-8 shrink-0 items-center justify-center rounded-md text-content-muted data-[hovered]:bg-surface-sunken", H),
1409
+ children: /* @__PURE__ */ R(q, { className: t ? "rotate-0" : "-rotate-90" })
1410
+ }) : h && /* @__PURE__ */ R("span", {
1411
+ "aria-hidden": "true",
1412
+ className: "inline-block size-8 shrink-0"
1413
+ }),
1414
+ r(e, {
1415
+ isExpanded: t,
1416
+ hasChildItems: n,
1417
+ level: i
1418
+ })
1419
+ ]
1420
+ }) }), /* @__PURE__ */ R(g, {
1421
+ items: e.children,
1422
+ children: v
1423
+ })]
1424
+ });
1425
+ return /* @__PURE__ */ R("div", {
1426
+ onKeyDownCapture: _,
1427
+ children: /* @__PURE__ */ R(Oe, {
1428
+ "aria-label": e,
1429
+ items: t,
1430
+ ...a ? { expandedKeys: a } : {},
1431
+ ...o ? { onExpandedChange: o } : {},
1432
+ ...s ? { dragAndDropHooks: s } : {},
1433
+ renderEmptyState: () => /* @__PURE__ */ R("p", {
1434
+ className: "py-6 text-content-muted",
1435
+ style: { paddingInline: `calc(var(--spacing) * ${String(d + 2)})` },
1436
+ children: l
1437
+ }),
1438
+ className: "flex w-full flex-col gap-0.5",
1439
+ children: v
1440
+ })
1441
+ });
1442
+ }
1443
+ //#endregion
1444
+ //#region src/app/context.tsx
1445
+ var ir = "Vesper", ar = n(null);
1446
+ function J() {
1447
+ let e = o(ar);
1448
+ if (!e) throw Error("useStudio() must be used inside <App>.");
1449
+ return e;
1450
+ }
1451
+ //#endregion
1452
+ //#region src/app/format.ts
1453
+ var or = [
1454
+ ["year", 31536e3],
1455
+ ["month", 2592e3],
1456
+ ["week", 604800],
1457
+ ["day", 86400],
1458
+ ["hour", 3600],
1459
+ ["minute", 60]
1460
+ ];
1461
+ function sr(e, t = /* @__PURE__ */ new Date(), n) {
1462
+ let r = new Date(e), i = Math.round((r.getTime() - t.getTime()) / 1e3);
1463
+ if (Number.isNaN(i)) return "";
1464
+ if (Math.abs(i) < 45) return "just now";
1465
+ let a = new Intl.RelativeTimeFormat(n, { numeric: "auto" });
1466
+ for (let [e, t] of or) if (Math.abs(i) >= t || e === "minute") return a.format(Math.round(i / t), e);
1467
+ return "just now";
1468
+ }
1469
+ function cr(e, t, n, r) {
1470
+ return `${new Intl.NumberFormat(r).format(e)} ${e === 1 ? t : n}`;
1471
+ }
1472
+ //#endregion
1473
+ //#region src/app/load.ts
1474
+ function lr(e, t = "") {
1475
+ let [n, r] = d(null), [i, o] = d(0), c = u(e);
1476
+ s(() => {
1477
+ c.current = e;
1478
+ }), s(() => {
1479
+ let e = !0;
1480
+ return c.current().then((n) => {
1481
+ e && r({
1482
+ key: t,
1483
+ load: {
1484
+ state: "ready",
1485
+ value: n
1486
+ }
1487
+ });
1488
+ }, (n) => {
1489
+ let i = n instanceof Error ? n.message : String(n);
1490
+ e && r({
1491
+ key: t,
1492
+ load: {
1493
+ state: "failed",
1494
+ message: i
1495
+ }
1496
+ });
1497
+ }), () => {
1498
+ e = !1;
1499
+ };
1500
+ }, [t, i]);
1501
+ let l = a(() => {
1502
+ o((e) => e + 1);
1503
+ }, []);
1504
+ return [n?.key === t ? n.load : { state: "loading" }, l];
1505
+ }
1506
+ //#endregion
1507
+ //#region src/editor/values.ts
1508
+ function ur(e, t) {
1509
+ let n = e;
1510
+ for (let e of t) if (n = typeof e == "number" ? Array.isArray(n) ? n[e] : void 0 : B(n) ? n[e] : void 0, n === void 0) return;
1511
+ return n;
1512
+ }
1513
+ function dr(e, t, n) {
1514
+ return fr(e, t, 0, n);
1515
+ }
1516
+ function fr(e, t, n, r) {
1517
+ if (n === t.length) return r;
1518
+ let i = t[n];
1519
+ if (typeof i == "number") {
1520
+ let a = Array.isArray(e) ? [...e] : [];
1521
+ return a[i] = fr(a[i], t, n + 1, r), a;
1522
+ }
1523
+ let a = B(e) ? { ...e } : {}, o = fr(a[i], t, n + 1, r);
1524
+ return o === void 0 ? Reflect.deleteProperty(a, i) : a[i] = o, a;
1525
+ }
1526
+ function pr(e, t = "field") {
1527
+ return `${t}.${e.map((e) => String(e).replace(/[^A-Za-z0-9_]/g, "_")).join(".")}`;
1528
+ }
1529
+ function mr(e) {
1530
+ return e.map(String).join(".");
1531
+ }
1532
+ function Y(e) {
1533
+ return e.path.at(-1) ?? "";
1534
+ }
1535
+ function hr(e) {
1536
+ let t = {};
1537
+ for (let n of e ?? []) n.default !== void 0 && !n.defaultDynamic && (t[Y(n)] = structuredClone(n.default));
1538
+ return t;
1539
+ }
1540
+ //#endregion
1541
+ //#region src/editor/context.tsx
1542
+ var gr = n(null);
1543
+ function X() {
1544
+ let e = o(gr);
1545
+ if (!e) throw Error("useEditor() must be used inside an entry editor.");
1546
+ return e;
1547
+ }
1548
+ //#endregion
1549
+ //#region src/widgets/blank-date.ts
1550
+ var _r = /* @__PURE__ */ new Set([
1551
+ "Tab",
1552
+ "Shift",
1553
+ "Escape",
1554
+ "Enter",
1555
+ "Meta",
1556
+ "Control",
1557
+ "Alt"
1558
+ ]);
1559
+ function vr(e) {
1560
+ let [t, n] = d(!1);
1561
+ return {
1562
+ "data-blank": e === "" && !t ? "" : void 0,
1563
+ onPointerDown: () => {
1564
+ n(!0);
1565
+ },
1566
+ onKeyDown: (e) => {
1567
+ _r.has(e.key) || n(!0);
1568
+ },
1569
+ onBlur: (e) => {
1570
+ e.currentTarget.validity.badInput || n(!1);
1571
+ }
1572
+ };
1573
+ }
1574
+ //#endregion
1575
+ //#region src/widgets/basic.tsx
1576
+ var Z = V("min-h-10 w-full rounded-md border border-border-strong bg-surface-sunken px-3 py-2 text-body text-content", "outline-none focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-focus", "focus-visible:ring-6 focus-visible:ring-(color:--glow-focus)", "aria-[invalid=true]:border-danger disabled:opacity-60");
1577
+ function yr(e) {
1578
+ return e.required ? "" : void 0;
1579
+ }
1580
+ function br(e) {
1581
+ let { onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o } = e, s = e.value;
1582
+ return {
1583
+ id: r,
1584
+ value: typeof s == "string" ? s : typeof s == "number" || typeof s == "boolean" ? String(s) : "",
1585
+ onChange: (e) => {
1586
+ t(e.target.value === "" ? yr(n) : e.target.value);
1587
+ },
1588
+ "aria-describedby": i,
1589
+ "aria-invalid": a || void 0,
1590
+ "aria-required": n.required || void 0,
1591
+ disabled: o,
1592
+ placeholder: n.placeholder,
1593
+ autoComplete: n.autocomplete,
1594
+ className: Z
1595
+ };
1596
+ }
1597
+ function xr(e) {
1598
+ return /* @__PURE__ */ R("input", {
1599
+ type: "text",
1600
+ ...br(e)
1601
+ });
1602
+ }
1603
+ function Sr(e) {
1604
+ let t = br(e);
1605
+ return /* @__PURE__ */ R("input", {
1606
+ type: "email",
1607
+ inputMode: "email",
1608
+ ...t,
1609
+ autoComplete: t.autoComplete ?? "email"
1610
+ });
1611
+ }
1612
+ function Cr(e) {
1613
+ let t = e.field.widget === "markdown" ? 8 : 3;
1614
+ return /* @__PURE__ */ R("textarea", {
1615
+ rows: t,
1616
+ ...br(e),
1617
+ className: V(Z, "resize-y")
1618
+ });
1619
+ }
1620
+ function wr({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
1621
+ let [s, c] = d(e === void 0 ? "" : String(e)), l = n.constraints;
1622
+ return /* @__PURE__ */ R("input", {
1623
+ id: r,
1624
+ type: "number",
1625
+ inputMode: l?.integer ? "numeric" : "decimal",
1626
+ value: s,
1627
+ min: l?.min,
1628
+ max: l?.max,
1629
+ step: l?.step ?? (l?.integer ? 1 : "any"),
1630
+ onChange: (e) => {
1631
+ c(e.target.value), e.target.value === "" ? t(void 0) : Number.isFinite(e.target.valueAsNumber) && t(e.target.valueAsNumber);
1632
+ },
1633
+ "aria-describedby": i,
1634
+ "aria-invalid": a || void 0,
1635
+ "aria-required": n.required || void 0,
1636
+ disabled: o,
1637
+ className: V(Z, "max-w-48")
1638
+ });
1639
+ }
1640
+ function Tr({ value: e, onChange: t, id: n, describedBy: r, invalid: i, disabled: a }) {
1641
+ return /* @__PURE__ */ R(Rn, {
1642
+ id: n,
1643
+ isSelected: e === !0,
1644
+ onChange: t,
1645
+ isDisabled: a,
1646
+ isInvalid: i,
1647
+ "aria-labelledby": `${n}-label`,
1648
+ "aria-describedby": r,
1649
+ children: null
1650
+ });
1651
+ }
1652
+ function Er(e) {
1653
+ return e instanceof Date && !Number.isNaN(e.getTime()) ? e.toISOString().slice(0, 10) : typeof e == "string" ? e.slice(0, 10) : "";
1654
+ }
1655
+ function Dr({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
1656
+ let s = Er(e), c = vr(s);
1657
+ return /* @__PURE__ */ R("input", {
1658
+ id: r,
1659
+ type: "date",
1660
+ value: s,
1661
+ ...c,
1662
+ onChange: (r) => {
1663
+ let i = r.target.value;
1664
+ t(i === "" ? yr(n) === "" && typeof e == "string" ? "" : void 0 : typeof e == "string" ? i : /* @__PURE__ */ new Date(`${i}T00:00:00.000Z`));
1665
+ },
1666
+ "aria-describedby": i,
1667
+ "aria-invalid": a || void 0,
1668
+ "aria-required": n.required || void 0,
1669
+ disabled: o,
1670
+ className: V(Z, "max-w-56")
1671
+ });
1672
+ }
1673
+ function Or(e) {
1674
+ return e.constraints?.options ?? e.children?.[0]?.constraints?.options ?? [];
1675
+ }
1676
+ function kr({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
1677
+ return /* @__PURE__ */ R(Nn, {
1678
+ id: r,
1679
+ "aria-labelledby": `${r}-label`,
1680
+ "aria-describedby": i,
1681
+ options: Or(n),
1682
+ value: e ?? null,
1683
+ onChange: (e) => {
1684
+ t(e ?? void 0);
1685
+ },
1686
+ isInvalid: a,
1687
+ isDisabled: o
1688
+ });
1689
+ }
1690
+ function Ar({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
1691
+ return /* @__PURE__ */ R(zn, {
1692
+ id: r,
1693
+ "aria-labelledby": `${r}-label`,
1694
+ "aria-describedby": i,
1695
+ options: Or(n),
1696
+ value: e ?? null,
1697
+ onChange: t,
1698
+ isInvalid: a,
1699
+ isDisabled: o,
1700
+ orientation: Or(n).length <= 3 ? "horizontal" : "vertical"
1701
+ });
1702
+ }
1703
+ function jr({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
1704
+ let s = Array.isArray(e) ? e.filter((e) => typeof e == "string") : [], c = Or(n), l = n.children?.[0]?.kind === "enum";
1705
+ return /* @__PURE__ */ R(Fn, {
1706
+ id: r,
1707
+ "aria-labelledby": `${r}-label`,
1708
+ "aria-describedby": i,
1709
+ options: l ? c : s.map((e) => ({
1710
+ value: e,
1711
+ label: e
1712
+ })),
1713
+ values: s,
1714
+ onChange: (e) => {
1715
+ t(e.length === 0 && !n.required ? void 0 : e);
1716
+ },
1717
+ allowsCustomValue: !l,
1718
+ itemName: l ? "option" : "tag",
1719
+ isInvalid: a,
1720
+ isDisabled: o
1721
+ });
1722
+ }
1723
+ function Mr({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
1724
+ let [s, c] = d(() => Ve(e)), [l, u] = d(null), f = `${r}-yaml`;
1725
+ return /* @__PURE__ */ z(L, { children: [
1726
+ /* @__PURE__ */ R("textarea", {
1727
+ id: r,
1728
+ rows: Math.min(12, Math.max(3, s.split("\n").length + 1)),
1729
+ value: s,
1730
+ spellCheck: !1,
1731
+ onChange: (e) => {
1732
+ c(e.target.value);
1733
+ let n = Ze(e.target.value);
1734
+ n.ok ? (u(null), t(n.value)) : u(n.message);
1735
+ },
1736
+ "aria-describedby": [
1737
+ i,
1738
+ `${r}-raw`,
1739
+ l ? f : void 0
1740
+ ].filter(Boolean).join(" "),
1741
+ "aria-invalid": a || l !== null || void 0,
1742
+ "aria-required": n.required || void 0,
1743
+ disabled: o,
1744
+ className: V(Z, "resize-y font-mono text-small")
1745
+ }),
1746
+ /* @__PURE__ */ z("p", {
1747
+ id: `${r}-raw`,
1748
+ className: "text-small text-content-muted",
1749
+ children: ["Edited as YAML", n.unknownReason ? `: Vesper has no control for this ${n.unknownReason} field.` : "."]
1750
+ }),
1751
+ l && /* @__PURE__ */ R("p", {
1752
+ id: f,
1753
+ className: "text-small text-danger",
1754
+ children: l
1755
+ })
1756
+ ] });
1757
+ }
1758
+ //#endregion
1759
+ //#region src/widgets/geo.tsx
1760
+ var Nr = i(() => import("./geo-map-CT3OGD7O.js"));
1761
+ function Pr(e) {
1762
+ if (!B(e)) return {};
1763
+ let { lat: t, lng: n } = e;
1764
+ return {
1765
+ ...typeof t == "number" ? { lat: t } : {},
1766
+ ...typeof n == "number" ? { lng: n } : {}
1767
+ };
1768
+ }
1769
+ function Fr({ value: e, onChange: n, field: r, id: i, disabled: a, invalid: o, describedBy: s }) {
1770
+ let c = Pr(e), [l, u] = d(!1), f = (t, i) => {
1771
+ let a = {
1772
+ ...B(e) ? e : {},
1773
+ [t]: i
1774
+ };
1775
+ i === void 0 && Reflect.deleteProperty(a, t), n(Object.keys(a).length === 0 && !r.required ? void 0 : a);
1776
+ }, p = r.widgetOptions;
1777
+ return /* @__PURE__ */ z("div", {
1778
+ className: "flex flex-col gap-3",
1779
+ children: [/* @__PURE__ */ z("div", {
1780
+ className: "flex flex-wrap gap-4",
1781
+ children: [/* @__PURE__ */ R(Ir, {
1782
+ id: i,
1783
+ label: "Latitude",
1784
+ hint: "−90 to 90, north is positive",
1785
+ value: c.lat,
1786
+ min: -90,
1787
+ max: 90,
1788
+ onChange: (e) => {
1789
+ f("lat", e);
1790
+ },
1791
+ disabled: a,
1792
+ invalid: o,
1793
+ describedBy: s
1794
+ }), /* @__PURE__ */ R(Ir, {
1795
+ id: `${i}-lng`,
1796
+ label: "Longitude",
1797
+ hint: "−180 to 180, east is positive",
1798
+ value: c.lng,
1799
+ min: -180,
1800
+ max: 180,
1801
+ onChange: (e) => {
1802
+ f("lng", e);
1803
+ },
1804
+ disabled: a,
1805
+ invalid: o,
1806
+ describedBy: s
1807
+ })]
1808
+ }), l ? /* @__PURE__ */ R(t, {
1809
+ fallback: /* @__PURE__ */ R("p", {
1810
+ className: "text-small text-content-muted",
1811
+ children: "Loading the map…"
1812
+ }),
1813
+ children: /* @__PURE__ */ R(Nr, {
1814
+ label: r.label,
1815
+ point: c.lat !== void 0 && c.lng !== void 0 ? c : null,
1816
+ center: p?.defaultCenter,
1817
+ zoom: p?.zoom,
1818
+ disabled: a,
1819
+ onChange: (t) => {
1820
+ n({
1821
+ ...B(e) ? e : {},
1822
+ lat: t.lat,
1823
+ lng: t.lng
1824
+ });
1825
+ }
1826
+ })
1827
+ }) : /* @__PURE__ */ R("div", { children: /* @__PURE__ */ R(K, {
1828
+ variant: "quiet",
1829
+ onPress: () => {
1830
+ u(!0);
1831
+ },
1832
+ children: "Show on a map"
1833
+ }) })]
1834
+ });
1835
+ }
1836
+ function Ir({ id: e, label: t, hint: n, value: r, min: i, max: a, onChange: o, disabled: s, invalid: c, describedBy: l }) {
1837
+ let [u, f] = d(r === void 0 ? "" : String(r)), [p, m] = d(r);
1838
+ return r !== p && (m(r), f(r === void 0 ? "" : String(r))), /* @__PURE__ */ z("div", {
1839
+ className: "flex flex-col gap-1",
1840
+ children: [
1841
+ /* @__PURE__ */ R("label", {
1842
+ htmlFor: e,
1843
+ className: "text-small text-content",
1844
+ children: t
1845
+ }),
1846
+ /* @__PURE__ */ R("input", {
1847
+ id: e,
1848
+ type: "number",
1849
+ inputMode: "decimal",
1850
+ step: "any",
1851
+ min: i,
1852
+ max: a,
1853
+ value: u,
1854
+ onChange: (e) => {
1855
+ f(e.target.value);
1856
+ let t = e.target.value === "" ? void 0 : e.target.valueAsNumber;
1857
+ (t === void 0 || Number.isFinite(t)) && (m(t), o(t));
1858
+ },
1859
+ "aria-describedby": [l, `${e}-hint`].filter(Boolean).join(" "),
1860
+ "aria-invalid": c || void 0,
1861
+ disabled: s,
1862
+ className: V(Z, "w-44")
1863
+ }),
1864
+ /* @__PURE__ */ R("p", {
1865
+ id: `${e}-hint`,
1866
+ className: "text-small text-content-muted",
1867
+ children: n
1868
+ })
1869
+ ]
1870
+ });
1871
+ }
1872
+ //#endregion
1873
+ //#region src/app/file-url.tsx
1874
+ function Lr(e) {
1875
+ let { api: t } = J(), [n, r] = d(null);
1876
+ return s(() => {
1877
+ if (!e) return;
1878
+ let n = !0;
1879
+ return t.fileUrl(e).then((t) => {
1880
+ n && r({
1881
+ path: e,
1882
+ url: t
1883
+ });
1884
+ }, () => {}), () => {
1885
+ n = !1;
1886
+ };
1887
+ }, [t, e]), e && n?.path === e ? n.url : "";
1888
+ }
1889
+ function Rr({ path: e, className: t, loading: n }) {
1890
+ let r = Lr(e);
1891
+ return r ? /* @__PURE__ */ R("img", {
1892
+ src: r,
1893
+ alt: "",
1894
+ loading: n,
1895
+ className: t
1896
+ }) : /* @__PURE__ */ R("span", {
1897
+ "aria-hidden": "true",
1898
+ className: t
1899
+ });
1900
+ }
1901
+ //#endregion
1902
+ //#region src/editor/reveal.ts
1903
+ var zr = "vesper:reveal";
1904
+ function Br(e) {
1905
+ return e.closest("[hidden], [inert]") !== null;
1906
+ }
1907
+ function Vr(e, t = 20, n = !1) {
1908
+ let r = document.getElementById(e);
1909
+ r && !Br(r) ? (r.scrollIntoView({ block: "center" }), r.focus()) : (r && !n && (r.dispatchEvent(new CustomEvent(zr, { bubbles: !0 })), n = !0), t > 0 && setTimeout(() => {
1910
+ Vr(e, t - 1, n);
1911
+ }, 25));
1912
+ }
1913
+ //#endregion
1914
+ //#region src/widgets/union.tsx
1915
+ function Hr(e, t) {
1916
+ return {
1917
+ [e.discriminator ?? ""]: t.value,
1918
+ ...hr(t.children)
1919
+ };
1920
+ }
1921
+ function Ur(e) {
1922
+ return e == null || e === "" ? !0 : Array.isArray(e) ? e.length === 0 : B(e) && Object.values(e).every(Ur);
1923
+ }
1924
+ function Wr(e, t, n, r) {
1925
+ let i = e.discriminator ?? "", a = ot(e, t), o = B(t) ? t : {}, s = hr(n.children), c = { [i]: n.value }, l = [];
1926
+ for (let e of n.children) {
1927
+ let t = Y(e), n = a?.children.find((e) => Y(e) === t), i = !a || n?.kind === e.kind ? o[t] : void 0;
1928
+ i === void 0 ? r?.[t] === void 0 ? s[t] !== void 0 && (c[t] = s[t]) : c[t] = r[t] : (c[t] = i, Ur(i) || l.push(e.label));
1929
+ }
1930
+ return {
1931
+ value: c,
1932
+ kept: l,
1933
+ dropped: Object.keys(o).filter((e) => e !== i && !(e in c) && !Ur(o[e])).map((e) => a?.children.find((t) => Y(t) === e)?.label ?? We(e))
1934
+ };
1935
+ }
1936
+ function Gr(e) {
1937
+ let t = (e) => e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e.at(-1) ?? ""}`;
1938
+ return [e.kept.length > 0 ? `${t(e.kept)} kept.` : "", e.dropped.length > 0 ? `${t(e.dropped)} removed.` : ""].filter(Boolean).join(" ");
1939
+ }
1940
+ var Kr = [
1941
+ "title",
1942
+ "name",
1943
+ "label",
1944
+ "heading",
1945
+ "text"
1946
+ ], qr = (e) => e.replace(/[*_`]/g, "").trim();
1947
+ function Jr(e, t) {
1948
+ let n = ot(t, e);
1949
+ if (!n) {
1950
+ let n = B(e) ? e[t.discriminator ?? ""] : void 0;
1951
+ return {
1952
+ name: typeof n == "string" && n ? `Unknown kind: ${n}` : "No kind",
1953
+ detail: ""
1954
+ };
1955
+ }
1956
+ if (!B(e)) return {
1957
+ name: n.label,
1958
+ detail: ""
1959
+ };
1960
+ let r = n.children.filter((e) => !e.hidden);
1961
+ for (let t of [
1962
+ n.summary,
1963
+ ...Kr,
1964
+ ...r.map(Y)
1965
+ ]) {
1966
+ let r = t ? e[t] : void 0;
1967
+ if (typeof r == "string" && qr(r)) return {
1968
+ name: n.label,
1969
+ detail: qr(r)
1970
+ };
1971
+ }
1972
+ let i = r.find((e) => e.kind === "array");
1973
+ if (i) {
1974
+ let t = e[Y(i)], r = i.label.toLowerCase(), a = /[^s]s$/.test(r) ? r.slice(0, -1) : r;
1975
+ return {
1976
+ name: n.label,
1977
+ detail: cr(Array.isArray(t) ? t.length : 0, a, r)
1978
+ };
1979
+ }
1980
+ return {
1981
+ name: n.label,
1982
+ detail: ""
1983
+ };
1984
+ }
1985
+ function Yr({ kind: e, path: t }) {
1986
+ return /* @__PURE__ */ R("div", {
1987
+ className: "flex flex-col gap-4",
1988
+ children: e.children.filter((e) => !e.hidden).map((e) => /* @__PURE__ */ R(Wa, {
1989
+ field: e,
1990
+ path: [...t, Y(e)]
1991
+ }, Y(e)))
1992
+ });
1993
+ }
1994
+ var Xr = "";
1995
+ function Zr(e) {
1996
+ let { value: t, onChange: n, field: r, path: i, id: a, describedBy: o, invalid: s, disabled: c, inRow: l } = e, d = u(/* @__PURE__ */ new Map()), f = ot(r, t), p = r.variants ?? [], m = f ? f.children.length > 0 ? /* @__PURE__ */ R(Yr, {
1997
+ kind: f,
1998
+ path: i
1999
+ }) : l ? /* @__PURE__ */ R("p", {
2000
+ className: "text-small text-content-muted",
2001
+ children: "This kind has nothing more to fill in."
2002
+ }) : null : t != null && !f ? /* @__PURE__ */ z("div", {
2003
+ className: "flex flex-col gap-2",
2004
+ children: [
2005
+ /* @__PURE__ */ R("label", {
2006
+ htmlFor: `${a}-yaml`,
2007
+ className: "text-label text-content",
2008
+ children: Jr(t, r).name
2009
+ }),
2010
+ /* @__PURE__ */ R("p", {
2011
+ id: `${a}-unknown`,
2012
+ className: "text-small text-content-muted",
2013
+ children: "The site has no kind by this name. Change it to one it has, or edit it here."
2014
+ }),
2015
+ /* @__PURE__ */ R(Mr, {
2016
+ value: t,
2017
+ onChange: n,
2018
+ field: {
2019
+ ...r,
2020
+ unknownReason: void 0
2021
+ },
2022
+ id: `${a}-yaml`,
2023
+ describedBy: [o, `${a}-unknown`].filter(Boolean).join(" "),
2024
+ invalid: s,
2025
+ disabled: c
2026
+ })
2027
+ ]
2028
+ }) : null;
2029
+ if (l) return m;
2030
+ let h = (e) => {
2031
+ f && d.current.set(f.value, B(t) ? t : {});
2032
+ let i = p.find((t) => t.value === e);
2033
+ n(i ? Wr(r, t, i, d.current.get(i.value)).value : void 0);
2034
+ }, g = [...r.required ? [] : [{
2035
+ value: Xr,
2036
+ label: "None"
2037
+ }], ...p.map((e) => ({
2038
+ value: e.value,
2039
+ label: e.label
2040
+ }))], _ = f ? f.value : t === void 0 ? Xr : null, v = g.length <= 4 ? /* @__PURE__ */ R(zn, {
2041
+ id: `${a}-kind`,
2042
+ label: "Kind",
2043
+ options: g,
2044
+ value: _,
2045
+ onChange: h,
2046
+ isDisabled: c,
2047
+ orientation: g.length <= 3 ? "horizontal" : "vertical"
2048
+ }) : /* @__PURE__ */ R(Nn, {
2049
+ id: `${a}-kind`,
2050
+ label: "Kind",
2051
+ options: g,
2052
+ value: _,
2053
+ onChange: (e) => {
2054
+ h(e ?? Xr);
2055
+ },
2056
+ isDisabled: c
2057
+ });
2058
+ return /* @__PURE__ */ z("div", {
2059
+ className: "flex flex-col gap-4",
2060
+ children: [
2061
+ v,
2062
+ f?.description && /* @__PURE__ */ R("p", {
2063
+ className: "text-small text-content-muted",
2064
+ children: f.description
2065
+ }),
2066
+ m
2067
+ ]
2068
+ });
2069
+ }
2070
+ //#endregion
2071
+ //#region src/widgets/group.tsx
2072
+ function Qr({ field: e, path: t }) {
2073
+ let n = (e.children ?? []).filter((e) => !e.hidden);
2074
+ return /* @__PURE__ */ R("div", {
2075
+ className: "flex flex-col gap-4",
2076
+ children: n.map((e) => /* @__PURE__ */ R(Wa, {
2077
+ field: e,
2078
+ path: [...t, Y(e)]
2079
+ }, Y(e)))
2080
+ });
2081
+ }
2082
+ function $r(e) {
2083
+ let t = e.children?.[0], n = e.label.toLowerCase(), r = t?.label && t.label !== "[]" && t.label !== "Item" ? t.label : "";
2084
+ return {
2085
+ one: r ? r.toLowerCase() : /[^s]s$/.test(n) ? n.slice(0, -1) : n,
2086
+ many: n
2087
+ };
2088
+ }
2089
+ var ei = (e) => e.charAt(0).toLocaleUpperCase() + e.slice(1), ti = [
2090
+ "title",
2091
+ "name",
2092
+ "label",
2093
+ "heading",
2094
+ "text"
2095
+ ];
2096
+ function ni(e) {
2097
+ return e?.kind === "image" || e?.widget === "image" || e?.inferredWidget === "image";
2098
+ }
2099
+ function ri(e) {
2100
+ return e.slice(e.lastIndexOf("/") + 1);
2101
+ }
2102
+ function ii(e) {
2103
+ let t = B(e) ? e.src : e;
2104
+ return typeof t == "string" ? t : "";
2105
+ }
2106
+ var ai = (e) => e.replace(/[*_`]/g, "").trim();
2107
+ function oi(e, t, n) {
2108
+ let r = {
2109
+ name: `${ei($r(n).one)} ${String(t + 1)}`,
2110
+ key: void 0
2111
+ };
2112
+ if (typeof e == "string") return e.trim() ? {
2113
+ name: ai(e),
2114
+ key: void 0
2115
+ } : r;
2116
+ if (ni(n.children?.[0])) {
2117
+ let t = B(e) && typeof e.alt == "string" ? e.alt.trim() : "", n = ii(e);
2118
+ return t ? {
2119
+ name: t,
2120
+ key: "alt"
2121
+ } : n ? {
2122
+ name: ri(n),
2123
+ key: "src"
2124
+ } : r;
2125
+ }
2126
+ if (!B(e)) return r;
2127
+ let i = (n.children?.[0]?.children ?? []).filter((e) => !e.hidden).map(Y);
2128
+ for (let t of [
2129
+ n.summary,
2130
+ ...ti,
2131
+ ...i
2132
+ ]) {
2133
+ if (!t) continue;
2134
+ let n = e[t];
2135
+ if (typeof n == "string" && n.trim()) return {
2136
+ name: ai(n),
2137
+ key: t
2138
+ };
2139
+ }
2140
+ return r;
2141
+ }
2142
+ function si(e, t, n) {
2143
+ if (!B(e)) return "";
2144
+ let r = t.children ?? [], i = r.find((e) => e.kind === "array" && !e.hidden);
2145
+ if (i) {
2146
+ let t = e[Y(i)], { one: n, many: r } = $r(i);
2147
+ return cr(Array.isArray(t) ? t.length : 0, n, r);
2148
+ }
2149
+ for (let t of r) {
2150
+ let r = Y(t), i = e[r];
2151
+ if (r !== n && !t.hidden && typeof i == "string" && i.trim()) return ai(i);
2152
+ }
2153
+ return "";
2154
+ }
2155
+ function ci(e, t) {
2156
+ if (!e) return 0;
2157
+ let n = 0;
2158
+ for (let [r, i] of e) (r === t || r.startsWith(`${t}.`)) && i.length > 0 && (n += i.length);
2159
+ return n;
2160
+ }
2161
+ function li(e) {
2162
+ return e ? e.default !== void 0 && !e.defaultDynamic ? structuredClone(e.default) : e.kind === "object" ? {} : e.kind === "boolean" ? !1 : e.kind === "array" ? [] : e.kind === "number" ? 0 : "" : null;
2163
+ }
2164
+ var ui = 0, di = () => `item${String(++ui)}`, fi = "application/x-vesper-list-item";
2165
+ function pi(e) {
2166
+ return e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e.at(-1) ?? ""}`;
2167
+ }
2168
+ function mi({ value: e, onChange: t, field: n, path: r, disabled: i, id: a }) {
2169
+ let o = X(), c = Array.isArray(e) ? e : [], l = n.children?.[0], f = $r(n), p = l?.kind === "union" ? l.variants ?? [] : null, m = l?.kind === "object" || p !== null || ni(l), h = n.constraints?.max, g = h !== void 0 && c.length >= h, _ = u(null), v = u(null), y = u(/* @__PURE__ */ new Map()), [b, x] = d(null), [S, C] = d(() => c.map(() => di())), w = S;
2170
+ S.length !== c.length && (w = c.map((e, t) => S[t] ?? di()), C(w));
2171
+ let [T, E] = d(() => /* @__PURE__ */ new Set()), [ee, te] = d(null), D = (e, t) => {
2172
+ E((n) => {
2173
+ if (n.has(e) === t) return n;
2174
+ let r = new Set(n);
2175
+ return t ? r.add(e) : r.delete(e), r;
2176
+ });
2177
+ }, [O, ne] = d(o.issues);
2178
+ if (O !== o.issues) {
2179
+ ne(o.issues);
2180
+ let e = w.filter((e, t) => ci(o.issues, mr([...r, t])) > 0);
2181
+ e.length > 0 && E((t) => /* @__PURE__ */ new Set([...t, ...e]));
2182
+ }
2183
+ s(() => {
2184
+ let e = v.current;
2185
+ if (!e) return;
2186
+ let t = (t) => {
2187
+ let n = t.target, r = [...e.children].findIndex((e) => e.contains(n)), i = w[r];
2188
+ i && E((e) => e.has(i) ? e : /* @__PURE__ */ new Set([...e, i]));
2189
+ };
2190
+ return e.addEventListener(zr, t), () => {
2191
+ e.removeEventListener(zr, t);
2192
+ };
2193
+ }, [w]);
2194
+ let k = (e) => {
2195
+ _.current && (_.current.textContent = e);
2196
+ }, A = (e) => {
2197
+ setTimeout(() => {
2198
+ e()?.focus();
2199
+ }, 0);
2200
+ }, re = (e) => document.getElementById(`${a}-more-${e}`)?.querySelector("button") ?? null, j = (e) => () => m ? document.getElementById(`${a}-row-${e}`) : re(e), M = (e) => {
2201
+ t(e.length === 0 && !n.required ? void 0 : e);
2202
+ }, N = (e, t) => {
2203
+ if (p && l) return Jr(e, l);
2204
+ let { name: r, key: i } = oi(e, t, n);
2205
+ return {
2206
+ name: r,
2207
+ detail: l && m ? si(e, l, i) : ""
2208
+ };
2209
+ }, P = (e) => N(c[e] ?? null, e).name, ie = (e) => p?.find((t) => t.value === e), F = (e, t) => {
2210
+ if (t < 0 || t >= c.length || i) return;
2211
+ let n = P(e), r = [...c], [a] = r.splice(e, 1);
2212
+ r.splice(t, 0, a ?? null);
2213
+ let o = [...w], [s = di()] = o.splice(e, 1);
2214
+ o.splice(t, 0, s), C(o), M(r), k(`Moved ${n} to position ${String(t + 1)} of ${String(r.length)}.`), A(j(s));
2215
+ }, ae = (e) => {
2216
+ if (g) return;
2217
+ let t = structuredClone(c[e] ?? null), n = di();
2218
+ C([
2219
+ ...w.slice(0, e + 1),
2220
+ n,
2221
+ ...w.slice(e + 1)
2222
+ ]), M([
2223
+ ...c.slice(0, e + 1),
2224
+ t,
2225
+ ...c.slice(e + 1)
2226
+ ]), k(`Duplicated ${P(e)} as ${f.one} ${String(e + 2)}.`), A(j(n));
2227
+ }, oe = (e) => {
2228
+ let t = P(e), n = w.filter((t, n) => n !== e), r = c.filter((t, n) => n !== e);
2229
+ C(n), M(r), k(`Removed ${t}.`);
2230
+ let i = n[Math.min(e, r.length - 1)];
2231
+ A(i ? j(i) : () => document.getElementById(`${a}-add`));
2232
+ }, se = (e, t) => {
2233
+ if (g || i) return;
2234
+ let n = di();
2235
+ C([
2236
+ ...w.slice(0, e),
2237
+ n,
2238
+ ...w.slice(e)
2239
+ ]), m && D(n, !0);
2240
+ let r = t && l ? Hr(l, t) : li(l);
2241
+ M([
2242
+ ...c.slice(0, e),
2243
+ r,
2244
+ ...c.slice(e)
2245
+ ]);
2246
+ let o = `${f.one} ${String(e + 1)}`;
2247
+ k(t ? `Added ${t.label}, ${o} of ${String(c.length + 1)}.` : `Added ${o}.`), A(() => document.getElementById(`${a}-panel-${n}`)?.querySelector("input, textarea, [contenteditable=\"true\"], button") ?? j(n)());
2248
+ }, [ce, le] = d(null), [ue, I] = d(null), de = (e) => {
2249
+ let t = v.current, n = ce === null ? -1 : w.indexOf(ce);
2250
+ if (!t || n === -1) return null;
2251
+ let r = t.getBoundingClientRect(), i = [...t.children].map((e) => e.getBoundingClientRect()), a = i.findIndex((t) => r.top + e < t.top + t.height / 2), o = a === -1 ? i.length : a, s = i[o - 1], c = i[o];
2252
+ if (o === n || o === n + 1 || !s && !c) return null;
2253
+ let l = (Number.parseFloat(getComputedStyle(t).rowGap) || 0) / 2;
2254
+ return {
2255
+ slot: o,
2256
+ top: (s && c ? (s.bottom + c.top) / 2 : s ? s.bottom + l : (c?.top ?? 0) - l) - (t.parentElement?.getBoundingClientRect() ?? r).top
2257
+ };
2258
+ }, { dropProps: fe } = Ne({
2259
+ ref: v,
2260
+ isDisabled: ce === null,
2261
+ hasDropButton: !0,
2262
+ getDropOperation: (e) => e.has(fi) ? "move" : "cancel",
2263
+ onDropEnter: ({ y: e }) => {
2264
+ I(de(e));
2265
+ },
2266
+ onDropMove: ({ y: e }) => {
2267
+ let t = de(e);
2268
+ I((e) => e?.slot === t?.slot ? e : t);
2269
+ },
2270
+ onDropExit: () => {
2271
+ I(null);
2272
+ },
2273
+ onDrop: ({ y: e }) => {
2274
+ let t = de(e), n = ce === null ? -1 : w.indexOf(ce);
2275
+ I(null), t && n !== -1 && F(n, t.slot > n ? t.slot - 1 : t.slot);
2276
+ }
2277
+ }), pe = i ? void 0 : (e) => ({
2278
+ onStart: () => {
2279
+ le(e);
2280
+ },
2281
+ onEnd: () => {
2282
+ le(null), I(null);
2283
+ }
2284
+ }), me = (e, t, n = !1) => {
2285
+ let r = w[e];
2286
+ if (!l || !r || i) return;
2287
+ let a = c[e] ?? null, o = y.current.get(r) ?? /* @__PURE__ */ new Map(), s = Wr(l, a, t, o.get(t.value));
2288
+ if (s.dropped.length > 0 && !n) {
2289
+ x({
2290
+ index: e,
2291
+ itemId: r,
2292
+ from: P(e),
2293
+ to: t,
2294
+ dropped: s.dropped
2295
+ });
2296
+ return;
2297
+ }
2298
+ let u = ot(l, a);
2299
+ u && B(a) && o.set(u.value, a), y.current.set(r, o), M(c.map((t, n) => n === e ? s.value : t)), k(`Changed to ${t.label}. ${Gr(s)}`.trim()), A(j(r));
2300
+ }, he = (e, t) => (p ?? []).filter((e) => e.value !== t).map((t) => ({
2301
+ id: `${e}:${t.value}`,
2302
+ label: t.label,
2303
+ ...t.description ? { description: t.description } : {}
2304
+ })), ge = (e) => {
2305
+ let t = [{
2306
+ id: "up",
2307
+ label: "Move up",
2308
+ icon: "move-up",
2309
+ isDisabled: i || e === 0
2310
+ }, {
2311
+ id: "down",
2312
+ label: "Move down",
2313
+ icon: "move-down",
2314
+ isDisabled: i || e === c.length - 1
2315
+ }], n = [{
2316
+ id: "duplicate",
2317
+ label: "Duplicate",
2318
+ icon: "duplicate",
2319
+ isDisabled: i || g
2320
+ }, {
2321
+ id: "remove",
2322
+ label: "Remove",
2323
+ icon: "delete",
2324
+ isDanger: !0,
2325
+ isDisabled: i
2326
+ }];
2327
+ if (!p || !l) return [...t, ...n];
2328
+ let [r] = p, a = p.length === 1 && r ? {
2329
+ id: `below:${r.value}`,
2330
+ label: "Add below",
2331
+ icon: "add"
2332
+ } : {
2333
+ id: "below",
2334
+ label: "Add below",
2335
+ icon: "add",
2336
+ items: he("below")
2337
+ }, o = he("change", ot(l, c[e] ?? null)?.value);
2338
+ return [
2339
+ ...t,
2340
+ {
2341
+ ...a,
2342
+ isDisabled: i || g
2343
+ },
2344
+ ...o.length > 0 ? [{
2345
+ id: "change",
2346
+ label: "Change to",
2347
+ icon: "change-kind",
2348
+ isDisabled: i,
2349
+ items: o
2350
+ }] : [],
2351
+ ...n
2352
+ ];
2353
+ }, _e = (e) => (t) => {
2354
+ t === "up" && F(e, e - 1), t === "down" && F(e, e + 1), t === "duplicate" && ae(e), t === "remove" && oe(e);
2355
+ let n = t.startsWith("below:") ? ie(t.slice(6)) : void 0;
2356
+ n && se(e + 1, n);
2357
+ let r = t.startsWith("change:") ? ie(t.slice(7)) : void 0;
2358
+ r && me(e, r);
2359
+ }, ve = (e, t, n) => /* @__PURE__ */ R(hi, {
2360
+ id: `${a}-more-${t}`,
2361
+ label: `Actions for ${n}`,
2362
+ items: ge(e),
2363
+ onAction: _e(e),
2364
+ isOpen: ee === t,
2365
+ onOpenChange: (e) => {
2366
+ te(e ? t : null);
2367
+ }
2368
+ }), ye = `Add ${f.one}`, be = c.length > 0 && w.every((e) => T.has(e));
2369
+ return /* @__PURE__ */ z("div", {
2370
+ className: "relative flex flex-col gap-3",
2371
+ children: [
2372
+ m && c.length >= 3 && /* @__PURE__ */ R("div", {
2373
+ className: "-mt-1 flex justify-end",
2374
+ children: /* @__PURE__ */ R(K, {
2375
+ variant: "quiet",
2376
+ onPress: () => {
2377
+ E(be ? /* @__PURE__ */ new Set() : new Set(w));
2378
+ },
2379
+ children: be ? "Close all" : "Open all"
2380
+ })
2381
+ }),
2382
+ c.length === 0 && /* @__PURE__ */ R("p", {
2383
+ className: "text-small text-content-muted",
2384
+ children: "None yet."
2385
+ }),
2386
+ /* @__PURE__ */ R("ol", {
2387
+ ...fe,
2388
+ ref: v,
2389
+ className: V("flex flex-col", m ? "gap-2" : "gap-3"),
2390
+ children: c.map((e, t) => {
2391
+ let n = w[t] ?? String(t), { name: i, detail: s } = N(e, t), c = p && s ? `${i}, ${s}` : i;
2392
+ if (!l) return null;
2393
+ if (!m) return /* @__PURE__ */ z("li", {
2394
+ className: "flex items-end gap-2",
2395
+ children: [/* @__PURE__ */ R("div", {
2396
+ className: "min-w-0 flex-1",
2397
+ children: /* @__PURE__ */ R(Wa, {
2398
+ field: l,
2399
+ path: [...r, t],
2400
+ label: `${ei(f.one)} ${String(t + 1)}`,
2401
+ item: "inline"
2402
+ })
2403
+ }), ve(t, n, c)]
2404
+ }, n);
2405
+ let u = mr([...r, t]);
2406
+ return /* @__PURE__ */ R("li", { children: /* @__PURE__ */ R(vi, {
2407
+ id: a,
2408
+ itemId: n,
2409
+ name: i,
2410
+ detail: s,
2411
+ problems: ci(o.issues, u),
2412
+ notes: ci(o.notes, u),
2413
+ image: ni(l) ? ii(e) : null,
2414
+ headingLevel: r.length === 1 ? 3 : null,
2415
+ isOpen: T.has(n),
2416
+ onOpenChange: (e) => {
2417
+ D(n, e);
2418
+ },
2419
+ onKeyDown: (e) => {
2420
+ e.altKey && e.key === "ArrowUp" ? (e.preventDefault(), F(t, t - 1)) : e.altKey && e.key === "ArrowDown" ? (e.preventDefault(), F(t, t + 1)) : e.shiftKey && e.key === "F10" || e.key === "ContextMenu" ? (e.preventDefault(), te(n)) : e.continuePropagation();
2421
+ },
2422
+ menu: ve(t, n, c),
2423
+ drag: pe?.(n),
2424
+ editor: o,
2425
+ children: /* @__PURE__ */ R(Wa, {
2426
+ field: l,
2427
+ path: [...r, t],
2428
+ label: i,
2429
+ item: "row"
2430
+ })
2431
+ }) }, n);
2432
+ })
2433
+ }),
2434
+ ue && /* @__PURE__ */ R("span", {
2435
+ "aria-hidden": "true",
2436
+ className: "pointer-events-none absolute inset-x-0 h-0.5 -translate-y-1/2 rounded-full bg-accent",
2437
+ style: { top: ue.top }
2438
+ }),
2439
+ /* @__PURE__ */ z("div", {
2440
+ className: "flex flex-col items-start gap-1",
2441
+ children: [p && p.length > 1 ? /* @__PURE__ */ R(On, {
2442
+ label: ye,
2443
+ trigger: /* @__PURE__ */ R(K, {
2444
+ id: `${a}-add`,
2445
+ icon: "add",
2446
+ isDisabled: i || g,
2447
+ children: ye
2448
+ }),
2449
+ items: he("add"),
2450
+ onAction: (e) => {
2451
+ let t = ie(e.slice(4));
2452
+ t && se(c.length, t);
2453
+ }
2454
+ }) : /* @__PURE__ */ R(K, {
2455
+ id: `${a}-add`,
2456
+ icon: "add",
2457
+ isDisabled: i || g,
2458
+ onPress: () => {
2459
+ se(c.length, p?.[0]);
2460
+ },
2461
+ children: ye
2462
+ }), g && /* @__PURE__ */ z("p", {
2463
+ className: "text-small text-content-muted",
2464
+ children: [
2465
+ "At most ",
2466
+ cr(h, f.one, f.many),
2467
+ "."
2468
+ ]
2469
+ })]
2470
+ }),
2471
+ /* @__PURE__ */ R("p", {
2472
+ ref: _,
2473
+ role: "status",
2474
+ className: "sr-only"
2475
+ }),
2476
+ /* @__PURE__ */ R(Sn, {
2477
+ title: b ? `Change ${b.from} to ${b.to.label}?` : "",
2478
+ role: "alertdialog",
2479
+ isOpen: b !== null,
2480
+ onOpenChange: (e) => {
2481
+ e || x(null);
2482
+ },
2483
+ children: b && /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ z("p", {
2484
+ className: "mb-6",
2485
+ children: [
2486
+ pi(b.dropped),
2487
+ " ",
2488
+ b.dropped.length === 1 ? "has" : "have",
2489
+ " no place in",
2490
+ " ",
2491
+ b.to.label,
2492
+ ", so ",
2493
+ b.dropped.length === 1 ? "it is" : "they are",
2494
+ " removed. Changing back before you save brings ",
2495
+ b.dropped.length === 1 ? "it" : "them",
2496
+ " ",
2497
+ "back."
2498
+ ]
2499
+ }), /* @__PURE__ */ z("div", {
2500
+ className: "flex flex-wrap justify-end gap-3",
2501
+ children: [/* @__PURE__ */ R(K, {
2502
+ onPress: () => {
2503
+ x(null), A(j(b.itemId));
2504
+ },
2505
+ children: "Cancel"
2506
+ }), /* @__PURE__ */ z(K, {
2507
+ variant: "danger",
2508
+ onPress: () => {
2509
+ x(null), me(b.index, b.to, !0);
2510
+ },
2511
+ children: ["Change to ", b.to.label]
2512
+ })]
2513
+ })] })
2514
+ })
2515
+ ]
2516
+ });
2517
+ }
2518
+ function hi(e) {
2519
+ let { id: t, ...n } = e;
2520
+ return /* @__PURE__ */ R("span", {
2521
+ id: t,
2522
+ className: "flex shrink-0",
2523
+ children: /* @__PURE__ */ R(On, { ...n })
2524
+ });
2525
+ }
2526
+ function gi({ src: e, entryPath: t }) {
2527
+ let n = Lr(e ? et(e, t) : null);
2528
+ return n ? /* @__PURE__ */ R("img", {
2529
+ src: n,
2530
+ alt: "",
2531
+ className: "size-10 shrink-0 rounded-sm object-cover"
2532
+ }) : /* @__PURE__ */ R("span", {
2533
+ "aria-hidden": "true",
2534
+ className: "size-10 shrink-0 rounded-sm bg-surface-sunken"
2535
+ });
2536
+ }
2537
+ function _i({ dragProps: e, header: t }) {
2538
+ return /* @__PURE__ */ R("span", {
2539
+ ...e,
2540
+ "aria-hidden": "true",
2541
+ onDragStart: (n) => {
2542
+ e.onDragStart?.(n);
2543
+ let r = t.current;
2544
+ if (!r || n.defaultPrevented) return;
2545
+ let i = r.getBoundingClientRect();
2546
+ n.dataTransfer.setDragImage(r, n.clientX - i.left, n.clientY - i.top);
2547
+ },
2548
+ className: "ml-1 inline-flex size-8 shrink-0 cursor-grab items-center justify-center rounded-md text-content-muted hover:text-content active:cursor-grabbing",
2549
+ children: /* @__PURE__ */ R(G, { name: "drag" })
2550
+ });
2551
+ }
2552
+ function vi({ id: e, itemId: t, name: n, detail: r, problems: i, notes: a, image: o, headingLevel: s, isOpen: c, onOpenChange: l, onKeyDown: d, menu: p, drag: m, editor: h, children: g }) {
2553
+ let _ = u(null), { dragProps: v, isDragging: y } = je({
2554
+ isDisabled: !m,
2555
+ hasDragButton: !0,
2556
+ getItems: () => [{ [fi]: t }],
2557
+ getAllowedDropOperations: () => ["move"],
2558
+ onDragStart: () => m?.onStart(),
2559
+ onDragEnd: () => m?.onEnd()
2560
+ }), S = /* @__PURE__ */ z(f, {
2561
+ slot: "trigger",
2562
+ id: `${e}-row-${t}`,
2563
+ onKeyDown: d,
2564
+ className: V("flex min-h-11 w-full min-w-0 items-center gap-2 rounded-md py-1 pl-2 text-left text-body text-content", H),
2565
+ children: [
2566
+ /* @__PURE__ */ R(q, { className: "shrink-0 -rotate-90 group-data-[expanded]:rotate-0" }),
2567
+ o !== null && /* @__PURE__ */ R(gi, {
2568
+ src: o,
2569
+ entryPath: h.entryPath
2570
+ }),
2571
+ /* @__PURE__ */ R("span", {
2572
+ className: "max-w-2/3 min-w-0 shrink-0 truncate",
2573
+ children: n
2574
+ }),
2575
+ r && /* @__PURE__ */ z("span", {
2576
+ className: "min-w-0 flex-1 truncate text-small text-content-muted",
2577
+ children: [
2578
+ /* @__PURE__ */ R("span", {
2579
+ className: "sr-only",
2580
+ children: ","
2581
+ }),
2582
+ " ",
2583
+ r
2584
+ ]
2585
+ }),
2586
+ i > 0 && /* @__PURE__ */ z("span", {
2587
+ className: "shrink-0 text-small text-danger",
2588
+ children: [
2589
+ /* @__PURE__ */ R("span", {
2590
+ className: "sr-only",
2591
+ children: ","
2592
+ }),
2593
+ " ",
2594
+ cr(i, "problem", "problems")
2595
+ ]
2596
+ }),
2597
+ a > 0 && /* @__PURE__ */ z("span", {
2598
+ className: "shrink-0 text-small text-content-muted",
2599
+ children: [
2600
+ /* @__PURE__ */ R("span", {
2601
+ className: "sr-only",
2602
+ children: ","
2603
+ }),
2604
+ " ",
2605
+ cr(a, "note", "notes")
2606
+ ]
2607
+ })
2608
+ ]
2609
+ });
2610
+ return /* @__PURE__ */ z(b, {
2611
+ id: t,
2612
+ isExpanded: c,
2613
+ onExpandedChange: l,
2614
+ className: V("group rounded-md border border-border bg-surface-raised", y && "opacity-50"),
2615
+ children: [/* @__PURE__ */ z("div", {
2616
+ ref: _,
2617
+ className: V("flex items-center gap-1 rounded-md bg-surface-raised pr-1", !c && "hover:bg-surface-sunken"),
2618
+ children: [
2619
+ m && /* @__PURE__ */ R(_i, {
2620
+ dragProps: v,
2621
+ header: _
2622
+ }),
2623
+ s ? /* @__PURE__ */ R(T, {
2624
+ level: s,
2625
+ className: "m-0 min-w-0 flex-1",
2626
+ children: S
2627
+ }) : /* @__PURE__ */ R("div", {
2628
+ className: "min-w-0 flex-1",
2629
+ children: S
2630
+ }),
2631
+ p
2632
+ ]
2633
+ }), /* @__PURE__ */ R(x, { children: /* @__PURE__ */ R("div", {
2634
+ id: `${e}-panel-${t}`,
2635
+ className: "border-t border-border px-4 pt-3 pb-4",
2636
+ children: g
2637
+ }) })]
2638
+ });
2639
+ }
2640
+ //#endregion
2641
+ //#region src/widgets/icon.tsx
2642
+ function yi({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
2643
+ let { manifest: s } = J(), c = l(() => {
2644
+ let e = s.icons ?? {};
2645
+ return (n.constraints?.options ?? []).map((t) => {
2646
+ let n = Object.hasOwn(e, t.value) ? e[t.value] : void 0;
2647
+ return {
2648
+ ...t,
2649
+ prefix: n ? /* @__PURE__ */ R(G, { node: n }) : /* @__PURE__ */ R("span", { className: "block size-5" })
2650
+ };
2651
+ });
2652
+ }, [n, s.icons]);
2653
+ return /* @__PURE__ */ R(Pn, {
2654
+ id: r,
2655
+ "aria-labelledby": `${r}-label`,
2656
+ "aria-describedby": i,
2657
+ options: c,
2658
+ value: typeof e == "string" ? e : null,
2659
+ onChange: (e) => {
2660
+ t(e ?? void 0);
2661
+ },
2662
+ placeholder: "Search icons",
2663
+ isRequired: n.required,
2664
+ isInvalid: a,
2665
+ isDisabled: o
2666
+ });
2667
+ }
2668
+ //#endregion
2669
+ //#region src/a11y/FieldNotes.tsx
2670
+ function bi({ note: e }) {
2671
+ return /* @__PURE__ */ z(L, { children: [
2672
+ e.subject ? `${e.subject}: ` : "",
2673
+ e.message,
2674
+ " ",
2675
+ /* @__PURE__ */ R("span", {
2676
+ className: "text-content-muted",
2677
+ children: e.why
2678
+ })
2679
+ ] });
2680
+ }
2681
+ function xi({ id: e, notes: t }) {
2682
+ return /* @__PURE__ */ R("ul", {
2683
+ id: e,
2684
+ className: "m-0 flex list-none flex-col gap-1 p-0",
2685
+ children: t.map((e, t) => /* @__PURE__ */ R("li", {
2686
+ className: "flex gap-2 text-small text-content",
2687
+ children: /* @__PURE__ */ R(Ci, { children: /* @__PURE__ */ R(bi, { note: e }) })
2688
+ }, `${e.rule}:${String(t)}`))
2689
+ });
2690
+ }
2691
+ function Si({ id: e, children: t }) {
2692
+ return /* @__PURE__ */ R("p", {
2693
+ id: e,
2694
+ className: "flex gap-2 text-small text-content",
2695
+ children: /* @__PURE__ */ R(Ci, { children: t })
2696
+ });
2697
+ }
2698
+ function Ci({ children: e }) {
2699
+ return /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R(G, {
2700
+ name: "warning",
2701
+ size: 16,
2702
+ className: "mt-0.5 text-warning"
2703
+ }), /* @__PURE__ */ z("span", { children: [/* @__PURE__ */ R("span", {
2704
+ className: "font-semibold",
2705
+ children: "Accessibility note: "
2706
+ }), e] })] });
2707
+ }
2708
+ //#endregion
2709
+ //#region src/media/formats.ts
2710
+ var Q = (e, t, n) => String.fromCharCode(...e.subarray(t, t + n));
2711
+ function wi(e) {
2712
+ if (e[0] === 255 && e[1] === 216 && e[2] === 255) return "jpeg";
2713
+ if (Q(e, 0, 8) === "‰PNG\r\n\n") return "png";
2714
+ if (Q(e, 0, 4) === "GIF8") return "gif";
2715
+ if (Q(e, 0, 4) === "RIFF" && Q(e, 8, 4) === "WEBP") return "webp";
2716
+ if (Q(e, 0, 5) === "%PDF-") return "pdf";
2717
+ if (Q(e, 4, 4) === "ftyp") {
2718
+ let t = $(e).getUint32(0), n = [Q(e, 8, 4)];
2719
+ for (let r = 16; r + 4 <= Math.min(t, e.length); r += 4) n.push(Q(e, r, 4));
2720
+ if (n.some((e) => e === "avif" || e === "avis")) return "avif";
2721
+ if (n.some((e) => [
2722
+ "heic",
2723
+ "heix",
2724
+ "hevc",
2725
+ "hevx",
2726
+ "heim",
2727
+ "heis",
2728
+ "mif1",
2729
+ "msf1"
2730
+ ].includes(e))) return "heic";
2731
+ }
2732
+ let t = new TextDecoder().decode(e.subarray(0, 1024)).replace(/^\uFEFF/, "").trimStart();
2733
+ return /^(<\?xml[^>]*>\s*)?(<!--[\s\S]*?-->\s*)*(<!DOCTYPE svg[^>]*>\s*)?<svg[\s>]/i.test(t) ? "svg" : "other";
2734
+ }
2735
+ function $(e) {
2736
+ return new DataView(e.buffer, e.byteOffset, e.byteLength);
2737
+ }
2738
+ function Ti(e) {
2739
+ let t = [], n = 2;
2740
+ for (; n + 4 <= e.length && e[n] === 255;) {
2741
+ let r = e[n + 1] ?? 0;
2742
+ if (r === 255) {
2743
+ n += 1;
2744
+ continue;
2745
+ }
2746
+ let i = $(e).getUint16(n + 2), a = n + 2 + i;
2747
+ if (r === 218) return {
2748
+ segments: t,
2749
+ dataStart: n
2750
+ };
2751
+ t.push({
2752
+ marker: r,
2753
+ start: n,
2754
+ end: a
2755
+ }), n = a;
2756
+ }
2757
+ return {
2758
+ segments: t,
2759
+ dataStart: n
2760
+ };
2761
+ }
2762
+ function Ei(e) {
2763
+ if (e.length < 8) return { hasLocation: !1 };
2764
+ let t = Q(e, 0, 2) === "II", n = $(e), r = (e) => n.getUint16(e, t), i = ((e) => n.getUint32(e, t))(4);
2765
+ if (i + 2 > e.length) return { hasLocation: !1 };
2766
+ let a, o = !1, s = r(i);
2767
+ for (let t = 0; t < s; t++) {
2768
+ let n = i + 2 + t * 12;
2769
+ if (n + 12 > e.length) break;
2770
+ let s = r(n);
2771
+ s === 274 && (a = r(n + 8)), s === 34853 && (o = !0);
2772
+ }
2773
+ return {
2774
+ ...a === void 0 ? {} : { orientation: a },
2775
+ hasLocation: o
2776
+ };
2777
+ }
2778
+ var Di = /* @__PURE__ */ new Set([
2779
+ 224,
2780
+ 226,
2781
+ 238
2782
+ ]);
2783
+ function Oi(e) {
2784
+ let t = {
2785
+ hasLocation: !1,
2786
+ hasMetadata: !1
2787
+ };
2788
+ for (let n of Ti(e).segments) {
2789
+ let r = e.subarray(n.start + 4, n.end);
2790
+ n.marker === 225 && Q(r, 0, 6) === "Exif\0\0" && Object.assign(t, Ei(r.subarray(6))), (n.marker >= 225 && n.marker <= 239 && !Di.has(n.marker) || n.marker === 254) && (t.hasMetadata = !0), n.marker >= 192 && n.marker <= 207 && ![
2791
+ 196,
2792
+ 200,
2793
+ 204
2794
+ ].includes(n.marker) && (t.height = $(e).getUint16(n.start + 5), t.width = $(e).getUint16(n.start + 7));
2795
+ }
2796
+ return t;
2797
+ }
2798
+ function ki(e) {
2799
+ let { segments: t, dataStart: n } = Ti(e), r = [e.subarray(0, 2)];
2800
+ for (let n of t) n.marker >= 225 && n.marker <= 239 && !Di.has(n.marker) || n.marker === 254 || r.push(e.subarray(n.start, n.end));
2801
+ return r.push(e.subarray(n)), Ri(r);
2802
+ }
2803
+ var Ai = /* @__PURE__ */ new Set([
2804
+ "eXIf",
2805
+ "tEXt",
2806
+ "iTXt",
2807
+ "zTXt",
2808
+ "tIME"
2809
+ ]);
2810
+ function ji(e) {
2811
+ let t = [], n = 8;
2812
+ for (; n + 12 <= e.length;) {
2813
+ let r = $(e).getUint32(n), i = Q(e, n + 4, 4), a = n + 12 + r;
2814
+ if (t.push({
2815
+ type: i,
2816
+ start: n,
2817
+ end: a
2818
+ }), n = a, i === "IEND") break;
2819
+ }
2820
+ return t;
2821
+ }
2822
+ function Mi(e) {
2823
+ let t = ji(e), n = t.find((e) => e.type === "IHDR"), r = t.find((e) => e.type === "eXIf");
2824
+ return {
2825
+ ...n ? {
2826
+ width: $(e).getUint32(n.start + 8),
2827
+ height: $(e).getUint32(n.start + 12)
2828
+ } : {},
2829
+ ...r ? Ei(e.subarray(r.start + 8, r.end - 4)) : { hasLocation: !1 },
2830
+ hasMetadata: t.some((e) => Ai.has(e.type))
2831
+ };
2832
+ }
2833
+ function Ni(e) {
2834
+ let t = [e.subarray(0, 8)];
2835
+ for (let n of ji(e)) Ai.has(n.type) || t.push(e.subarray(n.start, n.end));
2836
+ return Ri(t);
2837
+ }
2838
+ function Pi(e) {
2839
+ let t = [], n = 12;
2840
+ for (; n + 8 <= e.length;) {
2841
+ let r = $(e).getUint32(n + 4, !0), i = n + 8 + r + r % 2;
2842
+ t.push({
2843
+ type: Q(e, n, 4),
2844
+ start: n,
2845
+ end: Math.min(i, e.length)
2846
+ }), n = i;
2847
+ }
2848
+ return t;
2849
+ }
2850
+ function Fi(e) {
2851
+ let t = Pi(e), n = $(e), r = {
2852
+ hasLocation: !1,
2853
+ hasMetadata: t.some((e) => e.type === "EXIF" || e.type === "XMP ")
2854
+ }, i = t.find((e) => e.type === "EXIF");
2855
+ if (i) {
2856
+ let t = e.subarray(i.start + 8, i.end);
2857
+ Q(t, 0, 6) === "Exif\0\0" && (t = t.subarray(6)), Object.assign(r, Ei(t));
2858
+ }
2859
+ for (let e of t) {
2860
+ let t = e.start + 8;
2861
+ if (e.type === "VP8X") {
2862
+ r.width = 1 + (n.getUint32(t + 4, !0) & 16777215), r.height = 1 + (n.getUint32(t + 7, !0) & 16777215);
2863
+ break;
2864
+ }
2865
+ if (e.type === "VP8 ") {
2866
+ r.width = n.getUint16(t + 6, !0) & 16383, r.height = n.getUint16(t + 8, !0) & 16383;
2867
+ break;
2868
+ }
2869
+ if (e.type === "VP8L") {
2870
+ let e = n.getUint32(t + 1, !0);
2871
+ r.width = 1 + (e & 16383), r.height = 1 + (e >> 14 & 16383);
2872
+ break;
2873
+ }
2874
+ }
2875
+ return r;
2876
+ }
2877
+ function Ii(e) {
2878
+ let t = [];
2879
+ for (let n of Pi(e)) {
2880
+ if (n.type === "EXIF" || n.type === "XMP ") continue;
2881
+ let r = e.slice(n.start, n.end);
2882
+ n.type === "VP8X" && (r[8] = (r[8] ?? 0) & -13), t.push(r);
2883
+ }
2884
+ let n = Ri(t), r = new Uint8Array(12 + n.length);
2885
+ return r.set(e.subarray(0, 12)), r.set(n, 12), new DataView(r.buffer).setUint32(4, r.length - 8, !0), r;
2886
+ }
2887
+ function Li(e, t) {
2888
+ return e === "jpeg" ? Oi(t) : e === "png" ? Mi(t) : e === "webp" ? Fi(t) : {
2889
+ hasLocation: !1,
2890
+ hasMetadata: !1
2891
+ };
2892
+ }
2893
+ function Ri(e) {
2894
+ let t = new Uint8Array(e.reduce((e, t) => e + t.length, 0)), n = 0;
2895
+ for (let r of e) t.set(r, n), n += r.length;
2896
+ return t;
2897
+ }
2898
+ //#endregion
2899
+ //#region src/media/hygiene.ts
2900
+ var zi = /* @__PURE__ */ new Set([
2901
+ "jpeg",
2902
+ "png",
2903
+ "gif",
2904
+ "webp",
2905
+ "avif",
2906
+ "heic",
2907
+ "svg"
2908
+ ]);
2909
+ async function Bi(e, t = {}) {
2910
+ let n = t.maxEdge ?? 3e3, r = new Uint8Array(await e.arrayBuffer()), i = wi(r);
2911
+ if (t.accept === "image" && !zi.has(i)) return {
2912
+ ok: !1,
2913
+ message: `${e.name} isn’t an image this site can use (JPEG, PNG, WebP, AVIF, GIF or SVG).`
2914
+ };
2915
+ let a = [], o = r, s = e.name, c, l;
2916
+ if (i === "svg") {
2917
+ let e = Gi(new TextDecoder().decode(r));
2918
+ e.removed && a.push("Removed scripts and unsafe links from the SVG"), o = new TextEncoder().encode(e.svg);
2919
+ } else if (i === "heic") {
2920
+ let e = await Wi(new Blob([r]), "image/jpeg", n);
2921
+ if (!e) return {
2922
+ ok: !1,
2923
+ message: "This browser can’t convert iPhone (HEIC) photos. Export the photo as JPEG first, or upload it from Safari."
2924
+ };
2925
+ o = e.bytes, {width: c, height: l} = e, s = s.replace(/\.(heic|heif)$/i, "") + ".jpg", a.push("Converted from HEIC to JPEG", "Removed location and camera data");
2926
+ } else if (i === "jpeg" || i === "png" || i === "webp") {
2927
+ let e = Li(i, r);
2928
+ ({width: c, height: l} = e);
2929
+ let t = (e.orientation ?? 1) !== 1, s = Math.max(e.width ?? 0, e.height ?? 0) > n;
2930
+ if (t || s) {
2931
+ let u = i === "jpeg" ? "image/jpeg" : i === "png" ? "image/png" : "image/webp", d = await Wi(new Blob([r], { type: u }), u, n);
2932
+ d ? (o = d.bytes, s && a.push(`Resized from ${String(e.width)}×${String(e.height)} to ${String(d.width)}×${String(d.height)}`), t && a.push("Turned the photo upright"), {width: c, height: l} = d) : (o = Vi(i, r), a.push("Couldn’t resize this image in this browser, so it was kept at full size"));
2933
+ } else o = Vi(i, r);
2934
+ e.hasLocation ? a.push("Removed location data") : e.hasMetadata && a.push("Removed camera and editing metadata");
2935
+ }
2936
+ return o.length > Fe ? {
2937
+ ok: !1,
2938
+ message: `${s} is ${Hi(o.length)} even after processing. The limit is ${Hi(Fe)}.`
2939
+ } : {
2940
+ ok: !0,
2941
+ upload: {
2942
+ bytes: o,
2943
+ name: s,
2944
+ type: i === "heic" ? "jpeg" : i,
2945
+ notes: a,
2946
+ large: o.length > Ie,
2947
+ ...c === void 0 ? {} : { width: c },
2948
+ ...l === void 0 ? {} : { height: l }
2949
+ }
2950
+ };
2951
+ }
2952
+ function Vi(e, t) {
2953
+ return e === "jpeg" ? ki(t) : e === "png" ? Ni(t) : Ii(t);
2954
+ }
2955
+ function Hi(e) {
2956
+ return `${(e / 1024 / 1024).toFixed(1)} MB`;
2957
+ }
2958
+ function Ui(e) {
2959
+ return e < 1024 ? `${String(e)} bytes` : e < 1048576 ? `${String(Math.round(e / 1024))} KB` : Hi(e);
2960
+ }
2961
+ async function Wi(e, t, n) {
2962
+ if (typeof createImageBitmap != "function") return null;
2963
+ let r;
2964
+ try {
2965
+ r = await createImageBitmap(e, { imageOrientation: "from-image" });
2966
+ } catch {
2967
+ return null;
2968
+ }
2969
+ let i = Math.min(1, n / Math.max(r.width, r.height)), a = Math.round(r.width * i), o = Math.round(r.height * i), s = document.createElement("canvas");
2970
+ s.width = a, s.height = o;
2971
+ let c = s.getContext("2d");
2972
+ if (!c) return null;
2973
+ c.imageSmoothingQuality = "high", c.drawImage(r, 0, 0, a, o), r.close();
2974
+ let l = await new Promise((e) => {
2975
+ s.toBlob(e, t, t === "image/png" ? void 0 : .9);
2976
+ });
2977
+ return !l || l.type !== t ? null : {
2978
+ bytes: new Uint8Array(await l.arrayBuffer()),
2979
+ width: a,
2980
+ height: o
2981
+ };
2982
+ }
2983
+ function Gi(e) {
2984
+ let t = lt(window), n = !1;
2985
+ t.addHook("uponSanitizeElement", (e, t) => {
2986
+ if (t.tagName === "set" || /^animate/i.test(t.tagName)) {
2987
+ let t = e.getAttribute("attributeName") ?? "";
2988
+ /^(on|href$|xlink:href$)/i.test(t) && (e.parentNode?.removeChild(e), n = !0);
2989
+ }
2990
+ }), t.addHook("uponSanitizeAttribute", (e, t) => {
2991
+ /^(href|xlink:href)$/i.test(t.attrName) && /^\s*(javascript|data|vbscript):/i.test(t.attrValue) && (t.keepAttr = !1, n = !0);
2992
+ });
2993
+ let r = t.sanitize(e, {
2994
+ USE_PROFILES: {
2995
+ svg: !0,
2996
+ svgFilters: !0
2997
+ },
2998
+ FORBID_TAGS: [
2999
+ "foreignObject",
3000
+ "script",
3001
+ "iframe",
3002
+ "embed",
3003
+ "object"
3004
+ ]
3005
+ });
3006
+ return t.removed.some((e) => !("element" in e) || e.element.nodeName !== "BODY") && (n = !0), {
3007
+ svg: r.startsWith("<svg") ? r : "<svg xmlns=\"http://www.w3.org/2000/svg\"></svg>",
3008
+ removed: n
3009
+ };
3010
+ }
3011
+ //#endregion
3012
+ //#region src/media/file-icon.ts
3013
+ var Ki = [
3014
+ ["file-text", [
3015
+ "pdf",
3016
+ "doc",
3017
+ "docx",
3018
+ "odt",
3019
+ "rtf",
3020
+ "txt",
3021
+ "md",
3022
+ "mdx",
3023
+ "mdoc",
3024
+ "ppt",
3025
+ "pptx",
3026
+ "key"
3027
+ ]],
3028
+ ["file-sheet", [
3029
+ "csv",
3030
+ "tsv",
3031
+ "xls",
3032
+ "xlsx",
3033
+ "ods",
3034
+ "numbers"
3035
+ ]],
3036
+ ["file-archive", [
3037
+ "zip",
3038
+ "gz",
3039
+ "tgz",
3040
+ "tar",
3041
+ "7z",
3042
+ "rar"
3043
+ ]],
3044
+ ["file-video", [
3045
+ "mp4",
3046
+ "m4v",
3047
+ "mov",
3048
+ "webm",
3049
+ "ogv"
3050
+ ]],
3051
+ ["file-audio", [
3052
+ "mp3",
3053
+ "m4a",
3054
+ "wav",
3055
+ "ogg",
3056
+ "oga",
3057
+ "flac",
3058
+ "aac"
3059
+ ]]
3060
+ ];
3061
+ function qi(e) {
3062
+ return Ki.find(([, t]) => t.includes(e))?.[0] ?? "file";
3063
+ }
3064
+ //#endregion
3065
+ //#region src/media/upload.ts
3066
+ async function Ji(e, t, n) {
3067
+ let r = await Bi(e, n);
3068
+ if (!r.ok) return {
3069
+ step: "refused",
3070
+ message: r.message
3071
+ };
3072
+ let i = await Ue(r.upload.bytes), a = t.find((e) => e.hash === i);
3073
+ return a ? {
3074
+ step: "duplicate",
3075
+ upload: r.upload,
3076
+ existing: a.path
3077
+ } : r.upload.large ? {
3078
+ step: "confirm-large",
3079
+ upload: r.upload
3080
+ } : {
3081
+ step: "ready",
3082
+ upload: r.upload
3083
+ };
3084
+ }
3085
+ async function Yi(e, t, n, r = {}) {
3086
+ let i = await e.upload(new Blob([t.bytes]), t.name, n, r);
3087
+ return i.ok ? {
3088
+ ok: !0,
3089
+ path: i.path
3090
+ } : i;
3091
+ }
3092
+ //#endregion
3093
+ //#region src/media/MediaPicker.tsx
3094
+ function Xi({ isOpen: e, onOpenChange: t, kind: n, extensions: r = [], folder: i, onChoose: a }) {
3095
+ return /* @__PURE__ */ R(Sn, {
3096
+ title: n === "image" ? "Choose an image" : "Choose a file",
3097
+ isOpen: e,
3098
+ onOpenChange: t,
3099
+ children: e && /* @__PURE__ */ R(Zi, {
3100
+ kind: n,
3101
+ extensions: r,
3102
+ folder: i,
3103
+ onChoose: (e, n) => {
3104
+ a(e, n), t(!1);
3105
+ }
3106
+ })
3107
+ });
3108
+ }
3109
+ function Zi({ kind: e, extensions: t = [], folder: n, onChoose: r }) {
3110
+ let { api: i, siteName: a, manifest: o } = J(), s = o.site.images?.maxUploadEdge, [c, f] = lr(() => i.listMedia(), "media"), [p, m] = d(null), [h, g] = d(""), _ = u(null), v = (n) => e === "image" ? Ke(n) : t.length === 0 || t.includes(Be(n)), y = l(() => {
3111
+ let e = h.trim().toLowerCase();
3112
+ return (c.state === "ready" ? c.value : []).filter((e) => v(e.path)).filter((t) => e === "" || t.path.toLowerCase().includes(e));
3113
+ }, [c, h]), b = async (e) => {
3114
+ m({
3115
+ step: "working",
3116
+ text: "Uploading…"
3117
+ });
3118
+ let t = await Yi(i, e.upload, n, { withNextSave: !0 });
3119
+ t.ok ? (f(), r(t.path, e.upload.notes)) : m({
3120
+ step: "refused",
3121
+ message: t.message
3122
+ });
3123
+ }, x = e === "image" ? "image/*,.heic,.heif" : t.length > 0 ? t.map((e) => `.${e}`).join(",") : void 0;
3124
+ return /* @__PURE__ */ z("div", {
3125
+ className: "flex flex-col gap-6",
3126
+ children: [/* @__PURE__ */ z("section", {
3127
+ "aria-labelledby": "picker-upload",
3128
+ className: "flex flex-col gap-3",
3129
+ children: [
3130
+ /* @__PURE__ */ R("h3", {
3131
+ id: "picker-upload",
3132
+ className: "text-heading-3",
3133
+ children: "Upload from your computer"
3134
+ }),
3135
+ /* @__PURE__ */ R("p", {
3136
+ className: "text-small text-content-muted",
3137
+ children: e === "image" ? `Large photos are scaled down, turned upright, and stripped of location data before they’re added to ${a}.` : `The file is added to ${n}.`
3138
+ }),
3139
+ /* @__PURE__ */ R("input", {
3140
+ ref: _,
3141
+ type: "file",
3142
+ accept: x,
3143
+ tabIndex: -1,
3144
+ "aria-hidden": "true",
3145
+ className: "sr-only",
3146
+ onChange: (t) => {
3147
+ let n = t.target.files?.[0];
3148
+ t.target.value = "", n && (m({
3149
+ step: "working",
3150
+ text: `Preparing ${n.name}…`
3151
+ }), Ji(n, c.state === "ready" ? c.value : [], {
3152
+ accept: e === "image" ? "image" : "any",
3153
+ ...s ? { maxEdge: s } : {}
3154
+ }).then((e) => {
3155
+ e.step === "ready" ? b(e) : m(e);
3156
+ }));
3157
+ }
3158
+ }),
3159
+ /* @__PURE__ */ R("div", { children: /* @__PURE__ */ R(K, {
3160
+ icon: "upload",
3161
+ onPress: () => {
3162
+ _.current?.click();
3163
+ },
3164
+ children: e === "image" ? "Upload an image" : "Upload a file"
3165
+ }) }),
3166
+ /* @__PURE__ */ R($i, {
3167
+ step: p,
3168
+ onUpload: (e) => void b(e),
3169
+ onReuse: r,
3170
+ onCancel: () => {
3171
+ m(null);
3172
+ }
3173
+ })
3174
+ ]
3175
+ }), /* @__PURE__ */ z("section", {
3176
+ "aria-labelledby": "picker-existing",
3177
+ className: "flex flex-col gap-3",
3178
+ children: [
3179
+ /* @__PURE__ */ R("h3", {
3180
+ id: "picker-existing",
3181
+ className: "text-heading-3",
3182
+ children: "Or choose one already in the site"
3183
+ }),
3184
+ /* @__PURE__ */ R(_n, {
3185
+ label: "Search by file name",
3186
+ type: "search",
3187
+ icon: "search",
3188
+ value: h,
3189
+ onChange: g
3190
+ }),
3191
+ c.state === "loading" && /* @__PURE__ */ R("p", {
3192
+ className: "text-small text-content-muted",
3193
+ children: "Loading files…"
3194
+ }),
3195
+ c.state === "failed" && /* @__PURE__ */ z("p", {
3196
+ role: "alert",
3197
+ className: "text-danger",
3198
+ children: ["Couldn’t list files: ", c.message]
3199
+ }),
3200
+ c.state === "ready" && y.length === 0 && /* @__PURE__ */ z("p", {
3201
+ className: "text-content-muted",
3202
+ children: [
3203
+ "No ",
3204
+ e === "image" ? "images" : "files",
3205
+ " found."
3206
+ ]
3207
+ }),
3208
+ /* @__PURE__ */ R("ul", {
3209
+ className: "grid max-h-80 grid-cols-1 gap-2 overflow-y-auto sm:grid-cols-2",
3210
+ children: y.map((e) => /* @__PURE__ */ R("li", { children: /* @__PURE__ */ R(Qi, {
3211
+ item: e,
3212
+ onChoose: r
3213
+ }) }, e.path))
3214
+ })
3215
+ ]
3216
+ })]
3217
+ });
3218
+ }
3219
+ function Qi({ item: e, onChoose: t }) {
3220
+ let n = e.path.slice(e.path.lastIndexOf("/") + 1);
3221
+ return /* @__PURE__ */ z("button", {
3222
+ type: "button",
3223
+ onClick: () => {
3224
+ t(e.path);
3225
+ },
3226
+ className: "flex w-full items-center gap-3 rounded-md border border-border p-2 text-left hover:bg-surface-sunken focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-focus focus-visible:ring-6 focus-visible:ring-(color:--glow-focus)",
3227
+ children: [Ke(e.path) ? /* @__PURE__ */ R(Rr, {
3228
+ path: e.path,
3229
+ loading: "lazy",
3230
+ className: "size-12 shrink-0 rounded-md object-cover"
3231
+ }) : /* @__PURE__ */ R("span", {
3232
+ "aria-hidden": "true",
3233
+ className: "flex size-12 shrink-0 items-center justify-center rounded-md bg-surface-sunken text-content-muted",
3234
+ children: /* @__PURE__ */ R(G, {
3235
+ name: qi(Be(e.path)),
3236
+ size: 24
3237
+ })
3238
+ }), /* @__PURE__ */ z("span", {
3239
+ className: "min-w-0",
3240
+ children: [/* @__PURE__ */ R("span", {
3241
+ className: "block truncate font-semibold",
3242
+ children: n
3243
+ }), /* @__PURE__ */ z("span", {
3244
+ className: "block font-mono text-caption break-all text-content-muted",
3245
+ children: [
3246
+ e.path.slice(0, e.path.lastIndexOf("/")),
3247
+ " · ",
3248
+ Ui(e.size)
3249
+ ]
3250
+ })]
3251
+ })]
3252
+ });
3253
+ }
3254
+ function $i({ step: e, onUpload: t, onReuse: n, onCancel: r }) {
3255
+ if (!e) return null;
3256
+ if (e.step === "working") return /* @__PURE__ */ R("p", {
3257
+ role: "status",
3258
+ children: e.text
3259
+ });
3260
+ if (e.step === "refused") return /* @__PURE__ */ R("p", {
3261
+ role: "alert",
3262
+ className: "text-danger",
3263
+ children: e.message
3264
+ });
3265
+ let i = e.upload.notes.length > 0 && /* @__PURE__ */ R("ul", {
3266
+ className: "list-disc pl-6 text-small text-content-muted",
3267
+ children: e.upload.notes.map((e) => /* @__PURE__ */ R("li", { children: e }, e))
3268
+ });
3269
+ return e.step === "duplicate" ? /* @__PURE__ */ z("div", {
3270
+ role: "alert",
3271
+ className: "flex flex-col gap-3 rounded-md border border-warning bg-surface-raised p-4",
3272
+ children: [/* @__PURE__ */ z("p", { children: [
3273
+ "This file is already in the site as ",
3274
+ e.existing,
3275
+ "."
3276
+ ] }), /* @__PURE__ */ z("div", {
3277
+ className: "flex flex-wrap gap-3",
3278
+ children: [/* @__PURE__ */ R(K, {
3279
+ onPress: () => {
3280
+ n(e.existing);
3281
+ },
3282
+ children: "Use the existing file"
3283
+ }), /* @__PURE__ */ R(K, {
3284
+ variant: "quiet",
3285
+ onPress: () => {
3286
+ t(e);
3287
+ },
3288
+ children: "Upload a copy anyway"
3289
+ })]
3290
+ })]
3291
+ }) : e.step === "confirm-large" ? /* @__PURE__ */ z("div", {
3292
+ role: "alert",
3293
+ className: "flex flex-col gap-3 rounded-md border border-warning bg-surface-raised p-4",
3294
+ children: [
3295
+ /* @__PURE__ */ z("p", { children: [
3296
+ e.upload.name,
3297
+ " is ",
3298
+ Hi(e.upload.bytes.length),
3299
+ ". Large files make the site’s repository and pages heavier. Upload it anyway?"
3300
+ ] }),
3301
+ i,
3302
+ /* @__PURE__ */ z("div", {
3303
+ className: "flex flex-wrap gap-3",
3304
+ children: [/* @__PURE__ */ R(K, {
3305
+ onPress: () => {
3306
+ t(e);
3307
+ },
3308
+ children: "Upload it"
3309
+ }), /* @__PURE__ */ R(K, {
3310
+ variant: "quiet",
3311
+ onPress: r,
3312
+ children: "Cancel"
3313
+ })]
3314
+ })
3315
+ ]
3316
+ }) : null;
3317
+ }
3318
+ //#endregion
3319
+ //#region src/widgets/crops.tsx
3320
+ function ea(e) {
3321
+ return e === "og" ? "Social image" : We(e);
3322
+ }
3323
+ var ta = (e) => Math.round(e * 100);
3324
+ function na(e) {
3325
+ return {
3326
+ width: `${String(100 / e.w)}%`,
3327
+ height: `${String(100 / e.h)}%`,
3328
+ left: `${String(-e.x / e.w * 100)}%`,
3329
+ top: `${String(-e.y / e.h * 100)}%`
3330
+ };
3331
+ }
3332
+ function ra({ id: e, src: t, size: n, value: r, ratios: i, onChange: a, disabled: o }) {
3333
+ let [s, c] = d(null), [l, u] = d("");
3334
+ if (!n) return /* @__PURE__ */ R("p", {
3335
+ className: "text-small text-content-muted",
3336
+ children: "Loading the image for the crop previews…"
3337
+ });
3338
+ let f = (t) => `${e}-crop-${t}`, p = (e) => {
3339
+ requestAnimationFrame(() => {
3340
+ document.getElementById(f(e))?.focus();
3341
+ });
3342
+ };
3343
+ return /* @__PURE__ */ z("div", {
3344
+ className: "flex flex-col gap-2",
3345
+ children: [
3346
+ /* @__PURE__ */ R("ul", {
3347
+ "aria-label": "Crops",
3348
+ className: "flex flex-wrap items-end gap-4",
3349
+ children: i.map(({ name: e, ratio: i }) => {
3350
+ let { rect: a, custom: s } = Le(r, e, i, n), l = ea(e);
3351
+ return /* @__PURE__ */ z("li", { children: [/* @__PURE__ */ z("figure", {
3352
+ className: "flex flex-col gap-1",
3353
+ children: [/* @__PURE__ */ R("div", {
3354
+ className: "relative h-24 self-start overflow-hidden rounded-sm border border-border",
3355
+ style: { aspectRatio: String(i) },
3356
+ children: /* @__PURE__ */ R("img", {
3357
+ src: t,
3358
+ alt: "",
3359
+ draggable: !1,
3360
+ className: "absolute max-w-none",
3361
+ style: na(a)
3362
+ })
3363
+ }), /* @__PURE__ */ z("figcaption", {
3364
+ className: "text-small text-content",
3365
+ children: [
3366
+ l,
3367
+ " · ",
3368
+ Qe(i),
3369
+ s && /* @__PURE__ */ R("span", {
3370
+ className: "text-content-muted",
3371
+ children: " · Custom crop"
3372
+ })
3373
+ ]
3374
+ })]
3375
+ }), /* @__PURE__ */ z(K, {
3376
+ id: f(e),
3377
+ variant: "quiet",
3378
+ isDisabled: o,
3379
+ className: "-ml-4",
3380
+ onPress: () => {
3381
+ c({
3382
+ name: e,
3383
+ ratio: i
3384
+ });
3385
+ },
3386
+ children: ["Adjust crop ", /* @__PURE__ */ z("span", {
3387
+ className: "sr-only",
3388
+ children: ["for ", l]
3389
+ })]
3390
+ })] }, e);
3391
+ })
3392
+ }),
3393
+ /* @__PURE__ */ R("p", {
3394
+ role: "status",
3395
+ className: "sr-only",
3396
+ children: l
3397
+ }),
3398
+ s && /* @__PURE__ */ R(ca, {
3399
+ src: t,
3400
+ size: n,
3401
+ name: s.name,
3402
+ ratio: s.ratio,
3403
+ start: Le(r, s.name, s.ratio, n),
3404
+ onClose: () => {
3405
+ c(null), p(s.name);
3406
+ },
3407
+ onApply: (e) => {
3408
+ a({
3409
+ ...r.crops,
3410
+ [s.name]: rt(e)
3411
+ }), u(`Custom crop applied to ${ea(s.name)}.`);
3412
+ },
3413
+ onReset: () => {
3414
+ let { [s.name]: e, ...t } = r.crops;
3415
+ a(t), u(`${ea(s.name)} crop reset to the focal point.`);
3416
+ }
3417
+ })
3418
+ ]
3419
+ });
3420
+ }
3421
+ function ia(e) {
3422
+ return `${String(ta(e.x))}% from the left, ${String(ta(e.y))}% from the top, ${String(ta(e.w))}% of the width`;
3423
+ }
3424
+ var aa = {
3425
+ ArrowLeft: [-1, 0],
3426
+ ArrowRight: [1, 0],
3427
+ ArrowUp: [0, -1],
3428
+ ArrowDown: [0, 1]
3429
+ }, oa = {
3430
+ ArrowRight: 1,
3431
+ ArrowDown: 1,
3432
+ ArrowLeft: -1,
3433
+ ArrowUp: -1
3434
+ }, sa = [
3435
+ {
3436
+ corner: "top-left",
3437
+ className: "-left-1.5 -top-1.5 cursor-nwse-resize"
3438
+ },
3439
+ {
3440
+ corner: "top-right",
3441
+ className: "-right-1.5 -top-1.5 cursor-nesw-resize"
3442
+ },
3443
+ {
3444
+ corner: "bottom-left",
3445
+ className: "-bottom-1.5 -left-1.5 cursor-nesw-resize"
3446
+ },
3447
+ {
3448
+ corner: "bottom-right",
3449
+ className: "-bottom-1.5 -right-1.5 cursor-nwse-resize"
3450
+ }
3451
+ ];
3452
+ function ca({ src: e, size: t, name: n, ratio: r, start: i, onClose: a, onApply: o, onReset: s }) {
3453
+ let [l, f] = d(i.rect), [p, m] = d(!1), [h, g] = d(""), _ = u(null), v = u(null), y = u(null), b = `${ea(n)} (${Qe(r)})`;
3454
+ c(() => {
3455
+ v.current?.focus();
3456
+ }, []);
3457
+ let x = (e, t) => {
3458
+ f(e), m(!0), t && g(`Crop ${ia(e)}.`);
3459
+ }, S = (e) => {
3460
+ (p || i.custom) && o(l), e();
3461
+ }, C = (e) => {
3462
+ let t = _.current?.getBoundingClientRect();
3463
+ return !t || t.width === 0 || t.height === 0 ? null : {
3464
+ x: (e.clientX - t.left) / t.width,
3465
+ y: (e.clientY - t.top) / t.height
3466
+ };
3467
+ }, w = (e) => {
3468
+ if (e.button !== 0) return;
3469
+ let t = e.target.dataset.corner, n = C(e);
3470
+ n && (e.currentTarget.setPointerCapture(e.pointerId), y.current = t ? {
3471
+ kind: "corner",
3472
+ corner: t,
3473
+ start: l
3474
+ } : {
3475
+ kind: "move",
3476
+ from: n,
3477
+ start: l
3478
+ });
3479
+ }, T = (e) => {
3480
+ let n = y.current, i = n ? C(e) : null;
3481
+ n && i && x(n.kind === "move" ? Ye(n.start, i.x - n.from.x, i.y - n.from.y) : ze(n.start, n.corner, i, r, t), !1);
3482
+ }, E = () => {
3483
+ y.current && (y.current = null, g(`Crop ${ia(l)}.`));
3484
+ };
3485
+ return /* @__PURE__ */ R(Sn, {
3486
+ title: `Adjust the ${ea(n)} crop`,
3487
+ size: "wide",
3488
+ isOpen: !0,
3489
+ onOpenChange: (e) => {
3490
+ e || a();
3491
+ },
3492
+ children: (n) => /* @__PURE__ */ z(L, { children: [
3493
+ /* @__PURE__ */ R("p", {
3494
+ id: "vesper-crop-help",
3495
+ className: "text-small text-content-muted",
3496
+ children: "Drag the box to move it, or a corner to resize it. With the box focused, the arrow keys move it, Shift and the arrow keys resize it, Enter applies and Escape cancels."
3497
+ }),
3498
+ /* @__PURE__ */ z("div", {
3499
+ className: "relative mx-auto w-fit max-w-full touch-none select-none",
3500
+ children: [
3501
+ /* @__PURE__ */ R("img", {
3502
+ ref: _,
3503
+ src: e,
3504
+ alt: "",
3505
+ draggable: !1,
3506
+ className: "block max-h-[60vh] max-w-full"
3507
+ }),
3508
+ /* @__PURE__ */ R("span", {
3509
+ "aria-hidden": "true",
3510
+ className: "absolute inset-x-0 top-0 bg-content/50",
3511
+ style: { height: `${String(l.y * 100)}%` }
3512
+ }),
3513
+ /* @__PURE__ */ R("span", {
3514
+ "aria-hidden": "true",
3515
+ className: "absolute inset-x-0 bottom-0 bg-content/50",
3516
+ style: { height: `${String((1 - l.y - l.h) * 100)}%` }
3517
+ }),
3518
+ /* @__PURE__ */ R("span", {
3519
+ "aria-hidden": "true",
3520
+ className: "absolute left-0 bg-content/50",
3521
+ style: {
3522
+ top: `${String(l.y * 100)}%`,
3523
+ height: `${String(l.h * 100)}%`,
3524
+ width: `${String(l.x * 100)}%`
3525
+ }
3526
+ }),
3527
+ /* @__PURE__ */ R("span", {
3528
+ "aria-hidden": "true",
3529
+ className: "absolute right-0 bg-content/50",
3530
+ style: {
3531
+ top: `${String(l.y * 100)}%`,
3532
+ height: `${String(l.h * 100)}%`,
3533
+ width: `${String((1 - l.x - l.w) * 100)}%`
3534
+ }
3535
+ }),
3536
+ /* @__PURE__ */ z("div", {
3537
+ ref: v,
3538
+ role: "application",
3539
+ tabIndex: 0,
3540
+ "aria-label": `Crop box for ${b}`,
3541
+ "aria-describedby": "vesper-crop-position vesper-crop-help",
3542
+ "data-crop-box": "",
3543
+ onKeyDown: (e) => {
3544
+ if (e.key === "Enter") {
3545
+ e.preventDefault(), S(n);
3546
+ return;
3547
+ }
3548
+ let i = aa[e.key];
3549
+ !i || e.altKey || e.ctrlKey || e.metaKey || (e.preventDefault(), x(e.shiftKey ? $e(l, l.w + (oa[e.key] ?? 0) * .01, r, t) : Ye(l, i[0] * .01, i[1] * .01), !0));
3550
+ },
3551
+ onPointerDown: w,
3552
+ onPointerMove: T,
3553
+ onPointerUp: E,
3554
+ className: V("absolute cursor-move border border-on-accent outline-offset-0", H),
3555
+ style: {
3556
+ left: `${String(l.x * 100)}%`,
3557
+ top: `${String(l.y * 100)}%`,
3558
+ width: `${String(l.w * 100)}%`,
3559
+ height: `${String(l.h * 100)}%`
3560
+ },
3561
+ children: [/* @__PURE__ */ R("span", {
3562
+ "aria-hidden": "true",
3563
+ className: "absolute inset-0 border border-content/60"
3564
+ }), sa.map(({ corner: e, className: t }) => /* @__PURE__ */ R("span", {
3565
+ "aria-hidden": "true",
3566
+ "data-corner": e,
3567
+ className: V("absolute size-3 border border-content bg-on-accent", t)
3568
+ }, e))]
3569
+ })
3570
+ ]
3571
+ }),
3572
+ /* @__PURE__ */ R("p", {
3573
+ id: "vesper-crop-position",
3574
+ className: "sr-only",
3575
+ children: ia(l)
3576
+ }),
3577
+ /* @__PURE__ */ R("p", {
3578
+ role: "status",
3579
+ className: "sr-only",
3580
+ children: h
3581
+ }),
3582
+ /* @__PURE__ */ z("div", {
3583
+ className: "flex flex-wrap justify-end gap-2",
3584
+ children: [
3585
+ i.custom && /* @__PURE__ */ R(K, {
3586
+ onPress: () => {
3587
+ s(), n();
3588
+ },
3589
+ children: "Reset to focal point"
3590
+ }),
3591
+ /* @__PURE__ */ R(K, {
3592
+ variant: "quiet",
3593
+ onPress: n,
3594
+ children: "Cancel"
3595
+ }),
3596
+ /* @__PURE__ */ R(K, {
3597
+ variant: "primary",
3598
+ onPress: () => {
3599
+ S(n);
3600
+ },
3601
+ children: "Apply crop"
3602
+ })
3603
+ ]
3604
+ })
3605
+ ] })
3606
+ });
3607
+ }
3608
+ //#endregion
3609
+ //#region src/widgets/focal-point.tsx
3610
+ var la = (e) => Math.round(e * 100);
3611
+ function ua(e) {
3612
+ let t = e ?? Pe;
3613
+ return `${String(la(t.x))}% across, ${String(la(t.y))}% down`;
3614
+ }
3615
+ var da = {
3616
+ ArrowLeft: [-1, 0],
3617
+ ArrowRight: [1, 0],
3618
+ ArrowUp: [0, -1],
3619
+ ArrowDown: [0, 1]
3620
+ };
3621
+ function fa({ id: e, src: t, focus: n, onChange: r, onImageSize: i, disabled: a }) {
3622
+ let o = u(null), s = u(!1), [c, l] = d(""), f = n ?? Pe, p = (e, t) => {
3623
+ let n = nt(e);
3624
+ r(n), t && l(`Focal point ${ua(n)}.`);
3625
+ }, m = (e, t) => {
3626
+ let n = o.current?.getBoundingClientRect();
3627
+ return !n || n.width === 0 || n.height === 0 ? null : {
3628
+ x: (e - n.left) / n.width,
3629
+ y: (t - n.top) / n.height
3630
+ };
3631
+ };
3632
+ return /* @__PURE__ */ z("div", {
3633
+ className: "flex flex-col gap-3",
3634
+ children: [
3635
+ /* @__PURE__ */ R("p", {
3636
+ id: `${e}-focus-help`,
3637
+ className: "text-small text-content-muted",
3638
+ children: "The focal point stays in view when the image is cropped. Click the image or drag the marker; or focus the image and use the arrow keys (Shift moves 10%)."
3639
+ }),
3640
+ /* @__PURE__ */ z("div", {
3641
+ className: "flex flex-wrap items-start gap-4",
3642
+ children: [/* @__PURE__ */ z("button", {
3643
+ type: "button",
3644
+ id: `${e}-focus`,
3645
+ "aria-label": "Focal point",
3646
+ "aria-describedby": `${e}-focus-position ${e}-focus-help`,
3647
+ disabled: a,
3648
+ onPointerDown: (e) => {
3649
+ if (a || e.button !== 0) return;
3650
+ let t = m(e.clientX, e.clientY);
3651
+ t && (s.current = !0, e.currentTarget.setPointerCapture(e.pointerId), p(t, !1));
3652
+ },
3653
+ onPointerMove: (e) => {
3654
+ if (!s.current) return;
3655
+ let t = m(e.clientX, e.clientY);
3656
+ t && p(t, !1);
3657
+ },
3658
+ onPointerUp: (e) => {
3659
+ if (!s.current) return;
3660
+ s.current = !1;
3661
+ let t = m(e.clientX, e.clientY);
3662
+ t && p(t, !0);
3663
+ },
3664
+ onKeyDown: (e) => {
3665
+ let t = da[e.key];
3666
+ if (!t || a || e.altKey || e.ctrlKey || e.metaKey) return;
3667
+ e.preventDefault();
3668
+ let n = e.shiftKey ? .1 : .01;
3669
+ p({
3670
+ x: f.x + t[0] * n,
3671
+ y: f.y + t[1] * n
3672
+ }, !0);
3673
+ },
3674
+ className: V("relative max-w-full cursor-crosshair touch-none rounded-md disabled:cursor-not-allowed", H),
3675
+ children: [/* @__PURE__ */ R("img", {
3676
+ ref: o,
3677
+ src: t,
3678
+ alt: "",
3679
+ draggable: !1,
3680
+ onLoad: (e) => {
3681
+ let { naturalWidth: t, naturalHeight: n } = e.currentTarget;
3682
+ t > 0 && n > 0 && i?.({
3683
+ width: t,
3684
+ height: n
3685
+ });
3686
+ },
3687
+ className: "block max-h-64 max-w-full rounded-md border border-border"
3688
+ }), /* @__PURE__ */ R("span", {
3689
+ "aria-hidden": "true",
3690
+ "data-focal-marker": "",
3691
+ className: "pointer-events-none absolute -ml-3 -mt-3 size-6 rounded-full border border-on-accent bg-accent/70",
3692
+ style: {
3693
+ left: `${String(f.x * 100)}%`,
3694
+ top: `${String(f.y * 100)}%`
3695
+ }
3696
+ })]
3697
+ }), /* @__PURE__ */ z("div", {
3698
+ className: "flex flex-col gap-3",
3699
+ children: [
3700
+ /* @__PURE__ */ R(pa, {
3701
+ id: `${e}-focus-x`,
3702
+ label: "Across (%)",
3703
+ hint: "0 is the left edge, 100 the right",
3704
+ value: n ? la(n.x) : void 0,
3705
+ placeholder: la(Pe.x),
3706
+ disabled: a,
3707
+ onChange: (e) => {
3708
+ p({
3709
+ x: e / 100,
3710
+ y: f.y
3711
+ }, !1);
3712
+ }
3713
+ }),
3714
+ /* @__PURE__ */ R(pa, {
3715
+ id: `${e}-focus-y`,
3716
+ label: "Down (%)",
3717
+ hint: "0 is the top, 100 the bottom",
3718
+ value: n ? la(n.y) : void 0,
3719
+ placeholder: la(Pe.y),
3720
+ disabled: a,
3721
+ onChange: (e) => {
3722
+ p({
3723
+ x: f.x,
3724
+ y: e / 100
3725
+ }, !1);
3726
+ }
3727
+ }),
3728
+ n && /* @__PURE__ */ R("div", { children: /* @__PURE__ */ R(K, {
3729
+ variant: "quiet",
3730
+ isDisabled: a,
3731
+ onPress: () => {
3732
+ r(void 0), l("Focal point back to the center.");
3733
+ },
3734
+ children: "Use the center"
3735
+ }) })
3736
+ ]
3737
+ })]
3738
+ }),
3739
+ /* @__PURE__ */ R("p", {
3740
+ id: `${e}-focus-position`,
3741
+ className: "sr-only",
3742
+ children: n ? ua(n) : `Not set: the center, ${ua(void 0)}`
3743
+ }),
3744
+ /* @__PURE__ */ R("p", {
3745
+ role: "status",
3746
+ className: "sr-only",
3747
+ children: c
3748
+ })
3749
+ ]
3750
+ });
3751
+ }
3752
+ function pa({ id: e, label: t, hint: n, value: r, placeholder: i, disabled: a, onChange: o }) {
3753
+ let [s, c] = d(r === void 0 ? "" : String(r)), [l, u] = d(r);
3754
+ return r !== l && (u(r), c(r === void 0 ? "" : String(r))), /* @__PURE__ */ z("div", {
3755
+ className: "flex flex-col gap-1",
3756
+ children: [
3757
+ /* @__PURE__ */ R("label", {
3758
+ htmlFor: e,
3759
+ className: "text-small text-content",
3760
+ children: t
3761
+ }),
3762
+ /* @__PURE__ */ R("input", {
3763
+ id: e,
3764
+ type: "number",
3765
+ inputMode: "numeric",
3766
+ min: 0,
3767
+ max: 100,
3768
+ step: 1,
3769
+ value: s,
3770
+ placeholder: String(i),
3771
+ disabled: a,
3772
+ onChange: (e) => {
3773
+ c(e.target.value);
3774
+ let t = e.target.valueAsNumber;
3775
+ Number.isFinite(t) && t >= 0 && t <= 100 && (u(Math.round(t)), o(Math.round(t)));
3776
+ },
3777
+ "aria-describedby": `${e}-hint`,
3778
+ className: V(Z, "w-28")
3779
+ }),
3780
+ /* @__PURE__ */ R("p", {
3781
+ id: `${e}-hint`,
3782
+ className: "text-small text-content-muted",
3783
+ children: n
3784
+ })
3785
+ ]
3786
+ });
3787
+ }
3788
+ //#endregion
3789
+ //#region src/widgets/image.tsx
3790
+ function ma(e, t, n) {
3791
+ return e ? Re(e) : `${t}/assets/${n}`;
3792
+ }
3793
+ function ha(e) {
3794
+ return e.slice(e.lastIndexOf("/") + 1);
3795
+ }
3796
+ function ga(e, t) {
3797
+ let n = e.widgetOptions?.ratios;
3798
+ return (Array.isArray(n) ? n.filter((e) => typeof e == "string" && e in t) : Object.keys(t)).map((e) => ({
3799
+ name: e,
3800
+ ratio: t[e] ?? 1
3801
+ }));
3802
+ }
3803
+ function _a({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o, path: s }) {
3804
+ let { manifest: c } = J(), l = X(), [u, f] = d(!1), [p, m] = d([]), [h, g] = d(null), _ = n.kind === "object", v = B(e) ? e : {}, y = _ ? v.src : e, b = typeof y == "string" ? y : "", x = b ? et(b, l.entryPath) : null, S = Lr(x), C = _ && (n.children ?? []).some((e) => e.path.at(-1) === "alt"), w = _ && (n.children ?? []).some((e) => e.path.at(-1) === "decorative"), T = v.decorative === !0, E = typeof v.alt == "string" ? v.alt : "", ee = (l.notes?.get(mr(s)) ?? []).filter((e) => e.target.kind === "field" && e.target.path[s.length] === "alt"), te = (e) => _ && (n.children ?? []).some((t) => t.path.at(-1) === e), D = te("focus"), O = te("crops"), [ne, k] = d(null), [A, re] = d(b);
3805
+ A !== b && (re(b), k(null));
3806
+ let j = h === b, M = T ? "You replaced the image. Check that it’s still decorative." : "You replaced the image. Check that the alt text still describes it.", N = (e) => {
3807
+ if (e === x) return;
3808
+ let n = Je(e, l.entryPath);
3809
+ if (!_) {
3810
+ t(n);
3811
+ return;
3812
+ }
3813
+ let { focus: r, crops: i, ...a } = v;
3814
+ t({
3815
+ ...a,
3816
+ src: n
3817
+ }), b && (E !== "" || T) && g(n);
3818
+ }, P = (e) => {
3819
+ t(e);
3820
+ };
3821
+ return /* @__PURE__ */ z("div", {
3822
+ className: "flex flex-col gap-4",
3823
+ children: [
3824
+ b ? /* @__PURE__ */ z("div", {
3825
+ className: "flex flex-wrap items-start gap-4",
3826
+ children: [x ? S && /* @__PURE__ */ R("img", {
3827
+ src: S,
3828
+ alt: "",
3829
+ className: "max-h-48 max-w-full rounded-md border border-border object-contain"
3830
+ }) : /* @__PURE__ */ z("p", {
3831
+ className: "text-small text-content-muted",
3832
+ children: [
3833
+ "The studio can’t show a preview of ",
3834
+ b,
3835
+ "."
3836
+ ]
3837
+ }), /* @__PURE__ */ z("div", {
3838
+ className: "flex min-w-0 flex-col gap-2",
3839
+ children: [/* @__PURE__ */ R("p", {
3840
+ id: `${r}-file`,
3841
+ className: "font-mono text-small break-all",
3842
+ children: ha(b)
3843
+ }), /* @__PURE__ */ z("div", {
3844
+ className: "flex flex-wrap gap-2",
3845
+ children: [/* @__PURE__ */ R(K, {
3846
+ id: r,
3847
+ isDisabled: o,
3848
+ "aria-describedby": [i, `${r}-file`].filter(Boolean).join(" "),
3849
+ icon: "replace-image",
3850
+ onPress: () => {
3851
+ f(!0);
3852
+ },
3853
+ children: "Replace image"
3854
+ }), /* @__PURE__ */ R(K, {
3855
+ variant: "quiet",
3856
+ isDisabled: o,
3857
+ onPress: () => {
3858
+ m([]), g(null), t(n.required ? _ ? {
3859
+ ...v,
3860
+ src: ""
3861
+ } : "" : void 0);
3862
+ },
3863
+ children: "Remove image"
3864
+ })]
3865
+ })]
3866
+ })]
3867
+ }) : /* @__PURE__ */ R("div", { children: /* @__PURE__ */ R(K, {
3868
+ id: r,
3869
+ isDisabled: o,
3870
+ "aria-describedby": i,
3871
+ onPress: () => {
3872
+ f(!0);
3873
+ },
3874
+ children: "Choose image"
3875
+ }) }),
3876
+ p.length > 0 && /* @__PURE__ */ z("p", {
3877
+ role: "status",
3878
+ className: "text-small text-content-muted",
3879
+ children: [
3880
+ "Added. ",
3881
+ p.join(". "),
3882
+ "."
3883
+ ]
3884
+ }),
3885
+ C && !T && /* @__PURE__ */ z("div", {
3886
+ className: "flex flex-col gap-1",
3887
+ children: [
3888
+ /* @__PURE__ */ R("label", {
3889
+ htmlFor: `${r}-alt`,
3890
+ className: "text-label text-content",
3891
+ children: "Alt text"
3892
+ }),
3893
+ /* @__PURE__ */ R("textarea", {
3894
+ id: `${r}-alt`,
3895
+ rows: 2,
3896
+ value: E,
3897
+ onChange: (e) => {
3898
+ g(null), P({
3899
+ ...v,
3900
+ alt: e.target.value
3901
+ });
3902
+ },
3903
+ "aria-describedby": [
3904
+ `${r}-alt-help`,
3905
+ ee.length > 0 ? `${r}-alt-a11y` : "",
3906
+ j ? `${r}-replaced` : "",
3907
+ i
3908
+ ].filter(Boolean).join(" "),
3909
+ "aria-invalid": a || void 0,
3910
+ "aria-required": "true",
3911
+ disabled: o,
3912
+ className: V(Z, "resize-y")
3913
+ }),
3914
+ /* @__PURE__ */ R("p", {
3915
+ id: `${r}-alt-help`,
3916
+ className: "text-small text-content-muted",
3917
+ children: "Describe what this image communicates on this page."
3918
+ }),
3919
+ ee.length > 0 && /* @__PURE__ */ R(xi, {
3920
+ id: `${r}-alt-a11y`,
3921
+ notes: ee
3922
+ }),
3923
+ j && /* @__PURE__ */ R(Si, {
3924
+ id: `${r}-replaced`,
3925
+ children: M
3926
+ })
3927
+ ]
3928
+ }),
3929
+ w && /* @__PURE__ */ R(Ln, {
3930
+ isSelected: T,
3931
+ isDisabled: o,
3932
+ "aria-describedby": T && j ? `${r}-replaced` : void 0,
3933
+ onChange: (e) => {
3934
+ if (g(null), e) P({
3935
+ ...v,
3936
+ alt: "",
3937
+ decorative: !0
3938
+ });
3939
+ else {
3940
+ let { decorative: e, ...t } = v;
3941
+ P(t);
3942
+ }
3943
+ },
3944
+ children: "Decorative image (it adds nothing a reader needs)"
3945
+ }),
3946
+ w && T && j && /* @__PURE__ */ R(Si, {
3947
+ id: `${r}-replaced`,
3948
+ children: M
3949
+ }),
3950
+ x && (D || O) && /* @__PURE__ */ R(kn, {
3951
+ title: "Focal point & crops",
3952
+ children: /* @__PURE__ */ z("div", {
3953
+ className: "flex flex-col gap-6",
3954
+ children: [
3955
+ D && S && /* @__PURE__ */ R(fa, {
3956
+ id: r,
3957
+ src: S,
3958
+ focus: Ge(v).focus,
3959
+ disabled: o,
3960
+ onImageSize: k,
3961
+ onChange: (e) => {
3962
+ let { focus: t, ...n } = v;
3963
+ P(e ? {
3964
+ ...n,
3965
+ focus: e
3966
+ } : n);
3967
+ }
3968
+ }),
3969
+ O && S && /* @__PURE__ */ R(ra, {
3970
+ id: r,
3971
+ src: S,
3972
+ size: ne,
3973
+ value: Ge(v),
3974
+ ratios: ga(n, it(c.site.images?.ratios)),
3975
+ disabled: o,
3976
+ onChange: (e) => {
3977
+ let { crops: t, ...n } = v;
3978
+ P(Object.keys(e).length > 0 ? {
3979
+ ...n,
3980
+ crops: e
3981
+ } : n);
3982
+ }
3983
+ }),
3984
+ O && !D && S && /* @__PURE__ */ R("img", {
3985
+ src: S,
3986
+ alt: "",
3987
+ hidden: !0,
3988
+ onLoad: (e) => {
3989
+ let { naturalWidth: t, naturalHeight: n } = e.currentTarget;
3990
+ t > 0 && n > 0 && k({
3991
+ width: t,
3992
+ height: n
3993
+ });
3994
+ }
3995
+ })
3996
+ ]
3997
+ })
3998
+ }),
3999
+ /* @__PURE__ */ R(Xi, {
4000
+ isOpen: u,
4001
+ onOpenChange: f,
4002
+ kind: "image",
4003
+ folder: ma(x, c.site.srcDir, l.collection.name),
4004
+ onChoose: (e, t) => {
4005
+ m(t ?? []), N(e), requestAnimationFrame(() => {
4006
+ document.getElementById(r)?.focus();
4007
+ });
4008
+ }
4009
+ })
4010
+ ]
4011
+ });
4012
+ }
4013
+ function va(e) {
4014
+ let t = typeof e == "string" ? e.split(",") : Array.isArray(e) ? e : [], n = {
4015
+ "application/pdf": ["pdf"],
4016
+ "video/mp4": ["mp4"],
4017
+ "audio/mpeg": ["mp3"],
4018
+ "text/csv": ["csv"]
4019
+ };
4020
+ return t.flatMap((e) => {
4021
+ let t = String(e).trim().toLowerCase();
4022
+ return t.startsWith(".") ? [t.slice(1)] : n[t] ?? [];
4023
+ });
4024
+ }
4025
+ function ya({ value: e, onChange: t, field: n, id: r, describedBy: i, disabled: a }) {
4026
+ let o = X(), [s, c] = d(!1), l = typeof e == "string" ? e : "", u = l ? et(l, o.entryPath) : null, f = Lr(u), p = va(n.widgetOptions?.accept);
4027
+ return /* @__PURE__ */ z("div", {
4028
+ className: "flex flex-col gap-2",
4029
+ children: [
4030
+ l && /* @__PURE__ */ z("p", {
4031
+ id: `${r}-file`,
4032
+ className: "text-small",
4033
+ children: [
4034
+ u && f ? /* @__PURE__ */ R("a", {
4035
+ href: f,
4036
+ target: "_blank",
4037
+ rel: "noopener noreferrer",
4038
+ className: "text-accent underline underline-offset-2",
4039
+ children: ha(l)
4040
+ }) : ha(l),
4041
+ " ",
4042
+ /* @__PURE__ */ z("span", {
4043
+ className: "text-content-muted",
4044
+ children: [
4045
+ "(",
4046
+ Be(l).toUpperCase() || "file",
4047
+ ")"
4048
+ ]
4049
+ })
4050
+ ]
4051
+ }),
4052
+ /* @__PURE__ */ z("div", {
4053
+ className: "flex flex-wrap gap-2",
4054
+ children: [/* @__PURE__ */ R(K, {
4055
+ id: r,
4056
+ isDisabled: a,
4057
+ "aria-describedby": [i, l ? `${r}-file` : ""].filter(Boolean).join(" ") || void 0,
4058
+ onPress: () => {
4059
+ c(!0);
4060
+ },
4061
+ children: l ? "Replace file" : "Choose file"
4062
+ }), l && /* @__PURE__ */ R(K, {
4063
+ variant: "quiet",
4064
+ isDisabled: a,
4065
+ onPress: () => {
4066
+ t(n.required ? "" : void 0);
4067
+ },
4068
+ children: "Remove file"
4069
+ })]
4070
+ }),
4071
+ /* @__PURE__ */ R(Xi, {
4072
+ isOpen: s,
4073
+ onOpenChange: c,
4074
+ kind: "file",
4075
+ extensions: p,
4076
+ folder: u ? Re(u) : "public/files",
4077
+ onChoose: (e) => {
4078
+ t(Je(e, o.entryPath)), requestAnimationFrame(() => {
4079
+ document.getElementById(r)?.focus();
4080
+ });
4081
+ }
4082
+ })
4083
+ ]
4084
+ });
4085
+ }
4086
+ //#endregion
4087
+ //#region src/widgets/reference.tsx
4088
+ function ba(e) {
4089
+ if (typeof e == "string") return e;
4090
+ if (B(e)) {
4091
+ let t = e.id ?? e.slug;
4092
+ if (typeof t == "string") return t;
4093
+ }
4094
+ }
4095
+ function xa(e, t) {
4096
+ return B(e) ? {
4097
+ ...e,
4098
+ id: t
4099
+ } : t;
4100
+ }
4101
+ function Sa(e) {
4102
+ let { api: t, collection: n } = J(), r = X(), [i] = lr(() => e ? t.listEntries(e) : Promise.resolve([]), e ?? ""), a = l(() => i.state === "ready" ? i.value : [], [i]);
4103
+ return {
4104
+ options: l(() => {
4105
+ let t = a.filter((t) => e !== r.collection.name || t.id !== r.entryId), n = /* @__PURE__ */ new Map();
4106
+ for (let e of t) n.set(e.title, (n.get(e.title) ?? 0) + 1);
4107
+ return t.map((e) => ({
4108
+ value: e.id,
4109
+ label: (n.get(e.title) ?? 0) > 1 ? `${e.title} (${e.id})` : e.title
4110
+ }));
4111
+ }, [
4112
+ a,
4113
+ e,
4114
+ r.collection.name,
4115
+ r.entryId
4116
+ ]),
4117
+ load: i,
4118
+ label: (e ? n(e)?.label : void 0) ?? e ?? "entries"
4119
+ };
4120
+ }
4121
+ function Ca(e, t) {
4122
+ return e.find((e) => e.value === t)?.label ?? `${t} (not found)`;
4123
+ }
4124
+ function wa(e) {
4125
+ return e.reference?.collection ?? e.children?.[0]?.reference?.collection;
4126
+ }
4127
+ function Ta({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
4128
+ let { options: s, load: c, label: l } = Sa(wa(n)), u = ba(e), d = u && !s.some((e) => e.value === u) ? [...s, {
4129
+ value: u,
4130
+ label: Ca(s, u)
4131
+ }] : s;
4132
+ return /* @__PURE__ */ R(Pn, {
4133
+ id: r,
4134
+ "aria-labelledby": `${r}-label`,
4135
+ "aria-describedby": i,
4136
+ options: d,
4137
+ value: u ?? null,
4138
+ onChange: (n) => {
4139
+ t(n === null ? void 0 : xa(e, n));
4140
+ },
4141
+ placeholder: c.state === "loading" ? "Loading…" : `Search ${l.toLowerCase()}`,
4142
+ isInvalid: a,
4143
+ isDisabled: o
4144
+ });
4145
+ }
4146
+ function Ea({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
4147
+ let { options: s, load: c, label: l } = Sa(wa(n)), d = Array.isArray(e) ? e : [], f = d.map(ba), p = u(null), m = (e) => {
4148
+ p.current && (p.current.textContent = e);
4149
+ }, h = (e) => {
4150
+ t(e.length === 0 && !n.required ? void 0 : e);
4151
+ }, g = (e, t) => {
4152
+ let n = [...d], [r] = n.splice(e, 1);
4153
+ n.splice(t, 0, r), h(n), m(`Moved ${Ca(s, ba(r) ?? "")} to position ${String(t + 1)}.`);
4154
+ }, _ = s.filter((e) => !f.includes(e.value));
4155
+ return /* @__PURE__ */ z("div", {
4156
+ className: "flex flex-col gap-3",
4157
+ children: [
4158
+ d.length > 0 && /* @__PURE__ */ R("ol", {
4159
+ className: "flex flex-col divide-y divide-border border-y border-border",
4160
+ children: d.map((e, t) => {
4161
+ let n = Ca(s, ba(e) ?? "");
4162
+ return /* @__PURE__ */ z("li", {
4163
+ className: "flex flex-wrap items-center gap-2 py-2",
4164
+ children: [
4165
+ /* @__PURE__ */ R("span", {
4166
+ className: "min-w-0 flex-1",
4167
+ children: n
4168
+ }),
4169
+ /* @__PURE__ */ R(K, {
4170
+ variant: "quiet",
4171
+ isDisabled: o || t === 0,
4172
+ onPress: () => {
4173
+ g(t, t - 1);
4174
+ },
4175
+ "aria-label": `Move ${n} up`,
4176
+ children: "Up"
4177
+ }),
4178
+ /* @__PURE__ */ R(K, {
4179
+ variant: "quiet",
4180
+ isDisabled: o || t === d.length - 1,
4181
+ onPress: () => {
4182
+ g(t, t + 1);
4183
+ },
4184
+ "aria-label": `Move ${n} down`,
4185
+ children: "Down"
4186
+ }),
4187
+ /* @__PURE__ */ R(K, {
4188
+ variant: "quiet",
4189
+ isDisabled: o,
4190
+ onPress: () => {
4191
+ h(d.filter((e, n) => n !== t)), m(`Removed ${n}.`), document.getElementById(r)?.focus();
4192
+ },
4193
+ "aria-label": `Remove ${n}`,
4194
+ children: "Remove"
4195
+ })
4196
+ ]
4197
+ }, `${String(ba(e))}-${String(t)}`);
4198
+ })
4199
+ }),
4200
+ /* @__PURE__ */ R(Pn, {
4201
+ id: r,
4202
+ "aria-labelledby": `${r}-label`,
4203
+ "aria-describedby": i,
4204
+ options: _,
4205
+ value: null,
4206
+ onChange: (e) => {
4207
+ e !== null && (h([...d, e]), m(`Added ${Ca(s, e)}.`));
4208
+ },
4209
+ placeholder: c.state === "loading" ? "Loading…" : `Add from ${l.toLowerCase()}`,
4210
+ isInvalid: a,
4211
+ isDisabled: o
4212
+ }),
4213
+ /* @__PURE__ */ R("p", {
4214
+ ref: p,
4215
+ role: "status",
4216
+ className: "sr-only"
4217
+ })
4218
+ ]
4219
+ });
4220
+ }
4221
+ //#endregion
4222
+ //#region src/widgets/markdown-lazy.tsx
4223
+ var Da = i(() => import("./markdown-4fVeej3c.js").then((e) => ({ default: e.MarkdownWidget })));
4224
+ function Oa(e) {
4225
+ return /* @__PURE__ */ R(t, {
4226
+ fallback: /* @__PURE__ */ R("p", {
4227
+ role: "status",
4228
+ className: "text-small text-content-muted",
4229
+ children: "Loading the editor…"
4230
+ }),
4231
+ children: /* @__PURE__ */ R(Da, { ...e })
4232
+ });
4233
+ }
4234
+ //#endregion
4235
+ //#region src/editor/PagePicker.tsx
4236
+ var ka = /* @__PURE__ */ new WeakMap();
4237
+ function Aa() {
4238
+ let { api: e } = J(), [t, n] = d([]);
4239
+ return s(() => {
4240
+ let t = !0, r = ka.get(e);
4241
+ return r || (r = e.listPages(), ka.set(e, r)), r.then((e) => {
4242
+ t && n(e);
4243
+ }, () => {
4244
+ ka.delete(e);
4245
+ }), () => {
4246
+ t = !1;
4247
+ };
4248
+ }, [e]), t;
4249
+ }
4250
+ function ja(e) {
4251
+ return e.map((e) => ({
4252
+ value: e.url,
4253
+ label: e.title,
4254
+ detail: e.url
4255
+ }));
4256
+ }
4257
+ function Ma({ onPick: e, absolute: t, fieldLabel: n, isDisabled: r }) {
4258
+ let i = Aa(), [a, o] = d(!1), s = l(() => i.map((e) => ({
4259
+ value: t ? new URL(e.url, t).href : e.url,
4260
+ label: `${e.title} (${e.url})`
4261
+ })), [i, t]);
4262
+ return i.length === 0 ? null : /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R(K, {
4263
+ variant: "quiet",
4264
+ ...r ? { isDisabled: r } : {},
4265
+ onPress: () => {
4266
+ o(!0);
4267
+ },
4268
+ "aria-label": `Choose a page for ${n}`,
4269
+ children: "Choose a page…"
4270
+ }), /* @__PURE__ */ R(Sn, {
4271
+ title: "Choose a page",
4272
+ isOpen: a,
4273
+ onOpenChange: o,
4274
+ children: /* @__PURE__ */ R(Pn, {
4275
+ label: "Page",
4276
+ description: "Search by title. Its address goes in the field.",
4277
+ options: s,
4278
+ value: null,
4279
+ onChange: (t) => {
4280
+ t && (e(t), o(!1));
4281
+ }
4282
+ })
4283
+ })] });
4284
+ }
4285
+ //#endregion
4286
+ //#region src/widgets/special.tsx
4287
+ var Na = /^#[0-9a-f]{6}$/i;
4288
+ function Pa(e, ...t) {
4289
+ return [e, ...t].filter(Boolean).join(" ");
4290
+ }
4291
+ function Fa({ color: e }) {
4292
+ return /* @__PURE__ */ R("span", {
4293
+ className: "inline-block size-6 shrink-0 rounded-sm border border-border-strong",
4294
+ style: { backgroundColor: e }
4295
+ });
4296
+ }
4297
+ function Ia({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
4298
+ let s = n.widgetOptions?.palette, c = typeof e == "string" ? e : "";
4299
+ if (s && Object.keys(s).length > 0) {
4300
+ let e = Object.entries(s).map(([e, t]) => ({
4301
+ value: t,
4302
+ label: `${e} (${t})`,
4303
+ prefix: /* @__PURE__ */ R(Fa, { color: t })
4304
+ }));
4305
+ return c && !e.some((e) => e.value.toLowerCase() === c.toLowerCase()) && e.push({
4306
+ value: c,
4307
+ label: `Current colour (${c})`,
4308
+ prefix: /* @__PURE__ */ R(Fa, { color: c })
4309
+ }), /* @__PURE__ */ R(zn, {
4310
+ id: r,
4311
+ "aria-labelledby": `${r}-label`,
4312
+ "aria-describedby": i,
4313
+ options: e,
4314
+ value: e.find((e) => e.value.toLowerCase() === c.toLowerCase())?.value ?? null,
4315
+ onChange: t,
4316
+ isInvalid: a,
4317
+ isDisabled: o
4318
+ });
4319
+ }
4320
+ return /* @__PURE__ */ z("div", {
4321
+ className: "flex items-center gap-3",
4322
+ children: [/* @__PURE__ */ R("input", {
4323
+ id: r,
4324
+ type: "text",
4325
+ value: c,
4326
+ placeholder: "#1a73e8",
4327
+ spellCheck: !1,
4328
+ autoComplete: "off",
4329
+ onChange: (e) => {
4330
+ t(e.target.value === "" && !n.required ? void 0 : e.target.value);
4331
+ },
4332
+ "aria-describedby": i,
4333
+ "aria-invalid": a || void 0,
4334
+ "aria-required": n.required || void 0,
4335
+ disabled: o,
4336
+ className: V(Z, "max-w-40 font-mono")
4337
+ }), n.widgetOptions?.alpha !== !0 && /* @__PURE__ */ R("input", {
4338
+ type: "color",
4339
+ "aria-label": `Pick ${n.label.toLowerCase()} from a colour picker`,
4340
+ value: Na.test(c) ? c.toLowerCase() : "#000000",
4341
+ onChange: (e) => {
4342
+ t(e.target.value);
4343
+ },
4344
+ disabled: o,
4345
+ className: "size-10 cursor-pointer rounded-md border border-border-strong bg-surface p-1 focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-focus focus-visible:ring-6 focus-visible:ring-(color:--glow-focus)"
4346
+ })]
4347
+ });
4348
+ }
4349
+ function La({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
4350
+ let c = X(), l = typeof n.widgetOptions?.from == "string" ? n.widgetOptions.from : void 0, u = l ? c.values[l] : void 0, f = typeof u == "string" ? u : "", p = typeof e == "string" ? e : "", [m, h] = d(() => c.isNew && l !== void 0 && (p === "" || p === Ra(f)));
4351
+ s(() => {
4352
+ if (!m) return;
4353
+ let e = Ra(f);
4354
+ e !== p && t(e === "" && !n.required ? void 0 : e);
4355
+ }, [
4356
+ m,
4357
+ f,
4358
+ p,
4359
+ t,
4360
+ n.required
4361
+ ]);
4362
+ let g = c.collection.fields?.find((e) => e.path[0] === l)?.label ?? l;
4363
+ return /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R("input", {
4364
+ id: r,
4365
+ type: "text",
4366
+ value: p,
4367
+ spellCheck: !1,
4368
+ autoComplete: "off",
4369
+ onChange: (e) => {
4370
+ h(!1), t(e.target.value === "" && !n.required ? void 0 : e.target.value);
4371
+ },
4372
+ "aria-describedby": Pa(i, m && `${r}-follows`),
4373
+ "aria-invalid": a || void 0,
4374
+ "aria-required": n.required || void 0,
4375
+ disabled: o,
4376
+ className: V(Z, "font-mono")
4377
+ }), m && g && /* @__PURE__ */ z("p", {
4378
+ id: `${r}-follows`,
4379
+ className: "text-small text-content-muted",
4380
+ children: [
4381
+ "Follows the ",
4382
+ g.toLowerCase(),
4383
+ " until you edit it."
4384
+ ]
4385
+ })] });
4386
+ }
4387
+ function Ra(e) {
4388
+ return at(e).replaceAll("/", "-");
4389
+ }
4390
+ function za({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
4391
+ let { manifest: s } = J(), c = typeof e == "string" ? e : "", l = /^https?:\/\/\S+$/i.test(c), u = s.site.urls?.site, d = n.format !== "url" || u !== void 0;
4392
+ return /* @__PURE__ */ z("div", {
4393
+ className: "flex flex-wrap items-center gap-3",
4394
+ children: [
4395
+ /* @__PURE__ */ R("input", {
4396
+ id: r,
4397
+ type: "url",
4398
+ inputMode: "url",
4399
+ value: c,
4400
+ placeholder: n.placeholder ?? "https://",
4401
+ onChange: (e) => {
4402
+ t(e.target.value === "" && !n.required ? void 0 : e.target.value);
4403
+ },
4404
+ "aria-describedby": i,
4405
+ "aria-invalid": a || void 0,
4406
+ "aria-required": n.required || void 0,
4407
+ disabled: o,
4408
+ className: Z
4409
+ }),
4410
+ l && /* @__PURE__ */ z("a", {
4411
+ href: c,
4412
+ target: "_blank",
4413
+ rel: "noopener noreferrer",
4414
+ className: "shrink-0 rounded-sm text-accent underline underline-offset-2 hover:text-accent-hover focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-focus focus-visible:ring-6 focus-visible:ring-(color:--glow-focus)",
4415
+ children: ["Open ", /* @__PURE__ */ z("span", {
4416
+ className: "sr-only",
4417
+ children: [c, " in a new tab"]
4418
+ })]
4419
+ }),
4420
+ d && /* @__PURE__ */ R(Ma, {
4421
+ fieldLabel: n.label,
4422
+ ...n.format === "url" && u ? { absolute: u } : {},
4423
+ ...o ? { isDisabled: !0 } : {},
4424
+ onPick: (e) => {
4425
+ t(e);
4426
+ }
4427
+ })
4428
+ ]
4429
+ });
4430
+ }
4431
+ function Ba({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
4432
+ let { manifest: s } = J(), { zone: c, isSite: l } = tt(s.site.timeZone), u = e instanceof Date ? e : typeof e == "string" && e ? new Date(e) : null, d = u !== null && !Number.isNaN(u.getTime()), f = ct(c, d ? u : /* @__PURE__ */ new Date()), p = d ? st(u, c) : "", m = vr(p);
4433
+ return /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R("input", {
4434
+ id: r,
4435
+ type: "datetime-local",
4436
+ value: p,
4437
+ ...m,
4438
+ onChange: (n) => {
4439
+ if (n.target.value === "") {
4440
+ t(void 0);
4441
+ return;
4442
+ }
4443
+ let r = He(n.target.value, c);
4444
+ r && t(typeof e == "string" ? qe(r, Xe(r) ?? 0) : r);
4445
+ },
4446
+ "aria-describedby": Pa(i, `${r}-zone`),
4447
+ "aria-invalid": a || void 0,
4448
+ "aria-required": n.required || void 0,
4449
+ disabled: o,
4450
+ required: n.required,
4451
+ className: V(Z, "max-w-64")
4452
+ }), /* @__PURE__ */ R("p", {
4453
+ id: `${r}-zone`,
4454
+ className: "text-small text-content-muted",
4455
+ children: l ? `Times are in ${f}, the site’s time zone.` : `Times are in your time zone, ${f}.`
4456
+ })] });
4457
+ }
4458
+ //#endregion
4459
+ //#region src/widgets/registry.ts
4460
+ var Va = {
4461
+ text: { component: xr },
4462
+ textarea: { component: Cr },
4463
+ email: { component: Sr },
4464
+ url: { component: za },
4465
+ number: { component: wr },
4466
+ switch: { component: Tr },
4467
+ date: { component: Dr },
4468
+ datetime: { component: Ba },
4469
+ select: { component: kr },
4470
+ radio: {
4471
+ component: Ar,
4472
+ group: !0
4473
+ },
4474
+ icon: { component: yi },
4475
+ tags: { component: jr },
4476
+ multiselect: { component: jr },
4477
+ group: {
4478
+ component: Qr,
4479
+ group: !0,
4480
+ rendersChildren: !0,
4481
+ section: !0
4482
+ },
4483
+ union: {
4484
+ component: Zr,
4485
+ group: !0,
4486
+ rendersChildren: !0,
4487
+ section: !0
4488
+ },
4489
+ repeater: {
4490
+ component: mi,
4491
+ group: !0,
4492
+ rendersChildren: !0,
4493
+ section: !0
4494
+ },
4495
+ raw: { component: Mr },
4496
+ markdown: { component: Oa },
4497
+ slug: { component: La },
4498
+ color: { component: Ia },
4499
+ geo: {
4500
+ component: Fr,
4501
+ group: "boxed"
4502
+ },
4503
+ reference: { component: Ta },
4504
+ references: {
4505
+ component: Ea,
4506
+ group: !0
4507
+ },
4508
+ image: {
4509
+ component: _a,
4510
+ group: "boxed",
4511
+ childControls: { alt: "-alt" }
4512
+ },
4513
+ file: {
4514
+ component: ya,
4515
+ group: !0
4516
+ }
4517
+ }, Ha = {
4518
+ string: "text",
4519
+ number: "number",
4520
+ boolean: "switch",
4521
+ date: "date",
4522
+ enum: "select",
4523
+ object: "group",
4524
+ union: "union",
4525
+ array: "repeater",
4526
+ reference: "reference",
4527
+ image: "image"
4528
+ };
4529
+ function Ua(e) {
4530
+ for (let t of [
4531
+ e.widget,
4532
+ e.inferredWidget,
4533
+ Ha[e.kind]
4534
+ ]) {
4535
+ let e = t ? Va[t] : void 0;
4536
+ if (e) return e;
4537
+ }
4538
+ return Va.raw;
4539
+ }
4540
+ //#endregion
4541
+ //#region src/editor/Field.tsx
4542
+ function Wa({ field: e, path: n, label: r, item: i, asSection: a = !0 }) {
4543
+ let o = X(), { widgets: s } = J(), c = pr(n, o.idPrefix), l = o.issues.get(mr(n)) ?? [], u = e.widget ? s[e.widget] : void 0, d = Ua(e), f = u ? void 0 : d.childControls, p = (o.notes?.get(mr(n)) ?? []).filter((e) => {
4544
+ let t = e.target.kind === "field" ? e.target.path[n.length] : void 0;
4545
+ return !(typeof t == "string" && f && t in f);
4546
+ }), m = e.description ? `${c}-help` : void 0, h = l.length > 0 ? `${c}-error` : void 0, g = p.length > 0 ? `${c}-a11y` : void 0, _ = [
4547
+ m,
4548
+ h,
4549
+ g
4550
+ ].filter(Boolean).join(" ") || void 0, v = {
4551
+ value: ur(o.values, n),
4552
+ onChange: (e) => {
4553
+ o.setValue(n, e);
4554
+ },
4555
+ field: e,
4556
+ id: c,
4557
+ describedBy: _,
4558
+ invalid: l.length > 0,
4559
+ disabled: o.disabled || e.readOnly === !0,
4560
+ path: n
4561
+ }, y = i === "row" ? {
4562
+ ...v,
4563
+ inRow: !0
4564
+ } : v, b = u ? /* @__PURE__ */ R(Ga, {
4565
+ fallback: /* @__PURE__ */ R(d.component, { ...y }),
4566
+ name: e.widget ?? "",
4567
+ children: /* @__PURE__ */ R(t, {
4568
+ fallback: /* @__PURE__ */ R("p", {
4569
+ className: "text-small text-content-muted",
4570
+ children: "Loading…"
4571
+ }),
4572
+ children: /* @__PURE__ */ R(u, { ...v })
4573
+ })
4574
+ }) : /* @__PURE__ */ R(d.component, { ...y }), x = r ?? e.label, S = !e.required && !i && e.kind !== "boolean" && e.readOnly !== !0 ? /* @__PURE__ */ R(sn, {}) : null, C = m ? /* @__PURE__ */ R("p", {
4575
+ id: m,
4576
+ className: "text-small text-content-muted",
4577
+ children: e.description
4578
+ }) : null, w = h ? /* @__PURE__ */ R("p", {
4579
+ id: h,
4580
+ className: "text-small text-danger",
4581
+ children: l.join(" ")
4582
+ }) : null, T = g ? /* @__PURE__ */ R(xi, {
4583
+ id: g,
4584
+ notes: p
4585
+ }) : null;
4586
+ if (!u && d.group) {
4587
+ let t = d.section && n.length === 1 && a && !o.idPrefix && !i, r = d.section && (e.kind === "object" || e.kind === "union") && !t && i !== "row", s = /* @__PURE__ */ z("fieldset", {
4588
+ "aria-describedby": _,
4589
+ className: V("flex min-w-0 flex-col gap-2", t && "gap-3", r && "border-l border-border pl-4", d.group === "boxed" && !i && "rounded-md border border-border p-4"),
4590
+ children: [
4591
+ /* @__PURE__ */ R("legend", {
4592
+ id: `${c}-label`,
4593
+ tabIndex: -1,
4594
+ className: V("mb-1 outline-none", i === "row" ? "sr-only" : "text-label text-content"),
4595
+ children: t ? /* @__PURE__ */ z("h2", {
4596
+ className: "text-heading-3 text-content",
4597
+ children: [x, S]
4598
+ }) : /* @__PURE__ */ z(L, { children: [x, S] })
4599
+ }),
4600
+ C,
4601
+ b,
4602
+ w,
4603
+ T
4604
+ ]
4605
+ });
4606
+ return t ? /* @__PURE__ */ R("div", {
4607
+ className: "mt-4 border-t border-border pt-6",
4608
+ children: s
4609
+ }) : s;
4610
+ }
4611
+ return /* @__PURE__ */ z("div", {
4612
+ className: "flex min-w-0 flex-col gap-2",
4613
+ children: [
4614
+ /* @__PURE__ */ z("label", {
4615
+ id: `${c}-label`,
4616
+ htmlFor: c,
4617
+ className: "text-label text-content",
4618
+ children: [x, S]
4619
+ }),
4620
+ b,
4621
+ C,
4622
+ w,
4623
+ T
4624
+ ]
4625
+ });
4626
+ }
4627
+ var Ga = class extends e {
4628
+ state = { failed: !1 };
4629
+ static getDerivedStateFromError() {
4630
+ return { failed: !0 };
4631
+ }
4632
+ render() {
4633
+ return this.state.failed ? /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ z("p", {
4634
+ className: "text-small text-content-muted",
4635
+ children: [
4636
+ "The “",
4637
+ this.props.name,
4638
+ "” control couldn’t load, so this is a plain one."
4639
+ ]
4640
+ }), this.props.fallback] }) : this.props.children;
4641
+ }
4642
+ }, Ka = typeof navigator < "u" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);
4643
+ function qa(...e) {
4644
+ let t = e.at(-1) ?? "", n = e.slice(0, -1);
4645
+ if (Ka) {
4646
+ let e = {
4647
+ Alt: "⌥",
4648
+ Shift: "⇧",
4649
+ Mod: "⌘"
4650
+ }, r = [
4651
+ "Alt",
4652
+ "Shift",
4653
+ "Mod"
4654
+ ].filter((e) => n.includes(e));
4655
+ return {
4656
+ text: `${r.map((t) => e[t]).join("")}${t}`,
4657
+ aria: [...r.map((e) => e === "Mod" ? "Meta" : e), t].join("+")
4658
+ };
4659
+ }
4660
+ return {
4661
+ text: [...n.map((e) => e === "Mod" ? "Ctrl" : e), t].join("+"),
4662
+ aria: [...n.map((e) => e === "Mod" ? "Control" : e), t].join("+")
4663
+ };
4664
+ }
4665
+ //#endregion
4666
+ export { Nn as $, dr as A, nr as B, gr as C, hr as D, ur as E, ir as F, Gn as G, Zn as H, J as I, Un as J, Wn as K, rr as L, cr as M, sr as N, Y as O, ar as P, zn as Q, Me as R, vr as S, pr as T, Jn as U, Yn as V, qn as W, Ln as X, Vn as Y, Pn as Z, zr as _, Ma as a, wn as at, Lr as b, Xi as c, _n as ct, Yi as d, gn as dt, Bn as et, qi as f, mn as ft, Jr as g, H as gt, $r as h, V as ht, Ua as i, On as it, lr as j, mr as k, $i as l, K as lt, bi as m, G as mt, qa as n, Sn as nt, ja as o, xn as ot, Ui as p, hn as pt, Hn as q, Wa as r, Cn as rt, Aa as s, vn as st, Ka as t, q as tt, Ji as u, pn as ut, Vr as v, X as w, Z as x, Rr as y, tr as z };