@pixerate/editor-react 0.94.0 → 0.96.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +3 -1
  2. package/dist/animation-editor/index.cjs +1240 -195
  3. package/dist/animation-editor/index.js +4 -2
  4. package/dist/canvas/index.cjs +1419 -372
  5. package/dist/canvas/index.js +9 -4
  6. package/dist/canvas/useMermaidDiagram.d.cts +7 -1
  7. package/dist/canvas/useMermaidDiagram.d.ts +7 -1
  8. package/dist/chunk-3I7FOSLF.js +988 -0
  9. package/dist/{chunk-OTGJEYHV.js → chunk-5LFQ2UQZ.js} +75 -68
  10. package/dist/{chunk-5R67YSSD.js → chunk-GLSOQNQR.js} +1 -1
  11. package/dist/{chunk-6YRSQW2V.js → chunk-IY6YOY5B.js} +1 -1
  12. package/dist/chunk-KIRIU53A.js +72 -0
  13. package/dist/{chunk-NNM633RN.js → chunk-R7MEGRPV.js} +23 -0
  14. package/dist/color/ColorPicker.d.cts +30 -0
  15. package/dist/color/ColorPicker.d.ts +30 -0
  16. package/dist/color/DualColorPicker.d.cts +29 -0
  17. package/dist/color/DualColorPicker.d.ts +29 -0
  18. package/dist/color/index.cjs +1067 -0
  19. package/dist/color/index.d.cts +7 -0
  20. package/dist/color/index.d.ts +7 -0
  21. package/dist/color/index.js +14 -0
  22. package/dist/color/useColorScheme.d.cts +16 -0
  23. package/dist/color/useColorScheme.d.ts +16 -0
  24. package/dist/effects/index.cjs +1169 -124
  25. package/dist/effects/index.js +4 -2
  26. package/dist/gradient/FillPicker.d.cts +27 -0
  27. package/dist/gradient/FillPicker.d.ts +27 -0
  28. package/dist/gradient/GradientEditor.d.cts +21 -0
  29. package/dist/gradient/GradientEditor.d.ts +21 -0
  30. package/dist/gradient/index.cjs +1601 -0
  31. package/dist/gradient/index.d.cts +6 -0
  32. package/dist/gradient/index.d.ts +6 -0
  33. package/dist/gradient/index.js +617 -0
  34. package/dist/gradient/useGradientController.d.cts +10 -0
  35. package/dist/gradient/useGradientController.d.ts +10 -0
  36. package/dist/image-editor/index.cjs +1742 -697
  37. package/dist/image-editor/index.js +5 -3
  38. package/dist/index.cjs +2181 -1115
  39. package/dist/index.js +9 -5
  40. package/dist/paint-editor/index.cjs +1233 -188
  41. package/dist/paint-editor/index.js +4 -2
  42. package/dist/parameters/fields.d.cts +1 -1
  43. package/dist/parameters/fields.d.ts +1 -1
  44. package/dist/parameters/index.cjs +1218 -173
  45. package/dist/parameters/index.js +3 -1
  46. package/dist/persistence/index.cjs +25 -4
  47. package/dist/persistence/index.d.cts +1 -0
  48. package/dist/persistence/index.d.ts +1 -0
  49. package/dist/persistence/index.js +5 -3
  50. package/dist/persistence/useEditorAutosave.d.cts +17 -0
  51. package/dist/persistence/useEditorAutosave.d.ts +17 -0
  52. package/dist/vector/index.cjs +1219 -174
  53. package/dist/vector/index.js +4 -2
  54. package/dist/video-editor/index.cjs +1230 -185
  55. package/dist/video-editor/index.js +4 -2
  56. package/package.json +29 -3
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  }
18
18
  return to;
19
19
  };
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
21
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
22
  // If the importer is in node compatibility mode or this is not an ESM
22
23
  // file that has been converted to a CommonJS file using a Babel-
@@ -175,14 +176,1055 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
175
176
  }
176
177
 
177
178
  // src/effects/EffectParameters.tsx
178
- var import_react5 = __toESM(require("react"), 1);
179
+ var import_react8 = __toESM(require("react"), 1);
179
180
  var import_effects3 = require("@pixerate/editor/effects");
180
181
  var import_parameters2 = require("@pixerate/editor/parameters");
181
182
 
182
183
  // src/parameters/fields.tsx
183
- var import_react4 = require("react");
184
+ var import_react7 = require("react");
184
185
  var import_parameters = require("@pixerate/editor/parameters");
186
+
187
+ // src/color/index.ts
188
+ var color_exports = {};
189
+ __export(color_exports, {
190
+ ColorPicker: () => ColorPicker,
191
+ DualColorPicker: () => DualColorPicker,
192
+ useColorScheme: () => useColorScheme,
193
+ useResolvedColor: () => useResolvedColor
194
+ });
195
+
196
+ // src/color/ColorPicker.tsx
197
+ var import_react4 = require("react");
198
+ var import_color = require("@pixerate/editor/color");
185
199
  var import_jsx_runtime3 = require("react/jsx-runtime");
200
+ var LOCAL_STORAGE_KEY = "pixerate:color:recent";
201
+ function readLocalRecents() {
202
+ try {
203
+ if (typeof localStorage === "undefined") return [];
204
+ const raw = localStorage.getItem(LOCAL_STORAGE_KEY);
205
+ if (!raw) return [];
206
+ const parsed = JSON.parse(raw);
207
+ return Array.isArray(parsed) ? parsed : [];
208
+ } catch {
209
+ return [];
210
+ }
211
+ }
212
+ function writeLocalRecents(list) {
213
+ try {
214
+ if (typeof localStorage !== "undefined") {
215
+ localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(list));
216
+ }
217
+ } catch {
218
+ }
219
+ }
220
+ var CHECKERBOARD_BG = "repeating-conic-gradient(var(--pixerate-checker-a, #d4d4d8) 0 25%, var(--pixerate-checker-b, #ffffff) 0 50%)";
221
+ var DEFAULT_PICKER_STATE = { h: 0, s: 1, v: 1, alpha: 1 };
222
+ var ColorPicker = ({
223
+ value,
224
+ onChange,
225
+ onGestureStart,
226
+ onGestureEnd,
227
+ alpha = false,
228
+ swatches,
229
+ recent: controlledRecent,
230
+ onRecentChange,
231
+ contrastAgainst,
232
+ disabled = false,
233
+ className,
234
+ id,
235
+ "aria-label": ariaLabel = "Color picker"
236
+ }) => {
237
+ const generatedId = (0, import_react4.useId)();
238
+ const pickerId = id || generatedId;
239
+ const [pickerState, setPickerState] = (0, import_react4.useState)(
240
+ () => (0, import_color.pickerStateFromColor)(value) ?? DEFAULT_PICKER_STATE
241
+ );
242
+ const stateRef = (0, import_react4.useRef)(pickerState);
243
+ stateRef.current = pickerState;
244
+ (0, import_react4.useEffect)(() => {
245
+ const next = (0, import_color.pickerStateFromColor)(value, stateRef.current);
246
+ if (next) {
247
+ setPickerState(next);
248
+ }
249
+ }, [value]);
250
+ const [internalRecent, setInternalRecent] = (0, import_react4.useState)(
251
+ () => controlledRecent ? [] : readLocalRecents()
252
+ );
253
+ const activeRecent = controlledRecent ?? internalRecent;
254
+ const recordRecent = (0, import_react4.useCallback)(
255
+ (color) => {
256
+ const updated = (0, import_color.pushRecentColor)(activeRecent, color, 12);
257
+ if (!controlledRecent) {
258
+ setInternalRecent(updated);
259
+ writeLocalRecents(updated);
260
+ }
261
+ onRecentChange?.(updated);
262
+ },
263
+ [activeRecent, controlledRecent, onRecentChange]
264
+ );
265
+ const [textDraft, setTextDraft] = (0, import_react4.useState)(value);
266
+ const [isInvalid, setIsInvalid] = (0, import_react4.useState)(false);
267
+ const [isClipped, setIsClipped] = (0, import_react4.useState)(false);
268
+ const isTypingRef = (0, import_react4.useRef)(false);
269
+ (0, import_react4.useEffect)(() => {
270
+ if (!isTypingRef.current) {
271
+ setTextDraft(value);
272
+ setIsInvalid(false);
273
+ const parsed = (0, import_color.parseColor)(value);
274
+ setIsClipped(Boolean(parsed && !(0, import_color.inSrgbGamut)(parsed)));
275
+ }
276
+ }, [value]);
277
+ const [hasEyeDropper, setHasEyeDropper] = (0, import_react4.useState)(false);
278
+ (0, import_react4.useEffect)(() => {
279
+ setHasEyeDropper(typeof window !== "undefined" && "EyeDropper" in window);
280
+ }, []);
281
+ const emitColorChange = (0, import_react4.useCallback)(
282
+ (nextState) => {
283
+ setPickerState(nextState);
284
+ const hex = (0, import_color.pickerStateToHex)(nextState, alpha);
285
+ onChange(hex);
286
+ },
287
+ [alpha, onChange]
288
+ );
289
+ const latest = (0, import_react4.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
290
+ latest.current = { emitColorChange, recordRecent, onGestureEnd, alpha };
291
+ const endDragRef = (0, import_react4.useRef)(null);
292
+ (0, import_react4.useEffect)(() => () => endDragRef.current?.(), []);
293
+ const startDrag = (e, next) => {
294
+ if (disabled) return;
295
+ e.preventDefault();
296
+ endDragRef.current?.();
297
+ onGestureStart?.();
298
+ const rect = e.currentTarget.getBoundingClientRect();
299
+ const update = (clientX, clientY) => {
300
+ const x = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
301
+ const y = Math.max(0, Math.min(1, (clientY - rect.top) / rect.height));
302
+ latest.current.emitColorChange(next(stateRef.current, x, y));
303
+ };
304
+ update(e.clientX, e.clientY);
305
+ const onPointerMove = (ev) => update(ev.clientX, ev.clientY);
306
+ const end = () => {
307
+ window.removeEventListener("pointermove", onPointerMove);
308
+ window.removeEventListener("pointerup", onPointerUp);
309
+ window.removeEventListener("pointercancel", onPointerUp);
310
+ endDragRef.current = null;
311
+ latest.current.onGestureEnd?.();
312
+ };
313
+ const onPointerUp = () => {
314
+ end();
315
+ latest.current.recordRecent((0, import_color.pickerStateToHex)(stateRef.current, latest.current.alpha));
316
+ };
317
+ endDragRef.current = end;
318
+ window.addEventListener("pointermove", onPointerMove);
319
+ window.addEventListener("pointerup", onPointerUp);
320
+ window.addEventListener("pointercancel", onPointerUp);
321
+ };
322
+ const handleAreaPointerDown = (e) => startDrag(e, (state, x, y) => (0, import_color.pickerStateFromArea)(state, x, y));
323
+ const handleHuePointerDown = (e) => startDrag(e, (state, x) => (0, import_color.pickerStateFromHue)(state, x));
324
+ const handleAlphaPointerDown = (e) => startDrag(e, (state, x) => (0, import_color.pickerStateFromAlpha)(state, x));
325
+ const handleAreaKeyDown = (e) => {
326
+ if (disabled) return;
327
+ const next = (0, import_color.pickerKeyStep)(pickerState, "area", e.key, e.shiftKey);
328
+ if (next) {
329
+ e.preventDefault();
330
+ emitColorChange(next);
331
+ recordRecent((0, import_color.pickerStateToHex)(next, alpha));
332
+ }
333
+ };
334
+ const handleHueKeyDown = (e) => {
335
+ if (disabled) return;
336
+ const next = (0, import_color.pickerKeyStep)(pickerState, "hue", e.key, e.shiftKey);
337
+ if (next) {
338
+ e.preventDefault();
339
+ emitColorChange(next);
340
+ recordRecent((0, import_color.pickerStateToHex)(next, alpha));
341
+ }
342
+ };
343
+ const handleAlphaKeyDown = (e) => {
344
+ if (disabled) return;
345
+ const next = (0, import_color.pickerKeyStep)(pickerState, "alpha", e.key, e.shiftKey);
346
+ if (next) {
347
+ e.preventDefault();
348
+ emitColorChange(next);
349
+ recordRecent((0, import_color.pickerStateToHex)(next, alpha));
350
+ }
351
+ };
352
+ const commitTextInput = (inputElement) => {
353
+ isTypingRef.current = false;
354
+ const parsed = (0, import_color.parseColor)(textDraft);
355
+ if (parsed) {
356
+ setIsInvalid(false);
357
+ setIsClipped(!(0, import_color.inSrgbGamut)(parsed));
358
+ const formatted = (0, import_color.formatHex)(parsed);
359
+ onChange(formatted);
360
+ recordRecent(formatted);
361
+ } else {
362
+ setIsInvalid(true);
363
+ setTextDraft(value);
364
+ if (inputElement) {
365
+ inputElement.value = value;
366
+ }
367
+ }
368
+ };
369
+ const handleTextKeyDown = (e) => {
370
+ if (e.key === "Enter") {
371
+ e.preventDefault();
372
+ commitTextInput(e.currentTarget);
373
+ } else if (e.key === "Escape") {
374
+ e.preventDefault();
375
+ isTypingRef.current = false;
376
+ setIsInvalid(false);
377
+ setTextDraft(value);
378
+ e.currentTarget.value = value;
379
+ }
380
+ };
381
+ const handleEyeDropper = async () => {
382
+ if (disabled || !hasEyeDropper) return;
383
+ try {
384
+ const EyeDropperClass = window.EyeDropper;
385
+ const eyeDropper = new EyeDropperClass();
386
+ const res = await eyeDropper.open();
387
+ if (res?.sRGBHex) {
388
+ onChange(res.sRGBHex);
389
+ recordRecent(res.sRGBHex);
390
+ }
391
+ } catch {
392
+ }
393
+ };
394
+ const contrastResult = (0, import_react4.useMemo)(() => {
395
+ if (!contrastAgainst) return null;
396
+ const fg = (0, import_color.parseColor)(value);
397
+ const bg = (0, import_color.parseColor)(contrastAgainst);
398
+ if (!fg || !bg) return null;
399
+ const ratio = (0, import_color.contrastRatio)(fg, bg);
400
+ const aa = ratio >= 4.5;
401
+ const aaa = ratio >= 7;
402
+ return { ratio, aa, aaa };
403
+ }, [value, contrastAgainst]);
404
+ const currentHex = (0, import_color.pickerStateToHex)(pickerState, alpha);
405
+ const liveDescription = `Selected color: ${value}${contrastResult ? `, contrast ${contrastResult.ratio.toFixed(1)}:1 against ${contrastAgainst}, ${contrastResult.aa ? "passes AA" : "fails AA"}` : ""}`;
406
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
407
+ "div",
408
+ {
409
+ id: pickerId,
410
+ role: "group",
411
+ "aria-label": ariaLabel,
412
+ className,
413
+ style: {
414
+ boxSizing: "border-box",
415
+ width: "var(--pixerate-color-picker-width, 240px)",
416
+ borderRadius: "var(--pixerate-color-picker-radius, 8px)",
417
+ background: "var(--pixerate-color-picker-bg, #1f2430)",
418
+ color: "var(--pixerate-color-picker-fg, #f0f2f5)",
419
+ padding: "12px",
420
+ display: "flex",
421
+ flexDirection: "column",
422
+ gap: "10px",
423
+ fontFamily: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
424
+ fontSize: "12px",
425
+ userSelect: "none",
426
+ opacity: disabled ? 0.6 : 1,
427
+ pointerEvents: disabled ? "none" : "auto"
428
+ },
429
+ children: [
430
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
431
+ "span",
432
+ {
433
+ role: "status",
434
+ "aria-live": "polite",
435
+ style: {
436
+ position: "absolute",
437
+ width: "1px",
438
+ height: "1px",
439
+ padding: 0,
440
+ margin: "-1px",
441
+ overflow: "hidden",
442
+ clip: "rect(0, 0, 0, 0)",
443
+ whiteSpace: "nowrap",
444
+ border: 0
445
+ },
446
+ children: liveDescription
447
+ }
448
+ ),
449
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
450
+ "div",
451
+ {
452
+ role: "slider",
453
+ tabIndex: disabled ? -1 : 0,
454
+ "aria-label": "Saturation and brightness",
455
+ "aria-valuetext": `Saturation ${Math.round(pickerState.s * 100)}%, Brightness ${Math.round(
456
+ pickerState.v * 100
457
+ )}%`,
458
+ "aria-disabled": disabled,
459
+ onPointerDown: handleAreaPointerDown,
460
+ onKeyDown: handleAreaKeyDown,
461
+ style: {
462
+ position: "relative",
463
+ width: "100%",
464
+ height: "150px",
465
+ borderRadius: "6px",
466
+ background: (0, import_color.pickerAreaBackground)(pickerState),
467
+ cursor: disabled ? "default" : "crosshair",
468
+ touchAction: "none",
469
+ outline: "none"
470
+ },
471
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
472
+ "div",
473
+ {
474
+ style: {
475
+ position: "absolute",
476
+ width: "var(--pixerate-color-picker-thumb-size, 14px)",
477
+ height: "var(--pixerate-color-picker-thumb-size, 14px)",
478
+ borderRadius: "50%",
479
+ transform: "translate(-50%, -50%)",
480
+ left: `${pickerState.s * 100}%`,
481
+ top: `${(1 - pickerState.v) * 100}%`,
482
+ border: "2px solid #ffffff",
483
+ boxShadow: "0 0 2px 1px rgba(0,0,0,0.6)",
484
+ pointerEvents: "none",
485
+ backgroundColor: currentHex
486
+ }
487
+ }
488
+ )
489
+ }
490
+ ),
491
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
492
+ "div",
493
+ {
494
+ role: "slider",
495
+ tabIndex: disabled ? -1 : 0,
496
+ "aria-label": "Hue",
497
+ "aria-valuenow": Math.round(pickerState.h),
498
+ "aria-valuemin": 0,
499
+ "aria-valuemax": 360,
500
+ "aria-valuetext": `${Math.round(pickerState.h)} degrees`,
501
+ "aria-disabled": disabled,
502
+ onPointerDown: handleHuePointerDown,
503
+ onKeyDown: handleHueKeyDown,
504
+ style: {
505
+ position: "relative",
506
+ width: "100%",
507
+ height: "12px",
508
+ borderRadius: "6px",
509
+ background: import_color.PICKER_HUE_BACKGROUND,
510
+ cursor: disabled ? "default" : "pointer",
511
+ touchAction: "none",
512
+ outline: "none"
513
+ },
514
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
515
+ "div",
516
+ {
517
+ style: {
518
+ position: "absolute",
519
+ top: "50%",
520
+ transform: "translate(-50%, -50%)",
521
+ left: `${pickerState.h / 360 * 100}%`,
522
+ width: "var(--pixerate-color-picker-thumb-size, 14px)",
523
+ height: "var(--pixerate-color-picker-thumb-size, 14px)",
524
+ borderRadius: "50%",
525
+ border: "2px solid #ffffff",
526
+ boxShadow: "0 0 2px 1px rgba(0,0,0,0.6)",
527
+ pointerEvents: "none",
528
+ backgroundColor: `hsl(${pickerState.h}, 100%, 50%)`
529
+ }
530
+ }
531
+ )
532
+ }
533
+ ),
534
+ alpha && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
535
+ "div",
536
+ {
537
+ role: "slider",
538
+ tabIndex: disabled ? -1 : 0,
539
+ "aria-label": "Alpha",
540
+ "aria-valuenow": Math.round(pickerState.alpha * 100),
541
+ "aria-valuemin": 0,
542
+ "aria-valuemax": 100,
543
+ "aria-valuetext": `${Math.round(pickerState.alpha * 100)}%`,
544
+ "aria-disabled": disabled,
545
+ onPointerDown: handleAlphaPointerDown,
546
+ onKeyDown: handleAlphaKeyDown,
547
+ style: {
548
+ position: "relative",
549
+ width: "100%",
550
+ height: "12px",
551
+ borderRadius: "6px",
552
+ backgroundImage: CHECKERBOARD_BG,
553
+ backgroundSize: "8px 8px",
554
+ cursor: disabled ? "default" : "pointer",
555
+ touchAction: "none",
556
+ outline: "none",
557
+ overflow: "hidden"
558
+ },
559
+ children: [
560
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
561
+ "div",
562
+ {
563
+ style: {
564
+ position: "absolute",
565
+ inset: 0,
566
+ background: (0, import_color.pickerAlphaBackground)(pickerState)
567
+ }
568
+ }
569
+ ),
570
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
571
+ "div",
572
+ {
573
+ style: {
574
+ position: "absolute",
575
+ top: "50%",
576
+ transform: "translate(-50%, -50%)",
577
+ left: `${pickerState.alpha * 100}%`,
578
+ width: "var(--pixerate-color-picker-thumb-size, 14px)",
579
+ height: "var(--pixerate-color-picker-thumb-size, 14px)",
580
+ borderRadius: "50%",
581
+ border: "2px solid #ffffff",
582
+ boxShadow: "0 0 2px 1px rgba(0,0,0,0.6)",
583
+ pointerEvents: "none",
584
+ backgroundColor: currentHex
585
+ }
586
+ }
587
+ )
588
+ ]
589
+ }
590
+ ),
591
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginTop: "2px" }, children: [
592
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
593
+ "div",
594
+ {
595
+ style: {
596
+ position: "relative",
597
+ width: "28px",
598
+ height: "28px",
599
+ borderRadius: "4px",
600
+ backgroundImage: CHECKERBOARD_BG,
601
+ backgroundSize: "8px 8px",
602
+ overflow: "hidden",
603
+ flexShrink: 0,
604
+ border: "1px solid rgba(255,255,255,0.15)"
605
+ },
606
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
607
+ "div",
608
+ {
609
+ style: {
610
+ width: "100%",
611
+ height: "100%",
612
+ backgroundColor: currentHex
613
+ }
614
+ }
615
+ )
616
+ }
617
+ ),
618
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
619
+ "input",
620
+ {
621
+ type: "text",
622
+ value: textDraft,
623
+ disabled,
624
+ "aria-label": "Color hex or CSS string",
625
+ "aria-invalid": isInvalid ? "true" : void 0,
626
+ onChange: (e) => {
627
+ isTypingRef.current = true;
628
+ setTextDraft(e.target.value);
629
+ setIsInvalid(false);
630
+ },
631
+ onKeyDown: handleTextKeyDown,
632
+ onBlur: (e) => commitTextInput(e.currentTarget),
633
+ style: {
634
+ flex: 1,
635
+ minWidth: 0,
636
+ height: "28px",
637
+ padding: "0 8px",
638
+ fontSize: "12px",
639
+ fontFamily: "monospace",
640
+ borderRadius: "4px",
641
+ border: isInvalid ? "1px solid #ef4444" : "1px solid rgba(255,255,255,0.2)",
642
+ background: "rgba(0,0,0,0.2)",
643
+ color: "inherit",
644
+ outline: "none"
645
+ }
646
+ }
647
+ ),
648
+ hasEyeDropper && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
649
+ "button",
650
+ {
651
+ type: "button",
652
+ disabled,
653
+ "aria-label": "Pick color from screen",
654
+ title: "Pick color from screen",
655
+ onClick: handleEyeDropper,
656
+ style: {
657
+ display: "inline-flex",
658
+ alignItems: "center",
659
+ justifyContent: "center",
660
+ width: "28px",
661
+ height: "28px",
662
+ borderRadius: "4px",
663
+ border: "1px solid rgba(255,255,255,0.2)",
664
+ background: "transparent",
665
+ color: "inherit",
666
+ cursor: disabled ? "default" : "pointer"
667
+ },
668
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
669
+ "svg",
670
+ {
671
+ width: "14",
672
+ height: "14",
673
+ viewBox: "0 0 24 24",
674
+ fill: "none",
675
+ stroke: "currentColor",
676
+ strokeWidth: "2",
677
+ strokeLinecap: "round",
678
+ strokeLinejoin: "round",
679
+ children: [
680
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m19 11-8-8-8.5 8.5a2.12 2.12 0 0 0 0 3l2.5 2.5 1.5-1.5" }),
681
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m5 16-3 3 1 1 3-3" }),
682
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m14 6 4 4" })
683
+ ]
684
+ }
685
+ )
686
+ }
687
+ )
688
+ ] }),
689
+ isClipped && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
690
+ "div",
691
+ {
692
+ role: "note",
693
+ title: "This colour was outside standard sRGB and clipped.",
694
+ style: {
695
+ display: "inline-flex",
696
+ alignItems: "center",
697
+ gap: "4px",
698
+ fontSize: "10px",
699
+ color: "#f59e0b",
700
+ background: "rgba(245, 158, 11, 0.1)",
701
+ padding: "2px 6px",
702
+ borderRadius: "4px",
703
+ alignSelf: "flex-start"
704
+ },
705
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "\u26A0 Clipped to sRGB" })
706
+ }
707
+ ),
708
+ contrastResult && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
709
+ "div",
710
+ {
711
+ style: {
712
+ display: "flex",
713
+ alignItems: "center",
714
+ justifyContent: "space-between",
715
+ fontSize: "11px",
716
+ padding: "4px 8px",
717
+ borderRadius: "4px",
718
+ background: "rgba(255,255,255,0.05)",
719
+ border: "1px solid rgba(255,255,255,0.1)"
720
+ },
721
+ children: [
722
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { children: [
723
+ "Contrast: ",
724
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("strong", { children: [
725
+ contrastResult.ratio.toFixed(2),
726
+ ":1"
727
+ ] })
728
+ ] }),
729
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", gap: "6px" }, children: [
730
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
731
+ "span",
732
+ {
733
+ style: {
734
+ color: contrastResult.aa ? "#10b981" : "#ef4444",
735
+ fontWeight: 600
736
+ },
737
+ children: [
738
+ "AA ",
739
+ contrastResult.aa ? "\u2713" : "\u2717"
740
+ ]
741
+ }
742
+ ),
743
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
744
+ "span",
745
+ {
746
+ style: {
747
+ color: contrastResult.aaa ? "#10b981" : "#ef4444",
748
+ fontWeight: 600
749
+ },
750
+ children: [
751
+ "AAA ",
752
+ contrastResult.aaa ? "\u2713" : "\u2717"
753
+ ]
754
+ }
755
+ )
756
+ ] })
757
+ ]
758
+ }
759
+ ),
760
+ swatches && swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
761
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Palette" }),
762
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: swatches.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
763
+ "button",
764
+ {
765
+ type: "button",
766
+ "data-testid": "color-picker-swatch",
767
+ title: color,
768
+ disabled,
769
+ "aria-label": `Color ${color}`,
770
+ onClick: () => {
771
+ onChange(color);
772
+ recordRecent(color);
773
+ },
774
+ style: {
775
+ width: "18px",
776
+ height: "18px",
777
+ borderRadius: "3px",
778
+ backgroundColor: color,
779
+ border: color.toLowerCase() === value.toLowerCase() ? "2px solid #ffffff" : "1px solid rgba(255,255,255,0.2)",
780
+ cursor: disabled ? "default" : "pointer",
781
+ padding: 0,
782
+ outline: "none"
783
+ }
784
+ },
785
+ `${color}-${idx}`
786
+ )) })
787
+ ] }),
788
+ activeRecent.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
789
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Recent" }),
790
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: activeRecent.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
791
+ "button",
792
+ {
793
+ type: "button",
794
+ "data-testid": "color-picker-recent",
795
+ disabled,
796
+ "aria-label": `Color ${color}`,
797
+ onClick: () => {
798
+ onChange(color);
799
+ recordRecent(color);
800
+ },
801
+ style: {
802
+ width: "18px",
803
+ height: "18px",
804
+ borderRadius: "3px",
805
+ backgroundColor: color,
806
+ border: color.toLowerCase() === value.toLowerCase() ? "2px solid #ffffff" : "1px solid rgba(255,255,255,0.2)",
807
+ cursor: disabled ? "default" : "pointer",
808
+ padding: 0,
809
+ outline: "none"
810
+ }
811
+ },
812
+ `recent-${color}-${idx}`
813
+ )) })
814
+ ] })
815
+ ]
816
+ }
817
+ );
818
+ };
819
+
820
+ // src/color/DualColorPicker.tsx
821
+ var import_react5 = require("react");
822
+ var import_color2 = require("@pixerate/editor/color");
823
+ var import_jsx_runtime4 = require("react/jsx-runtime");
824
+ function DualColorPicker({
825
+ value,
826
+ onChange,
827
+ onGestureStart,
828
+ onGestureEnd,
829
+ scheme: controlledScheme,
830
+ onSchemeChange,
831
+ surfaces = import_color2.DEFAULT_SCHEME_SURFACES,
832
+ contrastAgainst,
833
+ alpha = false,
834
+ swatches,
835
+ disabled = false,
836
+ className = ""
837
+ }) {
838
+ const sameId = (0, import_react5.useId)();
839
+ const [internalScheme, setInternalScheme] = (0, import_react5.useState)("light");
840
+ const activeScheme = controlledScheme ?? internalScheme;
841
+ const handleSchemeSelect = (nextScheme) => {
842
+ if (onSchemeChange) {
843
+ onSchemeChange(nextScheme);
844
+ } else {
845
+ setInternalScheme(nextScheme);
846
+ }
847
+ };
848
+ const dual = (0, import_color2.normalizeDualColor)(value) ?? { light: "#000000", dark: "#000000" };
849
+ const isSame = dual.light.toLowerCase() === dual.dark.toLowerCase();
850
+ const [sameInBoth, setSameInBoth] = (0, import_react5.useState)(isSame);
851
+ const handleSameToggle = (e) => {
852
+ const nextSame = e.target.checked;
853
+ setSameInBoth(nextSame);
854
+ if (nextSame) {
855
+ const activeVal = activeScheme === "dark" ? dual.dark : dual.light;
856
+ onChange({ light: activeVal, dark: activeVal });
857
+ }
858
+ };
859
+ const handleDerive = () => {
860
+ if (disabled) return;
861
+ onGestureStart?.();
862
+ const currentActive = activeScheme === "dark" ? dual.dark : dual.light;
863
+ const derived = (0, import_color2.deriveDualColor)(currentActive, {
864
+ from: activeScheme,
865
+ // An unreadable surfaces prop falls back to the defaults rather than throwing.
866
+ surfaces: (0, import_color2.normalizeDualColor)(surfaces) ?? import_color2.DEFAULT_SCHEME_SURFACES
867
+ });
868
+ onChange(derived);
869
+ onGestureEnd?.();
870
+ };
871
+ const handleInnerChange = (hex) => {
872
+ if (sameInBoth) {
873
+ onChange({ light: hex, dark: hex });
874
+ } else {
875
+ const updated = (0, import_color2.setDualColorSide)(dual, activeScheme, hex);
876
+ onChange(updated);
877
+ }
878
+ };
879
+ const activeColor = activeScheme === "dark" ? dual.dark : dual.light;
880
+ const activeContrastTarget = contrastAgainst ? (0, import_color2.resolveColor)(contrastAgainst, activeScheme) ?? void 0 : void 0;
881
+ const dualContrast = contrastAgainst && (0, import_color2.normalizeDualColor)(contrastAgainst) ? (0, import_color2.checkDualColorContrast)(dual, contrastAgainst) : null;
882
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
883
+ "div",
884
+ {
885
+ className: `pixerate-dual-color-picker ${className}`,
886
+ style: {
887
+ display: "flex",
888
+ flexDirection: "column",
889
+ gap: "12px",
890
+ padding: "12px",
891
+ background: "#1a1d24",
892
+ color: "#e2e8f0",
893
+ borderRadius: "10px",
894
+ boxShadow: "0 4px 12px rgba(0,0,0,0.3)",
895
+ width: "260px",
896
+ fontFamily: "system-ui, -apple-system, sans-serif",
897
+ fontSize: "13px",
898
+ boxSizing: "border-box"
899
+ },
900
+ children: [
901
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
902
+ "div",
903
+ {
904
+ role: "tablist",
905
+ "aria-label": "Color scheme mode",
906
+ style: {
907
+ display: "flex",
908
+ background: "#111318",
909
+ borderRadius: "6px",
910
+ padding: "2px",
911
+ gap: "2px"
912
+ },
913
+ children: [
914
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
915
+ "button",
916
+ {
917
+ type: "button",
918
+ role: "tab",
919
+ "aria-selected": activeScheme === "light",
920
+ onClick: () => handleSchemeSelect("light"),
921
+ disabled,
922
+ style: {
923
+ flex: 1,
924
+ padding: "6px 8px",
925
+ border: "none",
926
+ borderRadius: "4px",
927
+ background: activeScheme === "light" ? "#2d3342" : "transparent",
928
+ color: activeScheme === "light" ? "#ffffff" : "#8c95a6",
929
+ fontWeight: activeScheme === "light" ? 600 : 400,
930
+ cursor: disabled ? "not-allowed" : "pointer",
931
+ fontSize: "12px",
932
+ transition: "all 0.15s ease"
933
+ },
934
+ children: "Light"
935
+ }
936
+ ),
937
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
938
+ "button",
939
+ {
940
+ type: "button",
941
+ role: "tab",
942
+ "aria-selected": activeScheme === "dark",
943
+ onClick: () => handleSchemeSelect("dark"),
944
+ disabled,
945
+ style: {
946
+ flex: 1,
947
+ padding: "6px 8px",
948
+ border: "none",
949
+ borderRadius: "4px",
950
+ background: activeScheme === "dark" ? "#2d3342" : "transparent",
951
+ color: activeScheme === "dark" ? "#ffffff" : "#8c95a6",
952
+ fontWeight: activeScheme === "dark" ? 600 : 400,
953
+ cursor: disabled ? "not-allowed" : "pointer",
954
+ fontSize: "12px",
955
+ transition: "all 0.15s ease"
956
+ },
957
+ children: "Dark"
958
+ }
959
+ )
960
+ ]
961
+ }
962
+ ),
963
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
964
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
965
+ "button",
966
+ {
967
+ type: "button",
968
+ onClick: () => handleSchemeSelect("light"),
969
+ disabled,
970
+ title: "Edit light mode colour",
971
+ style: {
972
+ flex: 1,
973
+ display: "flex",
974
+ flexDirection: "column",
975
+ alignItems: "center",
976
+ gap: "6px",
977
+ padding: "8px",
978
+ background: surfaces.light,
979
+ color: "#000000",
980
+ border: activeScheme === "light" ? "2px solid #3b82f6" : "1px solid #333842",
981
+ borderRadius: "6px",
982
+ cursor: disabled ? "not-allowed" : "pointer",
983
+ outline: "none"
984
+ },
985
+ children: [
986
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
987
+ "span",
988
+ {
989
+ style: {
990
+ width: "100%",
991
+ height: "24px",
992
+ borderRadius: "4px",
993
+ background: dual.light,
994
+ border: "1px solid rgba(0,0,0,0.15)"
995
+ }
996
+ }
997
+ ),
998
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Light" })
999
+ ]
1000
+ }
1001
+ ),
1002
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1003
+ "button",
1004
+ {
1005
+ type: "button",
1006
+ onClick: () => handleSchemeSelect("dark"),
1007
+ disabled,
1008
+ title: "Edit dark mode colour",
1009
+ style: {
1010
+ flex: 1,
1011
+ display: "flex",
1012
+ flexDirection: "column",
1013
+ alignItems: "center",
1014
+ gap: "6px",
1015
+ padding: "8px",
1016
+ background: surfaces.dark,
1017
+ color: "#ffffff",
1018
+ border: activeScheme === "dark" ? "2px solid #3b82f6" : "1px solid #333842",
1019
+ borderRadius: "6px",
1020
+ cursor: disabled ? "not-allowed" : "pointer",
1021
+ outline: "none"
1022
+ },
1023
+ children: [
1024
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1025
+ "span",
1026
+ {
1027
+ style: {
1028
+ width: "100%",
1029
+ height: "24px",
1030
+ borderRadius: "4px",
1031
+ background: dual.dark,
1032
+ border: "1px solid rgba(255,255,255,0.15)"
1033
+ }
1034
+ }
1035
+ ),
1036
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Dark" })
1037
+ ]
1038
+ }
1039
+ )
1040
+ ] }),
1041
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1042
+ "div",
1043
+ {
1044
+ style: {
1045
+ display: "flex",
1046
+ alignItems: "center",
1047
+ justifyContent: "space-between",
1048
+ gap: "8px",
1049
+ padding: "2px 0"
1050
+ },
1051
+ children: [
1052
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1053
+ "label",
1054
+ {
1055
+ htmlFor: sameId,
1056
+ style: {
1057
+ display: "flex",
1058
+ alignItems: "center",
1059
+ gap: "6px",
1060
+ cursor: disabled ? "not-allowed" : "pointer",
1061
+ userSelect: "none",
1062
+ fontSize: "12px",
1063
+ color: "#c4cad4"
1064
+ },
1065
+ children: [
1066
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1067
+ "input",
1068
+ {
1069
+ id: sameId,
1070
+ type: "checkbox",
1071
+ checked: sameInBoth,
1072
+ onChange: handleSameToggle,
1073
+ disabled,
1074
+ style: { cursor: disabled ? "not-allowed" : "pointer" }
1075
+ }
1076
+ ),
1077
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "Same in both" })
1078
+ ]
1079
+ }
1080
+ ),
1081
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1082
+ "button",
1083
+ {
1084
+ type: "button",
1085
+ onClick: handleDerive,
1086
+ disabled,
1087
+ style: {
1088
+ padding: "4px 10px",
1089
+ background: "#2d3342",
1090
+ color: "#e2e8f0",
1091
+ border: "1px solid #3b4252",
1092
+ borderRadius: "4px",
1093
+ fontSize: "11px",
1094
+ fontWeight: 500,
1095
+ cursor: disabled ? "not-allowed" : "pointer"
1096
+ },
1097
+ children: "Derive"
1098
+ }
1099
+ )
1100
+ ]
1101
+ }
1102
+ ),
1103
+ dualContrast && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1104
+ "div",
1105
+ {
1106
+ "data-testid": "dual-contrast-summary",
1107
+ style: {
1108
+ display: "flex",
1109
+ justifyContent: "space-between",
1110
+ background: "#111318",
1111
+ padding: "6px 8px",
1112
+ borderRadius: "6px",
1113
+ fontSize: "11px",
1114
+ color: "#8c95a6"
1115
+ },
1116
+ children: [
1117
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
1118
+ "Light:",
1119
+ " ",
1120
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("strong", { style: { color: dualContrast.light.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
1121
+ dualContrast.light.ratio.toFixed(2),
1122
+ " (",
1123
+ dualContrast.light.level,
1124
+ ")"
1125
+ ] })
1126
+ ] }),
1127
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
1128
+ "Dark:",
1129
+ " ",
1130
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("strong", { style: { color: dualContrast.dark.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
1131
+ dualContrast.dark.ratio.toFixed(2),
1132
+ " (",
1133
+ dualContrast.dark.level,
1134
+ ")"
1135
+ ] })
1136
+ ] })
1137
+ ]
1138
+ }
1139
+ ),
1140
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1141
+ ColorPicker,
1142
+ {
1143
+ value: activeColor,
1144
+ onChange: handleInnerChange,
1145
+ onGestureStart,
1146
+ onGestureEnd,
1147
+ contrastAgainst: activeContrastTarget,
1148
+ alpha,
1149
+ swatches,
1150
+ disabled
1151
+ }
1152
+ )
1153
+ ]
1154
+ }
1155
+ );
1156
+ }
1157
+
1158
+ // src/color/useColorScheme.ts
1159
+ var import_react6 = require("react");
1160
+ var import_color3 = require("@pixerate/editor/color");
1161
+ function getSnapshot(attribute) {
1162
+ if (typeof window === "undefined" || typeof document === "undefined") {
1163
+ return "light";
1164
+ }
1165
+ if (attribute) {
1166
+ const el = document.documentElement;
1167
+ if (attribute === "class") {
1168
+ return el.classList.contains("dark") ? "dark" : "light";
1169
+ }
1170
+ const val = el.getAttribute(attribute);
1171
+ return val === "dark" ? "dark" : "light";
1172
+ }
1173
+ if (typeof window.matchMedia === "function") {
1174
+ return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
1175
+ }
1176
+ return "light";
1177
+ }
1178
+ function getServerSnapshot() {
1179
+ return "light";
1180
+ }
1181
+ function useColorScheme(options) {
1182
+ const override = options?.override;
1183
+ const attribute = options?.attribute;
1184
+ const subscribe = (0, import_react6.useMemo)(() => {
1185
+ return (callback) => {
1186
+ if (typeof window === "undefined" || typeof document === "undefined") {
1187
+ return () => {
1188
+ };
1189
+ }
1190
+ if (attribute) {
1191
+ const observer = new MutationObserver(() => {
1192
+ callback();
1193
+ });
1194
+ observer.observe(document.documentElement, {
1195
+ attributes: true,
1196
+ attributeFilter: [attribute]
1197
+ });
1198
+ return () => observer.disconnect();
1199
+ }
1200
+ if (typeof window.matchMedia === "function") {
1201
+ const mql = window.matchMedia("(prefers-color-scheme: dark)");
1202
+ const handler = () => callback();
1203
+ mql.addEventListener("change", handler);
1204
+ return () => mql.removeEventListener("change", handler);
1205
+ }
1206
+ return () => {
1207
+ };
1208
+ };
1209
+ }, [attribute]);
1210
+ const detected = (0, import_react6.useSyncExternalStore)(
1211
+ subscribe,
1212
+ () => getSnapshot(attribute),
1213
+ getServerSnapshot
1214
+ );
1215
+ return override ?? detected;
1216
+ }
1217
+ function useResolvedColor(value, scheme) {
1218
+ const detectedScheme = useColorScheme();
1219
+ const activeScheme = scheme ?? detectedScheme;
1220
+ return (0, import_color3.resolveColor)(value, activeScheme);
1221
+ }
1222
+
1223
+ // src/color/index.ts
1224
+ __reExport(color_exports, require("@pixerate/editor/color"));
1225
+
1226
+ // src/parameters/fields.tsx
1227
+ var import_jsx_runtime5 = require("react/jsx-runtime");
186
1228
  var parameterInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-background px-2 text-xs text-foreground tabular-nums focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50";
187
1229
  var parameterButtonClass = "inline-flex h-7 items-center justify-center gap-1 rounded-md border border-input bg-background px-2 text-xs text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50";
188
1230
  var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
@@ -206,7 +1248,7 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
206
1248
  onKeyDown: keyDown,
207
1249
  ...rest
208
1250
  };
209
- return multiline ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("textarea", { ...props, className: `${props.className} h-auto min-h-[3.5rem] py-1` }, value) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("input", { type: "text", ...props }, value);
1251
+ return multiline ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("textarea", { ...props, className: `${props.className} h-auto min-h-[3.5rem] py-1` }, value) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { type: "text", ...props }, value);
210
1252
  }
211
1253
  var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
212
1254
  function ParameterNumberInput({
@@ -217,8 +1259,8 @@ function ParameterNumberInput({
217
1259
  id,
218
1260
  "aria-label": ariaLabel
219
1261
  }) {
220
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
221
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1262
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
1263
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
222
1264
  ParameterCommitInput,
223
1265
  {
224
1266
  id,
@@ -240,21 +1282,21 @@ function ParameterNumberInput({
240
1282
  }
241
1283
  }
242
1284
  ),
243
- field.unit && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
1285
+ field.unit && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
244
1286
  ] });
245
1287
  }
246
1288
  function ParameterSlider(props) {
247
1289
  const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
248
- const dragging = (0, import_react4.useRef)(false);
1290
+ const dragging = (0, import_react7.useRef)(false);
249
1291
  const end = () => {
250
1292
  if (!dragging.current) return;
251
1293
  dragging.current = false;
252
1294
  onGestureEnd?.();
253
1295
  };
254
- if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ParameterNumberInput, { ...props });
1296
+ if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ParameterNumberInput, { ...props });
255
1297
  const step = (0, import_parameters.parameterStep)(field);
256
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-2", children: [
257
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1298
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
1299
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
258
1300
  "input",
259
1301
  {
260
1302
  type: "range",
@@ -277,11 +1319,11 @@ function ParameterSlider(props) {
277
1319
  onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
278
1320
  }
279
1321
  ),
280
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
1322
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
281
1323
  ] });
282
1324
  }
283
1325
  function ParameterToggle({ field, value, onChange, disabled, id }) {
284
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1326
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
285
1327
  "button",
286
1328
  {
287
1329
  type: "button",
@@ -292,7 +1334,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
292
1334
  disabled: disabled || field.readOnly,
293
1335
  onClick: () => onChange(!value),
294
1336
  className: `relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:opacity-50 ${value ? "bg-primary" : "bg-muted"}`,
295
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1337
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
296
1338
  "span",
297
1339
  {
298
1340
  className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
@@ -305,7 +1347,7 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
305
1347
  const options = (0, import_parameters.getChoiceOptions)(field);
306
1348
  const off = disabled || field.readOnly;
307
1349
  if (field.control === "segmented") {
308
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { role: "radiogroup", "aria-label": (0, import_parameters.parameterLabel)(field), className: "inline-flex flex-wrap rounded-md border border-input bg-muted p-0.5", children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1350
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { role: "radiogroup", "aria-label": (0, import_parameters.parameterLabel)(field), className: "inline-flex flex-wrap rounded-md border border-input bg-muted p-0.5", children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
309
1351
  "button",
310
1352
  {
311
1353
  type: "button",
@@ -321,7 +1363,7 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
321
1363
  )) });
322
1364
  }
323
1365
  const index = options.findIndex((o) => o.value === value);
324
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1366
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
325
1367
  "select",
326
1368
  {
327
1369
  id,
@@ -333,53 +1375,64 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
333
1375
  if (option) onChange(option.value);
334
1376
  },
335
1377
  className: parameterInputClass,
336
- children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: String(i), title: o.description, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
1378
+ children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: String(i), title: o.description, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
337
1379
  }
338
1380
  );
339
1381
  }
340
1382
  function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
341
- const picking = (0, import_react4.useRef)(false);
1383
+ const [open, setOpen] = (0, import_react7.useState)(false);
1384
+ const containerRef = (0, import_react7.useRef)(null);
1385
+ const buttonRef = (0, import_react7.useRef)(null);
1386
+ const popoverRef = (0, import_react7.useRef)(null);
342
1387
  const alpha = !!field.alpha;
343
1388
  const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
344
1389
  const rgb = hex.slice(0, 7);
345
- const a = hex.slice(7);
1390
+ const shown = alpha ? hex : rgb;
346
1391
  const off = disabled || field.readOnly;
347
- const start = () => {
348
- if (picking.current) return;
349
- picking.current = true;
350
- onGestureStart?.();
351
- };
352
- const end = () => {
353
- if (!picking.current) return;
354
- picking.current = false;
355
- onGestureEnd?.();
356
- };
357
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "space-y-1.5", children: [
358
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-2", children: [
359
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "relative h-7 w-9 shrink-0 overflow-hidden rounded-md border border-input bg-[repeating-conic-gradient(#d4d4d8_0_25%,#fff_0_50%)] bg-[length:8px_8px]", children: [
360
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "absolute inset-0", style: { background: alpha ? hex : rgb } }),
361
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
362
- "input",
363
- {
364
- type: "color",
365
- "aria-label": (0, import_parameters.parameterLabel)(field),
366
- value: rgb,
367
- disabled: off,
368
- className: "absolute inset-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed",
369
- onChange: (e) => {
370
- start();
371
- onChange(alpha ? `${e.target.value}${a}` : e.target.value);
372
- },
373
- onBlur: end
374
- }
375
- )
376
- ] }),
377
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1392
+ const name = (0, import_parameters.parameterLabel)(field);
1393
+ (0, import_react7.useEffect)(() => {
1394
+ if (!open) return;
1395
+ const onPointerDown = (e) => {
1396
+ if (containerRef.current && !containerRef.current.contains(e.target)) {
1397
+ setOpen(false);
1398
+ }
1399
+ };
1400
+ const onKeyDown = (e) => {
1401
+ if (e.key === "Escape") {
1402
+ e.stopPropagation();
1403
+ setOpen(false);
1404
+ buttonRef.current?.focus();
1405
+ }
1406
+ };
1407
+ window.addEventListener("pointerdown", onPointerDown, true);
1408
+ window.addEventListener("keydown", onKeyDown, true);
1409
+ return () => {
1410
+ window.removeEventListener("pointerdown", onPointerDown, true);
1411
+ window.removeEventListener("keydown", onKeyDown, true);
1412
+ };
1413
+ }, [open]);
1414
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
1415
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
1416
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1417
+ "button",
1418
+ {
1419
+ ref: buttonRef,
1420
+ type: "button",
1421
+ "aria-label": name,
1422
+ "aria-expanded": open,
1423
+ "aria-haspopup": "dialog",
1424
+ disabled: off,
1425
+ onClick: () => setOpen((prev) => !prev),
1426
+ className: "relative h-7 w-9 shrink-0 overflow-hidden rounded-md border border-input bg-[repeating-conic-gradient(#d4d4d8_0_25%,#fff_0_50%)] bg-[length:8px_8px] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50",
1427
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
1428
+ }
1429
+ ),
1430
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
378
1431
  ParameterCommitInput,
379
1432
  {
380
1433
  id,
381
- "aria-label": `${(0, import_parameters.parameterLabel)(field)} hex`,
382
- value: alpha ? hex : rgb,
1434
+ "aria-label": `${name} hex`,
1435
+ value: shown,
383
1436
  disabled: off,
384
1437
  spellCheck: false,
385
1438
  className: `${parameterInputClass} font-mono`,
@@ -390,51 +1443,43 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
390
1443
  }
391
1444
  )
392
1445
  ] }),
393
- alpha && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
394
- "input",
1446
+ open && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1447
+ "div",
395
1448
  {
396
- type: "range",
397
- "aria-label": `${(0, import_parameters.parameterLabel)(field)} opacity`,
398
- min: 0,
399
- max: 255,
400
- step: 1,
401
- value: parseInt(a, 16),
402
- disabled: off,
403
- className: rangeClass,
404
- onPointerDown: start,
405
- onPointerUp: end,
406
- onPointerCancel: end,
407
- onBlur: end,
408
- onChange: (e) => onChange(`${rgb}${Number(e.target.value).toString(16).padStart(2, "0")}`)
409
- }
410
- ),
411
- field.swatches && field.swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "flex flex-wrap gap-1", children: field.swatches.map((s) => {
412
- const swatch = (0, import_parameters.normalizeHexColor)(s, alpha);
413
- if (!swatch) return null;
414
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
415
- "button",
416
- {
417
- type: "button",
418
- title: swatch,
419
- "aria-label": `${(0, import_parameters.parameterLabel)(field)} ${swatch}`,
420
- "aria-pressed": swatch === (alpha ? hex : rgb),
421
- disabled: off,
422
- onClick: () => onChange(swatch),
423
- className: "h-5 w-5 rounded border border-input aria-pressed:ring-1 aria-pressed:ring-primary",
424
- style: { background: swatch }
1449
+ ref: popoverRef,
1450
+ role: "dialog",
1451
+ "aria-label": name,
1452
+ tabIndex: -1,
1453
+ onBlur: (e) => {
1454
+ if (popoverRef.current && !popoverRef.current.contains(e.relatedTarget)) {
1455
+ setOpen(false);
1456
+ }
425
1457
  },
426
- s
427
- );
428
- }) })
1458
+ className: "absolute left-0 top-full z-50 mt-1 w-64 rounded-lg border border-border bg-popover p-2 text-popover-foreground shadow-xl",
1459
+ style: { background: "var(--popover, var(--background, #fff))" },
1460
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1461
+ ColorPicker,
1462
+ {
1463
+ value: shown,
1464
+ alpha,
1465
+ swatches: field.swatches,
1466
+ disabled: off,
1467
+ onChange,
1468
+ onGestureStart,
1469
+ onGestureEnd
1470
+ }
1471
+ )
1472
+ }
1473
+ )
429
1474
  ] });
430
1475
  }
431
1476
  function ParameterVector({ field, value, onChange, disabled, id }) {
432
1477
  const size = (0, import_parameters.vectorSize)(field);
433
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
1478
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
434
1479
  const component = (0, import_parameters.vectorComponentField)(field, i);
435
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
436
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
437
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1480
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
1481
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
1482
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
438
1483
  ParameterNumberInput,
439
1484
  {
440
1485
  field: component,
@@ -451,11 +1496,11 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
451
1496
  function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
452
1497
  const off = disabled || field.readOnly;
453
1498
  const name = (0, import_parameters.parameterLabel)(field);
454
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "space-y-1.5", children: [
455
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-2", children: [
456
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "flex h-12 w-16 shrink-0 items-center justify-center overflow-hidden rounded-md border border-input bg-muted", children: value ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
457
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
458
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1499
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-1.5", children: [
1500
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
1501
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex h-12 w-16 shrink-0 items-center justify-center overflow-hidden rounded-md border border-input bg-muted", children: value ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
1502
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
1503
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
459
1504
  ParameterCommitInput,
460
1505
  {
461
1506
  id,
@@ -466,10 +1511,10 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
466
1511
  onCommit: (text) => onChange(text.trim())
467
1512
  }
468
1513
  ),
469
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex gap-1", children: [
470
- resolveFile && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`, children: [
1514
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-1", children: [
1515
+ resolveFile && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`, children: [
471
1516
  "Choose file\u2026",
472
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1517
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
473
1518
  "input",
474
1519
  {
475
1520
  type: "file",
@@ -485,11 +1530,11 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
485
1530
  }
486
1531
  )
487
1532
  ] }),
488
- value && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: parameterButtonClass, disabled: off, onClick: () => onChange(""), "aria-label": `Clear ${name}`, children: "Clear" })
1533
+ value && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: parameterButtonClass, disabled: off, onClick: () => onChange(""), "aria-label": `Clear ${name}`, children: "Clear" })
489
1534
  ] })
490
1535
  ] })
491
1536
  ] }),
492
- field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1537
+ field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
493
1538
  "button",
494
1539
  {
495
1540
  type: "button",
@@ -499,14 +1544,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
499
1544
  disabled: off,
500
1545
  onClick: () => onChange(o.url),
501
1546
  className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
502
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
1547
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
503
1548
  },
504
1549
  o.url
505
1550
  )) })
506
1551
  ] });
507
1552
  }
508
1553
  function ParameterText({ field, value, onChange, disabled, id }) {
509
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1554
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
510
1555
  ParameterCommitInput,
511
1556
  {
512
1557
  id,
@@ -525,31 +1570,31 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
525
1570
  switch (field.type) {
526
1571
  case "number":
527
1572
  case "int":
528
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
1573
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
529
1574
  case "boolean":
530
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
1575
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
531
1576
  case "choice":
532
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
1577
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
533
1578
  case "color":
534
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
1579
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
535
1580
  case "vector":
536
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
1581
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
537
1582
  case "image":
538
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
1583
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
539
1584
  case "text":
540
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ParameterText, { field, value, onChange: set, ...rest });
1585
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ParameterText, { field, value, onChange: set, ...rest });
541
1586
  }
542
1587
  }
543
1588
 
544
1589
  // src/effects/EffectParameters.tsx
545
- var import_jsx_runtime4 = require("react/jsx-runtime");
1590
+ var import_jsx_runtime6 = require("react/jsx-runtime");
546
1591
  function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, disabled = false, className = "" }) {
547
- const fields = (0, import_react5.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
548
- const idBase = (0, import_react5.useId)();
549
- const gesture = import_react5.default.useRef(null);
550
- const count = import_react5.default.useRef(0);
551
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
552
- onPreset && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1592
+ const fields = (0, import_react8.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
1593
+ const idBase = (0, import_react8.useId)();
1594
+ const gesture = import_react8.default.useRef(null);
1595
+ const count = import_react8.default.useRef(0);
1596
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
1597
+ onPreset && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
553
1598
  "select",
554
1599
  {
555
1600
  className: "w-full rounded border border-border bg-transparent px-1 py-0.5 text-xs",
@@ -561,8 +1606,8 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
561
1606
  if (preset) onPreset({ ...description.defaults, ...preset.values });
562
1607
  },
563
1608
  children: [
564
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "", children: "Presets\u2026" }),
565
- description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: p.name, children: p.name }, p.name))
1609
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "", children: "Presets\u2026" }),
1610
+ description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: p.name, children: p.name }, p.name))
566
1611
  ]
567
1612
  }
568
1613
  ),
@@ -572,13 +1617,13 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
572
1617
  const keyed = keyframed?.has(field.id) ?? false;
573
1618
  const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
574
1619
  const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
575
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
576
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center gap-1.5", children: [
577
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
578
- keyed && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
579
- onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "rounded px-1 text-[11px] text-muted-foreground hover:text-foreground", "aria-label": `Reset ${label}`, onClick: () => onReset(field.id), children: "\u21BA" })
1620
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
1621
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center gap-1.5", children: [
1622
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
1623
+ keyed && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
1624
+ onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "rounded px-1 text-[11px] text-muted-foreground hover:text-foreground", "aria-label": `Reset ${label}`, onClick: () => onReset(field.id), children: "\u21BA" })
580
1625
  ] }),
581
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1626
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
582
1627
  ParameterFieldControl,
583
1628
  {
584
1629
  field,
@@ -592,7 +1637,7 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
592
1637
  )
593
1638
  ] }, field.id);
594
1639
  }),
595
- !fields.length && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
1640
+ !fields.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
596
1641
  ] });
597
1642
  }
598
1643
  // Annotate the CommonJS export names for ESM import in node: