@pixerate/editor-react 0.161.0 → 0.163.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.
@@ -43,6 +43,7 @@ __export(paint_editor_exports, {
43
43
  PaintToolbar: () => PaintToolbar,
44
44
  PaperPanel: () => PaperPanel,
45
45
  StickerPanel: () => StickerPanel,
46
+ StrokePanel: () => StrokePanel,
46
47
  WetPanel: () => WetPanel,
47
48
  usePaintDirector: () => usePaintDirector,
48
49
  usePaintEditor: () => usePaintEditor,
@@ -89,6 +90,7 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
89
90
  const [size, setSize] = (0, import_react2.useState)({ width: 800, height: 600 });
90
91
  const measured = (0, import_react2.useRef)(false);
91
92
  const [predicted, setPredicted] = (0, import_react2.useState)([]);
93
+ const [strokeDrag, setStrokeDrag] = (0, import_react2.useState)(null);
92
94
  const presenter = (0, import_react2.useMemo)(() => new import_paint_editor2.PaintCanvasPresenter(controller), [controller]);
93
95
  const gesture = (0, import_react2.useMemo)(
94
96
  () => new import_paint_editor2.PaintGesture(controller, () => {
@@ -130,6 +132,10 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
130
132
  const ctx = water.current?.getContext("2d");
131
133
  if (ctx && typeof ctx.createImageData === "function") (0, import_paint_editor2.drawWaterOverlay)(controller, ctx);
132
134
  }, [state, controller]);
135
+ (0, import_react2.useEffect)(() => {
136
+ const player = controller.playEffects();
137
+ return () => player.stop();
138
+ }, [controller]);
133
139
  (0, import_react2.useEffect)(() => {
134
140
  const el = viewport.current;
135
141
  if (!el) return;
@@ -142,7 +148,7 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
142
148
  }, [gesture]);
143
149
  const report = () => onError?.(gesture.error);
144
150
  const transform = (0, import_paint_editor2.viewCssTransform)(state.view, doc, size);
145
- const lines = showGuides ? (0, import_paint_editor2.guideOverlay)(controller) : [];
151
+ const lines = showGuides ? (0, import_paint_editor2.guideOverlay)(controller, strokeDrag) : [];
146
152
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
147
153
  "div",
148
154
  {
@@ -152,7 +158,7 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
152
158
  "aria-label": "Paint canvas",
153
159
  "data-testid": "paint-canvas",
154
160
  className: `relative overflow-hidden bg-slate-950 outline-none touch-none select-none ${className ?? ""}`,
155
- style: { cursor: tool === "pan" ? "grab" : tool === "eyedropper" ? "copy" : "crosshair" },
161
+ style: { cursor: tool === "pan" ? "grab" : tool === "eyedropper" ? "copy" : tool === "stroke" ? "default" : "crosshair" },
156
162
  onPointerDown: (e) => {
157
163
  viewport.current?.focus();
158
164
  if (gesture.down(e.nativeEvent)) e.target.setPointerCapture?.(e.pointerId);
@@ -161,14 +167,18 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
161
167
  onPointerMove: (e) => {
162
168
  gesture.move(e.nativeEvent);
163
169
  if (gesture.predicted.length || predicted.length) setPredicted(gesture.predicted.map((p) => ({ x: p.x, y: p.y })));
170
+ if (gesture.strokeDrag || strokeDrag) setStrokeDrag(gesture.strokeDrag);
164
171
  },
165
172
  onPointerUp: (e) => {
166
173
  gesture.up(e.nativeEvent);
167
174
  setPredicted([]);
175
+ setStrokeDrag(null);
176
+ report();
168
177
  },
169
178
  onPointerCancel: () => {
170
179
  gesture.cancel();
171
180
  setPredicted([]);
181
+ setStrokeDrag(null);
172
182
  },
173
183
  onKeyDown: (e) => {
174
184
  if ((0, import_paint_editor2.handlePaintShortcut)(controller, gesture, e)) e.preventDefault();
@@ -203,8 +213,8 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
203
213
  y1: l.from.y,
204
214
  x2: l.to.x,
205
215
  y2: l.to.y,
206
- stroke: l.kind === "symmetry" ? "#22d3ee" : l.kind === "stencil" ? "#fbbf24" : l.kind === "sticker" ? "#818cf8" : "#f472b6",
207
- strokeOpacity: l.kind === "symmetry" || l.kind === "stencil" || l.kind === "sticker" ? 0.8 : 0.35,
216
+ stroke: l.kind === "symmetry" ? "#22d3ee" : l.kind === "stencil" ? "#fbbf24" : l.kind === "stroke" || l.kind === "sticker" ? "#818cf8" : "#f472b6",
217
+ strokeOpacity: l.kind === "symmetry" || l.kind === "stencil" || l.kind === "stroke" || l.kind === "sticker" ? 0.8 : 0.35,
208
218
  strokeWidth: 1 / state.view.zoom,
209
219
  strokeDasharray: l.kind === "symmetry" ? `${6 / state.view.zoom} ${4 / state.view.zoom}` : void 0
210
220
  },
@@ -1157,6 +1167,7 @@ var PaintLayersPanel = ({ controller, className }) => {
1157
1167
  /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
1158
1168
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer()), children: "New layer" }),
1159
1169
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer({ type: "group" })), children: "New group" }),
1170
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: button, title: "A layer whose strokes stay editable", onClick: () => attempt(() => controller.addLayer({ type: "strokes" })), children: "New stroke layer" }),
1160
1171
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.duplicateLayer(active.id)), children: "Duplicate" }),
1161
1172
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer up", onClick: () => move(1), children: "\u2191" }),
1162
1173
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer down", onClick: () => move(-1), children: "\u2193" }),
@@ -1204,6 +1215,10 @@ var PaintLayersPanel = ({ controller, className }) => {
1204
1215
  }
1205
1216
  ) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex-1 truncate", onDoubleClick: () => setRenaming(l.id), children: [
1206
1217
  l.type === "group" ? "\u25B8 " : "",
1218
+ l.liveStrokes !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { "aria-label": "Stroke layer", title: `Stroke layer: ${l.liveStrokes} editable strokes`, children: [
1219
+ "\u270E",
1220
+ " "
1221
+ ] }),
1207
1222
  l.name
1208
1223
  ] }),
1209
1224
  l.locks.pixels || l.locks.all ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { title: "Locked", children: "\u{1F512}" }) : null
@@ -1354,13 +1369,80 @@ var StickerPanel = ({ controller, className }) => {
1354
1369
  ] });
1355
1370
  };
1356
1371
 
1372
+ // src/paint-editor/StrokePanel.tsx
1373
+ var import_paint_editor13 = require("@pixerate/editor/paint-editor");
1374
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1375
+ var StrokePanel = ({ controller, className }) => {
1376
+ const state = usePaintEditorState(controller);
1377
+ const [error, attempt] = useAttempt();
1378
+ const layerId = state.document.activeLayerId;
1379
+ const strokes = layerId ? state.document.liveStrokes?.[layerId] : void 0;
1380
+ if (!layerId || !strokes) return null;
1381
+ const index = strokes.findIndex((s) => s.id === state.selectedStroke);
1382
+ const sel = index >= 0 ? strokes[index] : null;
1383
+ const brushes = state.brushes.filter((b) => !(0, import_paint_editor13.liveStrokeRefusal)(b));
1384
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "stroke-panel", children: [
1385
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center justify-between", children: [
1386
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "font-medium text-slate-300", children: [
1387
+ "Strokes (",
1388
+ strokes.length,
1389
+ ")"
1390
+ ] }),
1391
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.rasterizeLiveStrokes(layerId)), children: "Rasterize" })
1392
+ ] }),
1393
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex max-h-24 flex-wrap gap-1 overflow-y-auto", role: "listbox", "aria-label": "Strokes", children: strokes.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1394
+ "button",
1395
+ {
1396
+ type: "button",
1397
+ role: "option",
1398
+ "aria-selected": s.id === state.selectedStroke,
1399
+ title: `${i + 1}. ${s.brush.name} (${s.id})`,
1400
+ className: `h-5 w-5 rounded ring-1 ${s.id === state.selectedStroke ? "ring-indigo-400" : "ring-slate-700"}`,
1401
+ style: { background: s.color },
1402
+ onClick: () => controller.selectStroke(s.id)
1403
+ },
1404
+ s.id
1405
+ )) }),
1406
+ sel && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "stroke-edit", children: [
1407
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
1408
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-slate-400", children: "Brush" }),
1409
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1410
+ "select",
1411
+ {
1412
+ "aria-label": "Stroke brush",
1413
+ value: brushes.some((b) => b.id === sel.brush.id) ? sel.brush.id : "",
1414
+ onChange: (e) => e.target.value && attempt(() => controller.updateStroke(sel.id, { brushId: e.target.value })),
1415
+ className: "max-w-[10rem] rounded bg-slate-800 px-1 py-0.5",
1416
+ children: [
1417
+ !brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: "", children: sel.brush.name }),
1418
+ brushes.map((b) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: b.id, children: b.name }, b.id))
1419
+ ]
1420
+ }
1421
+ )
1422
+ ] }),
1423
+ import_paint_editor13.STROKE_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor13.readPath)(sel.brush, c.path), onCommit: (v) => attempt(() => controller.updateStroke(sel.id, { brush: { tip: { [c.path.split(".")[1]]: v } } })) }, c.path)),
1424
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "flex items-center justify-between", children: [
1425
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-slate-400", children: "Colour" }),
1426
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CommitColorInput, { label: "Stroke colour", value: sel.color, onCommit: (v) => attempt(() => controller.updateStroke(sel.id, { color: v })), className: "h-6 w-10 rounded bg-transparent" })
1427
+ ] }),
1428
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
1429
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => controller.updateStroke(sel.id, { seed: (sel.seed + 1) % 2147483647 })), children: "New seed" }),
1430
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, disabled: index === strokes.length - 1, "aria-label": "Move stroke up", onClick: () => attempt(() => controller.reorderStroke(sel.id, index + 1)), children: "\u2191" }),
1431
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, disabled: index === 0, "aria-label": "Move stroke down", onClick: () => attempt(() => controller.reorderStroke(sel.id, index - 1)), children: "\u2193" }),
1432
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStrokes([sel.id]), controller.selectStroke(null))), children: "Delete" })
1433
+ ] })
1434
+ ] }),
1435
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ErrorLine, { error })
1436
+ ] });
1437
+ };
1438
+
1357
1439
  // src/paint-editor/PaintEditor.tsx
1358
1440
  var import_react23 = require("react");
1359
- var import_paint_editor14 = require("@pixerate/editor/paint-editor");
1441
+ var import_paint_editor15 = require("@pixerate/editor/paint-editor");
1360
1442
 
1361
1443
  // src/playback/AgentPlaybackContext.tsx
1362
1444
  var import_react10 = require("react");
1363
- var import_jsx_runtime12 = require("react/jsx-runtime");
1445
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1364
1446
  var AgentPlaybackContext = (0, import_react10.createContext)(null);
1365
1447
  function useAgentPlayback() {
1366
1448
  return (0, import_react10.useContext)(AgentPlaybackContext);
@@ -1409,12 +1491,12 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
1409
1491
 
1410
1492
  // src/playback/PresenceLayer.tsx
1411
1493
  var import_react12 = __toESM(require("react"), 1);
1412
- var import_jsx_runtime13 = require("react/jsx-runtime");
1494
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1413
1495
  function PresenceLayer({ presence, viewport, clip = true, renderCursor, className = "" }) {
1414
1496
  const { actors } = (0, import_react12.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
1415
1497
  if (!actors.length) return null;
1416
1498
  const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
1417
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1499
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1418
1500
  "div",
1419
1501
  {
1420
1502
  className: `pixerate-presence ${className}`.trim(),
@@ -1428,19 +1510,19 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
1428
1510
  const br = map({ x: a.focus.x + a.focus.width, y: a.focus.y + a.focus.height });
1429
1511
  return { left: tl.x - 4, top: tl.y - 4, width: br.x - tl.x + 8, height: br.y - tl.y + 8 };
1430
1512
  })();
1431
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react12.default.Fragment, { children: [
1432
- ring && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1513
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react12.default.Fragment, { children: [
1514
+ ring && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1433
1515
  "div",
1434
1516
  {
1435
1517
  "data-actor-focus": a.id,
1436
1518
  style: { position: "absolute", ...ring, borderRadius: 8, border: `2px solid ${a.color}`, background: `${a.color}14`, transition: "all 160ms ease-out" }
1437
1519
  }
1438
1520
  ),
1439
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { "data-actor": a.id, style: { position: "absolute", left: 0, top: 0, transform: `translate(${at.x}px, ${at.y}px)` }, children: renderCursor ? renderCursor(a) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
1440
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("svg", { width: "18", height: "20", viewBox: "0 0 12 18", style: { display: "block", transform: a.pressed ? "scale(0.85)" : void 0, transformOrigin: "0 0", filter: "drop-shadow(0 1px 2px rgba(0,0,0,.35))" }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("path", { d: "M0,0 L0,14 L4,10.5 L7,17 L9.5,16 L6.5,9.5 L11.5,9.5 Z", style: { fill: a.color, stroke: "#ffffff", strokeWidth: 1 } }) }),
1441
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { style: { position: "absolute", left: 14, top: 16, display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 4 }, children: [
1442
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { style: { whiteSpace: "nowrap", borderRadius: 999, padding: "1px 7px", fontSize: 11, fontWeight: 600, color: "#ffffff", background: a.color }, children: a.name }),
1443
- a.message && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { "data-actor-message": a.id, style: { width: "max-content", maxWidth: 240, borderRadius: 8, borderTopLeftRadius: 0, padding: "4px 8px", fontSize: 12, color: "#1e293b", background: "#ffffff", boxShadow: "0 4px 12px rgba(15,23,42,.18)" }, children: a.message })
1521
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { "data-actor": a.id, style: { position: "absolute", left: 0, top: 0, transform: `translate(${at.x}px, ${at.y}px)` }, children: renderCursor ? renderCursor(a) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
1522
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("svg", { width: "18", height: "20", viewBox: "0 0 12 18", style: { display: "block", transform: a.pressed ? "scale(0.85)" : void 0, transformOrigin: "0 0", filter: "drop-shadow(0 1px 2px rgba(0,0,0,.35))" }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M0,0 L0,14 L4,10.5 L7,17 L9.5,16 L6.5,9.5 L11.5,9.5 Z", style: { fill: a.color, stroke: "#ffffff", strokeWidth: 1 } }) }),
1523
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { style: { position: "absolute", left: 14, top: 16, display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 4 }, children: [
1524
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { style: { whiteSpace: "nowrap", borderRadius: 999, padding: "1px 7px", fontSize: 11, fontWeight: 600, color: "#ffffff", background: a.color }, children: a.name }),
1525
+ a.message && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { "data-actor-message": a.id, style: { width: "max-content", maxWidth: 240, borderRadius: 8, borderTopLeftRadius: 0, padding: "4px 8px", fontSize: 12, color: "#1e293b", background: "#ffffff", boxShadow: "0 4px 12px rgba(15,23,42,.18)" }, children: a.message })
1444
1526
  ] })
1445
1527
  ] }) })
1446
1528
  ] }, a.id);
@@ -1451,7 +1533,7 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
1451
1533
 
1452
1534
  // src/paint-editor/PaintEffectsPanel.tsx
1453
1535
  var import_react22 = require("react");
1454
- var import_paint_editor13 = require("@pixerate/editor/paint-editor");
1536
+ var import_paint_editor14 = require("@pixerate/editor/paint-editor");
1455
1537
 
1456
1538
  // src/effects/useEffects.ts
1457
1539
  var import_react13 = require("react");
@@ -1475,7 +1557,7 @@ function useEffectDescription(provider, effect) {
1475
1557
  // src/effects/EffectThumbnail.tsx
1476
1558
  var import_react14 = require("react");
1477
1559
  var import_effects = require("@pixerate/editor/effects");
1478
- var import_jsx_runtime14 = require("react/jsx-runtime");
1560
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1479
1561
  var LABELS = { motion: "Motion", camera: "Camera" };
1480
1562
  function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
1481
1563
  const ref = (0, import_react14.useRef)(null);
@@ -1495,13 +1577,13 @@ function EffectThumbnail({ provider, effect, width = 96, height = 54, className
1495
1577
  live = false;
1496
1578
  };
1497
1579
  }, [provider, effect, width, height]);
1498
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1580
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1499
1581
  "div",
1500
1582
  {
1501
1583
  className: `relative overflow-hidden rounded border border-border bg-[repeating-conic-gradient(#8884_0_25%,transparent_0_50%)] bg-[length:12px_12px] ${className}`,
1502
1584
  style: { aspectRatio: `${width} / ${height}` },
1503
1585
  "data-effect-thumbnail": effect.id,
1504
- children: failed ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "absolute inset-0 flex items-center justify-center text-[10px] text-muted-foreground", children: LABELS[effect.kind] ?? "No preview" }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("canvas", { ref, width, height, className: "h-full w-full", "aria-hidden": "true" })
1586
+ children: failed ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "absolute inset-0 flex items-center justify-center text-[10px] text-muted-foreground", children: LABELS[effect.kind] ?? "No preview" }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("canvas", { ref, width, height, className: "h-full w-full", "aria-hidden": "true" })
1505
1587
  }
1506
1588
  );
1507
1589
  }
@@ -1509,7 +1591,7 @@ function EffectThumbnail({ provider, effect, width = 96, height = 54, className
1509
1591
  // src/effects/EffectsBrowser.tsx
1510
1592
  var import_react15 = require("react");
1511
1593
  var import_effects2 = require("@pixerate/editor/effects");
1512
- var import_jsx_runtime15 = require("react/jsx-runtime");
1594
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1513
1595
  function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, title = "Effects", className = "" }) {
1514
1596
  const [all, setAll] = (0, import_react15.useState)([]);
1515
1597
  const [query, setQuery] = (0, import_react15.useState)("");
@@ -1540,11 +1622,11 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
1540
1622
  const categories = (0, import_react15.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds]);
1541
1623
  const shown = found.filter(allowed);
1542
1624
  if (!provider)
1543
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: `rounded-md border border-dashed border-border p-3 text-xs text-muted-foreground ${className}`, "data-effects-browser": "", "data-effects-unavailable": "", children: "No effects provider is registered, so effects cannot be added. Effects already in the document are kept." });
1544
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("section", { className: `flex flex-col gap-2 ${className}`, "data-effects-browser": "", "aria-label": "Effects browser", children: [
1545
- title && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("h3", { className: "text-xs font-semibold", children: title }),
1546
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
1547
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1625
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: `rounded-md border border-dashed border-border p-3 text-xs text-muted-foreground ${className}`, "data-effects-browser": "", "data-effects-unavailable": "", children: "No effects provider is registered, so effects cannot be added. Effects already in the document are kept." });
1626
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("section", { className: `flex flex-col gap-2 ${className}`, "data-effects-browser": "", "aria-label": "Effects browser", children: [
1627
+ title && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("h3", { className: "text-xs font-semibold", children: title }),
1628
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
1629
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1548
1630
  "input",
1549
1631
  {
1550
1632
  type: "search",
@@ -1555,17 +1637,17 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
1555
1637
  onChange: (e) => setQuery(e.currentTarget.value)
1556
1638
  }
1557
1639
  ),
1558
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-xs", "aria-label": "Category", value: category, onChange: (e) => setCategory(e.currentTarget.value), children: [
1559
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: "", children: "All categories" }),
1560
- categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: c, children: c }, c))
1640
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-xs", "aria-label": "Category", value: category, onChange: (e) => setCategory(e.currentTarget.value), children: [
1641
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "", children: "All categories" }),
1642
+ categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: c, children: c }, c))
1561
1643
  ] }),
1562
- uses && uses.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-xs", "aria-label": "Use", value: use, onChange: (e) => setUse(e.currentTarget.value), children: [
1563
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: "", children: "Any use" }),
1564
- uses.map((u) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: u, children: import_effects2.EFFECT_USE_LABELS[u] }, u))
1644
+ uses && uses.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-xs", "aria-label": "Use", value: use, onChange: (e) => setUse(e.currentTarget.value), children: [
1645
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "", children: "Any use" }),
1646
+ uses.map((u) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: u, children: import_effects2.EFFECT_USE_LABELS[u] }, u))
1565
1647
  ] })
1566
1648
  ] }),
1567
- error && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: error }),
1568
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("ul", { className: "grid max-h-96 grid-cols-[repeat(auto-fill,minmax(6.5rem,1fr))] gap-1.5 overflow-y-auto", role: "list", children: shown.map((e) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
1649
+ error && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: error }),
1650
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("ul", { className: "grid max-h-96 grid-cols-[repeat(auto-fill,minmax(6.5rem,1fr))] gap-1.5 overflow-y-auto", role: "list", children: shown.map((e) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
1569
1651
  "button",
1570
1652
  {
1571
1653
  type: "button",
@@ -1574,13 +1656,13 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
1574
1656
  "data-effect-id": e.id,
1575
1657
  onClick: () => onPick(e),
1576
1658
  children: [
1577
- thumbnails && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(EffectThumbnail, { provider, effect: e }),
1578
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "truncate text-[11px] font-medium", children: e.name }),
1579
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "truncate text-[10px] text-muted-foreground", children: e.uses.map((u) => import_effects2.EFFECT_USE_LABELS[u]).join(" \xB7 ") })
1659
+ thumbnails && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(EffectThumbnail, { provider, effect: e }),
1660
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "truncate text-[11px] font-medium", children: e.name }),
1661
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "truncate text-[10px] text-muted-foreground", children: e.uses.map((u) => import_effects2.EFFECT_USE_LABELS[u]).join(" \xB7 ") })
1580
1662
  ]
1581
1663
  }
1582
1664
  ) }, e.id)) }),
1583
- !shown.length && !error && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects match." })
1665
+ !shown.length && !error && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects match." })
1584
1666
  ] });
1585
1667
  }
1586
1668
 
@@ -1605,7 +1687,7 @@ __export(color_exports, {
1605
1687
  // src/color/ColorPicker.tsx
1606
1688
  var import_react16 = require("react");
1607
1689
  var import_color = require("@pixerate/editor/color");
1608
- var import_jsx_runtime16 = require("react/jsx-runtime");
1690
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1609
1691
  var LOCAL_STORAGE_KEY = "pixerate:color:recent";
1610
1692
  function readLocalRecents() {
1611
1693
  try {
@@ -1812,7 +1894,7 @@ var ColorPicker = ({
1812
1894
  }, [value, contrastAgainst]);
1813
1895
  const currentHex = (0, import_color.pickerStateToHex)(pickerState, alpha);
1814
1896
  const liveDescription = `Selected color: ${value}${contrastResult ? `, contrast ${contrastResult.ratio.toFixed(1)}:1 against ${contrastAgainst}, ${contrastResult.aa ? "passes AA" : "fails AA"}` : ""}`;
1815
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
1897
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
1816
1898
  "div",
1817
1899
  {
1818
1900
  id: pickerId,
@@ -1836,7 +1918,7 @@ var ColorPicker = ({
1836
1918
  pointerEvents: disabled ? "none" : "auto"
1837
1919
  },
1838
1920
  children: [
1839
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1921
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1840
1922
  "span",
1841
1923
  {
1842
1924
  role: "status",
@@ -1855,7 +1937,7 @@ var ColorPicker = ({
1855
1937
  children: liveDescription
1856
1938
  }
1857
1939
  ),
1858
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1940
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1859
1941
  "div",
1860
1942
  {
1861
1943
  role: "slider",
@@ -1877,7 +1959,7 @@ var ColorPicker = ({
1877
1959
  touchAction: "none",
1878
1960
  outline: "none"
1879
1961
  },
1880
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1962
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1881
1963
  "div",
1882
1964
  {
1883
1965
  style: {
@@ -1897,7 +1979,7 @@ var ColorPicker = ({
1897
1979
  )
1898
1980
  }
1899
1981
  ),
1900
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1982
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1901
1983
  "div",
1902
1984
  {
1903
1985
  role: "slider",
@@ -1920,7 +2002,7 @@ var ColorPicker = ({
1920
2002
  touchAction: "none",
1921
2003
  outline: "none"
1922
2004
  },
1923
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2005
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1924
2006
  "div",
1925
2007
  {
1926
2008
  style: {
@@ -1940,7 +2022,7 @@ var ColorPicker = ({
1940
2022
  )
1941
2023
  }
1942
2024
  ),
1943
- alpha && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
2025
+ alpha && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
1944
2026
  "div",
1945
2027
  {
1946
2028
  role: "slider",
@@ -1966,7 +2048,7 @@ var ColorPicker = ({
1966
2048
  overflow: "hidden"
1967
2049
  },
1968
2050
  children: [
1969
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2051
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1970
2052
  "div",
1971
2053
  {
1972
2054
  style: {
@@ -1976,7 +2058,7 @@ var ColorPicker = ({
1976
2058
  }
1977
2059
  }
1978
2060
  ),
1979
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2061
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1980
2062
  "div",
1981
2063
  {
1982
2064
  style: {
@@ -1997,8 +2079,8 @@ var ColorPicker = ({
1997
2079
  ]
1998
2080
  }
1999
2081
  ),
2000
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginTop: "2px" }, children: [
2001
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2082
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginTop: "2px" }, children: [
2083
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2002
2084
  "div",
2003
2085
  {
2004
2086
  style: {
@@ -2012,7 +2094,7 @@ var ColorPicker = ({
2012
2094
  flexShrink: 0,
2013
2095
  border: "1px solid rgba(255,255,255,0.15)"
2014
2096
  },
2015
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2097
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2016
2098
  "div",
2017
2099
  {
2018
2100
  style: {
@@ -2024,7 +2106,7 @@ var ColorPicker = ({
2024
2106
  )
2025
2107
  }
2026
2108
  ),
2027
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2109
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2028
2110
  "input",
2029
2111
  {
2030
2112
  type: "text",
@@ -2054,7 +2136,7 @@ var ColorPicker = ({
2054
2136
  }
2055
2137
  }
2056
2138
  ),
2057
- hasEyeDropper && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2139
+ hasEyeDropper && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2058
2140
  "button",
2059
2141
  {
2060
2142
  type: "button",
@@ -2074,7 +2156,7 @@ var ColorPicker = ({
2074
2156
  color: "inherit",
2075
2157
  cursor: disabled ? "default" : "pointer"
2076
2158
  },
2077
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
2159
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
2078
2160
  "svg",
2079
2161
  {
2080
2162
  width: "14",
@@ -2086,16 +2168,16 @@ var ColorPicker = ({
2086
2168
  strokeLinecap: "round",
2087
2169
  strokeLinejoin: "round",
2088
2170
  children: [
2089
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("path", { d: "m19 11-8-8-8.5 8.5a2.12 2.12 0 0 0 0 3l2.5 2.5 1.5-1.5" }),
2090
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("path", { d: "m5 16-3 3 1 1 3-3" }),
2091
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("path", { d: "m14 6 4 4" })
2171
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("path", { d: "m19 11-8-8-8.5 8.5a2.12 2.12 0 0 0 0 3l2.5 2.5 1.5-1.5" }),
2172
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("path", { d: "m5 16-3 3 1 1 3-3" }),
2173
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("path", { d: "m14 6 4 4" })
2092
2174
  ]
2093
2175
  }
2094
2176
  )
2095
2177
  }
2096
2178
  )
2097
2179
  ] }),
2098
- isClipped && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2180
+ isClipped && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2099
2181
  "div",
2100
2182
  {
2101
2183
  role: "note",
@@ -2111,10 +2193,10 @@ var ColorPicker = ({
2111
2193
  borderRadius: "4px",
2112
2194
  alignSelf: "flex-start"
2113
2195
  },
2114
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { children: "\u26A0 Clipped to sRGB" })
2196
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: "\u26A0 Clipped to sRGB" })
2115
2197
  }
2116
2198
  ),
2117
- contrastResult && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
2199
+ contrastResult && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
2118
2200
  "div",
2119
2201
  {
2120
2202
  style: {
@@ -2128,15 +2210,15 @@ var ColorPicker = ({
2128
2210
  border: "1px solid rgba(255,255,255,0.1)"
2129
2211
  },
2130
2212
  children: [
2131
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { children: [
2213
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { children: [
2132
2214
  "Contrast: ",
2133
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("strong", { children: [
2215
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("strong", { children: [
2134
2216
  contrastResult.ratio.toFixed(2),
2135
2217
  ":1"
2136
2218
  ] })
2137
2219
  ] }),
2138
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { style: { display: "flex", gap: "6px" }, children: [
2139
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
2220
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { style: { display: "flex", gap: "6px" }, children: [
2221
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
2140
2222
  "span",
2141
2223
  {
2142
2224
  style: {
@@ -2149,7 +2231,7 @@ var ColorPicker = ({
2149
2231
  ]
2150
2232
  }
2151
2233
  ),
2152
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
2234
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
2153
2235
  "span",
2154
2236
  {
2155
2237
  style: {
@@ -2166,9 +2248,9 @@ var ColorPicker = ({
2166
2248
  ]
2167
2249
  }
2168
2250
  ),
2169
- swatches && swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
2170
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Palette" }),
2171
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: swatches.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2251
+ swatches && swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
2252
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Palette" }),
2253
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: swatches.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2172
2254
  "button",
2173
2255
  {
2174
2256
  type: "button",
@@ -2194,9 +2276,9 @@ var ColorPicker = ({
2194
2276
  `${color}-${idx}`
2195
2277
  )) })
2196
2278
  ] }),
2197
- activeRecent.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
2198
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Recent" }),
2199
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: activeRecent.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2279
+ activeRecent.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
2280
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Recent" }),
2281
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: activeRecent.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2200
2282
  "button",
2201
2283
  {
2202
2284
  type: "button",
@@ -2229,7 +2311,7 @@ var ColorPicker = ({
2229
2311
  // src/color/DualColorPicker.tsx
2230
2312
  var import_react17 = require("react");
2231
2313
  var import_color2 = require("@pixerate/editor/color");
2232
- var import_jsx_runtime17 = require("react/jsx-runtime");
2314
+ var import_jsx_runtime18 = require("react/jsx-runtime");
2233
2315
  function DualColorPicker({
2234
2316
  value,
2235
2317
  onChange,
@@ -2288,7 +2370,7 @@ function DualColorPicker({
2288
2370
  const activeColor = activeScheme === "dark" ? dual.dark : dual.light;
2289
2371
  const activeContrastTarget = contrastAgainst ? (0, import_color2.resolveColor)(contrastAgainst, activeScheme) ?? void 0 : void 0;
2290
2372
  const dualContrast = contrastAgainst && (0, import_color2.normalizeDualColor)(contrastAgainst) ? (0, import_color2.checkDualColorContrast)(dual, contrastAgainst) : null;
2291
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
2373
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2292
2374
  "div",
2293
2375
  {
2294
2376
  className: `pixerate-dual-color-picker ${className}`,
@@ -2307,7 +2389,7 @@ function DualColorPicker({
2307
2389
  boxSizing: "border-box"
2308
2390
  },
2309
2391
  children: [
2310
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
2392
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2311
2393
  "div",
2312
2394
  {
2313
2395
  role: "tablist",
@@ -2320,7 +2402,7 @@ function DualColorPicker({
2320
2402
  gap: "2px"
2321
2403
  },
2322
2404
  children: [
2323
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2405
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2324
2406
  "button",
2325
2407
  {
2326
2408
  type: "button",
@@ -2343,7 +2425,7 @@ function DualColorPicker({
2343
2425
  children: "Light"
2344
2426
  }
2345
2427
  ),
2346
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2428
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2347
2429
  "button",
2348
2430
  {
2349
2431
  type: "button",
@@ -2369,8 +2451,8 @@ function DualColorPicker({
2369
2451
  ]
2370
2452
  }
2371
2453
  ),
2372
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
2373
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
2454
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
2455
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2374
2456
  "button",
2375
2457
  {
2376
2458
  type: "button",
@@ -2392,7 +2474,7 @@ function DualColorPicker({
2392
2474
  outline: "none"
2393
2475
  },
2394
2476
  children: [
2395
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2477
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2396
2478
  "span",
2397
2479
  {
2398
2480
  style: {
@@ -2404,11 +2486,11 @@ function DualColorPicker({
2404
2486
  }
2405
2487
  }
2406
2488
  ),
2407
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Light" })
2489
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Light" })
2408
2490
  ]
2409
2491
  }
2410
2492
  ),
2411
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
2493
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2412
2494
  "button",
2413
2495
  {
2414
2496
  type: "button",
@@ -2430,7 +2512,7 @@ function DualColorPicker({
2430
2512
  outline: "none"
2431
2513
  },
2432
2514
  children: [
2433
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2515
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2434
2516
  "span",
2435
2517
  {
2436
2518
  style: {
@@ -2442,12 +2524,12 @@ function DualColorPicker({
2442
2524
  }
2443
2525
  }
2444
2526
  ),
2445
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Dark" })
2527
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Dark" })
2446
2528
  ]
2447
2529
  }
2448
2530
  )
2449
2531
  ] }),
2450
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
2532
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2451
2533
  "div",
2452
2534
  {
2453
2535
  style: {
@@ -2458,7 +2540,7 @@ function DualColorPicker({
2458
2540
  padding: "2px 0"
2459
2541
  },
2460
2542
  children: [
2461
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
2543
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2462
2544
  "label",
2463
2545
  {
2464
2546
  htmlFor: sameId,
@@ -2472,7 +2554,7 @@ function DualColorPicker({
2472
2554
  color: "#c4cad4"
2473
2555
  },
2474
2556
  children: [
2475
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2557
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2476
2558
  "input",
2477
2559
  {
2478
2560
  id: sameId,
@@ -2483,11 +2565,11 @@ function DualColorPicker({
2483
2565
  style: { cursor: disabled ? "not-allowed" : "pointer" }
2484
2566
  }
2485
2567
  ),
2486
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: "Same in both" })
2568
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { children: "Same in both" })
2487
2569
  ]
2488
2570
  }
2489
2571
  ),
2490
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2572
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2491
2573
  "button",
2492
2574
  {
2493
2575
  type: "button",
@@ -2509,7 +2591,7 @@ function DualColorPicker({
2509
2591
  ]
2510
2592
  }
2511
2593
  ),
2512
- dualContrast && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
2594
+ dualContrast && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2513
2595
  "div",
2514
2596
  {
2515
2597
  "data-testid": "dual-contrast-summary",
@@ -2523,20 +2605,20 @@ function DualColorPicker({
2523
2605
  color: "#8c95a6"
2524
2606
  },
2525
2607
  children: [
2526
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { children: [
2608
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { children: [
2527
2609
  "Light:",
2528
2610
  " ",
2529
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("strong", { style: { color: dualContrast.light.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
2611
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("strong", { style: { color: dualContrast.light.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
2530
2612
  dualContrast.light.ratio.toFixed(2),
2531
2613
  " (",
2532
2614
  dualContrast.light.level,
2533
2615
  ")"
2534
2616
  ] })
2535
2617
  ] }),
2536
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { children: [
2618
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { children: [
2537
2619
  "Dark:",
2538
2620
  " ",
2539
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("strong", { style: { color: dualContrast.dark.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
2621
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("strong", { style: { color: dualContrast.dark.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
2540
2622
  dualContrast.dark.ratio.toFixed(2),
2541
2623
  " (",
2542
2624
  dualContrast.dark.level,
@@ -2546,7 +2628,7 @@ function DualColorPicker({
2546
2628
  ]
2547
2629
  }
2548
2630
  ),
2549
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2631
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2550
2632
  ColorPicker,
2551
2633
  {
2552
2634
  value: activeColor,
@@ -2634,7 +2716,7 @@ __reExport(color_exports, require("@pixerate/editor/color"));
2634
2716
 
2635
2717
  // src/parameters/controls.tsx
2636
2718
  var import_react19 = require("react");
2637
- var import_jsx_runtime18 = require("react/jsx-runtime");
2719
+ var import_jsx_runtime19 = require("react/jsx-runtime");
2638
2720
  var ParameterComponentsContext = (0, import_react19.createContext)({});
2639
2721
  function useParameterComponents() {
2640
2722
  return (0, import_react19.useContext)(ParameterComponentsContext);
@@ -2649,7 +2731,7 @@ function resolveParameterComponents(explicit, context) {
2649
2731
  }
2650
2732
 
2651
2733
  // src/parameters/fields.tsx
2652
- var import_jsx_runtime19 = require("react/jsx-runtime");
2734
+ var import_jsx_runtime20 = require("react/jsx-runtime");
2653
2735
  var parameterInputStyle = import_parameters.parameterThemeStyles.input;
2654
2736
  var parameterSelectStyle = import_parameters.parameterThemeStyles.select;
2655
2737
  var parameterButtonStyle = import_parameters.parameterThemeStyles.button;
@@ -2704,7 +2786,7 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
2704
2786
  if (typeof forwarded === "function") forwarded(el);
2705
2787
  else if (forwarded) forwarded.current = el;
2706
2788
  };
2707
- 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 });
2789
+ return multiline ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("textarea", { ...props, ref: setRef, className: `${props.className} h-auto min-h-[3.5rem] py-1` }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("input", { type: "text", ...props, ref: setRef });
2708
2790
  }
2709
2791
  var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
2710
2792
  function ParameterNumberInput(props) {
@@ -2738,9 +2820,9 @@ function ParameterNumberInput(props) {
2738
2820
  onCommit: handleCommit,
2739
2821
  onKeyDown: handleKeyDown
2740
2822
  };
2741
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
2742
- CustomInput ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(CustomInput, { ...inputProps, label: (0, import_parameters.parameterLabel)(field) }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterCommitInput, { ...inputProps }),
2743
- 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 })
2823
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
2824
+ CustomInput ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CustomInput, { ...inputProps, label: (0, import_parameters.parameterLabel)(field) }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ParameterCommitInput, { ...inputProps }),
2825
+ field.unit && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
2744
2826
  ] });
2745
2827
  }
2746
2828
  function ParameterSlider(props) {
@@ -2759,7 +2841,7 @@ function ParameterSlider(props) {
2759
2841
  dragging.current = false;
2760
2842
  onGestureEnd?.();
2761
2843
  };
2762
- if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterNumberInput, { ...props });
2844
+ if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ParameterNumberInput, { ...props });
2763
2845
  const step = (0, import_parameters.parameterStep)(field);
2764
2846
  const sliderProps = {
2765
2847
  "aria-label": (0, import_parameters.parameterLabel)(field),
@@ -2773,8 +2855,8 @@ function ParameterSlider(props) {
2773
2855
  className: rangeClass,
2774
2856
  style: parameterRangeStyle
2775
2857
  };
2776
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-2", children: [
2777
- CustomSlider ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2858
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-2", children: [
2859
+ CustomSlider ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2778
2860
  CustomSlider,
2779
2861
  {
2780
2862
  ...sliderProps,
@@ -2784,7 +2866,7 @@ function ParameterSlider(props) {
2784
2866
  onGestureStart: start,
2785
2867
  onGestureEnd: end
2786
2868
  }
2787
- ) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2869
+ ) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2788
2870
  "input",
2789
2871
  {
2790
2872
  type: "range",
@@ -2796,11 +2878,11 @@ function ParameterSlider(props) {
2796
2878
  onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
2797
2879
  }
2798
2880
  ),
2799
- /* @__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` }) })
2881
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
2800
2882
  ] });
2801
2883
  }
2802
2884
  function ParameterToggle({ field, value, onChange, disabled, id }) {
2803
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2885
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2804
2886
  "button",
2805
2887
  {
2806
2888
  type: "button",
@@ -2811,7 +2893,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
2811
2893
  disabled: disabled || field.readOnly,
2812
2894
  onClick: () => onChange(!value),
2813
2895
  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"}`,
2814
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2896
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2815
2897
  "span",
2816
2898
  {
2817
2899
  className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
@@ -2828,7 +2910,7 @@ function ParameterSelect(props) {
2828
2910
  const options = (0, import_parameters.getChoiceOptions)(field);
2829
2911
  const off = disabled || field.readOnly;
2830
2912
  if (field.control === "segmented") {
2831
- 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)(
2913
+ return /* @__PURE__ */ (0, import_jsx_runtime20.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_runtime20.jsx)(
2832
2914
  "button",
2833
2915
  {
2834
2916
  type: "button",
@@ -2845,7 +2927,7 @@ function ParameterSelect(props) {
2845
2927
  }
2846
2928
  if (CustomSelect) {
2847
2929
  const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters.choiceOptionLabel)(o), description: o.description }));
2848
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2930
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2849
2931
  CustomSelect,
2850
2932
  {
2851
2933
  id,
@@ -2861,7 +2943,7 @@ function ParameterSelect(props) {
2861
2943
  );
2862
2944
  }
2863
2945
  const index = options.findIndex((o) => o.value === value);
2864
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2946
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2865
2947
  "select",
2866
2948
  {
2867
2949
  id,
@@ -2874,7 +2956,7 @@ function ParameterSelect(props) {
2874
2956
  },
2875
2957
  className: parameterInputClass,
2876
2958
  style: parameterSelectStyle,
2877
- 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)))
2959
+ children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: String(i), title: o.description, style: parameterSelectStyle, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
2878
2960
  }
2879
2961
  );
2880
2962
  }
@@ -2912,7 +2994,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
2912
2994
  };
2913
2995
  }, [open]);
2914
2996
  if (CustomColor) {
2915
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2997
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2916
2998
  CustomColor,
2917
2999
  {
2918
3000
  id,
@@ -2927,9 +3009,9 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
2927
3009
  }
2928
3010
  );
2929
3011
  }
2930
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
2931
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-2", children: [
2932
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3012
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
3013
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-2", children: [
3014
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2933
3015
  "button",
2934
3016
  {
2935
3017
  ref: buttonRef,
@@ -2940,10 +3022,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
2940
3022
  disabled: off,
2941
3023
  onClick: () => setOpen((prev) => !prev),
2942
3024
  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",
2943
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
3025
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
2944
3026
  }
2945
3027
  ),
2946
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3028
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2947
3029
  ParameterCommitInput,
2948
3030
  {
2949
3031
  id,
@@ -2959,7 +3041,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
2959
3041
  }
2960
3042
  )
2961
3043
  ] }),
2962
- open && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3044
+ open && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2963
3045
  "div",
2964
3046
  {
2965
3047
  ref: popoverRef,
@@ -2973,7 +3055,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
2973
3055
  },
2974
3056
  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",
2975
3057
  style: { background: "var(--popover, var(--background, #fff))" },
2976
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3058
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2977
3059
  ColorPicker,
2978
3060
  {
2979
3061
  value: shown,
@@ -2991,11 +3073,11 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
2991
3073
  }
2992
3074
  function ParameterVector({ field, value, onChange, disabled, id, components }) {
2993
3075
  const size = (0, import_parameters.vectorSize)(field);
2994
- 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) => {
3076
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
2995
3077
  const component = (0, import_parameters.vectorComponentField)(field, i);
2996
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
2997
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
2998
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3078
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
3079
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
3080
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2999
3081
  ParameterNumberInput,
3000
3082
  {
3001
3083
  field: component,
@@ -3013,11 +3095,11 @@ function ParameterVector({ field, value, onChange, disabled, id, components }) {
3013
3095
  function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
3014
3096
  const off = disabled || field.readOnly;
3015
3097
  const name = (0, import_parameters.parameterLabel)(field);
3016
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-1.5", children: [
3017
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-2", children: [
3018
- /* @__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" }) }),
3019
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
3020
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3098
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "space-y-1.5", children: [
3099
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-2", children: [
3100
+ /* @__PURE__ */ (0, import_jsx_runtime20.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_runtime20.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
3101
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
3102
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3021
3103
  ParameterCommitInput,
3022
3104
  {
3023
3105
  id,
@@ -3028,15 +3110,15 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
3028
3110
  onCommit: (text) => onChange(text.trim())
3029
3111
  }
3030
3112
  ),
3031
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex gap-1", children: [
3032
- resolveFile && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
3113
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex gap-1", children: [
3114
+ resolveFile && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
3033
3115
  "label",
3034
3116
  {
3035
3117
  style: parameterButtonStyle,
3036
3118
  className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
3037
3119
  children: [
3038
3120
  "Choose file\u2026",
3039
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3121
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3040
3122
  "input",
3041
3123
  {
3042
3124
  type: "file",
@@ -3054,7 +3136,7 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
3054
3136
  ]
3055
3137
  }
3056
3138
  ),
3057
- value && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3139
+ value && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3058
3140
  "button",
3059
3141
  {
3060
3142
  type: "button",
@@ -3069,7 +3151,7 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
3069
3151
  ] })
3070
3152
  ] })
3071
3153
  ] }),
3072
- 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)(
3154
+ field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3073
3155
  "button",
3074
3156
  {
3075
3157
  type: "button",
@@ -3079,14 +3161,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
3079
3161
  disabled: off,
3080
3162
  onClick: () => onChange(o.url),
3081
3163
  className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
3082
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
3164
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
3083
3165
  },
3084
3166
  o.url
3085
3167
  )) })
3086
3168
  ] });
3087
3169
  }
3088
3170
  function ParameterText({ field, value, onChange, disabled, id }) {
3089
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3171
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3090
3172
  ParameterCommitInput,
3091
3173
  {
3092
3174
  id,
@@ -3105,24 +3187,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
3105
3187
  switch (field.type) {
3106
3188
  case "number":
3107
3189
  case "int":
3108
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
3190
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
3109
3191
  case "boolean":
3110
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
3192
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
3111
3193
  case "choice":
3112
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
3194
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
3113
3195
  case "color":
3114
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
3196
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
3115
3197
  case "vector":
3116
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
3198
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
3117
3199
  case "image":
3118
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
3200
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
3119
3201
  case "text":
3120
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ParameterText, { field, value, onChange: set, ...rest });
3202
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ParameterText, { field, value, onChange: set, ...rest });
3121
3203
  }
3122
3204
  }
3123
3205
 
3124
3206
  // src/effects/EffectParameters.tsx
3125
- var import_jsx_runtime20 = require("react/jsx-runtime");
3207
+ var import_jsx_runtime21 = require("react/jsx-runtime");
3126
3208
  function EffectParameters({
3127
3209
  description,
3128
3210
  values,
@@ -3151,8 +3233,8 @@ function EffectParameters({
3151
3233
  if (preset) onPreset({ ...description.defaults, ...preset.values });
3152
3234
  }
3153
3235
  };
3154
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
3155
- (onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3236
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
3237
+ (onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3156
3238
  CustomPresetSelect,
3157
3239
  {
3158
3240
  "aria-label": `${description.name} presets`,
@@ -3167,7 +3249,7 @@ function EffectParameters({
3167
3249
  ],
3168
3250
  onChange: (name) => handlePresetSelect(String(name))
3169
3251
  }
3170
- ) : /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
3252
+ ) : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3171
3253
  "select",
3172
3254
  {
3173
3255
  className: "w-full rounded border border-border px-1 py-0.5 text-xs",
@@ -3177,8 +3259,8 @@ function EffectParameters({
3177
3259
  disabled,
3178
3260
  onChange: (e) => handlePresetSelect(e.currentTarget.value),
3179
3261
  children: [
3180
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: "", style: parameterSelectStyle, children: "Presets\u2026" }),
3181
- description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: p.name, style: parameterSelectStyle, children: p.name }, p.name))
3262
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "", style: parameterSelectStyle, children: "Presets\u2026" }),
3263
+ description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: p.name, style: parameterSelectStyle, children: p.name }, p.name))
3182
3264
  ]
3183
3265
  }
3184
3266
  )),
@@ -3188,14 +3270,14 @@ function EffectParameters({
3188
3270
  const keyed = keyframed?.has(field.id) ?? false;
3189
3271
  const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
3190
3272
  const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
3191
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
3192
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-1.5", children: [
3193
- /* @__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 }),
3194
- keyed && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
3273
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
3274
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center gap-1.5", children: [
3275
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
3276
+ keyed && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
3195
3277
  renderControlAddon?.(field.id),
3196
- 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" })
3278
+ onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime21.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" })
3197
3279
  ] }),
3198
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3280
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3199
3281
  ParameterFieldControl,
3200
3282
  {
3201
3283
  field,
@@ -3210,12 +3292,12 @@ function EffectParameters({
3210
3292
  )
3211
3293
  ] }, field.id);
3212
3294
  }),
3213
- !fields.length && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
3295
+ !fields.length && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
3214
3296
  ] });
3215
3297
  }
3216
3298
 
3217
3299
  // src/paint-editor/PaintEffectsPanel.tsx
3218
- var import_jsx_runtime21 = require("react/jsx-runtime");
3300
+ var import_jsx_runtime22 = require("react/jsx-runtime");
3219
3301
  function usePaintEffectsProvider(controller) {
3220
3302
  const [provider, setProvider] = (0, import_react22.useState)(controller.effectsProvider);
3221
3303
  (0, import_react22.useEffect)(() => {
@@ -3228,25 +3310,25 @@ function usePaintEffectsTools(registry, controller, options = {}) {
3228
3310
  const { id, namespace, readOnly, playbackSurface } = options;
3229
3311
  (0, import_react22.useEffect)(() => {
3230
3312
  if (!registry) return;
3231
- return registry.register((0, import_paint_editor13.createPaintEffectsToolProvider)(controller, { id, namespace, readOnly, playbackSurface }));
3313
+ return registry.register((0, import_paint_editor14.createPaintEffectsToolProvider)(controller, { id, namespace, readOnly, playbackSurface }));
3232
3314
  }, [registry, controller, id, namespace, readOnly, playbackSurface]);
3233
3315
  }
3234
3316
  function Controls({ provider, effect, name, values, apply }) {
3235
3317
  const { description, error } = useEffectDescription(provider, effect);
3236
3318
  const drags = (0, import_react22.useRef)(/* @__PURE__ */ new Set());
3237
- if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("p", { className: "text-[11px] text-slate-400", children: [
3319
+ if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("p", { className: "text-[11px] text-slate-400", children: [
3238
3320
  'No effects provider: "',
3239
3321
  name ?? effect,
3240
3322
  '" is kept as it was drawn.'
3241
3323
  ] });
3242
- if (error) return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-[11px] text-amber-400", children: error });
3243
- if (!description) return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
3324
+ if (error) return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "text-[11px] text-amber-400", children: error });
3325
+ if (!description) return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
3244
3326
  const commit = (gesture) => {
3245
3327
  if (!gesture || drags.current.has(gesture)) return !gesture;
3246
3328
  drags.current.add(gesture);
3247
3329
  return true;
3248
3330
  };
3249
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3331
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3250
3332
  EffectParameters,
3251
3333
  {
3252
3334
  description,
@@ -3275,6 +3357,12 @@ var PaintEffectsPanel = ({ controller, className }) => {
3275
3357
  const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
3276
3358
  const active = activeId ? controller.getLayer(activeId) : void 0;
3277
3359
  const effectPaint = state.effectPaint;
3360
+ const animation = controller.getAnimation();
3361
+ const playback = state.effectPlayback;
3362
+ const repaint = (patch) => {
3363
+ if (!effectPaint) return;
3364
+ run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: effectPaint.values, time: effectPaint.time, map: effectPaint.map, live: effectPaint.live, ...patch }));
3365
+ };
3278
3366
  const thumbnail = (0, import_react22.useMemo)(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
3279
3367
  const run = (work) => attempt(() => {
3280
3368
  setBusy(true);
@@ -3291,28 +3379,28 @@ var PaintEffectsPanel = ({ controller, className }) => {
3291
3379
  };
3292
3380
  const toggle = (b) => setBrowse(browse === b ? null : b);
3293
3381
  const pixel = active?.type === "pixel";
3294
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
3295
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
3296
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
3297
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
3298
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
3299
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
3300
- /* @__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" }),
3301
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paint", onClick: () => toggle("paint"), title: "Paint with an effect: brushes take each pixel's colour from it", children: "Paint\u2026" })
3382
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
3383
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
3384
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
3385
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
3386
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
3387
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
3388
+ /* @__PURE__ */ (0, import_jsx_runtime22.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" }),
3389
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paint", onClick: () => toggle("paint"), title: "Paint with an effect: brushes take each pixel's colour from it", children: "Paint\u2026" })
3302
3390
  ] }),
3303
- !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." }),
3304
- browse && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
3305
- 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: [
3306
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center gap-1", children: [
3307
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "flex-1 truncate", children: [
3391
+ !provider && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
3392
+ browse && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
3393
+ paper && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
3394
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex items-center gap-1", children: [
3395
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "flex-1 truncate", children: [
3308
3396
  "Paper: ",
3309
3397
  paper.name ?? paper.effect
3310
3398
  ] }),
3311
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
3399
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
3312
3400
  ] }),
3313
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-1", children: [
3314
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
3315
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3401
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", children: [
3402
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
3403
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3316
3404
  "input",
3317
3405
  {
3318
3406
  type: "range",
@@ -3334,43 +3422,89 @@ var PaintEffectsPanel = ({ controller, className }) => {
3334
3422
  `o${paper.opacity}`
3335
3423
  )
3336
3424
  ] }),
3337
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "flex items-center gap-1", children: [
3338
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
3339
- /* @__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) => {
3425
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", children: [
3426
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
3427
+ /* @__PURE__ */ (0, import_jsx_runtime22.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) => {
3340
3428
  const blend = e.currentTarget.value;
3341
3429
  run(() => controller.updatePaperEffect({ blend }));
3342
- }, children: import_paint_editor13.PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: b, children: b }, b)) })
3430
+ }, children: import_paint_editor14.PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: b, children: b }, b)) })
3343
3431
  ] }),
3344
- /* @__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)) })
3432
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
3345
3433
  ] }),
3346
- effectPaint && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
3347
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center gap-1", children: [
3348
- thumbnail ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("img", { src: thumbnail, alt: "", className: "h-5 w-8 rounded object-cover ring-1 ring-slate-700", "data-testid": "effect-paint-thumbnail" }) : null,
3349
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "flex-1 truncate", children: [
3434
+ effectPaint && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
3435
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex items-center gap-1", children: [
3436
+ thumbnail ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("img", { src: thumbnail, alt: "", className: "h-5 w-8 rounded object-cover ring-1 ring-slate-700", "data-testid": "effect-paint-thumbnail" }) : null,
3437
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "flex-1 truncate", children: [
3350
3438
  "Paint: ",
3351
3439
  effectPaint.effect,
3352
3440
  state.effectPaintRendering ? " (rendering\u2026)" : ""
3353
3441
  ] }),
3354
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
3442
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
3355
3443
  ] }),
3356
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: { ...effectPaint.values, ...values }, time: effectPaint.time })) })
3444
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "effect-paint-placement", children: [
3445
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", title: "Lay the effect along each stroke instead of fixing it to the canvas", children: [
3446
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("input", { type: "checkbox", checked: Boolean(effectPaint.map), onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
3447
+ "Along the stroke"
3448
+ ] }),
3449
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", title: "Strokes on a stroke layer keep playing the effect", children: [
3450
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("input", { type: "checkbox", checked: Boolean(effectPaint.live), onChange: (e) => repaint({ live: e.target.checked }) }),
3451
+ "Live"
3452
+ ] })
3453
+ ] }),
3454
+ effectPaint.map && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
3455
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", children: [
3456
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-slate-400", children: "Length" }),
3457
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3458
+ "input",
3459
+ {
3460
+ type: "number",
3461
+ "aria-label": "Effect length along the stroke",
3462
+ min: 16,
3463
+ max: 4096,
3464
+ defaultValue: effectPaint.map.length,
3465
+ onBlur: (e) => Number(e.target.value) !== effectPaint.map.length && repaint({ map: { ...effectPaint.map, length: Number(e.target.value) } }),
3466
+ className: "w-16 rounded bg-slate-800 px-1 py-0.5"
3467
+ },
3468
+ effectPaint.map.length
3469
+ )
3470
+ ] }),
3471
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("select", { "aria-label": "Effect repeat", value: effectPaint.map.repeat, onChange: (e) => repaint({ map: { ...effectPaint.map, repeat: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: [
3472
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: "repeat", children: "Repeat" }),
3473
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: "mirror", children: "Mirror" }),
3474
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: "clamp", children: "Clamp" })
3475
+ ] })
3476
+ ] }),
3477
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
3357
3478
  ] }),
3358
- 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: [
3359
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center gap-1", children: [
3360
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "flex-1 truncate", children: [
3479
+ animation && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex items-center gap-2 rounded border border-slate-700 p-1", "data-effect-part": "playback", children: [
3480
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "flex-1 truncate", children: [
3481
+ "Live paint: ",
3482
+ animation.strokes,
3483
+ " ",
3484
+ animation.strokes === 1 ? "stroke" : "strokes"
3485
+ ] }),
3486
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: button, "aria-pressed": playback.playing, onClick: () => attempt(() => controller.setEffectPlayback({ playing: !playback.playing })), children: playback.playing ? "Pause" : "Play" }),
3487
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", children: [
3488
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-slate-400", children: "fps" }),
3489
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("input", { type: "number", "aria-label": "Live paint frame rate", min: 1, max: 60, value: playback.fps, onChange: (e) => attempt(() => controller.setEffectPlayback({ fps: Math.round(Number(e.target.value)) })), className: "w-12 rounded bg-slate-800 px-1 py-0.5" })
3490
+ ] })
3491
+ ] }),
3492
+ layerEffect && activeId && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
3493
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex items-center gap-1", children: [
3494
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "flex-1 truncate", children: [
3361
3495
  "Layer: ",
3362
3496
  layerEffect.name ?? layerEffect.effect
3363
3497
  ] }),
3364
- /* @__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" })
3498
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
3365
3499
  ] }),
3366
- /* @__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)) })
3500
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
3367
3501
  ] }),
3368
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ErrorLine, { error })
3502
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ErrorLine, { error })
3369
3503
  ] });
3370
3504
  };
3371
3505
 
3372
3506
  // src/paint-editor/PaintEditor.tsx
3373
- var import_jsx_runtime22 = require("react/jsx-runtime");
3507
+ var import_jsx_runtime23 = require("react/jsx-runtime");
3374
3508
  var PAINT_CONTROLS = {
3375
3509
  "mixing-pad": '[data-testid="mixing-pad"]',
3376
3510
  lighting: '[data-testid="light-panel"]',
@@ -3382,7 +3516,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
3382
3516
  const tabRef = (0, import_react23.useRef)(tab);
3383
3517
  tabRef.current = tab;
3384
3518
  const rootRef = (0, import_react23.useRef)(null);
3385
- const [ownPresence] = (0, import_react23.useState)(() => new import_paint_editor14.PaintPresence());
3519
+ const [ownPresence] = (0, import_react23.useState)(() => new import_paint_editor15.PaintPresence());
3386
3520
  const ambientPlayback = useAgentPlayback();
3387
3521
  const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
3388
3522
  const viewBox = () => {
@@ -3393,12 +3527,12 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
3393
3527
  const docToClient = (p) => {
3394
3528
  const r = viewBox();
3395
3529
  if (!r) return null;
3396
- const q = (0, import_paint_editor14.documentToScreen)(controller.getState().view, controller.document.canvas, { width: r.width, height: r.height }, p.x, p.y);
3530
+ const q = (0, import_paint_editor15.documentToScreen)(controller.getState().view, controller.document.canvas, { width: r.width, height: r.height }, p.x, p.y);
3397
3531
  return { x: r.left + q.x, y: r.top + q.y };
3398
3532
  };
3399
3533
  const clientToDoc = (p) => {
3400
3534
  const r = viewBox();
3401
- return r ? (0, import_paint_editor14.screenToDocument)(controller.getState().view, controller.document.canvas, { width: r.width, height: r.height }, p.x - r.left, p.y - r.top) : null;
3535
+ return r ? (0, import_paint_editor15.screenToDocument)(controller.getState().view, controller.document.canvas, { width: r.width, height: r.height }, p.x - r.left, p.y - r.top) : null;
3402
3536
  };
3403
3537
  const elementRect = (selector) => {
3404
3538
  const r = rootRef.current?.querySelector(selector)?.getBoundingClientRect();
@@ -3441,24 +3575,25 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
3441
3575
  const [error, setError] = (0, import_react23.useState)(null);
3442
3576
  const effects = usePaintEffectsProvider(controller);
3443
3577
  const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
3444
- 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: [
3445
- playing && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
3446
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PaintToolbar, { controller, tool, onToolChange: setTool, fileName }),
3447
- /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex min-h-0 flex-1 gap-2", children: [
3448
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
3449
- /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col", children: [
3450
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, className: "flex-1 rounded-lg" }),
3451
- error && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
3578
+ return /* @__PURE__ */ (0, import_jsx_runtime23.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: [
3579
+ playing && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
3580
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PaintToolbar, { controller, tool, onToolChange: setTool, fileName }),
3581
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex min-h-0 flex-1 gap-2", children: [
3582
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
3583
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col", children: [
3584
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, className: "flex-1 rounded-lg" }),
3585
+ error && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
3452
3586
  ] }),
3453
- /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
3454
- /* @__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)) }),
3455
- /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
3456
- tab === "color" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ColorPanel, { controller }),
3457
- tab === "wet" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(WetPanel, { controller }),
3458
- tab === "paper" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PaperPanel, { controller }),
3459
- tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PaintLayersPanel, { controller }),
3460
- tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(StickerPanel, { controller }),
3461
- tab === "effects" && effects && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PaintEffectsPanel, { controller })
3587
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
3588
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ (0, import_jsx_runtime23.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)) }),
3589
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
3590
+ tab === "color" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ColorPanel, { controller }),
3591
+ tab === "wet" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(WetPanel, { controller }),
3592
+ tab === "paper" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PaperPanel, { controller }),
3593
+ tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PaintLayersPanel, { controller }),
3594
+ tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(StrokePanel, { controller }),
3595
+ tab === "layers" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(StickerPanel, { controller }),
3596
+ tab === "effects" && effects && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PaintEffectsPanel, { controller })
3462
3597
  ] })
3463
3598
  ] })
3464
3599
  ] })
@@ -3478,6 +3613,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
3478
3613
  PaintToolbar,
3479
3614
  PaperPanel,
3480
3615
  StickerPanel,
3616
+ StrokePanel,
3481
3617
  WetPanel,
3482
3618
  usePaintDirector,
3483
3619
  usePaintEditor,