@pixerate/editor-react 0.92.0 → 0.93.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/animation-editor/AnimationEditor.d.cts +11 -1
  2. package/dist/animation-editor/AnimationEditor.d.ts +11 -1
  3. package/dist/animation-editor/index.cjs +494 -366
  4. package/dist/animation-editor/index.js +48 -4
  5. package/dist/canvas/index.cjs +3 -2
  6. package/dist/canvas/index.js +4 -4
  7. package/dist/chart/ChartEditor.d.cts +12 -1
  8. package/dist/chart/ChartEditor.d.ts +12 -1
  9. package/dist/chart/index.cjs +187 -29
  10. package/dist/chart/index.js +74 -10
  11. package/dist/{chunk-6MDTFAPY.js → chunk-6YRSQW2V.js} +5 -5
  12. package/dist/chunk-7I73DW4V.js +43 -0
  13. package/dist/{chunk-GML6BYCN.js → chunk-GECXTPSH.js} +53 -3
  14. package/dist/{chunk-ECBC4HD7.js → chunk-IPVWWVSF.js} +3 -2
  15. package/dist/image-editor/index.cjs +3 -2
  16. package/dist/image-editor/index.js +2 -2
  17. package/dist/index.cjs +609 -527
  18. package/dist/index.js +10 -6
  19. package/dist/paint-editor/PaintEditor.d.cts +12 -1
  20. package/dist/paint-editor/PaintEditor.d.ts +12 -1
  21. package/dist/paint-editor/index.cjs +319 -164
  22. package/dist/paint-editor/index.js +84 -11
  23. package/dist/parameters/ParametersPanel.d.cts +11 -1
  24. package/dist/parameters/ParametersPanel.d.ts +11 -1
  25. package/dist/parameters/index.cjs +190 -41
  26. package/dist/parameters/index.js +23 -4
  27. package/dist/playback/index.d.cts +1 -0
  28. package/dist/playback/index.d.ts +1 -0
  29. package/dist/playback/useElementPlaybackSurface.d.cts +19 -0
  30. package/dist/playback/useElementPlaybackSurface.d.ts +19 -0
  31. package/dist/playback/usePlaybackSurface.d.cts +3 -1
  32. package/dist/playback/usePlaybackSurface.d.ts +3 -1
  33. package/dist/spreadsheet/SpreadsheetEditor.d.cts +10 -0
  34. package/dist/spreadsheet/SpreadsheetEditor.d.ts +10 -0
  35. package/dist/spreadsheet/index.cjs +443 -313
  36. package/dist/spreadsheet/index.js +2 -1
  37. package/dist/vector/index.cjs +3 -2
  38. package/dist/vector/index.js +5 -5
  39. package/dist/video-editor/VideoEditor.d.cts +6 -1
  40. package/dist/video-editor/VideoEditor.d.ts +6 -1
  41. package/dist/video-editor/VideoTimeline.d.cts +11 -1
  42. package/dist/video-editor/VideoTimeline.d.ts +11 -1
  43. package/dist/video-editor/index.cjs +463 -332
  44. package/dist/video-editor/index.js +53 -5
  45. package/package.json +3 -3
@@ -283,20 +283,107 @@ function useSpreadsheetEditor(options = {}) {
283
283
  }
284
284
 
285
285
  // src/spreadsheet/SpreadsheetEditor.tsx
286
- var import_react10 = require("react");
286
+ var import_react13 = require("react");
287
287
  var import_spreadsheet8 = require("@pixerate/editor/spreadsheet");
288
288
 
289
+ // src/playback/AgentPlaybackContext.tsx
290
+ var import_react2 = require("react");
291
+ var import_jsx_runtime = require("react/jsx-runtime");
292
+ var AgentPlaybackContext = (0, import_react2.createContext)(null);
293
+ function useAgentPlayback() {
294
+ return (0, import_react2.useContext)(AgentPlaybackContext);
295
+ }
296
+
297
+ // src/playback/usePlaybackSurface.ts
298
+ var import_react3 = require("react");
299
+ var import_tools = require("@pixerate/editor/tools");
300
+ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
301
+ const ambient = useAgentPlayback();
302
+ const target = playback === void 0 ? ambient : playback;
303
+ const [ownPresence] = (0, import_react3.useState)(() => new import_tools.PresenceStore());
304
+ const presence = sharedPresence ?? ownPresence;
305
+ const latest = (0, import_react3.useRef)(options);
306
+ latest.current = options;
307
+ (0, import_react3.useEffect)(() => {
308
+ if (!target || !id) return;
309
+ const o = () => latest.current;
310
+ const surface = {
311
+ presence,
312
+ locate: (ref) => o().locate?.(ref) ?? null,
313
+ bounds: () => o().bounds?.() ?? null,
314
+ visible: () => o().visible?.() ?? true,
315
+ toViewport: (p) => o().toViewport?.(p) ?? p,
316
+ fromViewport: (p) => o().fromViewport?.(p) ?? p,
317
+ beginGesture: (key) => o().beginGesture?.(key),
318
+ endGesture: () => o().endGesture?.(),
319
+ reveal: () => o().reveal?.(),
320
+ open: (ref) => o().open?.(ref),
321
+ get defaultKind() {
322
+ return o().defaultKind;
323
+ }
324
+ };
325
+ const detach = target.attach(id, surface);
326
+ return () => {
327
+ detach();
328
+ for (const a of presence.getState().actors) presence.remove(a.id);
329
+ };
330
+ }, [target, id, presence]);
331
+ return presence;
332
+ }
333
+
334
+ // src/playback/PresenceLayer.tsx
335
+ var import_react4 = __toESM(require("react"), 1);
336
+ var import_jsx_runtime2 = require("react/jsx-runtime");
337
+ function PresenceLayer({ presence, viewport, className = "" }) {
338
+ const { actors } = (0, import_react4.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
339
+ if (!actors.length) return null;
340
+ const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
341
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
342
+ "div",
343
+ {
344
+ className: `pixerate-presence ${className}`.trim(),
345
+ "aria-hidden": "true",
346
+ "data-testid": "presence-layer",
347
+ style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: "hidden", zIndex: 50 },
348
+ children: actors.map((a) => {
349
+ const at = map(a);
350
+ const ring = a.focus && (() => {
351
+ const tl = map(a.focus);
352
+ const br = map({ x: a.focus.x + a.focus.width, y: a.focus.y + a.focus.height });
353
+ return { left: tl.x - 4, top: tl.y - 4, width: br.x - tl.x + 8, height: br.y - tl.y + 8 };
354
+ })();
355
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react4.default.Fragment, { children: [
356
+ ring && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
357
+ "div",
358
+ {
359
+ "data-actor-focus": a.id,
360
+ style: { position: "absolute", ...ring, borderRadius: 8, border: `2px solid ${a.color}`, background: `${a.color}14`, transition: "all 160ms ease-out" }
361
+ }
362
+ ),
363
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-actor": a.id, style: { position: "absolute", left: 0, top: 0, transform: `translate(${at.x}px, ${at.y}px)` }, children: [
364
+ /* @__PURE__ */ (0, import_jsx_runtime2.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_runtime2.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 } }) }),
365
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: { position: "absolute", left: 14, top: 16, display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 4 }, children: [
366
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { whiteSpace: "nowrap", borderRadius: 999, padding: "1px 7px", fontSize: 11, fontWeight: 600, color: "#ffffff", background: a.color }, children: a.name }),
367
+ a.message && /* @__PURE__ */ (0, import_jsx_runtime2.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 })
368
+ ] })
369
+ ] })
370
+ ] }, a.id);
371
+ })
372
+ }
373
+ );
374
+ }
375
+
289
376
  // src/spreadsheet/SpreadsheetContextMenu.tsx
290
- var import_react2 = __toESM(require("react"), 1);
377
+ var import_react5 = __toESM(require("react"), 1);
291
378
  var import_spreadsheet2 = require("@pixerate/editor/spreadsheet");
292
- var import_jsx_runtime = require("react/jsx-runtime");
379
+ var import_jsx_runtime3 = require("react/jsx-runtime");
293
380
  var VIEWPORT_MARGIN = 4;
294
381
  var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "Table actions" }) => {
295
- const menuRef = (0, import_react2.useRef)(null);
296
- const onCloseRef = (0, import_react2.useRef)(onClose);
382
+ const menuRef = (0, import_react5.useRef)(null);
383
+ const onCloseRef = (0, import_react5.useRef)(onClose);
297
384
  onCloseRef.current = onClose;
298
- const [position, setPosition] = (0, import_react2.useState)({ x, y });
299
- (0, import_react2.useLayoutEffect)(() => {
385
+ const [position, setPosition] = (0, import_react5.useState)({ x, y });
386
+ (0, import_react5.useLayoutEffect)(() => {
300
387
  const menu = menuRef.current;
301
388
  if (!menu || typeof window === "undefined") return;
302
389
  const { width, height } = menu.getBoundingClientRect();
@@ -308,7 +395,7 @@ var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "
308
395
  );
309
396
  setPosition((prev) => prev.x === next.x && prev.y === next.y ? prev : next);
310
397
  }, [x, y, items]);
311
- (0, import_react2.useEffect)(() => {
398
+ (0, import_react5.useEffect)(() => {
312
399
  const handlePointer = (e) => {
313
400
  if (!menuRef.current?.contains(e.target)) onCloseRef.current();
314
401
  };
@@ -322,7 +409,7 @@ var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "
322
409
  window.removeEventListener("keydown", handleKey);
323
410
  };
324
411
  }, []);
325
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
412
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
326
413
  "div",
327
414
  {
328
415
  ref: menuRef,
@@ -338,9 +425,9 @@ var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "
338
425
  },
339
426
  onContextMenu: (e) => e.preventDefault(),
340
427
  onKeyDown: (e) => e.stopPropagation(),
341
- children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react2.default.Fragment, { children: [
342
- item.separatorBefore && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { role: "separator", className: "my-1 h-px bg-border" }),
343
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
428
+ children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react5.default.Fragment, { children: [
429
+ item.separatorBefore && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { role: "separator", className: "my-1 h-px bg-border" }),
430
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
344
431
  "button",
345
432
  {
346
433
  type: "button",
@@ -363,8 +450,8 @@ var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "
363
450
  };
364
451
 
365
452
  // src/spreadsheet/SpreadsheetGroupRow.tsx
366
- var import_react3 = __toESM(require("react"), 1);
367
- var import_jsx_runtime2 = require("react/jsx-runtime");
453
+ var import_react6 = __toESM(require("react"), 1);
454
+ var import_jsx_runtime4 = require("react/jsx-runtime");
368
455
  var formatSummary = (value) => value === null ? "\u2013" : String(value);
369
456
  var SpreadsheetGroupRow = ({
370
457
  group,
@@ -378,9 +465,9 @@ var SpreadsheetGroupRow = ({
378
465
  rightSpace = 0
379
466
  }) => {
380
467
  const labelColId = labelColumns.some((c) => c.column.id === groupColId) ? groupColId : labelColumns[0]?.column.id;
381
- const spacer = (key) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { "aria-hidden": "true", "data-spacer": "", style: { padding: 0 } }, key);
382
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { className: "border-b border-border bg-muted/40 font-semibold", "data-group-key": group.key, style: { height: 28 }, children: [
383
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { className: "w-12 min-w-[3rem] sticky left-0 z-10 bg-muted border-r border-border text-center", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
468
+ const spacer = (key) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("td", { "aria-hidden": "true", "data-spacer": "", style: { padding: 0 } }, key);
469
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("tr", { className: "border-b border-border bg-muted/40 font-semibold", "data-group-key": group.key, style: { height: 28 }, children: [
470
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("td", { className: "w-12 min-w-[3rem] sticky left-0 z-10 bg-muted border-r border-border text-center", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
384
471
  "button",
385
472
  {
386
473
  type: "button",
@@ -397,27 +484,27 @@ var SpreadsheetGroupRow = ({
397
484
  columns.map(({ column }, i) => {
398
485
  const summary = group.summaries[column.id];
399
486
  const before = leadingColumns !== void 0 && i === leadingColumns && leftSpace > 0 ? spacer("space:left") : null;
400
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react3.default.Fragment, { children: [
487
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react6.default.Fragment, { children: [
401
488
  before,
402
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { className: "border-r border-border px-2 py-1 truncate max-w-0 text-foreground", style: { maxWidth: 0, overflow: "hidden" }, children: column.id === labelColId ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "truncate", children: [
489
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("td", { className: "border-r border-border px-2 py-1 truncate max-w-0 text-foreground", style: { maxWidth: 0, overflow: "hidden" }, children: column.id === labelColId ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "truncate", children: [
403
490
  group.label,
404
491
  " ",
405
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "font-normal text-muted-foreground", children: [
492
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "font-normal text-muted-foreground", children: [
406
493
  "(",
407
494
  group.rowIndices.length,
408
495
  ")"
409
496
  ] })
410
- ] }) : summary !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "truncate", "data-summary": column.id, children: formatSummary(summary) }) : null })
497
+ ] }) : summary !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "truncate", "data-summary": column.id, children: formatSummary(summary) }) : null })
411
498
  ] }, column.id);
412
499
  }),
413
500
  leadingColumns !== void 0 && leadingColumns >= columns.length && leftSpace > 0 && spacer("space:left"),
414
501
  rightSpace > 0 && spacer("space:right"),
415
- trailingCell && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { className: "w-10 min-w-[2.5rem] bg-muted/10 border-r border-border" })
502
+ trailingCell && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("td", { className: "w-10 min-w-[2.5rem] bg-muted/10 border-r border-border" })
416
503
  ] });
417
504
  };
418
505
 
419
506
  // src/spreadsheet/useSpreadsheetTableInteractions.ts
420
- var import_react4 = require("react");
507
+ var import_react7 = require("react");
421
508
  var import_spreadsheet3 = require("@pixerate/editor/spreadsheet");
422
509
  function gridHasFocus(grid) {
423
510
  if (!grid || typeof document === "undefined") return false;
@@ -426,12 +513,12 @@ function gridHasFocus(grid) {
426
513
  return !(active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement);
427
514
  }
428
515
  function useSpreadsheetClipboard(gridRef, state, readOnly) {
429
- const stateRef = (0, import_react4.useRef)(state);
516
+ const stateRef = (0, import_react7.useRef)(state);
430
517
  stateRef.current = state;
431
- const readOnlyRef = (0, import_react4.useRef)(readOnly);
518
+ const readOnlyRef = (0, import_react7.useRef)(readOnly);
432
519
  readOnlyRef.current = readOnly;
433
- const copiedRef = (0, import_react4.useRef)(false);
434
- (0, import_react4.useEffect)(() => {
520
+ const copiedRef = (0, import_react7.useRef)(false);
521
+ (0, import_react7.useEffect)(() => {
435
522
  if (typeof document === "undefined") return;
436
523
  const handleCopy = (e) => {
437
524
  const s = stateRef.current;
@@ -454,7 +541,7 @@ function useSpreadsheetClipboard(gridRef, state, readOnly) {
454
541
  document.removeEventListener("paste", handlePaste);
455
542
  };
456
543
  }, [gridRef]);
457
- const copyShortcutFallback = (0, import_react4.useCallback)(() => {
544
+ const copyShortcutFallback = (0, import_react7.useCallback)(() => {
458
545
  copiedRef.current = false;
459
546
  setTimeout(() => {
460
547
  if (copiedRef.current) return;
@@ -466,13 +553,13 @@ function useSpreadsheetClipboard(gridRef, state, readOnly) {
466
553
  return { copyShortcutFallback };
467
554
  }
468
555
  function useFillHandle(state) {
469
- const [drag, setDrag] = (0, import_react4.useState)(null);
470
- const dragRef = (0, import_react4.useRef)(drag);
556
+ const [drag, setDrag] = (0, import_react7.useState)(null);
557
+ const dragRef = (0, import_react7.useRef)(drag);
471
558
  dragRef.current = drag;
472
- const stateRef = (0, import_react4.useRef)(state);
559
+ const stateRef = (0, import_react7.useRef)(state);
473
560
  stateRef.current = state;
474
561
  const dragging = drag !== null;
475
- (0, import_react4.useEffect)(() => {
562
+ (0, import_react7.useEffect)(() => {
476
563
  if (!dragging) return;
477
564
  const handleMouseUp = () => {
478
565
  const current = dragRef.current;
@@ -482,13 +569,13 @@ function useFillHandle(state) {
482
569
  window.addEventListener("mouseup", handleMouseUp);
483
570
  return () => window.removeEventListener("mouseup", handleMouseUp);
484
571
  }, [dragging]);
485
- const startFill = (0, import_react4.useCallback)((e) => {
572
+ const startFill = (0, import_react7.useCallback)((e) => {
486
573
  e.preventDefault();
487
574
  e.stopPropagation();
488
575
  const range = stateRef.current.selectedRange;
489
576
  if (range) setDrag({ source: (0, import_spreadsheet3.normalizeRange)(range), target: null });
490
577
  }, []);
491
- const extendFill = (0, import_react4.useCallback)((row, col) => {
578
+ const extendFill = (0, import_react7.useCallback)((row, col) => {
492
579
  const current = dragRef.current;
493
580
  if (!current) return;
494
581
  setDrag({ source: current.source, target: (0, import_spreadsheet3.computeFillTarget)(current.source, { row, col }) });
@@ -497,12 +584,12 @@ function useFillHandle(state) {
497
584
  }
498
585
 
499
586
  // src/spreadsheet/SpreadsheetValidationDialog.tsx
500
- var import_react5 = require("react");
501
- var import_jsx_runtime3 = require("react/jsx-runtime");
587
+ var import_react8 = require("react");
588
+ var import_jsx_runtime5 = require("react/jsx-runtime");
502
589
  var SpreadsheetValidationDialog = ({ prompt, onResolve }) => {
503
590
  const style = prompt.result.errorStyle ?? "stop";
504
- const firstButton = (0, import_react5.useRef)(null);
505
- (0, import_react5.useEffect)(() => {
591
+ const firstButton = (0, import_react8.useRef)(null);
592
+ (0, import_react8.useEffect)(() => {
506
593
  firstButton.current?.focus();
507
594
  }, [prompt]);
508
595
  const buttons = style === "stop" ? [
@@ -517,7 +604,7 @@ var SpreadsheetValidationDialog = ({ prompt, onResolve }) => {
517
604
  { label: "Cancel", action: "cancel" }
518
605
  ];
519
606
  const icon = style === "stop" ? "\u26D4" : style === "warning" ? "\u26A0" : "\u2139";
520
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
607
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
521
608
  "div",
522
609
  {
523
610
  className: "fixed inset-0 z-[60] flex items-center justify-center bg-black/30",
@@ -529,7 +616,7 @@ var SpreadsheetValidationDialog = ({ prompt, onResolve }) => {
529
616
  onResolve("cancel");
530
617
  }
531
618
  },
532
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
619
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
533
620
  "div",
534
621
  {
535
622
  role: "alertdialog",
@@ -540,15 +627,15 @@ var SpreadsheetValidationDialog = ({ prompt, onResolve }) => {
540
627
  className: "w-[22rem] max-w-[calc(100vw-2rem)] rounded-md border border-border bg-popover p-4 text-xs text-popover-foreground shadow-xl",
541
628
  style: { background: "var(--popover, var(--background, #fff))" },
542
629
  children: [
543
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-start gap-3", children: [
544
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "aria-hidden": "true", className: "text-lg leading-none", children: icon }),
545
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "min-w-0 flex-1", children: [
546
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { id: "spreadsheet-validation-title", className: "mb-1 text-sm font-semibold", children: prompt.result.title }),
547
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { id: "spreadsheet-validation-message", className: "whitespace-pre-wrap", children: prompt.result.message }),
548
- style === "warning" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "mt-2", children: "Continue?" })
630
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-start gap-3", children: [
631
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { "aria-hidden": "true", className: "text-lg leading-none", children: icon }),
632
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "min-w-0 flex-1", children: [
633
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h2", { id: "spreadsheet-validation-title", className: "mb-1 text-sm font-semibold", children: prompt.result.title }),
634
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { id: "spreadsheet-validation-message", className: "whitespace-pre-wrap", children: prompt.result.message }),
635
+ style === "warning" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "mt-2", children: "Continue?" })
549
636
  ] })
550
637
  ] }),
551
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mt-4 flex justify-end gap-2", children: buttons.map((button, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
638
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mt-4 flex justify-end gap-2", children: buttons.map((button, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
552
639
  "button",
553
640
  {
554
641
  ref: i === 0 ? firstButton : void 0,
@@ -568,9 +655,9 @@ var SpreadsheetValidationDialog = ({ prompt, onResolve }) => {
568
655
  };
569
656
 
570
657
  // src/spreadsheet/SpreadsheetRulePanels.tsx
571
- var import_react6 = require("react");
658
+ var import_react9 = require("react");
572
659
  var import_spreadsheet4 = require("@pixerate/editor/spreadsheet");
573
- var import_jsx_runtime4 = require("react/jsx-runtime");
660
+ var import_jsx_runtime6 = require("react/jsx-runtime");
574
661
  var inputClass = "w-full rounded border border-border bg-background px-1.5 py-0.5 text-xs text-foreground";
575
662
  var buttonClass = "rounded border border-border px-2 py-0.5 hover:bg-muted disabled:opacity-40";
576
663
  function selectionText(range) {
@@ -581,7 +668,7 @@ var PanelFrame = ({
581
668
  label,
582
669
  onClose,
583
670
  children
584
- }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
671
+ }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
585
672
  "div",
586
673
  {
587
674
  role: "dialog",
@@ -594,9 +681,9 @@ var PanelFrame = ({
594
681
  },
595
682
  onContextMenu: (e) => e.stopPropagation(),
596
683
  children: [
597
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "mb-2 flex items-center justify-between", children: [
598
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h2", { className: "text-sm font-semibold", children: title }),
599
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", "aria-label": "Close", className: "px-1 text-muted-foreground hover:text-foreground", onClick: onClose, children: "\u2715" })
684
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mb-2 flex items-center justify-between", children: [
685
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h2", { className: "text-sm font-semibold", children: title }),
686
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "aria-label": "Close", className: "px-1 text-muted-foreground hover:text-foreground", onClick: onClose, children: "\u2715" })
600
687
  ] }),
601
688
  children
602
689
  ]
@@ -604,7 +691,7 @@ var PanelFrame = ({
604
691
  );
605
692
  function RuleSwatch({ rule }) {
606
693
  if (rule.type === "colorScale") {
607
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
694
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
608
695
  "span",
609
696
  {
610
697
  "aria-hidden": "true",
@@ -614,26 +701,26 @@ function RuleSwatch({ rule }) {
614
701
  );
615
702
  }
616
703
  if (rule.type === "dataBar") {
617
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-hidden": "true", className: "inline-block h-3 w-6 shrink-0 rounded-sm", style: { background: rule.color ?? "#638ec6" } });
704
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "aria-hidden": "true", className: "inline-block h-3 w-6 shrink-0 rounded-sm", style: { background: rule.color ?? "#638ec6" } });
618
705
  }
619
- if (rule.type === "iconSet") return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-hidden": "true", className: "shrink-0", children: "\u25CF" });
706
+ if (rule.type === "iconSet") return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "aria-hidden": "true", className: "shrink-0", children: "\u25CF" });
620
707
  const css = (0, import_spreadsheet4.getConditionalFormatCss)(rule.style);
621
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-hidden": "true", className: "inline-flex h-4 w-6 shrink-0 items-center justify-center rounded-sm border border-border", style: css, children: "Aa" });
708
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "aria-hidden": "true", className: "inline-flex h-4 w-6 shrink-0 items-center justify-center rounded-sm border border-border", style: css, children: "Aa" });
622
709
  }
623
710
  var SpreadsheetConditionalFormatPanel = ({ state, onClose }) => {
624
711
  const rules = state.document.table?.conditionalFormats ?? [];
625
- const [kind, setKind] = (0, import_react6.useState)("greaterThan");
626
- const [appliesTo, setAppliesTo] = (0, import_react6.useState)(() => selectionText(state.selectedRange));
627
- const [value, setValue] = (0, import_react6.useState)("");
628
- const [value2, setValue2] = (0, import_react6.useState)("");
629
- const [text, setText] = (0, import_react6.useState)("");
630
- const [formula, setFormula] = (0, import_react6.useState)("=");
631
- const [rank, setRank] = (0, import_react6.useState)("10");
632
- const [period, setPeriod] = (0, import_react6.useState)("today");
633
- const [iconSet, setIconSet] = (0, import_react6.useState)("3TrafficLights1");
634
- const [color, setColor] = (0, import_react6.useState)("#638ec6");
635
- const [styleId, setStyleId] = (0, import_react6.useState)(import_spreadsheet4.CONDITIONAL_FORMAT_STYLE_PRESETS[0].id);
636
- const preset = (0, import_react6.useMemo)(() => import_spreadsheet4.CONDITIONAL_FORMAT_PRESETS.find((p) => p.kind === kind), [kind]);
712
+ const [kind, setKind] = (0, import_react9.useState)("greaterThan");
713
+ const [appliesTo, setAppliesTo] = (0, import_react9.useState)(() => selectionText(state.selectedRange));
714
+ const [value, setValue] = (0, import_react9.useState)("");
715
+ const [value2, setValue2] = (0, import_react9.useState)("");
716
+ const [text, setText] = (0, import_react9.useState)("");
717
+ const [formula, setFormula] = (0, import_react9.useState)("=");
718
+ const [rank, setRank] = (0, import_react9.useState)("10");
719
+ const [period, setPeriod] = (0, import_react9.useState)("today");
720
+ const [iconSet, setIconSet] = (0, import_react9.useState)("3TrafficLights1");
721
+ const [color, setColor] = (0, import_react9.useState)("#638ec6");
722
+ const [styleId, setStyleId] = (0, import_react9.useState)(import_spreadsheet4.CONDITIONAL_FORMAT_STYLE_PRESETS[0].id);
723
+ const preset = (0, import_react9.useMemo)(() => import_spreadsheet4.CONDITIONAL_FORMAT_PRESETS.find((p) => p.kind === kind), [kind]);
637
724
  const ranges = (0, import_spreadsheet4.parseRuleRanges)(appliesTo);
638
725
  const add = () => {
639
726
  if (!ranges) return;
@@ -653,17 +740,17 @@ var SpreadsheetConditionalFormatPanel = ({ state, onClose }) => {
653
740
  })
654
741
  );
655
742
  };
656
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(PanelFrame, { title: "Conditional formatting", label: "Conditional formatting rules", onClose, children: [
657
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("ol", { className: "mb-3 flex flex-col gap-1", "aria-label": "Rules in priority order", children: [
658
- rules.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("li", { className: "text-muted-foreground", children: "No rules on this sheet." }),
659
- rules.map((rule, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("li", { "data-rule-id": rule.id, className: "flex items-center gap-1.5 rounded border border-border px-1.5 py-1", children: [
660
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RuleSwatch, { rule }),
661
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "min-w-0 flex-1", children: [
662
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "truncate", title: (0, import_spreadsheet4.describeConditionalFormat)(rule), children: (0, import_spreadsheet4.describeConditionalFormat)(rule) }),
663
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "truncate font-mono text-[10px] text-muted-foreground", children: (0, import_spreadsheet4.formatRuleRanges)(rule.ranges) })
743
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(PanelFrame, { title: "Conditional formatting", label: "Conditional formatting rules", onClose, children: [
744
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("ol", { className: "mb-3 flex flex-col gap-1", "aria-label": "Rules in priority order", children: [
745
+ rules.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("li", { className: "text-muted-foreground", children: "No rules on this sheet." }),
746
+ rules.map((rule, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("li", { "data-rule-id": rule.id, className: "flex items-center gap-1.5 rounded border border-border px-1.5 py-1", children: [
747
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(RuleSwatch, { rule }),
748
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "min-w-0 flex-1", children: [
749
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "truncate", title: (0, import_spreadsheet4.describeConditionalFormat)(rule), children: (0, import_spreadsheet4.describeConditionalFormat)(rule) }),
750
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "truncate font-mono text-[10px] text-muted-foreground", children: (0, import_spreadsheet4.formatRuleRanges)(rule.ranges) })
664
751
  ] }),
665
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "flex items-center gap-0.5 text-[10px]", title: "Stop if true", children: [
666
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
752
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "flex items-center gap-0.5 text-[10px]", title: "Stop if true", children: [
753
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
667
754
  "input",
668
755
  {
669
756
  type: "checkbox",
@@ -674,8 +761,8 @@ var SpreadsheetConditionalFormatPanel = ({ state, onClose }) => {
674
761
  ),
675
762
  "Stop"
676
763
  ] }),
677
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", "aria-label": "Move up", className: buttonClass, disabled: i === 0, onClick: () => state.moveConditionalFormat(rule.id, { by: -1 }), children: "\u25B2" }),
678
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
764
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "aria-label": "Move up", className: buttonClass, disabled: i === 0, onClick: () => state.moveConditionalFormat(rule.id, { by: -1 }), children: "\u25B2" }),
765
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
679
766
  "button",
680
767
  {
681
768
  type: "button",
@@ -686,46 +773,46 @@ var SpreadsheetConditionalFormatPanel = ({ state, onClose }) => {
686
773
  children: "\u25BC"
687
774
  }
688
775
  ),
689
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", "aria-label": "Delete rule", className: buttonClass, onClick: () => state.deleteConditionalFormat(rule.id), children: "\u2715" })
776
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "aria-label": "Delete rule", className: buttonClass, onClick: () => state.deleteConditionalFormat(rule.id), children: "\u2715" })
690
777
  ] }, rule.id))
691
778
  ] }),
692
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { className: "flex flex-col gap-1.5 border-t border-border pt-2", children: [
693
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { className: "sr-only", children: "New rule" }),
694
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "flex flex-col gap-0.5", children: [
779
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("fieldset", { className: "flex flex-col gap-1.5 border-t border-border pt-2", children: [
780
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("legend", { className: "sr-only", children: "New rule" }),
781
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "flex flex-col gap-0.5", children: [
695
782
  "Format cells",
696
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("select", { "aria-label": "Rule type", className: inputClass, value: kind, onChange: (e) => setKind(e.target.value), children: import_spreadsheet4.CONDITIONAL_FORMAT_PRESETS.map((p) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: p.kind, children: p.label }, p.kind)) })
783
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("select", { "aria-label": "Rule type", className: inputClass, value: kind, onChange: (e) => setKind(e.target.value), children: import_spreadsheet4.CONDITIONAL_FORMAT_PRESETS.map((p) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: p.kind, children: p.label }, p.kind)) })
697
784
  ] }),
698
- preset.fields.includes("value") && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { "aria-label": "Value", placeholder: "Value or =formula", className: inputClass, value, onChange: (e) => setValue(e.target.value) }),
699
- preset.fields.includes("value2") && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { "aria-label": "Second value", placeholder: "and", className: inputClass, value: value2, onChange: (e) => setValue2(e.target.value) }),
700
- preset.fields.includes("text") && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { "aria-label": "Text", placeholder: "Text", className: inputClass, value: text, onChange: (e) => setText(e.target.value) }),
701
- preset.fields.includes("formula") && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { "aria-label": "Formula", placeholder: "=$A1>10", className: inputClass, value: formula, onChange: (e) => setFormula(e.target.value) }),
702
- preset.fields.includes("rank") && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { "aria-label": "Rank", type: "number", min: 1, className: inputClass, value: rank, onChange: (e) => setRank(e.target.value) }),
703
- preset.fields.includes("period") && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("select", { "aria-label": "Period", className: inputClass, value: period, onChange: (e) => setPeriod(e.target.value), children: import_spreadsheet4.CONDITIONAL_FORMAT_TIME_PERIODS.map((p) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: p.period, children: p.label }, p.period)) }),
704
- preset.fields.includes("iconSet") && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("select", { "aria-label": "Icon set", className: inputClass, value: iconSet, onChange: (e) => setIconSet(e.target.value), children: import_spreadsheet4.CONDITIONAL_FORMAT_ICON_SETS.map((set) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: set, children: set }, set)) }),
705
- preset.fields.includes("color") && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { "aria-label": "Bar colour", type: "color", className: "h-6 w-12", value: color, onChange: (e) => setColor(e.target.value) }),
706
- preset.usesStyle && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("select", { "aria-label": "Style", className: inputClass, value: styleId, onChange: (e) => setStyleId(e.target.value), children: import_spreadsheet4.CONDITIONAL_FORMAT_STYLE_PRESETS.map((s) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: s.id, children: s.label }, s.id)) }),
707
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "flex flex-col gap-0.5", children: [
785
+ preset.fields.includes("value") && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { "aria-label": "Value", placeholder: "Value or =formula", className: inputClass, value, onChange: (e) => setValue(e.target.value) }),
786
+ preset.fields.includes("value2") && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { "aria-label": "Second value", placeholder: "and", className: inputClass, value: value2, onChange: (e) => setValue2(e.target.value) }),
787
+ preset.fields.includes("text") && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { "aria-label": "Text", placeholder: "Text", className: inputClass, value: text, onChange: (e) => setText(e.target.value) }),
788
+ preset.fields.includes("formula") && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { "aria-label": "Formula", placeholder: "=$A1>10", className: inputClass, value: formula, onChange: (e) => setFormula(e.target.value) }),
789
+ preset.fields.includes("rank") && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { "aria-label": "Rank", type: "number", min: 1, className: inputClass, value: rank, onChange: (e) => setRank(e.target.value) }),
790
+ preset.fields.includes("period") && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("select", { "aria-label": "Period", className: inputClass, value: period, onChange: (e) => setPeriod(e.target.value), children: import_spreadsheet4.CONDITIONAL_FORMAT_TIME_PERIODS.map((p) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: p.period, children: p.label }, p.period)) }),
791
+ preset.fields.includes("iconSet") && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("select", { "aria-label": "Icon set", className: inputClass, value: iconSet, onChange: (e) => setIconSet(e.target.value), children: import_spreadsheet4.CONDITIONAL_FORMAT_ICON_SETS.map((set) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: set, children: set }, set)) }),
792
+ preset.fields.includes("color") && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { "aria-label": "Bar colour", type: "color", className: "h-6 w-12", value: color, onChange: (e) => setColor(e.target.value) }),
793
+ preset.usesStyle && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("select", { "aria-label": "Style", className: inputClass, value: styleId, onChange: (e) => setStyleId(e.target.value), children: import_spreadsheet4.CONDITIONAL_FORMAT_STYLE_PRESETS.map((s) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: s.id, children: s.label }, s.id)) }),
794
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "flex flex-col gap-0.5", children: [
708
795
  "Applies to",
709
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { "aria-label": "Applies to", className: `${inputClass} font-mono`, value: appliesTo, onChange: (e) => setAppliesTo(e.target.value) })
796
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { "aria-label": "Applies to", className: `${inputClass} font-mono`, value: appliesTo, onChange: (e) => setAppliesTo(e.target.value) })
710
797
  ] }),
711
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex justify-between gap-2", children: [
712
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: buttonClass, onClick: () => setAppliesTo(selectionText(state.selectedRange)), children: "Use selection" }),
713
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: buttonClass, disabled: !ranges, onClick: add, children: "Add rule" })
798
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex justify-between gap-2", children: [
799
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: buttonClass, onClick: () => setAppliesTo(selectionText(state.selectedRange)), children: "Use selection" }),
800
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: buttonClass, disabled: !ranges, onClick: add, children: "Add rule" })
714
801
  ] })
715
802
  ] })
716
803
  ] });
717
804
  };
718
805
  var SpreadsheetDataValidationPanel = ({ state, onClose }) => {
719
806
  const rules = state.document.table?.dataValidations ?? [];
720
- const [type, setType] = (0, import_react6.useState)("list");
721
- const [operator, setOperator] = (0, import_react6.useState)("between");
722
- const [formula1, setFormula1] = (0, import_react6.useState)("");
723
- const [formula2, setFormula2] = (0, import_react6.useState)("");
724
- const [errorStyle, setErrorStyle] = (0, import_react6.useState)("stop");
725
- const [errorMessage, setErrorMessage] = (0, import_react6.useState)("");
726
- const [inputMessage, setInputMessage] = (0, import_react6.useState)("");
727
- const [ignoreBlank, setIgnoreBlank] = (0, import_react6.useState)(true);
728
- const [appliesTo, setAppliesTo] = (0, import_react6.useState)(() => selectionText(state.selectedRange));
807
+ const [type, setType] = (0, import_react9.useState)("list");
808
+ const [operator, setOperator] = (0, import_react9.useState)("between");
809
+ const [formula1, setFormula1] = (0, import_react9.useState)("");
810
+ const [formula2, setFormula2] = (0, import_react9.useState)("");
811
+ const [errorStyle, setErrorStyle] = (0, import_react9.useState)("stop");
812
+ const [errorMessage, setErrorMessage] = (0, import_react9.useState)("");
813
+ const [inputMessage, setInputMessage] = (0, import_react9.useState)("");
814
+ const [ignoreBlank, setIgnoreBlank] = (0, import_react9.useState)(true);
815
+ const [appliesTo, setAppliesTo] = (0, import_react9.useState)(() => selectionText(state.selectedRange));
729
816
  const ranges = (0, import_spreadsheet4.parseRuleRanges)(appliesTo);
730
817
  const usesOperator = type === "whole" || type === "decimal" || type === "date" || type === "time" || type === "textLength";
731
818
  const needsTwo = usesOperator && (operator === "between" || operator === "notBetween");
@@ -744,29 +831,29 @@ var SpreadsheetDataValidationPanel = ({ state, onClose }) => {
744
831
  ignoreBlank
745
832
  });
746
833
  };
747
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(PanelFrame, { title: "Data validation", label: "Data validation rules", onClose, children: [
748
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("ul", { className: "mb-3 flex flex-col gap-1", "aria-label": "Validation rules", children: [
749
- rules.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("li", { className: "text-muted-foreground", children: "No validation on this sheet." }),
750
- rules.map((rule) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("li", { "data-rule-id": rule.id, className: "flex items-center gap-1.5 rounded border border-border px-1.5 py-1", children: [
751
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "min-w-0 flex-1", children: [
752
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "truncate", title: (0, import_spreadsheet4.describeDataValidation)(rule), children: (0, import_spreadsheet4.describeDataValidation)(rule) }),
753
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "truncate font-mono text-[10px] text-muted-foreground", children: [
834
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(PanelFrame, { title: "Data validation", label: "Data validation rules", onClose, children: [
835
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("ul", { className: "mb-3 flex flex-col gap-1", "aria-label": "Validation rules", children: [
836
+ rules.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("li", { className: "text-muted-foreground", children: "No validation on this sheet." }),
837
+ rules.map((rule) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("li", { "data-rule-id": rule.id, className: "flex items-center gap-1.5 rounded border border-border px-1.5 py-1", children: [
838
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "min-w-0 flex-1", children: [
839
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "truncate", title: (0, import_spreadsheet4.describeDataValidation)(rule), children: (0, import_spreadsheet4.describeDataValidation)(rule) }),
840
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "truncate font-mono text-[10px] text-muted-foreground", children: [
754
841
  (0, import_spreadsheet4.formatRuleRanges)(rule.ranges),
755
842
  " \xB7 ",
756
843
  rule.errorStyle ?? "stop"
757
844
  ] })
758
845
  ] }),
759
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", "aria-label": "Delete rule", className: buttonClass, onClick: () => state.deleteDataValidation(rule.id), children: "\u2715" })
846
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "aria-label": "Delete rule", className: buttonClass, onClick: () => state.deleteDataValidation(rule.id), children: "\u2715" })
760
847
  ] }, rule.id))
761
848
  ] }),
762
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { className: "flex flex-col gap-1.5 border-t border-border pt-2", children: [
763
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { className: "sr-only", children: "New validation" }),
764
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "flex flex-col gap-0.5", children: [
849
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("fieldset", { className: "flex flex-col gap-1.5 border-t border-border pt-2", children: [
850
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("legend", { className: "sr-only", children: "New validation" }),
851
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "flex flex-col gap-0.5", children: [
765
852
  "Allow",
766
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("select", { "aria-label": "Allow", className: inputClass, value: type, onChange: (e) => setType(e.target.value), children: import_spreadsheet4.DATA_VALIDATION_TYPE_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: o.type, children: o.label }, o.type)) })
853
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("select", { "aria-label": "Allow", className: inputClass, value: type, onChange: (e) => setType(e.target.value), children: import_spreadsheet4.DATA_VALIDATION_TYPE_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: o.type, children: o.label }, o.type)) })
767
854
  ] }),
768
- usesOperator && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("select", { "aria-label": "Operator", className: inputClass, value: operator, onChange: (e) => setOperator(e.target.value), children: import_spreadsheet4.DATA_VALIDATION_OPERATOR_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: o.operator, children: o.label }, o.operator)) }),
769
- type !== "any" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
855
+ usesOperator && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("select", { "aria-label": "Operator", className: inputClass, value: operator, onChange: (e) => setOperator(e.target.value), children: import_spreadsheet4.DATA_VALIDATION_OPERATOR_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: o.operator, children: o.label }, o.operator)) }),
856
+ type !== "any" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
770
857
  "input",
771
858
  {
772
859
  "aria-label": type === "list" ? "Source" : type === "custom" ? "Formula" : needsTwo ? "Minimum" : "Value",
@@ -776,52 +863,52 @@ var SpreadsheetDataValidationPanel = ({ state, onClose }) => {
776
863
  onChange: (e) => setFormula1(e.target.value)
777
864
  }
778
865
  ),
779
- needsTwo && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { "aria-label": "Maximum", placeholder: "Maximum", className: inputClass, value: formula2, onChange: (e) => setFormula2(e.target.value) }),
780
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "flex items-center gap-1", children: [
781
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "checkbox", checked: ignoreBlank, onChange: (e) => setIgnoreBlank(e.target.checked) }),
866
+ needsTwo && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { "aria-label": "Maximum", placeholder: "Maximum", className: inputClass, value: formula2, onChange: (e) => setFormula2(e.target.value) }),
867
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "flex items-center gap-1", children: [
868
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "checkbox", checked: ignoreBlank, onChange: (e) => setIgnoreBlank(e.target.checked) }),
782
869
  " Ignore blank"
783
870
  ] }),
784
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { "aria-label": "Input message", placeholder: "Input message (optional)", className: inputClass, value: inputMessage, onChange: (e) => setInputMessage(e.target.value) }),
785
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "flex gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("select", { "aria-label": "Error style", className: inputClass, value: errorStyle, onChange: (e) => setErrorStyle(e.target.value), children: import_spreadsheet4.DATA_VALIDATION_ERROR_STYLE_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: o.style, children: o.label }, o.style)) }) }),
786
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { "aria-label": "Error message", placeholder: "Error message (optional)", className: inputClass, value: errorMessage, onChange: (e) => setErrorMessage(e.target.value) }),
787
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "flex flex-col gap-0.5", children: [
871
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { "aria-label": "Input message", placeholder: "Input message (optional)", className: inputClass, value: inputMessage, onChange: (e) => setInputMessage(e.target.value) }),
872
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("select", { "aria-label": "Error style", className: inputClass, value: errorStyle, onChange: (e) => setErrorStyle(e.target.value), children: import_spreadsheet4.DATA_VALIDATION_ERROR_STYLE_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: o.style, children: o.label }, o.style)) }) }),
873
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { "aria-label": "Error message", placeholder: "Error message (optional)", className: inputClass, value: errorMessage, onChange: (e) => setErrorMessage(e.target.value) }),
874
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "flex flex-col gap-0.5", children: [
788
875
  "Applies to",
789
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { "aria-label": "Applies to", className: `${inputClass} font-mono`, value: appliesTo, onChange: (e) => setAppliesTo(e.target.value) })
876
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { "aria-label": "Applies to", className: `${inputClass} font-mono`, value: appliesTo, onChange: (e) => setAppliesTo(e.target.value) })
790
877
  ] }),
791
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-wrap justify-between gap-2", children: [
792
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: buttonClass, onClick: () => setAppliesTo(selectionText(state.selectedRange)), children: "Use selection" }),
793
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: buttonClass, disabled: !ranges, onClick: () => ranges && ranges.forEach((r) => state.clearDataValidation(r)), children: "Clear" }),
794
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: buttonClass, disabled: !ranges, onClick: apply, children: "Apply" })
878
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex flex-wrap justify-between gap-2", children: [
879
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: buttonClass, onClick: () => setAppliesTo(selectionText(state.selectedRange)), children: "Use selection" }),
880
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: buttonClass, disabled: !ranges, onClick: () => ranges && ranges.forEach((r) => state.clearDataValidation(r)), children: "Clear" }),
881
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: buttonClass, disabled: !ranges, onClick: apply, children: "Apply" })
795
882
  ] }),
796
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: buttonClass, "aria-pressed": circles, onClick: () => state.setInvalidDataCircles(!circles), children: circles ? "Clear validation circles" : "Circle invalid data" })
883
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: buttonClass, "aria-pressed": circles, onClick: () => state.setInvalidDataCircles(!circles), children: circles ? "Clear validation circles" : "Circle invalid data" })
797
884
  ] })
798
885
  ] });
799
886
  };
800
887
 
801
888
  // src/spreadsheet/useSpreadsheetViewport.ts
802
- var import_react7 = require("react");
889
+ var import_react10 = require("react");
803
890
  var import_spreadsheet5 = require("@pixerate/editor/spreadsheet");
804
- var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react7.useLayoutEffect : import_react7.useEffect;
891
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react10.useLayoutEffect : import_react10.useEffect;
805
892
  function useSpreadsheetViewport(scrollRef, view, options = {}) {
806
- const metrics = (0, import_react7.useMemo)(() => (0, import_spreadsheet5.measureSpreadsheetView)(view), [view]);
893
+ const metrics = (0, import_react10.useMemo)(() => (0, import_spreadsheet5.measureSpreadsheetView)(view), [view]);
807
894
  const virtual = (0, import_spreadsheet5.shouldVirtualizeSpreadsheet)(view, options.virtualize ?? "auto");
808
- const [viewport, setViewport] = (0, import_react7.useState)({ scrollTop: 0, scrollLeft: 0, width: 0, height: 0 });
809
- const windowOptions = (0, import_react7.useMemo)(
895
+ const [viewport, setViewport] = (0, import_react10.useState)({ scrollTop: 0, scrollLeft: 0, width: 0, height: 0 });
896
+ const windowOptions = (0, import_react10.useMemo)(
810
897
  () => ({ merges: options.merges, overscanRows: options.overscanRows, overscanColumns: options.overscanColumns }),
811
898
  [options.merges, options.overscanRows, options.overscanColumns]
812
899
  );
813
- const win = (0, import_react7.useMemo)(
900
+ const win = (0, import_react10.useMemo)(
814
901
  () => virtual ? (0, import_spreadsheet5.getSpreadsheetViewWindow)(metrics, viewport, windowOptions) : (0, import_spreadsheet5.fullSpreadsheetViewWindow)(metrics),
815
902
  [virtual, metrics, viewport, windowOptions]
816
903
  );
817
- const latest = (0, import_react7.useRef)({ metrics, viewport, virtual, windowOptions });
904
+ const latest = (0, import_react10.useRef)({ metrics, viewport, virtual, windowOptions });
818
905
  latest.current = { metrics, viewport, virtual, windowOptions };
819
- const readViewport = (0, import_react7.useCallback)(() => {
906
+ const readViewport = (0, import_react10.useCallback)(() => {
820
907
  const el = scrollRef.current;
821
908
  if (!el) return null;
822
909
  return { scrollTop: el.scrollTop, scrollLeft: el.scrollLeft, width: el.clientWidth, height: el.clientHeight };
823
910
  }, [scrollRef]);
824
- const updateViewport = (0, import_react7.useCallback)((next) => {
911
+ const updateViewport = (0, import_react10.useCallback)((next) => {
825
912
  setViewport((prev) => {
826
913
  const { metrics: m, virtual: v, windowOptions: o } = latest.current;
827
914
  if (!v) return prev;
@@ -829,7 +916,7 @@ function useSpreadsheetViewport(scrollRef, view, options = {}) {
829
916
  return same ? prev : next;
830
917
  });
831
918
  }, []);
832
- const onScroll = (0, import_react7.useCallback)(() => {
919
+ const onScroll = (0, import_react10.useCallback)(() => {
833
920
  const next = readViewport();
834
921
  if (next) updateViewport(next);
835
922
  }, [readViewport, updateViewport]);
@@ -863,24 +950,24 @@ function useSpreadsheetViewport(scrollRef, view, options = {}) {
863
950
  }
864
951
 
865
952
  // src/spreadsheet/FormulaHints.tsx
866
- var import_react8 = require("react");
953
+ var import_react11 = require("react");
867
954
  var import_spreadsheet6 = require("@pixerate/editor/spreadsheet");
868
- var import_jsx_runtime5 = require("react/jsx-runtime");
955
+ var import_jsx_runtime7 = require("react/jsx-runtime");
869
956
  var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
870
- const [caret, setCaret] = (0, import_react8.useState)(null);
871
- const [focused, setFocused] = (0, import_react8.useState)(false);
872
- const [selected, setSelected] = (0, import_react8.useState)(0);
873
- const [dismissed, setDismissed] = (0, import_react8.useState)(false);
874
- const [position, setPosition] = (0, import_react8.useState)(null);
875
- const pendingCaret = (0, import_react8.useRef)(null);
876
- const hints = (0, import_react8.useMemo)(
957
+ const [caret, setCaret] = (0, import_react11.useState)(null);
958
+ const [focused, setFocused] = (0, import_react11.useState)(false);
959
+ const [selected, setSelected] = (0, import_react11.useState)(0);
960
+ const [dismissed, setDismissed] = (0, import_react11.useState)(false);
961
+ const [position, setPosition] = (0, import_react11.useState)(null);
962
+ const pendingCaret = (0, import_react11.useRef)(null);
963
+ const hints = (0, import_react11.useMemo)(
877
964
  () => (0, import_spreadsheet6.getFormulaHints)(value, caret ?? value.length, { limit, names }),
878
965
  [value, caret, limit, names]
879
966
  );
880
967
  const suggestions = dismissed ? [] : hints.suggestions;
881
968
  const selectedIndex = Math.max(0, Math.min(selected, suggestions.length - 1));
882
969
  const visible = focused && value.trimStart().startsWith("=") && (suggestions.length > 0 || !!hints.activeCall);
883
- const latest = (0, import_react8.useRef)({ suggestions, selected: selectedIndex, value, caret, onAccept });
970
+ const latest = (0, import_react11.useRef)({ suggestions, selected: selectedIndex, value, caret, onAccept });
884
971
  latest.current = { suggestions, selected: selectedIndex, value, caret, onAccept };
885
972
  const accept = (index) => {
886
973
  const { suggestions: list, value: current, caret: at, onAccept: commit } = latest.current;
@@ -890,7 +977,7 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
890
977
  pendingCaret.current = next.caret;
891
978
  commit(next.value);
892
979
  };
893
- (0, import_react8.useEffect)(() => {
980
+ (0, import_react11.useEffect)(() => {
894
981
  const input = inputRef.current;
895
982
  if (!input) return;
896
983
  const syncCaret = () => setCaret(input.selectionStart ?? input.value.length);
@@ -940,7 +1027,7 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
940
1027
  input.removeEventListener("keydown", onKeyDown);
941
1028
  };
942
1029
  }, [inputRef]);
943
- (0, import_react8.useLayoutEffect)(() => {
1030
+ (0, import_react11.useLayoutEffect)(() => {
944
1031
  const input = inputRef.current;
945
1032
  const at = pendingCaret.current;
946
1033
  if (!input || at === null || input.value !== value) return;
@@ -949,7 +1036,7 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
949
1036
  setCaret(at);
950
1037
  setSelected(0);
951
1038
  }, [value, inputRef]);
952
- (0, import_react8.useLayoutEffect)(() => {
1039
+ (0, import_react11.useLayoutEffect)(() => {
953
1040
  const input = inputRef.current;
954
1041
  if (!visible || !input) return;
955
1042
  const rect = input.getBoundingClientRect();
@@ -957,7 +1044,7 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
957
1044
  }, [visible, value, inputRef]);
958
1045
  if (!visible) return null;
959
1046
  const { activeCall } = hints;
960
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1047
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
961
1048
  "div",
962
1049
  {
963
1050
  "data-formula-hints": "",
@@ -973,8 +1060,8 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
973
1060
  },
974
1061
  onMouseDown: (e) => e.preventDefault(),
975
1062
  children: [
976
- activeCall && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { "data-formula-signature": "", className: "px-2 py-1.5 border-b border-border bg-muted/30", children: [
977
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "font-mono", children: activeCall.parts.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1063
+ activeCall && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "data-formula-signature": "", className: "px-2 py-1.5 border-b border-border bg-muted/30", children: [
1064
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "font-mono", children: activeCall.parts.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
978
1065
  "span",
979
1066
  {
980
1067
  "data-active": part.active ? "" : void 0,
@@ -983,13 +1070,13 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
983
1070
  },
984
1071
  i
985
1072
  )) }),
986
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mt-0.5 text-muted-foreground", children: activeCall.argument ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
987
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-semibold", children: activeCall.argument.name }),
1073
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "mt-0.5 text-muted-foreground", children: activeCall.argument ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1074
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "font-semibold", children: activeCall.argument.name }),
988
1075
  ": ",
989
1076
  activeCall.argument.description
990
1077
  ] }) : activeCall.description })
991
1078
  ] }),
992
- suggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ul", { role: "listbox", "aria-label": "Formula suggestions", className: "max-h-64 overflow-auto py-1 m-0 list-none p-0", children: suggestions.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1079
+ suggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ul", { role: "listbox", "aria-label": "Formula suggestions", className: "max-h-64 overflow-auto py-1 m-0 list-none p-0", children: suggestions.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
993
1080
  "li",
994
1081
  {
995
1082
  role: "option",
@@ -1001,8 +1088,8 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
1001
1088
  accept(i);
1002
1089
  },
1003
1090
  children: [
1004
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "font-mono font-semibold text-foreground", children: s.signature }),
1005
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "text-muted-foreground truncate", children: s.description })
1091
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "font-mono font-semibold text-foreground", children: s.signature }),
1092
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "text-muted-foreground truncate", children: s.description })
1006
1093
  ]
1007
1094
  },
1008
1095
  `${s.kind ?? "fn"}:${s.name}`
@@ -1013,16 +1100,16 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
1013
1100
  };
1014
1101
 
1015
1102
  // src/spreadsheet/SheetTabs.tsx
1016
- var import_react9 = require("react");
1103
+ var import_react12 = require("react");
1017
1104
  var import_spreadsheet7 = require("@pixerate/editor/spreadsheet");
1018
- var import_jsx_runtime6 = require("react/jsx-runtime");
1105
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1019
1106
  var SheetTabs = ({ state, readOnly = false, className = "" }) => {
1020
1107
  const { controller, sheets } = state;
1021
- const [renaming, setRenaming] = (0, import_react9.useState)(null);
1022
- const [error, setError] = (0, import_react9.useState)(null);
1023
- const [menu, setMenu] = (0, import_react9.useState)(null);
1024
- const dragFrom = (0, import_react9.useRef)(null);
1025
- const [dropTarget, setDropTarget] = (0, import_react9.useState)(null);
1108
+ const [renaming, setRenaming] = (0, import_react12.useState)(null);
1109
+ const [error, setError] = (0, import_react12.useState)(null);
1110
+ const [menu, setMenu] = (0, import_react12.useState)(null);
1111
+ const dragFrom = (0, import_react12.useRef)(null);
1112
+ const [dropTarget, setDropTarget] = (0, import_react12.useState)(null);
1026
1113
  const commitRename = (cancelOnError) => {
1027
1114
  if (!renaming) return;
1028
1115
  const sheet = sheets.find((s) => s.id === renaming.id);
@@ -1045,8 +1132,8 @@ var SheetTabs = ({ state, readOnly = false, className = "" }) => {
1045
1132
  const rect = e.currentTarget.getBoundingClientRect();
1046
1133
  return e.clientX > rect.left + rect.width / 2;
1047
1134
  };
1048
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: `flex flex-col ${className}`, "data-sheet-tabs": "", children: [
1049
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1135
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: `flex flex-col ${className}`, "data-sheet-tabs": "", children: [
1136
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1050
1137
  "div",
1051
1138
  {
1052
1139
  role: "tablist",
@@ -1054,7 +1141,7 @@ var SheetTabs = ({ state, readOnly = false, className = "" }) => {
1054
1141
  className: "flex items-center gap-0.5 overflow-x-auto border-t border-border bg-muted px-1 py-1 text-xs",
1055
1142
  children: [
1056
1143
  sheets.map(
1057
- (sheet, index) => renaming?.id === sheet.id ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1144
+ (sheet, index) => renaming?.id === sheet.id ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1058
1145
  "input",
1059
1146
  {
1060
1147
  "aria-label": "Sheet name",
@@ -1074,7 +1161,7 @@ var SheetTabs = ({ state, readOnly = false, className = "" }) => {
1074
1161
  onBlur: () => commitRename(true)
1075
1162
  },
1076
1163
  sheet.id
1077
- ) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1164
+ ) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1078
1165
  "button",
1079
1166
  {
1080
1167
  type: "button",
@@ -1124,7 +1211,7 @@ var SheetTabs = ({ state, readOnly = false, className = "" }) => {
1124
1211
  sheet.id
1125
1212
  )
1126
1213
  ),
1127
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1214
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1128
1215
  "button",
1129
1216
  {
1130
1217
  type: "button",
@@ -1141,8 +1228,8 @@ var SheetTabs = ({ state, readOnly = false, className = "" }) => {
1141
1228
  ]
1142
1229
  }
1143
1230
  ),
1144
- error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { role: "alert", className: "px-2 py-1 text-xs text-destructive", children: error }),
1145
- menu && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1231
+ error && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { role: "alert", className: "px-2 py-1 text-xs text-destructive", children: error }),
1232
+ menu && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1146
1233
  SpreadsheetContextMenu,
1147
1234
  {
1148
1235
  items: menu.items,
@@ -1156,7 +1243,7 @@ var SheetTabs = ({ state, readOnly = false, className = "" }) => {
1156
1243
  };
1157
1244
 
1158
1245
  // src/spreadsheet/SpreadsheetEditor.tsx
1159
- var import_jsx_runtime7 = require("react/jsx-runtime");
1246
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1160
1247
  var COLUMN_HEADER_HEIGHT = 28;
1161
1248
  var ROW_HEADER_WIDTH = 48;
1162
1249
  function frozenCellStyle(viewRow, viewCol) {
@@ -1187,7 +1274,7 @@ function CellText({ cell, conditional }) {
1187
1274
  const shown = (0, import_spreadsheet8.formatCellForDisplay)(cell);
1188
1275
  const color = conditional?.color ?? (shown.color ? (0, import_spreadsheet8.numberFormatColorToCss)(shown.color) : void 0);
1189
1276
  const decorated = !!conditional?.dataBar || !!conditional?.icon;
1190
- const text = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1277
+ const text = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1191
1278
  "span",
1192
1279
  {
1193
1280
  className: `truncate block max-w-full ${cell.error ? "text-destructive font-semibold" : ""}`,
@@ -1204,10 +1291,10 @@ function CellText({ cell, conditional }) {
1204
1291
  );
1205
1292
  if (!conditional || !decorated) return text;
1206
1293
  const icon = conditional.icon ? (0, import_spreadsheet8.getConditionalFormatIcon)(conditional.icon.set, conditional.icon.index) : null;
1207
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1208
- conditional.dataBar && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { "aria-hidden": "true", className: "spreadsheet-data-bar", style: (0, import_spreadsheet8.getDataBarCss)(conditional.dataBar) }),
1209
- icon ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "flex items-center gap-1 min-w-0", style: { position: "relative" }, children: [
1210
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "spreadsheet-cf-icon shrink-0", role: "img", "aria-label": icon.label, "data-icon": conditional.icon.id, style: { color: icon.color }, children: icon.glyph }),
1294
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1295
+ conditional.dataBar && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { "aria-hidden": "true", className: "spreadsheet-data-bar", style: (0, import_spreadsheet8.getDataBarCss)(conditional.dataBar) }),
1296
+ icon ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 min-w-0", style: { position: "relative" }, children: [
1297
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "spreadsheet-cf-icon shrink-0", role: "img", "aria-label": icon.label, "data-icon": conditional.icon.id, style: { color: icon.color }, children: icon.glyph }),
1211
1298
  text
1212
1299
  ] }) : text
1213
1300
  ] });
@@ -1220,25 +1307,67 @@ var SpreadsheetEditor = ({
1220
1307
  onColumnHeaderClick,
1221
1308
  onColumnResize,
1222
1309
  showSheetTabs = false,
1223
- virtualize = "auto"
1310
+ virtualize = "auto",
1311
+ playback,
1312
+ playbackId = "spreadsheet",
1313
+ onPlaybackReveal
1224
1314
  }) => {
1225
1315
  const defaultState = useSpreadsheetEditor();
1226
1316
  const state = externalState || defaultState;
1227
- const gridRef = (0, import_react10.useRef)(null);
1228
- const scrollRef = (0, import_react10.useRef)(null);
1229
- const formulaBarRef = (0, import_react10.useRef)(null);
1230
- const cellInputRef = (0, import_react10.useRef)(null);
1231
- const [resizingColId, setResizingColId] = (0, import_react10.useState)(null);
1232
- const [hoveredColId, setHoveredColId] = (0, import_react10.useState)(null);
1233
- const [resizeStartX, setResizeStartX] = (0, import_react10.useState)(0);
1234
- const [resizeStartWidth, setResizeStartWidth] = (0, import_react10.useState)(0);
1317
+ const gridRef = (0, import_react13.useRef)(null);
1318
+ const ambientPlayback = useAgentPlayback();
1319
+ const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
1320
+ const agentPresence = usePlaybackSurface(playing, playbackId, {
1321
+ defaultKind: "cell",
1322
+ locate: (ref) => {
1323
+ const grid2 = gridRef.current;
1324
+ const range = (0, import_spreadsheet8.parseSpreadsheetPlaybackRef)(ref);
1325
+ if (!grid2 || !range) return null;
1326
+ const box = grid2.getBoundingClientRect();
1327
+ const inside = (v, a, b) => (a === null || v >= a) && (b === null || v <= b);
1328
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
1329
+ for (const td of grid2.querySelectorAll("td[data-row][data-col]")) {
1330
+ if (!inside(Number(td.dataset.row), range.startRow, range.endRow) || !inside(Number(td.dataset.col), range.startCol, range.endCol)) continue;
1331
+ const r = td.getBoundingClientRect();
1332
+ minX = Math.min(minX, r.left - box.left);
1333
+ minY = Math.min(minY, r.top - box.top);
1334
+ maxX = Math.max(maxX, r.right - box.left);
1335
+ maxY = Math.max(maxY, r.bottom - box.top);
1336
+ }
1337
+ return minX < maxX ? { x: minX, y: minY, width: maxX - minX, height: maxY - minY } : null;
1338
+ },
1339
+ bounds: () => {
1340
+ const r = gridRef.current?.getBoundingClientRect();
1341
+ return r && r.width > 0 ? { x: 0, y: 0, width: r.width, height: r.height } : null;
1342
+ },
1343
+ visible: () => {
1344
+ const r = gridRef.current?.getBoundingClientRect();
1345
+ return !!r && r.width > 0 && r.height > 0 && !(typeof document !== "undefined" && document.visibilityState === "hidden");
1346
+ },
1347
+ toViewport: (p) => {
1348
+ const r = gridRef.current?.getBoundingClientRect();
1349
+ return { x: (r?.left ?? 0) + p.x, y: (r?.top ?? 0) + p.y };
1350
+ },
1351
+ fromViewport: (p) => {
1352
+ const r = gridRef.current?.getBoundingClientRect();
1353
+ return { x: p.x - (r?.left ?? 0), y: p.y - (r?.top ?? 0) };
1354
+ },
1355
+ reveal: () => onPlaybackReveal?.()
1356
+ });
1357
+ const scrollRef = (0, import_react13.useRef)(null);
1358
+ const formulaBarRef = (0, import_react13.useRef)(null);
1359
+ const cellInputRef = (0, import_react13.useRef)(null);
1360
+ const [resizingColId, setResizingColId] = (0, import_react13.useState)(null);
1361
+ const [hoveredColId, setHoveredColId] = (0, import_react13.useState)(null);
1362
+ const [resizeStartX, setResizeStartX] = (0, import_react13.useState)(0);
1363
+ const [resizeStartWidth, setResizeStartWidth] = (0, import_react13.useState)(0);
1235
1364
  const view = state.viewModel;
1236
1365
  const { window: viewWindow, onScroll: handleGridScroll } = useSpreadsheetViewport(scrollRef, view, {
1237
1366
  virtualize,
1238
1367
  merges: state.document.table?.merges,
1239
1368
  activeCell: state.activeCell
1240
1369
  });
1241
- const columnSlots = (0, import_react10.useMemo)(() => {
1370
+ const columnSlots = (0, import_react13.useMemo)(() => {
1242
1371
  const col = (viewCol) => ({ kind: "col", viewCol });
1243
1372
  if (!viewWindow.virtual) return view.columns.map(col);
1244
1373
  const slots = view.columns.slice(0, viewWindow.frozenColumns).map(col);
@@ -1247,11 +1376,11 @@ var SpreadsheetEditor = ({
1247
1376
  if (viewWindow.rightSpace > 0) slots.push({ kind: "space", key: "space:right", width: viewWindow.rightSpace });
1248
1377
  return slots;
1249
1378
  }, [view, viewWindow]);
1250
- const renderedColumns = (0, import_react10.useMemo)(
1379
+ const renderedColumns = (0, import_react13.useMemo)(
1251
1380
  () => columnSlots.flatMap((slot) => slot.kind === "col" ? [slot.viewCol] : []),
1252
1381
  [columnSlots]
1253
1382
  );
1254
- const rowSlots = (0, import_react10.useMemo)(() => {
1383
+ const rowSlots = (0, import_react13.useMemo)(() => {
1255
1384
  const row = (viewRow) => ({ kind: "row", viewRow });
1256
1385
  if (!viewWindow.virtual) return view.rows.map(row);
1257
1386
  const slots = view.rows.slice(0, viewWindow.frozenRows).map(row);
@@ -1262,16 +1391,16 @@ var SpreadsheetEditor = ({
1262
1391
  }, [view, viewWindow]);
1263
1392
  const { copyShortcutFallback } = useSpreadsheetClipboard(gridRef, state, readOnly);
1264
1393
  const { fillTarget, startFill, extendFill } = useFillHandle(state);
1265
- const [menu, setMenu] = (0, import_react10.useState)(null);
1266
- const [panel, setPanel] = (0, import_react10.useState)(null);
1267
- const [listMenu, setListMenu] = (0, import_react10.useState)(null);
1394
+ const [menu, setMenu] = (0, import_react13.useState)(null);
1395
+ const [panel, setPanel] = (0, import_react13.useState)(null);
1396
+ const [listMenu, setListMenu] = (0, import_react13.useState)(null);
1268
1397
  const overlay = state.conditionalFormatOverlay;
1269
1398
  const filter = state.document.table?.filter;
1270
- const filteredColIds = (0, import_react10.useMemo)(
1399
+ const filteredColIds = (0, import_react13.useMemo)(
1271
1400
  () => new Set(filter?.enabled ? filter.rules.map((r) => r.colId) : []),
1272
1401
  [filter]
1273
1402
  );
1274
- const handleCellContextMenu = (0, import_react10.useCallback)((rIdx, cIdx, e) => {
1403
+ const handleCellContextMenu = (0, import_react13.useCallback)((rIdx, cIdx, e) => {
1275
1404
  if (readOnly) return;
1276
1405
  e.preventDefault();
1277
1406
  if (state.editingCell) state.commitEditing();
@@ -1280,33 +1409,33 @@ var SpreadsheetEditor = ({
1280
1409
  }
1281
1410
  setMenu({ x: e.clientX, y: e.clientY, items: (0, import_spreadsheet8.getSpreadsheetMenuItems)(state.controller, { row: rIdx, col: cIdx }) });
1282
1411
  }, [readOnly, state]);
1283
- const nameSuggestions = (0, import_react10.useMemo)(
1412
+ const nameSuggestions = (0, import_react13.useMemo)(
1284
1413
  () => state.controller.getNameSuggestions(),
1285
1414
  // eslint-disable-next-line react-hooks/exhaustive-deps
1286
1415
  [state.controller, state.document]
1287
1416
  );
1288
- const activeRawValue = (0, import_react10.useMemo)(() => {
1417
+ const activeRawValue = (0, import_react13.useMemo)(() => {
1289
1418
  if (!state.activeCell) return "";
1290
1419
  const row = state.document.rows[state.activeCell.row];
1291
1420
  const col = state.document.columns[state.activeCell.col];
1292
1421
  if (!row || !col) return "";
1293
1422
  return state.getCell(row.id, col.id).raw;
1294
1423
  }, [state.activeCell, state.document]);
1295
- const activeSpill = (0, import_react10.useMemo)(
1424
+ const activeSpill = (0, import_react13.useMemo)(
1296
1425
  () => state.activeCell ? state.controller.getSpillAt(state.activeCell.row, state.activeCell.col) : null,
1297
1426
  // eslint-disable-next-line react-hooks/exhaustive-deps
1298
1427
  [state.controller, state.activeCell, state.document]
1299
1428
  );
1300
1429
  const spillFormula = activeSpill && !activeRawValue && activeSpill.key !== coordKey(state.activeCell) ? activeSpill.formula : "";
1301
- const coordLabel = (0, import_react10.useMemo)(() => {
1430
+ const coordLabel = (0, import_react13.useMemo)(() => {
1302
1431
  if (!state.activeCell) return "--";
1303
1432
  const colName = (0, import_spreadsheet8.indexToColName)(state.activeCell.col);
1304
1433
  return `${colName}${state.activeCell.row + 1}`;
1305
1434
  }, [state.activeCell]);
1306
- const [formulaDraft, setFormulaDraft] = (0, import_react10.useState)(null);
1435
+ const [formulaDraft, setFormulaDraft] = (0, import_react13.useState)(null);
1307
1436
  const activeColumn = state.activeCell ? state.document.columns[state.activeCell.col] : void 0;
1308
1437
  const formulaBarReadOnly = readOnly || !state.activeCell || !!activeColumn?.readOnly;
1309
- (0, import_react10.useEffect)(() => {
1438
+ (0, import_react13.useEffect)(() => {
1310
1439
  setFormulaDraft(null);
1311
1440
  }, [state.activeCell?.row, state.activeCell?.col]);
1312
1441
  const commitFormulaBar = () => {
@@ -1322,19 +1451,19 @@ var SpreadsheetEditor = ({
1322
1451
  }
1323
1452
  setFormulaDraft(null);
1324
1453
  };
1325
- const handleCellClick = (0, import_react10.useCallback)((rIdx, cIdx, e) => {
1454
+ const handleCellClick = (0, import_react13.useCallback)((rIdx, cIdx, e) => {
1326
1455
  if (state.editingCell && (state.editingCell.row !== rIdx || state.editingCell.col !== cIdx)) {
1327
1456
  state.commitEditing();
1328
1457
  }
1329
1458
  state.selectCell(rIdx, cIdx, e.shiftKey);
1330
1459
  }, [state]);
1331
- const handleCellDblClick = (0, import_react10.useCallback)((rIdx, cIdx) => {
1460
+ const handleCellDblClick = (0, import_react13.useCallback)((rIdx, cIdx) => {
1332
1461
  if (readOnly) return;
1333
1462
  const col = state.document.columns[cIdx];
1334
1463
  if (col?.readOnly) return;
1335
1464
  state.startEditing(rIdx, cIdx);
1336
1465
  }, [readOnly, state]);
1337
- const handleKeyDown = (0, import_react10.useCallback)((e) => {
1466
+ const handleKeyDown = (0, import_react13.useCallback)((e) => {
1338
1467
  if (state.editingCell) {
1339
1468
  if (e.key === "Enter") {
1340
1469
  e.preventDefault();
@@ -1406,12 +1535,12 @@ var SpreadsheetEditor = ({
1406
1535
  }
1407
1536
  }
1408
1537
  }, [readOnly, state, copyShortcutFallback]);
1409
- const activeListValues = (0, import_react10.useMemo)(
1538
+ const activeListValues = (0, import_react13.useMemo)(
1410
1539
  () => state.activeCell && !readOnly ? state.controller.getValidationListValues(state.activeCell.row, state.activeCell.col) : null,
1411
1540
  // eslint-disable-next-line react-hooks/exhaustive-deps
1412
1541
  [state.controller, state.activeCell, state.document, readOnly]
1413
1542
  );
1414
- const activeRule = (0, import_react10.useMemo)(
1543
+ const activeRule = (0, import_react13.useMemo)(
1415
1544
  () => state.activeCell ? state.controller.getDataValidationAt(state.activeCell.row, state.activeCell.col) : void 0,
1416
1545
  // eslint-disable-next-line react-hooks/exhaustive-deps
1417
1546
  [state.controller, state.activeCell, state.document]
@@ -1425,7 +1554,7 @@ var SpreadsheetEditor = ({
1425
1554
  const rect = td?.getBoundingClientRect();
1426
1555
  setListMenu({ x: rect ? rect.left : 0, y: rect ? rect.bottom : 0, row, col, values });
1427
1556
  }
1428
- (0, import_react10.useEffect)(() => {
1557
+ (0, import_react13.useEffect)(() => {
1429
1558
  if (!listMenu) return;
1430
1559
  const close = (e) => {
1431
1560
  if (!e.target?.closest?.('[aria-label="Allowed values"], .spreadsheet-list-arrow')) setListMenu(null);
@@ -1448,11 +1577,11 @@ var SpreadsheetEditor = ({
1448
1577
  else gridRef.current?.focus();
1449
1578
  });
1450
1579
  };
1451
- const stateRef = (0, import_react10.useRef)(state);
1580
+ const stateRef = (0, import_react13.useRef)(state);
1452
1581
  stateRef.current = state;
1453
- const onColumnResizeRef = (0, import_react10.useRef)(onColumnResize);
1582
+ const onColumnResizeRef = (0, import_react13.useRef)(onColumnResize);
1454
1583
  onColumnResizeRef.current = onColumnResize;
1455
- (0, import_react10.useEffect)(() => {
1584
+ (0, import_react13.useEffect)(() => {
1456
1585
  if (!resizingColId) return;
1457
1586
  if (typeof document !== "undefined") {
1458
1587
  document.body.style.cursor = "col-resize";
@@ -1503,7 +1632,7 @@ var SpreadsheetEditor = ({
1503
1632
  window.removeEventListener("mouseup", handleMouseUp);
1504
1633
  };
1505
1634
  }, [resizingColId, resizeStartX, resizeStartWidth]);
1506
- const measureElementContentWidth = (0, import_react10.useCallback)((el, container) => {
1635
+ const measureElementContentWidth = (0, import_react13.useCallback)((el, container) => {
1507
1636
  if (typeof document === "undefined") return 0;
1508
1637
  let maxW = el.scrollWidth || 0;
1509
1638
  const firstChild = el.firstElementChild;
@@ -1551,7 +1680,7 @@ var SpreadsheetEditor = ({
1551
1680
  }
1552
1681
  return maxW;
1553
1682
  }, []);
1554
- const autoFitColumn = (0, import_react10.useCallback)((colId, colIndex) => {
1683
+ const autoFitColumn = (0, import_react13.useCallback)((colId, colIndex) => {
1555
1684
  const col = state.document.columns.find((c) => c.id === colId);
1556
1685
  if (!col) return;
1557
1686
  let calculatedWidth = 0;
@@ -1587,12 +1716,12 @@ var SpreadsheetEditor = ({
1587
1716
  onColumnResize(updatedCol.id, updatedCol.width || 130);
1588
1717
  }
1589
1718
  }, [state, measureElementContentWidth, onColumnResize]);
1590
- const handleResizeDblClick = (0, import_react10.useCallback)((colId, colIndex, e) => {
1719
+ const handleResizeDblClick = (0, import_react13.useCallback)((colId, colIndex, e) => {
1591
1720
  e.preventDefault();
1592
1721
  e.stopPropagation();
1593
1722
  autoFitColumn(colId, colIndex);
1594
1723
  }, [autoFitColumn]);
1595
- const handleHeaderDblClick = (0, import_react10.useCallback)((colId, colIndex, e) => {
1724
+ const handleHeaderDblClick = (0, import_react13.useCallback)((colId, colIndex, e) => {
1596
1725
  const target = e.currentTarget;
1597
1726
  if (target) {
1598
1727
  const rect = target.getBoundingClientRect();
@@ -1614,20 +1743,20 @@ var SpreadsheetEditor = ({
1614
1743
  const isActiveCell = (rIdx, cIdx) => {
1615
1744
  return state.activeCell?.row === rIdx && state.activeCell?.col === cIdx;
1616
1745
  };
1617
- const grid = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1746
+ const grid = /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1618
1747
  "div",
1619
1748
  {
1620
1749
  ref: gridRef,
1621
- className: "flex flex-col h-full w-full overflow-hidden border border-border bg-background select-none outline-none text-foreground font-sans text-xs",
1750
+ className: "relative flex flex-col h-full w-full overflow-hidden border border-border bg-background select-none outline-none text-foreground font-sans text-xs",
1622
1751
  tabIndex: 0,
1623
1752
  onKeyDown: handleKeyDown,
1624
1753
  role: "grid",
1625
1754
  "aria-label": "Spreadsheet",
1626
1755
  children: [
1627
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-2 border-b border-border bg-muted/20 px-3 py-1.5 text-xs font-mono", children: [
1628
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex h-6 min-w-[3rem] items-center justify-center rounded border border-border bg-background px-1.5 font-semibold text-foreground", children: coordLabel }),
1629
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex items-center text-muted-foreground select-none", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "italic font-serif font-bold text-sm text-primary", children: "fx" }) }),
1630
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1756
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2 border-b border-border bg-muted/20 px-3 py-1.5 text-xs font-mono", children: [
1757
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex h-6 min-w-[3rem] items-center justify-center rounded border border-border bg-background px-1.5 font-semibold text-foreground", children: coordLabel }),
1758
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex items-center text-muted-foreground select-none", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "italic font-serif font-bold text-sm text-primary", children: "fx" }) }),
1759
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1631
1760
  "input",
1632
1761
  {
1633
1762
  ref: formulaBarRef,
@@ -1663,7 +1792,7 @@ var SpreadsheetEditor = ({
1663
1792
  }
1664
1793
  }
1665
1794
  ),
1666
- !formulaBarReadOnly && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1795
+ !formulaBarReadOnly && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1667
1796
  FormulaHints,
1668
1797
  {
1669
1798
  inputRef: formulaBarRef,
@@ -1673,14 +1802,14 @@ var SpreadsheetEditor = ({
1673
1802
  }
1674
1803
  )
1675
1804
  ] }),
1676
- inputMessage && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { role: "note", "data-validation-input-message": "", className: "border-b border-border bg-muted/30 px-3 py-1 text-[11px] text-muted-foreground", children: [
1677
- inputMessage.inputTitle && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "mr-1 font-semibold text-foreground", children: inputMessage.inputTitle }),
1805
+ inputMessage && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { role: "note", "data-validation-input-message": "", className: "border-b border-border bg-muted/30 px-3 py-1 text-[11px] text-muted-foreground", children: [
1806
+ inputMessage.inputTitle && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "mr-1 font-semibold text-foreground", children: inputMessage.inputTitle }),
1678
1807
  inputMessage.inputMessage
1679
1808
  ] }),
1680
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { ref: scrollRef, className: "relative flex-1 overflow-auto", onScroll: handleGridScroll, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("table", { className: "border-separate border-spacing-0 table-fixed w-max min-w-full [&>*>tr:not([data-spacer])>*]:border-b [&>*>tr>*]:border-border", children: [
1681
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("tr", { className: "h-7 bg-muted sticky top-0 z-20 border-b border-border shadow-xs", children: [
1682
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("th", { className: "w-12 min-w-[3rem] sticky left-0 z-30 bg-muted border-r border-border text-center text-[10px] text-muted-foreground font-medium", children: "#" }),
1683
- columnSlots.map((slot) => slot.kind === "space" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1809
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { ref: scrollRef, className: "relative flex-1 overflow-auto", onScroll: handleGridScroll, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("table", { className: "border-separate border-spacing-0 table-fixed w-max min-w-full [&>*>tr:not([data-spacer])>*]:border-b [&>*>tr>*]:border-border", children: [
1810
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("tr", { className: "h-7 bg-muted sticky top-0 z-20 border-b border-border shadow-xs", children: [
1811
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("th", { className: "w-12 min-w-[3rem] sticky left-0 z-30 bg-muted border-r border-border text-center text-[10px] text-muted-foreground font-medium", children: "#" }),
1812
+ columnSlots.map((slot) => slot.kind === "space" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1684
1813
  "th",
1685
1814
  {
1686
1815
  "aria-hidden": "true",
@@ -1689,7 +1818,7 @@ var SpreadsheetEditor = ({
1689
1818
  style: { width: slot.width, minWidth: slot.width, maxWidth: slot.width, padding: 0 }
1690
1819
  },
1691
1820
  slot.key
1692
- ) : (({ column: col, index: cIdx, frozen, stickyLeft }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1821
+ ) : (({ column: col, index: cIdx, frozen, stickyLeft }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1693
1822
  "th",
1694
1823
  {
1695
1824
  "data-col": cIdx,
@@ -1704,16 +1833,16 @@ var SpreadsheetEditor = ({
1704
1833
  onClick: () => onColumnHeaderClick?.(col),
1705
1834
  onDoubleClick: (e) => handleHeaderDblClick(col.id, cIdx, e),
1706
1835
  children: [
1707
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center justify-between gap-1 min-w-0 overflow-hidden truncate", children: [
1708
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "truncate font-semibold text-foreground text-xs min-w-0", children: col.title }),
1709
- filteredColIds.has(col.id) && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-[10px] text-primary shrink-0", title: "Filtered", "data-filtered": "true", children: "\u23F7" }),
1710
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "text-[10px] text-muted-foreground/70 font-mono font-normal shrink-0", children: [
1836
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center justify-between gap-1 min-w-0 overflow-hidden truncate", children: [
1837
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "truncate font-semibold text-foreground text-xs min-w-0", children: col.title }),
1838
+ filteredColIds.has(col.id) && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-[10px] text-primary shrink-0", title: "Filtered", "data-filtered": "true", children: "\u23F7" }),
1839
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-[10px] text-muted-foreground/70 font-mono font-normal shrink-0", children: [
1711
1840
  "(",
1712
1841
  col.key,
1713
1842
  ")"
1714
1843
  ] })
1715
1844
  ] }),
1716
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1845
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1717
1846
  "div",
1718
1847
  {
1719
1848
  className: "col-resize-handle",
@@ -1730,7 +1859,7 @@ var SpreadsheetEditor = ({
1730
1859
  onDoubleClick: (e) => handleResizeDblClick(col.id, cIdx, e),
1731
1860
  role: "separator",
1732
1861
  "aria-orientation": "vertical",
1733
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1862
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1734
1863
  "div",
1735
1864
  {
1736
1865
  className: "col-resize-handle-line",
@@ -1749,23 +1878,23 @@ var SpreadsheetEditor = ({
1749
1878
  },
1750
1879
  col.id
1751
1880
  ))(slot.viewCol)),
1752
- onAddColumnClick && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1881
+ onAddColumnClick && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1753
1882
  "th",
1754
1883
  {
1755
1884
  className: "w-10 min-w-[2.5rem] px-1 text-center bg-muted/40 hover:bg-muted cursor-pointer transition-colors",
1756
1885
  onClick: onAddColumnClick,
1757
1886
  title: "Add Column",
1758
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-xs font-bold text-muted-foreground", children: "+" })
1887
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs font-bold text-muted-foreground", children: "+" })
1759
1888
  }
1760
1889
  )
1761
1890
  ] }) }),
1762
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("tbody", { children: rowSlots.map((rowSlot) => {
1891
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("tbody", { children: rowSlots.map((rowSlot) => {
1763
1892
  if (rowSlot.kind === "space") {
1764
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("tr", { "aria-hidden": "true", "data-spacer": "", style: { height: rowSlot.height }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("td", { colSpan: columnSlots.length + 2, style: { padding: 0, border: 0 } }) }, rowSlot.key);
1893
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("tr", { "aria-hidden": "true", "data-spacer": "", style: { height: rowSlot.height }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("td", { colSpan: columnSlots.length + 2, style: { padding: 0, border: 0 } }) }, rowSlot.key);
1765
1894
  }
1766
1895
  const viewRow = rowSlot.viewRow;
1767
1896
  if (viewRow.kind === "group") {
1768
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1897
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1769
1898
  SpreadsheetGroupRow,
1770
1899
  {
1771
1900
  group: viewRow.group,
@@ -1783,14 +1912,14 @@ var SpreadsheetEditor = ({
1783
1912
  }
1784
1913
  const displayRowIndex = viewRow.index;
1785
1914
  const selection = state.selectedRange ? (0, import_spreadsheet8.normalizeRange)(state.selectedRange) : null;
1786
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1915
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1787
1916
  "tr",
1788
1917
  {
1789
1918
  "data-row": displayRowIndex,
1790
1919
  className: `border-b border-border hover:bg-muted/10 transition-colors ${viewRow.section !== "body" ? "bg-muted/30 font-semibold" : ""}`,
1791
1920
  style: { height: viewRow.row.height || 32 },
1792
1921
  children: [
1793
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1922
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1794
1923
  "td",
1795
1924
  {
1796
1925
  className: "w-12 min-w-[3rem] sticky left-0 z-10 bg-muted border-r border-border text-center text-[10px] text-muted-foreground font-mono select-none",
@@ -1799,7 +1928,7 @@ var SpreadsheetEditor = ({
1799
1928
  }
1800
1929
  ),
1801
1930
  columnSlots.map((slot) => {
1802
- if (slot.kind === "space") return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("td", { "aria-hidden": "true", "data-spacer": "", style: { padding: 0 } }, slot.key);
1931
+ if (slot.kind === "space") return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("td", { "aria-hidden": "true", "data-spacer": "", style: { padding: 0 } }, slot.key);
1803
1932
  const viewCol = slot.viewCol;
1804
1933
  const span = view.getCellSpan(displayRowIndex, viewCol.index);
1805
1934
  if (!span) return null;
@@ -1817,7 +1946,7 @@ var SpreadsheetEditor = ({
1817
1946
  const showListArrow = active && !isEditing && !!activeListValues;
1818
1947
  const inFillPreview = !!fillTarget && !selected && (0, import_spreadsheet8.rangeContains)(fillTarget, displayRowIndex, viewCol.index);
1819
1948
  const showFillHandle = !readOnly && !isEditing && !!selection && (span.merge ? (0, import_spreadsheet8.rangeContains)(span.merge, selection.endRow, selection.endCol) : selection.endRow === rIdx && selection.endCol === cIdx);
1820
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1949
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1821
1950
  "td",
1822
1951
  {
1823
1952
  "data-row": rIdx,
@@ -1840,8 +1969,8 @@ var SpreadsheetEditor = ({
1840
1969
  onContextMenu: (e) => handleCellContextMenu(rIdx, cIdx, e),
1841
1970
  onMouseOver: () => extendFill(displayRowIndex, viewCol.index),
1842
1971
  children: [
1843
- isEditing ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1844
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1972
+ isEditing ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1973
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1845
1974
  "input",
1846
1975
  {
1847
1976
  ref: cellInputRef,
@@ -1857,9 +1986,9 @@ var SpreadsheetEditor = ({
1857
1986
  autoFocus: true
1858
1987
  }
1859
1988
  ),
1860
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FormulaHints, { inputRef: cellInputRef, value: state.draftValue, onAccept: state.setDraftValue, names: nameSuggestions })
1861
- ] }) : customCellRenderer ? customCellRenderer({ row, col, cell }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CellText, { cell, conditional }),
1862
- circled && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1989
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FormulaHints, { inputRef: cellInputRef, value: state.draftValue, onAccept: state.setDraftValue, names: nameSuggestions })
1990
+ ] }) : customCellRenderer ? customCellRenderer({ row, col, cell }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CellText, { cell, conditional }),
1991
+ circled && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1863
1992
  "span",
1864
1993
  {
1865
1994
  className: "spreadsheet-invalid-circle",
@@ -1867,7 +1996,7 @@ var SpreadsheetEditor = ({
1867
1996
  style: { position: "absolute", inset: "1px 2px", border: "2px solid #e11d48", borderRadius: "50%", pointerEvents: "none", zIndex: 6 }
1868
1997
  }
1869
1998
  ),
1870
- showListArrow && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1999
+ showListArrow && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1871
2000
  "button",
1872
2001
  {
1873
2002
  type: "button",
@@ -1885,8 +2014,8 @@ var SpreadsheetEditor = ({
1885
2014
  children: "\u25BE"
1886
2015
  }
1887
2016
  ),
1888
- activeSpill && (0, import_spreadsheet8.rangeContains)(activeSpill.range, rIdx, cIdx) && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { "aria-hidden": "true", className: "spreadsheet-spill-border", style: spillBorderStyle(activeSpill.range, rIdx, cIdx) }),
1889
- showFillHandle && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2017
+ activeSpill && (0, import_spreadsheet8.rangeContains)(activeSpill.range, rIdx, cIdx) && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { "aria-hidden": "true", className: "spreadsheet-spill-border", style: spillBorderStyle(activeSpill.range, rIdx, cIdx) }),
2018
+ showFillHandle && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1890
2019
  "div",
1891
2020
  {
1892
2021
  className: "spreadsheet-fill-handle",
@@ -1901,14 +2030,14 @@ var SpreadsheetEditor = ({
1901
2030
  viewCol.column.id
1902
2031
  );
1903
2032
  }),
1904
- onAddColumnClick && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("td", { className: "w-10 min-w-[2.5rem] bg-muted/10 border-r border-border" })
2033
+ onAddColumnClick && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("td", { className: "w-10 min-w-[2.5rem] bg-muted/10 border-r border-border" })
1905
2034
  ]
1906
2035
  },
1907
2036
  viewRow.row.id
1908
2037
  );
1909
2038
  }) })
1910
2039
  ] }) }),
1911
- menu && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2040
+ menu && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1912
2041
  SpreadsheetContextMenu,
1913
2042
  {
1914
2043
  items: menu.items,
@@ -1921,9 +2050,9 @@ var SpreadsheetEditor = ({
1921
2050
  onOpenPanel: setPanel
1922
2051
  }
1923
2052
  ),
1924
- panel === "conditionalFormatting" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SpreadsheetConditionalFormatPanel, { state, onClose: () => setPanel(null) }),
1925
- panel === "dataValidation" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SpreadsheetDataValidationPanel, { state, onClose: () => setPanel(null) }),
1926
- listMenu && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
2053
+ panel === "conditionalFormatting" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SpreadsheetConditionalFormatPanel, { state, onClose: () => setPanel(null) }),
2054
+ panel === "dataValidation" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SpreadsheetDataValidationPanel, { state, onClose: () => setPanel(null) }),
2055
+ listMenu && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1927
2056
  "div",
1928
2057
  {
1929
2058
  role: "listbox",
@@ -1938,8 +2067,8 @@ var SpreadsheetEditor = ({
1938
2067
  }
1939
2068
  },
1940
2069
  children: [
1941
- listMenu.values.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "px-3 py-1 text-muted-foreground", children: "No values" }),
1942
- listMenu.values.map((value, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2070
+ listMenu.values.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "px-3 py-1 text-muted-foreground", children: "No values" }),
2071
+ listMenu.values.map((value, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1943
2072
  "button",
1944
2073
  {
1945
2074
  type: "button",
@@ -1954,8 +2083,9 @@ var SpreadsheetEditor = ({
1954
2083
  ]
1955
2084
  }
1956
2085
  ),
1957
- state.validationPrompt && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SpreadsheetValidationDialog, { prompt: state.validationPrompt, onResolve: resolveValidation }),
1958
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("style", { children: `
2086
+ state.validationPrompt && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SpreadsheetValidationDialog, { prompt: state.validationPrompt, onResolve: resolveValidation }),
2087
+ playing && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PresenceLayer, { presence: agentPresence }),
2088
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("style", { children: `
1959
2089
  .col-resize-handle:hover .col-resize-handle-line {
1960
2090
  background-color: var(--primary, #6366f1);
1961
2091
  opacity: 0.75;
@@ -1976,26 +2106,26 @@ var SpreadsheetEditor = ({
1976
2106
  }
1977
2107
  );
1978
2108
  if (!showSheetTabs) return grid;
1979
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex h-full w-full flex-col", children: [
1980
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "min-h-0 flex-1", children: grid }),
1981
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SheetTabs, { state, readOnly })
2109
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex h-full w-full flex-col", children: [
2110
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "min-h-0 flex-1", children: grid }),
2111
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SheetTabs, { state, readOnly })
1982
2112
  ] });
1983
2113
  };
1984
2114
 
1985
2115
  // src/spreadsheet/NameManager.tsx
1986
- var import_react11 = require("react");
2116
+ var import_react14 = require("react");
1987
2117
  var import_spreadsheet9 = require("@pixerate/editor/spreadsheet");
1988
- var import_jsx_runtime8 = require("react/jsx-runtime");
2118
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1989
2119
  var EMPTY_DRAFT = { original: null, name: "", refersTo: "=", scope: "", comment: "" };
1990
2120
  var NameManager = ({ state, readOnly = false, onClose, className = "" }) => {
1991
2121
  const { controller, sheets } = state;
1992
- const rows = (0, import_react11.useMemo)(
2122
+ const rows = (0, import_react14.useMemo)(
1993
2123
  () => (0, import_spreadsheet9.getNameManagerRows)(controller),
1994
2124
  // eslint-disable-next-line react-hooks/exhaustive-deps
1995
2125
  [controller, state.document, state.names]
1996
2126
  );
1997
- const [draft, setDraft] = (0, import_react11.useState)(EMPTY_DRAFT);
1998
- const [error, setError] = (0, import_react11.useState)(null);
2127
+ const [draft, setDraft] = (0, import_react14.useState)(EMPTY_DRAFT);
2128
+ const [error, setError] = (0, import_react14.useState)(null);
1999
2129
  const edit = (row) => {
2000
2130
  setError(null);
2001
2131
  setDraft({
@@ -2033,29 +2163,29 @@ var NameManager = ({ state, readOnly = false, onClose, className = "" }) => {
2033
2163
  setError(err?.message ?? String(err));
2034
2164
  }
2035
2165
  };
2036
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { "aria-label": "Name Manager", className: `flex flex-col gap-2 text-xs ${className}`, "data-name-manager": "", children: [
2037
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center justify-between", children: [
2038
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h3", { className: "m-0 text-sm font-semibold", children: "Name Manager" }),
2039
- onClose && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "aria-label": "Close Name Manager", className: "rounded px-2 hover:bg-muted", onClick: onClose, children: "\xD7" })
2166
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { "aria-label": "Name Manager", className: `flex flex-col gap-2 text-xs ${className}`, "data-name-manager": "", children: [
2167
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center justify-between", children: [
2168
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h3", { className: "m-0 text-sm font-semibold", children: "Name Manager" }),
2169
+ onClose && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", "aria-label": "Close Name Manager", className: "rounded px-2 hover:bg-muted", onClick: onClose, children: "\xD7" })
2040
2170
  ] }),
2041
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("table", { className: "w-full border-collapse", children: [
2042
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("tr", { className: "text-left text-muted-foreground", children: [
2043
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("th", { className: "px-1 font-medium", children: "Name" }),
2044
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("th", { className: "px-1 font-medium", children: "Value" }),
2045
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("th", { className: "px-1 font-medium", children: "Refers to" }),
2046
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("th", { className: "px-1 font-medium", children: "Scope" }),
2047
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("th", { className: "px-1" })
2171
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("table", { className: "w-full border-collapse", children: [
2172
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("tr", { className: "text-left text-muted-foreground", children: [
2173
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("th", { className: "px-1 font-medium", children: "Name" }),
2174
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("th", { className: "px-1 font-medium", children: "Value" }),
2175
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("th", { className: "px-1 font-medium", children: "Refers to" }),
2176
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("th", { className: "px-1 font-medium", children: "Scope" }),
2177
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("th", { className: "px-1" })
2048
2178
  ] }) }),
2049
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("tbody", { children: [
2050
- rows.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("td", { colSpan: 5, className: "px-1 py-2 text-muted-foreground", children: "No names yet." }) }),
2051
- rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("tr", { "data-name": row.name, className: "border-t border-border", title: row.comment, children: [
2052
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("td", { className: "px-1 py-0.5 font-mono font-semibold", children: row.name }),
2053
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("td", { className: "px-1 py-0.5", children: row.value }),
2054
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("td", { className: "px-1 py-0.5 font-mono", children: row.refersTo }),
2055
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("td", { className: "px-1 py-0.5", children: row.scopeLabel }),
2056
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("td", { className: "whitespace-nowrap px-1 py-0.5 text-right", children: [
2057
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "aria-label": `Edit ${row.name}`, className: "rounded px-1 hover:bg-muted", onClick: () => edit(row), children: "Edit" }),
2058
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2179
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("tbody", { children: [
2180
+ rows.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("td", { colSpan: 5, className: "px-1 py-2 text-muted-foreground", children: "No names yet." }) }),
2181
+ rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("tr", { "data-name": row.name, className: "border-t border-border", title: row.comment, children: [
2182
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("td", { className: "px-1 py-0.5 font-mono font-semibold", children: row.name }),
2183
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("td", { className: "px-1 py-0.5", children: row.value }),
2184
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("td", { className: "px-1 py-0.5 font-mono", children: row.refersTo }),
2185
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("td", { className: "px-1 py-0.5", children: row.scopeLabel }),
2186
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("td", { className: "whitespace-nowrap px-1 py-0.5 text-right", children: [
2187
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", "aria-label": `Edit ${row.name}`, className: "rounded px-1 hover:bg-muted", onClick: () => edit(row), children: "Edit" }),
2188
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2059
2189
  "button",
2060
2190
  {
2061
2191
  type: "button",
@@ -2072,9 +2202,9 @@ var NameManager = ({ state, readOnly = false, onClose, className = "" }) => {
2072
2202
  ] }, `${row.sheetId ?? ""}!${row.name}`))
2073
2203
  ] })
2074
2204
  ] }),
2075
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("form", { className: "grid grid-cols-[auto_1fr] items-center gap-x-2 gap-y-1", onSubmit: save, "aria-label": draft.original ? `Edit name ${draft.original.name}` : "New name", children: [
2076
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: "pixerate-name-manager-name", children: "Name" }),
2077
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2205
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("form", { className: "grid grid-cols-[auto_1fr] items-center gap-x-2 gap-y-1", onSubmit: save, "aria-label": draft.original ? `Edit name ${draft.original.name}` : "New name", children: [
2206
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { htmlFor: "pixerate-name-manager-name", children: "Name" }),
2207
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2078
2208
  "input",
2079
2209
  {
2080
2210
  id: "pixerate-name-manager-name",
@@ -2083,8 +2213,8 @@ var NameManager = ({ state, readOnly = false, onClose, className = "" }) => {
2083
2213
  onChange: (e) => setDraft({ ...draft, name: e.target.value })
2084
2214
  }
2085
2215
  ),
2086
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: "pixerate-name-manager-refers", children: "Refers to" }),
2087
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2216
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { htmlFor: "pixerate-name-manager-refers", children: "Refers to" }),
2217
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2088
2218
  "input",
2089
2219
  {
2090
2220
  id: "pixerate-name-manager-refers",
@@ -2093,8 +2223,8 @@ var NameManager = ({ state, readOnly = false, onClose, className = "" }) => {
2093
2223
  onChange: (e) => setDraft({ ...draft, refersTo: e.target.value })
2094
2224
  }
2095
2225
  ),
2096
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: "pixerate-name-manager-scope", children: "Scope" }),
2097
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
2226
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { htmlFor: "pixerate-name-manager-scope", children: "Scope" }),
2227
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
2098
2228
  "select",
2099
2229
  {
2100
2230
  id: "pixerate-name-manager-scope",
@@ -2102,13 +2232,13 @@ var NameManager = ({ state, readOnly = false, onClose, className = "" }) => {
2102
2232
  value: draft.scope,
2103
2233
  onChange: (e) => setDraft({ ...draft, scope: e.target.value }),
2104
2234
  children: [
2105
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: "Workbook" }),
2106
- sheets.map((sheet) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: sheet.id, children: sheet.name }, sheet.id))
2235
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: "", children: "Workbook" }),
2236
+ sheets.map((sheet) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: sheet.id, children: sheet.name }, sheet.id))
2107
2237
  ]
2108
2238
  }
2109
2239
  ),
2110
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: "pixerate-name-manager-comment", children: "Comment" }),
2111
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2240
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { htmlFor: "pixerate-name-manager-comment", children: "Comment" }),
2241
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2112
2242
  "input",
2113
2243
  {
2114
2244
  id: "pixerate-name-manager-comment",
@@ -2117,9 +2247,9 @@ var NameManager = ({ state, readOnly = false, onClose, className = "" }) => {
2117
2247
  onChange: (e) => setDraft({ ...draft, comment: e.target.value })
2118
2248
  }
2119
2249
  ),
2120
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "col-span-2 flex gap-2", children: [
2121
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "submit", className: "rounded bg-primary px-2 py-0.5 text-primary-foreground", children: draft.original ? "Save" : "Add name" }),
2122
- draft.original && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2250
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "col-span-2 flex gap-2", children: [
2251
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "submit", className: "rounded bg-primary px-2 py-0.5 text-primary-foreground", children: draft.original ? "Save" : "Add name" }),
2252
+ draft.original && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2123
2253
  "button",
2124
2254
  {
2125
2255
  type: "button",
@@ -2133,7 +2263,7 @@ var NameManager = ({ state, readOnly = false, onClose, className = "" }) => {
2133
2263
  )
2134
2264
  ] })
2135
2265
  ] }),
2136
- error && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { role: "alert", className: "text-destructive", children: error })
2266
+ error && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { role: "alert", className: "text-destructive", children: error })
2137
2267
  ] });
2138
2268
  };
2139
2269
  // Annotate the CommonJS export names for ESM import in node: