@pixerate/editor-react 0.114.2 → 0.115.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 (42) hide show
  1. package/dist/animation-editor/index.cjs +361 -216
  2. package/dist/animation-editor/index.js +2 -2
  3. package/dist/canvas/index.cjs +539 -394
  4. package/dist/canvas/index.js +2 -2
  5. package/dist/{chunk-2INOKIJN.js → chunk-2KXZLZAS.js} +381 -364
  6. package/dist/{chunk-5LFQ2UQZ.js → chunk-5RPB4WGT.js} +240 -102
  7. package/dist/{chunk-BWEARAWR.js → chunk-6BWTJ3EE.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 +367 -222
  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/controls.d.cts +19 -0
  17. package/dist/image-editor/controls/controls.d.ts +19 -0
  18. package/dist/image-editor/controls/parameterControls.d.cts +4 -0
  19. package/dist/image-editor/controls/parameterControls.d.ts +4 -0
  20. package/dist/image-editor/index.cjs +924 -765
  21. package/dist/image-editor/index.d.cts +1 -1
  22. package/dist/image-editor/index.d.ts +1 -1
  23. package/dist/image-editor/index.js +5 -3
  24. package/dist/index.cjs +1444 -1285
  25. package/dist/index.js +5 -3
  26. package/dist/paint-editor/index.cjs +354 -209
  27. package/dist/paint-editor/index.js +2 -2
  28. package/dist/parameters/ParametersPanel.d.cts +4 -1
  29. package/dist/parameters/ParametersPanel.d.ts +4 -1
  30. package/dist/parameters/controls.d.cts +92 -0
  31. package/dist/parameters/controls.d.ts +92 -0
  32. package/dist/parameters/fields.d.cts +20 -7
  33. package/dist/parameters/fields.d.ts +20 -7
  34. package/dist/parameters/index.cjs +369 -184
  35. package/dist/parameters/index.d.cts +1 -0
  36. package/dist/parameters/index.d.ts +1 -0
  37. package/dist/parameters/index.js +70 -14
  38. package/dist/vector/index.cjs +340 -195
  39. package/dist/vector/index.js +2 -2
  40. package/dist/video-editor/index.cjs +437 -292
  41. package/dist/video-editor/index.js +2 -2
  42. package/package.json +3 -3
@@ -3248,12 +3248,12 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
3248
3248
  }
3249
3249
 
3250
3250
  // src/effects/EffectParameters.tsx
3251
- var import_react22 = __toESM(require("react"), 1);
3251
+ var import_react23 = __toESM(require("react"), 1);
3252
3252
  var import_effects3 = require("@pixerate/editor/effects");
3253
3253
  var import_parameters2 = require("@pixerate/editor/parameters");
3254
3254
 
3255
3255
  // src/parameters/fields.tsx
3256
- var import_react21 = require("react");
3256
+ var import_react22 = require("react");
3257
3257
  var import_parameters = require("@pixerate/editor/parameters");
3258
3258
 
3259
3259
  // src/color/index.ts
@@ -4295,18 +4295,58 @@ function useResolvedColor(value, scheme) {
4295
4295
  // src/color/index.ts
4296
4296
  __reExport(color_exports, require("@pixerate/editor/color"));
4297
4297
 
4298
- // src/parameters/fields.tsx
4298
+ // src/parameters/controls.tsx
4299
+ var import_react21 = require("react");
4299
4300
  var import_jsx_runtime26 = require("react/jsx-runtime");
4301
+ var ParameterComponentsContext = (0, import_react21.createContext)({});
4302
+ function useParameterComponents() {
4303
+ return (0, import_react21.useContext)(ParameterComponentsContext);
4304
+ }
4305
+ function resolveParameterComponents(explicit, context) {
4306
+ return {
4307
+ input: explicit?.input ?? context?.input,
4308
+ slider: explicit?.slider ?? context?.slider,
4309
+ select: explicit?.select ?? context?.select,
4310
+ color: explicit?.color ?? context?.color
4311
+ };
4312
+ }
4313
+
4314
+ // src/parameters/fields.tsx
4315
+ var import_jsx_runtime27 = require("react/jsx-runtime");
4316
+ var parameterInputStyle = import_parameters.parameterThemeStyles.input;
4317
+ var parameterSelectStyle = import_parameters.parameterThemeStyles.select;
4318
+ var parameterButtonStyle = import_parameters.parameterThemeStyles.button;
4319
+ var parameterRangeStyle = import_parameters.parameterThemeStyles.range;
4300
4320
  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";
4301
4321
  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";
4302
4322
  var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
4303
- function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, ...rest }) {
4323
+ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
4324
+ const inputRef = (0, import_react22.useRef)(null);
4325
+ const lastCommitted = (0, import_react22.useRef)(null);
4326
+ (0, import_react22.useLayoutEffect)(() => {
4327
+ lastCommitted.current = null;
4328
+ const el = inputRef.current;
4329
+ if (el && el.value !== value) el.value = value;
4330
+ }, [value]);
4304
4331
  const commit = (el) => {
4305
- if (el.value !== value) onCommit(el.value, el);
4332
+ const text = el.value;
4333
+ if (text === value || text === lastCommitted.current) return;
4334
+ onCommit(text, el);
4335
+ lastCommitted.current = el.value === text ? text : null;
4306
4336
  };
4337
+ const commitRef = (0, import_react22.useRef)(commit);
4338
+ commitRef.current = commit;
4339
+ (0, import_react22.useEffect)(() => {
4340
+ const el = inputRef.current;
4341
+ if (!el) return;
4342
+ const change = () => commitRef.current(el);
4343
+ el.addEventListener("change", change);
4344
+ return () => el.removeEventListener("change", change);
4345
+ }, [multiline]);
4307
4346
  const keyDown = (e) => {
4308
4347
  onKeyDown?.(e);
4309
4348
  if (e.defaultPrevented) return;
4349
+ if (e.key === "Tab") commit(e.currentTarget);
4310
4350
  if (e.key === "Enter" && (!multiline || e.metaKey || e.ctrlKey)) {
4311
4351
  e.preventDefault();
4312
4352
  commit(e.currentTarget);
@@ -4316,86 +4356,114 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
4316
4356
  const props = {
4317
4357
  defaultValue: value,
4318
4358
  className: className ?? parameterInputClass,
4359
+ style: { ...parameterInputStyle, ...style },
4319
4360
  onBlur: (e) => commit(e.currentTarget),
4320
4361
  onKeyDown: keyDown,
4321
4362
  ...rest
4322
4363
  };
4323
- return multiline ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("textarea", { ...props, className: `${props.className} h-auto min-h-[3.5rem] py-1` }, value) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("input", { type: "text", ...props }, value);
4364
+ const forwarded = rest.ref;
4365
+ const setRef = (el) => {
4366
+ inputRef.current = el;
4367
+ if (typeof forwarded === "function") forwarded(el);
4368
+ else if (forwarded) forwarded.current = el;
4369
+ };
4370
+ return multiline ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("textarea", { ...props, ref: setRef, className: `${props.className} h-auto min-h-[3.5rem] py-1` }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("input", { type: "text", ...props, ref: setRef });
4324
4371
  }
4325
4372
  var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
4326
- function ParameterNumberInput({
4327
- field,
4328
- value,
4329
- onChange,
4330
- disabled,
4331
- id,
4332
- "aria-label": ariaLabel
4333
- }) {
4334
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
4335
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4336
- ParameterCommitInput,
4337
- {
4338
- id,
4339
- inputMode: "decimal",
4340
- "aria-label": ariaLabel ?? (0, import_parameters.parameterLabel)(field),
4341
- value: plainNumber(field, value),
4342
- disabled: disabled || field.readOnly,
4343
- className: `${parameterInputClass} ${field.unit ? "pr-6" : ""}`,
4344
- onCommit: (text, input) => {
4345
- const n = (0, import_parameters.parseParameterNumberInput)(field, text);
4346
- if (n === null || n === value) input.value = plainNumber(field, value);
4347
- else onChange(n);
4348
- },
4349
- onKeyDown: (e) => {
4350
- if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
4351
- e.preventDefault();
4352
- const step = (0, import_parameters.parameterStep)(field) * (e.shiftKey ? 10 : 1);
4353
- onChange((0, import_parameters.clampParameterNumber)(field, value + (e.key === "ArrowUp" ? step : -step)));
4354
- }
4355
- }
4356
- ),
4357
- field.unit && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
4373
+ function ParameterNumberInput(props) {
4374
+ const { field, value, onChange, disabled, id, components, "aria-label": ariaLabel } = props;
4375
+ const ctx = useParameterComponents();
4376
+ const resolved = resolveParameterComponents(components, ctx);
4377
+ const CustomInput = resolved.input;
4378
+ const plain = plainNumber(field, value);
4379
+ const handleCommit = (text, input) => {
4380
+ const n = (0, import_parameters.parseParameterNumberInput)(field, text);
4381
+ if (n === null || n === value) {
4382
+ if (input) input.value = plain;
4383
+ } else {
4384
+ onChange(n);
4385
+ }
4386
+ };
4387
+ const handleKeyDown = (e) => {
4388
+ if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
4389
+ e.preventDefault();
4390
+ const step = (0, import_parameters.parameterStep)(field) * (e.shiftKey ? 10 : 1);
4391
+ onChange((0, import_parameters.clampParameterNumber)(field, value + (e.key === "ArrowUp" ? step : -step)));
4392
+ };
4393
+ const inputProps = {
4394
+ id,
4395
+ inputMode: "decimal",
4396
+ "aria-label": ariaLabel ?? (0, import_parameters.parameterLabel)(field),
4397
+ value: plain,
4398
+ disabled: disabled || field.readOnly,
4399
+ className: `${parameterInputClass} ${field.unit ? "pr-6" : ""}`,
4400
+ style: parameterInputStyle,
4401
+ onCommit: handleCommit,
4402
+ onKeyDown: handleKeyDown
4403
+ };
4404
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
4405
+ CustomInput ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CustomInput, { ...inputProps, label: (0, import_parameters.parameterLabel)(field) }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ParameterCommitInput, { ...inputProps }),
4406
+ field.unit && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
4358
4407
  ] });
4359
4408
  }
4360
4409
  function ParameterSlider(props) {
4361
- const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
4362
- const dragging = (0, import_react21.useRef)(false);
4410
+ const { field, value, onChange, onGestureStart, onGestureEnd, disabled, components } = props;
4411
+ const ctx = useParameterComponents();
4412
+ const resolved = resolveParameterComponents(components, ctx);
4413
+ const CustomSlider = resolved.slider;
4414
+ const dragging = (0, import_react22.useRef)(false);
4415
+ const start = () => {
4416
+ if (dragging.current) return;
4417
+ dragging.current = true;
4418
+ onGestureStart?.();
4419
+ };
4363
4420
  const end = () => {
4364
4421
  if (!dragging.current) return;
4365
4422
  dragging.current = false;
4366
4423
  onGestureEnd?.();
4367
4424
  };
4368
- if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterNumberInput, { ...props });
4425
+ if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ParameterNumberInput, { ...props });
4369
4426
  const step = (0, import_parameters.parameterStep)(field);
4370
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-2", children: [
4371
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4427
+ const sliderProps = {
4428
+ "aria-label": (0, import_parameters.parameterLabel)(field),
4429
+ "aria-valuetext": (0, import_parameters.formatParameterNumber)(field, value),
4430
+ // A `control: 'slider'` field may leave out a bound: the range input's own defaults.
4431
+ min: field.min ?? 0,
4432
+ max: field.max ?? 100,
4433
+ step,
4434
+ value,
4435
+ disabled: disabled || field.readOnly,
4436
+ className: rangeClass,
4437
+ style: parameterRangeStyle
4438
+ };
4439
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex items-center gap-2", children: [
4440
+ CustomSlider ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4441
+ CustomSlider,
4442
+ {
4443
+ ...sliderProps,
4444
+ id: props.id ? `${props.id}-slider` : void 0,
4445
+ label: (0, import_parameters.parameterLabel)(field),
4446
+ onChange: (v) => onChange((0, import_parameters.clampParameterNumber)(field, v)),
4447
+ onGestureStart: start,
4448
+ onGestureEnd: end
4449
+ }
4450
+ ) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4372
4451
  "input",
4373
4452
  {
4374
4453
  type: "range",
4375
- "aria-label": (0, import_parameters.parameterLabel)(field),
4376
- "aria-valuetext": (0, import_parameters.formatParameterNumber)(field, value),
4377
- min: field.min,
4378
- max: field.max,
4379
- step,
4380
- value,
4381
- disabled: disabled || field.readOnly,
4382
- className: rangeClass,
4383
- onPointerDown: () => {
4384
- if (dragging.current) return;
4385
- dragging.current = true;
4386
- onGestureStart?.();
4387
- },
4454
+ ...sliderProps,
4455
+ onPointerDown: start,
4388
4456
  onPointerUp: end,
4389
4457
  onPointerCancel: end,
4390
4458
  onBlur: end,
4391
4459
  onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
4392
4460
  }
4393
4461
  ),
4394
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
4462
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
4395
4463
  ] });
4396
4464
  }
4397
4465
  function ParameterToggle({ field, value, onChange, disabled, id }) {
4398
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4466
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4399
4467
  "button",
4400
4468
  {
4401
4469
  type: "button",
@@ -4406,7 +4474,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
4406
4474
  disabled: disabled || field.readOnly,
4407
4475
  onClick: () => onChange(!value),
4408
4476
  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"}`,
4409
- children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4477
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4410
4478
  "span",
4411
4479
  {
4412
4480
  className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
@@ -4415,11 +4483,15 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
4415
4483
  }
4416
4484
  );
4417
4485
  }
4418
- function ParameterSelect({ field, value, onChange, disabled, id }) {
4486
+ function ParameterSelect(props) {
4487
+ const { field, value, onChange, disabled, id, components } = props;
4488
+ const ctx = useParameterComponents();
4489
+ const resolved = resolveParameterComponents(components, ctx);
4490
+ const CustomSelect = resolved.select;
4419
4491
  const options = (0, import_parameters.getChoiceOptions)(field);
4420
4492
  const off = disabled || field.readOnly;
4421
4493
  if (field.control === "segmented") {
4422
- return /* @__PURE__ */ (0, import_jsx_runtime26.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_runtime26.jsx)(
4494
+ return /* @__PURE__ */ (0, import_jsx_runtime27.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_runtime27.jsx)(
4423
4495
  "button",
4424
4496
  {
4425
4497
  type: "button",
@@ -4434,8 +4506,25 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
4434
4506
  String(o.value)
4435
4507
  )) });
4436
4508
  }
4509
+ if (CustomSelect) {
4510
+ const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters.choiceOptionLabel)(o), description: o.description }));
4511
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4512
+ CustomSelect,
4513
+ {
4514
+ id,
4515
+ label: (0, import_parameters.parameterLabel)(field),
4516
+ "aria-label": (0, import_parameters.parameterLabel)(field),
4517
+ value,
4518
+ options: customOptions,
4519
+ disabled: off,
4520
+ className: parameterInputClass,
4521
+ style: parameterSelectStyle,
4522
+ onChange: (v) => onChange((0, import_parameters.matchParameterOptionValue)(options, v))
4523
+ }
4524
+ );
4525
+ }
4437
4526
  const index = options.findIndex((o) => o.value === value);
4438
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4527
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4439
4528
  "select",
4440
4529
  {
4441
4530
  id,
@@ -4447,22 +4536,24 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
4447
4536
  if (option) onChange(option.value);
4448
4537
  },
4449
4538
  className: parameterInputClass,
4450
- children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("option", { value: String(i), title: o.description, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
4539
+ style: parameterSelectStyle,
4540
+ children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("option", { value: String(i), title: o.description, style: parameterSelectStyle, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
4451
4541
  }
4452
4542
  );
4453
4543
  }
4454
- function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
4455
- const [open, setOpen] = (0, import_react21.useState)(false);
4456
- const containerRef = (0, import_react21.useRef)(null);
4457
- const buttonRef = (0, import_react21.useRef)(null);
4458
- const popoverRef = (0, import_react21.useRef)(null);
4544
+ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
4545
+ const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
4546
+ const [open, setOpen] = (0, import_react22.useState)(false);
4547
+ const containerRef = (0, import_react22.useRef)(null);
4548
+ const buttonRef = (0, import_react22.useRef)(null);
4549
+ const popoverRef = (0, import_react22.useRef)(null);
4459
4550
  const alpha = !!field.alpha;
4460
4551
  const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
4461
4552
  const rgb = hex.slice(0, 7);
4462
4553
  const shown = alpha ? hex : rgb;
4463
4554
  const off = disabled || field.readOnly;
4464
4555
  const name = (0, import_parameters.parameterLabel)(field);
4465
- (0, import_react21.useEffect)(() => {
4556
+ (0, import_react22.useEffect)(() => {
4466
4557
  if (!open) return;
4467
4558
  const onPointerDown = (e) => {
4468
4559
  if (containerRef.current && !containerRef.current.contains(e.target)) {
@@ -4483,9 +4574,25 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
4483
4574
  window.removeEventListener("keydown", onKeyDown, true);
4484
4575
  };
4485
4576
  }, [open]);
4486
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
4487
- /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-2", children: [
4488
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4577
+ if (CustomColor) {
4578
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4579
+ CustomColor,
4580
+ {
4581
+ id,
4582
+ value: shown,
4583
+ alpha,
4584
+ swatches: field.swatches,
4585
+ disabled: off,
4586
+ label: name,
4587
+ onChange,
4588
+ onGestureStart,
4589
+ onGestureEnd
4590
+ }
4591
+ );
4592
+ }
4593
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
4594
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex items-center gap-2", children: [
4595
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4489
4596
  "button",
4490
4597
  {
4491
4598
  ref: buttonRef,
@@ -4496,10 +4603,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
4496
4603
  disabled: off,
4497
4604
  onClick: () => setOpen((prev) => !prev),
4498
4605
  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",
4499
- children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
4606
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
4500
4607
  }
4501
4608
  ),
4502
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4609
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4503
4610
  ParameterCommitInput,
4504
4611
  {
4505
4612
  id,
@@ -4515,7 +4622,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
4515
4622
  }
4516
4623
  )
4517
4624
  ] }),
4518
- open && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4625
+ open && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4519
4626
  "div",
4520
4627
  {
4521
4628
  ref: popoverRef,
@@ -4529,7 +4636,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
4529
4636
  },
4530
4637
  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",
4531
4638
  style: { background: "var(--popover, var(--background, #fff))" },
4532
- children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4639
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4533
4640
  ColorPicker,
4534
4641
  {
4535
4642
  value: shown,
@@ -4545,13 +4652,13 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
4545
4652
  )
4546
4653
  ] });
4547
4654
  }
4548
- function ParameterVector({ field, value, onChange, disabled, id }) {
4655
+ function ParameterVector({ field, value, onChange, disabled, id, components }) {
4549
4656
  const size = (0, import_parameters.vectorSize)(field);
4550
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
4657
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
4551
4658
  const component = (0, import_parameters.vectorComponentField)(field, i);
4552
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
4553
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
4554
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4659
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
4660
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
4661
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4555
4662
  ParameterNumberInput,
4556
4663
  {
4557
4664
  field: component,
@@ -4559,6 +4666,7 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
4559
4666
  id: i === 0 ? id : void 0,
4560
4667
  "aria-label": `${(0, import_parameters.parameterLabel)(field)} ${component.label}`,
4561
4668
  disabled: disabled || field.readOnly,
4669
+ components,
4562
4670
  onChange: (n) => onChange(Array.from({ length: size }, (_2, j) => j === i ? n : value[j] ?? 0))
4563
4671
  }
4564
4672
  )
@@ -4568,11 +4676,11 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
4568
4676
  function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
4569
4677
  const off = disabled || field.readOnly;
4570
4678
  const name = (0, import_parameters.parameterLabel)(field);
4571
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "space-y-1.5", children: [
4572
- /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-2", children: [
4573
- /* @__PURE__ */ (0, import_jsx_runtime26.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_runtime26.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
4574
- /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
4575
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4679
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "space-y-1.5", children: [
4680
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex items-center gap-2", children: [
4681
+ /* @__PURE__ */ (0, import_jsx_runtime27.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_runtime27.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
4682
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
4683
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4576
4684
  ParameterCommitInput,
4577
4685
  {
4578
4686
  id,
@@ -4583,30 +4691,48 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
4583
4691
  onCommit: (text) => onChange(text.trim())
4584
4692
  }
4585
4693
  ),
4586
- /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex gap-1", children: [
4587
- resolveFile && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("label", { className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`, children: [
4588
- "Choose file\u2026",
4589
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4590
- "input",
4591
- {
4592
- type: "file",
4593
- className: "sr-only",
4594
- accept: field.accept ?? "image/*",
4595
- disabled: off,
4596
- "aria-label": `${name} file`,
4597
- onChange: async (e) => {
4598
- const file = e.target.files?.[0];
4599
- e.target.value = "";
4600
- if (file) onChange(await resolveFile(file));
4601
- }
4602
- }
4603
- )
4604
- ] }),
4605
- value && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("button", { type: "button", className: parameterButtonClass, disabled: off, onClick: () => onChange(""), "aria-label": `Clear ${name}`, children: "Clear" })
4694
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex gap-1", children: [
4695
+ resolveFile && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
4696
+ "label",
4697
+ {
4698
+ style: parameterButtonStyle,
4699
+ className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
4700
+ children: [
4701
+ "Choose file\u2026",
4702
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4703
+ "input",
4704
+ {
4705
+ type: "file",
4706
+ className: "sr-only",
4707
+ accept: field.accept ?? "image/*",
4708
+ disabled: off,
4709
+ "aria-label": `${name} file`,
4710
+ onChange: async (e) => {
4711
+ const file = e.target.files?.[0];
4712
+ e.target.value = "";
4713
+ if (file) onChange(await resolveFile(file));
4714
+ }
4715
+ }
4716
+ )
4717
+ ]
4718
+ }
4719
+ ),
4720
+ value && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4721
+ "button",
4722
+ {
4723
+ type: "button",
4724
+ style: parameterButtonStyle,
4725
+ className: parameterButtonClass,
4726
+ disabled: off,
4727
+ onClick: () => onChange(""),
4728
+ "aria-label": `Clear ${name}`,
4729
+ children: "Clear"
4730
+ }
4731
+ )
4606
4732
  ] })
4607
4733
  ] })
4608
4734
  ] }),
4609
- field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4735
+ field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4610
4736
  "button",
4611
4737
  {
4612
4738
  type: "button",
@@ -4616,14 +4742,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
4616
4742
  disabled: off,
4617
4743
  onClick: () => onChange(o.url),
4618
4744
  className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
4619
- children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
4745
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
4620
4746
  },
4621
4747
  o.url
4622
4748
  )) })
4623
4749
  ] });
4624
4750
  }
4625
4751
  function ParameterText({ field, value, onChange, disabled, id }) {
4626
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4752
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4627
4753
  ParameterCommitInput,
4628
4754
  {
4629
4755
  id,
@@ -4642,24 +4768,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
4642
4768
  switch (field.type) {
4643
4769
  case "number":
4644
4770
  case "int":
4645
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
4771
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
4646
4772
  case "boolean":
4647
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
4773
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
4648
4774
  case "choice":
4649
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
4775
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
4650
4776
  case "color":
4651
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
4777
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
4652
4778
  case "vector":
4653
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
4779
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
4654
4780
  case "image":
4655
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
4781
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
4656
4782
  case "text":
4657
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ParameterText, { field, value, onChange: set, ...rest });
4783
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ParameterText, { field, value, onChange: set, ...rest });
4658
4784
  }
4659
4785
  }
4660
4786
 
4661
4787
  // src/effects/EffectParameters.tsx
4662
- var import_jsx_runtime27 = require("react/jsx-runtime");
4788
+ var import_jsx_runtime28 = require("react/jsx-runtime");
4663
4789
  function EffectParameters({
4664
4790
  description,
4665
4791
  values,
@@ -4671,56 +4797,75 @@ function EffectParameters({
4671
4797
  renderControlAddon,
4672
4798
  fonts,
4673
4799
  disabled = false,
4674
- className = ""
4800
+ className = "",
4801
+ components
4675
4802
  }) {
4676
- const fields = (0, import_react22.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
4677
- const idBase = (0, import_react22.useId)();
4678
- const gesture = import_react22.default.useRef(null);
4679
- const count = import_react22.default.useRef(0);
4680
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
4681
- (onPreset || onPresetName) && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
4803
+ const fields = (0, import_react23.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
4804
+ const idBase = (0, import_react23.useId)();
4805
+ const gesture = import_react23.default.useRef(null);
4806
+ const count = import_react23.default.useRef(0);
4807
+ const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
4808
+ const handlePresetSelect = (name) => {
4809
+ if (!name) return;
4810
+ if (onPresetName) {
4811
+ onPresetName(name);
4812
+ } else if (onPreset) {
4813
+ const preset = description.presets.find((p) => p.name === name);
4814
+ if (preset) onPreset({ ...description.defaults, ...preset.values });
4815
+ }
4816
+ };
4817
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
4818
+ (onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4819
+ CustomPresetSelect,
4820
+ {
4821
+ "aria-label": `${description.name} presets`,
4822
+ label: `${description.name} presets`,
4823
+ value: "",
4824
+ disabled,
4825
+ className: "w-full rounded border border-border px-1 py-0.5 text-xs",
4826
+ style: parameterSelectStyle,
4827
+ options: [
4828
+ { value: "", label: "Presets\u2026" },
4829
+ ...description.presets.map((p) => ({ value: p.name, label: p.name }))
4830
+ ],
4831
+ onChange: (name) => handlePresetSelect(String(name))
4832
+ }
4833
+ ) : /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
4682
4834
  "select",
4683
4835
  {
4684
- className: "w-full rounded border border-border bg-transparent px-1 py-0.5 text-xs",
4836
+ className: "w-full rounded border border-border px-1 py-0.5 text-xs",
4837
+ style: parameterSelectStyle,
4685
4838
  "aria-label": `${description.name} presets`,
4686
4839
  value: "",
4687
4840
  disabled,
4688
- onChange: (e) => {
4689
- const name = e.currentTarget.value;
4690
- if (!name) return;
4691
- if (onPresetName) {
4692
- onPresetName(name);
4693
- } else if (onPreset) {
4694
- const preset = description.presets.find((p) => p.name === name);
4695
- if (preset) onPreset({ ...description.defaults, ...preset.values });
4696
- }
4697
- },
4841
+ onChange: (e) => handlePresetSelect(e.currentTarget.value),
4698
4842
  children: [
4699
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("option", { value: "", children: "Presets\u2026" }),
4700
- description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("option", { value: p.name, children: p.name }, p.name))
4843
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("option", { value: "", style: parameterSelectStyle, children: "Presets\u2026" }),
4844
+ description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("option", { value: p.name, style: parameterSelectStyle, children: p.name }, p.name))
4701
4845
  ]
4702
4846
  }
4703
- ),
4847
+ )),
4704
4848
  fields.map((field) => {
4705
4849
  const label = (0, import_parameters2.parameterLabel)(field);
4706
4850
  const inputId = `${idBase}-${field.id}`;
4707
4851
  const keyed = keyframed?.has(field.id) ?? false;
4708
4852
  const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
4709
4853
  const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
4710
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
4711
- /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex items-center gap-1.5", children: [
4712
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
4713
- keyed && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
4854
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
4855
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex items-center gap-1.5", children: [
4856
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
4857
+ keyed && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
4714
4858
  renderControlAddon?.(field.id),
4715
- onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime27.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" })
4859
+ onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime28.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" })
4716
4860
  ] }),
4717
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4861
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4718
4862
  ParameterFieldControl,
4719
4863
  {
4720
4864
  field,
4721
4865
  value,
4722
4866
  id: inputId,
4723
4867
  disabled: disabled || keyed,
4868
+ components,
4724
4869
  onChange: (v) => onChange(field.id, v, gesture.current),
4725
4870
  onGestureStart: () => gesture.current = `${idBase}:${field.id}:${++count.current}`,
4726
4871
  onGestureEnd: () => gesture.current = null
@@ -4728,25 +4873,25 @@ function EffectParameters({
4728
4873
  )
4729
4874
  ] }, field.id);
4730
4875
  }),
4731
- !fields.length && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
4876
+ !fields.length && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
4732
4877
  ] });
4733
4878
  }
4734
4879
 
4735
4880
  // src/vector/VectorProviderEffectsPanel.tsx
4736
- var import_react23 = require("react");
4737
- var import_jsx_runtime28 = require("react/jsx-runtime");
4881
+ var import_react24 = require("react");
4882
+ var import_jsx_runtime29 = require("react/jsx-runtime");
4738
4883
  var btn = "rounded border border-border px-1.5 py-0.5 text-[11px] disabled:opacity-40";
4739
4884
  function Controls({ controller, group }) {
4740
4885
  const provider = controller.effectsProvider;
4741
4886
  const tag = group.providerEffect;
4742
4887
  const { description, error } = useEffectDescription(provider, tag.effect);
4743
- const [message, setMessage] = (0, import_react23.useState)(null);
4888
+ const [message, setMessage] = (0, import_react24.useState)(null);
4744
4889
  const run = (work) => void work.then(() => setMessage(null), (e) => setMessage(e instanceof Error ? e.message : String(e)));
4745
- if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider: the shapes are kept as they are." });
4746
- if (error) return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "text-[11px] text-amber-500", children: error });
4747
- if (!description) return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Loading\u2026" });
4748
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
4749
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4890
+ if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider: the shapes are kept as they are." });
4891
+ if (error) return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "text-[11px] text-amber-500", children: error });
4892
+ if (!description) return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Loading\u2026" });
4893
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
4894
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4750
4895
  EffectParameters,
4751
4896
  {
4752
4897
  description,
@@ -4756,18 +4901,18 @@ function Controls({ controller, group }) {
4756
4901
  onPreset: (v) => run(controller.updateVectorEffect(group.id, v))
4757
4902
  }
4758
4903
  ),
4759
- message && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
4904
+ message && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
4760
4905
  ] });
4761
4906
  }
4762
4907
  function VectorProviderEffectsPanel({ controller, className = "" }) {
4763
4908
  const state = useVectorEditorState(controller);
4764
- const provider = (0, import_react23.useSyncExternalStore)(
4909
+ const provider = (0, import_react24.useSyncExternalStore)(
4765
4910
  (cb) => controller.effects.subscribe(cb),
4766
4911
  () => controller.effects.provider,
4767
4912
  () => controller.effects.provider
4768
4913
  );
4769
- const [browse, setBrowse] = (0, import_react23.useState)(false);
4770
- const [message, setMessage] = (0, import_react23.useState)(null);
4914
+ const [browse, setBrowse] = (0, import_react24.useState)(false);
4915
+ const [message, setMessage] = (0, import_react24.useState)(null);
4771
4916
  void state;
4772
4917
  const groups = controller.vectorEffectGroups();
4773
4918
  const selected = groups.filter((g) => state.selection.includes(g.id));
@@ -4775,60 +4920,60 @@ function VectorProviderEffectsPanel({ controller, className = "" }) {
4775
4920
  setMessage(null);
4776
4921
  Promise.resolve().then(work).catch((e) => setMessage(e instanceof Error ? e.message : String(e)));
4777
4922
  };
4778
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("section", { className: `flex flex-col gap-2 text-xs ${className}`, "aria-label": "Vector effects", "data-vector-provider-effects": "", children: [
4779
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex items-center gap-1", children: [
4780
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "flex-1 font-semibold", children: "Effects" }),
4781
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("button", { type: "button", className: btn, disabled: !provider, "aria-pressed": browse, onClick: () => setBrowse(!browse), children: "Add effect\u2026" })
4923
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("section", { className: `flex flex-col gap-2 text-xs ${className}`, "aria-label": "Vector effects", "data-vector-provider-effects": "", children: [
4924
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-1", children: [
4925
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "flex-1 font-semibold", children: "Effects" }),
4926
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("button", { type: "button", className: btn, disabled: !provider, "aria-pressed": browse, onClick: () => setBrowse(!browse), children: "Add effect\u2026" })
4782
4927
  ] }),
4783
- !provider && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Effect groups are kept as shapes." }),
4784
- browse && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(EffectsBrowser, { provider, kinds: ["vector"], title: "Vector effects", onPick: (e) => (setBrowse(false), run(() => controller.addVectorEffect(e.id))) }),
4785
- selected.map((g) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "space-y-1 rounded border border-border p-1", "data-vector-effect-group": g.id, children: [
4786
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex items-center gap-1", children: [
4787
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "min-w-0 flex-1 truncate font-medium", children: g.providerEffect.name ?? g.providerEffect.effect }),
4788
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("button", { type: "button", className: btn, title: "Keep the shapes as a plain group", onClick: () => run(() => controller.detachVectorEffect(g.id)), children: "Detach" })
4928
+ !provider && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Effect groups are kept as shapes." }),
4929
+ browse && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(EffectsBrowser, { provider, kinds: ["vector"], title: "Vector effects", onPick: (e) => (setBrowse(false), run(() => controller.addVectorEffect(e.id))) }),
4930
+ selected.map((g) => /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "space-y-1 rounded border border-border p-1", "data-vector-effect-group": g.id, children: [
4931
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-1", children: [
4932
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "min-w-0 flex-1 truncate font-medium", children: g.providerEffect.name ?? g.providerEffect.effect }),
4933
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("button", { type: "button", className: btn, title: "Keep the shapes as a plain group", onClick: () => run(() => controller.detachVectorEffect(g.id)), children: "Detach" })
4789
4934
  ] }),
4790
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Controls, { controller, group: g })
4935
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Controls, { controller, group: g })
4791
4936
  ] }, g.id)),
4792
- groups.length > 0 && !selected.length && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("p", { className: "text-[11px] text-muted-foreground", children: [
4937
+ groups.length > 0 && !selected.length && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("p", { className: "text-[11px] text-muted-foreground", children: [
4793
4938
  "Select an effect group (",
4794
4939
  groups.length,
4795
4940
  " in the drawing) to change it."
4796
4941
  ] }),
4797
- message && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
4942
+ message && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
4798
4943
  ] });
4799
4944
  }
4800
4945
 
4801
4946
  // src/vector/VectorEditor.tsx
4802
- var import_jsx_runtime29 = require("react/jsx-runtime");
4947
+ var import_jsx_runtime30 = require("react/jsx-runtime");
4803
4948
  function VectorEditor({ controller, tools, showStylePanel = true, height = 520, canvasProps, effects, className }) {
4804
4949
  useEffects(controller, effects);
4805
4950
  const effectsShown = !!effects || controller.vectorEffectGroups().length > 0;
4806
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-vector-editor": "", children: [
4807
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(VectorToolbar, { controller, tools }),
4808
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex min-h-0 flex-col gap-2 md:flex-row", children: [
4809
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "relative min-h-[320px] flex-1 overflow-hidden rounded-md border border-border bg-muted/40", style: { height }, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(VectorCanvas, { controller, ...canvasProps }) }),
4810
- showStylePanel && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex w-full shrink-0 flex-col gap-2 md:w-56", children: [
4811
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(VectorStylePanel, { controller, className: "rounded-md border border-border p-3" }),
4812
- effectsShown && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(VectorProviderEffectsPanel, { controller, className: "rounded-md border border-border p-3" })
4951
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-vector-editor": "", children: [
4952
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(VectorToolbar, { controller, tools }),
4953
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex min-h-0 flex-col gap-2 md:flex-row", children: [
4954
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "relative min-h-[320px] flex-1 overflow-hidden rounded-md border border-border bg-muted/40", style: { height }, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(VectorCanvas, { controller, ...canvasProps }) }),
4955
+ showStylePanel && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex w-full shrink-0 flex-col gap-2 md:w-56", children: [
4956
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(VectorStylePanel, { controller, className: "rounded-md border border-border p-3" }),
4957
+ effectsShown && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(VectorProviderEffectsPanel, { controller, className: "rounded-md border border-border p-3" })
4813
4958
  ] })
4814
4959
  ] })
4815
4960
  ] });
4816
4961
  }
4817
4962
 
4818
4963
  // src/vector/VectorGeneratePanel.tsx
4819
- var import_react24 = require("react");
4964
+ var import_react25 = require("react");
4820
4965
  var import_vector21 = require("@pixerate/editor/vector");
4821
- var import_jsx_runtime30 = require("react/jsx-runtime");
4966
+ var import_jsx_runtime31 = require("react/jsx-runtime");
4822
4967
  var buttonClass17 = "inline-flex h-7 min-w-7 items-center justify-center rounded-md border border-border bg-background px-1.5 text-xs font-medium text-foreground hover:bg-muted disabled:cursor-not-allowed disabled:opacity-40";
4823
4968
  var selectClass15 = "h-7 min-w-0 flex-1 rounded border border-border bg-background px-1 text-xs";
4824
4969
  var AS_LABELS = { color: "Traced in colour", threshold: "Traced in one colour", mosaic: "Mosaic", halftone: "Halftone", lowPoly: "Low poly", hatch: "Engraving" };
4825
4970
  function VectorGeneratePanel({ controller, models, generate, className }) {
4826
4971
  const usable = (0, import_vector21.vectorArtModels)(models);
4827
- const [prompt, setPrompt] = (0, import_react24.useState)("");
4828
- const [model, setModel] = (0, import_react24.useState)("");
4829
- const [as, setAs] = (0, import_react24.useState)("color");
4830
- const [busy, setBusy] = (0, import_react24.useState)(false);
4831
- const [message, setMessage] = (0, import_react24.useState)(null);
4972
+ const [prompt, setPrompt] = (0, import_react25.useState)("");
4973
+ const [model, setModel] = (0, import_react25.useState)("");
4974
+ const [as, setAs] = (0, import_react25.useState)("color");
4975
+ const [busy, setBusy] = (0, import_react25.useState)(false);
4976
+ const [message, setMessage] = (0, import_react25.useState)(null);
4832
4977
  const chosen = usable.find((m) => m.id === model) ?? usable[0];
4833
4978
  if (!usable.length) return null;
4834
4979
  const run = async () => {
@@ -4838,18 +4983,18 @@ function VectorGeneratePanel({ controller, models, generate, className }) {
4838
4983
  setBusy(false);
4839
4984
  setMessage(r.ok ? null : r.message ?? "Generation failed.");
4840
4985
  };
4841
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: `space-y-1 ${className ?? ""}`, "data-vector-generate-panel": "", "aria-label": "Generate", children: [
4842
- /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex items-center gap-1", children: [
4843
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "w-16 text-[11px] font-medium uppercase tracking-wide text-muted-foreground", children: "Generate" }),
4844
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("select", { "aria-label": "Generation model", className: selectClass15, value: chosen.id, onChange: (e) => setModel(e.target.value), children: usable.map((m) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("option", { value: m.id, children: m.name ?? m.id }, m.id)) }),
4845
- chosen.media === "image" && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("select", { "aria-label": "Image to vectors", className: selectClass15, value: as, onChange: (e) => setAs(e.target.value), children: import_vector21.VECTOR_GENERATED_IMAGE_AS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("option", { value: a, children: AS_LABELS[a] }, a)) })
4986
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: `space-y-1 ${className ?? ""}`, "data-vector-generate-panel": "", "aria-label": "Generate", children: [
4987
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex items-center gap-1", children: [
4988
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "w-16 text-[11px] font-medium uppercase tracking-wide text-muted-foreground", children: "Generate" }),
4989
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("select", { "aria-label": "Generation model", className: selectClass15, value: chosen.id, onChange: (e) => setModel(e.target.value), children: usable.map((m) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("option", { value: m.id, children: m.name ?? m.id }, m.id)) }),
4990
+ chosen.media === "image" && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("select", { "aria-label": "Image to vectors", className: selectClass15, value: as, onChange: (e) => setAs(e.target.value), children: import_vector21.VECTOR_GENERATED_IMAGE_AS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("option", { value: a, children: AS_LABELS[a] }, a)) })
4846
4991
  ] }),
4847
- /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex items-center gap-1", children: [
4848
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "w-16" }),
4849
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("input", { type: "text", "aria-label": "Prompt", placeholder: "Describe the art\u2026", className: "h-7 min-w-0 flex-1 rounded border border-border bg-background px-1.5 text-xs", value: prompt, onChange: (e) => setPrompt(e.target.value), onKeyDown: (e) => e.key === "Enter" && prompt.trim() && !busy && void run() }),
4850
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", className: buttonClass17, "data-vector-generate-action": "", disabled: !prompt.trim() || busy, onClick: () => void run(), children: busy ? "Generating\u2026" : "Generate" })
4992
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex items-center gap-1", children: [
4993
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "w-16" }),
4994
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("input", { type: "text", "aria-label": "Prompt", placeholder: "Describe the art\u2026", className: "h-7 min-w-0 flex-1 rounded border border-border bg-background px-1.5 text-xs", value: prompt, onChange: (e) => setPrompt(e.target.value), onKeyDown: (e) => e.key === "Enter" && prompt.trim() && !busy && void run() }),
4995
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("button", { type: "button", className: buttonClass17, "data-vector-generate-action": "", disabled: !prompt.trim() || busy, onClick: () => void run(), children: busy ? "Generating\u2026" : "Generate" })
4851
4996
  ] }),
4852
- message && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "text-[11px] text-red-600", children: message })
4997
+ message && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "text-[11px] text-red-600", children: message })
4853
4998
  ] });
4854
4999
  }
4855
5000
  // Annotate the CommonJS export names for ESM import in node: