@pixerate/editor-react 0.208.0 → 0.209.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.
package/dist/index.cjs CHANGED
@@ -137,6 +137,7 @@ __export(src_exports, {
137
137
  useImageEffectsTools: () => useImageEffectsTools,
138
138
  useImageHistogram: () => useImageHistogram,
139
139
  useJobProgress: () => useJobProgress,
140
+ useLinkFocus: () => useLinkFocus,
140
141
  useMergePreview: () => useMergePreview,
141
142
  useNavigationGuard: () => useNavigationGuard,
142
143
  useOutline: () => useOutline,
@@ -452,20 +453,51 @@ function useHistory(managerOrOptions) {
452
453
  };
453
454
  }
454
455
 
455
- // src/hooks/useHistoryDirty.ts
456
+ // src/hooks/useLinkFocus.ts
456
457
  var import_react7 = require("react");
458
+ var import_tools = require("@pixerate/editor/tools");
459
+ function useLinkFocus(options) {
460
+ const [model] = (0, import_react7.useState)(() => options.model ?? (0, import_tools.createLinkFocus)({ marks: options.marks ?? [], links: options.links ?? {}, order: options.order, labels: options.labels, dim: options.dim }));
461
+ const state = (0, import_react7.useSyncExternalStore)(model.subscribe, model.getState, model.getState);
462
+ const markProps = (0, import_react7.useCallback)(
463
+ (key) => ({ onPointerEnter: () => model.focus(key), onFocus: () => model.focus(key), "data-link-focus": key }),
464
+ [model]
465
+ );
466
+ const rootProps = {
467
+ onKeyDown: (event) => {
468
+ if (model.handleKey(event)) event.preventDefault();
469
+ },
470
+ onPointerLeave: () => {
471
+ model.clear();
472
+ },
473
+ onBlur: (event) => {
474
+ if (!event.currentTarget.contains(event.relatedTarget)) model.clear();
475
+ }
476
+ };
477
+ return {
478
+ model,
479
+ state,
480
+ markProps,
481
+ rootProps,
482
+ opacity: (index) => state.lit[index] ? 1 : model.dim,
483
+ description: model.describe(state.focus)
484
+ };
485
+ }
486
+
487
+ // src/hooks/useHistoryDirty.ts
488
+ var import_react8 = require("react");
457
489
  var import_editor4 = require("@pixerate/editor");
458
490
  function useHistoryDirty(options) {
459
- const getValueRef = (0, import_react7.useRef)(options.getValue);
491
+ const getValueRef = (0, import_react8.useRef)(options.getValue);
460
492
  getValueRef.current = options.getValue;
461
- const [tracker] = (0, import_react7.useState)(
493
+ const [tracker] = (0, import_react8.useState)(
462
494
  () => options.tracker ?? new import_editor4.DirtyTracker(options.getValue(), {
463
495
  isEqual: options.isEqual,
464
496
  normalize: options.normalize
465
497
  })
466
498
  );
467
- const bindingRef = (0, import_react7.useRef)(null);
468
- (0, import_react7.useEffect)(() => {
499
+ const bindingRef = (0, import_react8.useRef)(null);
500
+ (0, import_react8.useEffect)(() => {
469
501
  const binding = (0, import_editor4.bindDirtyToHistory)({
470
502
  history: options.history,
471
503
  getValue: () => getValueRef.current(),
@@ -477,20 +509,20 @@ function useHistoryDirty(options) {
477
509
  if (bindingRef.current === binding) bindingRef.current = null;
478
510
  };
479
511
  }, [options.history, tracker]);
480
- const isDirty = (0, import_react7.useSyncExternalStore)(
481
- (0, import_react7.useCallback)((onChange) => tracker.subscribe(onChange), [tracker]),
512
+ const isDirty = (0, import_react8.useSyncExternalStore)(
513
+ (0, import_react8.useCallback)((onChange) => tracker.subscribe(onChange), [tracker]),
482
514
  () => tracker.dirty,
483
515
  () => tracker.dirty
484
516
  );
485
- const markClean = (0, import_react7.useCallback)(
517
+ const markClean = (0, import_react8.useCallback)(
486
518
  () => tracker.markClean(getValueRef.current()),
487
519
  [tracker]
488
520
  );
489
- const suppress = (0, import_react7.useCallback)(
521
+ const suppress = (0, import_react8.useCallback)(
490
522
  (fn) => bindingRef.current ? bindingRef.current.suppress(fn) : tracker.suppress(fn),
491
523
  [tracker]
492
524
  );
493
- const refresh = (0, import_react7.useCallback)(
525
+ const refresh = (0, import_react8.useCallback)(
494
526
  () => tracker.update(getValueRef.current()),
495
527
  [tracker]
496
528
  );
@@ -498,7 +530,7 @@ function useHistoryDirty(options) {
498
530
  }
499
531
 
500
532
  // src/hooks/useHistoryShortcuts.ts
501
- var import_react8 = require("react");
533
+ var import_react9 = require("react");
502
534
  var import_commands = require("@pixerate/editor/commands");
503
535
  function useHistoryShortcuts(manager, options = {}) {
504
536
  const {
@@ -506,7 +538,7 @@ function useHistoryShortcuts(manager, options = {}) {
506
538
  target,
507
539
  ignoreEditableElements = true
508
540
  } = options;
509
- (0, import_react8.useEffect)(() => {
541
+ (0, import_react9.useEffect)(() => {
510
542
  if (!enabled) return;
511
543
  const eventTarget = target ?? (typeof window !== "undefined" ? window : null);
512
544
  if (!eventTarget) return;
@@ -529,23 +561,23 @@ function useHistoryShortcuts(manager, options = {}) {
529
561
  }
530
562
 
531
563
  // src/hooks/useFileImport.ts
532
- var import_react9 = require("react");
564
+ var import_react10 = require("react");
533
565
  var import_editor5 = require("@pixerate/editor");
534
566
  function useFileImport(editor, options = {}) {
535
- const editorRef = (0, import_react9.useRef)(editor);
567
+ const editorRef = (0, import_react10.useRef)(editor);
536
568
  editorRef.current = editor;
537
- const controller = (0, import_react9.useMemo)(
569
+ const controller = (0, import_react10.useMemo)(
538
570
  () => new import_editor5.FileImportController(() => {
539
571
  const current = editorRef.current;
540
572
  return current && !current.isDestroyed ? current : null;
541
573
  }, options),
542
574
  []
543
575
  );
544
- (0, import_react9.useEffect)(() => {
576
+ (0, import_react10.useEffect)(() => {
545
577
  controller.setOptions(options);
546
578
  });
547
- const state = (0, import_react9.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
548
- const structureSummary = (0, import_react9.useMemo)(() => (0, import_editor5.summarizeImportStructure)(state.lastOutcomes), [state.lastOutcomes]);
579
+ const state = (0, import_react10.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
580
+ const structureSummary = (0, import_react10.useMemo)(() => (0, import_editor5.summarizeImportStructure)(state.lastOutcomes), [state.lastOutcomes]);
549
581
  return {
550
582
  ...state,
551
583
  structureSummary,
@@ -556,22 +588,22 @@ function useFileImport(editor, options = {}) {
556
588
  }
557
589
 
558
590
  // src/hooks/useDocxExport.ts
559
- var import_react10 = require("react");
591
+ var import_react11 = require("react");
560
592
  var import_export = require("@pixerate/editor/export");
561
593
  function useDocxExport(editor, options = {}) {
562
- const editorRef = (0, import_react10.useRef)(editor);
594
+ const editorRef = (0, import_react11.useRef)(editor);
563
595
  editorRef.current = editor;
564
- const controller = (0, import_react10.useMemo)(
596
+ const controller = (0, import_react11.useMemo)(
565
597
  () => new import_export.DocxExportController(() => {
566
598
  const current = editorRef.current;
567
599
  return current && !current.isDestroyed ? current : null;
568
600
  }, options),
569
601
  []
570
602
  );
571
- (0, import_react10.useEffect)(() => {
603
+ (0, import_react11.useEffect)(() => {
572
604
  controller.setOptions(options);
573
605
  });
574
- const state = (0, import_react10.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
606
+ const state = (0, import_react11.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
575
607
  return {
576
608
  ...state,
577
609
  download: (fileName) => controller.download(fileName),
@@ -607,32 +639,32 @@ var ExportDocxButton = ({
607
639
  };
608
640
 
609
641
  // src/hooks/useAgentToolProvider.ts
610
- var import_react11 = require("react");
642
+ var import_react12 = require("react");
611
643
  function useAgentToolProvider(registry, provider, options = {}) {
612
644
  const { playback } = options;
613
- (0, import_react11.useEffect)(() => {
645
+ (0, import_react12.useEffect)(() => {
614
646
  if (registry && playback) playback.install(registry);
615
647
  }, [registry, playback]);
616
- (0, import_react11.useEffect)(() => {
648
+ (0, import_react12.useEffect)(() => {
617
649
  if (!registry || !provider) return;
618
650
  return registry.register(provider);
619
651
  }, [registry, provider]);
620
652
  }
621
653
 
622
654
  // src/hooks/useRichTextEditorDocument.ts
623
- var import_react12 = require("react");
655
+ var import_react13 = require("react");
624
656
  var import_editor6 = require("@pixerate/editor");
625
657
  function useRichTextEditorDocument(editor) {
626
- const doc = (0, import_react12.useMemo)(() => editor ? (0, import_editor6.createRichTextEditorDocument)(editor) : null, [editor]);
627
- (0, import_react12.useEffect)(() => () => doc?.destroy(), [doc]);
658
+ const doc = (0, import_react13.useMemo)(() => editor ? (0, import_editor6.createRichTextEditorDocument)(editor) : null, [editor]);
659
+ (0, import_react13.useEffect)(() => () => doc?.destroy(), [doc]);
628
660
  return doc;
629
661
  }
630
662
 
631
663
  // src/playback/PresenceLayer.tsx
632
- var import_react13 = __toESM(require("react"), 1);
664
+ var import_react14 = __toESM(require("react"), 1);
633
665
  var import_jsx_runtime3 = require("react/jsx-runtime");
634
666
  function PresenceLayer({ presence, viewport, clip = true, renderCursor, className = "" }) {
635
- const { actors } = (0, import_react13.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
667
+ const { actors } = (0, import_react14.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
636
668
  if (!actors.length) return null;
637
669
  const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
638
670
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -649,7 +681,7 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
649
681
  const br = map({ x: a.focus.x + a.focus.width, y: a.focus.y + a.focus.height });
650
682
  return { left: tl.x - 4, top: tl.y - 4, width: br.x - tl.x + 8, height: br.y - tl.y + 8 };
651
683
  })();
652
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react13.default.Fragment, { children: [
684
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react14.default.Fragment, { children: [
653
685
  ring && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
654
686
  "div",
655
687
  {
@@ -671,27 +703,27 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
671
703
  }
672
704
 
673
705
  // src/playback/AgentPlaybackContext.tsx
674
- var import_react14 = require("react");
706
+ var import_react15 = require("react");
675
707
  var import_jsx_runtime4 = require("react/jsx-runtime");
676
- var AgentPlaybackContext = (0, import_react14.createContext)(null);
708
+ var AgentPlaybackContext = (0, import_react15.createContext)(null);
677
709
  function AgentPlaybackProvider({ playback, children }) {
678
710
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AgentPlaybackContext.Provider, { value: playback ?? null, children });
679
711
  }
680
712
  function useAgentPlayback() {
681
- return (0, import_react14.useContext)(AgentPlaybackContext);
713
+ return (0, import_react15.useContext)(AgentPlaybackContext);
682
714
  }
683
715
 
684
716
  // src/playback/usePlaybackSurface.ts
685
- var import_react15 = require("react");
686
- var import_tools = require("@pixerate/editor/tools");
717
+ var import_react16 = require("react");
718
+ var import_tools2 = require("@pixerate/editor/tools");
687
719
  function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
688
720
  const ambient = useAgentPlayback();
689
721
  const target = playback === void 0 ? ambient : playback;
690
- const [ownPresence] = (0, import_react15.useState)(() => new import_tools.PresenceStore());
722
+ const [ownPresence] = (0, import_react16.useState)(() => new import_tools2.PresenceStore());
691
723
  const presence = sharedPresence ?? ownPresence;
692
- const latest = (0, import_react15.useRef)(options);
724
+ const latest = (0, import_react16.useRef)(options);
693
725
  latest.current = options;
694
- (0, import_react15.useEffect)(() => {
726
+ (0, import_react16.useEffect)(() => {
695
727
  if (!target || !id) return;
696
728
  const o = () => latest.current;
697
729
  const surface = {
@@ -723,10 +755,10 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
723
755
  }
724
756
 
725
757
  // src/playback/useElementPlaybackSurface.ts
726
- var import_react16 = require("react");
727
- var import_tools2 = require("@pixerate/editor/tools");
758
+ var import_react17 = require("react");
759
+ var import_tools3 = require("@pixerate/editor/tools");
728
760
  function useElementPlaybackSurface(playback, id, element, options) {
729
- const latest = (0, import_react16.useRef)(options);
761
+ const latest = (0, import_react17.useRef)(options);
730
762
  latest.current = options;
731
763
  const box = () => element.current?.getBoundingClientRect() ?? null;
732
764
  const fromViewport = (p) => {
@@ -742,7 +774,7 @@ function useElementPlaybackSurface(playback, id, element, options) {
742
774
  const b = box();
743
775
  const r = selector ? element.current?.querySelector(selector)?.getBoundingClientRect() : null;
744
776
  if (b && r && r.width > 0) return { x: r.left - b.left, y: r.top - b.top, width: r.width, height: r.height };
745
- return (0, import_tools2.locatePlaybackChrome)(ref, latest.current, fromViewport);
777
+ return (0, import_tools3.locatePlaybackChrome)(ref, latest.current, fromViewport);
746
778
  },
747
779
  bounds: () => {
748
780
  const r = box();
@@ -765,18 +797,18 @@ function useElementPlaybackSurface(playback, id, element, options) {
765
797
  }
766
798
 
767
799
  // src/hooks/useToolBridge.ts
768
- var import_react17 = require("react");
769
- var import_tools3 = require("@pixerate/editor/tools");
800
+ var import_react18 = require("react");
801
+ var import_tools4 = require("@pixerate/editor/tools");
770
802
  function useToolBridge(registry, options) {
771
- const [state, setState] = (0, import_react17.useState)({ status: "off", editorId: null });
803
+ const [state, setState] = (0, import_react18.useState)({ status: "off", editorId: null });
772
804
  const key = options ? JSON.stringify([options.url, options.token, options.name, options.kind, options.reconnect]) : null;
773
- (0, import_react17.useEffect)(() => {
805
+ (0, import_react18.useEffect)(() => {
774
806
  if (!registry || !options) {
775
807
  setState({ status: "off", editorId: null });
776
808
  return;
777
809
  }
778
810
  let connection;
779
- connection = (0, import_tools3.connectToolBridge)(registry, {
811
+ connection = (0, import_tools4.connectToolBridge)(registry, {
780
812
  ...options,
781
813
  onStatus: (status, detail) => {
782
814
  setState({ status, detail, editorId: connection?.editorId ?? null });
@@ -790,36 +822,36 @@ function useToolBridge(registry, options) {
790
822
  }
791
823
 
792
824
  // src/hooks/useToolRegistryView.ts
793
- var import_react18 = require("react");
825
+ var import_react19 = require("react");
794
826
  function useToolRegistryView(registry, options = {}) {
795
827
  const { toolsets, readOnly, discovery } = options;
796
- const view = (0, import_react18.useMemo)(
828
+ const view = (0, import_react19.useMemo)(
797
829
  () => registry ? registry.view({ toolsets, readOnly, discovery }) : null,
798
830
  // toolsets is applied below without making a new view, so enabled tools survive.
799
831
  // eslint-disable-next-line react-hooks/exhaustive-deps
800
832
  [registry, readOnly, discovery]
801
833
  );
802
834
  const toolsetsKey = typeof toolsets === "function" ? toolsets : JSON.stringify(toolsets ?? null);
803
- (0, import_react18.useEffect)(() => {
835
+ (0, import_react19.useEffect)(() => {
804
836
  view?.setToolsets(toolsets);
805
837
  }, [view, toolsetsKey]);
806
- (0, import_react18.useEffect)(() => () => view?.dispose(), [view]);
838
+ (0, import_react19.useEffect)(() => () => view?.dispose(), [view]);
807
839
  return view;
808
840
  }
809
841
 
810
842
  // src/components/EditorContent.tsx
811
- var import_react19 = require("@tiptap/react");
843
+ var import_react20 = require("@tiptap/react");
812
844
  var import_jsx_runtime5 = require("react/jsx-runtime");
813
845
  var EditorContent = ({
814
846
  className,
815
847
  editor,
816
848
  ...props
817
849
  }) => {
818
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react19.EditorContent, { editor, ...props }) });
850
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react20.EditorContent, { editor, ...props }) });
819
851
  };
820
852
 
821
853
  // src/components/BubbleMenu.tsx
822
- var import_react20 = require("react");
854
+ var import_react21 = require("react");
823
855
  var import_react_dom = require("react-dom");
824
856
  var import_extension_bubble_menu = require("@tiptap/extension-bubble-menu");
825
857
  var BubbleMenu = ({
@@ -831,12 +863,12 @@ var BubbleMenu = ({
831
863
  pluginKey = "bubbleMenu",
832
864
  updateDelay
833
865
  }) => {
834
- const menuEl = (0, import_react20.useRef)(null);
835
- const [mounted, setMounted] = (0, import_react20.useState)(false);
866
+ const menuEl = (0, import_react21.useRef)(null);
867
+ const [mounted, setMounted] = (0, import_react21.useState)(false);
836
868
  if (!menuEl.current && typeof document !== "undefined") {
837
869
  menuEl.current = document.createElement("div");
838
870
  }
839
- (0, import_react20.useEffect)(() => {
871
+ (0, import_react21.useEffect)(() => {
840
872
  if (!editor || !menuEl.current || editor.isDestroyed) {
841
873
  return;
842
874
  }
@@ -867,7 +899,7 @@ var BubbleMenu = ({
867
899
  };
868
900
 
869
901
  // src/components/TemplateRenderer.tsx
870
- var import_react21 = require("react");
902
+ var import_react22 = require("react");
871
903
  var import_editor7 = require("@pixerate/editor");
872
904
  var import_jsx_runtime6 = require("react/jsx-runtime");
873
905
  var TemplateRenderer = ({
@@ -881,11 +913,11 @@ var TemplateRenderer = ({
881
913
  onTemplateClick,
882
914
  onVariableClick
883
915
  }) => {
884
- const displayText = (0, import_react21.useMemo)(() => {
916
+ const displayText = (0, import_react22.useMemo)(() => {
885
917
  if (!resolve || templates.length === 0) return content;
886
918
  return (0, import_editor7.resolveTemplates)(content, templates, { bindings });
887
919
  }, [content, templates, resolve, bindings]);
888
- const tokens = (0, import_react21.useMemo)(() => {
920
+ const tokens = (0, import_react22.useMemo)(() => {
889
921
  return (0, import_editor7.evaluatePromptTokens)(displayText, values);
890
922
  }, [displayText, values]);
891
923
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className, children: tokens.map((token, index) => {
@@ -974,7 +1006,7 @@ var TemplateRenderer = ({
974
1006
  };
975
1007
 
976
1008
  // src/components/VariableForm.tsx
977
- var import_react22 = require("react");
1009
+ var import_react23 = require("react");
978
1010
  var import_editor8 = require("@pixerate/editor");
979
1011
  var import_jsx_runtime7 = require("react/jsx-runtime");
980
1012
  var VariableForm = ({
@@ -986,12 +1018,12 @@ var VariableForm = ({
986
1018
  onChange,
987
1019
  className = "flex flex-col gap-3 text-sm"
988
1020
  }) => {
989
- const idPrefix = (0, import_react22.useId)();
990
- const [internal, setInternal] = (0, import_react22.useState)(
1021
+ const idPrefix = (0, import_react23.useId)();
1022
+ const [internal, setInternal] = (0, import_react23.useState)(
991
1023
  () => defaultValues ?? {}
992
1024
  );
993
1025
  const entered = values ?? internal;
994
- const fields = (0, import_react22.useMemo)(
1026
+ const fields = (0, import_react23.useMemo)(
995
1027
  () => (0, import_editor8.getVariableFormFields)(content, { templates, bindings }),
996
1028
  [content, templates, bindings]
997
1029
  );
@@ -1059,26 +1091,26 @@ var VariableForm = ({
1059
1091
  };
1060
1092
 
1061
1093
  // src/components/MergePreview.tsx
1062
- var import_react24 = require("react");
1094
+ var import_react25 = require("react");
1063
1095
 
1064
1096
  // src/hooks/useMergePreview.ts
1065
- var import_react23 = require("react");
1097
+ var import_react24 = require("react");
1066
1098
  var import_editor9 = require("@pixerate/editor");
1067
1099
  function useMergePreview(options) {
1068
1100
  const { template, templates, bindings, parseOptions } = options;
1069
- const [sourceText, setSourceTextState] = (0, import_react23.useState)(options.initialSource ?? "");
1070
- const [overrides, setOverrides] = (0, import_react23.useState)({});
1071
- const [index, setIndexState] = (0, import_react23.useState)(0);
1072
- const [result, setResult] = (0, import_react23.useState)(null);
1073
- const source = (0, import_react23.useMemo)(
1101
+ const [sourceText, setSourceTextState] = (0, import_react24.useState)(options.initialSource ?? "");
1102
+ const [overrides, setOverrides] = (0, import_react24.useState)({});
1103
+ const [index, setIndexState] = (0, import_react24.useState)(0);
1104
+ const [result, setResult] = (0, import_react24.useState)(null);
1105
+ const source = (0, import_react24.useMemo)(
1074
1106
  () => (0, import_editor9.parseDataSource)(sourceText, parseOptions),
1075
1107
  [sourceText, parseOptions]
1076
1108
  );
1077
- const variables = (0, import_react23.useMemo)(
1109
+ const variables = (0, import_react24.useMemo)(
1078
1110
  () => (0, import_editor9.extractVariables)(template, { templates, bindings }).map((v) => v.name),
1079
1111
  [template, templates, bindings]
1080
1112
  );
1081
- const mapping = (0, import_react23.useMemo)(() => {
1113
+ const mapping = (0, import_react24.useMemo)(() => {
1082
1114
  const merged = {
1083
1115
  ...(0, import_editor9.matchFields)(variables, source.fields).mapping
1084
1116
  };
@@ -1092,29 +1124,29 @@ function useMergePreview(options) {
1092
1124
  const count = source.records.length;
1093
1125
  const current = count === 0 ? 0 : Math.min(index, count - 1);
1094
1126
  const record = source.records[current];
1095
- const values = (0, import_react23.useMemo)(
1127
+ const values = (0, import_react24.useMemo)(
1096
1128
  () => record ? (0, import_editor9.recordToValues)(record, mapping) : {},
1097
1129
  [record, mapping]
1098
1130
  );
1099
- const setSourceText = (0, import_react23.useCallback)((text) => {
1131
+ const setSourceText = (0, import_react24.useCallback)((text) => {
1100
1132
  setSourceTextState(text);
1101
1133
  setIndexState(0);
1102
1134
  setResult(null);
1103
1135
  }, []);
1104
- const loadFile = (0, import_react23.useCallback)(
1136
+ const loadFile = (0, import_react24.useCallback)(
1105
1137
  async (file) => setSourceText(await file.text()),
1106
1138
  [setSourceText]
1107
1139
  );
1108
- const setIndex = (0, import_react23.useCallback)(
1140
+ const setIndex = (0, import_react24.useCallback)(
1109
1141
  (next) => setIndexState(Math.max(0, Math.min(next, count - 1))),
1110
1142
  [count]
1111
1143
  );
1112
- const setFieldMapping = (0, import_react23.useCallback)((variable, field) => {
1144
+ const setFieldMapping = (0, import_react24.useCallback)((variable, field) => {
1113
1145
  setOverrides((previous) => ({ ...previous, [variable]: field }));
1114
1146
  setResult(null);
1115
1147
  }, []);
1116
- const resetMapping = (0, import_react23.useCallback)(() => setOverrides({}), []);
1117
- const merge = (0, import_react23.useCallback)(() => {
1148
+ const resetMapping = (0, import_react24.useCallback)(() => setOverrides({}), []);
1149
+ const merge = (0, import_react24.useCallback)(() => {
1118
1150
  const merged = (0, import_editor9.mergeRecords)(template, source, {
1119
1151
  templates,
1120
1152
  bindings,
@@ -1126,7 +1158,7 @@ function useMergePreview(options) {
1126
1158
  setResult(merged);
1127
1159
  return merged;
1128
1160
  }, [template, source, templates, bindings, mapping, options.skipIf, options.separator, options.maxOutputs]);
1129
- const serialize = (0, import_react23.useCallback)(
1161
+ const serialize = (0, import_react24.useCallback)(
1130
1162
  (format) => result ? (0, import_editor9.serializeMergeOutputs)(result.outputs, format, options.separator) : "",
1131
1163
  [result, options.separator]
1132
1164
  );
@@ -1179,7 +1211,7 @@ var MergePreview = ({
1179
1211
  downloadName = "merged",
1180
1212
  className = "flex flex-col gap-3 text-sm"
1181
1213
  }) => {
1182
- const id = (0, import_react24.useId)();
1214
+ const id = (0, import_react25.useId)();
1183
1215
  const merge = useMergePreview({
1184
1216
  template: content,
1185
1217
  templates,
@@ -1190,7 +1222,7 @@ var MergePreview = ({
1190
1222
  separator,
1191
1223
  maxOutputs
1192
1224
  });
1193
- const [copied, setCopied] = (0, import_react24.useState)(false);
1225
+ const [copied, setCopied] = (0, import_react25.useState)(false);
1194
1226
  const { source, result } = merge;
1195
1227
  const copy = async () => {
1196
1228
  try {
@@ -1347,11 +1379,11 @@ var MergePreview = ({
1347
1379
  };
1348
1380
 
1349
1381
  // src/hooks/useOutline.ts
1350
- var import_react25 = require("react");
1382
+ var import_react26 = require("react");
1351
1383
  var import_editor10 = require("@pixerate/editor");
1352
1384
  function useOutline(editor) {
1353
- const store = (0, import_react25.useMemo)(() => (0, import_editor10.createOutlineStore)(editor), [editor]);
1354
- return (0, import_react25.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
1385
+ const store = (0, import_react26.useMemo)(() => (0, import_editor10.createOutlineStore)(editor), [editor]);
1386
+ return (0, import_react26.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
1355
1387
  }
1356
1388
 
1357
1389
  // src/components/OutlinePanel.tsx
@@ -1396,12 +1428,12 @@ var OutlinePanel = ({
1396
1428
  };
1397
1429
 
1398
1430
  // src/hooks/useParagraphStyles.ts
1399
- var import_react26 = require("react");
1431
+ var import_react27 = require("react");
1400
1432
  var import_editor12 = require("@pixerate/editor");
1401
1433
  function useParagraphStyles(editor) {
1402
- const store = (0, import_react26.useMemo)(() => (0, import_editor12.createParagraphStylesStore)(editor), [editor]);
1403
- const snapshot = (0, import_react26.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
1404
- return (0, import_react26.useMemo)(() => {
1434
+ const store = (0, import_react27.useMemo)(() => (0, import_editor12.createParagraphStylesStore)(editor), [editor]);
1435
+ const snapshot = (0, import_react27.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
1436
+ return (0, import_react27.useMemo)(() => {
1405
1437
  const registry = (0, import_editor12.getStyleRegistry)(editor);
1406
1438
  const live = () => editor && !editor.isDestroyed ? editor : null;
1407
1439
  return {
@@ -1424,7 +1456,7 @@ function useParagraphStyles(editor) {
1424
1456
  }
1425
1457
 
1426
1458
  // src/components/StylesGallery.tsx
1427
- var import_react27 = require("react");
1459
+ var import_react28 = require("react");
1428
1460
  var import_jsx_runtime10 = require("react/jsx-runtime");
1429
1461
  var camel = (property) => property.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
1430
1462
  var keepSelection = (event) => event.preventDefault();
@@ -1440,9 +1472,9 @@ var StylesGallery = ({
1440
1472
  onChange
1441
1473
  }) => {
1442
1474
  const styles = useParagraphStyles(editor);
1443
- const [open, setOpen] = (0, import_react27.useState)(false);
1444
- const [creating, setCreating] = (0, import_react27.useState)(false);
1445
- const [name, setName] = (0, import_react27.useState)("");
1475
+ const [open, setOpen] = (0, import_react28.useState)(false);
1476
+ const [creating, setCreating] = (0, import_react28.useState)(false);
1477
+ const [name, setName] = (0, import_react28.useState)("");
1446
1478
  const list = showAllStyles ? styles.styles : styles.gallery;
1447
1479
  const current = styles.currentStyle;
1448
1480
  const expanded = variant === "gallery" || open;
@@ -1558,13 +1590,13 @@ var StylesGallery = ({
1558
1590
  var import_editor24 = require("@pixerate/editor");
1559
1591
 
1560
1592
  // src/spreadsheet/useSpreadsheetEditor.ts
1561
- var import_react28 = require("react");
1593
+ var import_react29 = require("react");
1562
1594
  var import_spreadsheet = require("@pixerate/editor/spreadsheet");
1563
1595
  function useSpreadsheetEditor(options = {}) {
1564
- const optionsRef = (0, import_react28.useRef)(options);
1596
+ const optionsRef = (0, import_react29.useRef)(options);
1565
1597
  optionsRef.current = options;
1566
- const settersRef = (0, import_react28.useRef)({});
1567
- const [controller] = (0, import_react28.useState)(
1598
+ const settersRef = (0, import_react29.useRef)({});
1599
+ const [controller] = (0, import_react29.useState)(
1568
1600
  () => new import_spreadsheet.SpreadsheetController({
1569
1601
  ...options,
1570
1602
  onDocumentChange: (updated) => {
@@ -1581,37 +1613,37 @@ function useSpreadsheetEditor(options = {}) {
1581
1613
  }
1582
1614
  })
1583
1615
  );
1584
- const [doc, setDoc] = (0, import_react28.useState)(() => ({ ...controller.document }));
1585
- const [activeCell, setActiveCell] = (0, import_react28.useState)(controller.activeCell);
1586
- const [selectedRange, setSelectedRange] = (0, import_react28.useState)(controller.selectedRange);
1587
- const [editingCell, setEditingCell] = (0, import_react28.useState)(null);
1588
- const [draftValue, setDraftState] = (0, import_react28.useState)("");
1589
- const [validationPrompt, setValidationPrompt] = (0, import_react28.useState)(null);
1616
+ const [doc, setDoc] = (0, import_react29.useState)(() => ({ ...controller.document }));
1617
+ const [activeCell, setActiveCell] = (0, import_react29.useState)(controller.activeCell);
1618
+ const [selectedRange, setSelectedRange] = (0, import_react29.useState)(controller.selectedRange);
1619
+ const [editingCell, setEditingCell] = (0, import_react29.useState)(null);
1620
+ const [draftValue, setDraftState] = (0, import_react29.useState)("");
1621
+ const [validationPrompt, setValidationPrompt] = (0, import_react29.useState)(null);
1590
1622
  settersRef.current = { setDoc, setActiveCell, setSelectedRange };
1591
- const setDraftValue = (0, import_react28.useCallback)((value) => {
1623
+ const setDraftValue = (0, import_react29.useCallback)((value) => {
1592
1624
  controller.draftValue = value;
1593
1625
  setDraftState(value);
1594
1626
  }, [controller]);
1595
- const setCellValue = (0, import_react28.useCallback)((rowId, colId, raw) => {
1627
+ const setCellValue = (0, import_react29.useCallback)((rowId, colId, raw) => {
1596
1628
  controller.setCellValue(rowId, colId, raw);
1597
1629
  setDoc({ ...controller.document });
1598
1630
  }, [controller]);
1599
- const selectCell = (0, import_react28.useCallback)((row, col, extendSelection = false) => {
1631
+ const selectCell = (0, import_react29.useCallback)((row, col, extendSelection = false) => {
1600
1632
  controller.selectCell(row, col, extendSelection);
1601
1633
  setActiveCell(controller.activeCell);
1602
1634
  setSelectedRange(controller.selectedRange);
1603
1635
  }, [controller]);
1604
- const selectRange = (0, import_react28.useCallback)((range) => {
1636
+ const selectRange = (0, import_react29.useCallback)((range) => {
1605
1637
  controller.selectRange(range);
1606
1638
  setSelectedRange(controller.selectedRange);
1607
1639
  }, [controller]);
1608
- const startEditing = (0, import_react28.useCallback)((row, col, initialVal) => {
1640
+ const startEditing = (0, import_react29.useCallback)((row, col, initialVal) => {
1609
1641
  controller.startEditing(row, col, initialVal);
1610
1642
  setActiveCell(controller.activeCell);
1611
1643
  setEditingCell(controller.editingCell);
1612
1644
  setDraftValue(controller.draftValue);
1613
1645
  }, [controller]);
1614
- const syncEditing = (0, import_react28.useCallback)(() => {
1646
+ const syncEditing = (0, import_react29.useCallback)(() => {
1615
1647
  setEditingCell(controller.editingCell);
1616
1648
  setDraftValue(controller.draftValue);
1617
1649
  setValidationPrompt(controller.validationPrompt);
@@ -1619,90 +1651,90 @@ function useSpreadsheetEditor(options = {}) {
1619
1651
  setSelectedRange(controller.selectedRange);
1620
1652
  setDoc({ ...controller.document });
1621
1653
  }, [controller]);
1622
- const commitEditing = (0, import_react28.useCallback)((val) => {
1654
+ const commitEditing = (0, import_react29.useCallback)((val) => {
1623
1655
  const result = controller.commitEditing(val);
1624
1656
  syncEditing();
1625
1657
  return result;
1626
1658
  }, [controller, syncEditing]);
1627
- const commitCellInput = (0, import_react28.useCallback)((rowId, colId, raw) => {
1659
+ const commitCellInput = (0, import_react29.useCallback)((rowId, colId, raw) => {
1628
1660
  const result = controller.commitCellInput(rowId, colId, raw);
1629
1661
  syncEditing();
1630
1662
  return result;
1631
1663
  }, [controller, syncEditing]);
1632
- const resolveValidationPrompt = (0, import_react28.useCallback)((action) => {
1664
+ const resolveValidationPrompt = (0, import_react29.useCallback)((action) => {
1633
1665
  controller.resolveValidationPrompt(action);
1634
1666
  syncEditing();
1635
1667
  }, [controller, syncEditing]);
1636
- const cancelEditing = (0, import_react28.useCallback)(() => {
1668
+ const cancelEditing = (0, import_react29.useCallback)(() => {
1637
1669
  controller.cancelEditing();
1638
1670
  setEditingCell(null);
1639
1671
  setDraftValue("");
1640
1672
  }, [controller]);
1641
- const moveCursor = (0, import_react28.useCallback)((dir, extend = false) => {
1673
+ const moveCursor = (0, import_react29.useCallback)((dir, extend = false) => {
1642
1674
  controller.moveCursor(dir, extend);
1643
1675
  setActiveCell(controller.activeCell);
1644
1676
  setSelectedRange(controller.selectedRange);
1645
1677
  }, [controller]);
1646
- const insertColumn = (0, import_react28.useCallback)((index, config) => {
1678
+ const insertColumn = (0, import_react29.useCallback)((index, config) => {
1647
1679
  controller.insertColumn(index, config);
1648
1680
  setDoc({ ...controller.document });
1649
1681
  }, [controller]);
1650
- const deleteColumn = (0, import_react28.useCallback)((colId) => {
1682
+ const deleteColumn = (0, import_react29.useCallback)((colId) => {
1651
1683
  controller.deleteColumn(colId);
1652
1684
  setDoc({ ...controller.document });
1653
1685
  }, [controller]);
1654
- const insertRow = (0, import_react28.useCallback)((index, config) => {
1686
+ const insertRow = (0, import_react29.useCallback)((index, config) => {
1655
1687
  controller.insertRow(index, config);
1656
1688
  setDoc({ ...controller.document });
1657
1689
  }, [controller]);
1658
- const deleteRow = (0, import_react28.useCallback)((rowId) => {
1690
+ const deleteRow = (0, import_react29.useCallback)((rowId) => {
1659
1691
  controller.deleteRow(rowId);
1660
1692
  setDoc({ ...controller.document });
1661
1693
  }, [controller]);
1662
- const setColumnWidth = (0, import_react28.useCallback)((colId, width) => {
1694
+ const setColumnWidth = (0, import_react29.useCallback)((colId, width) => {
1663
1695
  controller.setColumnWidth(colId, width);
1664
1696
  setDoc({ ...controller.document });
1665
1697
  }, [controller]);
1666
- const autoFitColumnWidth = (0, import_react28.useCallback)((colId, customWidth) => {
1698
+ const autoFitColumnWidth = (0, import_react29.useCallback)((colId, customWidth) => {
1667
1699
  controller.autoFitColumnWidth(colId, customWidth);
1668
1700
  setDoc({ ...controller.document });
1669
1701
  }, [controller]);
1670
- const registerDataSource = (0, import_react28.useCallback)((ds) => {
1702
+ const registerDataSource = (0, import_react29.useCallback)((ds) => {
1671
1703
  controller.registerDataSource(ds);
1672
1704
  setDoc({ ...controller.document });
1673
1705
  }, [controller]);
1674
- const setPrimaryDataSource = (0, import_react28.useCallback)((id) => {
1706
+ const setPrimaryDataSource = (0, import_react29.useCallback)((id) => {
1675
1707
  controller.setPrimaryDataSource(id);
1676
1708
  setDoc({ ...controller.document });
1677
1709
  }, [controller]);
1678
- const recalculateAll = (0, import_react28.useCallback)(() => {
1710
+ const recalculateAll = (0, import_react29.useCallback)(() => {
1679
1711
  controller.recalculateAll();
1680
1712
  setDoc({ ...controller.document });
1681
1713
  }, [controller]);
1682
- const undo = (0, import_react28.useCallback)(() => {
1714
+ const undo = (0, import_react29.useCallback)(() => {
1683
1715
  controller.undo();
1684
1716
  setDoc({ ...controller.document });
1685
1717
  setActiveCell(controller.activeCell);
1686
1718
  setSelectedRange(controller.selectedRange);
1687
1719
  }, [controller]);
1688
- const redo = (0, import_react28.useCallback)(() => {
1720
+ const redo = (0, import_react29.useCallback)(() => {
1689
1721
  controller.redo();
1690
1722
  setDoc({ ...controller.document });
1691
1723
  setActiveCell(controller.activeCell);
1692
1724
  setSelectedRange(controller.selectedRange);
1693
1725
  }, [controller]);
1694
- const tableActions = (0, import_react28.useMemo)(() => (0, import_spreadsheet.bindSpreadsheetTableActions)(controller), [controller]);
1695
- const viewModel = (0, import_react28.useMemo)(() => controller.getViewModel(), [controller, doc]);
1696
- const sheets = (0, import_react28.useMemo)(() => controller.getSheets(), [controller, doc]);
1697
- const names = (0, import_react28.useMemo)(() => controller.getNames(), [controller, doc]);
1698
- const afterSheetSwitch = (0, import_react28.useCallback)(() => {
1726
+ const tableActions = (0, import_react29.useMemo)(() => (0, import_spreadsheet.bindSpreadsheetTableActions)(controller), [controller]);
1727
+ const viewModel = (0, import_react29.useMemo)(() => controller.getViewModel(), [controller, doc]);
1728
+ const sheets = (0, import_react29.useMemo)(() => controller.getSheets(), [controller, doc]);
1729
+ const names = (0, import_react29.useMemo)(() => controller.getNames(), [controller, doc]);
1730
+ const afterSheetSwitch = (0, import_react29.useCallback)(() => {
1699
1731
  setEditingCell(controller.editingCell);
1700
1732
  setDraftValue(controller.draftValue);
1701
1733
  setActiveCell(controller.activeCell);
1702
1734
  setSelectedRange(controller.selectedRange);
1703
1735
  setDoc({ ...controller.document });
1704
1736
  }, [controller, setDraftValue]);
1705
- const workbookActions = (0, import_react28.useMemo)(
1737
+ const workbookActions = (0, import_react29.useMemo)(
1706
1738
  () => ({
1707
1739
  setActiveSheet: (idOrName) => {
1708
1740
  const changed = controller.setActiveSheet(idOrName);
@@ -1732,9 +1764,9 @@ function useSpreadsheetEditor(options = {}) {
1732
1764
  }),
1733
1765
  [controller, afterSheetSwitch]
1734
1766
  );
1735
- const conditionalFormatOverlay = (0, import_react28.useMemo)(() => controller.getConditionalFormatOverlay(), [controller, doc]);
1736
- const editorDocument = (0, import_react28.useMemo)(() => (0, import_spreadsheet.createSpreadsheetEditorDocument)(controller), [controller]);
1737
- (0, import_react28.useEffect)(() => () => editorDocument.destroy(), [editorDocument]);
1767
+ const conditionalFormatOverlay = (0, import_react29.useMemo)(() => controller.getConditionalFormatOverlay(), [controller, doc]);
1768
+ const editorDocument = (0, import_react29.useMemo)(() => (0, import_spreadsheet.createSpreadsheetEditorDocument)(controller), [controller]);
1769
+ (0, import_react29.useEffect)(() => () => editorDocument.destroy(), [editorDocument]);
1738
1770
  return {
1739
1771
  document: doc,
1740
1772
  activeCell,
@@ -1798,20 +1830,20 @@ function useSpreadsheetEditor(options = {}) {
1798
1830
  }
1799
1831
 
1800
1832
  // src/spreadsheet/SpreadsheetEditor.tsx
1801
- var import_react37 = require("react");
1833
+ var import_react38 = require("react");
1802
1834
  var import_spreadsheet8 = require("@pixerate/editor/spreadsheet");
1803
1835
 
1804
1836
  // src/spreadsheet/SpreadsheetContextMenu.tsx
1805
- var import_react29 = __toESM(require("react"), 1);
1837
+ var import_react30 = __toESM(require("react"), 1);
1806
1838
  var import_spreadsheet2 = require("@pixerate/editor/spreadsheet");
1807
1839
  var import_jsx_runtime11 = require("react/jsx-runtime");
1808
1840
  var VIEWPORT_MARGIN = 4;
1809
1841
  var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "Table actions" }) => {
1810
- const menuRef = (0, import_react29.useRef)(null);
1811
- const onCloseRef = (0, import_react29.useRef)(onClose);
1842
+ const menuRef = (0, import_react30.useRef)(null);
1843
+ const onCloseRef = (0, import_react30.useRef)(onClose);
1812
1844
  onCloseRef.current = onClose;
1813
- const [position, setPosition] = (0, import_react29.useState)({ x, y });
1814
- (0, import_react29.useLayoutEffect)(() => {
1845
+ const [position, setPosition] = (0, import_react30.useState)({ x, y });
1846
+ (0, import_react30.useLayoutEffect)(() => {
1815
1847
  const menu = menuRef.current;
1816
1848
  if (!menu || typeof window === "undefined") return;
1817
1849
  const { width, height } = menu.getBoundingClientRect();
@@ -1823,7 +1855,7 @@ var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "
1823
1855
  );
1824
1856
  setPosition((prev) => prev.x === next.x && prev.y === next.y ? prev : next);
1825
1857
  }, [x, y, items]);
1826
- (0, import_react29.useEffect)(() => {
1858
+ (0, import_react30.useEffect)(() => {
1827
1859
  const handlePointer = (e) => {
1828
1860
  if (!menuRef.current?.contains(e.target)) onCloseRef.current();
1829
1861
  };
@@ -1853,7 +1885,7 @@ var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "
1853
1885
  },
1854
1886
  onContextMenu: (e) => e.preventDefault(),
1855
1887
  onKeyDown: (e) => e.stopPropagation(),
1856
- children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react29.default.Fragment, { children: [
1888
+ children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react30.default.Fragment, { children: [
1857
1889
  item.separatorBefore && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { role: "separator", className: "my-1 h-px bg-border" }),
1858
1890
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1859
1891
  "button",
@@ -1878,7 +1910,7 @@ var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "
1878
1910
  };
1879
1911
 
1880
1912
  // src/spreadsheet/SpreadsheetGroupRow.tsx
1881
- var import_react30 = __toESM(require("react"), 1);
1913
+ var import_react31 = __toESM(require("react"), 1);
1882
1914
  var import_jsx_runtime12 = require("react/jsx-runtime");
1883
1915
  var formatSummary = (value) => value === null ? "\u2013" : String(value);
1884
1916
  var SpreadsheetGroupRow = ({
@@ -1912,7 +1944,7 @@ var SpreadsheetGroupRow = ({
1912
1944
  columns.map(({ column }, i) => {
1913
1945
  const summary = group.summaries[column.id];
1914
1946
  const before = leadingColumns !== void 0 && i === leadingColumns && leftSpace > 0 ? spacer("space:left") : null;
1915
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react30.default.Fragment, { children: [
1947
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react31.default.Fragment, { children: [
1916
1948
  before,
1917
1949
  /* @__PURE__ */ (0, import_jsx_runtime12.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_runtime12.jsxs)("span", { className: "truncate", children: [
1918
1950
  group.label,
@@ -1932,7 +1964,7 @@ var SpreadsheetGroupRow = ({
1932
1964
  };
1933
1965
 
1934
1966
  // src/spreadsheet/useSpreadsheetTableInteractions.ts
1935
- var import_react31 = require("react");
1967
+ var import_react32 = require("react");
1936
1968
  var import_spreadsheet3 = require("@pixerate/editor/spreadsheet");
1937
1969
  function gridHasFocus(grid) {
1938
1970
  if (!grid || typeof document === "undefined") return false;
@@ -1941,12 +1973,12 @@ function gridHasFocus(grid) {
1941
1973
  return !(active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement);
1942
1974
  }
1943
1975
  function useSpreadsheetClipboard(gridRef, state, readOnly) {
1944
- const stateRef = (0, import_react31.useRef)(state);
1976
+ const stateRef = (0, import_react32.useRef)(state);
1945
1977
  stateRef.current = state;
1946
- const readOnlyRef = (0, import_react31.useRef)(readOnly);
1978
+ const readOnlyRef = (0, import_react32.useRef)(readOnly);
1947
1979
  readOnlyRef.current = readOnly;
1948
- const copiedRef = (0, import_react31.useRef)(false);
1949
- (0, import_react31.useEffect)(() => {
1980
+ const copiedRef = (0, import_react32.useRef)(false);
1981
+ (0, import_react32.useEffect)(() => {
1950
1982
  if (typeof document === "undefined") return;
1951
1983
  const handleCopy = (e) => {
1952
1984
  const s = stateRef.current;
@@ -1969,7 +2001,7 @@ function useSpreadsheetClipboard(gridRef, state, readOnly) {
1969
2001
  document.removeEventListener("paste", handlePaste);
1970
2002
  };
1971
2003
  }, [gridRef]);
1972
- const copyShortcutFallback = (0, import_react31.useCallback)(() => {
2004
+ const copyShortcutFallback = (0, import_react32.useCallback)(() => {
1973
2005
  copiedRef.current = false;
1974
2006
  setTimeout(() => {
1975
2007
  if (copiedRef.current) return;
@@ -1981,13 +2013,13 @@ function useSpreadsheetClipboard(gridRef, state, readOnly) {
1981
2013
  return { copyShortcutFallback };
1982
2014
  }
1983
2015
  function useFillHandle(state) {
1984
- const [drag, setDrag] = (0, import_react31.useState)(null);
1985
- const dragRef = (0, import_react31.useRef)(drag);
2016
+ const [drag, setDrag] = (0, import_react32.useState)(null);
2017
+ const dragRef = (0, import_react32.useRef)(drag);
1986
2018
  dragRef.current = drag;
1987
- const stateRef = (0, import_react31.useRef)(state);
2019
+ const stateRef = (0, import_react32.useRef)(state);
1988
2020
  stateRef.current = state;
1989
2021
  const dragging = drag !== null;
1990
- (0, import_react31.useEffect)(() => {
2022
+ (0, import_react32.useEffect)(() => {
1991
2023
  if (!dragging) return;
1992
2024
  const handleMouseUp = () => {
1993
2025
  const current = dragRef.current;
@@ -1997,13 +2029,13 @@ function useFillHandle(state) {
1997
2029
  window.addEventListener("mouseup", handleMouseUp);
1998
2030
  return () => window.removeEventListener("mouseup", handleMouseUp);
1999
2031
  }, [dragging]);
2000
- const startFill = (0, import_react31.useCallback)((e) => {
2032
+ const startFill = (0, import_react32.useCallback)((e) => {
2001
2033
  e.preventDefault();
2002
2034
  e.stopPropagation();
2003
2035
  const range = stateRef.current.selectedRange;
2004
2036
  if (range) setDrag({ source: (0, import_spreadsheet3.normalizeRange)(range), target: null });
2005
2037
  }, []);
2006
- const extendFill = (0, import_react31.useCallback)((row, col) => {
2038
+ const extendFill = (0, import_react32.useCallback)((row, col) => {
2007
2039
  const current = dragRef.current;
2008
2040
  if (!current) return;
2009
2041
  setDrag({ source: current.source, target: (0, import_spreadsheet3.computeFillTarget)(current.source, { row, col }) });
@@ -2012,12 +2044,12 @@ function useFillHandle(state) {
2012
2044
  }
2013
2045
 
2014
2046
  // src/spreadsheet/SpreadsheetValidationDialog.tsx
2015
- var import_react32 = require("react");
2047
+ var import_react33 = require("react");
2016
2048
  var import_jsx_runtime13 = require("react/jsx-runtime");
2017
2049
  var SpreadsheetValidationDialog = ({ prompt, onResolve }) => {
2018
2050
  const style = prompt.result.errorStyle ?? "stop";
2019
- const firstButton = (0, import_react32.useRef)(null);
2020
- (0, import_react32.useEffect)(() => {
2051
+ const firstButton = (0, import_react33.useRef)(null);
2052
+ (0, import_react33.useEffect)(() => {
2021
2053
  firstButton.current?.focus();
2022
2054
  }, [prompt]);
2023
2055
  const buttons = style === "stop" ? [
@@ -2083,7 +2115,7 @@ var SpreadsheetValidationDialog = ({ prompt, onResolve }) => {
2083
2115
  };
2084
2116
 
2085
2117
  // src/spreadsheet/SpreadsheetRulePanels.tsx
2086
- var import_react33 = require("react");
2118
+ var import_react34 = require("react");
2087
2119
  var import_spreadsheet4 = require("@pixerate/editor/spreadsheet");
2088
2120
  var import_jsx_runtime14 = require("react/jsx-runtime");
2089
2121
  var inputClass = "w-full rounded border border-border bg-background px-1.5 py-0.5 text-xs text-foreground";
@@ -2137,18 +2169,18 @@ function RuleSwatch({ rule }) {
2137
2169
  }
2138
2170
  var SpreadsheetConditionalFormatPanel = ({ state, onClose }) => {
2139
2171
  const rules = state.document.table?.conditionalFormats ?? [];
2140
- const [kind, setKind] = (0, import_react33.useState)("greaterThan");
2141
- const [appliesTo, setAppliesTo] = (0, import_react33.useState)(() => selectionText(state.selectedRange));
2142
- const [value, setValue] = (0, import_react33.useState)("");
2143
- const [value2, setValue2] = (0, import_react33.useState)("");
2144
- const [text, setText] = (0, import_react33.useState)("");
2145
- const [formula, setFormula] = (0, import_react33.useState)("=");
2146
- const [rank, setRank] = (0, import_react33.useState)("10");
2147
- const [period, setPeriod] = (0, import_react33.useState)("today");
2148
- const [iconSet, setIconSet] = (0, import_react33.useState)("3TrafficLights1");
2149
- const [color, setColor] = (0, import_react33.useState)("#638ec6");
2150
- const [styleId, setStyleId] = (0, import_react33.useState)(import_spreadsheet4.CONDITIONAL_FORMAT_STYLE_PRESETS[0].id);
2151
- const preset = (0, import_react33.useMemo)(() => import_spreadsheet4.CONDITIONAL_FORMAT_PRESETS.find((p) => p.kind === kind), [kind]);
2172
+ const [kind, setKind] = (0, import_react34.useState)("greaterThan");
2173
+ const [appliesTo, setAppliesTo] = (0, import_react34.useState)(() => selectionText(state.selectedRange));
2174
+ const [value, setValue] = (0, import_react34.useState)("");
2175
+ const [value2, setValue2] = (0, import_react34.useState)("");
2176
+ const [text, setText] = (0, import_react34.useState)("");
2177
+ const [formula, setFormula] = (0, import_react34.useState)("=");
2178
+ const [rank, setRank] = (0, import_react34.useState)("10");
2179
+ const [period, setPeriod] = (0, import_react34.useState)("today");
2180
+ const [iconSet, setIconSet] = (0, import_react34.useState)("3TrafficLights1");
2181
+ const [color, setColor] = (0, import_react34.useState)("#638ec6");
2182
+ const [styleId, setStyleId] = (0, import_react34.useState)(import_spreadsheet4.CONDITIONAL_FORMAT_STYLE_PRESETS[0].id);
2183
+ const preset = (0, import_react34.useMemo)(() => import_spreadsheet4.CONDITIONAL_FORMAT_PRESETS.find((p) => p.kind === kind), [kind]);
2152
2184
  const ranges = (0, import_spreadsheet4.parseRuleRanges)(appliesTo);
2153
2185
  const add = () => {
2154
2186
  if (!ranges) return;
@@ -2232,15 +2264,15 @@ var SpreadsheetConditionalFormatPanel = ({ state, onClose }) => {
2232
2264
  };
2233
2265
  var SpreadsheetDataValidationPanel = ({ state, onClose }) => {
2234
2266
  const rules = state.document.table?.dataValidations ?? [];
2235
- const [type, setType] = (0, import_react33.useState)("list");
2236
- const [operator, setOperator] = (0, import_react33.useState)("between");
2237
- const [formula1, setFormula1] = (0, import_react33.useState)("");
2238
- const [formula2, setFormula2] = (0, import_react33.useState)("");
2239
- const [errorStyle, setErrorStyle] = (0, import_react33.useState)("stop");
2240
- const [errorMessage, setErrorMessage] = (0, import_react33.useState)("");
2241
- const [inputMessage, setInputMessage] = (0, import_react33.useState)("");
2242
- const [ignoreBlank, setIgnoreBlank] = (0, import_react33.useState)(true);
2243
- const [appliesTo, setAppliesTo] = (0, import_react33.useState)(() => selectionText(state.selectedRange));
2267
+ const [type, setType] = (0, import_react34.useState)("list");
2268
+ const [operator, setOperator] = (0, import_react34.useState)("between");
2269
+ const [formula1, setFormula1] = (0, import_react34.useState)("");
2270
+ const [formula2, setFormula2] = (0, import_react34.useState)("");
2271
+ const [errorStyle, setErrorStyle] = (0, import_react34.useState)("stop");
2272
+ const [errorMessage, setErrorMessage] = (0, import_react34.useState)("");
2273
+ const [inputMessage, setInputMessage] = (0, import_react34.useState)("");
2274
+ const [ignoreBlank, setIgnoreBlank] = (0, import_react34.useState)(true);
2275
+ const [appliesTo, setAppliesTo] = (0, import_react34.useState)(() => selectionText(state.selectedRange));
2244
2276
  const ranges = (0, import_spreadsheet4.parseRuleRanges)(appliesTo);
2245
2277
  const usesOperator = type === "whole" || type === "decimal" || type === "date" || type === "time" || type === "textLength";
2246
2278
  const needsTwo = usesOperator && (operator === "between" || operator === "notBetween");
@@ -2314,29 +2346,29 @@ var SpreadsheetDataValidationPanel = ({ state, onClose }) => {
2314
2346
  };
2315
2347
 
2316
2348
  // src/spreadsheet/useSpreadsheetViewport.ts
2317
- var import_react34 = require("react");
2349
+ var import_react35 = require("react");
2318
2350
  var import_spreadsheet5 = require("@pixerate/editor/spreadsheet");
2319
- var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react34.useLayoutEffect : import_react34.useEffect;
2351
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react35.useLayoutEffect : import_react35.useEffect;
2320
2352
  function useSpreadsheetViewport(scrollRef, view, options = {}) {
2321
- const metrics = (0, import_react34.useMemo)(() => (0, import_spreadsheet5.measureSpreadsheetView)(view), [view]);
2353
+ const metrics = (0, import_react35.useMemo)(() => (0, import_spreadsheet5.measureSpreadsheetView)(view), [view]);
2322
2354
  const virtual = (0, import_spreadsheet5.shouldVirtualizeSpreadsheet)(view, options.virtualize ?? "auto");
2323
- const [viewport, setViewport] = (0, import_react34.useState)({ scrollTop: 0, scrollLeft: 0, width: 0, height: 0 });
2324
- const windowOptions = (0, import_react34.useMemo)(
2355
+ const [viewport, setViewport] = (0, import_react35.useState)({ scrollTop: 0, scrollLeft: 0, width: 0, height: 0 });
2356
+ const windowOptions = (0, import_react35.useMemo)(
2325
2357
  () => ({ merges: options.merges, overscanRows: options.overscanRows, overscanColumns: options.overscanColumns }),
2326
2358
  [options.merges, options.overscanRows, options.overscanColumns]
2327
2359
  );
2328
- const win = (0, import_react34.useMemo)(
2360
+ const win = (0, import_react35.useMemo)(
2329
2361
  () => virtual ? (0, import_spreadsheet5.getSpreadsheetViewWindow)(metrics, viewport, windowOptions) : (0, import_spreadsheet5.fullSpreadsheetViewWindow)(metrics),
2330
2362
  [virtual, metrics, viewport, windowOptions]
2331
2363
  );
2332
- const latest = (0, import_react34.useRef)({ metrics, viewport, virtual, windowOptions });
2364
+ const latest = (0, import_react35.useRef)({ metrics, viewport, virtual, windowOptions });
2333
2365
  latest.current = { metrics, viewport, virtual, windowOptions };
2334
- const readViewport = (0, import_react34.useCallback)(() => {
2366
+ const readViewport = (0, import_react35.useCallback)(() => {
2335
2367
  const el = scrollRef.current;
2336
2368
  if (!el) return null;
2337
2369
  return { scrollTop: el.scrollTop, scrollLeft: el.scrollLeft, width: el.clientWidth, height: el.clientHeight };
2338
2370
  }, [scrollRef]);
2339
- const updateViewport = (0, import_react34.useCallback)((next) => {
2371
+ const updateViewport = (0, import_react35.useCallback)((next) => {
2340
2372
  setViewport((prev) => {
2341
2373
  const { metrics: m, virtual: v, windowOptions: o } = latest.current;
2342
2374
  if (!v) return prev;
@@ -2344,7 +2376,7 @@ function useSpreadsheetViewport(scrollRef, view, options = {}) {
2344
2376
  return same ? prev : next;
2345
2377
  });
2346
2378
  }, []);
2347
- const onScroll = (0, import_react34.useCallback)(() => {
2379
+ const onScroll = (0, import_react35.useCallback)(() => {
2348
2380
  const next = readViewport();
2349
2381
  if (next) updateViewport(next);
2350
2382
  }, [readViewport, updateViewport]);
@@ -2378,24 +2410,24 @@ function useSpreadsheetViewport(scrollRef, view, options = {}) {
2378
2410
  }
2379
2411
 
2380
2412
  // src/spreadsheet/FormulaHints.tsx
2381
- var import_react35 = require("react");
2413
+ var import_react36 = require("react");
2382
2414
  var import_spreadsheet6 = require("@pixerate/editor/spreadsheet");
2383
2415
  var import_jsx_runtime15 = require("react/jsx-runtime");
2384
2416
  var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
2385
- const [caret, setCaret] = (0, import_react35.useState)(null);
2386
- const [focused, setFocused] = (0, import_react35.useState)(false);
2387
- const [selected, setSelected] = (0, import_react35.useState)(0);
2388
- const [dismissed, setDismissed] = (0, import_react35.useState)(false);
2389
- const [position, setPosition] = (0, import_react35.useState)(null);
2390
- const pendingCaret = (0, import_react35.useRef)(null);
2391
- const hints = (0, import_react35.useMemo)(
2417
+ const [caret, setCaret] = (0, import_react36.useState)(null);
2418
+ const [focused, setFocused] = (0, import_react36.useState)(false);
2419
+ const [selected, setSelected] = (0, import_react36.useState)(0);
2420
+ const [dismissed, setDismissed] = (0, import_react36.useState)(false);
2421
+ const [position, setPosition] = (0, import_react36.useState)(null);
2422
+ const pendingCaret = (0, import_react36.useRef)(null);
2423
+ const hints = (0, import_react36.useMemo)(
2392
2424
  () => (0, import_spreadsheet6.getFormulaHints)(value, caret ?? value.length, { limit, names }),
2393
2425
  [value, caret, limit, names]
2394
2426
  );
2395
2427
  const suggestions = dismissed ? [] : hints.suggestions;
2396
2428
  const selectedIndex = Math.max(0, Math.min(selected, suggestions.length - 1));
2397
2429
  const visible = focused && value.trimStart().startsWith("=") && (suggestions.length > 0 || !!hints.activeCall);
2398
- const latest = (0, import_react35.useRef)({ suggestions, selected: selectedIndex, value, caret, onAccept });
2430
+ const latest = (0, import_react36.useRef)({ suggestions, selected: selectedIndex, value, caret, onAccept });
2399
2431
  latest.current = { suggestions, selected: selectedIndex, value, caret, onAccept };
2400
2432
  const accept = (index) => {
2401
2433
  const { suggestions: list, value: current, caret: at, onAccept: commit } = latest.current;
@@ -2405,7 +2437,7 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
2405
2437
  pendingCaret.current = next.caret;
2406
2438
  commit(next.value);
2407
2439
  };
2408
- (0, import_react35.useEffect)(() => {
2440
+ (0, import_react36.useEffect)(() => {
2409
2441
  const input2 = inputRef.current;
2410
2442
  if (!input2) return;
2411
2443
  const syncCaret = () => setCaret(input2.selectionStart ?? input2.value.length);
@@ -2455,7 +2487,7 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
2455
2487
  input2.removeEventListener("keydown", onKeyDown);
2456
2488
  };
2457
2489
  }, [inputRef]);
2458
- (0, import_react35.useLayoutEffect)(() => {
2490
+ (0, import_react36.useLayoutEffect)(() => {
2459
2491
  const input2 = inputRef.current;
2460
2492
  const at = pendingCaret.current;
2461
2493
  if (!input2 || at === null || input2.value !== value) return;
@@ -2464,7 +2496,7 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
2464
2496
  setCaret(at);
2465
2497
  setSelected(0);
2466
2498
  }, [value, inputRef]);
2467
- (0, import_react35.useLayoutEffect)(() => {
2499
+ (0, import_react36.useLayoutEffect)(() => {
2468
2500
  const input2 = inputRef.current;
2469
2501
  if (!visible || !input2) return;
2470
2502
  const rect = input2.getBoundingClientRect();
@@ -2528,16 +2560,16 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
2528
2560
  };
2529
2561
 
2530
2562
  // src/spreadsheet/SheetTabs.tsx
2531
- var import_react36 = require("react");
2563
+ var import_react37 = require("react");
2532
2564
  var import_spreadsheet7 = require("@pixerate/editor/spreadsheet");
2533
2565
  var import_jsx_runtime16 = require("react/jsx-runtime");
2534
2566
  var SheetTabs = ({ state, readOnly = false, className = "" }) => {
2535
2567
  const { controller, sheets } = state;
2536
- const [renaming, setRenaming] = (0, import_react36.useState)(null);
2537
- const [error, setError] = (0, import_react36.useState)(null);
2538
- const [menu, setMenu] = (0, import_react36.useState)(null);
2539
- const dragFrom = (0, import_react36.useRef)(null);
2540
- const [dropTarget, setDropTarget] = (0, import_react36.useState)(null);
2568
+ const [renaming, setRenaming] = (0, import_react37.useState)(null);
2569
+ const [error, setError] = (0, import_react37.useState)(null);
2570
+ const [menu, setMenu] = (0, import_react37.useState)(null);
2571
+ const dragFrom = (0, import_react37.useRef)(null);
2572
+ const [dropTarget, setDropTarget] = (0, import_react37.useState)(null);
2541
2573
  const commitRename = (cancelOnError) => {
2542
2574
  if (!renaming) return;
2543
2575
  const sheet = sheets.find((s) => s.id === renaming.id);
@@ -2742,7 +2774,7 @@ var SpreadsheetEditor = ({
2742
2774
  }) => {
2743
2775
  const defaultState = useSpreadsheetEditor();
2744
2776
  const state = externalState || defaultState;
2745
- const gridRef = (0, import_react37.useRef)(null);
2777
+ const gridRef = (0, import_react38.useRef)(null);
2746
2778
  const ambientPlayback = useAgentPlayback();
2747
2779
  const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
2748
2780
  const agentPresence = usePlaybackSurface(playing, playbackId, {
@@ -2782,20 +2814,20 @@ var SpreadsheetEditor = ({
2782
2814
  },
2783
2815
  reveal: () => onPlaybackReveal?.()
2784
2816
  });
2785
- const scrollRef = (0, import_react37.useRef)(null);
2786
- const formulaBarRef = (0, import_react37.useRef)(null);
2787
- const cellInputRef = (0, import_react37.useRef)(null);
2788
- const [resizingColId, setResizingColId] = (0, import_react37.useState)(null);
2789
- const [hoveredColId, setHoveredColId] = (0, import_react37.useState)(null);
2790
- const [resizeStartX, setResizeStartX] = (0, import_react37.useState)(0);
2791
- const [resizeStartWidth, setResizeStartWidth] = (0, import_react37.useState)(0);
2817
+ const scrollRef = (0, import_react38.useRef)(null);
2818
+ const formulaBarRef = (0, import_react38.useRef)(null);
2819
+ const cellInputRef = (0, import_react38.useRef)(null);
2820
+ const [resizingColId, setResizingColId] = (0, import_react38.useState)(null);
2821
+ const [hoveredColId, setHoveredColId] = (0, import_react38.useState)(null);
2822
+ const [resizeStartX, setResizeStartX] = (0, import_react38.useState)(0);
2823
+ const [resizeStartWidth, setResizeStartWidth] = (0, import_react38.useState)(0);
2792
2824
  const view = state.viewModel;
2793
2825
  const { window: viewWindow, onScroll: handleGridScroll } = useSpreadsheetViewport(scrollRef, view, {
2794
2826
  virtualize,
2795
2827
  merges: state.document.table?.merges,
2796
2828
  activeCell: state.activeCell
2797
2829
  });
2798
- const columnSlots = (0, import_react37.useMemo)(() => {
2830
+ const columnSlots = (0, import_react38.useMemo)(() => {
2799
2831
  const col = (viewCol) => ({ kind: "col", viewCol });
2800
2832
  if (!viewWindow.virtual) return view.columns.map(col);
2801
2833
  const slots = view.columns.slice(0, viewWindow.frozenColumns).map(col);
@@ -2804,11 +2836,11 @@ var SpreadsheetEditor = ({
2804
2836
  if (viewWindow.rightSpace > 0) slots.push({ kind: "space", key: "space:right", width: viewWindow.rightSpace });
2805
2837
  return slots;
2806
2838
  }, [view, viewWindow]);
2807
- const renderedColumns = (0, import_react37.useMemo)(
2839
+ const renderedColumns = (0, import_react38.useMemo)(
2808
2840
  () => columnSlots.flatMap((slot) => slot.kind === "col" ? [slot.viewCol] : []),
2809
2841
  [columnSlots]
2810
2842
  );
2811
- const rowSlots = (0, import_react37.useMemo)(() => {
2843
+ const rowSlots = (0, import_react38.useMemo)(() => {
2812
2844
  const row = (viewRow) => ({ kind: "row", viewRow });
2813
2845
  if (!viewWindow.virtual) return view.rows.map(row);
2814
2846
  const slots = view.rows.slice(0, viewWindow.frozenRows).map(row);
@@ -2819,16 +2851,16 @@ var SpreadsheetEditor = ({
2819
2851
  }, [view, viewWindow]);
2820
2852
  const { copyShortcutFallback } = useSpreadsheetClipboard(gridRef, state, readOnly);
2821
2853
  const { fillTarget, startFill, extendFill } = useFillHandle(state);
2822
- const [menu, setMenu] = (0, import_react37.useState)(null);
2823
- const [panel, setPanel] = (0, import_react37.useState)(null);
2824
- const [listMenu, setListMenu] = (0, import_react37.useState)(null);
2854
+ const [menu, setMenu] = (0, import_react38.useState)(null);
2855
+ const [panel, setPanel] = (0, import_react38.useState)(null);
2856
+ const [listMenu, setListMenu] = (0, import_react38.useState)(null);
2825
2857
  const overlay = state.conditionalFormatOverlay;
2826
2858
  const filter = state.document.table?.filter;
2827
- const filteredColIds = (0, import_react37.useMemo)(
2859
+ const filteredColIds = (0, import_react38.useMemo)(
2828
2860
  () => new Set(filter?.enabled ? filter.rules.map((r) => r.colId) : []),
2829
2861
  [filter]
2830
2862
  );
2831
- const handleCellContextMenu = (0, import_react37.useCallback)((rIdx, cIdx, e) => {
2863
+ const handleCellContextMenu = (0, import_react38.useCallback)((rIdx, cIdx, e) => {
2832
2864
  if (readOnly) return;
2833
2865
  e.preventDefault();
2834
2866
  if (state.editingCell) state.commitEditing();
@@ -2837,33 +2869,33 @@ var SpreadsheetEditor = ({
2837
2869
  }
2838
2870
  setMenu({ x: e.clientX, y: e.clientY, items: (0, import_spreadsheet8.getSpreadsheetMenuItems)(state.controller, { row: rIdx, col: cIdx }) });
2839
2871
  }, [readOnly, state]);
2840
- const nameSuggestions = (0, import_react37.useMemo)(
2872
+ const nameSuggestions = (0, import_react38.useMemo)(
2841
2873
  () => state.controller.getNameSuggestions(),
2842
2874
  // eslint-disable-next-line react-hooks/exhaustive-deps
2843
2875
  [state.controller, state.document]
2844
2876
  );
2845
- const activeRawValue = (0, import_react37.useMemo)(() => {
2877
+ const activeRawValue = (0, import_react38.useMemo)(() => {
2846
2878
  if (!state.activeCell) return "";
2847
2879
  const row = state.document.rows[state.activeCell.row];
2848
2880
  const col = state.document.columns[state.activeCell.col];
2849
2881
  if (!row || !col) return "";
2850
2882
  return state.getCell(row.id, col.id).raw;
2851
2883
  }, [state.activeCell, state.document]);
2852
- const activeSpill = (0, import_react37.useMemo)(
2884
+ const activeSpill = (0, import_react38.useMemo)(
2853
2885
  () => state.activeCell ? state.controller.getSpillAt(state.activeCell.row, state.activeCell.col) : null,
2854
2886
  // eslint-disable-next-line react-hooks/exhaustive-deps
2855
2887
  [state.controller, state.activeCell, state.document]
2856
2888
  );
2857
2889
  const spillFormula = activeSpill && !activeRawValue && activeSpill.key !== coordKey(state.activeCell) ? activeSpill.formula : "";
2858
- const coordLabel = (0, import_react37.useMemo)(() => {
2890
+ const coordLabel = (0, import_react38.useMemo)(() => {
2859
2891
  if (!state.activeCell) return "--";
2860
2892
  const colName = (0, import_spreadsheet8.indexToColName)(state.activeCell.col);
2861
2893
  return `${colName}${state.activeCell.row + 1}`;
2862
2894
  }, [state.activeCell]);
2863
- const [formulaDraft, setFormulaDraft] = (0, import_react37.useState)(null);
2895
+ const [formulaDraft, setFormulaDraft] = (0, import_react38.useState)(null);
2864
2896
  const activeColumn = state.activeCell ? state.document.columns[state.activeCell.col] : void 0;
2865
2897
  const formulaBarReadOnly = readOnly || !state.activeCell || !!activeColumn?.readOnly;
2866
- (0, import_react37.useEffect)(() => {
2898
+ (0, import_react38.useEffect)(() => {
2867
2899
  setFormulaDraft(null);
2868
2900
  }, [state.activeCell?.row, state.activeCell?.col]);
2869
2901
  const commitFormulaBar = () => {
@@ -2879,19 +2911,19 @@ var SpreadsheetEditor = ({
2879
2911
  }
2880
2912
  setFormulaDraft(null);
2881
2913
  };
2882
- const handleCellClick = (0, import_react37.useCallback)((rIdx, cIdx, e) => {
2914
+ const handleCellClick = (0, import_react38.useCallback)((rIdx, cIdx, e) => {
2883
2915
  if (state.editingCell && (state.editingCell.row !== rIdx || state.editingCell.col !== cIdx)) {
2884
2916
  state.commitEditing();
2885
2917
  }
2886
2918
  state.selectCell(rIdx, cIdx, e.shiftKey);
2887
2919
  }, [state]);
2888
- const handleCellDblClick = (0, import_react37.useCallback)((rIdx, cIdx) => {
2920
+ const handleCellDblClick = (0, import_react38.useCallback)((rIdx, cIdx) => {
2889
2921
  if (readOnly) return;
2890
2922
  const col = state.document.columns[cIdx];
2891
2923
  if (col?.readOnly) return;
2892
2924
  state.startEditing(rIdx, cIdx);
2893
2925
  }, [readOnly, state]);
2894
- const handleKeyDown = (0, import_react37.useCallback)((e) => {
2926
+ const handleKeyDown = (0, import_react38.useCallback)((e) => {
2895
2927
  if (state.editingCell) {
2896
2928
  if (e.key === "Enter") {
2897
2929
  e.preventDefault();
@@ -2963,12 +2995,12 @@ var SpreadsheetEditor = ({
2963
2995
  }
2964
2996
  }
2965
2997
  }, [readOnly, state, copyShortcutFallback]);
2966
- const activeListValues = (0, import_react37.useMemo)(
2998
+ const activeListValues = (0, import_react38.useMemo)(
2967
2999
  () => state.activeCell && !readOnly ? state.controller.getValidationListValues(state.activeCell.row, state.activeCell.col) : null,
2968
3000
  // eslint-disable-next-line react-hooks/exhaustive-deps
2969
3001
  [state.controller, state.activeCell, state.document, readOnly]
2970
3002
  );
2971
- const activeRule = (0, import_react37.useMemo)(
3003
+ const activeRule = (0, import_react38.useMemo)(
2972
3004
  () => state.activeCell ? state.controller.getDataValidationAt(state.activeCell.row, state.activeCell.col) : void 0,
2973
3005
  // eslint-disable-next-line react-hooks/exhaustive-deps
2974
3006
  [state.controller, state.activeCell, state.document]
@@ -2982,7 +3014,7 @@ var SpreadsheetEditor = ({
2982
3014
  const rect = td?.getBoundingClientRect();
2983
3015
  setListMenu({ x: rect ? rect.left : 0, y: rect ? rect.bottom : 0, row, col, values });
2984
3016
  }
2985
- (0, import_react37.useEffect)(() => {
3017
+ (0, import_react38.useEffect)(() => {
2986
3018
  if (!listMenu) return;
2987
3019
  const close = (e) => {
2988
3020
  if (!e.target?.closest?.('[aria-label="Allowed values"], .spreadsheet-list-arrow')) setListMenu(null);
@@ -3005,11 +3037,11 @@ var SpreadsheetEditor = ({
3005
3037
  else gridRef.current?.focus();
3006
3038
  });
3007
3039
  };
3008
- const stateRef = (0, import_react37.useRef)(state);
3040
+ const stateRef = (0, import_react38.useRef)(state);
3009
3041
  stateRef.current = state;
3010
- const onColumnResizeRef = (0, import_react37.useRef)(onColumnResize);
3042
+ const onColumnResizeRef = (0, import_react38.useRef)(onColumnResize);
3011
3043
  onColumnResizeRef.current = onColumnResize;
3012
- (0, import_react37.useEffect)(() => {
3044
+ (0, import_react38.useEffect)(() => {
3013
3045
  if (!resizingColId) return;
3014
3046
  if (typeof document !== "undefined") {
3015
3047
  document.body.style.cursor = "col-resize";
@@ -3060,7 +3092,7 @@ var SpreadsheetEditor = ({
3060
3092
  window.removeEventListener("mouseup", handleMouseUp);
3061
3093
  };
3062
3094
  }, [resizingColId, resizeStartX, resizeStartWidth]);
3063
- const measureElementContentWidth = (0, import_react37.useCallback)((el, container) => {
3095
+ const measureElementContentWidth = (0, import_react38.useCallback)((el, container) => {
3064
3096
  if (typeof document === "undefined") return 0;
3065
3097
  let maxW = el.scrollWidth || 0;
3066
3098
  const firstChild = el.firstElementChild;
@@ -3108,7 +3140,7 @@ var SpreadsheetEditor = ({
3108
3140
  }
3109
3141
  return maxW;
3110
3142
  }, []);
3111
- const autoFitColumn = (0, import_react37.useCallback)((colId, colIndex) => {
3143
+ const autoFitColumn = (0, import_react38.useCallback)((colId, colIndex) => {
3112
3144
  const col = state.document.columns.find((c) => c.id === colId);
3113
3145
  if (!col) return;
3114
3146
  let calculatedWidth = 0;
@@ -3144,12 +3176,12 @@ var SpreadsheetEditor = ({
3144
3176
  onColumnResize(updatedCol.id, updatedCol.width || 130);
3145
3177
  }
3146
3178
  }, [state, measureElementContentWidth, onColumnResize]);
3147
- const handleResizeDblClick = (0, import_react37.useCallback)((colId, colIndex, e) => {
3179
+ const handleResizeDblClick = (0, import_react38.useCallback)((colId, colIndex, e) => {
3148
3180
  e.preventDefault();
3149
3181
  e.stopPropagation();
3150
3182
  autoFitColumn(colId, colIndex);
3151
3183
  }, [autoFitColumn]);
3152
- const handleHeaderDblClick = (0, import_react37.useCallback)((colId, colIndex, e) => {
3184
+ const handleHeaderDblClick = (0, import_react38.useCallback)((colId, colIndex, e) => {
3153
3185
  const target = e.currentTarget;
3154
3186
  if (target) {
3155
3187
  const rect = target.getBoundingClientRect();
@@ -3541,19 +3573,19 @@ var SpreadsheetEditor = ({
3541
3573
  };
3542
3574
 
3543
3575
  // src/spreadsheet/NameManager.tsx
3544
- var import_react38 = require("react");
3576
+ var import_react39 = require("react");
3545
3577
  var import_spreadsheet9 = require("@pixerate/editor/spreadsheet");
3546
3578
  var import_jsx_runtime18 = require("react/jsx-runtime");
3547
3579
  var EMPTY_DRAFT = { original: null, name: "", refersTo: "=", scope: "", comment: "" };
3548
3580
  var NameManager = ({ state, readOnly = false, onClose, className = "" }) => {
3549
3581
  const { controller, sheets } = state;
3550
- const rows = (0, import_react38.useMemo)(
3582
+ const rows = (0, import_react39.useMemo)(
3551
3583
  () => (0, import_spreadsheet9.getNameManagerRows)(controller),
3552
3584
  // eslint-disable-next-line react-hooks/exhaustive-deps
3553
3585
  [controller, state.document, state.names]
3554
3586
  );
3555
- const [draft, setDraft] = (0, import_react38.useState)(EMPTY_DRAFT);
3556
- const [error, setError] = (0, import_react38.useState)(null);
3587
+ const [draft, setDraft] = (0, import_react39.useState)(EMPTY_DRAFT);
3588
+ const [error, setError] = (0, import_react39.useState)(null);
3557
3589
  const edit = (row) => {
3558
3590
  setError(null);
3559
3591
  setDraft({
@@ -3696,7 +3728,7 @@ var NameManager = ({ state, readOnly = false, onClose, className = "" }) => {
3696
3728
  };
3697
3729
 
3698
3730
  // src/slots.tsx
3699
- var import_react39 = require("react");
3731
+ var import_react40 = require("react");
3700
3732
  var import_jsx_runtime19 = require("react/jsx-runtime");
3701
3733
  var defaultSlots = {
3702
3734
  Button: (props) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
@@ -3718,121 +3750,121 @@ var defaultSlots = {
3718
3750
  props.onClose && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", onClick: props.onClose, className: "opacity-70 hover:opacity-100", children: "\xD7" })
3719
3751
  ] })
3720
3752
  };
3721
- var EditorSlotsContext = (0, import_react39.createContext)(defaultSlots);
3753
+ var EditorSlotsContext = (0, import_react40.createContext)(defaultSlots);
3722
3754
  function EditorSlotsProvider({ slots, children }) {
3723
- const mergedSlots = (0, import_react39.useMemo)(() => ({ ...defaultSlots, ...slots }), [slots]);
3755
+ const mergedSlots = (0, import_react40.useMemo)(() => ({ ...defaultSlots, ...slots }), [slots]);
3724
3756
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(EditorSlotsContext.Provider, { value: mergedSlots, children });
3725
3757
  }
3726
3758
  function useEditorSlots() {
3727
- return (0, import_react39.useContext)(EditorSlotsContext);
3759
+ return (0, import_react40.useContext)(EditorSlotsContext);
3728
3760
  }
3729
3761
 
3730
3762
  // src/image-editor/useImageEditor.ts
3731
- var import_react40 = require("react");
3763
+ var import_react41 = require("react");
3732
3764
  var import_image_editor = require("@pixerate/editor/image-editor");
3733
3765
  function useImageEditor(options = {}) {
3734
- const controllerRef = (0, import_react40.useRef)(null);
3766
+ const controllerRef = (0, import_react41.useRef)(null);
3735
3767
  if (!controllerRef.current) {
3736
3768
  controllerRef.current = new import_image_editor.ImageEditorController(options);
3737
3769
  }
3738
3770
  const controller = controllerRef.current;
3739
- const [state, setState] = (0, import_react40.useState)(() => controller.getState());
3740
- const [historyTicks, setHistoryTicks] = (0, import_react40.useState)(0);
3741
- const [histogram, setHistogram] = (0, import_react40.useState)(() => controller.getHistogram());
3742
- (0, import_react40.useEffect)(() => controller.subscribeHistogram(setHistogram), [controller]);
3743
- (0, import_react40.useEffect)(() => {
3771
+ const [state, setState] = (0, import_react41.useState)(() => controller.getState());
3772
+ const [historyTicks, setHistoryTicks] = (0, import_react41.useState)(0);
3773
+ const [histogram, setHistogram] = (0, import_react41.useState)(() => controller.getHistogram());
3774
+ (0, import_react41.useEffect)(() => controller.subscribeHistogram(setHistogram), [controller]);
3775
+ (0, import_react41.useEffect)(() => {
3744
3776
  const unsub = controller.subscribe((next) => {
3745
3777
  setState(next);
3746
3778
  setHistoryTicks((t) => t + 1);
3747
3779
  });
3748
3780
  return unsub;
3749
3781
  }, [controller]);
3750
- const loadedImageRef = (0, import_react40.useRef)(options.image);
3751
- (0, import_react40.useEffect)(() => {
3782
+ const loadedImageRef = (0, import_react41.useRef)(options.image);
3783
+ (0, import_react41.useEffect)(() => {
3752
3784
  if (options.image === loadedImageRef.current) return;
3753
3785
  loadedImageRef.current = options.image;
3754
3786
  if (options.image) {
3755
3787
  controller.loadImage(options.image);
3756
3788
  }
3757
3789
  }, [options.image, controller]);
3758
- const setTool = (0, import_react40.useCallback)((tool) => controller.setTool(tool), [controller]);
3759
- const setCrop = (0, import_react40.useCallback)(
3790
+ const setTool = (0, import_react41.useCallback)((tool) => controller.setTool(tool), [controller]);
3791
+ const setCrop = (0, import_react41.useCallback)(
3760
3792
  (crop, addToHistory = true) => controller.setCrop(crop, addToHistory),
3761
3793
  [controller]
3762
3794
  );
3763
- const applyCropPreset = (0, import_react40.useCallback)((ratio) => controller.applyCropPreset(ratio), [controller]);
3764
- const resetCrop = (0, import_react40.useCallback)(() => controller.resetCrop(), [controller]);
3765
- const rotate = (0, import_react40.useCallback)((deg) => controller.rotate(deg), [controller]);
3766
- const setRotation = (0, import_react40.useCallback)((deg) => controller.setRotation(deg), [controller]);
3767
- const flipHorizontal = (0, import_react40.useCallback)(() => controller.flipHorizontal(), [controller]);
3768
- const flipVertical = (0, import_react40.useCallback)(() => controller.flipVertical(), [controller]);
3769
- const setAdjustments = (0, import_react40.useCallback)(
3795
+ const applyCropPreset = (0, import_react41.useCallback)((ratio) => controller.applyCropPreset(ratio), [controller]);
3796
+ const resetCrop = (0, import_react41.useCallback)(() => controller.resetCrop(), [controller]);
3797
+ const rotate = (0, import_react41.useCallback)((deg) => controller.rotate(deg), [controller]);
3798
+ const setRotation = (0, import_react41.useCallback)((deg) => controller.setRotation(deg), [controller]);
3799
+ const flipHorizontal = (0, import_react41.useCallback)(() => controller.flipHorizontal(), [controller]);
3800
+ const flipVertical = (0, import_react41.useCallback)(() => controller.flipVertical(), [controller]);
3801
+ const setAdjustments = (0, import_react41.useCallback)(
3770
3802
  (partial, commitToHistory = true) => controller.setAdjustments(partial, commitToHistory),
3771
3803
  [controller]
3772
3804
  );
3773
- const resetAdjustments = (0, import_react40.useCallback)(() => controller.resetAdjustments(), [controller]);
3774
- const upgradeProcess = (0, import_react40.useCallback)(() => controller.upgradeProcess(), [controller]);
3775
- const addAdjustmentLayer = (0, import_react40.useCallback)(
3805
+ const resetAdjustments = (0, import_react41.useCallback)(() => controller.resetAdjustments(), [controller]);
3806
+ const upgradeProcess = (0, import_react41.useCallback)(() => controller.upgradeProcess(), [controller]);
3807
+ const addAdjustmentLayer = (0, import_react41.useCallback)(
3776
3808
  (init, index) => controller.addAdjustmentLayer(init, index),
3777
3809
  [controller]
3778
3810
  );
3779
- const updateAdjustmentLayer = (0, import_react40.useCallback)(
3811
+ const updateAdjustmentLayer = (0, import_react41.useCallback)(
3780
3812
  (id, update, commitToHistory = true) => controller.updateAdjustmentLayer(id, update, commitToHistory),
3781
3813
  [controller]
3782
3814
  );
3783
- const removeAdjustmentLayer = (0, import_react40.useCallback)((id) => controller.removeAdjustmentLayer(id), [controller]);
3784
- const moveAdjustmentLayer = (0, import_react40.useCallback)((id, to) => controller.moveAdjustmentLayer(id, to), [controller]);
3785
- const toggleAdjustmentLayer = (0, import_react40.useCallback)(
3815
+ const removeAdjustmentLayer = (0, import_react41.useCallback)((id) => controller.removeAdjustmentLayer(id), [controller]);
3816
+ const moveAdjustmentLayer = (0, import_react41.useCallback)((id, to) => controller.moveAdjustmentLayer(id, to), [controller]);
3817
+ const toggleAdjustmentLayer = (0, import_react41.useCallback)(
3786
3818
  (id, enabled) => controller.toggleAdjustmentLayer(id, enabled),
3787
3819
  [controller]
3788
3820
  );
3789
- const setDepthMask = (0, import_react40.useCallback)((partial) => controller.setDepthMask(partial), [controller]);
3790
- const resetDepthMask = (0, import_react40.useCallback)(() => controller.resetDepthMask(), [controller]);
3791
- const addAnnotation = (0, import_react40.useCallback)((ann) => controller.addAnnotation(ann), [controller]);
3792
- const updateAnnotation = (0, import_react40.useCallback)(
3821
+ const setDepthMask = (0, import_react41.useCallback)((partial) => controller.setDepthMask(partial), [controller]);
3822
+ const resetDepthMask = (0, import_react41.useCallback)(() => controller.resetDepthMask(), [controller]);
3823
+ const addAnnotation = (0, import_react41.useCallback)((ann) => controller.addAnnotation(ann), [controller]);
3824
+ const updateAnnotation = (0, import_react41.useCallback)(
3793
3825
  (id, partial, commitToHistory = true) => controller.updateAnnotation(id, partial, commitToHistory),
3794
3826
  [controller]
3795
3827
  );
3796
- const removeAnnotation = (0, import_react40.useCallback)((id) => controller.removeAnnotation(id), [controller]);
3797
- const clearAnnotations = (0, import_react40.useCallback)(() => controller.clearAnnotations(), [controller]);
3798
- const selectAnnotation = (0, import_react40.useCallback)((id) => controller.selectAnnotation(id), [controller]);
3799
- const undo = (0, import_react40.useCallback)(() => controller.undo(), [controller]);
3800
- const redo = (0, import_react40.useCallback)(() => controller.redo(), [controller]);
3801
- const reset = (0, import_react40.useCallback)(() => controller.reset(), [controller]);
3802
- const zoomIn = (0, import_react40.useCallback)((factor) => controller.zoomIn(factor), [controller]);
3803
- const zoomOut = (0, import_react40.useCallback)((factor) => controller.zoomOut(factor), [controller]);
3804
- const resetZoom = (0, import_react40.useCallback)(() => controller.resetZoom(), [controller]);
3805
- const setZoom = (0, import_react40.useCallback)((zoom) => controller.setZoom(zoom), [controller]);
3806
- const setPan = (0, import_react40.useCallback)((pan) => controller.setPan(pan), [controller]);
3807
- const setComparing = (0, import_react40.useCallback)((comp) => controller.setComparing(comp), [controller]);
3808
- const loadImage = (0, import_react40.useCallback)((src) => controller.loadImage(src), [controller]);
3809
- const toDataURL = (0, import_react40.useCallback)((opts) => controller.toDataURL(opts), [controller]);
3810
- const toBlob = (0, import_react40.useCallback)((opts) => controller.toBlob(opts), [controller]);
3811
- const toJSON = (0, import_react40.useCallback)(() => controller.toJSON(), [controller]);
3812
- const loadJSON = (0, import_react40.useCallback)((data) => controller.loadJSON(data), [controller]);
3813
- const renderMask = (0, import_react40.useCallback)(
3828
+ const removeAnnotation = (0, import_react41.useCallback)((id) => controller.removeAnnotation(id), [controller]);
3829
+ const clearAnnotations = (0, import_react41.useCallback)(() => controller.clearAnnotations(), [controller]);
3830
+ const selectAnnotation = (0, import_react41.useCallback)((id) => controller.selectAnnotation(id), [controller]);
3831
+ const undo = (0, import_react41.useCallback)(() => controller.undo(), [controller]);
3832
+ const redo = (0, import_react41.useCallback)(() => controller.redo(), [controller]);
3833
+ const reset = (0, import_react41.useCallback)(() => controller.reset(), [controller]);
3834
+ const zoomIn = (0, import_react41.useCallback)((factor) => controller.zoomIn(factor), [controller]);
3835
+ const zoomOut = (0, import_react41.useCallback)((factor) => controller.zoomOut(factor), [controller]);
3836
+ const resetZoom = (0, import_react41.useCallback)(() => controller.resetZoom(), [controller]);
3837
+ const setZoom = (0, import_react41.useCallback)((zoom) => controller.setZoom(zoom), [controller]);
3838
+ const setPan = (0, import_react41.useCallback)((pan) => controller.setPan(pan), [controller]);
3839
+ const setComparing = (0, import_react41.useCallback)((comp) => controller.setComparing(comp), [controller]);
3840
+ const loadImage = (0, import_react41.useCallback)((src) => controller.loadImage(src), [controller]);
3841
+ const toDataURL = (0, import_react41.useCallback)((opts) => controller.toDataURL(opts), [controller]);
3842
+ const toBlob = (0, import_react41.useCallback)((opts) => controller.toBlob(opts), [controller]);
3843
+ const toJSON = (0, import_react41.useCallback)(() => controller.toJSON(), [controller]);
3844
+ const loadJSON = (0, import_react41.useCallback)((data) => controller.loadJSON(data), [controller]);
3845
+ const renderMask = (0, import_react41.useCallback)(
3814
3846
  (opts) => controller.renderMask(opts),
3815
3847
  [controller]
3816
3848
  );
3817
- const toMaskDataURL = (0, import_react40.useCallback)(
3849
+ const toMaskDataURL = (0, import_react41.useCallback)(
3818
3850
  (opts) => controller.toMaskDataURL(opts),
3819
3851
  [controller]
3820
3852
  );
3821
- const toSourceDataURL = (0, import_react40.useCallback)(
3853
+ const toSourceDataURL = (0, import_react41.useCallback)(
3822
3854
  (opts) => controller.toSourceDataURL(opts),
3823
3855
  [controller]
3824
3856
  );
3825
- const applyInpaintedImage = (0, import_react40.useCallback)(
3857
+ const applyInpaintedImage = (0, import_react41.useCallback)(
3826
3858
  (newDataUrl, options2) => controller.applyInpaintedImage(newDataUrl, options2),
3827
3859
  [controller]
3828
3860
  );
3829
- const applyBackgroundRemovedImage = (0, import_react40.useCallback)(
3861
+ const applyBackgroundRemovedImage = (0, import_react41.useCallback)(
3830
3862
  (newDataUrl, options2) => controller.applyBackgroundRemovedImage(newDataUrl, options2),
3831
3863
  [controller]
3832
3864
  );
3833
- const editorDocument = (0, import_react40.useMemo)(() => (0, import_image_editor.createImageEditorDocument)(controller), [controller]);
3834
- (0, import_react40.useEffect)(() => () => editorDocument.destroy(), [editorDocument]);
3835
- return (0, import_react40.useMemo)(
3865
+ const editorDocument = (0, import_react41.useMemo)(() => (0, import_image_editor.createImageEditorDocument)(controller), [controller]);
3866
+ (0, import_react41.useEffect)(() => () => editorDocument.destroy(), [editorDocument]);
3867
+ return (0, import_react41.useMemo)(
3836
3868
  () => ({
3837
3869
  controller,
3838
3870
  editorDocument,
@@ -3889,20 +3921,20 @@ function useImageEditor(options = {}) {
3889
3921
  }
3890
3922
  function useImageEffectsTools(registry, controller, options = {}) {
3891
3923
  const { id, namespace, readOnly, playbackSurface } = options;
3892
- (0, import_react40.useEffect)(() => {
3924
+ (0, import_react41.useEffect)(() => {
3893
3925
  if (!registry) return;
3894
3926
  return registry.register((0, import_image_editor.createImageEffectsToolProvider)(controller, { id, namespace, readOnly, playbackSurface }));
3895
3927
  }, [registry, controller, id, namespace, readOnly, playbackSurface]);
3896
3928
  }
3897
3929
 
3898
3930
  // src/image-editor/ImageEditor.tsx
3899
- var import_react82 = __toESM(require("react"), 1);
3931
+ var import_react83 = __toESM(require("react"), 1);
3900
3932
  var import_image_editor25 = require("@pixerate/editor/image-editor");
3901
3933
 
3902
3934
  // src/image-editor/ImageEditorCanvas.tsx
3903
- var import_react41 = require("react");
3935
+ var import_react42 = require("react");
3904
3936
  var import_image_editor2 = require("@pixerate/editor/image-editor");
3905
- var import_tools4 = require("@pixerate/editor/tools");
3937
+ var import_tools5 = require("@pixerate/editor/tools");
3906
3938
  var import_jsx_runtime20 = require("react/jsx-runtime");
3907
3939
  var ImageEditorCanvas = ({
3908
3940
  editor,
@@ -3931,18 +3963,18 @@ var ImageEditorCanvas = ({
3931
3963
  style
3932
3964
  }) => {
3933
3965
  const { state, controller } = editor;
3934
- const canvasRef = (0, import_react41.useRef)(null);
3935
- const containerRef = (0, import_react41.useRef)(null);
3936
- const rootRef = (0, import_react41.useRef)(null);
3937
- const viewRef = (0, import_react41.useRef)({ width: 0, height: 0 });
3938
- const modeRef = (0, import_react41.useRef)(mode);
3966
+ const canvasRef = (0, import_react42.useRef)(null);
3967
+ const containerRef = (0, import_react42.useRef)(null);
3968
+ const rootRef = (0, import_react42.useRef)(null);
3969
+ const viewRef = (0, import_react42.useRef)({ width: 0, height: 0 });
3970
+ const modeRef = (0, import_react42.useRef)(mode);
3939
3971
  modeRef.current = mode;
3940
- const latest = (0, import_react41.useRef)({ onError, onTypeSessionChange, locate, locateElement, open, chromeRoot, onPlaybackReveal });
3972
+ const latest = (0, import_react42.useRef)({ onError, onTypeSessionChange, locate, locateElement, open, chromeRoot, onPlaybackReveal });
3941
3973
  latest.current = { onError, onTypeSessionChange, locate, locateElement, open, chromeRoot, onPlaybackReveal };
3942
3974
  const report = (source, message2) => latest.current.onError?.(source, message2);
3943
3975
  const ambientPlayback = useAgentPlayback();
3944
3976
  const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
3945
- const locateLayer = (0, import_react41.useMemo)(() => (0, import_image_editor2.createImagePlaybackLocator)(controller), [controller]);
3977
+ const locateLayer = (0, import_react42.useMemo)(() => (0, import_image_editor2.createImagePlaybackLocator)(controller), [controller]);
3946
3978
  const docToRoot = (p) => {
3947
3979
  const canvas = canvasRef.current;
3948
3980
  const root = rootRef.current;
@@ -3999,22 +4031,22 @@ var ImageEditorCanvas = ({
3999
4031
  fromViewport: clientToDoc,
4000
4032
  reveal: () => latest.current.onPlaybackReveal?.()
4001
4033
  });
4002
- const selectionOptionsRef = (0, import_react41.useRef)(selectionOptions);
4034
+ const selectionOptionsRef = (0, import_react42.useRef)(selectionOptions);
4003
4035
  selectionOptionsRef.current = selectionOptions;
4004
- const selectionGestureRef = (0, import_react41.useRef)(null);
4036
+ const selectionGestureRef = (0, import_react42.useRef)(null);
4005
4037
  if (!selectionGestureRef.current || selectionGestureRef.current.controller !== controller) {
4006
4038
  selectionGestureRef.current = new import_image_editor2.SelectionGesture(controller, () => selectionOptionsRef.current);
4007
4039
  }
4008
- const selectionDraftRef = (0, import_react41.useRef)(null);
4009
- const paintGestureRef = (0, import_react41.useRef)(null);
4010
- const paintControllerRef = (0, import_react41.useRef)(controller);
4040
+ const selectionDraftRef = (0, import_react42.useRef)(null);
4041
+ const paintGestureRef = (0, import_react42.useRef)(null);
4042
+ const paintControllerRef = (0, import_react42.useRef)(controller);
4011
4043
  if (!paintGestureRef.current || paintControllerRef.current !== controller) {
4012
4044
  paintGestureRef.current = new import_image_editor2.PaintGesture(controller);
4013
4045
  paintControllerRef.current = controller;
4014
4046
  }
4015
- const brushCursorRef = (0, import_react41.useRef)(null);
4016
- const ownTransformRef = (0, import_react41.useRef)(null);
4017
- const ownTransformControllerRef = (0, import_react41.useRef)(controller);
4047
+ const brushCursorRef = (0, import_react42.useRef)(null);
4048
+ const ownTransformRef = (0, import_react42.useRef)(null);
4049
+ const ownTransformControllerRef = (0, import_react42.useRef)(controller);
4018
4050
  if (!hostTransformTool && (!ownTransformRef.current || ownTransformControllerRef.current !== controller)) {
4019
4051
  ownTransformRef.current?.cancel();
4020
4052
  ownTransformRef.current = new import_image_editor2.FreeTransformTool(controller, {
@@ -4023,43 +4055,43 @@ var ImageEditorCanvas = ({
4023
4055
  ownTransformControllerRef.current = controller;
4024
4056
  }
4025
4057
  const transformTool = hostTransformTool ?? ownTransformRef.current;
4026
- const [, setTransformTick] = (0, import_react41.useState)(0);
4027
- const [transformCursor, setTransformCursor] = (0, import_react41.useState)("default");
4028
- (0, import_react41.useEffect)(() => () => ownTransformRef.current?.cancel(), []);
4029
- const shapeOptionsRef = (0, import_react41.useRef)(shapeOptions);
4058
+ const [, setTransformTick] = (0, import_react42.useState)(0);
4059
+ const [transformCursor, setTransformCursor] = (0, import_react42.useState)("default");
4060
+ (0, import_react42.useEffect)(() => () => ownTransformRef.current?.cancel(), []);
4061
+ const shapeOptionsRef = (0, import_react42.useRef)(shapeOptions);
4030
4062
  shapeOptionsRef.current = shapeOptions;
4031
- const typeOptionsRef = (0, import_react41.useRef)(typeOptions);
4063
+ const typeOptionsRef = (0, import_react42.useRef)(typeOptions);
4032
4064
  typeOptionsRef.current = typeOptions;
4033
- const shapeGestureRef = (0, import_react41.useRef)(null);
4034
- const typeToolRef = (0, import_react41.useRef)(null);
4035
- const shapeTypeControllerRef = (0, import_react41.useRef)(controller);
4065
+ const shapeGestureRef = (0, import_react42.useRef)(null);
4066
+ const typeToolRef = (0, import_react42.useRef)(null);
4067
+ const shapeTypeControllerRef = (0, import_react42.useRef)(controller);
4036
4068
  if (!shapeGestureRef.current || !typeToolRef.current || shapeTypeControllerRef.current !== controller) {
4037
4069
  typeToolRef.current?.finish();
4038
4070
  shapeGestureRef.current = new import_image_editor2.ShapeDrawGesture(controller, () => shapeOptionsRef.current);
4039
4071
  typeToolRef.current = new import_image_editor2.TypeToolGesture(controller, () => typeOptionsRef.current);
4040
4072
  shapeTypeControllerRef.current = controller;
4041
4073
  }
4042
- const pathGestureRef = (0, import_react41.useRef)(null);
4043
- const pathControllerRef = (0, import_react41.useRef)(controller);
4074
+ const pathGestureRef = (0, import_react42.useRef)(null);
4075
+ const pathControllerRef = (0, import_react42.useRef)(controller);
4044
4076
  if (!pathGestureRef.current || pathControllerRef.current !== controller) {
4045
4077
  pathGestureRef.current = new import_image_editor2.PathEditGesture(controller);
4046
4078
  pathControllerRef.current = controller;
4047
4079
  }
4048
- const typeInputRef = (0, import_react41.useRef)(null);
4049
- const [typeSession, setTypeSessionState] = (0, import_react41.useState)(typeToolRef.current.session);
4080
+ const typeInputRef = (0, import_react42.useRef)(null);
4081
+ const [typeSession, setTypeSessionState] = (0, import_react42.useState)(typeToolRef.current.session);
4050
4082
  const setTypeSession = (session) => {
4051
4083
  setTypeSessionState(session);
4052
4084
  latest.current.onTypeSessionChange?.(session);
4053
4085
  };
4054
- const draftAnnotationRef = (0, import_react41.useRef)(null);
4055
- const draftCropRef = (0, import_react41.useRef)(null);
4056
- const cropDragInfoRef = (0, import_react41.useRef)(null);
4057
- const annotationDragInfoRef = (0, import_react41.useRef)(null);
4058
- const isDrawingRef = (0, import_react41.useRef)(false);
4059
- const currentPathRef = (0, import_react41.useRef)([]);
4060
- const dragStartPointRef = (0, import_react41.useRef)(null);
4061
- const antsOffsetRef = (0, import_react41.useRef)(0);
4062
- const renderCanvas = (0, import_react41.useCallback)(
4086
+ const draftAnnotationRef = (0, import_react42.useRef)(null);
4087
+ const draftCropRef = (0, import_react42.useRef)(null);
4088
+ const cropDragInfoRef = (0, import_react42.useRef)(null);
4089
+ const annotationDragInfoRef = (0, import_react42.useRef)(null);
4090
+ const isDrawingRef = (0, import_react42.useRef)(false);
4091
+ const currentPathRef = (0, import_react42.useRef)([]);
4092
+ const dragStartPointRef = (0, import_react42.useRef)(null);
4093
+ const antsOffsetRef = (0, import_react42.useRef)(0);
4094
+ const renderCanvas = (0, import_react42.useCallback)(
4063
4095
  async (draftAnnotation, draftCrop) => {
4064
4096
  const canvas = canvasRef.current;
4065
4097
  const container = containerRef.current;
@@ -4092,17 +4124,17 @@ var ImageEditorCanvas = ({
4092
4124
  [controller, mode, fit, transformTool]
4093
4125
  );
4094
4126
  const marching = !!state.selection?.bounds && !state.quickMask;
4095
- (0, import_react41.useEffect)(() => {
4127
+ (0, import_react42.useEffect)(() => {
4096
4128
  if (!marching) return;
4097
4129
  return (0, import_image_editor2.startMarchingAnts)((offset) => {
4098
4130
  antsOffsetRef.current = offset;
4099
4131
  void renderCanvas();
4100
4132
  });
4101
4133
  }, [marching, renderCanvas]);
4102
- (0, import_react41.useEffect)(() => {
4134
+ (0, import_react42.useEffect)(() => {
4103
4135
  let drafting = false;
4104
4136
  return agentPresence.subscribe(
4105
- (0, import_tools4.trackPresenceDrag)({
4137
+ (0, import_tools5.trackPresenceDrag)({
4106
4138
  onDrag: (box) => {
4107
4139
  if (cropDragInfoRef.current || selectionGestureRef.current?.active) return;
4108
4140
  const draft = (0, import_image_editor2.agentDragDraft)(modeRef.current, box, controller.getState().imageDimensions);
@@ -4122,18 +4154,18 @@ var ImageEditorCanvas = ({
4122
4154
  })
4123
4155
  );
4124
4156
  }, [agentPresence, controller, renderCanvas]);
4125
- (0, import_react41.useEffect)(() => typeSession?.subscribe(() => void renderCanvas()), [typeSession, renderCanvas]);
4157
+ (0, import_react42.useEffect)(() => typeSession?.subscribe(() => void renderCanvas()), [typeSession, renderCanvas]);
4126
4158
  const finishTyping = () => {
4127
4159
  typeToolRef.current?.finish();
4128
4160
  setTypeSession(null);
4129
4161
  void renderCanvas();
4130
4162
  };
4131
- (0, import_react41.useEffect)(() => {
4163
+ (0, import_react42.useEffect)(() => {
4132
4164
  if (mode === "annotate" && state.activeTool === "type") return;
4133
4165
  if (typeToolRef.current?.session) finishTyping();
4134
4166
  }, [mode, state.activeTool, renderCanvas]);
4135
- const prevTypeSessionProp = (0, import_react41.useRef)(typeSessionProp);
4136
- (0, import_react41.useEffect)(() => {
4167
+ const prevTypeSessionProp = (0, import_react42.useRef)(typeSessionProp);
4168
+ (0, import_react42.useEffect)(() => {
4137
4169
  const was = prevTypeSessionProp.current;
4138
4170
  prevTypeSessionProp.current = typeSessionProp;
4139
4171
  if (was && typeSessionProp === null && typeToolRef.current?.session) finishTyping();
@@ -4160,7 +4192,7 @@ var ImageEditorCanvas = ({
4160
4192
  el.value = "";
4161
4193
  }
4162
4194
  };
4163
- (0, import_react41.useEffect)(() => transformTool.subscribe(() => {
4195
+ (0, import_react42.useEffect)(() => transformTool.subscribe(() => {
4164
4196
  setTransformTick((n) => n + 1);
4165
4197
  void renderCanvas();
4166
4198
  }), [transformTool, renderCanvas]);
@@ -4203,7 +4235,7 @@ var ImageEditorCanvas = ({
4203
4235
  transformTool.up();
4204
4236
  return true;
4205
4237
  };
4206
- (0, import_react41.useEffect)(() => {
4238
+ (0, import_react42.useEffect)(() => {
4207
4239
  if (typeof window === "undefined") return;
4208
4240
  const onKey = (e) => {
4209
4241
  if (transformTool.key(e)) e.preventDefault();
@@ -4211,7 +4243,7 @@ var ImageEditorCanvas = ({
4211
4243
  window.addEventListener("keydown", onKey);
4212
4244
  return () => window.removeEventListener("keydown", onKey);
4213
4245
  }, [transformTool]);
4214
- (0, import_react41.useEffect)(() => {
4246
+ (0, import_react42.useEffect)(() => {
4215
4247
  const raf = typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : (cb) => setTimeout(cb, 0);
4216
4248
  const caf = typeof cancelAnimationFrame !== "undefined" ? cancelAnimationFrame : (id) => clearTimeout(id);
4217
4249
  const animId = raf(() => {
@@ -4219,7 +4251,7 @@ var ImageEditorCanvas = ({
4219
4251
  });
4220
4252
  return () => caf(animId);
4221
4253
  }, [renderCanvas, state]);
4222
- (0, import_react41.useEffect)(() => {
4254
+ (0, import_react42.useEffect)(() => {
4223
4255
  const container = containerRef.current;
4224
4256
  if (!container) return;
4225
4257
  const { width, height } = (0, import_image_editor2.measureCanvasViewport)(container);
@@ -4279,7 +4311,7 @@ var ImageEditorCanvas = ({
4279
4311
  if (g.error) report("paint", g.error);
4280
4312
  }
4281
4313
  };
4282
- (0, import_react41.useEffect)(() => {
4314
+ (0, import_react42.useEffect)(() => {
4283
4315
  if (mode !== "select" || typeof window === "undefined") return;
4284
4316
  const onKey = (e) => {
4285
4317
  const target = e.target;
@@ -4303,7 +4335,7 @@ var ImageEditorCanvas = ({
4303
4335
  window.addEventListener("keydown", onKey);
4304
4336
  return () => window.removeEventListener("keydown", onKey);
4305
4337
  });
4306
- (0, import_react41.useEffect)(() => {
4338
+ (0, import_react42.useEffect)(() => {
4307
4339
  if (mode !== "annotate" || typeof window === "undefined") return;
4308
4340
  const onKey = (e) => {
4309
4341
  const target = e.target;
@@ -4318,7 +4350,7 @@ var ImageEditorCanvas = ({
4318
4350
  window.addEventListener("keydown", onKey);
4319
4351
  return () => window.removeEventListener("keydown", onKey);
4320
4352
  });
4321
- (0, import_react41.useEffect)(() => {
4353
+ (0, import_react42.useEffect)(() => {
4322
4354
  if (mode !== "paint" || typeof window === "undefined") return;
4323
4355
  const onKey = (e) => {
4324
4356
  if ((0, import_image_editor2.handlePaintShortcut)(controller, e)) e.preventDefault();
@@ -4725,7 +4757,7 @@ var ImageEditorCanvas = ({
4725
4757
  var import_image_editor3 = require("@pixerate/editor/image-editor");
4726
4758
 
4727
4759
  // src/image-editor/controls/controls.tsx
4728
- var import_react42 = require("react");
4760
+ var import_react43 = require("react");
4729
4761
 
4730
4762
  // src/image-editor/styles.ts
4731
4763
  var imageEditorFrameClass = "relative flex flex-col bg-background border border-border rounded-xl overflow-hidden shadow-sm text-foreground";
@@ -4751,12 +4783,12 @@ var imageSpinnerClass = "w-3.5 h-3.5 border-2 border-primary-foreground/30 borde
4751
4783
 
4752
4784
  // src/image-editor/controls/controls.tsx
4753
4785
  var import_jsx_runtime21 = require("react/jsx-runtime");
4754
- var ControlsContext = (0, import_react42.createContext)({});
4786
+ var ControlsContext = (0, import_react43.createContext)({});
4755
4787
  function ImageEditorControlsProvider({ controls, children }) {
4756
4788
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ControlsContext.Provider, { value: controls, children });
4757
4789
  }
4758
4790
  function useImageEditorControls() {
4759
- return (0, import_react42.useContext)(ControlsContext);
4791
+ return (0, import_react43.useContext)(ControlsContext);
4760
4792
  }
4761
4793
  function ImageCheckbox(props) {
4762
4794
  const Host = useImageEditorControls().Checkbox;
@@ -4839,7 +4871,7 @@ var ControlSlider = ({ spec, value, onChange, disabled, label, className }) => {
4839
4871
  };
4840
4872
 
4841
4873
  // src/image-editor/Histogram.tsx
4842
- var import_react43 = require("react");
4874
+ var import_react44 = require("react");
4843
4875
  var import_image_editor4 = require("@pixerate/editor/image-editor");
4844
4876
  var import_jsx_runtime23 = require("react/jsx-runtime");
4845
4877
  var FILL = {
@@ -4851,7 +4883,7 @@ var FILL = {
4851
4883
  var W = 256;
4852
4884
  var Histogram = ({ histogram, channel = "rgb", height = 64, className = "", style }) => {
4853
4885
  const channels = channel === "rgb" ? ["luminance", "red", "green", "blue"] : [channel];
4854
- const paths = (0, import_react43.useMemo)(
4886
+ const paths = (0, import_react44.useMemo)(
4855
4887
  () => histogram && histogram.samples > 0 ? channels.map((c) => ({ c, d: (0, import_image_editor4.histogramPath)(histogram, c, W, height) })) : [],
4856
4888
  // eslint-disable-next-line react-hooks/exhaustive-deps
4857
4889
  [histogram, channel, height]
@@ -4877,24 +4909,24 @@ var Histogram = ({ histogram, channel = "rgb", height = 64, className = "", styl
4877
4909
  );
4878
4910
  };
4879
4911
  function useImageHistogram(controller) {
4880
- const [histogram, setHistogram] = (0, import_react43.useState)(() => controller.getHistogram());
4881
- (0, import_react43.useEffect)(() => controller.subscribeHistogram(setHistogram), [controller]);
4912
+ const [histogram, setHistogram] = (0, import_react44.useState)(() => controller.getHistogram());
4913
+ (0, import_react44.useEffect)(() => controller.subscribeHistogram(setHistogram), [controller]);
4882
4914
  return histogram;
4883
4915
  }
4884
4916
 
4885
4917
  // src/image-editor/AdjustmentLayersPanel.tsx
4886
- var import_react45 = require("react");
4918
+ var import_react46 = require("react");
4887
4919
  var import_image_editor6 = require("@pixerate/editor/image-editor");
4888
4920
 
4889
4921
  // src/image-editor/CurvesEditor.tsx
4890
- var import_react44 = require("react");
4922
+ var import_react45 = require("react");
4891
4923
  var import_image_editor5 = require("@pixerate/editor/image-editor");
4892
4924
  var import_jsx_runtime24 = require("react/jsx-runtime");
4893
4925
  var BOX = 256;
4894
4926
  var STROKE = { master: "var(--foreground, #e2e8f0)", red: "#ef4444", green: "#22c55e", blue: "#3b82f6" };
4895
4927
  var CurvesEditor = ({ points, onChange, histogram, channel = "master", size = 200, className = "" }) => {
4896
- const svgRef = (0, import_react44.useRef)(null);
4897
- const [drag, setDrag] = (0, import_react44.useState)(null);
4928
+ const svgRef = (0, import_react45.useRef)(null);
4929
+ const [drag, setDrag] = (0, import_react45.useState)(null);
4898
4930
  const toBox = (e) => {
4899
4931
  const rect = svgRef.current?.getBoundingClientRect();
4900
4932
  if (!rect || !rect.width || !rect.height) return { x: 0, y: 0 };
@@ -4992,14 +5024,14 @@ var HueRangeStrip = ({ bounds }) => {
4992
5024
  };
4993
5025
  var AdjustmentLayersPanel = ({ controller, layers: layersProp, histogram, className = "" }) => {
4994
5026
  const follow = layersProp === void 0;
4995
- const [, setTick] = (0, import_react45.useState)(0);
4996
- (0, import_react45.useEffect)(() => follow ? controller.subscribe(() => setTick((n) => n + 1)) : void 0, [controller, follow]);
5027
+ const [, setTick] = (0, import_react46.useState)(0);
5028
+ (0, import_react46.useEffect)(() => follow ? controller.subscribe(() => setTick((n) => n + 1)) : void 0, [controller, follow]);
4997
5029
  const layers = layersProp ?? controller.getAdjustmentLayers();
4998
- const [newKind, setNewKind] = (0, import_react45.useState)("curves");
4999
- const [selectedId, setSelectedId] = (0, import_react45.useState)(null);
5000
- const [channel, setChannel] = (0, import_react45.useState)("master");
5001
- const [range, setRange] = (0, import_react45.useState)(-1);
5002
- const [tone, setTone] = (0, import_react45.useState)("midtones");
5030
+ const [newKind, setNewKind] = (0, import_react46.useState)("curves");
5031
+ const [selectedId, setSelectedId] = (0, import_react46.useState)(null);
5032
+ const [channel, setChannel] = (0, import_react46.useState)("master");
5033
+ const [range, setRange] = (0, import_react46.useState)(-1);
5034
+ const [tone, setTone] = (0, import_react46.useState)("midtones");
5003
5035
  const selected = layers.find((l) => l.id === selectedId) ?? null;
5004
5036
  const topFirst = [...layers].reverse();
5005
5037
  const setParam = (layer, path, value, commit = true) => controller.updateAdjustmentLayer(layer.id, { params: (0, import_image_editor6.setControlPath)(layer.params, path, value) }, commit);
@@ -5195,18 +5227,18 @@ var AdjustmentLayersPanel = ({ controller, layers: layersProp, histogram, classN
5195
5227
  };
5196
5228
 
5197
5229
  // src/image-editor/LayersPanel.tsx
5198
- var import_react50 = __toESM(require("react"), 1);
5230
+ var import_react51 = __toESM(require("react"), 1);
5199
5231
 
5200
5232
  // src/image-editor/LayerEffectsPanel.tsx
5201
- var import_react46 = require("react");
5233
+ var import_react47 = require("react");
5202
5234
  var import_raster = require("@pixerate/editor/raster");
5203
5235
  var import_jsx_runtime26 = require("react/jsx-runtime");
5204
5236
  var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) => {
5205
- const [, setTick] = (0, import_react46.useState)(0);
5206
- (0, import_react46.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
5207
- const [open, setOpen] = (0, import_react46.useState)(null);
5208
- const [error, setError] = (0, import_react46.useState)(null);
5209
- const commitNext = (0, import_react46.useRef)(true);
5237
+ const [, setTick] = (0, import_react47.useState)(0);
5238
+ (0, import_react47.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
5239
+ const [open, setOpen] = (0, import_react47.useState)(null);
5240
+ const [error, setError] = (0, import_react47.useState)(null);
5241
+ const commitNext = (0, import_react47.useRef)(true);
5210
5242
  const layer = layerId ? controller.getLayer(layerId) : controller.getActiveLayer();
5211
5243
  const model = (0, import_raster.layerEffectsPanel)(layer);
5212
5244
  const id = layer?.id;
@@ -5354,7 +5386,7 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
5354
5386
  };
5355
5387
 
5356
5388
  // src/image-editor/EdgeColorPanel.tsx
5357
- var import_react47 = require("react");
5389
+ var import_react48 = require("react");
5358
5390
  var import_jsx_runtime27 = require("react/jsx-runtime");
5359
5391
  var SLIDERS = [
5360
5392
  { key: "decontaminate", label: "Decontaminate", hint: "Unmix the old background from a soft-edged mask" },
@@ -5362,8 +5394,8 @@ var SLIDERS = [
5362
5394
  { key: "ambient", label: "Cast", hint: "Tint the edge with what is behind the layer, live" }
5363
5395
  ];
5364
5396
  var EdgeColorPanel = ({ controller, layer, className = "" }) => {
5365
- const [error, setError] = (0, import_react47.useState)(null);
5366
- const commitNext = (0, import_react47.useRef)(true);
5397
+ const [error, setError] = (0, import_react48.useState)(null);
5398
+ const commitNext = (0, import_react48.useRef)(true);
5367
5399
  const info = controller.getEdgeColor(layer.id);
5368
5400
  const fixed = info.ambientSource !== "auto";
5369
5401
  const set = (change) => {
@@ -5440,12 +5472,12 @@ var EdgeColorPanel = ({ controller, layer, className = "" }) => {
5440
5472
  };
5441
5473
 
5442
5474
  // src/image-editor/VectorMaskEdgesPanel.tsx
5443
- var import_react48 = require("react");
5475
+ var import_react49 = require("react");
5444
5476
  var import_jsx_runtime28 = require("react/jsx-runtime");
5445
5477
  var MODES = ["hard", "feather", "matte"];
5446
5478
  var input = "w-12 bg-background border border-border rounded px-1 py-0.5 text-foreground";
5447
5479
  var VectorMaskEdgesPanel = ({ controller, layer, className = "" }) => {
5448
- const [error, setError] = (0, import_react48.useState)(null);
5480
+ const [error, setError] = (0, import_react49.useState)(null);
5449
5481
  const info = controller.getVectorMask(layer.id);
5450
5482
  if (!info) return null;
5451
5483
  const set = (e, mode, options = {}) => {
@@ -5490,17 +5522,17 @@ var VectorMaskEdgesPanel = ({ controller, layer, className = "" }) => {
5490
5522
  };
5491
5523
 
5492
5524
  // src/image-editor/SmartObjectPanel.tsx
5493
- var import_react49 = require("react");
5525
+ var import_react50 = require("react");
5494
5526
  var import_image_editor7 = require("@pixerate/editor/image-editor");
5495
5527
  var import_jsx_runtime29 = require("react/jsx-runtime");
5496
5528
  var button = imageIconButtonClass;
5497
5529
  var SmartObjectPanel = ({ controller, layerId, className }) => {
5498
- const [, setTick] = (0, import_react49.useState)(0);
5499
- (0, import_react49.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
5500
- const [open, setOpen] = (0, import_react49.useState)(null);
5501
- const [error, setError] = (0, import_react49.useState)(null);
5502
- const fileInput = (0, import_react49.useRef)(null);
5503
- const commitNext = (0, import_react49.useRef)(true);
5530
+ const [, setTick] = (0, import_react50.useState)(0);
5531
+ (0, import_react50.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
5532
+ const [open, setOpen] = (0, import_react50.useState)(null);
5533
+ const [error, setError] = (0, import_react50.useState)(null);
5534
+ const fileInput = (0, import_react50.useRef)(null);
5535
+ const commitNext = (0, import_react50.useRef)(true);
5504
5536
  const model = (0, import_image_editor7.smartObjectPanel)(controller, layerId);
5505
5537
  const id = model.layerId;
5506
5538
  const attempt = (fn) => {
@@ -5686,8 +5718,8 @@ var Thumbnail = ({
5686
5718
  selected,
5687
5719
  testId
5688
5720
  }) => {
5689
- const ref = (0, import_react50.useRef)(null);
5690
- (0, import_react50.useEffect)(() => {
5721
+ const ref = (0, import_react51.useRef)(null);
5722
+ (0, import_react51.useEffect)(() => {
5691
5723
  const canvas = ref.current;
5692
5724
  const ctx = canvas?.getContext("2d");
5693
5725
  if (!canvas || !ctx || !pixels || typeof ctx.createImageData !== "function") return;
@@ -5712,14 +5744,14 @@ var Thumbnail = ({
5712
5744
  );
5713
5745
  };
5714
5746
  var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "image", effects = true, smartObjects = true, className }) => {
5715
- const [, setTick] = (0, import_react50.useState)(0);
5716
- (0, import_react50.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
5717
- const [error, setError] = (0, import_react50.useState)(null);
5718
- const [renaming, setRenaming] = (0, import_react50.useState)(null);
5719
- const [menu, setMenu] = (0, import_react50.useState)(null);
5720
- const [drag, setDrag] = (0, import_react50.useState)(null);
5721
- const [psdNotes, setPsdNotes] = (0, import_react50.useState)([]);
5722
- const fileInput = (0, import_react50.useRef)(null);
5747
+ const [, setTick] = (0, import_react51.useState)(0);
5748
+ (0, import_react51.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
5749
+ const [error, setError] = (0, import_react51.useState)(null);
5750
+ const [renaming, setRenaming] = (0, import_react51.useState)(null);
5751
+ const [menu, setMenu] = (0, import_react51.useState)(null);
5752
+ const [drag, setDrag] = (0, import_react51.useState)(null);
5753
+ const [psdNotes, setPsdNotes] = (0, import_react51.useState)([]);
5754
+ const fileInput = (0, import_react51.useRef)(null);
5723
5755
  const psdTask = async (fn) => {
5724
5756
  try {
5725
5757
  setError(null);
@@ -5728,7 +5760,7 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
5728
5760
  setError(err instanceof Error ? err.message : String(err));
5729
5761
  }
5730
5762
  };
5731
- const commitNext = (0, import_react50.useRef)(true);
5763
+ const commitNext = (0, import_react51.useRef)(true);
5732
5764
  const state = controller.getState();
5733
5765
  const maskView = controller.getMaskView();
5734
5766
  const rows = (0, import_image_editor8.layerPanelRows)(state.layers, state.activeLayerId);
@@ -5925,7 +5957,7 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
5925
5957
  const { layer } = row;
5926
5958
  const badge = (0, import_image_editor8.smartObjectBadge)(state.layers, layer);
5927
5959
  const filterRows = (0, import_image_editor8.smartFilterRows)(layer);
5928
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_react50.default.Fragment, { children: [
5960
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_react51.default.Fragment, { children: [
5929
5961
  /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
5930
5962
  "li",
5931
5963
  {
@@ -6246,21 +6278,21 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
6246
6278
  };
6247
6279
 
6248
6280
  // src/image-editor/ImageProviderEffectsPanel.tsx
6249
- var import_react60 = require("react");
6281
+ var import_react61 = require("react");
6250
6282
  var import_image_editor9 = require("@pixerate/editor/image-editor");
6251
6283
 
6252
6284
  // src/effects/useEffects.ts
6253
- var import_react51 = require("react");
6285
+ var import_react52 = require("react");
6254
6286
  function useEffects(host, provider) {
6255
- (0, import_react51.useEffect)(() => {
6287
+ (0, import_react52.useEffect)(() => {
6256
6288
  if (!host || !provider) return;
6257
6289
  return host.useEffects(provider);
6258
6290
  }, [host, provider]);
6259
6291
  }
6260
6292
  function useEffectDescription(provider, effect) {
6261
- const [state, setState] = (0, import_react51.useState)({ key: "", description: null, error: null });
6293
+ const [state, setState] = (0, import_react52.useState)({ key: "", description: null, error: null });
6262
6294
  const key = provider && effect ? `${provider.id}:${effect}` : "";
6263
- (0, import_react51.useEffect)(() => {
6295
+ (0, import_react52.useEffect)(() => {
6264
6296
  if (!provider || !effect) return;
6265
6297
  let live = true;
6266
6298
  Promise.resolve().then(() => provider.describe(effect)).then(
@@ -6275,14 +6307,14 @@ function useEffectDescription(provider, effect) {
6275
6307
  }
6276
6308
 
6277
6309
  // src/effects/EffectThumbnail.tsx
6278
- var import_react52 = require("react");
6310
+ var import_react53 = require("react");
6279
6311
  var import_effects = require("@pixerate/editor/effects");
6280
6312
  var import_jsx_runtime31 = require("react/jsx-runtime");
6281
- var LABELS = { motion: "Motion", camera: "Camera", timing: "Timing" };
6313
+ var LABELS = { motion: "Motion", camera: "Camera", timing: "Timing", "text-treatment": "Text treatment" };
6282
6314
  function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
6283
- const ref = (0, import_react52.useRef)(null);
6284
- const [failed, setFailed] = (0, import_react52.useState)(effect.kind in LABELS);
6285
- (0, import_react52.useEffect)(() => {
6315
+ const ref = (0, import_react53.useRef)(null);
6316
+ const [failed, setFailed] = (0, import_react53.useState)(effect.kind in LABELS);
6317
+ (0, import_react53.useEffect)(() => {
6286
6318
  if (effect.kind in LABELS) return;
6287
6319
  let live = true;
6288
6320
  (0, import_effects.renderEffectThumbnail)(provider, effect, { width, height }).then(
@@ -6309,16 +6341,16 @@ function EffectThumbnail({ provider, effect, width = 96, height = 54, className
6309
6341
  }
6310
6342
 
6311
6343
  // src/effects/EffectsBrowser.tsx
6312
- var import_react53 = require("react");
6344
+ var import_react54 = require("react");
6313
6345
  var import_effects2 = require("@pixerate/editor/effects");
6314
6346
  var import_jsx_runtime32 = require("react/jsx-runtime");
6315
6347
  function EffectsBrowser({ provider, uses, kinds, filter, onPick, thumbnails = true, title = "Effects", className = "" }) {
6316
- const [all, setAll] = (0, import_react53.useState)([]);
6317
- const [query, setQuery] = (0, import_react53.useState)("");
6318
- const [category, setCategory] = (0, import_react53.useState)("");
6319
- const [use, setUse] = (0, import_react53.useState)("");
6320
- const [error, setError] = (0, import_react53.useState)(null);
6321
- (0, import_react53.useEffect)(() => {
6348
+ const [all, setAll] = (0, import_react54.useState)([]);
6349
+ const [query, setQuery] = (0, import_react54.useState)("");
6350
+ const [category, setCategory] = (0, import_react54.useState)("");
6351
+ const [use, setUse] = (0, import_react54.useState)("");
6352
+ const [error, setError] = (0, import_react54.useState)(null);
6353
+ (0, import_react54.useEffect)(() => {
6322
6354
  if (!provider) return setAll([]);
6323
6355
  let live = true;
6324
6356
  Promise.resolve().then(() => provider.list()).then(
@@ -6329,8 +6361,8 @@ function EffectsBrowser({ provider, uses, kinds, filter, onPick, thumbnails = tr
6329
6361
  live = false;
6330
6362
  };
6331
6363
  }, [provider]);
6332
- const [found, setFound] = (0, import_react53.useState)([]);
6333
- (0, import_react53.useEffect)(() => {
6364
+ const [found, setFound] = (0, import_react54.useState)([]);
6365
+ (0, import_react54.useEffect)(() => {
6334
6366
  if (!provider) return setFound([]);
6335
6367
  let live = true;
6336
6368
  Promise.resolve().then(() => provider.search(query, { ...category ? { category } : {}, ...use ? { use } : {} })).then((list) => live && setFound(list), () => live && setFound([]));
@@ -6339,7 +6371,7 @@ function EffectsBrowser({ provider, uses, kinds, filter, onPick, thumbnails = tr
6339
6371
  };
6340
6372
  }, [provider, query, category, use]);
6341
6373
  const allowed = (e) => (!kinds || kinds.includes(e.kind)) && (0, import_effects2.effectOffered)(e, uses) && (!filter || filter(e));
6342
- const categories = (0, import_react53.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds, filter]);
6374
+ const categories = (0, import_react54.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds, filter]);
6343
6375
  const shown = found.filter(allowed);
6344
6376
  if (!provider)
6345
6377
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: `rounded-md border border-dashed border-border p-3 text-xs text-muted-foreground ${className}`, "data-effects-browser": "", "data-effects-unavailable": "", children: "No effects provider is registered, so effects cannot be added. Effects already in the document are kept." });
@@ -6387,12 +6419,12 @@ function EffectsBrowser({ provider, uses, kinds, filter, onPick, thumbnails = tr
6387
6419
  }
6388
6420
 
6389
6421
  // src/effects/EffectParameters.tsx
6390
- var import_react59 = __toESM(require("react"), 1);
6422
+ var import_react60 = __toESM(require("react"), 1);
6391
6423
  var import_effects3 = require("@pixerate/editor/effects");
6392
6424
  var import_parameters2 = require("@pixerate/editor/parameters");
6393
6425
 
6394
6426
  // src/parameters/fields.tsx
6395
- var import_react58 = require("react");
6427
+ var import_react59 = require("react");
6396
6428
  var import_parameters = require("@pixerate/editor/parameters");
6397
6429
 
6398
6430
  // src/color/index.ts
@@ -6405,7 +6437,7 @@ __export(color_exports, {
6405
6437
  });
6406
6438
 
6407
6439
  // src/color/ColorPicker.tsx
6408
- var import_react54 = require("react");
6440
+ var import_react55 = require("react");
6409
6441
  var import_color = require("@pixerate/editor/color");
6410
6442
  var import_jsx_runtime33 = require("react/jsx-runtime");
6411
6443
  var LOCAL_STORAGE_KEY = "pixerate:color:recent";
@@ -6445,24 +6477,24 @@ var ColorPicker = ({
6445
6477
  id,
6446
6478
  "aria-label": ariaLabel = "Color picker"
6447
6479
  }) => {
6448
- const generatedId = (0, import_react54.useId)();
6480
+ const generatedId = (0, import_react55.useId)();
6449
6481
  const pickerId = id || generatedId;
6450
- const [pickerState, setPickerState] = (0, import_react54.useState)(
6482
+ const [pickerState, setPickerState] = (0, import_react55.useState)(
6451
6483
  () => (0, import_color.pickerStateFromColor)(value) ?? DEFAULT_PICKER_STATE
6452
6484
  );
6453
- const stateRef = (0, import_react54.useRef)(pickerState);
6485
+ const stateRef = (0, import_react55.useRef)(pickerState);
6454
6486
  stateRef.current = pickerState;
6455
- (0, import_react54.useEffect)(() => {
6487
+ (0, import_react55.useEffect)(() => {
6456
6488
  const next = (0, import_color.pickerStateFromColor)(value, stateRef.current);
6457
6489
  if (next) {
6458
6490
  setPickerState(next);
6459
6491
  }
6460
6492
  }, [value]);
6461
- const [internalRecent, setInternalRecent] = (0, import_react54.useState)(
6493
+ const [internalRecent, setInternalRecent] = (0, import_react55.useState)(
6462
6494
  () => controlledRecent ? [] : readLocalRecents()
6463
6495
  );
6464
6496
  const activeRecent = controlledRecent ?? internalRecent;
6465
- const recordRecent = (0, import_react54.useCallback)(
6497
+ const recordRecent = (0, import_react55.useCallback)(
6466
6498
  (color) => {
6467
6499
  const updated = (0, import_color.pushRecentColor)(activeRecent, color, 12);
6468
6500
  if (!controlledRecent) {
@@ -6473,11 +6505,11 @@ var ColorPicker = ({
6473
6505
  },
6474
6506
  [activeRecent, controlledRecent, onRecentChange]
6475
6507
  );
6476
- const [textDraft, setTextDraft] = (0, import_react54.useState)(value);
6477
- const [isInvalid, setIsInvalid] = (0, import_react54.useState)(false);
6478
- const [isClipped, setIsClipped] = (0, import_react54.useState)(false);
6479
- const isTypingRef = (0, import_react54.useRef)(false);
6480
- (0, import_react54.useEffect)(() => {
6508
+ const [textDraft, setTextDraft] = (0, import_react55.useState)(value);
6509
+ const [isInvalid, setIsInvalid] = (0, import_react55.useState)(false);
6510
+ const [isClipped, setIsClipped] = (0, import_react55.useState)(false);
6511
+ const isTypingRef = (0, import_react55.useRef)(false);
6512
+ (0, import_react55.useEffect)(() => {
6481
6513
  if (!isTypingRef.current) {
6482
6514
  setTextDraft(value);
6483
6515
  setIsInvalid(false);
@@ -6485,11 +6517,11 @@ var ColorPicker = ({
6485
6517
  setIsClipped(Boolean(parsed && !(0, import_color.inSrgbGamut)(parsed)));
6486
6518
  }
6487
6519
  }, [value]);
6488
- const [hasEyeDropper, setHasEyeDropper] = (0, import_react54.useState)(false);
6489
- (0, import_react54.useEffect)(() => {
6520
+ const [hasEyeDropper, setHasEyeDropper] = (0, import_react55.useState)(false);
6521
+ (0, import_react55.useEffect)(() => {
6490
6522
  setHasEyeDropper(typeof window !== "undefined" && "EyeDropper" in window);
6491
6523
  }, []);
6492
- const emitColorChange = (0, import_react54.useCallback)(
6524
+ const emitColorChange = (0, import_react55.useCallback)(
6493
6525
  (nextState) => {
6494
6526
  setPickerState(nextState);
6495
6527
  const hex = (0, import_color.pickerStateToHex)(nextState, alpha);
@@ -6497,10 +6529,10 @@ var ColorPicker = ({
6497
6529
  },
6498
6530
  [alpha, onChange]
6499
6531
  );
6500
- const latest = (0, import_react54.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
6532
+ const latest = (0, import_react55.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
6501
6533
  latest.current = { emitColorChange, recordRecent, onGestureEnd, alpha };
6502
- const endDragRef = (0, import_react54.useRef)(null);
6503
- (0, import_react54.useEffect)(() => () => endDragRef.current?.(), []);
6534
+ const endDragRef = (0, import_react55.useRef)(null);
6535
+ (0, import_react55.useEffect)(() => () => endDragRef.current?.(), []);
6504
6536
  const startDrag = (e, next) => {
6505
6537
  if (disabled) return;
6506
6538
  e.preventDefault();
@@ -6602,7 +6634,7 @@ var ColorPicker = ({
6602
6634
  } catch {
6603
6635
  }
6604
6636
  };
6605
- const contrastResult = (0, import_react54.useMemo)(() => {
6637
+ const contrastResult = (0, import_react55.useMemo)(() => {
6606
6638
  if (!contrastAgainst) return null;
6607
6639
  const fg = (0, import_color.parseColor)(value);
6608
6640
  const bg = (0, import_color.parseColor)(contrastAgainst);
@@ -7029,7 +7061,7 @@ var ColorPicker = ({
7029
7061
  };
7030
7062
 
7031
7063
  // src/color/DualColorPicker.tsx
7032
- var import_react55 = require("react");
7064
+ var import_react56 = require("react");
7033
7065
  var import_color2 = require("@pixerate/editor/color");
7034
7066
  var import_jsx_runtime34 = require("react/jsx-runtime");
7035
7067
  function DualColorPicker({
@@ -7046,8 +7078,8 @@ function DualColorPicker({
7046
7078
  disabled = false,
7047
7079
  className = ""
7048
7080
  }) {
7049
- const sameId = (0, import_react55.useId)();
7050
- const [internalScheme, setInternalScheme] = (0, import_react55.useState)("light");
7081
+ const sameId = (0, import_react56.useId)();
7082
+ const [internalScheme, setInternalScheme] = (0, import_react56.useState)("light");
7051
7083
  const activeScheme = controlledScheme ?? internalScheme;
7052
7084
  const handleSchemeSelect = (nextScheme) => {
7053
7085
  if (onSchemeChange) {
@@ -7058,7 +7090,7 @@ function DualColorPicker({
7058
7090
  };
7059
7091
  const dual = (0, import_color2.normalizeDualColor)(value) ?? { light: "#000000", dark: "#000000" };
7060
7092
  const isSame = dual.light.toLowerCase() === dual.dark.toLowerCase();
7061
- const [sameInBoth, setSameInBoth] = (0, import_react55.useState)(isSame);
7093
+ const [sameInBoth, setSameInBoth] = (0, import_react56.useState)(isSame);
7062
7094
  const handleSameToggle = (e) => {
7063
7095
  const nextSame = e.target.checked;
7064
7096
  setSameInBoth(nextSame);
@@ -7367,7 +7399,7 @@ function DualColorPicker({
7367
7399
  }
7368
7400
 
7369
7401
  // src/color/useColorScheme.ts
7370
- var import_react56 = require("react");
7402
+ var import_react57 = require("react");
7371
7403
  var import_color3 = require("@pixerate/editor/color");
7372
7404
  function getSnapshot(attribute) {
7373
7405
  if (typeof window === "undefined" || typeof document === "undefined") {
@@ -7392,7 +7424,7 @@ function getServerSnapshot() {
7392
7424
  function useColorScheme(options) {
7393
7425
  const override = options?.override;
7394
7426
  const attribute = options?.attribute;
7395
- const subscribe = (0, import_react56.useMemo)(() => {
7427
+ const subscribe = (0, import_react57.useMemo)(() => {
7396
7428
  return (callback) => {
7397
7429
  if (typeof window === "undefined" || typeof document === "undefined") {
7398
7430
  return () => {
@@ -7418,7 +7450,7 @@ function useColorScheme(options) {
7418
7450
  };
7419
7451
  };
7420
7452
  }, [attribute]);
7421
- const detected = (0, import_react56.useSyncExternalStore)(
7453
+ const detected = (0, import_react57.useSyncExternalStore)(
7422
7454
  subscribe,
7423
7455
  () => getSnapshot(attribute),
7424
7456
  getServerSnapshot
@@ -7435,11 +7467,11 @@ function useResolvedColor(value, scheme) {
7435
7467
  __reExport(color_exports, require("@pixerate/editor/color"));
7436
7468
 
7437
7469
  // src/parameters/controls.tsx
7438
- var import_react57 = require("react");
7470
+ var import_react58 = require("react");
7439
7471
  var import_jsx_runtime35 = require("react/jsx-runtime");
7440
- var ParameterComponentsContext = (0, import_react57.createContext)({});
7472
+ var ParameterComponentsContext = (0, import_react58.createContext)({});
7441
7473
  function useParameterComponents() {
7442
- return (0, import_react57.useContext)(ParameterComponentsContext);
7474
+ return (0, import_react58.useContext)(ParameterComponentsContext);
7443
7475
  }
7444
7476
  function resolveParameterComponents(explicit, context) {
7445
7477
  return {
@@ -7460,9 +7492,9 @@ var parameterInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-
7460
7492
  var parameterButtonClass = "inline-flex h-7 items-center justify-center gap-1 rounded-md border border-input bg-background px-2 text-xs text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50";
7461
7493
  var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
7462
7494
  function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
7463
- const inputRef = (0, import_react58.useRef)(null);
7464
- const lastCommitted = (0, import_react58.useRef)(null);
7465
- (0, import_react58.useLayoutEffect)(() => {
7495
+ const inputRef = (0, import_react59.useRef)(null);
7496
+ const lastCommitted = (0, import_react59.useRef)(null);
7497
+ (0, import_react59.useLayoutEffect)(() => {
7466
7498
  lastCommitted.current = null;
7467
7499
  const el = inputRef.current;
7468
7500
  if (el && el.value !== value) el.value = value;
@@ -7473,9 +7505,9 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
7473
7505
  onCommit(text, el);
7474
7506
  lastCommitted.current = el.value === text ? text : null;
7475
7507
  };
7476
- const commitRef = (0, import_react58.useRef)(commit);
7508
+ const commitRef = (0, import_react59.useRef)(commit);
7477
7509
  commitRef.current = commit;
7478
- (0, import_react58.useEffect)(() => {
7510
+ (0, import_react59.useEffect)(() => {
7479
7511
  const el = inputRef.current;
7480
7512
  if (!el) return;
7481
7513
  const change = () => commitRef.current(el);
@@ -7550,7 +7582,7 @@ function ParameterSlider(props) {
7550
7582
  const ctx = useParameterComponents();
7551
7583
  const resolved = resolveParameterComponents(components, ctx);
7552
7584
  const CustomSlider = resolved.slider;
7553
- const dragging = (0, import_react58.useRef)(false);
7585
+ const dragging = (0, import_react59.useRef)(false);
7554
7586
  const start = () => {
7555
7587
  if (dragging.current) return;
7556
7588
  dragging.current = true;
@@ -7682,17 +7714,17 @@ function ParameterSelect(props) {
7682
7714
  }
7683
7715
  function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
7684
7716
  const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
7685
- const [open, setOpen] = (0, import_react58.useState)(false);
7686
- const containerRef = (0, import_react58.useRef)(null);
7687
- const buttonRef = (0, import_react58.useRef)(null);
7688
- const popoverRef = (0, import_react58.useRef)(null);
7717
+ const [open, setOpen] = (0, import_react59.useState)(false);
7718
+ const containerRef = (0, import_react59.useRef)(null);
7719
+ const buttonRef = (0, import_react59.useRef)(null);
7720
+ const popoverRef = (0, import_react59.useRef)(null);
7689
7721
  const alpha = !!field.alpha;
7690
7722
  const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
7691
7723
  const rgb = hex.slice(0, 7);
7692
7724
  const shown = alpha ? hex : rgb;
7693
7725
  const off = disabled || field.readOnly;
7694
7726
  const name = (0, import_parameters.parameterLabel)(field);
7695
- (0, import_react58.useEffect)(() => {
7727
+ (0, import_react59.useEffect)(() => {
7696
7728
  if (!open) return;
7697
7729
  const onPointerDown = (e) => {
7698
7730
  if (containerRef.current && !containerRef.current.contains(e.target)) {
@@ -7939,10 +7971,10 @@ function EffectParameters({
7939
7971
  className = "",
7940
7972
  components
7941
7973
  }) {
7942
- const fields = (0, import_react59.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
7943
- const idBase = (0, import_react59.useId)();
7944
- const gesture = import_react59.default.useRef(null);
7945
- const count = import_react59.default.useRef(0);
7974
+ const fields = (0, import_react60.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
7975
+ const idBase = (0, import_react60.useId)();
7976
+ const gesture = import_react60.default.useRef(null);
7977
+ const count = import_react60.default.useRef(0);
7946
7978
  const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
7947
7979
  const handlePresetSelect = (name) => {
7948
7980
  if (!name) return;
@@ -8094,13 +8126,13 @@ function ImageEffectControls({ provider, effect, name, values, onChange, onPrese
8094
8126
  var import_jsx_runtime40 = require("react/jsx-runtime");
8095
8127
  var fmt = (ms) => `${(ms / 1e3).toFixed(ms < 1e4 ? 2 : 1)} s`;
8096
8128
  function ImageProviderEffectsPanel({ controller, className = "", components }) {
8097
- const [, setTick] = (0, import_react60.useState)(0);
8098
- (0, import_react60.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
8099
- const [browse, setBrowse] = (0, import_react60.useState)(null);
8100
- const [clip, setClip] = (0, import_react60.useState)(false);
8101
- const [message2, setMessage] = (0, import_react60.useState)(null);
8102
- const [open, setOpen] = (0, import_react60.useState)(null);
8103
- const [scrubbed, setScrubbed] = (0, import_react60.useState)(null);
8129
+ const [, setTick] = (0, import_react61.useState)(0);
8130
+ (0, import_react61.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
8131
+ const [browse, setBrowse] = (0, import_react61.useState)(null);
8132
+ const [clip, setClip] = (0, import_react61.useState)(false);
8133
+ const [message2, setMessage] = (0, import_react61.useState)(null);
8134
+ const [open, setOpen] = (0, import_react61.useState)(null);
8135
+ const [scrubbed, setScrubbed] = (0, import_react61.useState)(null);
8104
8136
  const provider = controller.effectsProvider;
8105
8137
  const state = controller.getState();
8106
8138
  const layer = state.activeLayerId ? (0, import_image_editor9.findLayer)(state.layers, state.activeLayerId)?.layer ?? null : null;
@@ -8108,7 +8140,7 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
8108
8140
  setMessage(null);
8109
8141
  Promise.resolve().then(work).catch((e) => setMessage(e instanceof Error ? e.message : String(e)));
8110
8142
  };
8111
- const drags = (0, import_react60.useRef)(/* @__PURE__ */ new Set());
8143
+ const drags = (0, import_react61.useRef)(/* @__PURE__ */ new Set());
8112
8144
  const commit = (gesture) => {
8113
8145
  if (gesture) {
8114
8146
  if (!drags.current.has(gesture)) {
@@ -8124,7 +8156,7 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
8124
8156
  const canFilter = !!provider && !!layer && layer.type !== "adjustment" && layer.type !== "annotation";
8125
8157
  const { description } = useEffectDescription(provider, generator?.effect);
8126
8158
  const timing = generator ? (0, import_image_editor9.effectLayerTiming)(generator, description) : null;
8127
- const scrub = (0, import_react60.useRef)({ next: null, busy: false, gesture: null });
8159
+ const scrub = (0, import_react61.useRef)({ next: null, busy: false, gesture: null });
8128
8160
  const scrubTo = (layerId, time) => {
8129
8161
  const s = scrub.current;
8130
8162
  setScrubbed(time);
@@ -8318,7 +8350,7 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
8318
8350
  }
8319
8351
 
8320
8352
  // src/image-editor/BrushOptionsBar.tsx
8321
- var import_react67 = require("react");
8353
+ var import_react68 = require("react");
8322
8354
  var import_image_editor11 = require("@pixerate/editor/image-editor");
8323
8355
  var import_image_editor12 = require("@pixerate/editor/image-editor");
8324
8356
 
@@ -8326,7 +8358,7 @@ var import_image_editor12 = require("@pixerate/editor/image-editor");
8326
8358
  var import_image_editor10 = require("@pixerate/editor/image-editor");
8327
8359
 
8328
8360
  // src/paint-editor/PaintGradientEditorView.tsx
8329
- var import_react61 = require("react");
8361
+ var import_react62 = require("react");
8330
8362
  var import_jsx_runtime41 = require("react/jsx-runtime");
8331
8363
  var button2 = "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700 disabled:opacity-40";
8332
8364
  var select = "rounded bg-slate-800 px-1 py-0.5 text-[11px]";
@@ -8348,7 +8380,7 @@ var PaintGradientEditorView = ({ value, onChange, colors, className, kit }) => {
8348
8380
  reversePaintGradient,
8349
8381
  updatePaintGradientStop
8350
8382
  } = kit;
8351
- const [selected, setSelected] = (0, import_react61.useState)(0);
8383
+ const [selected, setSelected] = (0, import_react62.useState)(0);
8352
8384
  const sel = Math.min(selected, value.stops.length - 1);
8353
8385
  const stop = value.stops[sel];
8354
8386
  const map = value.map;
@@ -8455,12 +8487,12 @@ var PaintGradientEditor = (props) => /* @__PURE__ */ (0, import_jsx_runtime42.js
8455
8487
  var import_brushes4 = require("@pixerate/editor/brushes");
8456
8488
 
8457
8489
  // src/brushes/BrushLibraryBrowser.tsx
8458
- var import_react62 = require("react");
8490
+ var import_react63 = require("react");
8459
8491
  var import_brushes = require("@pixerate/editor/brushes");
8460
8492
  var import_jsx_runtime43 = require("react/jsx-runtime");
8461
8493
  var Thumbnail2 = ({ image, label, style }) => {
8462
- const ref = (0, import_react62.useRef)(null);
8463
- (0, import_react62.useEffect)(() => {
8494
+ const ref = (0, import_react63.useRef)(null);
8495
+ (0, import_react63.useEffect)(() => {
8464
8496
  const canvas = ref.current;
8465
8497
  const ctx = canvas?.getContext("2d");
8466
8498
  if (!canvas || !ctx || !image || typeof image === "string" || typeof ctx.createImageData !== "function") return;
@@ -8474,8 +8506,8 @@ var Thumbnail2 = ({ image, label, style }) => {
8474
8506
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("canvas", { ref, role: "img", "aria-label": label, className: "rounded", style, width: image?.width, height: image?.height });
8475
8507
  };
8476
8508
  var BrushLibraryBrowser = ({ entries, activeId, onSelect, profile, thumbnail, thumbnailWidth = 112, thumbnailHeight = 32, className }) => {
8477
- const [text, setText] = (0, import_react62.useState)("");
8478
- const groups = (0, import_react62.useMemo)(() => (0, import_brushes.brushLibraryGroups)(entries, { text, profile }), [entries, text, profile]);
8509
+ const [text, setText] = (0, import_react63.useState)("");
8510
+ const groups = (0, import_react63.useMemo)(() => (0, import_brushes.brushLibraryGroups)(entries, { text, profile }), [entries, text, profile]);
8479
8511
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: `flex flex-col gap-1 ${className ?? ""}`, "data-testid": "brush-library", children: [
8480
8512
  /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("input", { type: "search", value: text, placeholder: "Find a brush", "aria-label": "Find a brush", onChange: (e) => setText(e.target.value), className: "rounded bg-slate-800 px-1.5 py-0.5" }),
8481
8513
  /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex flex-col gap-1.5", role: "listbox", "aria-label": "Brushes", children: [
@@ -8508,17 +8540,17 @@ var BrushLibraryBrowser = ({ entries, activeId, onSelect, profile, thumbnail, th
8508
8540
  };
8509
8541
 
8510
8542
  // src/brushes/BrushLibraryEditor.tsx
8511
- var import_react65 = require("react");
8543
+ var import_react66 = require("react");
8512
8544
  var import_brushes3 = require("@pixerate/editor/brushes");
8513
8545
 
8514
8546
  // src/paint-editor/shared.tsx
8515
- var import_react63 = require("react");
8547
+ var import_react64 = require("react");
8516
8548
  var import_jsx_runtime44 = require("react/jsx-runtime");
8517
8549
  var chip = (on) => `px-2 py-1 rounded text-[11px] ${on ? "bg-indigo-600 text-white" : "bg-slate-800 text-slate-300 hover:text-white"}`;
8518
8550
  var button3 = "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700 disabled:opacity-40";
8519
8551
  var PixelCanvas = ({ pixels, label, className, style }) => {
8520
- const ref = (0, import_react63.useRef)(null);
8521
- (0, import_react63.useEffect)(() => {
8552
+ const ref = (0, import_react64.useRef)(null);
8553
+ (0, import_react64.useEffect)(() => {
8522
8554
  const canvas = ref.current;
8523
8555
  const ctx = canvas?.getContext("2d");
8524
8556
  if (!canvas || !ctx || !pixels || typeof ctx.createImageData !== "function") return;
@@ -8532,11 +8564,11 @@ var PixelCanvas = ({ pixels, label, className, style }) => {
8532
8564
  };
8533
8565
  var fmt2 = (c, v) => c.step >= 1 ? String(Math.round(v)) : v.toFixed(2);
8534
8566
  var PaintSlider = ({ control, value, onChange, onCommit }) => {
8535
- const [draft, setDraft] = (0, import_react63.useState)(null);
8536
- const ref = (0, import_react63.useRef)(null);
8537
- const commit = (0, import_react63.useRef)(onCommit);
8567
+ const [draft, setDraft] = (0, import_react64.useState)(null);
8568
+ const ref = (0, import_react64.useRef)(null);
8569
+ const commit = (0, import_react64.useRef)(onCommit);
8538
8570
  commit.current = onCommit;
8539
- (0, import_react63.useEffect)(() => {
8571
+ (0, import_react64.useEffect)(() => {
8540
8572
  const el = ref.current;
8541
8573
  if (!el) return;
8542
8574
  const done = () => {
@@ -8575,14 +8607,14 @@ var PaintSlider = ({ control, value, onChange, onCommit }) => {
8575
8607
  var ErrorLine = ({ error }) => error ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("p", { role: "alert", className: "text-[11px] text-rose-400", children: error }) : null;
8576
8608
 
8577
8609
  // src/brushes/BrushEditor.tsx
8578
- var import_react64 = __toESM(require("react"), 1);
8610
+ var import_react65 = __toESM(require("react"), 1);
8579
8611
  var import_brushes2 = require("@pixerate/editor/brushes");
8580
8612
  var import_jsx_runtime45 = require("react/jsx-runtime");
8581
8613
  var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, sources, onAddSource, className }) => {
8582
- const sections = (0, import_react64.useMemo)(() => (0, import_brushes2.brushEditorSections)(brush, profile, { sources }), [brush, profile, sources]);
8583
- const scope = (0, import_react64.useMemo)(() => (0, import_brushes2.brushEditorScope)(brush, profile), [brush, profile]);
8584
- const [problems, setProblems] = (0, import_react64.useState)(null);
8585
- const [name, setName] = (0, import_react64.useState)("");
8614
+ const sections = (0, import_react65.useMemo)(() => (0, import_brushes2.brushEditorSections)(brush, profile, { sources }), [brush, profile, sources]);
8615
+ const scope = (0, import_react65.useMemo)(() => (0, import_brushes2.brushEditorScope)(brush, profile), [brush, profile]);
8616
+ const [problems, setProblems] = (0, import_react65.useState)(null);
8617
+ const [name, setName] = (0, import_react65.useState)("");
8586
8618
  const save = async (fn, after) => {
8587
8619
  try {
8588
8620
  await fn();
@@ -8611,7 +8643,7 @@ var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, p
8611
8643
  scope.note && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "text-[10px] text-amber-400", "data-testid": "brush-editor-scope", title: `${profile.name} shows only what it can use; these are kept unchanged when you save.`, children: scope.note }),
8612
8644
  sections.map((s) => /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("section", { className: "flex flex-col gap-1.5", "data-section": s.id, ...s.id === "behaviour" ? { "data-testid": "brush-engine" } : {}, children: [
8613
8645
  /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "font-medium text-slate-300", children: s.title }),
8614
- s.controls.map((c) => /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_react64.default.Fragment, { children: [
8646
+ s.controls.map((c) => /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_react65.default.Fragment, { children: [
8615
8647
  /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(EditorControl, { control: c, onSet: set }),
8616
8648
  c.hint && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "text-[10px] leading-snug text-slate-400", "data-hint": c.path, children: c.hint }),
8617
8649
  addSource && (c.path === "tip.stamps" || c.path === "tip.grain.source") && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(AddImage, { label: c.path === "tip.stamps" ? "Add image tip\u2026" : "Add grain image\u2026", onFile: (f) => addSource(f, c.path === "tip.stamps" ? "tip" : "grain") })
@@ -8717,13 +8749,13 @@ var EditorControl = ({ control: c, onSet }) => {
8717
8749
  // src/brushes/BrushLibraryEditor.tsx
8718
8750
  var import_jsx_runtime46 = require("react/jsx-runtime");
8719
8751
  var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPaper = "#ffffff", previewColor, onSaved, onClose, className }) => {
8720
- const [original, setOriginal] = (0, import_react65.useState)(null);
8721
- const [builtin, setBuiltin] = (0, import_react65.useState)(false);
8722
- const [draft, setDraft] = (0, import_react65.useState)(null);
8723
- const [status, setStatus] = (0, import_react65.useState)(null);
8724
- const [preview, setPreview] = (0, import_react65.useState)(null);
8725
- const [sources, setSources] = (0, import_react65.useState)([]);
8726
- (0, import_react65.useEffect)(() => {
8752
+ const [original, setOriginal] = (0, import_react66.useState)(null);
8753
+ const [builtin, setBuiltin] = (0, import_react66.useState)(false);
8754
+ const [draft, setDraft] = (0, import_react66.useState)(null);
8755
+ const [status, setStatus] = (0, import_react66.useState)(null);
8756
+ const [preview, setPreview] = (0, import_react66.useState)(null);
8757
+ const [sources, setSources] = (0, import_react66.useState)([]);
8758
+ (0, import_react66.useEffect)(() => {
8727
8759
  let live = true;
8728
8760
  const read = () => void library.listSources().then((list) => live && setSources(list), () => void 0);
8729
8761
  read();
@@ -8733,7 +8765,7 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPap
8733
8765
  off();
8734
8766
  };
8735
8767
  }, [library]);
8736
- (0, import_react65.useEffect)(() => {
8768
+ (0, import_react66.useEffect)(() => {
8737
8769
  let live = true;
8738
8770
  setStatus(null);
8739
8771
  void (async () => {
@@ -8748,9 +8780,9 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPap
8748
8780
  };
8749
8781
  }, [library, brushId, profile]);
8750
8782
  const paper = renderPreview?.paper ?? previewPaper;
8751
- const colours = (0, import_react65.useMemo)(() => draft ? (0, import_brushes3.brushPreviewColours)(draft, { paper, profile }) : null, [draft, paper, profile]);
8783
+ const colours = (0, import_react66.useMemo)(() => draft ? (0, import_brushes3.brushPreviewColours)(draft, { paper, profile }) : null, [draft, paper, profile]);
8752
8784
  const colour = previewColor ?? colours?.color ?? "#475569";
8753
- (0, import_react65.useEffect)(() => {
8785
+ (0, import_react66.useEffect)(() => {
8754
8786
  if (!draft || !renderPreview) return;
8755
8787
  let live = true;
8756
8788
  Promise.resolve(renderPreview(draft, { width: 240, height: 60, color: colour.slice(0, 7) })).then((img) => live && setPreview(img.data ? `data:${img.mimeType};base64,${img.data}` : null)).catch(() => live && setPreview(null));
@@ -8758,7 +8790,7 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPap
8758
8790
  live = false;
8759
8791
  };
8760
8792
  }, [draft, renderPreview, colour]);
8761
- const check = (0, import_react65.useMemo)(() => draft ? (0, import_brushes3.checkBrushEdit)(original, draft, profile) : null, [original, draft, profile]);
8793
+ const check = (0, import_react66.useMemo)(() => draft ? (0, import_brushes3.checkBrushEdit)(original, draft, profile) : null, [original, draft, profile]);
8762
8794
  if (!draft) return null;
8763
8795
  const save = async (name) => {
8764
8796
  const saved = await (0, import_brushes3.saveBrushEdit)(library, { original, brush: draft, profile, ...name !== void 0 ? { name } : {} });
@@ -8819,12 +8851,12 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPap
8819
8851
  };
8820
8852
 
8821
8853
  // src/brushes/useBrushLibrary.ts
8822
- var import_react66 = require("react");
8854
+ var import_react67 = require("react");
8823
8855
  function useBrushLibrary(library, filter = {}) {
8824
- const [entries, setEntries] = (0, import_react66.useState)([]);
8856
+ const [entries, setEntries] = (0, import_react67.useState)([]);
8825
8857
  const { profile, ...rest } = filter;
8826
8858
  const key = `${profile?.id ?? ""}:${JSON.stringify(rest)}`;
8827
- (0, import_react66.useEffect)(() => {
8859
+ (0, import_react67.useEffect)(() => {
8828
8860
  if (!library) return;
8829
8861
  let live = true;
8830
8862
  const read = () => void library.list(filter).then((list) => live && setEntries(list), () => void 0);
@@ -8841,14 +8873,14 @@ function useBrushLibrary(library, filter = {}) {
8841
8873
  // src/image-editor/BrushOptionsBar.tsx
8842
8874
  var import_jsx_runtime47 = require("react/jsx-runtime");
8843
8875
  var BrushOptionsBar = ({ controller, showTools = true, renderBrushPreview, className }) => {
8844
- const [, setTick] = (0, import_react67.useState)(0);
8845
- (0, import_react67.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
8846
- const [error, setError] = (0, import_react67.useState)(null);
8876
+ const [, setTick] = (0, import_react68.useState)(0);
8877
+ (0, import_react68.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
8878
+ const [error, setError] = (0, import_react68.useState)(null);
8847
8879
  const state = controller.getState();
8848
8880
  const { brush, foreground, background, mixer, mixerLoad, retouch, cloneSource, paint } = state.paint;
8849
8881
  const tool = state.activeTool;
8850
- const [presetsOpen, setPresetsOpen] = (0, import_react67.useState)(false);
8851
- const [editing, setEditing] = (0, import_react67.useState)(false);
8882
+ const [presetsOpen, setPresetsOpen] = (0, import_react68.useState)(false);
8883
+ const [editing, setEditing] = (0, import_react68.useState)(false);
8852
8884
  const presets = useBrushLibrary(presetsOpen ? controller.brushLibrary : null, { profile: import_brushes4.IMAGE_PROFILE });
8853
8885
  const presetName = presets.find((e) => e.brush.id === state.paint.brushPreset)?.brush.name ?? state.paint.brushPreset;
8854
8886
  const attempt = (fn) => {
@@ -9032,18 +9064,18 @@ var BrushOptionsBar = ({ controller, showTools = true, renderBrushPreview, class
9032
9064
  };
9033
9065
 
9034
9066
  // src/image-editor/ColorProfilePanel.tsx
9035
- var import_react68 = require("react");
9067
+ var import_react69 = require("react");
9036
9068
  var import_image_editor13 = require("@pixerate/editor/image-editor");
9037
9069
  var import_jsx_runtime48 = require("react/jsx-runtime");
9038
9070
  var chip2 = imageChipClass(false);
9039
9071
  var select2 = "rounded bg-muted px-1 py-0.5 text-[11px] text-foreground";
9040
9072
  var ColorProfilePanel = ({ controller, className }) => {
9041
- const [, setTick] = (0, import_react68.useState)(0);
9042
- (0, import_react68.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
9043
- const [target, setTarget] = (0, import_react68.useState)("display-p3");
9044
- const [intent, setIntent] = (0, import_react68.useState)("relative");
9045
- const [bpc, setBpc] = (0, import_react68.useState)(true);
9046
- const [error, setError] = (0, import_react68.useState)(null);
9073
+ const [, setTick] = (0, import_react69.useState)(0);
9074
+ (0, import_react69.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
9075
+ const [target, setTarget] = (0, import_react69.useState)("display-p3");
9076
+ const [intent, setIntent] = (0, import_react69.useState)("relative");
9077
+ const [bpc, setBpc] = (0, import_react69.useState)(true);
9078
+ const [error, setError] = (0, import_react69.useState)(null);
9047
9079
  const view = (0, import_image_editor13.colorPanelView)(controller);
9048
9080
  const attempt = (fn) => {
9049
9081
  try {
@@ -9117,16 +9149,16 @@ var ColorProfilePanel = ({ controller, className }) => {
9117
9149
  };
9118
9150
 
9119
9151
  // src/image-editor/SelectionOptionsBar.tsx
9120
- var import_react72 = require("react");
9152
+ var import_react73 = require("react");
9121
9153
 
9122
9154
  // src/image-editor/SelectionRecipePanel.tsx
9123
- var import_react69 = require("react");
9155
+ var import_react70 = require("react");
9124
9156
  var import_image_editor14 = require("@pixerate/editor/image-editor");
9125
9157
  var import_jsx_runtime49 = require("react/jsx-runtime");
9126
9158
  var MODES2 = ["replace", "add", "subtract", "intersect"];
9127
9159
  var button4 = "px-1.5 py-0.5 rounded border border-border bg-background text-[11px] text-foreground hover:bg-accent hover:text-accent-foreground disabled:opacity-40";
9128
9160
  var SelectionRecipePanel = ({ controller, className = "" }) => {
9129
- const [error, setError] = (0, import_react69.useState)(null);
9161
+ const [error, setError] = (0, import_react70.useState)(null);
9130
9162
  const recipe = controller.getSelectionRecipe();
9131
9163
  if (!recipe.live) return null;
9132
9164
  const run = (p) => {
@@ -9180,30 +9212,30 @@ var SelectionRecipePanel = ({ controller, className = "" }) => {
9180
9212
  var import_image_editor17 = require("@pixerate/editor/image-editor");
9181
9213
 
9182
9214
  // src/image-editor/SelectAndMaskWorkspace.tsx
9183
- var import_react70 = require("react");
9215
+ var import_react71 = require("react");
9184
9216
  var import_image_editor15 = require("@pixerate/editor/image-editor");
9185
9217
  var import_jsx_runtime50 = require("react/jsx-runtime");
9186
9218
  var button5 = "px-2 py-1 rounded-md border border-border bg-background text-[11px] text-foreground hover:bg-accent hover:text-accent-foreground disabled:opacity-40";
9187
9219
  var toggle = (on) => `${button5} ${on ? "bg-primary text-primary-foreground border-primary" : ""}`;
9188
9220
  var SelectAndMaskWorkspace = ({ controller, onClose, className = "" }) => {
9189
- const session = (0, import_react70.useMemo)(() => new import_image_editor15.SelectAndMaskSession(controller), [controller]);
9190
- const [, setRevision] = (0, import_react70.useState)(0);
9191
- const [zoom, setZoom] = (0, import_react70.useState)(1);
9192
- const [pan, setPan] = (0, import_react70.useState)({ x: 0, y: 0 });
9193
- const [busy, setBusy] = (0, import_react70.useState)(false);
9194
- const [error, setError] = (0, import_react70.useState)(null);
9195
- const canvasRef = (0, import_react70.useRef)(null);
9196
- const panFrom = (0, import_react70.useRef)(null);
9221
+ const session = (0, import_react71.useMemo)(() => new import_image_editor15.SelectAndMaskSession(controller), [controller]);
9222
+ const [, setRevision] = (0, import_react71.useState)(0);
9223
+ const [zoom, setZoom] = (0, import_react71.useState)(1);
9224
+ const [pan, setPan] = (0, import_react71.useState)({ x: 0, y: 0 });
9225
+ const [busy, setBusy] = (0, import_react71.useState)(false);
9226
+ const [error, setError] = (0, import_react71.useState)(null);
9227
+ const canvasRef = (0, import_react71.useRef)(null);
9228
+ const panFrom = (0, import_react71.useRef)(null);
9197
9229
  const settings = session.settings;
9198
9230
  const size = session.previewSize;
9199
- (0, import_react70.useEffect)(() => {
9231
+ (0, import_react71.useEffect)(() => {
9200
9232
  const off = session.subscribe(() => setRevision(session.revision));
9201
9233
  void session.open();
9202
9234
  return () => {
9203
9235
  off();
9204
9236
  };
9205
9237
  }, [session]);
9206
- (0, import_react70.useEffect)(() => {
9238
+ (0, import_react71.useEffect)(() => {
9207
9239
  const canvas = canvasRef.current;
9208
9240
  const ctx = canvas?.getContext?.("2d");
9209
9241
  if (!canvas || !ctx || !size.width || typeof ImageData === "undefined") return;
@@ -9222,7 +9254,7 @@ var SelectAndMaskWorkspace = ({ controller, onClose, className = "" }) => {
9222
9254
  setBusy(false);
9223
9255
  }
9224
9256
  };
9225
- (0, import_react70.useEffect)(() => {
9257
+ (0, import_react71.useEffect)(() => {
9226
9258
  const onKey = (e) => {
9227
9259
  const t = e.target;
9228
9260
  if (t && (t.tagName === "INPUT" || t.tagName === "SELECT" || t.tagName === "TEXTAREA")) return;
@@ -9441,31 +9473,31 @@ var SelectAndMaskWorkspace = ({ controller, onClose, className = "" }) => {
9441
9473
  };
9442
9474
 
9443
9475
  // src/image-editor/ContentAwareFillWorkspace.tsx
9444
- var import_react71 = require("react");
9476
+ var import_react72 = require("react");
9445
9477
  var import_image_editor16 = require("@pixerate/editor/image-editor");
9446
9478
  var import_jsx_runtime51 = require("react/jsx-runtime");
9447
9479
  var button6 = "px-2 py-1 rounded-md border border-border bg-background text-[11px] text-foreground hover:bg-accent hover:text-accent-foreground disabled:opacity-40";
9448
9480
  var toggle2 = (on) => `${button6} ${on ? "bg-primary text-primary-foreground border-primary" : ""}`;
9449
9481
  var ContentAwareFillWorkspace = ({ controller, onClose, className = "" }) => {
9450
- const session = (0, import_react71.useMemo)(() => new import_image_editor16.ContentAwareFillSession(controller), [controller]);
9451
- const [, setRevision] = (0, import_react71.useState)(0);
9452
- const [zoom, setZoom] = (0, import_react71.useState)(1);
9453
- const [pan, setPan] = (0, import_react71.useState)({ x: 0, y: 0 });
9454
- const [busy, setBusy] = (0, import_react71.useState)(false);
9455
- const [error, setError] = (0, import_react71.useState)(null);
9456
- const sourceRef = (0, import_react71.useRef)(null);
9457
- const previewRef = (0, import_react71.useRef)(null);
9458
- const panFrom = (0, import_react71.useRef)(null);
9482
+ const session = (0, import_react72.useMemo)(() => new import_image_editor16.ContentAwareFillSession(controller), [controller]);
9483
+ const [, setRevision] = (0, import_react72.useState)(0);
9484
+ const [zoom, setZoom] = (0, import_react72.useState)(1);
9485
+ const [pan, setPan] = (0, import_react72.useState)({ x: 0, y: 0 });
9486
+ const [busy, setBusy] = (0, import_react72.useState)(false);
9487
+ const [error, setError] = (0, import_react72.useState)(null);
9488
+ const sourceRef = (0, import_react72.useRef)(null);
9489
+ const previewRef = (0, import_react72.useRef)(null);
9490
+ const panFrom = (0, import_react72.useRef)(null);
9459
9491
  const settings = session.settings;
9460
9492
  const win = session.window;
9461
- (0, import_react71.useEffect)(() => {
9493
+ (0, import_react72.useEffect)(() => {
9462
9494
  const off = session.subscribe(() => setRevision(session.revision));
9463
9495
  void session.open();
9464
9496
  return () => {
9465
9497
  off();
9466
9498
  };
9467
9499
  }, [session]);
9468
- (0, import_react71.useEffect)(() => {
9500
+ (0, import_react72.useEffect)(() => {
9469
9501
  if (!win || typeof ImageData === "undefined") return;
9470
9502
  for (const [canvas, rgba] of [
9471
9503
  [sourceRef.current, session.renderSource()],
@@ -9489,7 +9521,7 @@ var ContentAwareFillWorkspace = ({ controller, onClose, className = "" }) => {
9489
9521
  setBusy(false);
9490
9522
  }
9491
9523
  };
9492
- (0, import_react71.useEffect)(() => {
9524
+ (0, import_react72.useEffect)(() => {
9493
9525
  const onKey = (e) => {
9494
9526
  const t = e.target;
9495
9527
  if (t && (t.tagName === "INPUT" || t.tagName === "SELECT" || t.tagName === "TEXTAREA")) return;
@@ -9675,15 +9707,15 @@ var SelectionOptionsBar = ({
9675
9707
  showTools = true,
9676
9708
  className = ""
9677
9709
  }) => {
9678
- const [radius, setRadius] = (0, import_react72.useState)(2);
9710
+ const [radius, setRadius] = (0, import_react73.useState)(2);
9679
9711
  const set = (patch) => onOptionsChange({ ...options, ...patch });
9680
9712
  const sel = selection === void 0 ? controller.getSelection() : selection;
9681
9713
  const display = selectionDisplay ?? (quickMask === void 0 ? controller.getSelectionDisplay() : quickMask ? "quickMask" : "ants");
9682
- const [preset, setPreset] = (0, import_react72.useState)("reds");
9683
- const [rangeStatus, setRangeStatus] = (0, import_react72.useState)(null);
9684
- const [colorStatus, setColorStatus] = (0, import_react72.useState)(null);
9685
- const [strokeWidth, setStrokeWidth] = (0, import_react72.useState)(4);
9686
- const [strokeLocation, setStrokeLocation] = (0, import_react72.useState)("outside");
9714
+ const [preset, setPreset] = (0, import_react73.useState)("reds");
9715
+ const [rangeStatus, setRangeStatus] = (0, import_react73.useState)(null);
9716
+ const [colorStatus, setColorStatus] = (0, import_react73.useState)(null);
9717
+ const [strokeWidth, setStrokeWidth] = (0, import_react73.useState)(4);
9718
+ const [strokeLocation, setStrokeLocation] = (0, import_react73.useState)("outside");
9687
9719
  const edit = (fn) => {
9688
9720
  setColorStatus(null);
9689
9721
  try {
@@ -9716,8 +9748,8 @@ var SelectionOptionsBar = ({
9716
9748
  setRangeStatus(err instanceof Error ? err.message : String(err));
9717
9749
  }
9718
9750
  };
9719
- const [task, setTask] = (0, import_react72.useState)(null);
9720
- const taskAbort = (0, import_react72.useRef)(null);
9751
+ const [task, setTask] = (0, import_react73.useState)(null);
9752
+ const taskAbort = (0, import_react73.useRef)(null);
9721
9753
  const tracked = () => {
9722
9754
  const abort = new AbortController();
9723
9755
  taskAbort.current = abort;
@@ -9729,9 +9761,9 @@ var SelectionOptionsBar = ({
9729
9761
  setTask(null);
9730
9762
  };
9731
9763
  const failure = (err) => err?.name === "AbortError" ? "Cancelled." : err instanceof Error ? err.message : String(err);
9732
- const [subject, setSubject] = (0, import_react72.useState)("");
9733
- const [segmenting, setSegmenting] = (0, import_react72.useState)(false);
9734
- const [subjectStatus, setSubjectStatus] = (0, import_react72.useState)(null);
9764
+ const [subject, setSubject] = (0, import_react73.useState)("");
9765
+ const [segmenting, setSegmenting] = (0, import_react73.useState)(false);
9766
+ const [subjectStatus, setSubjectStatus] = (0, import_react73.useState)(null);
9735
9767
  const selectSubject = async () => {
9736
9768
  const target = subject.trim();
9737
9769
  const canSegment = Boolean(controller.segmentationProvider);
@@ -9748,10 +9780,10 @@ var SelectionOptionsBar = ({
9748
9780
  setSegmenting(false);
9749
9781
  }
9750
9782
  };
9751
- const [workspace, setWorkspace] = (0, import_react72.useState)(false);
9752
- const [fillWorkspace, setFillWorkspace] = (0, import_react72.useState)(false);
9753
- const [skying, setSkying] = (0, import_react72.useState)(false);
9754
- const [skyStatus, setSkyStatus] = (0, import_react72.useState)(null);
9783
+ const [workspace, setWorkspace] = (0, import_react73.useState)(false);
9784
+ const [fillWorkspace, setFillWorkspace] = (0, import_react73.useState)(false);
9785
+ const [skying, setSkying] = (0, import_react73.useState)(false);
9786
+ const [skyStatus, setSkyStatus] = (0, import_react73.useState)(null);
9755
9787
  const selectSky = async () => {
9756
9788
  if (skying) return;
9757
9789
  setSkying(true);
@@ -9766,8 +9798,8 @@ var SelectionOptionsBar = ({
9766
9798
  setSkying(false);
9767
9799
  }
9768
9800
  };
9769
- const [focusing, setFocusing] = (0, import_react72.useState)(false);
9770
- const [focusStatus, setFocusStatus] = (0, import_react72.useState)(null);
9801
+ const [focusing, setFocusing] = (0, import_react73.useState)(false);
9802
+ const [focusStatus, setFocusStatus] = (0, import_react73.useState)(null);
9771
9803
  const selectFocusArea = async () => {
9772
9804
  if (focusing) return;
9773
9805
  setFocusing(true);
@@ -10189,18 +10221,18 @@ var SelectionOptionsBar = ({
10189
10221
  };
10190
10222
 
10191
10223
  // src/image-editor/RefineEdgePanel.tsx
10192
- var import_react76 = require("react");
10224
+ var import_react77 = require("react");
10193
10225
  var import_image_editor19 = require("@pixerate/editor/image-editor");
10194
10226
 
10195
10227
  // src/image-editor/MaskEdgeCheck.tsx
10196
- var import_react73 = __toESM(require("react"), 1);
10228
+ var import_react74 = __toESM(require("react"), 1);
10197
10229
  var import_image_editor18 = require("@pixerate/editor/image-editor");
10198
10230
  var import_jsx_runtime53 = require("react/jsx-runtime");
10199
10231
  var button7 = "px-2 py-1 rounded-md border border-border bg-background text-[11px] text-foreground hover:bg-accent hover:text-accent-foreground disabled:opacity-40";
10200
10232
  var MaskEdgeCheck = ({ controller, selection, target = "selection", layerId, className = "" }) => {
10201
10233
  const sel = selection === void 0 ? controller.getSelection() : selection;
10202
- const [result, setResult] = (0, import_react73.useState)(null);
10203
- const [error, setError] = (0, import_react73.useState)(null);
10234
+ const [result, setResult] = (0, import_react74.useState)(null);
10235
+ const [error, setError] = (0, import_react74.useState)(null);
10204
10236
  const report = result && (target !== "selection" || result.for === sel) ? result.report : null;
10205
10237
  const check = () => {
10206
10238
  setError(null);
@@ -10222,7 +10254,7 @@ var MaskEdgeCheck = ({ controller, selection, target = "selection", layerId, cla
10222
10254
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("button", { type: "button", className: `${button7} self-start`, disabled: target === "selection" && !sel, onClick: check, children: "Check Edge" }),
10223
10255
  report && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
10224
10256
  /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("dl", { className: "grid grid-cols-[1fr_auto] gap-x-2 gap-y-0.5", children: [
10225
- rows.map((r) => /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_react73.default.Fragment, { children: [
10257
+ rows.map((r) => /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_react74.default.Fragment, { children: [
10226
10258
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("dt", { className: "text-muted-foreground", children: r.label }),
10227
10259
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("dd", { className: `font-mono text-right ${r.bad ? "text-destructive" : "text-foreground"}`, children: r.value })
10228
10260
  ] }, r.label)),
@@ -10240,13 +10272,13 @@ var MaskEdgeCheck = ({ controller, selection, target = "selection", layerId, cla
10240
10272
  };
10241
10273
 
10242
10274
  // src/image-editor/SelectionChangeCheck.tsx
10243
- var import_react74 = require("react");
10275
+ var import_react75 = require("react");
10244
10276
  var import_jsx_runtime54 = require("react/jsx-runtime");
10245
10277
  var button8 = "px-2 py-1 rounded-md border border-border bg-background text-[11px] text-foreground hover:bg-accent hover:text-accent-foreground disabled:opacity-40";
10246
10278
  var SelectionChangeCheck = ({ controller, selection, className = "" }) => {
10247
10279
  const sel = selection === void 0 ? controller.getSelection() : selection;
10248
- const [result, setResult] = (0, import_react74.useState)(null);
10249
- const [error, setError] = (0, import_react74.useState)(null);
10280
+ const [result, setResult] = (0, import_react75.useState)(null);
10281
+ const [error, setError] = (0, import_react75.useState)(null);
10250
10282
  const diff = result && result.for === sel ? result.diff : null;
10251
10283
  const show = () => {
10252
10284
  setError(null);
@@ -10280,16 +10312,16 @@ var SelectionChangeCheck = ({ controller, selection, className = "" }) => {
10280
10312
  };
10281
10313
 
10282
10314
  // src/image-editor/SeparateSubjectPanel.tsx
10283
- var import_react75 = require("react");
10315
+ var import_react76 = require("react");
10284
10316
  var import_jsx_runtime55 = require("react/jsx-runtime");
10285
10317
  var button9 = "px-2 py-1 rounded-md border border-border bg-background text-[11px] text-foreground hover:bg-accent hover:text-accent-foreground disabled:opacity-40";
10286
10318
  var SeparateSubjectPanel = ({ controller, selection, className = "" }) => {
10287
10319
  const sel = selection === void 0 ? controller.getSelection() : selection;
10288
- const [dilate, setDilate] = (0, import_react75.useState)(8);
10289
- const [fill, setFill] = (0, import_react75.useState)(true);
10290
- const [progress, setProgress] = (0, import_react75.useState)(null);
10291
- const [error, setError] = (0, import_react75.useState)(null);
10292
- const abort = (0, import_react75.useRef)(null);
10320
+ const [dilate, setDilate] = (0, import_react76.useState)(8);
10321
+ const [fill, setFill] = (0, import_react76.useState)(true);
10322
+ const [progress, setProgress] = (0, import_react76.useState)(null);
10323
+ const [error, setError] = (0, import_react76.useState)(null);
10324
+ const abort = (0, import_react76.useRef)(null);
10293
10325
  const run = async () => {
10294
10326
  setError(null);
10295
10327
  abort.current = new AbortController();
@@ -10347,15 +10379,15 @@ var import_jsx_runtime56 = require("react/jsx-runtime");
10347
10379
  var DEFAULT_PARAMS = { radius: 8, smartRadius: false, smooth: 0, feather: 0, contrast: 0, shiftEdge: 0 };
10348
10380
  var button10 = "px-2 py-1 rounded-md border border-border bg-background text-[11px] text-foreground hover:bg-accent hover:text-accent-foreground disabled:opacity-40";
10349
10381
  var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
10350
- const [params, setParams] = (0, import_react76.useState)(DEFAULT_PARAMS);
10351
- const [busy, setBusy] = (0, import_react76.useState)(false);
10352
- const [error, setError] = (0, import_react76.useState)(null);
10353
- const [layerId, setLayerId] = (0, import_react76.useState)("");
10354
- const [newKind, setNewKind] = (0, import_react76.useState)("hueSaturation");
10355
- const [output, setOutput] = (0, import_react76.useState)("selection");
10356
- const [decontaminate, setDecontaminate] = (0, import_react76.useState)(0);
10357
- const [objectAware, setObjectAware] = (0, import_react76.useState)(false);
10358
- const [onlyUncertain, setOnlyUncertain] = (0, import_react76.useState)(false);
10382
+ const [params, setParams] = (0, import_react77.useState)(DEFAULT_PARAMS);
10383
+ const [busy, setBusy] = (0, import_react77.useState)(false);
10384
+ const [error, setError] = (0, import_react77.useState)(null);
10385
+ const [layerId, setLayerId] = (0, import_react77.useState)("");
10386
+ const [newKind, setNewKind] = (0, import_react77.useState)("hueSaturation");
10387
+ const [output, setOutput] = (0, import_react77.useState)("selection");
10388
+ const [decontaminate, setDecontaminate] = (0, import_react77.useState)(0);
10389
+ const [objectAware, setObjectAware] = (0, import_react77.useState)(false);
10390
+ const [onlyUncertain, setOnlyUncertain] = (0, import_react77.useState)(false);
10359
10391
  const canObject = Boolean(controller.segmentationProvider);
10360
10392
  const toLayer = output !== "selection" && output !== "layer-mask";
10361
10393
  const sel = selection === void 0 ? controller.getSelection() : selection;
@@ -10554,13 +10586,13 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
10554
10586
  };
10555
10587
 
10556
10588
  // src/image-editor/ChannelsPanel.tsx
10557
- var import_react77 = require("react");
10589
+ var import_react78 = require("react");
10558
10590
  var import_image_editor20 = require("@pixerate/editor/image-editor");
10559
10591
  var import_jsx_runtime57 = require("react/jsx-runtime");
10560
10592
  var btn2 = (on = false) => `px-2 py-1 rounded-md border text-[11px] transition-colors disabled:opacity-40 ${on ? "bg-primary border-primary text-primary-foreground" : "bg-background border-border text-foreground hover:bg-accent hover:text-accent-foreground"}`;
10561
10593
  var ChannelThumb = ({ channel, size }) => {
10562
- const ref = (0, import_react77.useRef)(null);
10563
- (0, import_react77.useEffect)(() => {
10594
+ const ref = (0, import_react78.useRef)(null);
10595
+ (0, import_react78.useEffect)(() => {
10564
10596
  const canvas = ref.current;
10565
10597
  const ctx = canvas?.getContext("2d");
10566
10598
  if (!canvas || !ctx || typeof ctx.createImageData !== "function") return;
@@ -10574,12 +10606,12 @@ var ChannelThumb = ({ channel, size }) => {
10574
10606
  return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("canvas", { ref, "aria-hidden": "true", style: { width: size, height: size }, className: "shrink-0 rounded object-contain ring-1 ring-border bg-black" });
10575
10607
  };
10576
10608
  var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
10577
- const [, setTick] = (0, import_react77.useState)(0);
10578
- (0, import_react77.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
10579
- const [activeId, setActiveId] = (0, import_react77.useState)(null);
10580
- const [renaming, setRenaming] = (0, import_react77.useState)(null);
10581
- const [error, setError] = (0, import_react77.useState)(null);
10582
- const fileInput = (0, import_react77.useRef)(null);
10609
+ const [, setTick] = (0, import_react78.useState)(0);
10610
+ (0, import_react78.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
10611
+ const [activeId, setActiveId] = (0, import_react78.useState)(null);
10612
+ const [renaming, setRenaming] = (0, import_react78.useState)(null);
10613
+ const [error, setError] = (0, import_react78.useState)(null);
10614
+ const fileInput = (0, import_react78.useRef)(null);
10583
10615
  const channels = controller.getChannels();
10584
10616
  const active = channels.find((c) => c.id === activeId) ?? null;
10585
10617
  const hasSelection = Boolean(controller.getSelection());
@@ -10705,17 +10737,17 @@ var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
10705
10737
  };
10706
10738
 
10707
10739
  // src/image-editor/PathsPanel.tsx
10708
- var import_react78 = require("react");
10740
+ var import_react79 = require("react");
10709
10741
  var import_image_editor21 = require("@pixerate/editor/image-editor");
10710
10742
  var import_jsx_runtime58 = require("react/jsx-runtime");
10711
10743
  var btn3 = (on = false) => `px-2 py-1 rounded-md border text-[11px] transition-colors disabled:opacity-40 ${on ? "bg-primary border-primary text-primary-foreground" : "bg-background border-border text-foreground hover:bg-accent hover:text-accent-foreground"}`;
10712
10744
  var PathsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
10713
- const [, setTick] = (0, import_react78.useState)(0);
10714
- (0, import_react78.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
10715
- const [renaming, setRenaming] = (0, import_react78.useState)(null);
10716
- const [color, setColor] = (0, import_react78.useState)("#000000");
10717
- const [width, setWidth] = (0, import_react78.useState)(2);
10718
- const [error, setError] = (0, import_react78.useState)(null);
10745
+ const [, setTick] = (0, import_react79.useState)(0);
10746
+ (0, import_react79.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
10747
+ const [renaming, setRenaming] = (0, import_react79.useState)(null);
10748
+ const [color, setColor] = (0, import_react79.useState)("#000000");
10749
+ const [width, setWidth] = (0, import_react79.useState)(2);
10750
+ const [error, setError] = (0, import_react79.useState)(null);
10719
10751
  const paths = controller.getPaths();
10720
10752
  const activeId = controller.getState().activePathId ?? null;
10721
10753
  const active = paths.find((p) => p.id === activeId) ?? null;
@@ -10815,13 +10847,13 @@ var PathsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
10815
10847
  };
10816
10848
 
10817
10849
  // src/image-editor/FreeTransformOptionsBar.tsx
10818
- var import_react79 = require("react");
10850
+ var import_react80 = require("react");
10819
10851
  var import_image_editor22 = require("@pixerate/editor/image-editor");
10820
10852
  var import_jsx_runtime59 = require("react/jsx-runtime");
10821
10853
  var round = (v, unit) => unit === "px" ? Math.round(v * 10) / 10 : Math.round(v * 100) / 100;
10822
10854
  var FreeTransformOptionsBar = ({ tool, className }) => {
10823
- const [, setTick] = (0, import_react79.useState)(0);
10824
- (0, import_react79.useEffect)(() => tool.subscribe(() => setTick((n) => n + 1)), [tool]);
10855
+ const [, setTick] = (0, import_react80.useState)(0);
10856
+ (0, import_react80.useEffect)(() => tool.subscribe(() => setTick((n) => n + 1)), [tool]);
10825
10857
  const bar = tool.bar();
10826
10858
  if (!tool.active || !bar) return null;
10827
10859
  const warp = tool.warpBar();
@@ -10953,13 +10985,13 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
10953
10985
  };
10954
10986
 
10955
10987
  // src/image-editor/ShapeOptionsBar.tsx
10956
- var import_react80 = require("react");
10988
+ var import_react81 = require("react");
10957
10989
  var import_image_editor23 = require("@pixerate/editor/image-editor");
10958
10990
  var import_jsx_runtime60 = require("react/jsx-runtime");
10959
10991
  var ShapeOptionsBar = ({ controller, options, onChange, showTools = true, className }) => {
10960
- const [, setTick] = (0, import_react80.useState)(0);
10961
- (0, import_react80.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
10962
- const [error, setError] = (0, import_react80.useState)(null);
10992
+ const [, setTick] = (0, import_react81.useState)(0);
10993
+ (0, import_react81.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
10994
+ const [error, setError] = (0, import_react81.useState)(null);
10963
10995
  const active = controller.getActiveLayer();
10964
10996
  const shapeId = active?.type === "shape" ? active.id : null;
10965
10997
  const set = (change) => {
@@ -11038,16 +11070,16 @@ var ShapeOptionsBar = ({ controller, options, onChange, showTools = true, classN
11038
11070
  };
11039
11071
 
11040
11072
  // src/image-editor/TypeOptionsBar.tsx
11041
- var import_react81 = require("react");
11073
+ var import_react82 = require("react");
11042
11074
  var import_image_editor24 = require("@pixerate/editor/image-editor");
11043
11075
  var import_jsx_runtime61 = require("react/jsx-runtime");
11044
11076
  var ALIGN_LABELS = { left: "Left", center: "Centre", right: "Right", justify: "Justify" };
11045
11077
  var ORIENTATION_LABELS = { horizontal: "Horizontal", vertical: "Vertical" };
11046
11078
  var TypeOptionsBar = ({ controller, options, onChange, session, className }) => {
11047
- const [, setTick] = (0, import_react81.useState)(0);
11048
- (0, import_react81.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
11049
- (0, import_react81.useEffect)(() => session?.subscribe(() => setTick((n) => n + 1)), [session]);
11050
- const [error, setError] = (0, import_react81.useState)(null);
11079
+ const [, setTick] = (0, import_react82.useState)(0);
11080
+ (0, import_react82.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
11081
+ (0, import_react82.useEffect)(() => session?.subscribe(() => setTick((n) => n + 1)), [session]);
11082
+ const [error, setError] = (0, import_react82.useState)(null);
11051
11083
  const active = controller.getActiveLayer();
11052
11084
  const typeId = !session && active?.type === "type" ? active.id : null;
11053
11085
  const here = session?.alive ? session.styleHere() : {};
@@ -11187,32 +11219,32 @@ var ImageEditor = ({
11187
11219
  return l.type === "pixel" && !!l.generator || l.type === "smart" && !!l.smartFilters?.filters.some((f) => f.kind === "effect") || l.type === "group" && l.children.some(has);
11188
11220
  });
11189
11221
  const legacyProcess = (0, import_image_editor25.normalizeProcessVersion)(state.adjustments.process) < import_image_editor25.LATEST_PROCESS_VERSION;
11190
- const [activeTab, setActiveTab] = (0, import_react82.useState)("crop");
11191
- const rootRef = (0, import_react82.useRef)(null);
11222
+ const [activeTab, setActiveTab] = (0, import_react83.useState)("crop");
11223
+ const rootRef = (0, import_react83.useRef)(null);
11192
11224
  const canvasMode = activeTab === "crop" || activeTab === "select" || activeTab === "paint" || activeTab === "annotate" ? activeTab : "none";
11193
- const activeTabRef = (0, import_react82.useRef)(activeTab);
11225
+ const activeTabRef = (0, import_react83.useRef)(activeTab);
11194
11226
  activeTabRef.current = activeTab;
11195
11227
  const openPanel = async (ref) => {
11196
11228
  if (ref.kind !== "panel" || activeTabRef.current === ref.id) return;
11197
11229
  rootRef.current?.querySelector(`[data-image-tab="${CSS.escape(ref.id)}"]`)?.click();
11198
11230
  await new Promise((resolve) => setTimeout(resolve, 60));
11199
11231
  };
11200
- const [activeCropRatio, setActiveCropRatio] = (0, import_react82.useState)(null);
11201
- const [selectionOptions, setSelectionOptions] = (0, import_react82.useState)(import_image_editor25.DEFAULT_SELECTION_TOOL_OPTIONS);
11202
- const [shapeOptions, setShapeOptions] = (0, import_react82.useState)(import_image_editor25.DEFAULT_SHAPE_TOOL_OPTIONS);
11203
- const [typeOptions, setTypeOptions] = (0, import_react82.useState)(import_image_editor25.DEFAULT_TYPE_TOOL_OPTIONS);
11204
- const [typeSession, setTypeSession] = (0, import_react82.useState)(null);
11205
- const [selectionError, setSelectionError] = (0, import_react82.useState)(null);
11206
- const [paintError, setPaintError] = (0, import_react82.useState)(null);
11207
- const [shapeTypeError, setShapeTypeError] = (0, import_react82.useState)(null);
11232
+ const [activeCropRatio, setActiveCropRatio] = (0, import_react83.useState)(null);
11233
+ const [selectionOptions, setSelectionOptions] = (0, import_react83.useState)(import_image_editor25.DEFAULT_SELECTION_TOOL_OPTIONS);
11234
+ const [shapeOptions, setShapeOptions] = (0, import_react83.useState)(import_image_editor25.DEFAULT_SHAPE_TOOL_OPTIONS);
11235
+ const [typeOptions, setTypeOptions] = (0, import_react83.useState)(import_image_editor25.DEFAULT_TYPE_TOOL_OPTIONS);
11236
+ const [typeSession, setTypeSession] = (0, import_react83.useState)(null);
11237
+ const [selectionError, setSelectionError] = (0, import_react83.useState)(null);
11238
+ const [paintError, setPaintError] = (0, import_react83.useState)(null);
11239
+ const [shapeTypeError, setShapeTypeError] = (0, import_react83.useState)(null);
11208
11240
  const handleCanvasError = (source, message2) => {
11209
11241
  if (source === "paint") setPaintError(message2);
11210
11242
  else if (source === "select") setSelectionError(message2);
11211
11243
  else setShapeTypeError(message2);
11212
11244
  };
11213
11245
  const finishTyping = () => setTypeSession(null);
11214
- const transformToolRef = (0, import_react82.useRef)(null);
11215
- const transformControllerRef = (0, import_react82.useRef)(controller);
11246
+ const transformToolRef = (0, import_react83.useRef)(null);
11247
+ const transformControllerRef = (0, import_react83.useRef)(controller);
11216
11248
  if (!transformToolRef.current || transformControllerRef.current !== controller) {
11217
11249
  transformToolRef.current?.cancel();
11218
11250
  transformToolRef.current = new import_image_editor25.FreeTransformTool(controller, {
@@ -11221,16 +11253,16 @@ var ImageEditor = ({
11221
11253
  transformControllerRef.current = controller;
11222
11254
  }
11223
11255
  const transformTool = transformToolRef.current;
11224
- const [, setTransformTick] = (0, import_react82.useState)(0);
11225
- (0, import_react82.useEffect)(() => transformTool.subscribe(() => setTransformTick((n) => n + 1)), [transformTool]);
11226
- (0, import_react82.useEffect)(() => () => transformToolRef.current?.cancel(), []);
11227
- const [inpaintPrompt, setInpaintPrompt] = (0, import_react82.useState)("");
11228
- const [inpaintMaskMode, setInpaintMaskMode] = (0, import_react82.useState)("annotations");
11229
- const [isRemovingBg, setIsRemovingBg] = (0, import_react82.useState)(false);
11230
- const [isInpainting, setIsInpainting] = (0, import_react82.useState)(false);
11231
- const [aiError, setAiError] = (0, import_react82.useState)(null);
11232
- const [aiSuccess, setAiSuccess] = (0, import_react82.useState)(null);
11233
- const [aiTarget, setAiTarget] = (0, import_react82.useState)("auto");
11256
+ const [, setTransformTick] = (0, import_react83.useState)(0);
11257
+ (0, import_react83.useEffect)(() => transformTool.subscribe(() => setTransformTick((n) => n + 1)), [transformTool]);
11258
+ (0, import_react83.useEffect)(() => () => transformToolRef.current?.cancel(), []);
11259
+ const [inpaintPrompt, setInpaintPrompt] = (0, import_react83.useState)("");
11260
+ const [inpaintMaskMode, setInpaintMaskMode] = (0, import_react83.useState)("annotations");
11261
+ const [isRemovingBg, setIsRemovingBg] = (0, import_react83.useState)(false);
11262
+ const [isInpainting, setIsInpainting] = (0, import_react83.useState)(false);
11263
+ const [aiError, setAiError] = (0, import_react83.useState)(null);
11264
+ const [aiSuccess, setAiSuccess] = (0, import_react83.useState)(null);
11265
+ const [aiTarget, setAiTarget] = (0, import_react83.useState)("auto");
11234
11266
  const aiOptions = aiTarget === "auto" ? {} : { target: aiTarget };
11235
11267
  const effectiveOnInpaint = onInpaint || aiHooks?.onInpaint;
11236
11268
  const effectiveOnRemoveBg = onRemoveBackground || aiHooks?.onRemoveBackground;
@@ -11293,11 +11325,11 @@ var ImageEditor = ({
11293
11325
  setIsInpainting(false);
11294
11326
  }
11295
11327
  };
11296
- const [activeColor, setActiveColor] = (0, import_react82.useState)("#ef4444");
11297
- const [strokeWidth, setStrokeWidth] = (0, import_react82.useState)(3);
11298
- const [fontSize, setFontSize] = (0, import_react82.useState)(24);
11299
- const [textInput, setTextInput] = (0, import_react82.useState)("");
11300
- (0, import_react82.useEffect)(() => {
11328
+ const [activeColor, setActiveColor] = (0, import_react83.useState)("#ef4444");
11329
+ const [strokeWidth, setStrokeWidth] = (0, import_react83.useState)(3);
11330
+ const [fontSize, setFontSize] = (0, import_react83.useState)(24);
11331
+ const [textInput, setTextInput] = (0, import_react83.useState)("");
11332
+ (0, import_react83.useEffect)(() => {
11301
11333
  if (activeTab === "crop" && editor.state.activeTool !== "crop") {
11302
11334
  editor.setTool("crop");
11303
11335
  }
@@ -11697,7 +11729,7 @@ var ImageEditor = ({
11697
11729
  )
11698
11730
  ] }),
11699
11731
  /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Histogram, { histogram: editor.histogram }),
11700
- import_image_editor25.IMAGE_ADJUSTMENT_CONTROLS.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_react82.default.Fragment, { children: [
11732
+ import_image_editor25.IMAGE_ADJUSTMENT_CONTROLS.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_react83.default.Fragment, { children: [
11701
11733
  /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
11702
11734
  ControlSlider,
11703
11735
  {
@@ -12191,7 +12223,7 @@ var ImageEditor = ({
12191
12223
  };
12192
12224
 
12193
12225
  // src/review/useReview.ts
12194
- var import_react83 = require("react");
12226
+ var import_react84 = require("react");
12195
12227
  var import_editor13 = require("@pixerate/editor");
12196
12228
  var EMPTY_COMMENTS = Object.freeze({
12197
12229
  threads: [],
@@ -12210,23 +12242,23 @@ function isCommentStore(value) {
12210
12242
  }
12211
12243
  function useComments(source) {
12212
12244
  const store = isCommentStore(source) ? source : (0, import_editor13.getCommentStore)(source);
12213
- const subscribe = (0, import_react83.useCallback)(
12245
+ const subscribe = (0, import_react84.useCallback)(
12214
12246
  (onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe,
12215
12247
  [store]
12216
12248
  );
12217
12249
  const getSnapshot2 = () => store?.getSnapshot() ?? EMPTY_COMMENTS;
12218
- const snapshot = (0, import_react83.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
12219
- return (0, import_react83.useMemo)(() => ({ ...snapshot, store }), [snapshot, store]);
12250
+ const snapshot = (0, import_react84.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
12251
+ return (0, import_react84.useMemo)(() => ({ ...snapshot, store }), [snapshot, store]);
12220
12252
  }
12221
12253
  function useTrackChanges(editor) {
12222
12254
  const store = (0, import_editor13.getTrackChangesStore)(editor ?? null);
12223
- const subscribe = (0, import_react83.useCallback)(
12255
+ const subscribe = (0, import_react84.useCallback)(
12224
12256
  (onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe,
12225
12257
  [store]
12226
12258
  );
12227
12259
  const getSnapshot2 = () => store?.getSnapshot() ?? EMPTY_TRACK_CHANGES;
12228
- const snapshot = (0, import_react83.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
12229
- return (0, import_react83.useMemo)(() => {
12260
+ const snapshot = (0, import_react84.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
12261
+ return (0, import_react84.useMemo)(() => {
12230
12262
  const run = (fn) => () => {
12231
12263
  if (editor && !editor.isDestroyed) fn(editor);
12232
12264
  };
@@ -12249,7 +12281,7 @@ function useTrackChanges(editor) {
12249
12281
  }
12250
12282
 
12251
12283
  // src/review/CommentsPanel.tsx
12252
- var import_react84 = require("react");
12284
+ var import_react85 = require("react");
12253
12285
  var import_editor14 = require("@pixerate/editor");
12254
12286
  var import_jsx_runtime63 = require("react/jsx-runtime");
12255
12287
  var buttonClass2 = "rounded px-2 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-50";
@@ -12265,7 +12297,7 @@ var CommentsPanel = ({
12265
12297
  emptyMessage = "No comments yet. Select text and add a comment."
12266
12298
  }) => {
12267
12299
  const { threads, activeThreadId, store } = useComments(storeProp ?? editor);
12268
- const [showResolved, setShowResolved] = (0, import_react84.useState)(showResolvedInitial);
12300
+ const [showResolved, setShowResolved] = (0, import_react85.useState)(showResolvedInitial);
12269
12301
  const author = authorProp ?? (0, import_editor14.getCommentAuthor)(editor) ?? { id: "anonymous", name: "Anonymous" };
12270
12302
  const visible = threads.filter((t) => showResolved || !t.resolved);
12271
12303
  const resolvedCount = threads.filter((t) => t.resolved).length;
@@ -12309,7 +12341,7 @@ var CommentThreadCard = ({
12309
12341
  author,
12310
12342
  formatTime
12311
12343
  }) => {
12312
- const [draft, setDraft] = (0, import_react84.useState)("");
12344
+ const [draft, setDraft] = (0, import_react85.useState)("");
12313
12345
  const isDraft = thread.body === "";
12314
12346
  const quote = thread.anchor?.quote ?? thread.lastQuote ?? "";
12315
12347
  const live = editor && !editor.isDestroyed ? editor : null;
@@ -12523,13 +12555,13 @@ var CommentButton = ({
12523
12555
  );
12524
12556
 
12525
12557
  // src/review/useDocumentCompare.ts
12526
- var import_react85 = require("react");
12558
+ var import_react86 = require("react");
12527
12559
  var import_editor15 = require("@pixerate/editor");
12528
12560
  function useDocumentCompare(editor, options) {
12529
- const [summary, setSummary] = (0, import_react85.useState)(null);
12530
- const defaults = (0, import_react85.useRef)(options);
12561
+ const [summary, setSummary] = (0, import_react86.useState)(null);
12562
+ const defaults = (0, import_react86.useRef)(options);
12531
12563
  defaults.current = options;
12532
- const compare = (0, import_react85.useCallback)(
12564
+ const compare = (0, import_react86.useCallback)(
12533
12565
  (original, revised, overrides) => {
12534
12566
  if (!editor || editor.isDestroyed) return null;
12535
12567
  const result = (0, import_editor15.applyDocumentComparison)(editor, original, revised, {
@@ -12541,8 +12573,8 @@ function useDocumentCompare(editor, options) {
12541
12573
  },
12542
12574
  [editor]
12543
12575
  );
12544
- const clear = (0, import_react85.useCallback)(() => setSummary(null), []);
12545
- return (0, import_react85.useMemo)(() => ({ summary, compare, clear }), [summary, compare, clear]);
12576
+ const clear = (0, import_react86.useCallback)(() => setSummary(null), []);
12577
+ return (0, import_react86.useMemo)(() => ({ summary, compare, clear }), [summary, compare, clear]);
12546
12578
  }
12547
12579
 
12548
12580
  // src/review/TrackedChangesList.tsx
@@ -12593,12 +12625,12 @@ var TrackedChangesList = ({
12593
12625
  };
12594
12626
 
12595
12627
  // src/commands/useCommandPalette.ts
12596
- var import_react86 = require("react");
12628
+ var import_react87 = require("react");
12597
12629
  var import_commands2 = require("@pixerate/editor/commands");
12598
12630
  function useCommandPalette(registry, options = {}) {
12599
- const optionsRef = (0, import_react86.useRef)(options);
12631
+ const optionsRef = (0, import_react87.useRef)(options);
12600
12632
  optionsRef.current = options;
12601
- const controller = (0, import_react86.useMemo)(
12633
+ const controller = (0, import_react87.useMemo)(
12602
12634
  () => (0, import_commands2.createCommandPaletteController)(registry, {
12603
12635
  context: () => {
12604
12636
  const c = optionsRef.current.context;
@@ -12619,9 +12651,9 @@ function useCommandPalette(registry, options = {}) {
12619
12651
  // eslint-disable-next-line react-hooks/exhaustive-deps
12620
12652
  [registry]
12621
12653
  );
12622
- const state = (0, import_react86.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
12654
+ const state = (0, import_react87.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
12623
12655
  const { hotkey, hotkeyTarget } = options;
12624
- (0, import_react86.useEffect)(() => {
12656
+ (0, import_react87.useEffect)(() => {
12625
12657
  if (!hotkey) return;
12626
12658
  const target = hotkeyTarget ?? (typeof window !== "undefined" ? window : null);
12627
12659
  if (!target) return;
@@ -12649,13 +12681,13 @@ function useCommandPalette(registry, options = {}) {
12649
12681
  }
12650
12682
 
12651
12683
  // src/commands/CommandPalette.tsx
12652
- var import_react87 = __toESM(require("react"), 1);
12684
+ var import_react88 = __toESM(require("react"), 1);
12653
12685
  var import_jsx_runtime67 = require("react/jsx-runtime");
12654
12686
  function HighlightedLabel({ item }) {
12655
12687
  if (item.labelIndices.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_jsx_runtime67.Fragment, { children: item.label });
12656
12688
  const marked = new Set(item.labelIndices);
12657
12689
  return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_jsx_runtime67.Fragment, { children: Array.from(item.label).map(
12658
- (ch, i) => marked.has(i) ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "font-semibold text-foreground", "data-match": "", children: ch }, i) : /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_react87.default.Fragment, { children: ch }, i)
12690
+ (ch, i) => marked.has(i) ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "font-semibold text-foreground", "data-match": "", children: ch }, i) : /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_react88.default.Fragment, { children: ch }, i)
12659
12691
  ) });
12660
12692
  }
12661
12693
  var CommandPalette = ({
@@ -12664,16 +12696,16 @@ var CommandPalette = ({
12664
12696
  emptyMessage = "No matching commands",
12665
12697
  className = ""
12666
12698
  }) => {
12667
- const inputRef = (0, import_react87.useRef)(null);
12668
- const listRef = (0, import_react87.useRef)(null);
12669
- const baseId = (0, import_react87.useId)();
12699
+ const inputRef = (0, import_react88.useRef)(null);
12700
+ const listRef = (0, import_react88.useRef)(null);
12701
+ const baseId = (0, import_react88.useId)();
12670
12702
  const listId = `${baseId}-list`;
12671
12703
  const optionId = (index) => `${baseId}-option-${index}`;
12672
12704
  const { open, query, items, activeIndex } = palette;
12673
- (0, import_react87.useEffect)(() => {
12705
+ (0, import_react88.useEffect)(() => {
12674
12706
  if (open) inputRef.current?.focus();
12675
12707
  }, [open]);
12676
- (0, import_react87.useEffect)(() => {
12708
+ (0, import_react88.useEffect)(() => {
12677
12709
  if (!open) return;
12678
12710
  const active = listRef.current?.querySelector('[aria-selected="true"]');
12679
12711
  active?.scrollIntoView?.({ block: "nearest" });
@@ -12749,12 +12781,12 @@ var CommandPalette = ({
12749
12781
  };
12750
12782
 
12751
12783
  // src/commands/useCommandShortcuts.ts
12752
- var import_react88 = require("react");
12784
+ var import_react89 = require("react");
12753
12785
  function useCommandShortcuts(registry, options = {}) {
12754
- const optionsRef = (0, import_react88.useRef)(options);
12786
+ const optionsRef = (0, import_react89.useRef)(options);
12755
12787
  optionsRef.current = options;
12756
12788
  const { enabled = true, target } = options;
12757
- (0, import_react88.useEffect)(() => {
12789
+ (0, import_react89.useEffect)(() => {
12758
12790
  if (!registry || !enabled) return;
12759
12791
  const eventTarget = target ?? (typeof window !== "undefined" ? window : null);
12760
12792
  if (!eventTarget) return;
@@ -12772,14 +12804,14 @@ function useCommandShortcuts(registry, options = {}) {
12772
12804
  }, [registry, enabled, target]);
12773
12805
  }
12774
12806
  function useRegisterCommands(registry, specs) {
12775
- (0, import_react88.useEffect)(() => {
12807
+ (0, import_react89.useEffect)(() => {
12776
12808
  if (!registry || !specs || specs.length === 0) return;
12777
12809
  return registry.register(specs);
12778
12810
  }, [registry, specs]);
12779
12811
  }
12780
12812
 
12781
12813
  // src/persistence/useAutosave.ts
12782
- var import_react89 = require("react");
12814
+ var import_react90 = require("react");
12783
12815
  var import_persistence = require("@pixerate/editor/persistence");
12784
12816
  var IDLE = {
12785
12817
  status: "idle",
@@ -12790,18 +12822,18 @@ var IDLE = {
12790
12822
  ready: false
12791
12823
  };
12792
12824
  function useAutosave(options) {
12793
- const optionsRef = (0, import_react89.useRef)(options);
12825
+ const optionsRef = (0, import_react90.useRef)(options);
12794
12826
  optionsRef.current = options;
12795
12827
  const { storage, key, history, dirty } = options;
12796
12828
  const recover = options.recover !== false;
12797
12829
  const flushOnHide = options.flushOnHide !== false;
12798
12830
  const ready = options.ready !== false;
12799
- const [controller, setController] = (0, import_react89.useState)(null);
12800
- const [status, setStatus] = (0, import_react89.useState)(IDLE);
12801
- const [recovery, setRecovery] = (0, import_react89.useState)(null);
12802
- const [pendingRecovery, setPendingRecovery] = (0, import_react89.useState)(recover);
12803
- const revisionsRef = (0, import_react89.useRef)(null);
12804
- (0, import_react89.useEffect)(() => {
12831
+ const [controller, setController] = (0, import_react90.useState)(null);
12832
+ const [status, setStatus] = (0, import_react90.useState)(IDLE);
12833
+ const [recovery, setRecovery] = (0, import_react90.useState)(null);
12834
+ const [pendingRecovery, setPendingRecovery] = (0, import_react90.useState)(recover);
12835
+ const revisionsRef = (0, import_react90.useRef)(null);
12836
+ (0, import_react90.useEffect)(() => {
12805
12837
  const revisions = (0, import_persistence.createRevisionTracker)({ history, dirty });
12806
12838
  const o = optionsRef.current;
12807
12839
  const instance = (0, import_persistence.createAutosaveController)({
@@ -12848,10 +12880,10 @@ function useAutosave(options) {
12848
12880
  if (revisionsRef.current === revisions) revisionsRef.current = null;
12849
12881
  };
12850
12882
  }, [storage, key, history, dirty, recover]);
12851
- (0, import_react89.useEffect)(() => {
12883
+ (0, import_react90.useEffect)(() => {
12852
12884
  if (controller && ready && !pendingRecovery) controller.ready();
12853
12885
  }, [controller, ready, pendingRecovery]);
12854
- (0, import_react89.useEffect)(() => {
12886
+ (0, import_react90.useEffect)(() => {
12855
12887
  if (!controller || !flushOnHide || typeof window === "undefined") return;
12856
12888
  const flush = () => void controller.flushNow();
12857
12889
  const onVisibility = () => {
@@ -12864,33 +12896,33 @@ function useAutosave(options) {
12864
12896
  document.removeEventListener("visibilitychange", onVisibility);
12865
12897
  };
12866
12898
  }, [controller, flushOnHide]);
12867
- const restore = (0, import_react89.useCallback)(() => {
12899
+ const restore = (0, import_react90.useCallback)(() => {
12868
12900
  const snapshot = recovery?.snapshot;
12869
12901
  setRecovery(null);
12870
12902
  setPendingRecovery(false);
12871
12903
  return snapshot;
12872
12904
  }, [recovery]);
12873
- const discard = (0, import_react89.useCallback)(async () => {
12905
+ const discard = (0, import_react90.useCallback)(async () => {
12874
12906
  if (controller) await controller.discardRecovery();
12875
12907
  setRecovery(null);
12876
12908
  setPendingRecovery(false);
12877
12909
  }, [controller]);
12878
- const flushNow = (0, import_react89.useCallback)(async () => {
12910
+ const flushNow = (0, import_react90.useCallback)(async () => {
12879
12911
  await controller?.flushNow();
12880
12912
  }, [controller]);
12881
- const markClean = (0, import_react89.useCallback)(async () => {
12913
+ const markClean = (0, import_react90.useCallback)(async () => {
12882
12914
  revisionsRef.current?.markSaved();
12883
12915
  await controller?.markClean();
12884
12916
  }, [controller]);
12885
- const notifyChange = (0, import_react89.useCallback)(() => revisionsRef.current?.bump(), []);
12917
+ const notifyChange = (0, import_react90.useCallback)(() => revisionsRef.current?.bump(), []);
12886
12918
  return { status, recovery, pendingRecovery, restore, discard, flushNow, markClean, notifyChange, controller };
12887
12919
  }
12888
12920
 
12889
12921
  // src/persistence/useEditorAutosave.ts
12890
- var import_react90 = require("react");
12922
+ var import_react91 = require("react");
12891
12923
  var import_persistence2 = require("@pixerate/editor/persistence");
12892
12924
  function useEditorAutosave(doc, { collectAssetGarbage, ...options }) {
12893
- const storage = (0, import_react90.useMemo)(
12925
+ const storage = (0, import_react91.useMemo)(
12894
12926
  () => doc.assets ? (0, import_persistence2.withEditorAssets)(options.storage, doc.assets) : options.storage,
12895
12927
  [options.storage, doc.assets]
12896
12928
  );
@@ -12903,19 +12935,19 @@ function useEditorAutosave(doc, { collectAssetGarbage, ...options }) {
12903
12935
  history: doc
12904
12936
  });
12905
12937
  const take = autosave.restore;
12906
- const restore = (0, import_react90.useCallback)(() => {
12938
+ const restore = (0, import_react91.useCallback)(() => {
12907
12939
  const snapshot = take();
12908
12940
  return snapshot ? doc.loadDocument(snapshot, { history: "reset" }) : void 0;
12909
12941
  }, [take, doc]);
12910
12942
  const { markClean: clean, discard: drop } = autosave;
12911
12943
  const rawStorage = options.storage;
12912
- const gcRef = (0, import_react90.useRef)(collectAssetGarbage);
12944
+ const gcRef = (0, import_react91.useRef)(collectAssetGarbage);
12913
12945
  gcRef.current = collectAssetGarbage;
12914
- const markClean = (0, import_react90.useCallback)(async () => {
12946
+ const markClean = (0, import_react91.useCallback)(async () => {
12915
12947
  await clean();
12916
12948
  await (0, import_persistence2.collectRetiredEditorAssets)(rawStorage, doc, gcRef.current);
12917
12949
  }, [clean, rawStorage, doc]);
12918
- const discard = (0, import_react90.useCallback)(async () => {
12950
+ const discard = (0, import_react91.useCallback)(async () => {
12919
12951
  await drop();
12920
12952
  await (0, import_persistence2.collectRetiredEditorAssets)(rawStorage, doc, gcRef.current);
12921
12953
  }, [drop, rawStorage, doc]);
@@ -12978,20 +13010,20 @@ var RecoveryPrompt = ({
12978
13010
  };
12979
13011
 
12980
13012
  // src/persistence/useEditorSync.ts
12981
- var import_react91 = require("react");
13013
+ var import_react92 = require("react");
12982
13014
  var import_persistence4 = require("@pixerate/editor/persistence");
12983
13015
  function useEditorSync(doc, options) {
12984
- const optionsRef = (0, import_react91.useRef)(options);
13016
+ const optionsRef = (0, import_react92.useRef)(options);
12985
13017
  optionsRef.current = options;
12986
- const [controller, setController] = (0, import_react91.useState)(null);
12987
- const [status, setStatus] = (0, import_react91.useState)(() => ({
13018
+ const [controller, setController] = (0, import_react92.useState)(null);
13019
+ const [status, setStatus] = (0, import_react92.useState)(() => ({
12988
13020
  status: "idle",
12989
13021
  version: options.initialVersion ?? 0,
12990
13022
  savedVersion: options.initialVersion ?? 0,
12991
13023
  dirty: false,
12992
13024
  lastSavedAt: null
12993
13025
  }));
12994
- (0, import_react91.useEffect)(() => {
13026
+ (0, import_react92.useEffect)(() => {
12995
13027
  const { flushOnHide: _flushOnHide, ...initial } = optionsRef.current;
12996
13028
  const instance = (0, import_persistence4.createEditorRemoteSync)(doc, {
12997
13029
  ...initial,
@@ -13013,7 +13045,7 @@ function useEditorSync(doc, options) {
13013
13045
  };
13014
13046
  }, [doc]);
13015
13047
  const flushOnHide = options.flushOnHide ?? true;
13016
- (0, import_react91.useEffect)(() => {
13048
+ (0, import_react92.useEffect)(() => {
13017
13049
  if (!controller || !flushOnHide || typeof window === "undefined") return;
13018
13050
  const onVisibilityChange = () => {
13019
13051
  if (document.visibilityState === "hidden") void controller.flush();
@@ -13026,11 +13058,11 @@ function useEditorSync(doc, options) {
13026
13058
  window.removeEventListener("pagehide", onPageHide);
13027
13059
  };
13028
13060
  }, [controller, flushOnHide]);
13029
- const applyRemote = (0, import_react91.useCallback)(
13061
+ const applyRemote = (0, import_react92.useCallback)(
13030
13062
  (fn, remoteVersion) => controller ? controller.applyRemote(fn, remoteVersion) : fn(),
13031
13063
  [controller]
13032
13064
  );
13033
- return (0, import_react91.useMemo)(
13065
+ return (0, import_react92.useMemo)(
13034
13066
  () => ({
13035
13067
  status,
13036
13068
  version: status.version,
@@ -13049,17 +13081,17 @@ function useEditorSync(doc, options) {
13049
13081
  }
13050
13082
 
13051
13083
  // src/generation/useGenerationPlan.ts
13052
- var import_react92 = require("react");
13084
+ var import_react93 = require("react");
13053
13085
  var import_generation = require("@pixerate/editor/generation");
13054
13086
  function useGenerationPlan(request, capabilities, options = {}) {
13055
13087
  const key = JSON.stringify([request, capabilities, options]);
13056
- return (0, import_react92.useMemo)(() => (0, import_generation.planGenerationRequest)(request, capabilities, options), [key]);
13088
+ return (0, import_react93.useMemo)(() => (0, import_generation.planGenerationRequest)(request, capabilities, options), [key]);
13057
13089
  }
13058
13090
  function useJobProgress(options) {
13059
13091
  const { startedAt, expectedMs, done, now, intervalMs = 1e3 } = options;
13060
- const [tick, setTick] = (0, import_react92.useState)(() => Date.now());
13092
+ const [tick, setTick] = (0, import_react93.useState)(() => Date.now());
13061
13093
  const ticking = !done && now === void 0;
13062
- (0, import_react92.useEffect)(() => {
13094
+ (0, import_react93.useEffect)(() => {
13063
13095
  if (!ticking) return;
13064
13096
  setTick(Date.now());
13065
13097
  const id = setInterval(() => setTick(Date.now()), Math.max(16, intervalMs));
@@ -13069,7 +13101,7 @@ function useJobProgress(options) {
13069
13101
  }
13070
13102
 
13071
13103
  // src/generation/GenerationSettings.tsx
13072
- var import_react93 = require("react");
13104
+ var import_react94 = require("react");
13073
13105
  var import_generation2 = require("@pixerate/editor/generation");
13074
13106
  var import_jsx_runtime69 = require("react/jsx-runtime");
13075
13107
  var inputClass2 = "w-full rounded-md border border-border bg-background px-2 py-1 text-sm outline-none focus:ring-1 focus:ring-ring";
@@ -13152,8 +13184,8 @@ var GenerationSettings = ({
13152
13184
  renderReference,
13153
13185
  className = ""
13154
13186
  }) => {
13155
- const baseId = (0, import_react93.useId)();
13156
- const controls = (0, import_react93.useMemo)(() => (0, import_generation2.getGenerationControls)(capabilities), [capabilities]);
13187
+ const baseId = (0, import_react94.useId)();
13188
+ const controls = (0, import_react94.useMemo)(() => (0, import_generation2.getGenerationControls)(capabilities), [capabilities]);
13157
13189
  const computed = useGenerationPlan(value, capabilities, { strategy });
13158
13190
  const plan = planProp ?? computed;
13159
13191
  const slots = (0, import_generation2.getReferenceSlots)(capabilities, value);
@@ -13248,7 +13280,7 @@ var JobProgress = ({ title, className = "", ...options }) => {
13248
13280
  };
13249
13281
 
13250
13282
  // src/generation/AssetMentionChips.tsx
13251
- var import_react94 = require("react");
13283
+ var import_react95 = require("react");
13252
13284
  var import_generation3 = require("@pixerate/editor/generation");
13253
13285
  var import_jsx_runtime71 = require("react/jsx-runtime");
13254
13286
  var AssetMentionChips = ({
@@ -13260,14 +13292,14 @@ var AssetMentionChips = ({
13260
13292
  renderAsset,
13261
13293
  className = ""
13262
13294
  }) => {
13263
- const [open, setOpen] = (0, import_react94.useState)(null);
13264
- const rootRef = (0, import_react94.useRef)(null);
13265
- const chips = (0, import_react94.useMemo)(
13295
+ const [open, setOpen] = (0, import_react95.useState)(null);
13296
+ const rootRef = (0, import_react95.useRef)(null);
13297
+ const chips = (0, import_react95.useMemo)(
13266
13298
  () => (0, import_generation3.describeAssetMentions)((0, import_generation3.findTextMentions)(content), assets, capabilities),
13267
13299
  [content, assets, capabilities]
13268
13300
  );
13269
13301
  const options = roles ?? (capabilities ? (0, import_generation3.getAssetRoleOptions)(capabilities) : (0, import_generation3.defaultAssetRoleOptions)());
13270
- (0, import_react94.useEffect)(() => {
13302
+ (0, import_react95.useEffect)(() => {
13271
13303
  if (open === null) return;
13272
13304
  const onPointer = (event) => {
13273
13305
  if (!rootRef.current?.contains(event.target)) setOpen(null);
@@ -13362,15 +13394,15 @@ var AssetMentionChips = ({
13362
13394
  };
13363
13395
 
13364
13396
  // src/generation/GenerationHistory.tsx
13365
- var import_react95 = require("react");
13397
+ var import_react96 = require("react");
13366
13398
  var import_generation4 = require("@pixerate/editor/generation");
13367
13399
  var import_jsx_runtime72 = require("react/jsx-runtime");
13368
13400
  function useGenerationRecords(store, filter) {
13369
- const [records, setRecords] = (0, import_react95.useState)([]);
13370
- const [loading, setLoading] = (0, import_react95.useState)(!!store);
13371
- const [error, setError] = (0, import_react95.useState)(null);
13401
+ const [records, setRecords] = (0, import_react96.useState)([]);
13402
+ const [loading, setLoading] = (0, import_react96.useState)(!!store);
13403
+ const [error, setError] = (0, import_react96.useState)(null);
13372
13404
  const filterKey = (0, import_generation4.stableStringify)(filter ?? {});
13373
- const refresh = (0, import_react95.useCallback)(async () => {
13405
+ const refresh = (0, import_react96.useCallback)(async () => {
13374
13406
  if (!store) {
13375
13407
  setRecords([]);
13376
13408
  setLoading(false);
@@ -13387,7 +13419,7 @@ function useGenerationRecords(store, filter) {
13387
13419
  setLoading(false);
13388
13420
  }
13389
13421
  }, [store, filterKey]);
13390
- (0, import_react95.useEffect)(() => {
13422
+ (0, import_react96.useEffect)(() => {
13391
13423
  void refresh();
13392
13424
  if (!store) return;
13393
13425
  return store.subscribe(() => void refresh());
@@ -13413,15 +13445,15 @@ var GenerationHistory = ({
13413
13445
  emptyText = "No generations yet.",
13414
13446
  className = ""
13415
13447
  }) => {
13416
- const [innerMode, setInnerMode] = (0, import_react95.useState)("exact");
13448
+ const [innerMode, setInnerMode] = (0, import_react96.useState)("exact");
13417
13449
  const mode = modeProp ?? innerMode;
13418
13450
  const setMode = (next) => {
13419
13451
  if (modeProp === void 0) setInnerMode(next);
13420
13452
  onModeChange?.(next);
13421
13453
  };
13422
- const options = (0, import_react95.useMemo)(() => ({ templates, capabilities, assets, mode }), [templates, capabilities, assets, mode]);
13423
- const results = (0, import_react95.useMemo)(() => records.map((record) => (0, import_generation4.recreateRequest)(record, options)), [records, options]);
13424
- const models = (0, import_react95.useMemo)(
13454
+ const options = (0, import_react96.useMemo)(() => ({ templates, capabilities, assets, mode }), [templates, capabilities, assets, mode]);
13455
+ const results = (0, import_react96.useMemo)(() => records.map((record) => (0, import_generation4.recreateRequest)(record, options)), [records, options]);
13456
+ const models = (0, import_react96.useMemo)(
13425
13457
  () => capabilities ? Array.isArray(capabilities) ? capabilities : [capabilities] : [],
13426
13458
  [capabilities]
13427
13459
  );
@@ -13532,19 +13564,19 @@ var GenerationHistory = ({
13532
13564
  };
13533
13565
 
13534
13566
  // src/find-replace/useFindReplace.ts
13535
- var import_react96 = require("react");
13567
+ var import_react97 = require("react");
13536
13568
  var import_editor17 = require("@pixerate/editor");
13537
13569
  var noopUnsubscribe2 = () => {
13538
13570
  };
13539
13571
  function useFindReplace(editor) {
13540
13572
  const store = (0, import_editor17.getFindReplaceStore)(editor ?? null);
13541
- const subscribe = (0, import_react96.useCallback)(
13573
+ const subscribe = (0, import_react97.useCallback)(
13542
13574
  (onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe2,
13543
13575
  [store]
13544
13576
  );
13545
13577
  const getSnapshot2 = () => store?.getSnapshot() ?? import_editor17.EMPTY_FIND_REPLACE_SNAPSHOT;
13546
- const snapshot = (0, import_react96.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
13547
- return (0, import_react96.useMemo)(() => {
13578
+ const snapshot = (0, import_react97.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
13579
+ return (0, import_react97.useMemo)(() => {
13548
13580
  const run = (fn) => {
13549
13581
  if (editor && !editor.isDestroyed && store) fn(editor);
13550
13582
  };
@@ -13568,7 +13600,7 @@ function useFindReplace(editor) {
13568
13600
  }
13569
13601
 
13570
13602
  // src/find-replace/FindReplaceBar.tsx
13571
- var import_react97 = require("react");
13603
+ var import_react98 = require("react");
13572
13604
  var import_editor18 = require("@pixerate/editor");
13573
13605
  var import_jsx_runtime73 = require("react/jsx-runtime");
13574
13606
  var inputClass3 = "min-w-0 flex-1 rounded border border-input bg-background px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring";
@@ -13583,10 +13615,10 @@ var FindReplaceBar = ({
13583
13615
  onClose
13584
13616
  }) => {
13585
13617
  const find = useFindReplace(editor);
13586
- const findInput = (0, import_react97.useRef)(null);
13587
- const [moreOpen, setMoreOpen] = (0, import_react97.useState)(false);
13618
+ const findInput = (0, import_react98.useRef)(null);
13619
+ const [moreOpen, setMoreOpen] = (0, import_react98.useState)(false);
13588
13620
  const visible = find.available && (alwaysOpen || find.open);
13589
- (0, import_react97.useEffect)(() => {
13621
+ (0, import_react98.useEffect)(() => {
13590
13622
  if (!visible || find.focusRequest === 0) return;
13591
13623
  findInput.current?.focus();
13592
13624
  findInput.current?.select();
@@ -13730,12 +13762,12 @@ var FindReplaceBar = ({
13730
13762
  };
13731
13763
 
13732
13764
  // src/tables/useTableMenu.ts
13733
- var import_react98 = require("react");
13765
+ var import_react99 = require("react");
13734
13766
  var import_editor19 = require("@pixerate/editor");
13735
13767
  function useTableMenu(editor) {
13736
- const store = (0, import_react98.useMemo)(() => (0, import_editor19.createTableStore)(editor), [editor]);
13737
- const snapshot = (0, import_react98.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
13738
- return (0, import_react98.useMemo)(
13768
+ const store = (0, import_react99.useMemo)(() => (0, import_editor19.createTableStore)(editor), [editor]);
13769
+ const snapshot = (0, import_react99.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
13770
+ return (0, import_react99.useMemo)(
13739
13771
  () => ({
13740
13772
  ...snapshot,
13741
13773
  run: (action, params) => (0, import_editor19.runTableAction)(editor, action, params, { focus: true }),
@@ -13746,7 +13778,7 @@ function useTableMenu(editor) {
13746
13778
  }
13747
13779
 
13748
13780
  // src/tables/TableToolbar.tsx
13749
- var import_react99 = __toESM(require("react"), 1);
13781
+ var import_react100 = __toESM(require("react"), 1);
13750
13782
  var import_editor20 = require("@pixerate/editor");
13751
13783
  var import_jsx_runtime74 = require("react/jsx-runtime");
13752
13784
  var keepSelection2 = (event) => event.preventDefault();
@@ -13767,7 +13799,7 @@ var TableToolbar = ({
13767
13799
  const enabled = status === true;
13768
13800
  const active = item.active?.(table);
13769
13801
  const separator = index > 0 && items[index - 1].group !== item.group;
13770
- return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(import_react99.default.Fragment, { children: [
13802
+ return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(import_react100.default.Fragment, { children: [
13771
13803
  separator && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", { className: separatorClassName, "aria-hidden": "true" }),
13772
13804
  /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
13773
13805
  "button",
@@ -13791,7 +13823,7 @@ var TableToolbar = ({
13791
13823
  };
13792
13824
 
13793
13825
  // src/tables/InsertTableGrid.tsx
13794
- var import_react100 = require("react");
13826
+ var import_react101 = require("react");
13795
13827
  var import_jsx_runtime75 = require("react/jsx-runtime");
13796
13828
  var keepSelection3 = (event) => event.preventDefault();
13797
13829
  var InsertTableGrid = ({
@@ -13805,7 +13837,7 @@ var InsertTableGrid = ({
13805
13837
  onInsert
13806
13838
  }) => {
13807
13839
  const table = useTableMenu(editor);
13808
- const [hover, setHover] = (0, import_react100.useState)(null);
13840
+ const [hover, setHover] = (0, import_react101.useState)(null);
13809
13841
  const status = table.actions.insertTable;
13810
13842
  const disabled = !editor || !status.enabled;
13811
13843
  const insert = (size) => {
@@ -13872,14 +13904,14 @@ var TableBubbleMenu = ({
13872
13904
  var import_client2 = require("react-dom/client");
13873
13905
 
13874
13906
  // src/chart/ChartCanvas.tsx
13875
- var import_react102 = require("react");
13907
+ var import_react103 = require("react");
13876
13908
  var import_chart2 = require("@pixerate/editor/chart");
13877
13909
 
13878
13910
  // src/chart/useChartEditor.ts
13879
- var import_react101 = require("react");
13911
+ var import_react102 = require("react");
13880
13912
  var import_chart = require("@pixerate/editor/chart");
13881
13913
  function useChartState(controller) {
13882
- return (0, import_react101.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
13914
+ return (0, import_react102.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
13883
13915
  }
13884
13916
 
13885
13917
  // src/chart/ChartCanvas.tsx
@@ -13931,7 +13963,7 @@ function renderChartMark(mark, fontFamily, interactive) {
13931
13963
  }
13932
13964
  }
13933
13965
  function ChartPresenceLayer({ presence }) {
13934
- const { actors } = (0, import_react102.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
13966
+ const { actors } = (0, import_react103.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
13935
13967
  return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("g", { "data-chart-presence": "", pointerEvents: "none", children: actors.map((a) => /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("g", { transform: `translate(${a.x} ${a.y})`, "data-actor": a.id, children: [
13936
13968
  /* @__PURE__ */ (0, import_jsx_runtime77.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 }, transform: a.pressed ? "scale(0.9)" : void 0 }),
13937
13969
  /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("g", { transform: "translate(13 16)", children: [
@@ -13952,15 +13984,15 @@ function ChartTooltipContent({ tooltip }) {
13952
13984
  }
13953
13985
  function ChartCanvas({ controller, width = 640, height = 400, responsive = true, theme, editable = true, measureText, emptyMessage, className, presence, sceneRef, tooltip = false, renderTooltip }) {
13954
13986
  const state = useChartState(controller);
13955
- const wrapper = (0, import_react102.useRef)(null);
13956
- const svg = (0, import_react102.useRef)(null);
13957
- const drag = (0, import_react102.useRef)(null);
13958
- const [measured, setMeasured] = (0, import_react102.useState)(null);
13959
- const [frozen, setFrozen] = (0, import_react102.useState)(null);
13987
+ const wrapper = (0, import_react103.useRef)(null);
13988
+ const svg = (0, import_react103.useRef)(null);
13989
+ const drag = (0, import_react103.useRef)(null);
13990
+ const [measured, setMeasured] = (0, import_react103.useState)(null);
13991
+ const [frozen, setFrozen] = (0, import_react103.useState)(null);
13960
13992
  const tooltipMode = tooltip === true ? "point" : tooltip || null;
13961
- const [tip, setTip] = (0, import_react102.useState)(null);
13962
- const [tipAt, setTipAt] = (0, import_react102.useState)({ left: 0, top: 0, flip: false });
13963
- (0, import_react102.useEffect)(() => {
13993
+ const [tip, setTip] = (0, import_react103.useState)(null);
13994
+ const [tipAt, setTipAt] = (0, import_react103.useState)({ left: 0, top: 0, flip: false });
13995
+ (0, import_react103.useEffect)(() => {
13964
13996
  const el = wrapper.current;
13965
13997
  if (!responsive || !el || typeof ResizeObserver === "undefined") return;
13966
13998
  const observer = new ResizeObserver(([entry]) => {
@@ -13971,8 +14003,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
13971
14003
  return () => observer.disconnect();
13972
14004
  }, [responsive]);
13973
14005
  const sceneWidth = responsive && measured || width;
13974
- const fullTheme = (0, import_react102.useMemo)(() => ({ ...import_chart2.CSS_VARIABLE_CHART_THEME, ...theme }), [theme]);
13975
- const scene = (0, import_react102.useMemo)(
14006
+ const fullTheme = (0, import_react103.useMemo)(() => ({ ...import_chart2.CSS_VARIABLE_CHART_THEME, ...theme }), [theme]);
14007
+ const scene = (0, import_react103.useMemo)(
13976
14008
  () => (0, import_chart2.layoutChart)(state.spec, {
13977
14009
  width: sceneWidth,
13978
14010
  height,
@@ -13989,8 +14021,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
13989
14021
  [state.spec, state.selection, state.raceFrame, sceneWidth, height, fullTheme, editable, measureText, emptyMessage, frozen]
13990
14022
  );
13991
14023
  if (sceneRef) sceneRef.current = scene;
13992
- const byKey = (0, import_react102.useMemo)(() => new Map(scene.marks.map((m) => [m.key, m])), [scene]);
13993
- (0, import_react102.useEffect)(() => () => drag.current?.end(), []);
14024
+ const byKey = (0, import_react103.useMemo)(() => new Map(scene.marks.map((m) => [m.key, m])), [scene]);
14025
+ (0, import_react103.useEffect)(() => () => drag.current?.end(), []);
13994
14026
  const scenePoint = (e) => (0, import_chart2.chartClientToScene)(scene, svg.current.getBoundingClientRect(), e.clientX, e.clientY);
13995
14027
  const onPointerDown = (e) => {
13996
14028
  if (!editable || e.button !== 0) return;
@@ -14083,7 +14115,7 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
14083
14115
  }
14084
14116
 
14085
14117
  // src/chart/ChartDataGrid.tsx
14086
- var import_react103 = require("react");
14118
+ var import_react104 = require("react");
14087
14119
  var import_chart3 = require("@pixerate/editor/chart");
14088
14120
 
14089
14121
  // src/chart/styles.ts
@@ -14098,9 +14130,9 @@ var chartCellClass = "h-7 w-full min-w-[4.5rem] bg-transparent px-2 text-right t
14098
14130
  // src/chart/ChartDataGrid.tsx
14099
14131
  var import_jsx_runtime78 = require("react/jsx-runtime");
14100
14132
  function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
14101
- const [draft, setDraft] = (0, import_react103.useState)(value);
14102
- const typing = (0, import_react103.useRef)(false);
14103
- (0, import_react103.useEffect)(() => {
14133
+ const [draft, setDraft] = (0, import_react104.useState)(value);
14134
+ const typing = (0, import_react104.useRef)(false);
14135
+ (0, import_react104.useEffect)(() => {
14104
14136
  if (!typing.current) setDraft(value);
14105
14137
  }, [value]);
14106
14138
  const commit = () => {
@@ -14138,7 +14170,7 @@ function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
14138
14170
  }
14139
14171
  function ChartTreeGrid({ controller, readOnly = false, className }) {
14140
14172
  const { spec } = useChartState(controller);
14141
- const [columns, setColumns] = (0, import_react103.useState)(1);
14173
+ const [columns, setColumns] = (0, import_react104.useState)(1);
14142
14174
  const rows = (0, import_chart3.chartTreeToRows)(spec.tree);
14143
14175
  const depth = Math.max(columns, (0, import_chart3.chartTreeDepth)(spec.tree));
14144
14176
  const labels = (0, import_chart3.chartTreeColumnLabels)(depth);
@@ -14326,7 +14358,7 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
14326
14358
  }
14327
14359
 
14328
14360
  // src/chart/ChartInspector.tsx
14329
- var import_react104 = require("react");
14361
+ var import_react105 = require("react");
14330
14362
  var import_chart4 = require("@pixerate/editor/chart");
14331
14363
  var import_jsx_runtime79 = require("react/jsx-runtime");
14332
14364
  var cap = (s) => s.charAt(0).toUpperCase() + s.slice(1);
@@ -14491,7 +14523,7 @@ function ErrorBarFields({ controller, series, which, idBase }) {
14491
14523
  }
14492
14524
  function ChartInspector({ controller, sections, className, swatches }) {
14493
14525
  const { spec, selectedSeries, selection, raceFrame, racePlaying } = useChartState(controller);
14494
- const idBase = (0, import_react104.useId)();
14526
+ const idBase = (0, import_react105.useId)();
14495
14527
  const show = (section) => !sections || sections.includes(section);
14496
14528
  const cartesian = (0, import_chart4.isCartesianChart)(spec.type);
14497
14529
  const family = (0, import_chart4.chartFamily)(spec);
@@ -14849,12 +14881,12 @@ function createReactChartNodeView(options = {}) {
14849
14881
  }
14850
14882
 
14851
14883
  // src/style/useStyle.ts
14852
- var import_react105 = require("react");
14853
- var import_tools5 = require("@pixerate/editor/tools");
14884
+ var import_react106 = require("react");
14885
+ var import_tools6 = require("@pixerate/editor/tools");
14854
14886
  var import_editor22 = require("@pixerate/editor");
14855
14887
  var message = (error) => error instanceof Error ? error.message : String(error);
14856
14888
  function useResolverTask(styles, run, deliver, deps) {
14857
- (0, import_react105.useEffect)(() => {
14889
+ (0, import_react106.useEffect)(() => {
14858
14890
  if (!styles || !run) {
14859
14891
  deliver({ value: null, error: null });
14860
14892
  return;
@@ -14881,7 +14913,7 @@ function useResolverTask(styles, run, deliver, deps) {
14881
14913
  }, [styles, ...deps]);
14882
14914
  }
14883
14915
  function useStyle(styles, domain) {
14884
- const [result, setResult] = (0, import_react105.useState)({ style: null, error: null });
14916
+ const [result, setResult] = (0, import_react106.useState)({ style: null, error: null });
14885
14917
  useResolverTask(
14886
14918
  styles,
14887
14919
  (s) => s.resolve(domain),
@@ -14891,7 +14923,7 @@ function useStyle(styles, domain) {
14891
14923
  return result;
14892
14924
  }
14893
14925
  function useStyleFindings(styles, domain, state, scope) {
14894
- const [result, setResult] = (0, import_react105.useState)({ report: null, style: null, error: null });
14926
+ const [result, setResult] = (0, import_react106.useState)({ report: null, style: null, error: null });
14895
14927
  useResolverTask(
14896
14928
  styles,
14897
14929
  (s) => s.check(domain, state, scope !== void 0 ? { scope } : {}),
@@ -14907,14 +14939,14 @@ function useStyleFindings(styles, domain, state, scope) {
14907
14939
  return result;
14908
14940
  }
14909
14941
  function useStyleChoices(styles, scope) {
14910
- const [state, setState] = (0, import_react105.useState)({ groups: null, error: null });
14942
+ const [state, setState] = (0, import_react106.useState)({ groups: null, error: null });
14911
14943
  useResolverTask(
14912
14944
  styles,
14913
14945
  (s) => s.choices(scope !== void 0 ? { scope } : {}),
14914
14946
  ({ value, error }) => setState({ groups: value, error }),
14915
14947
  [scope]
14916
14948
  );
14917
- const choose = (0, import_react105.useCallback)(
14949
+ const choose = (0, import_react106.useCallback)(
14918
14950
  async (name, options = {}) => {
14919
14951
  if (!styles) throw new Error("There is no style resolver to choose with.");
14920
14952
  try {
@@ -14929,21 +14961,21 @@ function useStyleChoices(styles, scope) {
14929
14961
  return { ...state, choose };
14930
14962
  }
14931
14963
  function useStyleSwatches(styles, domain, scope) {
14932
- const [state, setState] = (0, import_react105.useState)({ style: null, error: null });
14964
+ const [state, setState] = (0, import_react106.useState)({ style: null, error: null });
14933
14965
  useResolverTask(
14934
14966
  styles,
14935
14967
  (s) => s.resolve(domain, scope !== void 0 ? { scope } : {}),
14936
14968
  ({ value, error }) => setState({ style: value, error }),
14937
14969
  [domain, scope]
14938
14970
  );
14939
- return (0, import_react105.useMemo)(() => {
14940
- const { colors, fonts } = state.style ? (0, import_tools5.styleSwatches)(state.style) : { colors: [], fonts: [] };
14971
+ return (0, import_react106.useMemo)(() => {
14972
+ const { colors, fonts } = state.style ? (0, import_tools6.styleSwatches)(state.style) : { colors: [], fonts: [] };
14941
14973
  return { colors: colors.map((c) => c.color), swatches: colors, fonts, error: state.error };
14942
14974
  }, [state]);
14943
14975
  }
14944
14976
  function useRichTextStyleFindings(styles, editor, scope) {
14945
- const [doc, setDoc] = (0, import_react105.useState)(() => editor?.state.doc ?? null);
14946
- (0, import_react105.useEffect)(() => {
14977
+ const [doc, setDoc] = (0, import_react106.useState)(() => editor?.state.doc ?? null);
14978
+ (0, import_react106.useEffect)(() => {
14947
14979
  if (!editor) {
14948
14980
  setDoc(null);
14949
14981
  return;
@@ -14955,7 +14987,7 @@ function useRichTextStyleFindings(styles, editor, scope) {
14955
14987
  editor.off("update", onUpdate);
14956
14988
  };
14957
14989
  }, [editor]);
14958
- const state = (0, import_react105.useMemo)(() => doc ? (0, import_editor22.richTextStyleState)(doc) : null, [doc]);
14990
+ const state = (0, import_react106.useMemo)(() => doc ? (0, import_editor22.richTextStyleState)(doc) : null, [doc]);
14959
14991
  return useStyleFindings(state ? styles : null, "rich-text", state, scope);
14960
14992
  }
14961
14993
 
@@ -15120,6 +15152,7 @@ function StyleFindings({ report, onSelect, title = "House style", className = ""
15120
15152
  useImageEffectsTools,
15121
15153
  useImageHistogram,
15122
15154
  useJobProgress,
15155
+ useLinkFocus,
15123
15156
  useMergePreview,
15124
15157
  useNavigationGuard,
15125
15158
  useOutline,