@povio/ui 5.0.0-rc.14 → 5.0.0-rc.16

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 (80) hide show
  1. package/dist/{AppCanvasPage-vta1j5YQ.js → AppCanvasPage-C3KN-Pwb.js} +156 -589
  2. package/dist/{AppCanvasPage-BZ2mrKY4.d.ts → AppCanvasPage-U9SxNwjS.d.ts} +1 -1
  3. package/dist/{BottomSheet-BXLE3161.js → BottomSheet-AqYVSMK9.js} +1 -75
  4. package/dist/BottomSheetHeader-Be6Elvs2.js +79 -0
  5. package/dist/{Calendar-DRHruqr_.js → Calendar-1p3VjSED.js} +3 -3
  6. package/dist/{CanvasComponentsFrame-D6Mh_G3q.js → CanvasComponentsFrame-Dp0oDDoH.js} +6 -6
  7. package/dist/{UIConfigurator-CjAW1SJY.js → CanvasInspector-TC9DOf5p.js} +1456 -500
  8. package/dist/{ComponentGallery-CzKU899_.js → ComponentGallery-C_rXFvUY.js} +250 -1797
  9. package/dist/{DatePicker-xDEqzNJv.js → DatePicker-CAzuZRmd.js} +6 -6
  10. package/dist/{DatePickerInput-B0fEeCOf.js → DatePickerInput-BeQOVCk0.js} +4 -3
  11. package/dist/{DateRangePicker-DxuVhRaf.js → DateRangePicker-X3mBhfmL.js} +5 -5
  12. package/dist/{DateTimePicker-4N1Pka07.js → DateTimePicker-EtmGtoRe.js} +6 -6
  13. package/dist/{InputItem-Cv19Hwnx.js → InputItem-yC5oMyN-.js} +7 -7
  14. package/dist/{Inputs-D1aE_J9f.js → Inputs-Bd2nRNqk.js} +1 -1
  15. package/dist/{NumberRangeInput-Bzfe-RlV.js → NumberRangeInput-TkPXiWV3.js} +2 -2
  16. package/dist/{RichTextEditor-Bd7F5D8f.js → RichTextEditor-DiaPcBUM.js} +110 -32
  17. package/dist/{Select-CgIhoWgk.js → Select-tNlFSbAC.js} +5 -5
  18. package/dist/{Table-piX1SWvN.js → Table-CgG02oHQ.js} +1 -1
  19. package/dist/{TextArea-uPffb457.js → TextArea-DuvFUjts.js} +1 -1
  20. package/dist/{TimePicker-DN-i98z5.js → TimePicker-CBkiE-Yq.js} +5 -4
  21. package/dist/{TooltipWrapper-CDHFaUKZ.js → TooltipWrapper-CSXs5-E3.js} +2 -2
  22. package/dist/components/autocomplete.js +3 -3
  23. package/dist/components/bottom-sheet.js +1 -1
  24. package/dist/components/date-picker.js +1 -1
  25. package/dist/components/date-range-picker.js +1 -1
  26. package/dist/components/date-time-picker.js +1 -1
  27. package/dist/components/input.js +3 -3
  28. package/dist/components/number-field.js +3 -3
  29. package/dist/components/number-range-input.js +1 -1
  30. package/dist/components/query-autocomplete.js +1 -1
  31. package/dist/components/query-select.js +2 -2
  32. package/dist/components/select.js +1 -1
  33. package/dist/components/text-area.js +1 -1
  34. package/dist/components/time-picker.js +1 -1
  35. package/dist/config/app-canvas-tanstack.d.ts +1 -1
  36. package/dist/config/app-canvas-tanstack.js +1 -1
  37. package/dist/config/app-canvas.d.ts +1 -1
  38. package/dist/config/app-canvas.js +1 -1
  39. package/dist/config/ui-configurator.d.ts +35 -2
  40. package/dist/config/ui-configurator.js +214 -3
  41. package/dist/{datePickerValue.utils-QWR2q5Vv.js → datePickerValue.utils-BDB6KM8q.js} +1 -1
  42. package/dist/demos-DIwj5vc0.js +2011 -0
  43. package/dist/index.js +7 -7
  44. package/dist/{logger-CqZjM-sn.js → logger-CW24po62.js} +10 -1
  45. package/dist/rhf/date-picker.js +1 -1
  46. package/dist/rhf/date-range-picker.js +1 -1
  47. package/dist/rhf/date-time-picker.js +1 -1
  48. package/dist/rhf/number-range-input.js +1 -1
  49. package/dist/rhf/rich-text-editor.js +1 -1
  50. package/dist/rhf/select.js +1 -1
  51. package/dist/rhf/text-area.js +1 -1
  52. package/dist/rhf/time-picker.js +1 -1
  53. package/dist/rhf.js +7 -7
  54. package/dist/rich-text-editor.js +1 -1
  55. package/dist/{staticDateTimeSegments-BWea3HAt.js → staticDateTimeSegments-Bs1_N5MR.js} +1 -1
  56. package/dist/{staticSelect.utils-BfTCi26B.js → staticSelect.utils-BgdYv2vP.js} +5 -4
  57. package/dist/styles/app-canvas.css +30 -24
  58. package/dist/styles/configurator.css +421 -34
  59. package/dist/tanstack/date-picker.js +1 -1
  60. package/dist/tanstack/date-range-picker.js +1 -1
  61. package/dist/tanstack/date-time-picker.js +1 -1
  62. package/dist/tanstack/form.js +1 -1
  63. package/dist/tanstack/inputs.js +1 -1
  64. package/dist/tanstack/number-range-input.js +1 -1
  65. package/dist/tanstack/rich-text-editor.js +1 -1
  66. package/dist/tanstack/select.js +1 -1
  67. package/dist/tanstack/table.js +2 -2
  68. package/dist/tanstack/text-area.js +1 -1
  69. package/dist/tanstack/time-picker.js +1 -1
  70. package/dist/tanstack.js +15 -15
  71. package/dist/token-classes-BqLWiy6O.js +245 -0
  72. package/dist/{useFieldAccessibility-B-bjtrNw.js → useFieldAccessibility-DnCdz938.js} +2 -1
  73. package/dist/{useFormAutosave-pmh35PXp.js → useFormAutosave-CxqZAJAB.js} +1 -1
  74. package/dist/{useStaticInputHandoff-B7DEm75m.js → useStaticInputHandoff-DKsxpVck.js} +2 -1
  75. package/dist/{useTableColumnConfig-CNJ_ZvIN.js → useTableColumnConfig-BnbKElno.js} +1 -1
  76. package/dist/utils/logger.js +1 -1
  77. package/package.json +1 -1
  78. package/src/configurator/README.md +11 -0
  79. package/dist/groups-oQmSeqXn.js +0 -18
  80. package/dist/underline-66hmELxa.js +0 -81
@@ -23,7 +23,7 @@ import { a as $928221da08ecbc62$export$dca12b0bb56e4fc, i as $928221da08ecbc62$e
23
23
  import { n as $8b8d26808cb8cb53$export$8948f78d83984c69, t as $8b8d26808cb8cb53$export$2b77a92f1a5ad772 } from "./Modal-w60dVQcb.js";
24
24
  import { i as radioDefinition, n as radioContentRowDefinition, r as radioContentWrapperDefinition, t as RadioGroup } from "./RadioGroup-efBKgTYA.js";
25
25
  import { n as switchDefinition, t as Switch } from "./Switch-CqnGEdeD.js";
26
- import { n as textAreaWrapperDefinition, t as TextArea } from "./TextArea-uPffb457.js";
26
+ import { n as textAreaWrapperDefinition, t as TextArea } from "./TextArea-DuvFUjts.js";
27
27
  import { a as breadcrumbsDefinition, i as breadcrumbSegmentDefinition, n as breadcrumbIconDefinition, r as breadcrumbItemDefinition, t as breadcrumbChevronDefinition } from "./breadcrumbs.cva-7zzdDhVR.js";
28
28
  import { i as menuPopoverWrapperDefinition, n as menuItemDefinition, r as menuPopoverDefinition, t as dropdownMenuDefinition } from "./dropdownMenu.cva-DvEmX0bs.js";
29
29
  import { i as tooltipTextDefinition, n as tooltipPointerHorizontalDefinition, r as tooltipPointerVerticalDefinition, t as tooltipDefinition } from "./tooltip.cva-BIzlOXHH.js";
@@ -50,6 +50,7 @@ import { a as tableHeaderTextDefinition, i as tableHeadRowDefinition, n as table
50
50
  import { t as linkDefinition } from "./link.cva-DMTHZiJG.js";
51
51
  import { t as tooltipWrapperTriggerDefinition } from "./tooltipWrapper.cva-BBQ4ic3D.js";
52
52
  import { C as toRgb, S as toHex, _ as listedLayoutToken, a as generateShades, b as runtimeCss, c as isEditableToken, d as labelFor, f as layoutKindFor, g as linkedLayoutTokens, h as layoutScales, i as exportCss, l as isFontSizeToken, m as layoutLevelFor, n as controlHeightCounterpart, o as groupFor, p as layoutKinds, r as emptyTheme, s as groups, t as baseColorNames, u as isRgb, v as parseThemeCss, w as validToken, x as spacingLevels, y as previewTokens } from "./theme-model-DtTsIxou.js";
53
+ import { n as splitVariants, r as variantState, t as inspectTokens } from "./token-classes-BqLWiy6O.js";
53
54
  import $ahdqC$react, { Fragment, Suspense, createContext, lazy, use, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
54
55
  import { c } from "react/compiler-runtime";
55
56
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -71,7 +72,7 @@ import { UNSAFE_PortalProvider } from "react-aria";
71
72
  * This source code is licensed under the ISC license.
72
73
  * See the LICENSE file in the root directory of this source tree.
73
74
  */
74
- const __iconData$10 = {
75
+ const __iconData$13 = {
75
76
  name: "arrow-down-to-line",
76
77
  size: 24,
77
78
  node: [
@@ -89,8 +90,8 @@ const __iconData$10 = {
89
90
  }]
90
91
  ]
91
92
  };
92
- __iconData$10.node;
93
- const ArrowDownToLine = createLucideIcon(__iconData$10);
93
+ __iconData$13.node;
94
+ const ArrowDownToLine = createLucideIcon(__iconData$13);
94
95
  //#endregion
95
96
  //#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/chevrons-up-down.mjs
96
97
  /**
@@ -99,7 +100,7 @@ const ArrowDownToLine = createLucideIcon(__iconData$10);
99
100
  * This source code is licensed under the ISC license.
100
101
  * See the LICENSE file in the root directory of this source tree.
101
102
  */
102
- const __iconData$9 = {
103
+ const __iconData$12 = {
103
104
  name: "chevrons-up-down",
104
105
  size: 24,
105
106
  node: [["path", {
@@ -110,8 +111,8 @@ const __iconData$9 = {
110
111
  key: "sgt6xg"
111
112
  }]]
112
113
  };
113
- __iconData$9.node;
114
- const ChevronsUpDown = createLucideIcon(__iconData$9);
114
+ __iconData$12.node;
115
+ const ChevronsUpDown = createLucideIcon(__iconData$12);
115
116
  //#endregion
116
117
  //#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/external-link.mjs
117
118
  /**
@@ -120,7 +121,7 @@ const ChevronsUpDown = createLucideIcon(__iconData$9);
120
121
  * This source code is licensed under the ISC license.
121
122
  * See the LICENSE file in the root directory of this source tree.
122
123
  */
123
- const __iconData$8 = {
124
+ const __iconData$11 = {
124
125
  name: "external-link",
125
126
  size: 24,
126
127
  node: [
@@ -138,8 +139,52 @@ const __iconData$8 = {
138
139
  }]
139
140
  ]
140
141
  };
141
- __iconData$8.node;
142
- const ExternalLink = createLucideIcon(__iconData$8);
142
+ __iconData$11.node;
143
+ const ExternalLink = createLucideIcon(__iconData$11);
144
+ //#endregion
145
+ //#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/frame.mjs
146
+ /**
147
+ * @license lucide-react v1.43.0 - ISC
148
+ *
149
+ * This source code is licensed under the ISC license.
150
+ * See the LICENSE file in the root directory of this source tree.
151
+ */
152
+ const __iconData$10 = {
153
+ name: "frame",
154
+ size: 24,
155
+ node: [
156
+ ["line", {
157
+ x1: "22",
158
+ x2: "2",
159
+ y1: "6",
160
+ y2: "6",
161
+ key: "15w7dq"
162
+ }],
163
+ ["line", {
164
+ x1: "22",
165
+ x2: "2",
166
+ y1: "18",
167
+ y2: "18",
168
+ key: "1ip48p"
169
+ }],
170
+ ["line", {
171
+ x1: "6",
172
+ x2: "6",
173
+ y1: "2",
174
+ y2: "22",
175
+ key: "a2lnyx"
176
+ }],
177
+ ["line", {
178
+ x1: "18",
179
+ x2: "18",
180
+ y1: "2",
181
+ y2: "22",
182
+ key: "8vb6jd"
183
+ }]
184
+ ]
185
+ };
186
+ __iconData$10.node;
187
+ const Frame = createLucideIcon(__iconData$10);
143
188
  //#endregion
144
189
  //#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/moon.mjs
145
190
  /**
@@ -148,7 +193,7 @@ const ExternalLink = createLucideIcon(__iconData$8);
148
193
  * This source code is licensed under the ISC license.
149
194
  * See the LICENSE file in the root directory of this source tree.
150
195
  */
151
- const __iconData$7 = {
196
+ const __iconData$9 = {
152
197
  name: "moon",
153
198
  size: 24,
154
199
  node: [["path", {
@@ -156,8 +201,8 @@ const __iconData$7 = {
156
201
  key: "kfwtm"
157
202
  }]]
158
203
  };
159
- __iconData$7.node;
160
- const Moon = createLucideIcon(__iconData$7);
204
+ __iconData$9.node;
205
+ const Moon = createLucideIcon(__iconData$9);
161
206
  //#endregion
162
207
  //#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/panel-top.mjs
163
208
  /**
@@ -166,7 +211,7 @@ const Moon = createLucideIcon(__iconData$7);
166
211
  * This source code is licensed under the ISC license.
167
212
  * See the LICENSE file in the root directory of this source tree.
168
213
  */
169
- const __iconData$6 = {
214
+ const __iconData$8 = {
170
215
  name: "panel-top",
171
216
  size: 24,
172
217
  node: [["rect", {
@@ -181,8 +226,8 @@ const __iconData$6 = {
181
226
  key: "1pudct"
182
227
  }]]
183
228
  };
184
- __iconData$6.node;
185
- const PanelTop = createLucideIcon(__iconData$6);
229
+ __iconData$8.node;
230
+ const PanelTop = createLucideIcon(__iconData$8);
186
231
  //#endregion
187
232
  //#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/pencil.mjs
188
233
  /**
@@ -191,7 +236,7 @@ const PanelTop = createLucideIcon(__iconData$6);
191
236
  * This source code is licensed under the ISC license.
192
237
  * See the LICENSE file in the root directory of this source tree.
193
238
  */
194
- const __iconData$5 = {
239
+ const __iconData$7 = {
195
240
  name: "pencil",
196
241
  size: 24,
197
242
  node: [["path", {
@@ -202,8 +247,8 @@ const __iconData$5 = {
202
247
  key: "1mk7zo"
203
248
  }]]
204
249
  };
205
- __iconData$5.node;
206
- const Pencil = createLucideIcon(__iconData$5);
250
+ __iconData$7.node;
251
+ const Pencil = createLucideIcon(__iconData$7);
207
252
  //#endregion
208
253
  //#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/pin.mjs
209
254
  /**
@@ -212,7 +257,7 @@ const Pencil = createLucideIcon(__iconData$5);
212
257
  * This source code is licensed under the ISC license.
213
258
  * See the LICENSE file in the root directory of this source tree.
214
259
  */
215
- const __iconData$4 = {
260
+ const __iconData$6 = {
216
261
  name: "pin",
217
262
  size: 24,
218
263
  node: [["path", {
@@ -223,8 +268,8 @@ const __iconData$4 = {
223
268
  key: "1nkz8b"
224
269
  }]]
225
270
  };
226
- __iconData$4.node;
227
- const Pin = createLucideIcon(__iconData$4);
271
+ __iconData$6.node;
272
+ const Pin = createLucideIcon(__iconData$6);
228
273
  //#endregion
229
274
  //#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/plus.mjs
230
275
  /**
@@ -233,7 +278,7 @@ const Pin = createLucideIcon(__iconData$4);
233
278
  * This source code is licensed under the ISC license.
234
279
  * See the LICENSE file in the root directory of this source tree.
235
280
  */
236
- const __iconData$3 = {
281
+ const __iconData$5 = {
237
282
  name: "plus",
238
283
  size: 24,
239
284
  node: [["path", {
@@ -244,8 +289,8 @@ const __iconData$3 = {
244
289
  key: "s699le"
245
290
  }]]
246
291
  };
247
- __iconData$3.node;
248
- const Plus = createLucideIcon(__iconData$3);
292
+ __iconData$5.node;
293
+ const Plus = createLucideIcon(__iconData$5);
249
294
  //#endregion
250
295
  //#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/rotate-ccw.mjs
251
296
  /**
@@ -254,7 +299,7 @@ const Plus = createLucideIcon(__iconData$3);
254
299
  * This source code is licensed under the ISC license.
255
300
  * See the LICENSE file in the root directory of this source tree.
256
301
  */
257
- const __iconData$2 = {
302
+ const __iconData$4 = {
258
303
  name: "rotate-ccw",
259
304
  size: 24,
260
305
  node: [["path", {
@@ -265,8 +310,80 @@ const __iconData$2 = {
265
310
  key: "1xhq8a"
266
311
  }]]
267
312
  };
313
+ __iconData$4.node;
314
+ const RotateCcw = createLucideIcon(__iconData$4);
315
+ //#endregion
316
+ //#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/scan-line.mjs
317
+ /**
318
+ * @license lucide-react v1.43.0 - ISC
319
+ *
320
+ * This source code is licensed under the ISC license.
321
+ * See the LICENSE file in the root directory of this source tree.
322
+ */
323
+ const __iconData$3 = {
324
+ name: "scan-line",
325
+ size: 24,
326
+ node: [
327
+ ["path", {
328
+ d: "M3 7V5a2 2 0 0 1 2-2h2",
329
+ key: "aa7l1z"
330
+ }],
331
+ ["path", {
332
+ d: "M17 3h2a2 2 0 0 1 2 2v2",
333
+ key: "4qcy5o"
334
+ }],
335
+ ["path", {
336
+ d: "M21 17v2a2 2 0 0 1-2 2h-2",
337
+ key: "6vwrx8"
338
+ }],
339
+ ["path", {
340
+ d: "M7 21H5a2 2 0 0 1-2-2v-2",
341
+ key: "ioqczr"
342
+ }],
343
+ ["path", {
344
+ d: "M7 12h10",
345
+ key: "b7w52i"
346
+ }]
347
+ ]
348
+ };
349
+ __iconData$3.node;
350
+ const ScanLine = createLucideIcon(__iconData$3);
351
+ //#endregion
352
+ //#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/settings-2.mjs
353
+ /**
354
+ * @license lucide-react v1.43.0 - ISC
355
+ *
356
+ * This source code is licensed under the ISC license.
357
+ * See the LICENSE file in the root directory of this source tree.
358
+ */
359
+ const __iconData$2 = {
360
+ name: "settings-2",
361
+ size: 24,
362
+ node: [
363
+ ["path", {
364
+ d: "M14 17H5",
365
+ key: "gfn3mx"
366
+ }],
367
+ ["path", {
368
+ d: "M19 7h-9",
369
+ key: "6i9tg"
370
+ }],
371
+ ["circle", {
372
+ cx: "17",
373
+ cy: "17",
374
+ r: "3",
375
+ key: "18b49y"
376
+ }],
377
+ ["circle", {
378
+ cx: "7",
379
+ cy: "7",
380
+ r: "3",
381
+ key: "dfmy0x"
382
+ }]
383
+ ]
384
+ };
268
385
  __iconData$2.node;
269
- const RotateCcw = createLucideIcon(__iconData$2);
386
+ const Settings2 = createLucideIcon(__iconData$2);
270
387
  //#endregion
271
388
  //#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/sun.mjs
272
389
  /**
@@ -696,7 +813,7 @@ function UIConfigurationProvider(t0) {
696
813
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
697
814
  t1 = () => {
698
815
  setComponentHosts(_temp$8);
699
- return () => setComponentHosts(_temp2$5);
816
+ return () => setComponentHosts(_temp2$6);
700
817
  };
701
818
  $[0] = t1;
702
819
  } else t1 = $[0];
@@ -710,7 +827,7 @@ function UIConfigurationProvider(t0) {
710
827
  setApplied(structuredClone(value));
711
828
  setDraft(structuredClone(value));
712
829
  setPreviewConfiguration(null);
713
- if (remount) setRevision(_temp3$4);
830
+ if (remount) setRevision(_temp3$5);
714
831
  };
715
832
  $[1] = t2;
716
833
  } else t2 = $[1];
@@ -889,10 +1006,10 @@ function _temp5$3(value_1) {
889
1006
  function _temp4$4(value_0) {
890
1007
  return value_0 + 1;
891
1008
  }
892
- function _temp3$4(current) {
1009
+ function _temp3$5(current) {
893
1010
  return current + 1;
894
1011
  }
895
- function _temp2$5(count_0) {
1012
+ function _temp2$6(count_0) {
896
1013
  return count_0 - 1;
897
1014
  }
898
1015
  function _temp$8(count) {
@@ -1337,7 +1454,7 @@ function InspectorDetails(t0) {
1337
1454
  $[13] = onSelect;
1338
1455
  $[14] = t6;
1339
1456
  } else t6 = $[14];
1340
- t5 = snapshot.groups.map(_temp$7).filter(_temp2$4).map(t6);
1457
+ t5 = snapshot.groups.map(_temp$7).filter(_temp2$5).map(t6);
1341
1458
  $[10] = onSelect;
1342
1459
  $[11] = snapshot.groups;
1343
1460
  $[12] = t5;
@@ -1351,7 +1468,7 @@ function InspectorDetails(t0) {
1351
1468
  } else t6 = $[17];
1352
1469
  return t6;
1353
1470
  }
1354
- function _temp2$4(group_0) {
1471
+ function _temp2$5(group_0) {
1355
1472
  return group_0.properties.length;
1356
1473
  }
1357
1474
  function _temp$7(group) {
@@ -1562,9 +1679,9 @@ function _temp5$2(group) {
1562
1679
  return group.properties;
1563
1680
  }
1564
1681
  function _temp4$3(value) {
1565
- return value.replace(/(-?\d*\.?\d+)px/g, _temp3$3);
1682
+ return value.replace(/(-?\d*\.?\d+)px/g, _temp3$4);
1566
1683
  }
1567
- function _temp3$3(_, amount) {
1684
+ function _temp3$4(_, amount) {
1568
1685
  return String(Math.round(Number(amount) * 10) / 10);
1569
1686
  }
1570
1687
  //#endregion
@@ -1834,236 +1951,6 @@ function getBoxHighlights(element, key) {
1834
1951
  };
1835
1952
  }
1836
1953
  //#endregion
1837
- //#region src/configurator/inspector/token-classes.ts
1838
- /** Tailwind breakpoints from the Atlas base theme, in rem. */
1839
- const breakpoints = {
1840
- sm: 23.75,
1841
- md: 37.5,
1842
- lg: 80,
1843
- xl: 105
1844
- };
1845
- /** Utility prefix → the slots it sets, its specificity, and the theme namespace its value lives in. */
1846
- const utilities = [
1847
- [
1848
- "p",
1849
- [
1850
- "padding.top",
1851
- "padding.right",
1852
- "padding.bottom",
1853
- "padding.left"
1854
- ],
1855
- 0,
1856
- "spacing"
1857
- ],
1858
- [
1859
- "px",
1860
- ["padding.left", "padding.right"],
1861
- 1,
1862
- "spacing"
1863
- ],
1864
- [
1865
- "py",
1866
- ["padding.top", "padding.bottom"],
1867
- 1,
1868
- "spacing"
1869
- ],
1870
- [
1871
- "pt",
1872
- ["padding.top"],
1873
- 2,
1874
- "spacing"
1875
- ],
1876
- [
1877
- "pr",
1878
- ["padding.right"],
1879
- 2,
1880
- "spacing"
1881
- ],
1882
- [
1883
- "pe",
1884
- ["padding.right"],
1885
- 2,
1886
- "spacing"
1887
- ],
1888
- [
1889
- "pb",
1890
- ["padding.bottom"],
1891
- 2,
1892
- "spacing"
1893
- ],
1894
- [
1895
- "pl",
1896
- ["padding.left"],
1897
- 2,
1898
- "spacing"
1899
- ],
1900
- [
1901
- "ps",
1902
- ["padding.left"],
1903
- 2,
1904
- "spacing"
1905
- ],
1906
- [
1907
- "gap",
1908
- ["gap.row", "gap.column"],
1909
- 0,
1910
- "spacing"
1911
- ],
1912
- [
1913
- "gap-x",
1914
- ["gap.column"],
1915
- 1,
1916
- "spacing"
1917
- ],
1918
- [
1919
- "gap-y",
1920
- ["gap.row"],
1921
- 1,
1922
- "spacing"
1923
- ],
1924
- [
1925
- "rounded",
1926
- ["radius"],
1927
- 0,
1928
- "radius"
1929
- ]
1930
- ];
1931
- /** Splits `md:hover:px-4` into its variants and utility, ignoring colons inside `[...]` / `(...)`. */
1932
- function splitVariants(className) {
1933
- const parts = [];
1934
- let depth = 0;
1935
- let current = "";
1936
- for (const char of className) {
1937
- if (char === "[" || char === "(") depth++;
1938
- if (char === "]" || char === ")") depth--;
1939
- if (char === ":" && depth === 0) {
1940
- parts.push(current);
1941
- current = "";
1942
- } else current += char;
1943
- }
1944
- return {
1945
- variants: parts,
1946
- utility: current
1947
- };
1948
- }
1949
- /** Variants that style a pseudo-element or other elements, never the element's own value. */
1950
- const otherTargets = /* @__PURE__ */ new Set([
1951
- "placeholder",
1952
- "before",
1953
- "after",
1954
- "selection",
1955
- "marker",
1956
- "file",
1957
- "first-letter",
1958
- "first-line",
1959
- "backdrop",
1960
- "*",
1961
- "**"
1962
- ]);
1963
- const stateSelectors = {
1964
- hover: ":hover",
1965
- focus: ":focus",
1966
- "focus-within": ":focus-within",
1967
- "focus-visible": ":focus-visible",
1968
- active: ":active",
1969
- disabled: ":disabled",
1970
- enabled: ":enabled",
1971
- checked: ":checked",
1972
- indeterminate: ":indeterminate",
1973
- invalid: ":invalid",
1974
- valid: ":valid",
1975
- required: ":required",
1976
- optional: ":optional",
1977
- "read-only": ":read-only",
1978
- "placeholder-shown": ":placeholder-shown",
1979
- empty: ":empty",
1980
- open: ":is([open], :popover-open, :open)",
1981
- first: ":first-child",
1982
- last: ":last-child",
1983
- only: ":only-child",
1984
- odd: ":nth-child(odd)",
1985
- even: ":nth-child(even)"
1986
- };
1987
- /** A CSS selector for one state variant, or `undefined` when its condition cannot be read from the element. */
1988
- function variantSelector(variant) {
1989
- if (variant.startsWith("not-")) {
1990
- const inner = variantSelector(variant.slice(4));
1991
- return inner && `:not(${inner})`;
1992
- }
1993
- if (variant.startsWith("has-")) {
1994
- const inner = variantSelector(variant.slice(4));
1995
- return inner && `:has(${inner})`;
1996
- }
1997
- if (stateSelectors[variant]) return stateSelectors[variant];
1998
- if (variant.startsWith("aria-") && !variant.includes("[")) return `[aria-${variant.slice(5)}="true"]`;
1999
- const arbitrary = variant.match(/^\[(&?)(:[^\s&>+~,]+)\]$/);
2000
- return arbitrary ? arbitrary[2].replaceAll("_", " ") : void 0;
2001
- }
2002
- /**
2003
- * How a variant class relates to an element's current value: `other` styles a pseudo-element or descendants,
2004
- * `inactive` / `active` are state conditions read from the element, and `unknown` covers breakpoints, container
2005
- * queries, group/peer state and anything else that cannot be checked from the element alone.
2006
- */
2007
- function variantState(variants, element) {
2008
- if (variants.some((variant) => otherTargets.has(variant))) return "other";
2009
- const selectors = variants.map(variantSelector);
2010
- if (selectors.some((selector) => selector === void 0) || typeof element.matches !== "function") return "unknown";
2011
- try {
2012
- return element.matches(`*${selectors.join("")}`) ? "active" : "inactive";
2013
- } catch {
2014
- return "unknown";
2015
- }
2016
- }
2017
- /** Breakpoint weight when every variant is an active breakpoint; `undefined` for state variants or inactive breakpoints. */
2018
- function variantWeight(variants, viewportWidth, rootFontSize) {
2019
- let weight = 0;
2020
- for (const variant of variants) {
2021
- const max = variant.startsWith("max-");
2022
- const size = breakpoints[max ? variant.slice(4) : variant];
2023
- if (size === void 0) return void 0;
2024
- if (!(max ? viewportWidth < size * rootFontSize : viewportWidth >= size * rootFontSize)) return void 0;
2025
- weight = Math.max(weight, size);
2026
- }
2027
- return weight;
2028
- }
2029
- function tokenFor(value, namespace, isKnown) {
2030
- const referenced = value.match(/^\[.*?var\((--[\w-]+)/)?.[1] ?? value.match(/^\((--[\w-]+)\)$/)?.[1];
2031
- if (referenced) return isKnown(referenced) ? referenced : void 0;
2032
- const name = `--${namespace}-${value}`;
2033
- return isKnown(name) ? name : void 0;
2034
- }
2035
- /**
2036
- * Resolves which theme tokens drive an element's padding, gap and radius from its rendered Tailwind classes.
2037
- * Only tokens accepted by `isKnown` are returned, so every result can be opened in the editor.
2038
- */
2039
- function inspectTokens(className, isKnown, viewportWidth = Infinity, rootFontSize = 16) {
2040
- const winners = /* @__PURE__ */ new Map();
2041
- for (const raw of className.split(/\s+/).filter(Boolean)) {
2042
- const { variants, utility } = splitVariants(raw);
2043
- const weight = variantWeight(variants, viewportWidth, rootFontSize);
2044
- if (weight === void 0) continue;
2045
- const clean = utility.replace(/^!|!$/g, "");
2046
- for (const [prefix, slots, specificity, namespace] of utilities) {
2047
- if (!clean.startsWith(`${prefix}-`)) continue;
2048
- const token = tokenFor(clean.slice(prefix.length + 1), namespace, isKnown);
2049
- if (!token) continue;
2050
- const rank = weight * 10 + specificity;
2051
- for (const slot of slots) if ((winners.get(slot)?.rank ?? -1) <= rank) winners.set(slot, {
2052
- token,
2053
- rank
2054
- });
2055
- }
2056
- }
2057
- const result = {
2058
- padding: {},
2059
- gap: {}
2060
- };
2061
- for (const [slot, { token }] of winners) if (slot === "radius") result.radius = token;
2062
- else if (slot.startsWith("gap.")) result.gap[slot.slice(4)] = token;
2063
- else result.padding[slot.slice(8)] = token;
2064
- return result;
2065
- }
2066
- //#endregion
2067
1954
  //#region src/configurator/inspector/inspection-model.ts
2068
1955
  function readableColor(value) {
2069
1956
  const rgb = value.trim().match(/^rgb\(\s*(\d+)\s*[, ]\s*(\d+)\s*[, ]\s*(\d+)\s*\)$/);
@@ -2250,8 +2137,9 @@ function inspectElement(element, isKnown) {
2250
2137
  if (row.label === "Display" && ["inline", "block"].includes(value)) return false;
2251
2138
  if (row.label === "Shadow" && value === "none") return false;
2252
2139
  if (row.label === "Opacity" && Number(value) === 1) return false;
2253
- if (row.label === "Fill" && (value === "transparent" || /^rgba?\([^)]*[,/]\s*0(?:\.0+)?%?\s*\)$/.test(value))) return false;
2254
- if (row.label === "Border" && !(Number.parseFloat(border.top) > 0)) return false;
2140
+ const transparent = value === "transparent" || /^rgba?\([^)]*[,/]\s*0(?:\.0+)?%?\s*\)$/.test(value);
2141
+ if (row.label === "Fill" && transparent) return false;
2142
+ if (row.label === "Border" && (transparent || !(Number.parseFloat(border.top) > 0))) return false;
2255
2143
  if (row.label === "Line height" && value === "normal") return false;
2256
2144
  if (row.label === "Letter spacing" && (value === "normal" || isZero(value))) return false;
2257
2145
  if (row.label === "Alignment" && [
@@ -2977,7 +2865,7 @@ function CvaPreview(t0) {
2977
2865
  component = slot.split(".")[0];
2978
2866
  const props = {
2979
2867
  ...definition?.config.defaultVariants,
2980
- ...Object.fromEntries(Object.entries(variants).filter(_temp$6).map(_temp2$3))
2868
+ ...Object.fromEntries(Object.entries(variants).filter(_temp$6).map(_temp2$4))
2981
2869
  };
2982
2870
  const classes = (key, t4) => {
2983
2871
  const extra = t4 === void 0 ? {} : t4;
@@ -3108,7 +2996,7 @@ function CvaPreview(t0) {
3108
2996
  sample = /* @__PURE__ */ jsx("a", {
3109
2997
  className: exact,
3110
2998
  href: "#preview",
3111
- onClick: _temp3$2,
2999
+ onClick: _temp3$3,
3112
3000
  children: "Example link"
3113
3001
  });
3114
3002
  break bb0;
@@ -3739,10 +3627,10 @@ function CvaPreview(t0) {
3739
3627
  function _temp4$2(value_2) {
3740
3628
  return /* @__PURE__ */ jsx("option", { children: value_2 }, value_2);
3741
3629
  }
3742
- function _temp3$2(event_1) {
3630
+ function _temp3$3(event_1) {
3743
3631
  return event_1.preventDefault();
3744
3632
  }
3745
- function _temp2$3(t0) {
3633
+ function _temp2$4(t0) {
3746
3634
  const [name, value_0] = t0;
3747
3635
  return [name, value_0 === "true" ? true : value_0 === "false" ? false : value_0];
3748
3636
  }
@@ -3954,7 +3842,7 @@ function CvaEditor(t0) {
3954
3842
  let update;
3955
3843
  if ($[2] !== component || $[3] !== draft.overrides || $[4] !== inheritedOverrides || $[5] !== setDraft || $[6] !== setSlot || $[7] !== slot) {
3956
3844
  slots = Object.keys(cvaDefinitions);
3957
- const components = [...new Set(slots.map(_temp2$2))];
3845
+ const components = [...new Set(slots.map(_temp2$3))];
3958
3846
  let t10;
3959
3847
  if ($[20] !== inheritedOverrides || $[21] !== slot) {
3960
3848
  t10 = resolveCvaDefinition(slot, inheritedOverrides);
@@ -3997,7 +3885,7 @@ function CvaEditor(t0) {
3997
3885
  const next_0 = event.target.value;
3998
3886
  setSlot(slots.find((key_0) => key_0.startsWith(`${next_0}.`)));
3999
3887
  };
4000
- t5 = components.map(_temp3$1);
3888
+ t5 = components.map(_temp3$2);
4001
3889
  $[2] = component;
4002
3890
  $[3] = draft.overrides;
4003
3891
  $[4] = inheritedOverrides;
@@ -4252,13 +4140,13 @@ function _temp4$1(key_2) {
4252
4140
  children: title(key_2.split(".")[1])
4253
4141
  }, key_2);
4254
4142
  }
4255
- function _temp3$1(name) {
4143
+ function _temp3$2(name) {
4256
4144
  return /* @__PURE__ */ jsx("option", {
4257
4145
  value: name,
4258
4146
  children: title(name)
4259
4147
  }, name);
4260
4148
  }
4261
- function _temp2$2(key) {
4149
+ function _temp2$3(key) {
4262
4150
  return key.split(".")[0];
4263
4151
  }
4264
4152
  //#endregion
@@ -4957,7 +4845,7 @@ function PaletteSelect(t0) {
4957
4845
  } else t6 = $[36];
4958
4846
  let t7;
4959
4847
  if ($[37] !== options) {
4960
- t7 = paletteFamilies(options).map(_temp2$1);
4848
+ t7 = paletteFamilies(options).map(_temp2$2);
4961
4849
  $[37] = options;
4962
4850
  $[38] = t7;
4963
4851
  } else t7 = $[38];
@@ -4977,6 +4865,7 @@ function PaletteSelect(t0) {
4977
4865
  if ($[40] !== t7) {
4978
4866
  t9 = /* @__PURE__ */ jsx($542a13ca2fa5b484$export$5b6b19405a83ff9d, {
4979
4867
  className: "studio-palette-popover",
4868
+ "data-povio-inspector-ignore": "",
4980
4869
  placement: "bottom end",
4981
4870
  children: /* @__PURE__ */ jsxs($928221da08ecbc62$export$41f133550aa26f48, {
4982
4871
  className: "studio-palette-list",
@@ -5008,7 +4897,7 @@ function PaletteSelect(t0) {
5008
4897
  } else t10 = $[49];
5009
4898
  return t10;
5010
4899
  }
5011
- function _temp2$1(t0) {
4900
+ function _temp2$2(t0) {
5012
4901
  const { family: name_0, steps: steps_0 } = t0;
5013
4902
  return /* @__PURE__ */ jsxs($928221da08ecbc62$export$dca12b0bb56e4fc, {
5014
4903
  id: name_0,
@@ -5216,7 +5105,7 @@ function useLoadedFonts() {
5216
5105
  document.fonts.ready.then(() => {
5217
5106
  if (!active) return;
5218
5107
  const root = getComputedStyle(document.documentElement);
5219
- const families = [...new Set([...document.fonts].map(_temp2))].filter(_temp3);
5108
+ const families = [...new Set([...document.fonts].map(_temp2$1))].filter(_temp3$1);
5220
5109
  setFonts(families.map((family_0) => {
5221
5110
  const base = `--font-${family_0.split(/\s+/)[0].toLowerCase()}-base`;
5222
5111
  const value_0 = unquote(root.getPropertyValue(base)) === family_0 ? `var(${base}), sans-serif` : `"${family_0}", sans-serif`;
@@ -5251,10 +5140,10 @@ function useLoadedFonts() {
5251
5140
  return t4;
5252
5141
  }
5253
5142
  /** Families added through the upload button in this page session. */
5254
- function _temp3(family) {
5143
+ function _temp3$1(family) {
5255
5144
  return !family.startsWith("Povio Fontsource preview ");
5256
5145
  }
5257
- function _temp2(face) {
5146
+ function _temp2$1(face) {
5258
5147
  return unquote(face.family);
5259
5148
  }
5260
5149
  function _temp$2(value) {
@@ -5859,214 +5748,819 @@ function isPresetActive(preset, defaults, current) {
5859
5748
  return Object.keys(a).length === Object.keys(b).length && Object.entries(a).every(([name, value]) => b[name] === value);
5860
5749
  });
5861
5750
  }
5862
- //#endregion
5863
- //#region src/configurator/ShadesGenerator.tsx
5751
+ const defaultShadeCurve = {
5752
+ hue: 0,
5753
+ saturation: 100,
5754
+ start: .985,
5755
+ end: .16,
5756
+ startHandle: {
5757
+ x: 1 / 3,
5758
+ y: .985
5759
+ },
5760
+ endHandle: {
5761
+ x: 2 / 3,
5762
+ y: .16
5763
+ },
5764
+ pins: {},
5765
+ basePinned: false
5766
+ };
5767
+ const toLinear = (channel) => {
5768
+ const c = channel / 255;
5769
+ return c <= .04045 ? c / 12.92 : ((c + .055) / 1.055) ** 2.4;
5770
+ };
5771
+ const toGamma = (channel) => {
5772
+ return (channel <= .0031308 ? 12.92 * channel : 1.055 * channel ** (1 / 2.4) - .055) * 255;
5773
+ };
5774
+ /** sRGB channels (0–255) to OKLCH: lightness 0–1, chroma, hue in degrees. */
5775
+ function rgbToOklch([red, green, blue]) {
5776
+ const [r, g, b] = [
5777
+ red,
5778
+ green,
5779
+ blue
5780
+ ].map((value) => toLinear(value ?? 0));
5781
+ const l = Math.cbrt(.4122214708 * r + .5363325363 * g + .0514459929 * b);
5782
+ const m = Math.cbrt(.2119034982 * r + .6806995451 * g + .1073969566 * b);
5783
+ const s = Math.cbrt(.0883024619 * r + .2817188376 * g + .6299787005 * b);
5784
+ const lightness = .2104542553 * l + .793617785 * m - .0040720468 * s;
5785
+ const a = 1.9779984951 * l - 2.428592205 * m + .4505937099 * s;
5786
+ const bAxis = .0259040371 * l + .7827717662 * m - .808675766 * s;
5787
+ return [
5788
+ lightness,
5789
+ Math.hypot(a, bAxis),
5790
+ (Math.atan2(bAxis, a) * 180 / Math.PI + 360) % 360
5791
+ ];
5792
+ }
5793
+ function oklchToRgb(lightness, chroma, hue) {
5794
+ const angle = hue * Math.PI / 180;
5795
+ const a = chroma * Math.cos(angle);
5796
+ const b = chroma * Math.sin(angle);
5797
+ const l = (lightness + .3963377774 * a + .2158037573 * b) ** 3;
5798
+ const m = (lightness - .1055613458 * a - .0638541728 * b) ** 3;
5799
+ const s = (lightness - .0894841775 * a - 1.291485548 * b) ** 3;
5800
+ return [
5801
+ 4.0767416621 * l - 3.3077115913 * m + .2309699292 * s,
5802
+ -1.2684380046 * l + 2.6097574011 * m - .3413193965 * s,
5803
+ -.0041960863 * l - .7034186147 * m + 1.707614701 * s
5804
+ ].map(toGamma);
5805
+ }
5806
+ const inGamut = (channels) => channels.every((value) => value >= -.5 && value <= 255.5);
5807
+ /** The color at this lightness and hue, keeping as much of the chroma as sRGB can show. */
5808
+ function fitToGamut(lightness, chroma, hue) {
5809
+ const exact = oklchToRgb(lightness, chroma, hue);
5810
+ if (inGamut(exact)) return exact;
5811
+ let low = 0;
5812
+ let high = chroma;
5813
+ for (let i = 0; i < 20; i++) {
5814
+ const middle = (low + high) / 2;
5815
+ if (inGamut(oklchToRgb(lightness, middle, hue))) low = middle;
5816
+ else high = middle;
5817
+ }
5818
+ return oklchToRgb(lightness, low, hue);
5819
+ }
5820
+ const toChannels = (channels) => channels.map((value) => Math.max(0, Math.min(255, Math.round(value)))).join(" ");
5821
+ const clamp$1 = (value, low, high) => Math.max(low, Math.min(high, value));
5822
+ /** The base color with the curve's Hue and Saturation applied: the hue and chroma every shade takes. */
5823
+ function adjustBase(baseRgb, curve) {
5824
+ const [lightness, chroma, hue] = rgbToOklch(baseRgb.split(/\s+/).map(Number));
5825
+ return toChannels(fitToGamut(lightness, chroma * curve.saturation / 100, (hue + curve.hue + 360) % 360));
5826
+ }
5827
+ /** Where each step sits on the curve's x axis, lightest first. */
5828
+ const stepPosition = (index, count) => count > 1 ? index / (count - 1) : 0;
5864
5829
  /**
5865
- * Generates a whole base palette scale from one color, which becomes its 500 step.
5830
+ * The curve as cubic bezier segments between its fixed points: the two ends and every pin. The end handles shape the
5831
+ * first and last segment; pins get smooth, monotone tangents so the curve never overshoots between them.
5866
5832
  */
5867
- function ShadesGenerator(t0) {
5868
- const $ = c(52);
5869
- const { title, steps, initial, onApply } = t0;
5833
+ function curveSegments(curve, steps, baseLightness) {
5834
+ const ordered = [...steps].sort((a, b) => a - b);
5835
+ const count = ordered.length;
5836
+ const fixed = [{
5837
+ x: 0,
5838
+ y: curve.start
5839
+ }, {
5840
+ x: 1,
5841
+ y: curve.end
5842
+ }];
5843
+ ordered.forEach((step, index) => {
5844
+ if (index === 0 || index === count - 1) return;
5845
+ const x = stepPosition(index, count);
5846
+ if (step === 500 && curve.basePinned) fixed.push({
5847
+ x,
5848
+ y: baseLightness
5849
+ });
5850
+ else if (curve.pins[step] !== void 0) fixed.push({
5851
+ x,
5852
+ y: curve.pins[step]
5853
+ });
5854
+ });
5855
+ fixed.sort((a, b) => a.x - b.x);
5856
+ const slopes = fixed.slice(1).map((point, k) => (point.y - fixed[k].y) / (point.x - fixed[k].x));
5857
+ const tangent = (k) => {
5858
+ const before = slopes[k - 1];
5859
+ const after = slopes[k];
5860
+ if (Math.sign(before) !== Math.sign(after) || before === 0 || after === 0) return 0;
5861
+ const average = (before + after) / 2;
5862
+ const limit = 3 * Math.min(Math.abs(before), Math.abs(after));
5863
+ return Math.sign(average) * Math.min(Math.abs(average), limit);
5864
+ };
5865
+ const fromHandle = (anchor, handle, width, sign) => {
5866
+ const reach = Math.abs(handle.x - anchor.x);
5867
+ const scale = Math.min(1, width * .9 / Math.max(reach, 1e-6));
5868
+ return {
5869
+ x: anchor.x + sign * reach * scale,
5870
+ y: anchor.y + (handle.y - anchor.y) * scale
5871
+ };
5872
+ };
5873
+ const last = fixed.length - 2;
5874
+ return fixed.slice(0, -1).map((from, k) => {
5875
+ const to = fixed[k + 1];
5876
+ const width = to.x - from.x;
5877
+ return [
5878
+ from,
5879
+ k === 0 ? fromHandle(from, curve.startHandle, width, 1) : {
5880
+ x: from.x + width / 3,
5881
+ y: from.y + tangent(k) * width / 3
5882
+ },
5883
+ k === last ? fromHandle(to, curve.endHandle, width, -1) : {
5884
+ x: to.x - width / 3,
5885
+ y: to.y - tangent(k + 1) * width / 3
5886
+ },
5887
+ to
5888
+ ];
5889
+ });
5890
+ }
5891
+ const bezier = ([p0, p1, p2, p3], t) => {
5892
+ const u = 1 - t;
5893
+ return {
5894
+ x: u * u * u * p0.x + 3 * u * u * t * p1.x + 3 * u * t * t * p2.x + t * t * t * p3.x,
5895
+ y: u * u * u * p0.y + 3 * u * u * t * p1.y + 3 * u * t * t * p2.y + t * t * t * p3.y
5896
+ };
5897
+ };
5898
+ /** The curve's lightness at `x`, clamped to 0–1 so no shade passes white or black. */
5899
+ function curveLightness(segments, x) {
5900
+ const segment = segments.find((item) => x <= item[3].x + 1e-9) ?? segments.at(-1);
5901
+ let low = 0;
5902
+ let high = 1;
5903
+ for (let i = 0; i < 40; i++) {
5904
+ const middle = (low + high) / 2;
5905
+ if (bezier(segment, middle).x < x) low = middle;
5906
+ else high = middle;
5907
+ }
5908
+ return clamp$1(bezier(segment, (low + high) / 2).y, 0, 1);
5909
+ }
5910
+ /** The lightness of every step on the curve, pins included, keyed by step. */
5911
+ function curveStepLightness(curve, steps, baseLightness) {
5912
+ const ordered = [...steps].sort((a, b) => a - b);
5913
+ const segments = curveSegments(curve, ordered, baseLightness);
5914
+ return Object.fromEntries(ordered.map((step, index) => [step, step === 500 && curve.basePinned ? baseLightness : curve.pins[step] ?? curveLightness(segments, stepPosition(index, ordered.length))]));
5915
+ }
5916
+ /** Generates a palette's RGB channel values from its base color and lightness curve, keyed by step. */
5917
+ function generateCurveShades(baseRgb, steps, curve) {
5918
+ const [baseLightness, baseChroma, baseHue] = rgbToOklch(baseRgb.split(/\s+/).map(Number));
5919
+ const ordered = [...steps].sort((a, b) => a - b);
5920
+ const lightness = curveStepLightness(curve, ordered, baseLightness);
5921
+ const hue = (baseHue + curve.hue + 360) % 360;
5922
+ const chroma = baseChroma * curve.saturation / 100;
5923
+ return Object.fromEntries(ordered.map((step, index) => {
5924
+ const taper = 1 - .55 * (Math.abs(stepPosition(index, ordered.length) - .5) * 2) ** 1.6;
5925
+ return [step, toChannels(fitToGamut(lightness[step], chroma * taper, hue))];
5926
+ }));
5927
+ }
5928
+ //#endregion
5929
+ //#region src/configurator/ShadesGenerator.tsx
5930
+ const colorRows = [{
5931
+ field: "hue",
5932
+ label: "Hue",
5933
+ min: -180,
5934
+ max: 180,
5935
+ step: 1,
5936
+ unit: "°"
5937
+ }, {
5938
+ field: "saturation",
5939
+ label: "Saturation",
5940
+ min: 0,
5941
+ max: 300,
5942
+ step: 1,
5943
+ unit: "%"
5944
+ }];
5945
+ /** A Figma-style slider field: label and value in a 24px field filled to the value; drag or use arrow keys. */
5946
+ function SliderField(t0) {
5947
+ const $ = c(25);
5948
+ const { label, value, min, max, step, display, disabled, onChange } = t0;
5949
+ const origin = min < 0 ? 0 : min;
5870
5950
  let t1;
5871
- if ($[0] !== initial) {
5872
- t1 = isRgb(initial) ? toHex(initial).slice(1).toUpperCase() : "";
5873
- $[0] = initial;
5874
- $[1] = t1;
5875
- } else t1 = $[1];
5876
- const [text, setText] = useState(t1);
5877
- let base;
5878
- let pending;
5879
- let shades;
5880
- let t10;
5881
- let t2;
5882
- let t3;
5951
+ if ($[0] !== max || $[1] !== min) {
5952
+ t1 = (amount) => (amount - min) / (max - min) * 100;
5953
+ $[0] = max;
5954
+ $[1] = min;
5955
+ $[2] = t1;
5956
+ } else t1 = $[2];
5957
+ const percent = t1;
5958
+ const from = Math.min(percent(origin), percent(value));
5959
+ const to = Math.max(percent(origin), percent(value));
5960
+ const t2 = `${from}%`;
5961
+ const t3 = `${to}%`;
5883
5962
  let t4;
5884
- let t5;
5963
+ if ($[3] !== t2 || $[4] !== t3) {
5964
+ t4 = {
5965
+ "--from": t2,
5966
+ "--to": t3
5967
+ };
5968
+ $[3] = t2;
5969
+ $[4] = t3;
5970
+ $[5] = t4;
5971
+ } else t4 = $[5];
5972
+ const t5 = t4;
5885
5973
  let t6;
5974
+ if ($[6] !== label) {
5975
+ t6 = /* @__PURE__ */ jsx("span", { children: label });
5976
+ $[6] = label;
5977
+ $[7] = t6;
5978
+ } else t6 = $[7];
5886
5979
  let t7;
5980
+ if ($[8] !== display) {
5981
+ t7 = /* @__PURE__ */ jsx("output", { children: display });
5982
+ $[8] = display;
5983
+ $[9] = t7;
5984
+ } else t7 = $[9];
5887
5985
  let t8;
5986
+ if ($[10] !== onChange) {
5987
+ t8 = (event) => onChange(Number(event.target.value));
5988
+ $[10] = onChange;
5989
+ $[11] = t8;
5990
+ } else t8 = $[11];
5888
5991
  let t9;
5889
- if ($[2] !== initial || $[3] !== steps || $[4] !== text || $[5] !== title) {
5890
- const hex = text.trim().replace(/^#/, "");
5891
- base = /^[0-9a-f]{6}$/i.test(hex) ? toRgb(`#${hex}`) : /^[0-9a-f]{3}$/i.test(hex) ? toRgb(`#${hex.replace(/./g, "$&$&")}`) : null;
5892
- shades = base ? generateShades(base, steps.map(_temp$1)) : null;
5893
- pending = !!shades && base !== initial;
5894
- t8 = "studio-shades";
5895
- t9 = "group";
5896
- t10 = `Generate ${title} shades`;
5897
- t5 = "studio-shades-input";
5898
- const t11 = `shades-${title}`;
5899
- if ($[18] !== t11) {
5900
- t6 = /* @__PURE__ */ jsx("label", {
5901
- htmlFor: t11,
5902
- children: "Base color (500)"
5903
- });
5904
- $[18] = t11;
5905
- $[19] = t6;
5906
- } else t6 = $[19];
5907
- let t12;
5908
- if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
5909
- t12 = /* @__PURE__ */ jsx("span", {
5910
- "aria-hidden": "true",
5911
- children: "#"
5912
- });
5913
- $[20] = t12;
5914
- } else t12 = $[20];
5915
- const t13 = `shades-${title}`;
5916
- const t14 = !base;
5917
- let t15;
5918
- if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
5919
- t15 = (event) => setText(event.target.value.replace(/^#/, ""));
5920
- $[21] = t15;
5921
- } else t15 = $[21];
5922
- if ($[22] !== t13 || $[23] !== t14 || $[24] !== text) {
5923
- t7 = /* @__PURE__ */ jsxs("span", {
5924
- className: "studio-token-input",
5925
- children: [t12, /* @__PURE__ */ jsx("input", {
5926
- id: t13,
5927
- value: text,
5928
- "aria-invalid": t14,
5929
- spellCheck: false,
5930
- onChange: t15
5931
- })]
5932
- });
5933
- $[22] = t13;
5934
- $[23] = t14;
5935
- $[24] = text;
5936
- $[25] = t7;
5937
- } else t7 = $[25];
5938
- t2 = "color";
5939
- t3 = "Pick base color";
5940
- t4 = base ? toHex(base) : "#000000";
5941
- $[2] = initial;
5942
- $[3] = steps;
5943
- $[4] = text;
5944
- $[5] = title;
5945
- $[6] = base;
5946
- $[7] = pending;
5947
- $[8] = shades;
5948
- $[9] = t10;
5949
- $[10] = t2;
5950
- $[11] = t3;
5951
- $[12] = t4;
5952
- $[13] = t5;
5953
- $[14] = t6;
5954
- $[15] = t7;
5955
- $[16] = t8;
5956
- $[17] = t9;
5957
- } else {
5958
- base = $[6];
5959
- pending = $[7];
5960
- shades = $[8];
5961
- t10 = $[9];
5962
- t2 = $[10];
5963
- t3 = $[11];
5964
- t4 = $[12];
5965
- t5 = $[13];
5966
- t6 = $[14];
5967
- t7 = $[15];
5968
- t8 = $[16];
5969
- t9 = $[17];
5970
- }
5971
- let t11;
5972
- if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
5973
- t11 = (event_0) => setText(event_0.target.value.slice(1).toUpperCase());
5974
- $[26] = t11;
5975
- } else t11 = $[26];
5976
- let t12;
5977
- if ($[27] !== t2 || $[28] !== t3 || $[29] !== t4) {
5978
- t12 = /* @__PURE__ */ jsx("input", {
5979
- type: t2,
5980
- "aria-label": t3,
5981
- value: t4,
5982
- onChange: t11
5983
- });
5984
- $[27] = t2;
5985
- $[28] = t3;
5986
- $[29] = t4;
5987
- $[30] = t12;
5988
- } else t12 = $[30];
5989
- const t13 = !pending;
5990
- let t14;
5991
- if ($[31] !== onApply || $[32] !== shades || $[33] !== steps) {
5992
- t14 = () => {
5993
- if (shades) onApply(Object.fromEntries(steps.map((t15) => {
5994
- const { name, step: step_0 } = t15;
5995
- return [name, shades[step_0]];
5996
- })));
5997
- };
5998
- $[31] = onApply;
5999
- $[32] = shades;
6000
- $[33] = steps;
6001
- $[34] = t14;
6002
- } else t14 = $[34];
6003
- let t15;
6004
- if ($[35] !== t13 || $[36] !== t14) {
6005
- t15 = /* @__PURE__ */ jsx("div", {
6006
- className: "studio-shades-actions",
6007
- children: /* @__PURE__ */ jsx("button", {
6008
- type: "button",
6009
- className: "studio-primary",
6010
- disabled: t13,
6011
- onClick: t14,
6012
- children: "Change shades"
6013
- })
5992
+ if ($[12] !== disabled || $[13] !== display || $[14] !== max || $[15] !== min || $[16] !== step || $[17] !== t8 || $[18] !== value) {
5993
+ t9 = /* @__PURE__ */ jsx("input", {
5994
+ type: "range",
5995
+ min,
5996
+ max,
5997
+ step,
5998
+ value,
5999
+ disabled,
6000
+ "aria-valuetext": display,
6001
+ onChange: t8
6014
6002
  });
6015
- $[35] = t13;
6016
- $[36] = t14;
6017
- $[37] = t15;
6018
- } else t15 = $[37];
6019
- let t16;
6020
- if ($[38] !== t12 || $[39] !== t15 || $[40] !== t5 || $[41] !== t6 || $[42] !== t7) {
6021
- t16 = /* @__PURE__ */ jsxs("div", {
6022
- className: t5,
6003
+ $[12] = disabled;
6004
+ $[13] = display;
6005
+ $[14] = max;
6006
+ $[15] = min;
6007
+ $[16] = step;
6008
+ $[17] = t8;
6009
+ $[18] = value;
6010
+ $[19] = t9;
6011
+ } else t9 = $[19];
6012
+ let t10;
6013
+ if ($[20] !== t5 || $[21] !== t6 || $[22] !== t7 || $[23] !== t9) {
6014
+ t10 = /* @__PURE__ */ jsxs("label", {
6015
+ className: "studio-slider-field",
6016
+ style: t5,
6023
6017
  children: [
6024
6018
  t6,
6025
6019
  t7,
6026
- t12,
6027
- t15
6020
+ t9
6028
6021
  ]
6029
6022
  });
6030
- $[38] = t12;
6031
- $[39] = t15;
6032
- $[40] = t5;
6033
- $[41] = t6;
6034
- $[42] = t7;
6035
- $[43] = t16;
6036
- } else t16 = $[43];
6037
- let t17;
6038
- if ($[44] !== base) {
6039
- t17 = !base && /* @__PURE__ */ jsx("p", {
6040
- className: "studio-error",
6041
- children: "Enter a hex color such as #75ACFF."
6023
+ $[20] = t5;
6024
+ $[21] = t6;
6025
+ $[22] = t7;
6026
+ $[23] = t9;
6027
+ $[24] = t10;
6028
+ } else t10 = $[24];
6029
+ return t10;
6030
+ }
6031
+ /** Dragging the base this close to the base color's own lightness snaps it there. */
6032
+ const baseSnap = .012;
6033
+ /** Keeps a moved shade at least this far (per step) from the fixed points beside it, so shades stay in order. */
6034
+ const orderMargin = .006;
6035
+ const width = 320;
6036
+ const height = 260;
6037
+ const insetX = 14;
6038
+ const insetY = 40;
6039
+ const toX = (x) => insetX + x * 292;
6040
+ const toY = (y) => insetY + (1 - y) * 180;
6041
+ const clamp = (value, low, high) => Math.max(low, Math.min(high, value));
6042
+ /**
6043
+ * The palette's lightness curve, edited like a vector path: drag the ends (the backgrounds) and their handles, and drag
6044
+ * any shade up or down to make the curve pass through it. A moved shade stays between the fixed points beside it, so
6045
+ * the curve keeps its order; double-click it (or press Delete) to release it. The base snaps to its own lightness.
6046
+ */
6047
+ function CurveEditor(t0) {
6048
+ const $ = c(13);
6049
+ const { curve, steps, shades, baseLightness, disabled, onChange } = t0;
6050
+ const svgRef = useRef(null);
6051
+ const [grip, setGrip] = useState(null);
6052
+ const press = useRef(null);
6053
+ const ordered = [...steps].sort(_temp$1);
6054
+ const segments = curveSegments(curve, ordered, baseLightness);
6055
+ const lightness = curveStepLightness(curve, ordered, baseLightness);
6056
+ const path = segments.map(_temp2).join(" ");
6057
+ const baseIndex = ordered.indexOf(500);
6058
+ let t1;
6059
+ if ($[0] !== curve.basePinned || $[1] !== curve.pins) {
6060
+ t1 = (step) => step === 500 && curve.basePinned || curve.pins[step] !== void 0;
6061
+ $[0] = curve.basePinned;
6062
+ $[1] = curve.pins;
6063
+ $[2] = t1;
6064
+ } else t1 = $[2];
6065
+ const isMoved = t1;
6066
+ const moveShade = (step_0, y) => {
6067
+ const index_0 = ordered.indexOf(step_0);
6068
+ let lighter = {
6069
+ index: 0,
6070
+ y: curve.start
6071
+ };
6072
+ let darker = {
6073
+ index: ordered.length - 1,
6074
+ y: curve.end
6075
+ };
6076
+ ordered.forEach((other, otherIndex) => {
6077
+ if (other === step_0 || otherIndex === 0 || otherIndex === ordered.length - 1 || !isMoved(other)) return;
6078
+ const value = lightness[other];
6079
+ if (otherIndex < index_0 && otherIndex > lighter.index) lighter = {
6080
+ index: otherIndex,
6081
+ y: value
6082
+ };
6083
+ if (otherIndex > index_0 && otherIndex < darker.index) darker = {
6084
+ index: otherIndex,
6085
+ y: value
6086
+ };
6042
6087
  });
6043
- $[44] = base;
6044
- $[45] = t17;
6045
- } else t17 = $[45];
6046
- let t18;
6047
- if ($[46] !== t10 || $[47] !== t16 || $[48] !== t17 || $[49] !== t8 || $[50] !== t9) {
6048
- t18 = /* @__PURE__ */ jsxs("div", {
6049
- className: t8,
6050
- role: t9,
6051
- "aria-label": t10,
6052
- children: [t16, t17]
6088
+ const bounded = clamp(y, darker.y + orderMargin * (darker.index - index_0), lighter.y - orderMargin * (index_0 - lighter.index));
6089
+ const pins = { ...curve.pins };
6090
+ if (step_0 === 500 && Math.abs(bounded - baseLightness) < baseSnap) {
6091
+ delete pins[500];
6092
+ onChange({
6093
+ ...curve,
6094
+ pins,
6095
+ basePinned: true
6096
+ });
6097
+ return;
6098
+ }
6099
+ pins[step_0] = bounded;
6100
+ onChange({
6101
+ ...curve,
6102
+ pins,
6103
+ basePinned: step_0 === 500 ? false : curve.basePinned
6053
6104
  });
6054
- $[46] = t10;
6055
- $[47] = t16;
6056
- $[48] = t17;
6057
- $[49] = t8;
6058
- $[50] = t9;
6059
- $[51] = t18;
6060
- } else t18 = $[51];
6061
- return t18;
6105
+ };
6106
+ let t2;
6107
+ if ($[3] !== curve || $[4] !== disabled || $[5] !== isMoved || $[6] !== onChange) {
6108
+ t2 = (step_1) => {
6109
+ if (disabled || !isMoved(step_1)) return;
6110
+ const pins_0 = { ...curve.pins };
6111
+ delete pins_0[step_1];
6112
+ onChange({
6113
+ ...curve,
6114
+ pins: pins_0,
6115
+ basePinned: step_1 === 500 ? false : curve.basePinned
6116
+ });
6117
+ };
6118
+ $[3] = curve;
6119
+ $[4] = disabled;
6120
+ $[5] = isMoved;
6121
+ $[6] = onChange;
6122
+ $[7] = t2;
6123
+ } else t2 = $[7];
6124
+ const release = t2;
6125
+ const move = (target, point) => {
6126
+ if (typeof target === "number") moveShade(target, point.y);
6127
+ else if (target === "start" || target === "end") {
6128
+ const y_0 = clamp(point.y, 0, 1);
6129
+ const handle = target === "start" ? "startHandle" : "endHandle";
6130
+ const delta = y_0 - curve[target];
6131
+ onChange({
6132
+ ...curve,
6133
+ [target]: y_0,
6134
+ [handle]: {
6135
+ ...curve[handle],
6136
+ y: clamp(curve[handle].y + delta, -.18, 1.18)
6137
+ }
6138
+ });
6139
+ } else onChange({
6140
+ ...curve,
6141
+ [target]: {
6142
+ x: clamp(point.x, 0, 1),
6143
+ y: clamp(point.y, -.18, 1.18)
6144
+ }
6145
+ });
6146
+ };
6147
+ const pointAt = (event) => {
6148
+ const box = svgRef.current.getBoundingClientRect();
6149
+ const px = (event.clientX - box.left) * width / box.width;
6150
+ const py = (event.clientY - box.top) * height / box.height;
6151
+ return {
6152
+ x: (px - insetX) / 292,
6153
+ y: 1 - (py - insetY) / 180
6154
+ };
6155
+ };
6156
+ const startDrag = (target_0) => (event_0) => {
6157
+ if (disabled || event_0.button !== 0) return;
6158
+ event_0.preventDefault();
6159
+ svgRef.current?.setPointerCapture(event_0.pointerId);
6160
+ press.current = {
6161
+ grip: target_0,
6162
+ x: event_0.clientX,
6163
+ y: event_0.clientY,
6164
+ moved: false
6165
+ };
6166
+ setGrip(target_0);
6167
+ };
6168
+ const nudge = (target_1) => (event_1) => {
6169
+ const amount = event_1.shiftKey ? .05 : .01;
6170
+ const vertical = target_1 === "start" || target_1 === "end";
6171
+ const offset = {
6172
+ ArrowUp: [0, amount],
6173
+ ArrowDown: [0, -amount],
6174
+ ArrowLeft: [vertical ? 0 : -amount, 0],
6175
+ ArrowRight: [vertical ? 0 : amount, 0]
6176
+ }[event_1.key];
6177
+ if (!offset || disabled) return;
6178
+ event_1.preventDefault();
6179
+ const current = vertical ? {
6180
+ x: target_1 === "start" ? 0 : 1,
6181
+ y: curve[target_1]
6182
+ } : curve[target_1];
6183
+ move(target_1, {
6184
+ x: current.x + offset[0],
6185
+ y: current.y + offset[1]
6186
+ });
6187
+ };
6188
+ const shadeKeys = (step_2) => (event_2) => {
6189
+ if (disabled) return;
6190
+ if (event_2.key === "Delete" || event_2.key === "Backspace") {
6191
+ event_2.preventDefault();
6192
+ release(step_2);
6193
+ return;
6194
+ }
6195
+ const amount_0 = event_2.shiftKey ? .05 : .01;
6196
+ const offset_0 = event_2.key === "ArrowUp" ? amount_0 : event_2.key === "ArrowDown" ? -amount_0 : 0;
6197
+ if (!offset_0) return;
6198
+ event_2.preventDefault();
6199
+ moveShade(step_2, lightness[step_2] + offset_0);
6200
+ };
6201
+ const ends = [{
6202
+ grip: "start",
6203
+ handle: "startHandle",
6204
+ x: 0,
6205
+ y: curve.start,
6206
+ label: `Lightest end, ${ordered[0]}`
6207
+ }, {
6208
+ grip: "end",
6209
+ handle: "endHandle",
6210
+ x: 1,
6211
+ y: curve.end,
6212
+ label: `Darkest end, ${ordered.at(-1)}`
6213
+ }];
6214
+ let t3;
6215
+ let t4;
6216
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
6217
+ t3 = () => setGrip(null);
6218
+ t4 = () => setGrip(null);
6219
+ $[8] = t3;
6220
+ $[9] = t4;
6221
+ } else {
6222
+ t3 = $[8];
6223
+ t4 = $[9];
6224
+ }
6225
+ let t5;
6226
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
6227
+ t5 = toY(1);
6228
+ $[10] = t5;
6229
+ } else t5 = $[10];
6230
+ let t6;
6231
+ let t7;
6232
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
6233
+ t6 = /* @__PURE__ */ jsx("rect", {
6234
+ className: "studio-curve-range",
6235
+ x: insetX,
6236
+ y: t5,
6237
+ width: 292,
6238
+ height: toY(0) - toY(1)
6239
+ });
6240
+ t7 = [
6241
+ .25,
6242
+ .5,
6243
+ .75
6244
+ ].map(_temp3);
6245
+ $[11] = t6;
6246
+ $[12] = t7;
6247
+ } else {
6248
+ t6 = $[11];
6249
+ t7 = $[12];
6250
+ }
6251
+ return /* @__PURE__ */ jsxs("svg", {
6252
+ ref: svgRef,
6253
+ className: `studio-curve-editor ${grip ? "is-dragging" : ""}`,
6254
+ viewBox: `0 0 ${width} ${height}`,
6255
+ "aria-label": "Lightness curve",
6256
+ onPointerMove: (event_3) => {
6257
+ const current_0 = press.current;
6258
+ if (!grip || !current_0) return;
6259
+ if (!current_0.moved && Math.hypot(event_3.clientX - current_0.x, event_3.clientY - current_0.y) < 3) return;
6260
+ current_0.moved = true;
6261
+ move(grip, pointAt(event_3));
6262
+ },
6263
+ onDoubleClick: () => {
6264
+ const target_2 = press.current?.grip;
6265
+ if (typeof target_2 === "number") release(target_2);
6266
+ },
6267
+ onPointerUp: t3,
6268
+ onPointerCancel: t4,
6269
+ children: [
6270
+ t6,
6271
+ t7,
6272
+ ordered.map((step_3, index_1) => /* @__PURE__ */ jsx("line", {
6273
+ className: "studio-curve-step",
6274
+ x1: toX(stepPosition(index_1, ordered.length)),
6275
+ x2: toX(stepPosition(index_1, ordered.length)),
6276
+ y1: toY(0),
6277
+ y2: toY(1)
6278
+ }, step_3)),
6279
+ baseIndex >= 0 && !curve.basePinned && /* @__PURE__ */ jsx("line", {
6280
+ className: "studio-curve-base-mark",
6281
+ x1: toX(stepPosition(baseIndex, ordered.length)) - 12,
6282
+ x2: toX(stepPosition(baseIndex, ordered.length)) + 12,
6283
+ y1: toY(baseLightness),
6284
+ y2: toY(baseLightness),
6285
+ children: /* @__PURE__ */ jsx("title", { children: "The base color's own lightness" })
6286
+ }),
6287
+ /* @__PURE__ */ jsx("path", {
6288
+ className: "studio-curve-path",
6289
+ d: path
6290
+ }),
6291
+ ends.map((end) => /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
6292
+ className: "studio-curve-handle-line",
6293
+ x1: toX(end.x),
6294
+ y1: toY(end.y),
6295
+ x2: toX(curve[end.handle].x),
6296
+ y2: toY(curve[end.handle].y)
6297
+ }), /* @__PURE__ */ jsx("circle", {
6298
+ className: "studio-curve-handle",
6299
+ cx: toX(curve[end.handle].x),
6300
+ cy: toY(curve[end.handle].y),
6301
+ r: "5",
6302
+ tabIndex: disabled ? -1 : 0,
6303
+ role: "button",
6304
+ "aria-label": `${end.label} handle. Drag or use arrow keys.`,
6305
+ onPointerDown: startDrag(end.handle),
6306
+ onKeyDown: nudge(end.handle)
6307
+ })] }, end.handle)),
6308
+ ordered.map((step_4, index_2) => {
6309
+ if (index_2 === 0 || index_2 === ordered.length - 1 || !shades[step_4]) return null;
6310
+ const pinned = isMoved(step_4);
6311
+ const cx = toX(stepPosition(index_2, ordered.length));
6312
+ const cy = toY(lightness[step_4]);
6313
+ return /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("circle", {
6314
+ className: `studio-curve-shade ${pinned ? "is-pinned" : ""} ${step_4 === 500 ? "is-base" : ""}`,
6315
+ cx,
6316
+ cy,
6317
+ r: pinned ? 5 : step_4 === 500 ? 4.5 : 3.5,
6318
+ fill: `rgb(${shades[step_4]})`,
6319
+ tabIndex: disabled ? -1 : 0,
6320
+ role: "button",
6321
+ "aria-label": `${step_4 === 500 ? "Base, 500" : step_4}, lightness ${(lightness[step_4] * 100).toFixed(1)}${pinned ? ", moved" : ""}. Drag or use arrow keys; Delete releases it.`,
6322
+ onPointerDown: startDrag(step_4),
6323
+ onKeyDown: shadeKeys(step_4),
6324
+ children: /* @__PURE__ */ jsx("title", { children: pinned ? `${step_4}: drag to adjust · double-click to release` : `${step_4}: drag to adjust` })
6325
+ }), step_4 === 500 && /* @__PURE__ */ jsx("text", {
6326
+ className: "studio-curve-label",
6327
+ x: cx + 8,
6328
+ y: cy - 8,
6329
+ children: curve.basePinned ? "Base · on base color" : "Base"
6330
+ })] }, step_4);
6331
+ }),
6332
+ ends.map((end_0) => /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("rect", {
6333
+ className: "studio-curve-end",
6334
+ x: toX(end_0.x) - 5,
6335
+ y: toY(end_0.y) - 5,
6336
+ width: "10",
6337
+ height: "10",
6338
+ rx: "2",
6339
+ tabIndex: disabled ? -1 : 0,
6340
+ role: "button",
6341
+ "aria-label": `${end_0.label}, lightness ${(end_0.y * 100).toFixed(1)}. Drag or use arrow keys.`,
6342
+ onPointerDown: startDrag(end_0.grip),
6343
+ onKeyDown: nudge(end_0.grip)
6344
+ }), /* @__PURE__ */ jsx("text", {
6345
+ className: "studio-curve-label",
6346
+ x: end_0.x ? toX(1) - 8 : toX(0) + 8,
6347
+ y: end_0.x ? toY(end_0.y) - 10 : toY(end_0.y) + 18,
6348
+ textAnchor: end_0.x ? "end" : "start",
6349
+ children: `${end_0.x ? ordered.at(-1) : ordered[0]} · ${(end_0.y * 100).toFixed(1)}`
6350
+ })] }, end_0.grip))
6351
+ ]
6352
+ });
6062
6353
  }
6063
- function _temp$1(t0) {
6064
- const { step } = t0;
6065
- return step;
6354
+ /**
6355
+ * Generates a whole base palette scale from one color. Advanced palette controls draw the scale from an editable
6356
+ * lightness curve instead and apply it live; until they are used, the classic weights apply with the base at 500.
6357
+ */
6358
+ function _temp3(y_1) {
6359
+ return /* @__PURE__ */ jsx("line", {
6360
+ className: "studio-curve-grid",
6361
+ x1: insetX,
6362
+ x2: 306,
6363
+ y1: toY(y_1),
6364
+ y2: toY(y_1)
6365
+ }, y_1);
6366
+ }
6367
+ function _temp2(t0, index) {
6368
+ const [from, first, second, to] = t0;
6369
+ return `${index ? "" : `M${toX(from.x)},${toY(from.y)} `}C${toX(first.x)},${toY(first.y)} ${toX(second.x)},${toY(second.y)} ${toX(to.x)},${toY(to.y)}`;
6370
+ }
6371
+ function _temp$1(a, b) {
6372
+ return a - b;
6373
+ }
6374
+ function ShadesGenerator({ title, steps, initial, onApply }) {
6375
+ const hexOf = (rgb) => isRgb(rgb) ? toHex(rgb).slice(1).toUpperCase() : "";
6376
+ const parseHex = (value) => {
6377
+ const hex = value.trim().replace(/^#/, "");
6378
+ return /^[0-9a-f]{6}$/i.test(hex) ? toRgb(`#${hex}`) : /^[0-9a-f]{3}$/i.test(hex) ? toRgb(`#${hex.replace(/./g, "$&$&")}`) : null;
6379
+ };
6380
+ /** The color the palette is generated from; Hue and Saturation adjust it on top. */
6381
+ const [source, setSource] = useState(isRgb(initial) ? initial : null);
6382
+ /** What is being typed into the base field, while it has focus. */
6383
+ const [draftText, setDraftText] = useState(null);
6384
+ const [advanced, setAdvanced] = useState(false);
6385
+ /** `null` until an advanced control is used: the classic generator. */
6386
+ const [curve, setCurve] = useState(null);
6387
+ /** The base the curve last applied from, so the button only offers changes to a new base. */
6388
+ const [curveBase, setCurveBase] = useState(null);
6389
+ const ownApply = useRef(null);
6390
+ const [synced, setSynced] = useState(initial);
6391
+ if (initial !== synced) {
6392
+ setSynced(initial);
6393
+ if (initial !== ownApply.current) {
6394
+ setSource(isRgb(initial) ? initial : null);
6395
+ setDraftText(null);
6396
+ setCurve(null);
6397
+ setCurveBase(null);
6398
+ }
6399
+ }
6400
+ const base = source;
6401
+ const shownBase = base && curve ? adjustBase(base, curve) : base;
6402
+ const fieldText = draftText ?? (shownBase ? hexOf(shownBase) : "");
6403
+ const invalid = draftText !== null ? !parseHex(draftText) : !base;
6404
+ /** A base entered by hand replaces the adjusted one, so Hue and Saturation start again from it. */
6405
+ const enterBase = (value_0) => {
6406
+ setDraftText(value_0);
6407
+ const parsed = parseHex(value_0);
6408
+ if (!parsed) return;
6409
+ setSource(parsed);
6410
+ if (curve && (curve.hue !== 0 || curve.saturation !== 100)) setCurve({
6411
+ ...curve,
6412
+ hue: 0,
6413
+ saturation: 100
6414
+ });
6415
+ };
6416
+ const numbers = steps.map(({ step }) => step);
6417
+ const shadesFor = (from, using) => using ? generateCurveShades(from, numbers, using) : generateShades(from, numbers);
6418
+ const shades = base ? shadesFor(base, curve) : null;
6419
+ const pending = !!shades && (curve ? base !== curveBase : base !== initial);
6420
+ const apply = (values, from_0) => {
6421
+ ownApply.current = values[500] ?? null;
6422
+ setCurveBase(from_0);
6423
+ onApply(Object.fromEntries(steps.map(({ name, step: step_0 }) => [name, values[step_0]])));
6424
+ };
6425
+ const updateCurve = (next) => {
6426
+ setCurve(next);
6427
+ if (base) apply(generateCurveShades(base, numbers, next), base);
6428
+ };
6429
+ const resetCurve = () => {
6430
+ setCurve(null);
6431
+ setCurveBase(null);
6432
+ if (base) apply(generateShades(base, numbers), base);
6433
+ };
6434
+ const active = curve ?? defaultShadeCurve;
6435
+ const curveShades = base ? generateCurveShades(base, numbers, active) : null;
6436
+ const baseLightness = shownBase ? rgbToOklch(shownBase.split(" ").map(Number))[0] : .5;
6437
+ const panelId = `shades-advanced-${title.replaceAll(" ", "-")}`;
6438
+ return /* @__PURE__ */ jsxs("div", {
6439
+ className: "studio-shades",
6440
+ role: "group",
6441
+ "aria-label": `Generate ${title} shades`,
6442
+ children: [
6443
+ /* @__PURE__ */ jsxs("div", {
6444
+ className: "studio-shades-row",
6445
+ children: [
6446
+ /* @__PURE__ */ jsx("label", {
6447
+ className: "studio-shades-label",
6448
+ htmlFor: `shades-${title}`,
6449
+ children: "Base"
6450
+ }),
6451
+ /* @__PURE__ */ jsxs("span", {
6452
+ className: "studio-shades-field",
6453
+ children: [
6454
+ /* @__PURE__ */ jsx("input", {
6455
+ type: "color",
6456
+ "aria-label": "Pick base color",
6457
+ value: shownBase ? toHex(shownBase) : "#000000",
6458
+ onChange: (event) => {
6459
+ enterBase(event.target.value.slice(1).toUpperCase());
6460
+ setDraftText(null);
6461
+ }
6462
+ }),
6463
+ /* @__PURE__ */ jsx("span", {
6464
+ "aria-hidden": "true",
6465
+ children: "#"
6466
+ }),
6467
+ /* @__PURE__ */ jsx("input", {
6468
+ id: `shades-${title}`,
6469
+ value: fieldText,
6470
+ "aria-invalid": invalid,
6471
+ spellCheck: false,
6472
+ onFocus: () => setDraftText(fieldText),
6473
+ onBlur: () => setDraftText(null),
6474
+ onChange: (event_0) => enterBase(event_0.target.value.replace(/^#/, ""))
6475
+ })
6476
+ ]
6477
+ }),
6478
+ /* @__PURE__ */ jsx("button", {
6479
+ type: "button",
6480
+ className: "studio-primary studio-shades-apply",
6481
+ disabled: !pending,
6482
+ onClick: () => {
6483
+ if (shades && base) apply(shades, base);
6484
+ },
6485
+ children: "Change shades"
6486
+ })
6487
+ ]
6488
+ }),
6489
+ invalid && /* @__PURE__ */ jsx("p", {
6490
+ className: "studio-error",
6491
+ children: "Enter a hex color such as #75ACFF."
6492
+ }),
6493
+ /* @__PURE__ */ jsxs("div", {
6494
+ className: "studio-shades-bar",
6495
+ children: [/* @__PURE__ */ jsxs("button", {
6496
+ type: "button",
6497
+ className: "studio-shades-advanced-toggle",
6498
+ "aria-expanded": advanced,
6499
+ "aria-controls": panelId,
6500
+ onClick: () => setAdvanced((value_1) => !value_1),
6501
+ children: [
6502
+ /* @__PURE__ */ jsx(ChevronRight, {
6503
+ size: 12,
6504
+ "aria-hidden": "true"
6505
+ }),
6506
+ "Advanced palette controls",
6507
+ curve && /* @__PURE__ */ jsx("span", {
6508
+ className: "studio-group-changed",
6509
+ "aria-label": "in use"
6510
+ })
6511
+ ]
6512
+ }), curve && /* @__PURE__ */ jsxs("button", {
6513
+ type: "button",
6514
+ className: "studio-shades-reset",
6515
+ "aria-label": "Back to standard shades",
6516
+ title: "Back to standard shades",
6517
+ onClick: resetCurve,
6518
+ children: [/* @__PURE__ */ jsx(RotateCcw, {
6519
+ size: 12,
6520
+ "aria-hidden": "true"
6521
+ }), "Reset"]
6522
+ })]
6523
+ }),
6524
+ advanced && /* @__PURE__ */ jsxs("div", {
6525
+ id: panelId,
6526
+ className: "studio-shades-advanced",
6527
+ children: [
6528
+ curveShades && /* @__PURE__ */ jsx(CurveEditor, {
6529
+ curve: active,
6530
+ steps: numbers,
6531
+ shades: curveShades,
6532
+ baseLightness,
6533
+ disabled: !base,
6534
+ onChange: updateCurve
6535
+ }),
6536
+ /* @__PURE__ */ jsx("p", {
6537
+ className: "studio-shades-hint",
6538
+ children: curve ? "Drag the ends, their handles or any shade · double-click a moved shade to release it" : "Standard shades in use · drag the curve or a shade to switch to it"
6539
+ }),
6540
+ /* @__PURE__ */ jsx("div", {
6541
+ className: "studio-slider-fields",
6542
+ children: colorRows.map(({ field, label, min, max, step: step_1, unit }) => /* @__PURE__ */ jsx(SliderField, {
6543
+ label,
6544
+ value: active[field],
6545
+ min,
6546
+ max,
6547
+ step: step_1,
6548
+ display: `${active[field]}${unit}`,
6549
+ disabled: !base,
6550
+ onChange: (value_2) => updateCurve({
6551
+ ...active,
6552
+ [field]: value_2
6553
+ })
6554
+ }, field))
6555
+ })
6556
+ ]
6557
+ })
6558
+ ]
6559
+ });
6066
6560
  }
6067
6561
  //#endregion
6068
6562
  //#region src/configurator/ComponentPreview.tsx
6069
- const ComponentGallery = lazy(() => import("./ComponentGallery-CzKU899_.js"));
6563
+ const ComponentGallery = lazy(() => import("./ComponentGallery-C_rXFvUY.js").then((n) => n.n));
6070
6564
  /** Every component, styled by a configuration; the configurator's preview and the App Canvas Components view. */
6071
6565
  function ComponentPreview(t0) {
6072
6566
  const $ = c(14);
@@ -6213,6 +6707,7 @@ function ThemeVersionControls(t0) {
6213
6707
  if ($[12] !== themes.versions) {
6214
6708
  t5 = /* @__PURE__ */ jsx($542a13ca2fa5b484$export$5b6b19405a83ff9d, {
6215
6709
  className: "studio-version-popover",
6710
+ "data-povio-inspector-ignore": "",
6216
6711
  placement: "bottom start",
6217
6712
  children: /* @__PURE__ */ jsx($928221da08ecbc62$export$41f133550aa26f48, {
6218
6713
  className: "studio-version-list",
@@ -6469,6 +6964,7 @@ function ThemeVersionControls(t0) {
6469
6964
  if ($[73] !== t14 || $[74] !== t15 || $[75] !== t31) {
6470
6965
  t32 = /* @__PURE__ */ jsx($542a13ca2fa5b484$export$5b6b19405a83ff9d, {
6471
6966
  triggerRef: t14,
6967
+ "data-povio-inspector-ignore": "",
6472
6968
  placement: "bottom start",
6473
6969
  offset: 6,
6474
6970
  className: "studio-version-popover studio-version-dialog",
@@ -6977,7 +7473,7 @@ function PopoutOverlay(t0) {
6977
7473
  } else t3 = $[5];
6978
7474
  return t3;
6979
7475
  }
6980
- function ConfigurationModalContent({ memory, windowBounds, poppedOut, floating, onPopout, onDock, popupBlocked, themeVersions }) {
7476
+ function ConfigurationModalContent({ memory, windowBounds, poppedOut, floating, onPopout, onDock, popupBlocked, themeVersions, editorOnly }) {
6981
7477
  const Overlay = poppedOut || floating ? PopoutOverlay : $8b8d26808cb8cb53$export$8948f78d83984c69;
6982
7478
  const Surface = poppedOut || floating ? "div" : $8b8d26808cb8cb53$export$2b77a92f1a5ad772;
6983
7479
  const studioWindow = useStudioWindow(windowBounds, !poppedOut);
@@ -6992,7 +7488,7 @@ function ConfigurationModalContent({ memory, windowBounds, poppedOut, floating,
6992
7488
  return () => observer.disconnect();
6993
7489
  }, [studioWindow.ref]);
6994
7490
  const inherited = UIConfig.useConfig();
6995
- const { defaults, draft, setDraft, isOpen, apply, revision, tokenRequest, clearTokenRequest, componentsHosted } = useUIConfiguration();
7491
+ const { defaults, draft, setDraft, isOpen, apply, revision, tokenRequest, clearTokenRequest } = useUIConfiguration();
6996
7492
  const remembered = memory.current;
6997
7493
  const [mode, setMode] = useState(remembered.mode ?? "light");
6998
7494
  const [sizeUnit, setSizeUnit] = useState(remembered.sizeUnit ?? "px");
@@ -7280,7 +7776,7 @@ function ConfigurationModalContent({ memory, windowBounds, poppedOut, floating,
7280
7776
  onApply: (values) => {
7281
7777
  for (const [name_16, value_7] of Object.entries(values)) setToken(name_16, value_7);
7282
7778
  }
7283
- }, base);
7779
+ }, title);
7284
7780
  };
7285
7781
  const tokenGroups = [...groupedEntries.entries()].filter(([key_2, group_0]) => `${key_2} ${group_0.title} ${group_0.entries.map(([name_17]) => `${name_17} ${labelFor(name_17)}`).join(" ")}`.toLowerCase().includes(search.toLowerCase().trim()));
7286
7782
  const visibleGroups = section === "Typography" ? tokenGroups : tokenGroups.map(([key_3, group_1]) => [key_3, {
@@ -7471,10 +7967,10 @@ function ConfigurationModalContent({ memory, windowBounds, poppedOut, floating,
7471
7967
  children: /* @__PURE__ */ jsx(Surface, {
7472
7968
  className: `studio-modal${poppedOut ? " studio-modal-popout" : ""}`,
7473
7969
  ref: studioWindow.ref,
7474
- "data-components-hosted": componentsHosted || void 0,
7970
+ "data-editor-only": editorOnly || void 0,
7475
7971
  children: /* @__PURE__ */ jsxs($f2ff30fde7b014be$export$3ddf2d174ce01153, {
7476
7972
  className: "studio-dialog",
7477
- "data-compact-preview": compactPreview && !componentsHosted || void 0,
7973
+ "data-compact-preview": compactPreview && !editorOnly || void 0,
7478
7974
  style: { "--studio-editor-track": editorWidth ? `minmax(260px, ${editorWidth}px)` : void 0 },
7479
7975
  children: [
7480
7976
  /* @__PURE__ */ jsxs("header", {
@@ -7510,7 +8006,7 @@ function ConfigurationModalContent({ memory, windowBounds, poppedOut, floating,
7510
8006
  })
7511
8007
  ]
7512
8008
  }),
7513
- !componentsHosted && /* @__PURE__ */ jsx("button", {
8009
+ !editorOnly && /* @__PURE__ */ jsx("button", {
7514
8010
  type: "button",
7515
8011
  className: "studio-preview-tab",
7516
8012
  "aria-current": compactPreview ? "page" : void 0,
@@ -7578,25 +8074,37 @@ function ConfigurationModalContent({ memory, windowBounds, poppedOut, floating,
7578
8074
  }), toggleAllButton]
7579
8075
  }) : showTabs ? /* @__PURE__ */ jsxs("div", {
7580
8076
  className: "studio-subtabs-bar",
7581
- children: [/* @__PURE__ */ jsx("div", {
7582
- className: "studio-subtabs",
7583
- role: "tablist",
7584
- "aria-label": `${section} tokens`,
7585
- children: sectionTabList.map((tab_0) => /* @__PURE__ */ jsxs("button", {
8077
+ children: [
8078
+ /* @__PURE__ */ jsx("div", {
8079
+ className: "studio-subtabs",
8080
+ role: "tablist",
8081
+ "aria-label": `${section} tokens`,
8082
+ children: sectionTabList.map((tab_0) => /* @__PURE__ */ jsxs("button", {
8083
+ type: "button",
8084
+ role: "tab",
8085
+ "aria-selected": !searching && tab_0 === activeSectionTab,
8086
+ disabled: searching,
8087
+ onClick: () => setSectionTabs((current_13) => ({
8088
+ ...current_13,
8089
+ [section]: tab_0
8090
+ })),
8091
+ children: [tab_0, groupChanged([...groupedEntries].filter(([key_14]) => tabFor(key_14) === tab_0).flatMap(([, group_6]) => group_6.entries)) && /* @__PURE__ */ jsx("span", {
8092
+ className: "studio-group-changed",
8093
+ "aria-label": "has changes"
8094
+ })]
8095
+ }, tab_0))
8096
+ }),
8097
+ section === "Colors" && !searching && activeSectionTab === semanticPaletteTab && /* @__PURE__ */ jsx("button", {
7586
8098
  type: "button",
7587
- role: "tab",
7588
- "aria-selected": !searching && tab_0 === activeSectionTab,
7589
- disabled: searching,
7590
- onClick: () => setSectionTabs((current_13) => ({
7591
- ...current_13,
7592
- [section]: tab_0
7593
- })),
7594
- children: [tab_0, groupChanged([...groupedEntries].filter(([key_14]) => tabFor(key_14) === tab_0).flatMap(([, group_6]) => group_6.entries)) && /* @__PURE__ */ jsx("span", {
7595
- className: "studio-group-changed",
7596
- "aria-label": "has changes"
7597
- })]
7598
- }, tab_0))
7599
- }), toggleAllButton]
8099
+ className: "studio-theme-toggle",
8100
+ onClick: () => setMode(mode === "dark" ? "light" : "dark"),
8101
+ "aria-pressed": mode === "dark",
8102
+ "aria-label": mode === "dark" ? "Dark" : "Light",
8103
+ title: "Toggle semantic palette mode",
8104
+ children: mode === "dark" ? /* @__PURE__ */ jsx(Moon, { size: 14 }) : /* @__PURE__ */ jsx(Sun, { size: 14 })
8105
+ }),
8106
+ toggleAllButton
8107
+ ]
7600
8108
  }) : advancedSection ? /* @__PURE__ */ jsx("div", {
7601
8109
  className: "studio-subtabs-bar",
7602
8110
  children: /* @__PURE__ */ jsx("div", {
@@ -7873,7 +8381,7 @@ function ConfigurationModalContent({ memory, windowBounds, poppedOut, floating,
7873
8381
  ]
7874
8382
  })
7875
8383
  ]
7876
- }), !componentsHosted && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("aside", {
8384
+ }), !editorOnly && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("aside", {
7877
8385
  ref: previewRef,
7878
8386
  className: "studio-preview",
7879
8387
  onScroll: (event_6) => memory.current.previewScroll = event_6.currentTarget.scrollTop,
@@ -8067,23 +8575,24 @@ function ConfigurationModalContent({ memory, windowBounds, poppedOut, floating,
8067
8575
  })
8068
8576
  });
8069
8577
  }
8070
- /** Where a floating configurator first opens; an editor-only window (components shown by the host) is narrower. */
8578
+ /** Where a floating configurator first opens; an editor-only window is narrower. */
8071
8579
  const floatingDefault = {
8072
8580
  left: 32,
8073
8581
  top: 80,
8074
8582
  width: 640,
8075
8583
  height: 720
8076
8584
  };
8077
- const hostedFloatingWidth = 360;
8078
- function UIConfigurationModal() {
8585
+ const editorOnlyFloatingWidth = 360;
8586
+ function UIConfigurationModal({ editorOnly: editorOnlyProp = false } = {}) {
8079
8587
  const { isOpen, revision, floating, componentsHosted } = useUIConfiguration();
8588
+ const editorOnly = editorOnlyProp || componentsHosted;
8080
8589
  const themeVersions = useThemeVersions();
8081
8590
  const memory = useRef({});
8082
8591
  const windowBounds = useRef(null);
8083
8592
  const floatingBounds = useRef(floatingDefault);
8084
- if (componentsHosted && floatingBounds.current === floatingDefault) floatingBounds.current = {
8593
+ if (editorOnly && floatingBounds.current === floatingDefault) floatingBounds.current = {
8085
8594
  ...floatingDefault,
8086
- width: hostedFloatingWidth
8595
+ width: editorOnlyFloatingWidth
8087
8596
  };
8088
8597
  const popout = useStudioPopout(isOpen);
8089
8598
  if (!isOpen) return null;
@@ -8095,7 +8604,8 @@ function UIConfigurationModal() {
8095
8604
  onPopout: popout.open,
8096
8605
  onDock: popout.dock,
8097
8606
  popupBlocked: popout.blocked,
8098
- themeVersions
8607
+ themeVersions,
8608
+ editorOnly
8099
8609
  }, revision);
8100
8610
  return popout.popup ? createPortal(/* @__PURE__ */ jsx(StudioPopoutContext, {
8101
8611
  value: true,
@@ -8106,4 +8616,450 @@ function UIConfigurationModal() {
8106
8616
  }), popout.popup.document.body) : floating ? createPortal(content, document.body) : content;
8107
8617
  }
8108
8618
  //#endregion
8109
- export { Moon as _, inspectElement as a, HighlightOverlay as c, useUIConfiguration as d, Trash as f, Pencil as g, Pin as h, resolveUIConfiguration as i, InspectorDetails as l, Plus as m, ColorModeSwitch as n, inspectTokens as o, Sun as p, useRepositoryStorage as r, getBoxHighlights as s, UIConfigurationModal as t, UIConfigurationProvider as u };
8619
+ //#region src/app-canvas/CanvasInspector.tsx
8620
+ /** Inspect the live iframe DOM using its own, unscaled viewport coordinates. */
8621
+ function useCanvasInspector(enabled, generation, isKnown) {
8622
+ const [selection, setSelection] = useState(null);
8623
+ const [measurement, setMeasurement] = useState(null);
8624
+ const [pinned, setPinned] = useState(false);
8625
+ const [highlightKey, setHighlightKey] = useState(null);
8626
+ const hoverFrame = useRef(null);
8627
+ const pending = useRef(null);
8628
+ const clear = useCallback(() => {
8629
+ if (hoverFrame.current !== null) cancelAnimationFrame(hoverFrame.current);
8630
+ hoverFrame.current = null;
8631
+ pending.current = null;
8632
+ setSelection(null);
8633
+ setMeasurement(null);
8634
+ setPinned(false);
8635
+ setHighlightKey(null);
8636
+ }, []);
8637
+ useEffect(() => {
8638
+ if (!enabled) clear();
8639
+ }, [enabled, clear]);
8640
+ useEffect(() => {
8641
+ clear();
8642
+ }, [generation, clear]);
8643
+ useEffect(() => () => {
8644
+ if (hoverFrame.current !== null) cancelAnimationFrame(hoverFrame.current);
8645
+ }, []);
8646
+ /** Picks the element at a point in `doc`'s own viewport: an iframe's document, or the page itself. */
8647
+ const pickInDocument = useCallback((pageId, doc, x, y, pin) => {
8648
+ if (!enabled || pinned && !pin) return;
8649
+ try {
8650
+ const hit = doc.elementFromPoint(x, y);
8651
+ const element = hit?.closest("button,input,textarea,select,a,label,[role],h1,h2,h3,h4,h5,h6,p") ?? hit;
8652
+ if (!element || element === doc.documentElement || element === doc.body || element.namespaceURI !== "http://www.w3.org/1999/xhtml") return;
8653
+ const target = element;
8654
+ setSelection((current) => current?.element === target ? current : {
8655
+ pageId,
8656
+ element: target
8657
+ });
8658
+ setHighlightKey(null);
8659
+ if (pin) setPinned((current_0) => !(current_0 && selection?.element === target));
8660
+ } catch {
8661
+ clear();
8662
+ }
8663
+ }, [
8664
+ enabled,
8665
+ pinned,
8666
+ selection,
8667
+ clear
8668
+ ]);
8669
+ const pick = useCallback((pageId_0, frame, clientX, clientY, pin_0) => {
8670
+ const bounds = frame.getBoundingClientRect();
8671
+ if (!bounds.width || !bounds.height) return;
8672
+ try {
8673
+ const doc_0 = frame.contentDocument;
8674
+ if (!doc_0) return;
8675
+ const x_0 = (clientX - bounds.left) * frame.clientWidth / bounds.width;
8676
+ const y_0 = (clientY - bounds.top) * frame.clientHeight / bounds.height;
8677
+ pickInDocument(pageId_0, doc_0, x_0, y_0, pin_0);
8678
+ } catch {
8679
+ clear();
8680
+ }
8681
+ }, [pickInDocument, clear]);
8682
+ const hover = useCallback((pageId_1, frame_0, x_1, y_1) => {
8683
+ if (!enabled || pinned) return;
8684
+ pending.current = () => pick(pageId_1, frame_0, x_1, y_1, false);
8685
+ if (hoverFrame.current !== null) return;
8686
+ hoverFrame.current = requestAnimationFrame(() => {
8687
+ hoverFrame.current = null;
8688
+ pending.current?.();
8689
+ pending.current = null;
8690
+ });
8691
+ }, [
8692
+ enabled,
8693
+ pinned,
8694
+ pick
8695
+ ]);
8696
+ const select = useCallback((pageId_2, frame_1, x_2, y_2) => {
8697
+ if (hoverFrame.current !== null) cancelAnimationFrame(hoverFrame.current);
8698
+ hoverFrame.current = null;
8699
+ pending.current = null;
8700
+ pick(pageId_2, frame_1, x_2, y_2, true);
8701
+ }, [pick]);
8702
+ useEffect(() => {
8703
+ if (!enabled || !selection) return;
8704
+ const { element: element_0 } = selection;
8705
+ const doc_1 = element_0.ownerDocument;
8706
+ const owner = doc_1.defaultView;
8707
+ if (!owner) return;
8708
+ let scheduled = null;
8709
+ const measure = () => {
8710
+ scheduled = null;
8711
+ if (!element_0.isConnected) {
8712
+ clear();
8713
+ return;
8714
+ }
8715
+ const rect = element_0.getBoundingClientRect();
8716
+ const snapshot = inspectElement(element_0, isKnown);
8717
+ const details = highlightKey ? getBoxHighlights(element_0, highlightKey) : null;
8718
+ const spacing = highlightKey ? [] : [
8719
+ "padding.top",
8720
+ "padding.right",
8721
+ "padding.bottom",
8722
+ "padding.left",
8723
+ "margin.top",
8724
+ "margin.right",
8725
+ "margin.bottom",
8726
+ "margin.left",
8727
+ "gap.row",
8728
+ "gap.column"
8729
+ ].flatMap((key) => {
8730
+ const [kind, side] = key.split(".");
8731
+ const raw = kind === "padding" ? snapshot.box.padding[side] : kind === "margin" ? snapshot.box.margin[side] : snapshot.box.gap[side];
8732
+ if (!(Math.abs(Number.parseFloat(raw)) > 0)) return [];
8733
+ const details_0 = getBoxHighlights(element_0, key);
8734
+ const regions = details_0.regions.filter((region) => region.width > 0 && region.height > 0);
8735
+ return regions.length ? [{
8736
+ key,
8737
+ label: details_0.label,
8738
+ regions
8739
+ }] : [];
8740
+ });
8741
+ if (!highlightKey) {
8742
+ const seen = new Set(spacing.flatMap((item) => item.regions.map((region_0) => `${item.key}:${region_0.left}:${region_0.top}:${region_0.width}:${region_0.height}`)));
8743
+ for (const child of Array.from(element_0.children).slice(0, 80)) {
8744
+ if (child.namespaceURI !== "http://www.w3.org/1999/xhtml" || !child.getClientRects().length) continue;
8745
+ const style = owner.getComputedStyle(child);
8746
+ if (style.display === "none" || style.visibility === "hidden" || /^(absolute|fixed)$/.test(style.position)) continue;
8747
+ for (const side_0 of [
8748
+ "top",
8749
+ "right",
8750
+ "bottom",
8751
+ "left"
8752
+ ]) {
8753
+ if (!(Math.abs(Number.parseFloat(style.getPropertyValue(`margin-${side_0}`))) > 0)) continue;
8754
+ const key_0 = `margin.${side_0}`;
8755
+ const details_1 = getBoxHighlights(child, key_0);
8756
+ const regions_0 = details_1.regions.filter((region_1) => {
8757
+ const id = `${key_0}:${region_1.left}:${region_1.top}:${region_1.width}:${region_1.height}`;
8758
+ if (seen.has(id)) return false;
8759
+ seen.add(id);
8760
+ return region_1.width > 0 && region_1.height > 0;
8761
+ });
8762
+ if (regions_0.length) spacing.push({
8763
+ key: key_0,
8764
+ label: details_1.label,
8765
+ regions: regions_0
8766
+ });
8767
+ }
8768
+ }
8769
+ }
8770
+ const next = {
8771
+ snapshot,
8772
+ spacing,
8773
+ outline: {
8774
+ left: rect.left,
8775
+ top: rect.top,
8776
+ width: rect.width,
8777
+ height: rect.height
8778
+ },
8779
+ highlight: details && highlightKey ? {
8780
+ key: highlightKey,
8781
+ ...details
8782
+ } : null
8783
+ };
8784
+ setMeasurement((current_1) => JSON.stringify(current_1) === JSON.stringify(next) ? current_1 : next);
8785
+ };
8786
+ const schedule = () => {
8787
+ if (scheduled === null) scheduled = requestAnimationFrame(measure);
8788
+ };
8789
+ const mutations = new MutationObserver(schedule);
8790
+ mutations.observe(doc_1.documentElement, {
8791
+ subtree: true,
8792
+ childList: true,
8793
+ attributes: true,
8794
+ characterData: true
8795
+ });
8796
+ const resize = new ResizeObserver(schedule);
8797
+ resize.observe(element_0);
8798
+ owner.addEventListener("scroll", schedule, true);
8799
+ measure();
8800
+ return () => {
8801
+ mutations.disconnect();
8802
+ resize.disconnect();
8803
+ owner.removeEventListener("scroll", schedule, true);
8804
+ if (scheduled !== null) cancelAnimationFrame(scheduled);
8805
+ };
8806
+ }, [
8807
+ enabled,
8808
+ selection,
8809
+ highlightKey,
8810
+ clear,
8811
+ isKnown
8812
+ ]);
8813
+ return {
8814
+ selection,
8815
+ hoverPoint: useCallback((doc_2, x_3, y_3) => {
8816
+ if (!enabled || pinned) return;
8817
+ pending.current = () => pickInDocument("page", doc_2, x_3, y_3, false);
8818
+ if (hoverFrame.current !== null) return;
8819
+ hoverFrame.current = requestAnimationFrame(() => {
8820
+ hoverFrame.current = null;
8821
+ pending.current?.();
8822
+ pending.current = null;
8823
+ });
8824
+ }, [
8825
+ enabled,
8826
+ pinned,
8827
+ pickInDocument
8828
+ ]),
8829
+ selectPoint: useCallback((doc_3, x_4, y_4) => {
8830
+ if (hoverFrame.current !== null) cancelAnimationFrame(hoverFrame.current);
8831
+ hoverFrame.current = null;
8832
+ pending.current = null;
8833
+ pickInDocument("page", doc_3, x_4, y_4, true);
8834
+ }, [pickInDocument]),
8835
+ selectElement: (pageId_3, element_1) => {
8836
+ setSelection({
8837
+ pageId: pageId_3,
8838
+ element: element_1
8839
+ });
8840
+ setPinned(true);
8841
+ setHighlightKey(null);
8842
+ },
8843
+ measurement,
8844
+ pinned,
8845
+ hover,
8846
+ select,
8847
+ clear,
8848
+ highlight: setHighlightKey,
8849
+ togglePin: () => setPinned((value) => !value)
8850
+ };
8851
+ }
8852
+ function CanvasInspectorPanel(t0) {
8853
+ const $ = c(24);
8854
+ const { inspector, onClose, onSelectToken, className: t1, emptyHint: t2 } = t0;
8855
+ const className = t1 === void 0 ? "povio-canvas-inspector" : t1;
8856
+ const emptyHint = t2 === void 0 ? "Inspect a live page to see its padding, margins, borders, radii and gaps." : t2;
8857
+ const t3 = `studio-inspector-panel ${className}`;
8858
+ let t4;
8859
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
8860
+ t4 = /* @__PURE__ */ jsx("strong", { children: "Inspector view" });
8861
+ $[0] = t4;
8862
+ } else t4 = $[0];
8863
+ const t5 = !inspector.selection;
8864
+ let t6;
8865
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
8866
+ t6 = /* @__PURE__ */ jsx(Pin, { size: 14 });
8867
+ $[1] = t6;
8868
+ } else t6 = $[1];
8869
+ let t7;
8870
+ if ($[2] !== inspector.pinned || $[3] !== inspector.togglePin || $[4] !== t5) {
8871
+ t7 = /* @__PURE__ */ jsx("button", {
8872
+ "aria-label": "Pin inspected element",
8873
+ "aria-pressed": inspector.pinned,
8874
+ disabled: t5,
8875
+ onClick: inspector.togglePin,
8876
+ children: t6
8877
+ });
8878
+ $[2] = inspector.pinned;
8879
+ $[3] = inspector.togglePin;
8880
+ $[4] = t5;
8881
+ $[5] = t7;
8882
+ } else t7 = $[5];
8883
+ let t8;
8884
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
8885
+ t8 = /* @__PURE__ */ jsx(X, { size: 15 });
8886
+ $[6] = t8;
8887
+ } else t8 = $[6];
8888
+ let t9;
8889
+ if ($[7] !== onClose) {
8890
+ t9 = /* @__PURE__ */ jsx("button", {
8891
+ "aria-label": "Close inspector view",
8892
+ onClick: onClose,
8893
+ children: t8
8894
+ });
8895
+ $[7] = onClose;
8896
+ $[8] = t9;
8897
+ } else t9 = $[8];
8898
+ let t10;
8899
+ if ($[9] !== t7 || $[10] !== t9) {
8900
+ t10 = /* @__PURE__ */ jsxs("header", { children: [
8901
+ t4,
8902
+ t7,
8903
+ t9
8904
+ ] });
8905
+ $[9] = t7;
8906
+ $[10] = t9;
8907
+ $[11] = t10;
8908
+ } else t10 = $[11];
8909
+ const t11 = inspector.pinned ? "Selection pinned · click it again to unpin" : "Hover a component · click to pin";
8910
+ let t12;
8911
+ if ($[12] !== t11) {
8912
+ t12 = /* @__PURE__ */ jsx("p", {
8913
+ className: "povio-canvas-inspect-hint",
8914
+ children: t11
8915
+ });
8916
+ $[12] = t11;
8917
+ $[13] = t12;
8918
+ } else t12 = $[13];
8919
+ let t13;
8920
+ if ($[14] !== emptyHint || $[15] !== inspector.highlight || $[16] !== inspector.measurement || $[17] !== onSelectToken) {
8921
+ t13 = inspector.measurement ? /* @__PURE__ */ jsx(InspectorDetails, {
8922
+ snapshot: inspector.measurement.snapshot,
8923
+ onSelect: onSelectToken,
8924
+ onHighlight: inspector.highlight
8925
+ }) : /* @__PURE__ */ jsx("p", {
8926
+ className: "povio-canvas-inspect-hint",
8927
+ children: emptyHint
8928
+ });
8929
+ $[14] = emptyHint;
8930
+ $[15] = inspector.highlight;
8931
+ $[16] = inspector.measurement;
8932
+ $[17] = onSelectToken;
8933
+ $[18] = t13;
8934
+ } else t13 = $[18];
8935
+ let t14;
8936
+ if ($[19] !== t10 || $[20] !== t12 || $[21] !== t13 || $[22] !== t3) {
8937
+ t14 = /* @__PURE__ */ jsxs("aside", {
8938
+ className: t3,
8939
+ "data-povio-inspector-ignore": "",
8940
+ "aria-label": "Inspector view",
8941
+ children: [
8942
+ t10,
8943
+ t12,
8944
+ t13
8945
+ ]
8946
+ });
8947
+ $[19] = t10;
8948
+ $[20] = t12;
8949
+ $[21] = t13;
8950
+ $[22] = t3;
8951
+ $[23] = t14;
8952
+ } else t14 = $[23];
8953
+ return t14;
8954
+ }
8955
+ function CanvasInspectionOverlay(t0) {
8956
+ const $ = c(10);
8957
+ const { measurement, width, className: t1 } = t0;
8958
+ const className = t1 === void 0 ? "povio-canvas-inspection-overlay" : t1;
8959
+ let t2;
8960
+ if ($[0] !== measurement.outline) {
8961
+ t2 = /* @__PURE__ */ jsx("div", {
8962
+ className: "studio-hover-outline",
8963
+ style: measurement.outline
8964
+ });
8965
+ $[0] = measurement.outline;
8966
+ $[1] = t2;
8967
+ } else t2 = $[1];
8968
+ let t3;
8969
+ if ($[2] !== measurement.highlight || $[3] !== measurement.spacing || $[4] !== width) {
8970
+ t3 = measurement.highlight ? /* @__PURE__ */ jsx(HighlightOverlay, {
8971
+ highlight: measurement.highlight,
8972
+ width
8973
+ }) : measurement.spacing.map((highlight) => /* @__PURE__ */ jsxs("div", {
8974
+ className: "povio-canvas-auto-spacing",
8975
+ children: [/* @__PURE__ */ jsx(HighlightOverlay, {
8976
+ highlight,
8977
+ width
8978
+ }), highlight.regions.map((region) => /* @__PURE__ */ jsx("span", {
8979
+ className: "povio-canvas-spacing-value",
8980
+ style: {
8981
+ left: region.left + region.width / 2,
8982
+ top: region.top + region.height / 2
8983
+ },
8984
+ children: highlight.label.split(": ")[1]
8985
+ }, `${region.left}:${region.top}:${region.width}:${region.height}`))]
8986
+ }, `${highlight.key}:${highlight.label}:${highlight.regions[0]?.left}:${highlight.regions[0]?.top}`));
8987
+ $[2] = measurement.highlight;
8988
+ $[3] = measurement.spacing;
8989
+ $[4] = width;
8990
+ $[5] = t3;
8991
+ } else t3 = $[5];
8992
+ let t4;
8993
+ if ($[6] !== className || $[7] !== t2 || $[8] !== t3) {
8994
+ t4 = /* @__PURE__ */ jsxs("div", {
8995
+ className,
8996
+ "aria-hidden": "true",
8997
+ children: [t2, t3]
8998
+ });
8999
+ $[6] = className;
9000
+ $[7] = t2;
9001
+ $[8] = t3;
9002
+ $[9] = t4;
9003
+ } else t4 = $[9];
9004
+ return t4;
9005
+ }
9006
+ /** Temporary layer hover never replaces the pinned inspector selection. */
9007
+ function CanvasLayerHighlight(t0) {
9008
+ const $ = c(5);
9009
+ const { element } = t0;
9010
+ const [bounds, setBounds] = useState(null);
9011
+ let t1;
9012
+ let t2;
9013
+ if ($[0] !== element) {
9014
+ t1 = () => {
9015
+ const owner = element.ownerDocument.defaultView;
9016
+ const measure = () => {
9017
+ if (!element.isConnected) {
9018
+ setBounds(null);
9019
+ return;
9020
+ }
9021
+ const rect = element.getBoundingClientRect();
9022
+ setBounds({
9023
+ left: rect.left,
9024
+ top: rect.top,
9025
+ width: rect.width,
9026
+ height: rect.height
9027
+ });
9028
+ };
9029
+ measure();
9030
+ const observer = new ResizeObserver(measure);
9031
+ observer.observe(element);
9032
+ owner?.addEventListener("scroll", measure, true);
9033
+ owner?.addEventListener("resize", measure);
9034
+ return () => {
9035
+ observer.disconnect();
9036
+ owner?.removeEventListener("scroll", measure, true);
9037
+ owner?.removeEventListener("resize", measure);
9038
+ };
9039
+ };
9040
+ t2 = [element];
9041
+ $[0] = element;
9042
+ $[1] = t1;
9043
+ $[2] = t2;
9044
+ } else {
9045
+ t1 = $[1];
9046
+ t2 = $[2];
9047
+ }
9048
+ useLayoutEffect(t1, t2);
9049
+ let t3;
9050
+ if ($[3] !== bounds) {
9051
+ t3 = bounds ? /* @__PURE__ */ jsx("div", {
9052
+ className: "povio-canvas-inspection-overlay povio-canvas-layer-highlight",
9053
+ "aria-hidden": "true",
9054
+ children: /* @__PURE__ */ jsx("div", {
9055
+ className: "studio-hover-outline",
9056
+ style: bounds
9057
+ })
9058
+ }) : null;
9059
+ $[3] = bounds;
9060
+ $[4] = t3;
9061
+ } else t3 = $[4];
9062
+ return t3;
9063
+ }
9064
+ //#endregion
9065
+ export { Moon as _, UIConfigurationModal as a, resolveUIConfiguration as c, Trash as d, Sun as f, Pencil as g, Plus as h, useCanvasInspector as i, UIConfigurationProvider as l, ScanLine as m, CanvasInspectorPanel as n, ColorModeSwitch as o, Settings2 as p, CanvasLayerHighlight as r, useRepositoryStorage as s, CanvasInspectionOverlay as t, useUIConfiguration as u, Frame as v };