@pixerate/editor-react 0.114.2 → 0.114.3

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 (38) hide show
  1. package/dist/animation-editor/index.cjs +342 -215
  2. package/dist/animation-editor/index.js +2 -2
  3. package/dist/canvas/index.cjs +520 -393
  4. package/dist/canvas/index.js +2 -2
  5. package/dist/{chunk-5LFQ2UQZ.js → chunk-354TA5QV.js} +221 -101
  6. package/dist/{chunk-2INOKIJN.js → chunk-SH63DFOO.js} +345 -297
  7. package/dist/{chunk-BWEARAWR.js → chunk-TOGMXZM4.js} +40 -18
  8. package/dist/effects/EffectParameters.d.cts +4 -1
  9. package/dist/effects/EffectParameters.d.ts +4 -1
  10. package/dist/effects/index.cjs +348 -221
  11. package/dist/effects/index.js +2 -2
  12. package/dist/image-editor/ImageEffectControls.d.cts +4 -1
  13. package/dist/image-editor/ImageEffectControls.d.ts +4 -1
  14. package/dist/image-editor/ImageProviderEffectsPanel.d.cts +4 -1
  15. package/dist/image-editor/ImageProviderEffectsPanel.d.ts +4 -1
  16. package/dist/image-editor/controls/parameterControls.d.cts +4 -0
  17. package/dist/image-editor/controls/parameterControls.d.ts +4 -0
  18. package/dist/image-editor/index.cjs +868 -697
  19. package/dist/image-editor/index.js +3 -3
  20. package/dist/index.cjs +1388 -1217
  21. package/dist/index.js +3 -3
  22. package/dist/paint-editor/index.cjs +335 -208
  23. package/dist/paint-editor/index.js +2 -2
  24. package/dist/parameters/ParametersPanel.d.cts +4 -1
  25. package/dist/parameters/ParametersPanel.d.ts +4 -1
  26. package/dist/parameters/controls.d.cts +72 -0
  27. package/dist/parameters/controls.d.ts +72 -0
  28. package/dist/parameters/fields.d.cts +19 -6
  29. package/dist/parameters/fields.d.ts +19 -6
  30. package/dist/parameters/index.cjs +350 -183
  31. package/dist/parameters/index.d.cts +1 -0
  32. package/dist/parameters/index.d.ts +1 -0
  33. package/dist/parameters/index.js +70 -14
  34. package/dist/vector/index.cjs +321 -194
  35. package/dist/vector/index.js +2 -2
  36. package/dist/video-editor/index.cjs +418 -291
  37. package/dist/video-editor/index.js +2 -2
  38. package/package.json +3 -3
@@ -1337,7 +1337,7 @@ var StickerPanel = ({ controller, className }) => {
1337
1337
  };
1338
1338
 
1339
1339
  // src/paint-editor/PaintEditor.tsx
1340
- var import_react23 = require("react");
1340
+ var import_react24 = require("react");
1341
1341
  var import_paint_editor14 = require("@pixerate/editor/paint-editor");
1342
1342
 
1343
1343
  // src/playback/AgentPlaybackContext.tsx
@@ -1432,7 +1432,7 @@ function PresenceLayer({ presence, viewport, clip = true, className = "" }) {
1432
1432
  }
1433
1433
 
1434
1434
  // src/paint-editor/PaintEffectsPanel.tsx
1435
- var import_react22 = require("react");
1435
+ var import_react23 = require("react");
1436
1436
  var import_paint_editor13 = require("@pixerate/editor/paint-editor");
1437
1437
 
1438
1438
  // src/effects/useEffects.ts
@@ -1566,12 +1566,12 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
1566
1566
  }
1567
1567
 
1568
1568
  // src/effects/EffectParameters.tsx
1569
- var import_react21 = __toESM(require("react"), 1);
1569
+ var import_react22 = __toESM(require("react"), 1);
1570
1570
  var import_effects3 = require("@pixerate/editor/effects");
1571
1571
  var import_parameters2 = require("@pixerate/editor/parameters");
1572
1572
 
1573
1573
  // src/parameters/fields.tsx
1574
- var import_react20 = require("react");
1574
+ var import_react21 = require("react");
1575
1575
  var import_parameters = require("@pixerate/editor/parameters");
1576
1576
 
1577
1577
  // src/color/index.ts
@@ -2613,18 +2613,57 @@ function useResolvedColor(value, scheme) {
2613
2613
  // src/color/index.ts
2614
2614
  __reExport(color_exports, require("@pixerate/editor/color"));
2615
2615
 
2616
- // src/parameters/fields.tsx
2616
+ // src/parameters/controls.tsx
2617
+ var import_react20 = require("react");
2617
2618
  var import_jsx_runtime18 = require("react/jsx-runtime");
2619
+ var ParameterComponentsContext = (0, import_react20.createContext)({});
2620
+ function useParameterComponents() {
2621
+ return (0, import_react20.useContext)(ParameterComponentsContext);
2622
+ }
2623
+ function resolveParameterComponents(explicit, context) {
2624
+ return {
2625
+ input: explicit?.input ?? context?.input,
2626
+ slider: explicit?.slider ?? context?.slider,
2627
+ select: explicit?.select ?? context?.select
2628
+ };
2629
+ }
2630
+
2631
+ // src/parameters/fields.tsx
2632
+ var import_jsx_runtime19 = require("react/jsx-runtime");
2633
+ var parameterInputStyle = import_parameters.parameterThemeStyles.input;
2634
+ var parameterSelectStyle = import_parameters.parameterThemeStyles.select;
2635
+ var parameterButtonStyle = import_parameters.parameterThemeStyles.button;
2636
+ var parameterRangeStyle = import_parameters.parameterThemeStyles.range;
2618
2637
  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";
2619
2638
  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";
2620
2639
  var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
2621
- function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, ...rest }) {
2640
+ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
2641
+ const inputRef = (0, import_react21.useRef)(null);
2642
+ const lastCommitted = (0, import_react21.useRef)(null);
2643
+ (0, import_react21.useLayoutEffect)(() => {
2644
+ lastCommitted.current = null;
2645
+ const el = inputRef.current;
2646
+ if (el && el.value !== value) el.value = value;
2647
+ }, [value]);
2622
2648
  const commit = (el) => {
2623
- if (el.value !== value) onCommit(el.value, el);
2649
+ const text = el.value;
2650
+ if (text === value || text === lastCommitted.current) return;
2651
+ onCommit(text, el);
2652
+ lastCommitted.current = el.value === text ? text : null;
2624
2653
  };
2654
+ const commitRef = (0, import_react21.useRef)(commit);
2655
+ commitRef.current = commit;
2656
+ (0, import_react21.useEffect)(() => {
2657
+ const el = inputRef.current;
2658
+ if (!el) return;
2659
+ const change = () => commitRef.current(el);
2660
+ el.addEventListener("change", change);
2661
+ return () => el.removeEventListener("change", change);
2662
+ }, [multiline]);
2625
2663
  const keyDown = (e) => {
2626
2664
  onKeyDown?.(e);
2627
2665
  if (e.defaultPrevented) return;
2666
+ if (e.key === "Tab") commit(e.currentTarget);
2628
2667
  if (e.key === "Enter" && (!multiline || e.metaKey || e.ctrlKey)) {
2629
2668
  e.preventDefault();
2630
2669
  commit(e.currentTarget);
@@ -2634,86 +2673,114 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
2634
2673
  const props = {
2635
2674
  defaultValue: value,
2636
2675
  className: className ?? parameterInputClass,
2676
+ style: { ...parameterInputStyle, ...style },
2637
2677
  onBlur: (e) => commit(e.currentTarget),
2638
2678
  onKeyDown: keyDown,
2639
2679
  ...rest
2640
2680
  };
2641
- return multiline ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("textarea", { ...props, className: `${props.className} h-auto min-h-[3.5rem] py-1` }, value) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("input", { type: "text", ...props }, value);
2681
+ const forwarded = rest.ref;
2682
+ const setRef = (el) => {
2683
+ inputRef.current = el;
2684
+ if (typeof forwarded === "function") forwarded(el);
2685
+ else if (forwarded) forwarded.current = el;
2686
+ };
2687
+ return multiline ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("textarea", { ...props, ref: setRef, className: `${props.className} h-auto min-h-[3.5rem] py-1` }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("input", { type: "text", ...props, ref: setRef });
2642
2688
  }
2643
2689
  var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
2644
- function ParameterNumberInput({
2645
- field,
2646
- value,
2647
- onChange,
2648
- disabled,
2649
- id,
2650
- "aria-label": ariaLabel
2651
- }) {
2652
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
2653
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2654
- ParameterCommitInput,
2655
- {
2656
- id,
2657
- inputMode: "decimal",
2658
- "aria-label": ariaLabel ?? (0, import_parameters.parameterLabel)(field),
2659
- value: plainNumber(field, value),
2660
- disabled: disabled || field.readOnly,
2661
- className: `${parameterInputClass} ${field.unit ? "pr-6" : ""}`,
2662
- onCommit: (text, input) => {
2663
- const n = (0, import_parameters.parseParameterNumberInput)(field, text);
2664
- if (n === null || n === value) input.value = plainNumber(field, value);
2665
- else onChange(n);
2666
- },
2667
- onKeyDown: (e) => {
2668
- if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
2669
- e.preventDefault();
2670
- const step = (0, import_parameters.parameterStep)(field) * (e.shiftKey ? 10 : 1);
2671
- onChange((0, import_parameters.clampParameterNumber)(field, value + (e.key === "ArrowUp" ? step : -step)));
2672
- }
2673
- }
2674
- ),
2675
- field.unit && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
2690
+ function ParameterNumberInput(props) {
2691
+ const { field, value, onChange, disabled, id, components, "aria-label": ariaLabel } = props;
2692
+ const ctx = useParameterComponents();
2693
+ const resolved = resolveParameterComponents(components, ctx);
2694
+ const CustomInput = resolved.input;
2695
+ const plain = plainNumber(field, value);
2696
+ const handleCommit = (text, input) => {
2697
+ const n = (0, import_parameters.parseParameterNumberInput)(field, text);
2698
+ if (n === null || n === value) {
2699
+ if (input) input.value = plain;
2700
+ } else {
2701
+ onChange(n);
2702
+ }
2703
+ };
2704
+ const handleKeyDown = (e) => {
2705
+ if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
2706
+ e.preventDefault();
2707
+ const step = (0, import_parameters.parameterStep)(field) * (e.shiftKey ? 10 : 1);
2708
+ onChange((0, import_parameters.clampParameterNumber)(field, value + (e.key === "ArrowUp" ? step : -step)));
2709
+ };
2710
+ const inputProps = {
2711
+ id,
2712
+ inputMode: "decimal",
2713
+ "aria-label": ariaLabel ?? (0, import_parameters.parameterLabel)(field),
2714
+ value: plain,
2715
+ disabled: disabled || field.readOnly,
2716
+ className: `${parameterInputClass} ${field.unit ? "pr-6" : ""}`,
2717
+ style: parameterInputStyle,
2718
+ onCommit: handleCommit,
2719
+ onKeyDown: handleKeyDown
2720
+ };
2721
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
2722
+ CustomInput ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(CustomInput, { ...inputProps, label: (0, import_parameters.parameterLabel)(field) }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterCommitInput, { ...inputProps }),
2723
+ field.unit && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
2676
2724
  ] });
2677
2725
  }
2678
2726
  function ParameterSlider(props) {
2679
- const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
2680
- const dragging = (0, import_react20.useRef)(false);
2727
+ const { field, value, onChange, onGestureStart, onGestureEnd, disabled, components } = props;
2728
+ const ctx = useParameterComponents();
2729
+ const resolved = resolveParameterComponents(components, ctx);
2730
+ const CustomSlider = resolved.slider;
2731
+ const dragging = (0, import_react21.useRef)(false);
2732
+ const start = () => {
2733
+ if (dragging.current) return;
2734
+ dragging.current = true;
2735
+ onGestureStart?.();
2736
+ };
2681
2737
  const end = () => {
2682
2738
  if (!dragging.current) return;
2683
2739
  dragging.current = false;
2684
2740
  onGestureEnd?.();
2685
2741
  };
2686
- if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterNumberInput, { ...props });
2742
+ if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterNumberInput, { ...props });
2687
2743
  const step = (0, import_parameters.parameterStep)(field);
2688
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
2689
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2744
+ const sliderProps = {
2745
+ "aria-label": (0, import_parameters.parameterLabel)(field),
2746
+ "aria-valuetext": (0, import_parameters.formatParameterNumber)(field, value),
2747
+ // A `control: 'slider'` field may leave out a bound: the range input's own defaults.
2748
+ min: field.min ?? 0,
2749
+ max: field.max ?? 100,
2750
+ step,
2751
+ value,
2752
+ disabled: disabled || field.readOnly,
2753
+ className: rangeClass,
2754
+ style: parameterRangeStyle
2755
+ };
2756
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-2", children: [
2757
+ CustomSlider ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2758
+ CustomSlider,
2759
+ {
2760
+ ...sliderProps,
2761
+ id: props.id ? `${props.id}-slider` : void 0,
2762
+ label: (0, import_parameters.parameterLabel)(field),
2763
+ onChange: (v) => onChange((0, import_parameters.clampParameterNumber)(field, v)),
2764
+ onGestureStart: start,
2765
+ onGestureEnd: end
2766
+ }
2767
+ ) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2690
2768
  "input",
2691
2769
  {
2692
2770
  type: "range",
2693
- "aria-label": (0, import_parameters.parameterLabel)(field),
2694
- "aria-valuetext": (0, import_parameters.formatParameterNumber)(field, value),
2695
- min: field.min,
2696
- max: field.max,
2697
- step,
2698
- value,
2699
- disabled: disabled || field.readOnly,
2700
- className: rangeClass,
2701
- onPointerDown: () => {
2702
- if (dragging.current) return;
2703
- dragging.current = true;
2704
- onGestureStart?.();
2705
- },
2771
+ ...sliderProps,
2772
+ onPointerDown: start,
2706
2773
  onPointerUp: end,
2707
2774
  onPointerCancel: end,
2708
2775
  onBlur: end,
2709
2776
  onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
2710
2777
  }
2711
2778
  ),
2712
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
2779
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
2713
2780
  ] });
2714
2781
  }
2715
2782
  function ParameterToggle({ field, value, onChange, disabled, id }) {
2716
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2783
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2717
2784
  "button",
2718
2785
  {
2719
2786
  type: "button",
@@ -2724,7 +2791,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
2724
2791
  disabled: disabled || field.readOnly,
2725
2792
  onClick: () => onChange(!value),
2726
2793
  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"}`,
2727
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2794
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2728
2795
  "span",
2729
2796
  {
2730
2797
  className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
@@ -2733,11 +2800,15 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
2733
2800
  }
2734
2801
  );
2735
2802
  }
2736
- function ParameterSelect({ field, value, onChange, disabled, id }) {
2803
+ function ParameterSelect(props) {
2804
+ const { field, value, onChange, disabled, id, components } = props;
2805
+ const ctx = useParameterComponents();
2806
+ const resolved = resolveParameterComponents(components, ctx);
2807
+ const CustomSelect = resolved.select;
2737
2808
  const options = (0, import_parameters.getChoiceOptions)(field);
2738
2809
  const off = disabled || field.readOnly;
2739
2810
  if (field.control === "segmented") {
2740
- return /* @__PURE__ */ (0, import_jsx_runtime18.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_runtime18.jsx)(
2811
+ return /* @__PURE__ */ (0, import_jsx_runtime19.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_runtime19.jsx)(
2741
2812
  "button",
2742
2813
  {
2743
2814
  type: "button",
@@ -2752,8 +2823,25 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
2752
2823
  String(o.value)
2753
2824
  )) });
2754
2825
  }
2826
+ if (CustomSelect) {
2827
+ const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters.choiceOptionLabel)(o), description: o.description }));
2828
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2829
+ CustomSelect,
2830
+ {
2831
+ id,
2832
+ label: (0, import_parameters.parameterLabel)(field),
2833
+ "aria-label": (0, import_parameters.parameterLabel)(field),
2834
+ value,
2835
+ options: customOptions,
2836
+ disabled: off,
2837
+ className: parameterInputClass,
2838
+ style: parameterSelectStyle,
2839
+ onChange: (v) => onChange((0, import_parameters.matchParameterOptionValue)(options, v))
2840
+ }
2841
+ );
2842
+ }
2755
2843
  const index = options.findIndex((o) => o.value === value);
2756
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2844
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2757
2845
  "select",
2758
2846
  {
2759
2847
  id,
@@ -2765,22 +2853,23 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
2765
2853
  if (option) onChange(option.value);
2766
2854
  },
2767
2855
  className: parameterInputClass,
2768
- children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: String(i), title: o.description, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
2856
+ style: parameterSelectStyle,
2857
+ children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: String(i), title: o.description, style: parameterSelectStyle, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
2769
2858
  }
2770
2859
  );
2771
2860
  }
2772
2861
  function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
2773
- const [open, setOpen] = (0, import_react20.useState)(false);
2774
- const containerRef = (0, import_react20.useRef)(null);
2775
- const buttonRef = (0, import_react20.useRef)(null);
2776
- const popoverRef = (0, import_react20.useRef)(null);
2862
+ const [open, setOpen] = (0, import_react21.useState)(false);
2863
+ const containerRef = (0, import_react21.useRef)(null);
2864
+ const buttonRef = (0, import_react21.useRef)(null);
2865
+ const popoverRef = (0, import_react21.useRef)(null);
2777
2866
  const alpha = !!field.alpha;
2778
2867
  const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
2779
2868
  const rgb = hex.slice(0, 7);
2780
2869
  const shown = alpha ? hex : rgb;
2781
2870
  const off = disabled || field.readOnly;
2782
2871
  const name = (0, import_parameters.parameterLabel)(field);
2783
- (0, import_react20.useEffect)(() => {
2872
+ (0, import_react21.useEffect)(() => {
2784
2873
  if (!open) return;
2785
2874
  const onPointerDown = (e) => {
2786
2875
  if (containerRef.current && !containerRef.current.contains(e.target)) {
@@ -2801,9 +2890,9 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
2801
2890
  window.removeEventListener("keydown", onKeyDown, true);
2802
2891
  };
2803
2892
  }, [open]);
2804
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
2805
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
2806
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2893
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
2894
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-2", children: [
2895
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2807
2896
  "button",
2808
2897
  {
2809
2898
  ref: buttonRef,
@@ -2814,10 +2903,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
2814
2903
  disabled: off,
2815
2904
  onClick: () => setOpen((prev) => !prev),
2816
2905
  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",
2817
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
2906
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
2818
2907
  }
2819
2908
  ),
2820
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2909
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2821
2910
  ParameterCommitInput,
2822
2911
  {
2823
2912
  id,
@@ -2833,7 +2922,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
2833
2922
  }
2834
2923
  )
2835
2924
  ] }),
2836
- open && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2925
+ open && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2837
2926
  "div",
2838
2927
  {
2839
2928
  ref: popoverRef,
@@ -2847,7 +2936,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
2847
2936
  },
2848
2937
  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",
2849
2938
  style: { background: "var(--popover, var(--background, #fff))" },
2850
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2939
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2851
2940
  ColorPicker,
2852
2941
  {
2853
2942
  value: shown,
@@ -2863,13 +2952,13 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
2863
2952
  )
2864
2953
  ] });
2865
2954
  }
2866
- function ParameterVector({ field, value, onChange, disabled, id }) {
2955
+ function ParameterVector({ field, value, onChange, disabled, id, components }) {
2867
2956
  const size = (0, import_parameters.vectorSize)(field);
2868
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
2957
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
2869
2958
  const component = (0, import_parameters.vectorComponentField)(field, i);
2870
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
2871
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
2872
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2959
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
2960
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
2961
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2873
2962
  ParameterNumberInput,
2874
2963
  {
2875
2964
  field: component,
@@ -2877,6 +2966,7 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
2877
2966
  id: i === 0 ? id : void 0,
2878
2967
  "aria-label": `${(0, import_parameters.parameterLabel)(field)} ${component.label}`,
2879
2968
  disabled: disabled || field.readOnly,
2969
+ components,
2880
2970
  onChange: (n) => onChange(Array.from({ length: size }, (_2, j) => j === i ? n : value[j] ?? 0))
2881
2971
  }
2882
2972
  )
@@ -2886,11 +2976,11 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
2886
2976
  function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
2887
2977
  const off = disabled || field.readOnly;
2888
2978
  const name = (0, import_parameters.parameterLabel)(field);
2889
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-1.5", children: [
2890
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
2891
- /* @__PURE__ */ (0, import_jsx_runtime18.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_runtime18.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
2892
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
2893
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2979
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-1.5", children: [
2980
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-2", children: [
2981
+ /* @__PURE__ */ (0, import_jsx_runtime19.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_runtime19.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
2982
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
2983
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2894
2984
  ParameterCommitInput,
2895
2985
  {
2896
2986
  id,
@@ -2901,30 +2991,48 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
2901
2991
  onCommit: (text) => onChange(text.trim())
2902
2992
  }
2903
2993
  ),
2904
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex gap-1", children: [
2905
- resolveFile && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`, children: [
2906
- "Choose file\u2026",
2907
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2908
- "input",
2909
- {
2910
- type: "file",
2911
- className: "sr-only",
2912
- accept: field.accept ?? "image/*",
2913
- disabled: off,
2914
- "aria-label": `${name} file`,
2915
- onChange: async (e) => {
2916
- const file = e.target.files?.[0];
2917
- e.target.value = "";
2918
- if (file) onChange(await resolveFile(file));
2919
- }
2920
- }
2921
- )
2922
- ] }),
2923
- value && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: parameterButtonClass, disabled: off, onClick: () => onChange(""), "aria-label": `Clear ${name}`, children: "Clear" })
2994
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex gap-1", children: [
2995
+ resolveFile && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
2996
+ "label",
2997
+ {
2998
+ style: parameterButtonStyle,
2999
+ className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
3000
+ children: [
3001
+ "Choose file\u2026",
3002
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3003
+ "input",
3004
+ {
3005
+ type: "file",
3006
+ className: "sr-only",
3007
+ accept: field.accept ?? "image/*",
3008
+ disabled: off,
3009
+ "aria-label": `${name} file`,
3010
+ onChange: async (e) => {
3011
+ const file = e.target.files?.[0];
3012
+ e.target.value = "";
3013
+ if (file) onChange(await resolveFile(file));
3014
+ }
3015
+ }
3016
+ )
3017
+ ]
3018
+ }
3019
+ ),
3020
+ value && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3021
+ "button",
3022
+ {
3023
+ type: "button",
3024
+ style: parameterButtonStyle,
3025
+ className: parameterButtonClass,
3026
+ disabled: off,
3027
+ onClick: () => onChange(""),
3028
+ "aria-label": `Clear ${name}`,
3029
+ children: "Clear"
3030
+ }
3031
+ )
2924
3032
  ] })
2925
3033
  ] })
2926
3034
  ] }),
2927
- field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3035
+ field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2928
3036
  "button",
2929
3037
  {
2930
3038
  type: "button",
@@ -2934,14 +3042,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
2934
3042
  disabled: off,
2935
3043
  onClick: () => onChange(o.url),
2936
3044
  className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
2937
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
3045
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
2938
3046
  },
2939
3047
  o.url
2940
3048
  )) })
2941
3049
  ] });
2942
3050
  }
2943
3051
  function ParameterText({ field, value, onChange, disabled, id }) {
2944
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3052
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2945
3053
  ParameterCommitInput,
2946
3054
  {
2947
3055
  id,
@@ -2960,24 +3068,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
2960
3068
  switch (field.type) {
2961
3069
  case "number":
2962
3070
  case "int":
2963
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
3071
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
2964
3072
  case "boolean":
2965
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
3073
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
2966
3074
  case "choice":
2967
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
3075
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
2968
3076
  case "color":
2969
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
3077
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
2970
3078
  case "vector":
2971
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
3079
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
2972
3080
  case "image":
2973
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
3081
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
2974
3082
  case "text":
2975
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ParameterText, { field, value, onChange: set, ...rest });
3083
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterText, { field, value, onChange: set, ...rest });
2976
3084
  }
2977
3085
  }
2978
3086
 
2979
3087
  // src/effects/EffectParameters.tsx
2980
- var import_jsx_runtime19 = require("react/jsx-runtime");
3088
+ var import_jsx_runtime20 = require("react/jsx-runtime");
2981
3089
  function EffectParameters({
2982
3090
  description,
2983
3091
  values,
@@ -2989,56 +3097,75 @@ function EffectParameters({
2989
3097
  renderControlAddon,
2990
3098
  fonts,
2991
3099
  disabled = false,
2992
- className = ""
3100
+ className = "",
3101
+ components
2993
3102
  }) {
2994
- const fields = (0, import_react21.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
2995
- const idBase = (0, import_react21.useId)();
2996
- const gesture = import_react21.default.useRef(null);
2997
- const count = import_react21.default.useRef(0);
2998
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
2999
- (onPreset || onPresetName) && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
3103
+ const fields = (0, import_react22.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
3104
+ const idBase = (0, import_react22.useId)();
3105
+ const gesture = import_react22.default.useRef(null);
3106
+ const count = import_react22.default.useRef(0);
3107
+ const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
3108
+ const handlePresetSelect = (name) => {
3109
+ if (!name) return;
3110
+ if (onPresetName) {
3111
+ onPresetName(name);
3112
+ } else if (onPreset) {
3113
+ const preset = description.presets.find((p) => p.name === name);
3114
+ if (preset) onPreset({ ...description.defaults, ...preset.values });
3115
+ }
3116
+ };
3117
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
3118
+ (onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3119
+ CustomPresetSelect,
3120
+ {
3121
+ "aria-label": `${description.name} presets`,
3122
+ label: `${description.name} presets`,
3123
+ value: "",
3124
+ disabled,
3125
+ className: "w-full rounded border border-border px-1 py-0.5 text-xs",
3126
+ style: parameterSelectStyle,
3127
+ options: [
3128
+ { value: "", label: "Presets\u2026" },
3129
+ ...description.presets.map((p) => ({ value: p.name, label: p.name }))
3130
+ ],
3131
+ onChange: (name) => handlePresetSelect(String(name))
3132
+ }
3133
+ ) : /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
3000
3134
  "select",
3001
3135
  {
3002
- className: "w-full rounded border border-border bg-transparent px-1 py-0.5 text-xs",
3136
+ className: "w-full rounded border border-border px-1 py-0.5 text-xs",
3137
+ style: parameterSelectStyle,
3003
3138
  "aria-label": `${description.name} presets`,
3004
3139
  value: "",
3005
3140
  disabled,
3006
- onChange: (e) => {
3007
- const name = e.currentTarget.value;
3008
- if (!name) return;
3009
- if (onPresetName) {
3010
- onPresetName(name);
3011
- } else if (onPreset) {
3012
- const preset = description.presets.find((p) => p.name === name);
3013
- if (preset) onPreset({ ...description.defaults, ...preset.values });
3014
- }
3015
- },
3141
+ onChange: (e) => handlePresetSelect(e.currentTarget.value),
3016
3142
  children: [
3017
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: "", children: "Presets\u2026" }),
3018
- description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: p.name, children: p.name }, p.name))
3143
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: "", style: parameterSelectStyle, children: "Presets\u2026" }),
3144
+ description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: p.name, style: parameterSelectStyle, children: p.name }, p.name))
3019
3145
  ]
3020
3146
  }
3021
- ),
3147
+ )),
3022
3148
  fields.map((field) => {
3023
3149
  const label = (0, import_parameters2.parameterLabel)(field);
3024
3150
  const inputId = `${idBase}-${field.id}`;
3025
3151
  const keyed = keyframed?.has(field.id) ?? false;
3026
3152
  const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
3027
3153
  const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
3028
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
3029
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-1.5", children: [
3030
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
3031
- keyed && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
3154
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
3155
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-1.5", children: [
3156
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
3157
+ keyed && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
3032
3158
  renderControlAddon?.(field.id),
3033
- onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime19.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" })
3159
+ onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime20.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" })
3034
3160
  ] }),
3035
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3161
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3036
3162
  ParameterFieldControl,
3037
3163
  {
3038
3164
  field,
3039
3165
  value,
3040
3166
  id: inputId,
3041
3167
  disabled: disabled || keyed,
3168
+ components,
3042
3169
  onChange: (v) => onChange(field.id, v, gesture.current),
3043
3170
  onGestureStart: () => gesture.current = `${idBase}:${field.id}:${++count.current}`,
3044
3171
  onGestureEnd: () => gesture.current = null
@@ -3046,15 +3173,15 @@ function EffectParameters({
3046
3173
  )
3047
3174
  ] }, field.id);
3048
3175
  }),
3049
- !fields.length && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
3176
+ !fields.length && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
3050
3177
  ] });
3051
3178
  }
3052
3179
 
3053
3180
  // src/paint-editor/PaintEffectsPanel.tsx
3054
- var import_jsx_runtime20 = require("react/jsx-runtime");
3181
+ var import_jsx_runtime21 = require("react/jsx-runtime");
3055
3182
  function usePaintEffectsProvider(controller) {
3056
- const [provider, setProvider] = (0, import_react22.useState)(controller.effectsProvider);
3057
- (0, import_react22.useEffect)(() => {
3183
+ const [provider, setProvider] = (0, import_react23.useState)(controller.effectsProvider);
3184
+ (0, import_react23.useEffect)(() => {
3058
3185
  setProvider(controller.effectsProvider);
3059
3186
  return controller.effects.subscribe(setProvider);
3060
3187
  }, [controller]);
@@ -3062,27 +3189,27 @@ function usePaintEffectsProvider(controller) {
3062
3189
  }
3063
3190
  function usePaintEffectsTools(registry, controller, options = {}) {
3064
3191
  const { id, namespace, readOnly, playbackSurface } = options;
3065
- (0, import_react22.useEffect)(() => {
3192
+ (0, import_react23.useEffect)(() => {
3066
3193
  if (!registry) return;
3067
3194
  return registry.register((0, import_paint_editor13.createPaintEffectsToolProvider)(controller, { id, namespace, readOnly, playbackSurface }));
3068
3195
  }, [registry, controller, id, namespace, readOnly, playbackSurface]);
3069
3196
  }
3070
3197
  function Controls({ provider, effect, name, values, apply }) {
3071
3198
  const { description, error } = useEffectDescription(provider, effect);
3072
- const drags = (0, import_react22.useRef)(/* @__PURE__ */ new Set());
3073
- if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("p", { className: "text-[11px] text-slate-400", children: [
3199
+ const drags = (0, import_react23.useRef)(/* @__PURE__ */ new Set());
3200
+ if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("p", { className: "text-[11px] text-slate-400", children: [
3074
3201
  'No effects provider: "',
3075
3202
  name ?? effect,
3076
3203
  '" is kept as it was drawn.'
3077
3204
  ] });
3078
- if (error) return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-amber-400", children: error });
3079
- if (!description) return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
3205
+ if (error) return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-[11px] text-amber-400", children: error });
3206
+ if (!description) return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
3080
3207
  const commit = (gesture) => {
3081
3208
  if (!gesture || drags.current.has(gesture)) return !gesture;
3082
3209
  drags.current.add(gesture);
3083
3210
  return true;
3084
3211
  };
3085
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3212
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3086
3213
  EffectParameters,
3087
3214
  {
3088
3215
  description,
@@ -3103,8 +3230,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
3103
3230
  const state = usePaintEditorState(controller);
3104
3231
  const provider = usePaintEffectsProvider(controller);
3105
3232
  const [error, attempt] = useAttempt();
3106
- const [browse, setBrowse] = (0, import_react22.useState)(null);
3107
- const [busy, setBusy] = (0, import_react22.useState)(false);
3233
+ const [browse, setBrowse] = (0, import_react23.useState)(null);
3234
+ const [busy, setBusy] = (0, import_react23.useState)(false);
3108
3235
  const paper = controller.getPaperEffect();
3109
3236
  const activeId = state.document.activeLayerId;
3110
3237
  const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
@@ -3123,27 +3250,27 @@ var PaintEffectsPanel = ({ controller, className }) => {
3123
3250
  };
3124
3251
  const toggle = (b) => setBrowse(browse === b ? null : b);
3125
3252
  const pixel = active?.type === "pixel";
3126
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
3127
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
3128
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
3129
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
3130
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
3131
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
3132
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "light", onClick: () => toggle("light"), title: "Bake a light, glow or grade into the active layer's dried paint", children: "Light\u2026" })
3253
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
3254
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
3255
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
3256
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
3257
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
3258
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
3259
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "light", onClick: () => toggle("light"), title: "Bake a light, glow or grade into the active layer's dried paint", children: "Light\u2026" })
3133
3260
  ] }),
3134
- !provider && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
3135
- browse && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
3136
- paper && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
3137
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-1", children: [
3138
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { className: "flex-1 truncate", children: [
3261
+ !provider && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
3262
+ browse && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
3263
+ paper && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
3264
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center gap-1", children: [
3265
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "flex-1 truncate", children: [
3139
3266
  "Paper: ",
3140
3267
  paper.name ?? paper.effect
3141
3268
  ] }),
3142
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
3269
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
3143
3270
  ] }),
3144
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex items-center gap-1", children: [
3145
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
3146
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3271
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-1", children: [
3272
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
3273
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3147
3274
  "input",
3148
3275
  {
3149
3276
  type: "range",
@@ -3165,43 +3292,43 @@ var PaintEffectsPanel = ({ controller, className }) => {
3165
3292
  `o${paper.opacity}`
3166
3293
  )
3167
3294
  ] }),
3168
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex items-center gap-1", children: [
3169
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
3170
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("select", { className: "flex-1 rounded bg-slate-800 px-1 py-0.5 text-[11px]", "aria-label": "Effect paper blend", value: paper.blend, onChange: (e) => {
3295
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-1", children: [
3296
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
3297
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("select", { className: "flex-1 rounded bg-slate-800 px-1 py-0.5 text-[11px]", "aria-label": "Effect paper blend", value: paper.blend, onChange: (e) => {
3171
3298
  const blend = e.currentTarget.value;
3172
3299
  run(() => controller.updatePaperEffect({ blend }));
3173
- }, children: import_paint_editor13.PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: b, children: b }, b)) })
3300
+ }, children: import_paint_editor13.PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: b, children: b }, b)) })
3174
3301
  ] }),
3175
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
3302
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
3176
3303
  ] }),
3177
- layerEffect && activeId && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
3178
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-1", children: [
3179
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { className: "flex-1 truncate", children: [
3304
+ layerEffect && activeId && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
3305
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center gap-1", children: [
3306
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "flex-1 truncate", children: [
3180
3307
  "Layer: ",
3181
3308
  layerEffect.name ?? layerEffect.effect
3182
3309
  ] }),
3183
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
3310
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
3184
3311
  ] }),
3185
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
3312
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
3186
3313
  ] }),
3187
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ErrorLine, { error })
3314
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ErrorLine, { error })
3188
3315
  ] });
3189
3316
  };
3190
3317
 
3191
3318
  // src/paint-editor/PaintEditor.tsx
3192
- var import_jsx_runtime21 = require("react/jsx-runtime");
3319
+ var import_jsx_runtime22 = require("react/jsx-runtime");
3193
3320
  var PAINT_CONTROLS = {
3194
3321
  "mixing-pad": '[data-testid="mixing-pad"]',
3195
3322
  lighting: '[data-testid="light-panel"]',
3196
3323
  symmetry: '[aria-label="Symmetry"]'
3197
3324
  };
3198
3325
  var PaintEditor = ({ controller, fileName, height = 720, presence, className, playback, playbackId = "paint", onPlaybackReveal }) => {
3199
- const [tool, setTool] = (0, import_react23.useState)("brush");
3200
- const [tab, setTab] = (0, import_react23.useState)("color");
3201
- const tabRef = (0, import_react23.useRef)(tab);
3326
+ const [tool, setTool] = (0, import_react24.useState)("brush");
3327
+ const [tab, setTab] = (0, import_react24.useState)("color");
3328
+ const tabRef = (0, import_react24.useRef)(tab);
3202
3329
  tabRef.current = tab;
3203
- const rootRef = (0, import_react23.useRef)(null);
3204
- const [ownPresence] = (0, import_react23.useState)(() => new import_paint_editor14.PaintPresence());
3330
+ const rootRef = (0, import_react24.useRef)(null);
3331
+ const [ownPresence] = (0, import_react24.useState)(() => new import_paint_editor14.PaintPresence());
3205
3332
  const ambientPlayback = useAgentPlayback();
3206
3333
  const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
3207
3334
  const viewBox = () => {
@@ -3257,27 +3384,27 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
3257
3384
  const box = rootRef.current?.getBoundingClientRect();
3258
3385
  return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
3259
3386
  };
3260
- const [error, setError] = (0, import_react23.useState)(null);
3387
+ const [error, setError] = (0, import_react24.useState)(null);
3261
3388
  const effects = usePaintEffectsProvider(controller);
3262
3389
  const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
3263
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { ref: rootRef, className: `relative flex flex-col gap-2 rounded-xl border border-slate-800 bg-slate-900 p-2 ${className ?? ""}`, style: { height }, "data-testid": "paint-editor", children: [
3264
- playing && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
3265
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PaintToolbar, { controller, tool, onToolChange: setTool, fileName }),
3266
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex min-h-0 flex-1 gap-2", children: [
3267
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
3268
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col", children: [
3269
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, className: "flex-1 rounded-lg" }),
3270
- error && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
3390
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { ref: rootRef, className: `relative flex flex-col gap-2 rounded-xl border border-slate-800 bg-slate-900 p-2 ${className ?? ""}`, style: { height }, "data-testid": "paint-editor", children: [
3391
+ playing && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
3392
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PaintToolbar, { controller, tool, onToolChange: setTool, fileName }),
3393
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex min-h-0 flex-1 gap-2", children: [
3394
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
3395
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col", children: [
3396
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, className: "flex-1 rounded-lg" }),
3397
+ error && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
3271
3398
  ] }),
3272
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
3273
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", role: "tab", "aria-selected": tab === t, "data-paint-tab": t, className: chip(tab === t), onClick: () => setTab(t), children: t === "color" ? "Colour" : t === "wet" ? "Wet" : t === "paper" ? "Paper" : t === "layers" ? "Layers" : "Effects" }, t)) }),
3274
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
3275
- tab === "color" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ColorPanel, { controller }),
3276
- tab === "wet" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(WetPanel, { controller }),
3277
- tab === "paper" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PaperPanel, { controller }),
3278
- tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PaintLayersPanel, { controller }),
3279
- tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(StickerPanel, { controller }),
3280
- tab === "effects" && effects && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PaintEffectsPanel, { controller })
3399
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
3400
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", role: "tab", "aria-selected": tab === t, "data-paint-tab": t, className: chip(tab === t), onClick: () => setTab(t), children: t === "color" ? "Colour" : t === "wet" ? "Wet" : t === "paper" ? "Paper" : t === "layers" ? "Layers" : "Effects" }, t)) }),
3401
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
3402
+ tab === "color" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ColorPanel, { controller }),
3403
+ tab === "wet" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(WetPanel, { controller }),
3404
+ tab === "paper" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PaperPanel, { controller }),
3405
+ tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PaintLayersPanel, { controller }),
3406
+ tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(StickerPanel, { controller }),
3407
+ tab === "effects" && effects && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PaintEffectsPanel, { controller })
3281
3408
  ] })
3282
3409
  ] })
3283
3410
  ] })