@pixerate/editor-react 0.209.1 → 0.210.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -155,6 +155,8 @@ __export(src_exports, {
155
155
  useStyleFindings: () => useStyleFindings,
156
156
  useStyleSwatches: () => useStyleSwatches,
157
157
  useTableMenu: () => useTableMenu,
158
+ useTextChangeFeed: () => useTextChangeFeed,
159
+ useTextProposals: () => useTextProposals,
158
160
  useToolBridge: () => useToolBridge,
159
161
  useToolRegistryView: () => useToolRegistryView,
160
162
  useTrackChanges: () => useTrackChanges,
@@ -651,20 +653,86 @@ function useAgentToolProvider(registry, provider, options = {}) {
651
653
  }, [registry, provider]);
652
654
  }
653
655
 
654
- // src/hooks/useRichTextEditorDocument.ts
656
+ // src/hooks/useTextProposals.ts
655
657
  var import_react13 = require("react");
658
+ var import_tools2 = require("@pixerate/editor/tools");
659
+ function useTextProposals(options) {
660
+ const latest = (0, import_react13.useRef)(options);
661
+ latest.current = options;
662
+ const storeRef = (0, import_react13.useRef)(null);
663
+ if (storeRef.current === null) {
664
+ storeRef.current = (0, import_tools2.createTextProposals)({
665
+ getText: () => latest.current.text,
666
+ applyEdit: (edit, step) => latest.current.applyEdit(edit, step),
667
+ readOnly: () => latest.current.readOnly?.() ?? false,
668
+ origin: options.origin,
669
+ idGenerator: options.idGenerator,
670
+ now: options.now
671
+ });
672
+ }
673
+ const store = storeRef.current;
674
+ const state = (0, import_react13.useSyncExternalStore)(store.subscribe, store.getState, store.getState);
675
+ (0, import_react13.useEffect)(() => {
676
+ store.sync();
677
+ }, [store, options.text]);
678
+ return (0, import_react13.useMemo)(
679
+ () => ({
680
+ store,
681
+ proposals: state.proposals,
682
+ propose: store.propose,
683
+ accept: store.accept,
684
+ reject: store.reject,
685
+ clear: store.clear
686
+ }),
687
+ [store, state]
688
+ );
689
+ }
690
+ function useTextChangeFeed(options) {
691
+ const latest = (0, import_react13.useRef)(options);
692
+ latest.current = options;
693
+ const [last, setLast] = (0, import_react13.useState)(null);
694
+ const feed = (0, import_react13.useMemo)(
695
+ () => (0, import_tools2.createTextChangeFeed)({
696
+ getText: () => latest.current.text,
697
+ getSelection: () => latest.current.selection ?? null,
698
+ burstMs: options.burstMs
699
+ }),
700
+ []
701
+ );
702
+ (0, import_react13.useEffect)(
703
+ () => feed.subscribe((change) => {
704
+ setLast(change);
705
+ latest.current.onChange?.(change);
706
+ }),
707
+ [feed]
708
+ );
709
+ (0, import_react13.useEffect)(() => options.history?.onCommit(feed.noteCommit), [feed, options.history]);
710
+ (0, import_react13.useEffect)(
711
+ () => () => {
712
+ feed.endGesture();
713
+ },
714
+ [feed]
715
+ );
716
+ (0, import_react13.useEffect)(() => {
717
+ feed.check();
718
+ }, [feed, options.text, options.selection?.from, options.selection?.to]);
719
+ return { feed, last };
720
+ }
721
+
722
+ // src/hooks/useRichTextEditorDocument.ts
723
+ var import_react14 = require("react");
656
724
  var import_editor6 = require("@pixerate/editor");
657
725
  function useRichTextEditorDocument(editor) {
658
- const doc = (0, import_react13.useMemo)(() => editor ? (0, import_editor6.createRichTextEditorDocument)(editor) : null, [editor]);
659
- (0, import_react13.useEffect)(() => () => doc?.destroy(), [doc]);
726
+ const doc = (0, import_react14.useMemo)(() => editor ? (0, import_editor6.createRichTextEditorDocument)(editor) : null, [editor]);
727
+ (0, import_react14.useEffect)(() => () => doc?.destroy(), [doc]);
660
728
  return doc;
661
729
  }
662
730
 
663
731
  // src/playback/PresenceLayer.tsx
664
- var import_react14 = __toESM(require("react"), 1);
732
+ var import_react15 = __toESM(require("react"), 1);
665
733
  var import_jsx_runtime3 = require("react/jsx-runtime");
666
734
  function PresenceLayer({ presence, viewport, clip = true, renderCursor, className = "" }) {
667
- const { actors } = (0, import_react14.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
735
+ const { actors } = (0, import_react15.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
668
736
  if (!actors.length) return null;
669
737
  const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
670
738
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -681,7 +749,7 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
681
749
  const br = map({ x: a.focus.x + a.focus.width, y: a.focus.y + a.focus.height });
682
750
  return { left: tl.x - 4, top: tl.y - 4, width: br.x - tl.x + 8, height: br.y - tl.y + 8 };
683
751
  })();
684
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react14.default.Fragment, { children: [
752
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react15.default.Fragment, { children: [
685
753
  ring && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
686
754
  "div",
687
755
  {
@@ -703,27 +771,27 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
703
771
  }
704
772
 
705
773
  // src/playback/AgentPlaybackContext.tsx
706
- var import_react15 = require("react");
774
+ var import_react16 = require("react");
707
775
  var import_jsx_runtime4 = require("react/jsx-runtime");
708
- var AgentPlaybackContext = (0, import_react15.createContext)(null);
776
+ var AgentPlaybackContext = (0, import_react16.createContext)(null);
709
777
  function AgentPlaybackProvider({ playback, children }) {
710
778
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AgentPlaybackContext.Provider, { value: playback ?? null, children });
711
779
  }
712
780
  function useAgentPlayback() {
713
- return (0, import_react15.useContext)(AgentPlaybackContext);
781
+ return (0, import_react16.useContext)(AgentPlaybackContext);
714
782
  }
715
783
 
716
784
  // src/playback/usePlaybackSurface.ts
717
- var import_react16 = require("react");
718
- var import_tools2 = require("@pixerate/editor/tools");
785
+ var import_react17 = require("react");
786
+ var import_tools3 = require("@pixerate/editor/tools");
719
787
  function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
720
788
  const ambient = useAgentPlayback();
721
789
  const target = playback === void 0 ? ambient : playback;
722
- const [ownPresence] = (0, import_react16.useState)(() => new import_tools2.PresenceStore());
790
+ const [ownPresence] = (0, import_react17.useState)(() => new import_tools3.PresenceStore());
723
791
  const presence = sharedPresence ?? ownPresence;
724
- const latest = (0, import_react16.useRef)(options);
792
+ const latest = (0, import_react17.useRef)(options);
725
793
  latest.current = options;
726
- (0, import_react16.useEffect)(() => {
794
+ (0, import_react17.useEffect)(() => {
727
795
  if (!target || !id) return;
728
796
  const o = () => latest.current;
729
797
  const surface = {
@@ -755,10 +823,10 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
755
823
  }
756
824
 
757
825
  // src/playback/useElementPlaybackSurface.ts
758
- var import_react17 = require("react");
759
- var import_tools3 = require("@pixerate/editor/tools");
826
+ var import_react18 = require("react");
827
+ var import_tools4 = require("@pixerate/editor/tools");
760
828
  function useElementPlaybackSurface(playback, id, element, options) {
761
- const latest = (0, import_react17.useRef)(options);
829
+ const latest = (0, import_react18.useRef)(options);
762
830
  latest.current = options;
763
831
  const box = () => element.current?.getBoundingClientRect() ?? null;
764
832
  const fromViewport = (p) => {
@@ -774,7 +842,7 @@ function useElementPlaybackSurface(playback, id, element, options) {
774
842
  const b = box();
775
843
  const r = selector ? element.current?.querySelector(selector)?.getBoundingClientRect() : null;
776
844
  if (b && r && r.width > 0) return { x: r.left - b.left, y: r.top - b.top, width: r.width, height: r.height };
777
- return (0, import_tools3.locatePlaybackChrome)(ref, latest.current, fromViewport);
845
+ return (0, import_tools4.locatePlaybackChrome)(ref, latest.current, fromViewport);
778
846
  },
779
847
  bounds: () => {
780
848
  const r = box();
@@ -797,18 +865,18 @@ function useElementPlaybackSurface(playback, id, element, options) {
797
865
  }
798
866
 
799
867
  // src/hooks/useToolBridge.ts
800
- var import_react18 = require("react");
801
- var import_tools4 = require("@pixerate/editor/tools");
868
+ var import_react19 = require("react");
869
+ var import_tools5 = require("@pixerate/editor/tools");
802
870
  function useToolBridge(registry, options) {
803
- const [state, setState] = (0, import_react18.useState)({ status: "off", editorId: null });
871
+ const [state, setState] = (0, import_react19.useState)({ status: "off", editorId: null });
804
872
  const key = options ? JSON.stringify([options.url, options.token, options.name, options.kind, options.reconnect]) : null;
805
- (0, import_react18.useEffect)(() => {
873
+ (0, import_react19.useEffect)(() => {
806
874
  if (!registry || !options) {
807
875
  setState({ status: "off", editorId: null });
808
876
  return;
809
877
  }
810
878
  let connection;
811
- connection = (0, import_tools4.connectToolBridge)(registry, {
879
+ connection = (0, import_tools5.connectToolBridge)(registry, {
812
880
  ...options,
813
881
  onStatus: (status, detail) => {
814
882
  setState({ status, detail, editorId: connection?.editorId ?? null });
@@ -822,36 +890,36 @@ function useToolBridge(registry, options) {
822
890
  }
823
891
 
824
892
  // src/hooks/useToolRegistryView.ts
825
- var import_react19 = require("react");
893
+ var import_react20 = require("react");
826
894
  function useToolRegistryView(registry, options = {}) {
827
895
  const { toolsets, readOnly, discovery } = options;
828
- const view = (0, import_react19.useMemo)(
896
+ const view = (0, import_react20.useMemo)(
829
897
  () => registry ? registry.view({ toolsets, readOnly, discovery }) : null,
830
898
  // toolsets is applied below without making a new view, so enabled tools survive.
831
899
  // eslint-disable-next-line react-hooks/exhaustive-deps
832
900
  [registry, readOnly, discovery]
833
901
  );
834
902
  const toolsetsKey = typeof toolsets === "function" ? toolsets : JSON.stringify(toolsets ?? null);
835
- (0, import_react19.useEffect)(() => {
903
+ (0, import_react20.useEffect)(() => {
836
904
  view?.setToolsets(toolsets);
837
905
  }, [view, toolsetsKey]);
838
- (0, import_react19.useEffect)(() => () => view?.dispose(), [view]);
906
+ (0, import_react20.useEffect)(() => () => view?.dispose(), [view]);
839
907
  return view;
840
908
  }
841
909
 
842
910
  // src/components/EditorContent.tsx
843
- var import_react20 = require("@tiptap/react");
911
+ var import_react21 = require("@tiptap/react");
844
912
  var import_jsx_runtime5 = require("react/jsx-runtime");
845
913
  var EditorContent = ({
846
914
  className,
847
915
  editor,
848
916
  ...props
849
917
  }) => {
850
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react20.EditorContent, { editor, ...props }) });
918
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react21.EditorContent, { editor, ...props }) });
851
919
  };
852
920
 
853
921
  // src/components/BubbleMenu.tsx
854
- var import_react21 = require("react");
922
+ var import_react22 = require("react");
855
923
  var import_react_dom = require("react-dom");
856
924
  var import_extension_bubble_menu = require("@tiptap/extension-bubble-menu");
857
925
  var BubbleMenu = ({
@@ -863,12 +931,12 @@ var BubbleMenu = ({
863
931
  pluginKey = "bubbleMenu",
864
932
  updateDelay
865
933
  }) => {
866
- const menuEl = (0, import_react21.useRef)(null);
867
- const [mounted, setMounted] = (0, import_react21.useState)(false);
934
+ const menuEl = (0, import_react22.useRef)(null);
935
+ const [mounted, setMounted] = (0, import_react22.useState)(false);
868
936
  if (!menuEl.current && typeof document !== "undefined") {
869
937
  menuEl.current = document.createElement("div");
870
938
  }
871
- (0, import_react21.useEffect)(() => {
939
+ (0, import_react22.useEffect)(() => {
872
940
  if (!editor || !menuEl.current || editor.isDestroyed) {
873
941
  return;
874
942
  }
@@ -899,7 +967,7 @@ var BubbleMenu = ({
899
967
  };
900
968
 
901
969
  // src/components/TemplateRenderer.tsx
902
- var import_react22 = require("react");
970
+ var import_react23 = require("react");
903
971
  var import_editor7 = require("@pixerate/editor");
904
972
  var import_jsx_runtime6 = require("react/jsx-runtime");
905
973
  var TemplateRenderer = ({
@@ -913,11 +981,11 @@ var TemplateRenderer = ({
913
981
  onTemplateClick,
914
982
  onVariableClick
915
983
  }) => {
916
- const displayText = (0, import_react22.useMemo)(() => {
984
+ const displayText = (0, import_react23.useMemo)(() => {
917
985
  if (!resolve || templates.length === 0) return content;
918
986
  return (0, import_editor7.resolveTemplates)(content, templates, { bindings });
919
987
  }, [content, templates, resolve, bindings]);
920
- const tokens = (0, import_react22.useMemo)(() => {
988
+ const tokens = (0, import_react23.useMemo)(() => {
921
989
  return (0, import_editor7.evaluatePromptTokens)(displayText, values);
922
990
  }, [displayText, values]);
923
991
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className, children: tokens.map((token, index) => {
@@ -1006,7 +1074,7 @@ var TemplateRenderer = ({
1006
1074
  };
1007
1075
 
1008
1076
  // src/components/VariableForm.tsx
1009
- var import_react23 = require("react");
1077
+ var import_react24 = require("react");
1010
1078
  var import_editor8 = require("@pixerate/editor");
1011
1079
  var import_jsx_runtime7 = require("react/jsx-runtime");
1012
1080
  var VariableForm = ({
@@ -1018,12 +1086,12 @@ var VariableForm = ({
1018
1086
  onChange,
1019
1087
  className = "flex flex-col gap-3 text-sm"
1020
1088
  }) => {
1021
- const idPrefix = (0, import_react23.useId)();
1022
- const [internal, setInternal] = (0, import_react23.useState)(
1089
+ const idPrefix = (0, import_react24.useId)();
1090
+ const [internal, setInternal] = (0, import_react24.useState)(
1023
1091
  () => defaultValues ?? {}
1024
1092
  );
1025
1093
  const entered = values ?? internal;
1026
- const fields = (0, import_react23.useMemo)(
1094
+ const fields = (0, import_react24.useMemo)(
1027
1095
  () => (0, import_editor8.getVariableFormFields)(content, { templates, bindings }),
1028
1096
  [content, templates, bindings]
1029
1097
  );
@@ -1091,26 +1159,26 @@ var VariableForm = ({
1091
1159
  };
1092
1160
 
1093
1161
  // src/components/MergePreview.tsx
1094
- var import_react25 = require("react");
1162
+ var import_react26 = require("react");
1095
1163
 
1096
1164
  // src/hooks/useMergePreview.ts
1097
- var import_react24 = require("react");
1165
+ var import_react25 = require("react");
1098
1166
  var import_editor9 = require("@pixerate/editor");
1099
1167
  function useMergePreview(options) {
1100
1168
  const { template, templates, bindings, parseOptions } = options;
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)(
1169
+ const [sourceText, setSourceTextState] = (0, import_react25.useState)(options.initialSource ?? "");
1170
+ const [overrides, setOverrides] = (0, import_react25.useState)({});
1171
+ const [index, setIndexState] = (0, import_react25.useState)(0);
1172
+ const [result, setResult] = (0, import_react25.useState)(null);
1173
+ const source = (0, import_react25.useMemo)(
1106
1174
  () => (0, import_editor9.parseDataSource)(sourceText, parseOptions),
1107
1175
  [sourceText, parseOptions]
1108
1176
  );
1109
- const variables = (0, import_react24.useMemo)(
1177
+ const variables = (0, import_react25.useMemo)(
1110
1178
  () => (0, import_editor9.extractVariables)(template, { templates, bindings }).map((v) => v.name),
1111
1179
  [template, templates, bindings]
1112
1180
  );
1113
- const mapping = (0, import_react24.useMemo)(() => {
1181
+ const mapping = (0, import_react25.useMemo)(() => {
1114
1182
  const merged = {
1115
1183
  ...(0, import_editor9.matchFields)(variables, source.fields).mapping
1116
1184
  };
@@ -1124,29 +1192,29 @@ function useMergePreview(options) {
1124
1192
  const count = source.records.length;
1125
1193
  const current = count === 0 ? 0 : Math.min(index, count - 1);
1126
1194
  const record = source.records[current];
1127
- const values = (0, import_react24.useMemo)(
1195
+ const values = (0, import_react25.useMemo)(
1128
1196
  () => record ? (0, import_editor9.recordToValues)(record, mapping) : {},
1129
1197
  [record, mapping]
1130
1198
  );
1131
- const setSourceText = (0, import_react24.useCallback)((text) => {
1199
+ const setSourceText = (0, import_react25.useCallback)((text) => {
1132
1200
  setSourceTextState(text);
1133
1201
  setIndexState(0);
1134
1202
  setResult(null);
1135
1203
  }, []);
1136
- const loadFile = (0, import_react24.useCallback)(
1204
+ const loadFile = (0, import_react25.useCallback)(
1137
1205
  async (file) => setSourceText(await file.text()),
1138
1206
  [setSourceText]
1139
1207
  );
1140
- const setIndex = (0, import_react24.useCallback)(
1208
+ const setIndex = (0, import_react25.useCallback)(
1141
1209
  (next) => setIndexState(Math.max(0, Math.min(next, count - 1))),
1142
1210
  [count]
1143
1211
  );
1144
- const setFieldMapping = (0, import_react24.useCallback)((variable, field) => {
1212
+ const setFieldMapping = (0, import_react25.useCallback)((variable, field) => {
1145
1213
  setOverrides((previous) => ({ ...previous, [variable]: field }));
1146
1214
  setResult(null);
1147
1215
  }, []);
1148
- const resetMapping = (0, import_react24.useCallback)(() => setOverrides({}), []);
1149
- const merge = (0, import_react24.useCallback)(() => {
1216
+ const resetMapping = (0, import_react25.useCallback)(() => setOverrides({}), []);
1217
+ const merge = (0, import_react25.useCallback)(() => {
1150
1218
  const merged = (0, import_editor9.mergeRecords)(template, source, {
1151
1219
  templates,
1152
1220
  bindings,
@@ -1158,7 +1226,7 @@ function useMergePreview(options) {
1158
1226
  setResult(merged);
1159
1227
  return merged;
1160
1228
  }, [template, source, templates, bindings, mapping, options.skipIf, options.separator, options.maxOutputs]);
1161
- const serialize = (0, import_react24.useCallback)(
1229
+ const serialize = (0, import_react25.useCallback)(
1162
1230
  (format) => result ? (0, import_editor9.serializeMergeOutputs)(result.outputs, format, options.separator) : "",
1163
1231
  [result, options.separator]
1164
1232
  );
@@ -1211,7 +1279,7 @@ var MergePreview = ({
1211
1279
  downloadName = "merged",
1212
1280
  className = "flex flex-col gap-3 text-sm"
1213
1281
  }) => {
1214
- const id = (0, import_react25.useId)();
1282
+ const id = (0, import_react26.useId)();
1215
1283
  const merge = useMergePreview({
1216
1284
  template: content,
1217
1285
  templates,
@@ -1222,7 +1290,7 @@ var MergePreview = ({
1222
1290
  separator,
1223
1291
  maxOutputs
1224
1292
  });
1225
- const [copied, setCopied] = (0, import_react25.useState)(false);
1293
+ const [copied, setCopied] = (0, import_react26.useState)(false);
1226
1294
  const { source, result } = merge;
1227
1295
  const copy = async () => {
1228
1296
  try {
@@ -1379,11 +1447,11 @@ var MergePreview = ({
1379
1447
  };
1380
1448
 
1381
1449
  // src/hooks/useOutline.ts
1382
- var import_react26 = require("react");
1450
+ var import_react27 = require("react");
1383
1451
  var import_editor10 = require("@pixerate/editor");
1384
1452
  function useOutline(editor) {
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);
1453
+ const store = (0, import_react27.useMemo)(() => (0, import_editor10.createOutlineStore)(editor), [editor]);
1454
+ return (0, import_react27.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
1387
1455
  }
1388
1456
 
1389
1457
  // src/components/OutlinePanel.tsx
@@ -1428,12 +1496,12 @@ var OutlinePanel = ({
1428
1496
  };
1429
1497
 
1430
1498
  // src/hooks/useParagraphStyles.ts
1431
- var import_react27 = require("react");
1499
+ var import_react28 = require("react");
1432
1500
  var import_editor12 = require("@pixerate/editor");
1433
1501
  function useParagraphStyles(editor) {
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)(() => {
1502
+ const store = (0, import_react28.useMemo)(() => (0, import_editor12.createParagraphStylesStore)(editor), [editor]);
1503
+ const snapshot = (0, import_react28.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
1504
+ return (0, import_react28.useMemo)(() => {
1437
1505
  const registry = (0, import_editor12.getStyleRegistry)(editor);
1438
1506
  const live = () => editor && !editor.isDestroyed ? editor : null;
1439
1507
  return {
@@ -1456,7 +1524,7 @@ function useParagraphStyles(editor) {
1456
1524
  }
1457
1525
 
1458
1526
  // src/components/StylesGallery.tsx
1459
- var import_react28 = require("react");
1527
+ var import_react29 = require("react");
1460
1528
  var import_jsx_runtime10 = require("react/jsx-runtime");
1461
1529
  var camel = (property) => property.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
1462
1530
  var keepSelection = (event) => event.preventDefault();
@@ -1472,9 +1540,9 @@ var StylesGallery = ({
1472
1540
  onChange
1473
1541
  }) => {
1474
1542
  const styles = useParagraphStyles(editor);
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)("");
1543
+ const [open, setOpen] = (0, import_react29.useState)(false);
1544
+ const [creating, setCreating] = (0, import_react29.useState)(false);
1545
+ const [name, setName] = (0, import_react29.useState)("");
1478
1546
  const list = showAllStyles ? styles.styles : styles.gallery;
1479
1547
  const current = styles.currentStyle;
1480
1548
  const expanded = variant === "gallery" || open;
@@ -1590,13 +1658,13 @@ var StylesGallery = ({
1590
1658
  var import_editor24 = require("@pixerate/editor");
1591
1659
 
1592
1660
  // src/spreadsheet/useSpreadsheetEditor.ts
1593
- var import_react29 = require("react");
1661
+ var import_react30 = require("react");
1594
1662
  var import_spreadsheet = require("@pixerate/editor/spreadsheet");
1595
1663
  function useSpreadsheetEditor(options = {}) {
1596
- const optionsRef = (0, import_react29.useRef)(options);
1664
+ const optionsRef = (0, import_react30.useRef)(options);
1597
1665
  optionsRef.current = options;
1598
- const settersRef = (0, import_react29.useRef)({});
1599
- const [controller] = (0, import_react29.useState)(
1666
+ const settersRef = (0, import_react30.useRef)({});
1667
+ const [controller] = (0, import_react30.useState)(
1600
1668
  () => new import_spreadsheet.SpreadsheetController({
1601
1669
  ...options,
1602
1670
  onDocumentChange: (updated) => {
@@ -1613,37 +1681,37 @@ function useSpreadsheetEditor(options = {}) {
1613
1681
  }
1614
1682
  })
1615
1683
  );
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);
1684
+ const [doc, setDoc] = (0, import_react30.useState)(() => ({ ...controller.document }));
1685
+ const [activeCell, setActiveCell] = (0, import_react30.useState)(controller.activeCell);
1686
+ const [selectedRange, setSelectedRange] = (0, import_react30.useState)(controller.selectedRange);
1687
+ const [editingCell, setEditingCell] = (0, import_react30.useState)(null);
1688
+ const [draftValue, setDraftState] = (0, import_react30.useState)("");
1689
+ const [validationPrompt, setValidationPrompt] = (0, import_react30.useState)(null);
1622
1690
  settersRef.current = { setDoc, setActiveCell, setSelectedRange };
1623
- const setDraftValue = (0, import_react29.useCallback)((value) => {
1691
+ const setDraftValue = (0, import_react30.useCallback)((value) => {
1624
1692
  controller.draftValue = value;
1625
1693
  setDraftState(value);
1626
1694
  }, [controller]);
1627
- const setCellValue = (0, import_react29.useCallback)((rowId, colId, raw) => {
1695
+ const setCellValue = (0, import_react30.useCallback)((rowId, colId, raw) => {
1628
1696
  controller.setCellValue(rowId, colId, raw);
1629
1697
  setDoc({ ...controller.document });
1630
1698
  }, [controller]);
1631
- const selectCell = (0, import_react29.useCallback)((row, col, extendSelection = false) => {
1699
+ const selectCell = (0, import_react30.useCallback)((row, col, extendSelection = false) => {
1632
1700
  controller.selectCell(row, col, extendSelection);
1633
1701
  setActiveCell(controller.activeCell);
1634
1702
  setSelectedRange(controller.selectedRange);
1635
1703
  }, [controller]);
1636
- const selectRange = (0, import_react29.useCallback)((range) => {
1704
+ const selectRange = (0, import_react30.useCallback)((range) => {
1637
1705
  controller.selectRange(range);
1638
1706
  setSelectedRange(controller.selectedRange);
1639
1707
  }, [controller]);
1640
- const startEditing = (0, import_react29.useCallback)((row, col, initialVal) => {
1708
+ const startEditing = (0, import_react30.useCallback)((row, col, initialVal) => {
1641
1709
  controller.startEditing(row, col, initialVal);
1642
1710
  setActiveCell(controller.activeCell);
1643
1711
  setEditingCell(controller.editingCell);
1644
1712
  setDraftValue(controller.draftValue);
1645
1713
  }, [controller]);
1646
- const syncEditing = (0, import_react29.useCallback)(() => {
1714
+ const syncEditing = (0, import_react30.useCallback)(() => {
1647
1715
  setEditingCell(controller.editingCell);
1648
1716
  setDraftValue(controller.draftValue);
1649
1717
  setValidationPrompt(controller.validationPrompt);
@@ -1651,90 +1719,90 @@ function useSpreadsheetEditor(options = {}) {
1651
1719
  setSelectedRange(controller.selectedRange);
1652
1720
  setDoc({ ...controller.document });
1653
1721
  }, [controller]);
1654
- const commitEditing = (0, import_react29.useCallback)((val) => {
1722
+ const commitEditing = (0, import_react30.useCallback)((val) => {
1655
1723
  const result = controller.commitEditing(val);
1656
1724
  syncEditing();
1657
1725
  return result;
1658
1726
  }, [controller, syncEditing]);
1659
- const commitCellInput = (0, import_react29.useCallback)((rowId, colId, raw) => {
1727
+ const commitCellInput = (0, import_react30.useCallback)((rowId, colId, raw) => {
1660
1728
  const result = controller.commitCellInput(rowId, colId, raw);
1661
1729
  syncEditing();
1662
1730
  return result;
1663
1731
  }, [controller, syncEditing]);
1664
- const resolveValidationPrompt = (0, import_react29.useCallback)((action) => {
1732
+ const resolveValidationPrompt = (0, import_react30.useCallback)((action) => {
1665
1733
  controller.resolveValidationPrompt(action);
1666
1734
  syncEditing();
1667
1735
  }, [controller, syncEditing]);
1668
- const cancelEditing = (0, import_react29.useCallback)(() => {
1736
+ const cancelEditing = (0, import_react30.useCallback)(() => {
1669
1737
  controller.cancelEditing();
1670
1738
  setEditingCell(null);
1671
1739
  setDraftValue("");
1672
1740
  }, [controller]);
1673
- const moveCursor = (0, import_react29.useCallback)((dir, extend = false) => {
1741
+ const moveCursor = (0, import_react30.useCallback)((dir, extend = false) => {
1674
1742
  controller.moveCursor(dir, extend);
1675
1743
  setActiveCell(controller.activeCell);
1676
1744
  setSelectedRange(controller.selectedRange);
1677
1745
  }, [controller]);
1678
- const insertColumn = (0, import_react29.useCallback)((index, config) => {
1746
+ const insertColumn = (0, import_react30.useCallback)((index, config) => {
1679
1747
  controller.insertColumn(index, config);
1680
1748
  setDoc({ ...controller.document });
1681
1749
  }, [controller]);
1682
- const deleteColumn = (0, import_react29.useCallback)((colId) => {
1750
+ const deleteColumn = (0, import_react30.useCallback)((colId) => {
1683
1751
  controller.deleteColumn(colId);
1684
1752
  setDoc({ ...controller.document });
1685
1753
  }, [controller]);
1686
- const insertRow = (0, import_react29.useCallback)((index, config) => {
1754
+ const insertRow = (0, import_react30.useCallback)((index, config) => {
1687
1755
  controller.insertRow(index, config);
1688
1756
  setDoc({ ...controller.document });
1689
1757
  }, [controller]);
1690
- const deleteRow = (0, import_react29.useCallback)((rowId) => {
1758
+ const deleteRow = (0, import_react30.useCallback)((rowId) => {
1691
1759
  controller.deleteRow(rowId);
1692
1760
  setDoc({ ...controller.document });
1693
1761
  }, [controller]);
1694
- const setColumnWidth = (0, import_react29.useCallback)((colId, width) => {
1762
+ const setColumnWidth = (0, import_react30.useCallback)((colId, width) => {
1695
1763
  controller.setColumnWidth(colId, width);
1696
1764
  setDoc({ ...controller.document });
1697
1765
  }, [controller]);
1698
- const autoFitColumnWidth = (0, import_react29.useCallback)((colId, customWidth) => {
1766
+ const autoFitColumnWidth = (0, import_react30.useCallback)((colId, customWidth) => {
1699
1767
  controller.autoFitColumnWidth(colId, customWidth);
1700
1768
  setDoc({ ...controller.document });
1701
1769
  }, [controller]);
1702
- const registerDataSource = (0, import_react29.useCallback)((ds) => {
1770
+ const registerDataSource = (0, import_react30.useCallback)((ds) => {
1703
1771
  controller.registerDataSource(ds);
1704
1772
  setDoc({ ...controller.document });
1705
1773
  }, [controller]);
1706
- const setPrimaryDataSource = (0, import_react29.useCallback)((id) => {
1774
+ const setPrimaryDataSource = (0, import_react30.useCallback)((id) => {
1707
1775
  controller.setPrimaryDataSource(id);
1708
1776
  setDoc({ ...controller.document });
1709
1777
  }, [controller]);
1710
- const recalculateAll = (0, import_react29.useCallback)(() => {
1778
+ const recalculateAll = (0, import_react30.useCallback)(() => {
1711
1779
  controller.recalculateAll();
1712
1780
  setDoc({ ...controller.document });
1713
1781
  }, [controller]);
1714
- const undo = (0, import_react29.useCallback)(() => {
1782
+ const undo = (0, import_react30.useCallback)(() => {
1715
1783
  controller.undo();
1716
1784
  setDoc({ ...controller.document });
1717
1785
  setActiveCell(controller.activeCell);
1718
1786
  setSelectedRange(controller.selectedRange);
1719
1787
  }, [controller]);
1720
- const redo = (0, import_react29.useCallback)(() => {
1788
+ const redo = (0, import_react30.useCallback)(() => {
1721
1789
  controller.redo();
1722
1790
  setDoc({ ...controller.document });
1723
1791
  setActiveCell(controller.activeCell);
1724
1792
  setSelectedRange(controller.selectedRange);
1725
1793
  }, [controller]);
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)(() => {
1794
+ const tableActions = (0, import_react30.useMemo)(() => (0, import_spreadsheet.bindSpreadsheetTableActions)(controller), [controller]);
1795
+ const viewModel = (0, import_react30.useMemo)(() => controller.getViewModel(), [controller, doc]);
1796
+ const sheets = (0, import_react30.useMemo)(() => controller.getSheets(), [controller, doc]);
1797
+ const names = (0, import_react30.useMemo)(() => controller.getNames(), [controller, doc]);
1798
+ const afterSheetSwitch = (0, import_react30.useCallback)(() => {
1731
1799
  setEditingCell(controller.editingCell);
1732
1800
  setDraftValue(controller.draftValue);
1733
1801
  setActiveCell(controller.activeCell);
1734
1802
  setSelectedRange(controller.selectedRange);
1735
1803
  setDoc({ ...controller.document });
1736
1804
  }, [controller, setDraftValue]);
1737
- const workbookActions = (0, import_react29.useMemo)(
1805
+ const workbookActions = (0, import_react30.useMemo)(
1738
1806
  () => ({
1739
1807
  setActiveSheet: (idOrName) => {
1740
1808
  const changed = controller.setActiveSheet(idOrName);
@@ -1764,9 +1832,9 @@ function useSpreadsheetEditor(options = {}) {
1764
1832
  }),
1765
1833
  [controller, afterSheetSwitch]
1766
1834
  );
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]);
1835
+ const conditionalFormatOverlay = (0, import_react30.useMemo)(() => controller.getConditionalFormatOverlay(), [controller, doc]);
1836
+ const editorDocument = (0, import_react30.useMemo)(() => (0, import_spreadsheet.createSpreadsheetEditorDocument)(controller), [controller]);
1837
+ (0, import_react30.useEffect)(() => () => editorDocument.destroy(), [editorDocument]);
1770
1838
  return {
1771
1839
  document: doc,
1772
1840
  activeCell,
@@ -1830,20 +1898,20 @@ function useSpreadsheetEditor(options = {}) {
1830
1898
  }
1831
1899
 
1832
1900
  // src/spreadsheet/SpreadsheetEditor.tsx
1833
- var import_react38 = require("react");
1901
+ var import_react39 = require("react");
1834
1902
  var import_spreadsheet8 = require("@pixerate/editor/spreadsheet");
1835
1903
 
1836
1904
  // src/spreadsheet/SpreadsheetContextMenu.tsx
1837
- var import_react30 = __toESM(require("react"), 1);
1905
+ var import_react31 = __toESM(require("react"), 1);
1838
1906
  var import_spreadsheet2 = require("@pixerate/editor/spreadsheet");
1839
1907
  var import_jsx_runtime11 = require("react/jsx-runtime");
1840
1908
  var VIEWPORT_MARGIN = 4;
1841
1909
  var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "Table actions" }) => {
1842
- const menuRef = (0, import_react30.useRef)(null);
1843
- const onCloseRef = (0, import_react30.useRef)(onClose);
1910
+ const menuRef = (0, import_react31.useRef)(null);
1911
+ const onCloseRef = (0, import_react31.useRef)(onClose);
1844
1912
  onCloseRef.current = onClose;
1845
- const [position, setPosition] = (0, import_react30.useState)({ x, y });
1846
- (0, import_react30.useLayoutEffect)(() => {
1913
+ const [position, setPosition] = (0, import_react31.useState)({ x, y });
1914
+ (0, import_react31.useLayoutEffect)(() => {
1847
1915
  const menu = menuRef.current;
1848
1916
  if (!menu || typeof window === "undefined") return;
1849
1917
  const { width, height } = menu.getBoundingClientRect();
@@ -1855,7 +1923,7 @@ var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "
1855
1923
  );
1856
1924
  setPosition((prev) => prev.x === next.x && prev.y === next.y ? prev : next);
1857
1925
  }, [x, y, items]);
1858
- (0, import_react30.useEffect)(() => {
1926
+ (0, import_react31.useEffect)(() => {
1859
1927
  const handlePointer = (e) => {
1860
1928
  if (!menuRef.current?.contains(e.target)) onCloseRef.current();
1861
1929
  };
@@ -1885,7 +1953,7 @@ var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "
1885
1953
  },
1886
1954
  onContextMenu: (e) => e.preventDefault(),
1887
1955
  onKeyDown: (e) => e.stopPropagation(),
1888
- children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react30.default.Fragment, { children: [
1956
+ children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react31.default.Fragment, { children: [
1889
1957
  item.separatorBefore && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { role: "separator", className: "my-1 h-px bg-border" }),
1890
1958
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1891
1959
  "button",
@@ -1910,7 +1978,7 @@ var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "
1910
1978
  };
1911
1979
 
1912
1980
  // src/spreadsheet/SpreadsheetGroupRow.tsx
1913
- var import_react31 = __toESM(require("react"), 1);
1981
+ var import_react32 = __toESM(require("react"), 1);
1914
1982
  var import_jsx_runtime12 = require("react/jsx-runtime");
1915
1983
  var formatSummary = (value) => value === null ? "\u2013" : String(value);
1916
1984
  var SpreadsheetGroupRow = ({
@@ -1944,7 +2012,7 @@ var SpreadsheetGroupRow = ({
1944
2012
  columns.map(({ column }, i) => {
1945
2013
  const summary = group.summaries[column.id];
1946
2014
  const before = leadingColumns !== void 0 && i === leadingColumns && leftSpace > 0 ? spacer("space:left") : null;
1947
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react31.default.Fragment, { children: [
2015
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react32.default.Fragment, { children: [
1948
2016
  before,
1949
2017
  /* @__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: [
1950
2018
  group.label,
@@ -1964,7 +2032,7 @@ var SpreadsheetGroupRow = ({
1964
2032
  };
1965
2033
 
1966
2034
  // src/spreadsheet/useSpreadsheetTableInteractions.ts
1967
- var import_react32 = require("react");
2035
+ var import_react33 = require("react");
1968
2036
  var import_spreadsheet3 = require("@pixerate/editor/spreadsheet");
1969
2037
  function gridHasFocus(grid) {
1970
2038
  if (!grid || typeof document === "undefined") return false;
@@ -1973,12 +2041,12 @@ function gridHasFocus(grid) {
1973
2041
  return !(active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement);
1974
2042
  }
1975
2043
  function useSpreadsheetClipboard(gridRef, state, readOnly) {
1976
- const stateRef = (0, import_react32.useRef)(state);
2044
+ const stateRef = (0, import_react33.useRef)(state);
1977
2045
  stateRef.current = state;
1978
- const readOnlyRef = (0, import_react32.useRef)(readOnly);
2046
+ const readOnlyRef = (0, import_react33.useRef)(readOnly);
1979
2047
  readOnlyRef.current = readOnly;
1980
- const copiedRef = (0, import_react32.useRef)(false);
1981
- (0, import_react32.useEffect)(() => {
2048
+ const copiedRef = (0, import_react33.useRef)(false);
2049
+ (0, import_react33.useEffect)(() => {
1982
2050
  if (typeof document === "undefined") return;
1983
2051
  const handleCopy = (e) => {
1984
2052
  const s = stateRef.current;
@@ -2001,7 +2069,7 @@ function useSpreadsheetClipboard(gridRef, state, readOnly) {
2001
2069
  document.removeEventListener("paste", handlePaste);
2002
2070
  };
2003
2071
  }, [gridRef]);
2004
- const copyShortcutFallback = (0, import_react32.useCallback)(() => {
2072
+ const copyShortcutFallback = (0, import_react33.useCallback)(() => {
2005
2073
  copiedRef.current = false;
2006
2074
  setTimeout(() => {
2007
2075
  if (copiedRef.current) return;
@@ -2013,13 +2081,13 @@ function useSpreadsheetClipboard(gridRef, state, readOnly) {
2013
2081
  return { copyShortcutFallback };
2014
2082
  }
2015
2083
  function useFillHandle(state) {
2016
- const [drag, setDrag] = (0, import_react32.useState)(null);
2017
- const dragRef = (0, import_react32.useRef)(drag);
2084
+ const [drag, setDrag] = (0, import_react33.useState)(null);
2085
+ const dragRef = (0, import_react33.useRef)(drag);
2018
2086
  dragRef.current = drag;
2019
- const stateRef = (0, import_react32.useRef)(state);
2087
+ const stateRef = (0, import_react33.useRef)(state);
2020
2088
  stateRef.current = state;
2021
2089
  const dragging = drag !== null;
2022
- (0, import_react32.useEffect)(() => {
2090
+ (0, import_react33.useEffect)(() => {
2023
2091
  if (!dragging) return;
2024
2092
  const handleMouseUp = () => {
2025
2093
  const current = dragRef.current;
@@ -2029,13 +2097,13 @@ function useFillHandle(state) {
2029
2097
  window.addEventListener("mouseup", handleMouseUp);
2030
2098
  return () => window.removeEventListener("mouseup", handleMouseUp);
2031
2099
  }, [dragging]);
2032
- const startFill = (0, import_react32.useCallback)((e) => {
2100
+ const startFill = (0, import_react33.useCallback)((e) => {
2033
2101
  e.preventDefault();
2034
2102
  e.stopPropagation();
2035
2103
  const range = stateRef.current.selectedRange;
2036
2104
  if (range) setDrag({ source: (0, import_spreadsheet3.normalizeRange)(range), target: null });
2037
2105
  }, []);
2038
- const extendFill = (0, import_react32.useCallback)((row, col) => {
2106
+ const extendFill = (0, import_react33.useCallback)((row, col) => {
2039
2107
  const current = dragRef.current;
2040
2108
  if (!current) return;
2041
2109
  setDrag({ source: current.source, target: (0, import_spreadsheet3.computeFillTarget)(current.source, { row, col }) });
@@ -2044,12 +2112,12 @@ function useFillHandle(state) {
2044
2112
  }
2045
2113
 
2046
2114
  // src/spreadsheet/SpreadsheetValidationDialog.tsx
2047
- var import_react33 = require("react");
2115
+ var import_react34 = require("react");
2048
2116
  var import_jsx_runtime13 = require("react/jsx-runtime");
2049
2117
  var SpreadsheetValidationDialog = ({ prompt, onResolve }) => {
2050
2118
  const style = prompt.result.errorStyle ?? "stop";
2051
- const firstButton = (0, import_react33.useRef)(null);
2052
- (0, import_react33.useEffect)(() => {
2119
+ const firstButton = (0, import_react34.useRef)(null);
2120
+ (0, import_react34.useEffect)(() => {
2053
2121
  firstButton.current?.focus();
2054
2122
  }, [prompt]);
2055
2123
  const buttons = style === "stop" ? [
@@ -2115,7 +2183,7 @@ var SpreadsheetValidationDialog = ({ prompt, onResolve }) => {
2115
2183
  };
2116
2184
 
2117
2185
  // src/spreadsheet/SpreadsheetRulePanels.tsx
2118
- var import_react34 = require("react");
2186
+ var import_react35 = require("react");
2119
2187
  var import_spreadsheet4 = require("@pixerate/editor/spreadsheet");
2120
2188
  var import_jsx_runtime14 = require("react/jsx-runtime");
2121
2189
  var inputClass = "w-full rounded border border-border bg-background px-1.5 py-0.5 text-xs text-foreground";
@@ -2169,18 +2237,18 @@ function RuleSwatch({ rule }) {
2169
2237
  }
2170
2238
  var SpreadsheetConditionalFormatPanel = ({ state, onClose }) => {
2171
2239
  const rules = state.document.table?.conditionalFormats ?? [];
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]);
2240
+ const [kind, setKind] = (0, import_react35.useState)("greaterThan");
2241
+ const [appliesTo, setAppliesTo] = (0, import_react35.useState)(() => selectionText(state.selectedRange));
2242
+ const [value, setValue] = (0, import_react35.useState)("");
2243
+ const [value2, setValue2] = (0, import_react35.useState)("");
2244
+ const [text, setText] = (0, import_react35.useState)("");
2245
+ const [formula, setFormula] = (0, import_react35.useState)("=");
2246
+ const [rank, setRank] = (0, import_react35.useState)("10");
2247
+ const [period, setPeriod] = (0, import_react35.useState)("today");
2248
+ const [iconSet, setIconSet] = (0, import_react35.useState)("3TrafficLights1");
2249
+ const [color, setColor] = (0, import_react35.useState)("#638ec6");
2250
+ const [styleId, setStyleId] = (0, import_react35.useState)(import_spreadsheet4.CONDITIONAL_FORMAT_STYLE_PRESETS[0].id);
2251
+ const preset = (0, import_react35.useMemo)(() => import_spreadsheet4.CONDITIONAL_FORMAT_PRESETS.find((p) => p.kind === kind), [kind]);
2184
2252
  const ranges = (0, import_spreadsheet4.parseRuleRanges)(appliesTo);
2185
2253
  const add = () => {
2186
2254
  if (!ranges) return;
@@ -2264,15 +2332,15 @@ var SpreadsheetConditionalFormatPanel = ({ state, onClose }) => {
2264
2332
  };
2265
2333
  var SpreadsheetDataValidationPanel = ({ state, onClose }) => {
2266
2334
  const rules = state.document.table?.dataValidations ?? [];
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));
2335
+ const [type, setType] = (0, import_react35.useState)("list");
2336
+ const [operator, setOperator] = (0, import_react35.useState)("between");
2337
+ const [formula1, setFormula1] = (0, import_react35.useState)("");
2338
+ const [formula2, setFormula2] = (0, import_react35.useState)("");
2339
+ const [errorStyle, setErrorStyle] = (0, import_react35.useState)("stop");
2340
+ const [errorMessage, setErrorMessage] = (0, import_react35.useState)("");
2341
+ const [inputMessage, setInputMessage] = (0, import_react35.useState)("");
2342
+ const [ignoreBlank, setIgnoreBlank] = (0, import_react35.useState)(true);
2343
+ const [appliesTo, setAppliesTo] = (0, import_react35.useState)(() => selectionText(state.selectedRange));
2276
2344
  const ranges = (0, import_spreadsheet4.parseRuleRanges)(appliesTo);
2277
2345
  const usesOperator = type === "whole" || type === "decimal" || type === "date" || type === "time" || type === "textLength";
2278
2346
  const needsTwo = usesOperator && (operator === "between" || operator === "notBetween");
@@ -2346,29 +2414,29 @@ var SpreadsheetDataValidationPanel = ({ state, onClose }) => {
2346
2414
  };
2347
2415
 
2348
2416
  // src/spreadsheet/useSpreadsheetViewport.ts
2349
- var import_react35 = require("react");
2417
+ var import_react36 = require("react");
2350
2418
  var import_spreadsheet5 = require("@pixerate/editor/spreadsheet");
2351
- var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react35.useLayoutEffect : import_react35.useEffect;
2419
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react36.useLayoutEffect : import_react36.useEffect;
2352
2420
  function useSpreadsheetViewport(scrollRef, view, options = {}) {
2353
- const metrics = (0, import_react35.useMemo)(() => (0, import_spreadsheet5.measureSpreadsheetView)(view), [view]);
2421
+ const metrics = (0, import_react36.useMemo)(() => (0, import_spreadsheet5.measureSpreadsheetView)(view), [view]);
2354
2422
  const virtual = (0, import_spreadsheet5.shouldVirtualizeSpreadsheet)(view, options.virtualize ?? "auto");
2355
- const [viewport, setViewport] = (0, import_react35.useState)({ scrollTop: 0, scrollLeft: 0, width: 0, height: 0 });
2356
- const windowOptions = (0, import_react35.useMemo)(
2423
+ const [viewport, setViewport] = (0, import_react36.useState)({ scrollTop: 0, scrollLeft: 0, width: 0, height: 0 });
2424
+ const windowOptions = (0, import_react36.useMemo)(
2357
2425
  () => ({ merges: options.merges, overscanRows: options.overscanRows, overscanColumns: options.overscanColumns }),
2358
2426
  [options.merges, options.overscanRows, options.overscanColumns]
2359
2427
  );
2360
- const win = (0, import_react35.useMemo)(
2428
+ const win = (0, import_react36.useMemo)(
2361
2429
  () => virtual ? (0, import_spreadsheet5.getSpreadsheetViewWindow)(metrics, viewport, windowOptions) : (0, import_spreadsheet5.fullSpreadsheetViewWindow)(metrics),
2362
2430
  [virtual, metrics, viewport, windowOptions]
2363
2431
  );
2364
- const latest = (0, import_react35.useRef)({ metrics, viewport, virtual, windowOptions });
2432
+ const latest = (0, import_react36.useRef)({ metrics, viewport, virtual, windowOptions });
2365
2433
  latest.current = { metrics, viewport, virtual, windowOptions };
2366
- const readViewport = (0, import_react35.useCallback)(() => {
2434
+ const readViewport = (0, import_react36.useCallback)(() => {
2367
2435
  const el = scrollRef.current;
2368
2436
  if (!el) return null;
2369
2437
  return { scrollTop: el.scrollTop, scrollLeft: el.scrollLeft, width: el.clientWidth, height: el.clientHeight };
2370
2438
  }, [scrollRef]);
2371
- const updateViewport = (0, import_react35.useCallback)((next) => {
2439
+ const updateViewport = (0, import_react36.useCallback)((next) => {
2372
2440
  setViewport((prev) => {
2373
2441
  const { metrics: m, virtual: v, windowOptions: o } = latest.current;
2374
2442
  if (!v) return prev;
@@ -2376,7 +2444,7 @@ function useSpreadsheetViewport(scrollRef, view, options = {}) {
2376
2444
  return same ? prev : next;
2377
2445
  });
2378
2446
  }, []);
2379
- const onScroll = (0, import_react35.useCallback)(() => {
2447
+ const onScroll = (0, import_react36.useCallback)(() => {
2380
2448
  const next = readViewport();
2381
2449
  if (next) updateViewport(next);
2382
2450
  }, [readViewport, updateViewport]);
@@ -2410,24 +2478,24 @@ function useSpreadsheetViewport(scrollRef, view, options = {}) {
2410
2478
  }
2411
2479
 
2412
2480
  // src/spreadsheet/FormulaHints.tsx
2413
- var import_react36 = require("react");
2481
+ var import_react37 = require("react");
2414
2482
  var import_spreadsheet6 = require("@pixerate/editor/spreadsheet");
2415
2483
  var import_jsx_runtime15 = require("react/jsx-runtime");
2416
2484
  var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
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)(
2485
+ const [caret, setCaret] = (0, import_react37.useState)(null);
2486
+ const [focused, setFocused] = (0, import_react37.useState)(false);
2487
+ const [selected, setSelected] = (0, import_react37.useState)(0);
2488
+ const [dismissed, setDismissed] = (0, import_react37.useState)(false);
2489
+ const [position, setPosition] = (0, import_react37.useState)(null);
2490
+ const pendingCaret = (0, import_react37.useRef)(null);
2491
+ const hints = (0, import_react37.useMemo)(
2424
2492
  () => (0, import_spreadsheet6.getFormulaHints)(value, caret ?? value.length, { limit, names }),
2425
2493
  [value, caret, limit, names]
2426
2494
  );
2427
2495
  const suggestions = dismissed ? [] : hints.suggestions;
2428
2496
  const selectedIndex = Math.max(0, Math.min(selected, suggestions.length - 1));
2429
2497
  const visible = focused && value.trimStart().startsWith("=") && (suggestions.length > 0 || !!hints.activeCall);
2430
- const latest = (0, import_react36.useRef)({ suggestions, selected: selectedIndex, value, caret, onAccept });
2498
+ const latest = (0, import_react37.useRef)({ suggestions, selected: selectedIndex, value, caret, onAccept });
2431
2499
  latest.current = { suggestions, selected: selectedIndex, value, caret, onAccept };
2432
2500
  const accept = (index) => {
2433
2501
  const { suggestions: list, value: current, caret: at, onAccept: commit } = latest.current;
@@ -2437,7 +2505,7 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
2437
2505
  pendingCaret.current = next.caret;
2438
2506
  commit(next.value);
2439
2507
  };
2440
- (0, import_react36.useEffect)(() => {
2508
+ (0, import_react37.useEffect)(() => {
2441
2509
  const input2 = inputRef.current;
2442
2510
  if (!input2) return;
2443
2511
  const syncCaret = () => setCaret(input2.selectionStart ?? input2.value.length);
@@ -2487,7 +2555,7 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
2487
2555
  input2.removeEventListener("keydown", onKeyDown);
2488
2556
  };
2489
2557
  }, [inputRef]);
2490
- (0, import_react36.useLayoutEffect)(() => {
2558
+ (0, import_react37.useLayoutEffect)(() => {
2491
2559
  const input2 = inputRef.current;
2492
2560
  const at = pendingCaret.current;
2493
2561
  if (!input2 || at === null || input2.value !== value) return;
@@ -2496,7 +2564,7 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
2496
2564
  setCaret(at);
2497
2565
  setSelected(0);
2498
2566
  }, [value, inputRef]);
2499
- (0, import_react36.useLayoutEffect)(() => {
2567
+ (0, import_react37.useLayoutEffect)(() => {
2500
2568
  const input2 = inputRef.current;
2501
2569
  if (!visible || !input2) return;
2502
2570
  const rect = input2.getBoundingClientRect();
@@ -2560,16 +2628,16 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
2560
2628
  };
2561
2629
 
2562
2630
  // src/spreadsheet/SheetTabs.tsx
2563
- var import_react37 = require("react");
2631
+ var import_react38 = require("react");
2564
2632
  var import_spreadsheet7 = require("@pixerate/editor/spreadsheet");
2565
2633
  var import_jsx_runtime16 = require("react/jsx-runtime");
2566
2634
  var SheetTabs = ({ state, readOnly = false, className = "" }) => {
2567
2635
  const { controller, sheets } = state;
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);
2636
+ const [renaming, setRenaming] = (0, import_react38.useState)(null);
2637
+ const [error, setError] = (0, import_react38.useState)(null);
2638
+ const [menu, setMenu] = (0, import_react38.useState)(null);
2639
+ const dragFrom = (0, import_react38.useRef)(null);
2640
+ const [dropTarget, setDropTarget] = (0, import_react38.useState)(null);
2573
2641
  const commitRename = (cancelOnError) => {
2574
2642
  if (!renaming) return;
2575
2643
  const sheet = sheets.find((s) => s.id === renaming.id);
@@ -2774,7 +2842,7 @@ var SpreadsheetEditor = ({
2774
2842
  }) => {
2775
2843
  const defaultState = useSpreadsheetEditor();
2776
2844
  const state = externalState || defaultState;
2777
- const gridRef = (0, import_react38.useRef)(null);
2845
+ const gridRef = (0, import_react39.useRef)(null);
2778
2846
  const ambientPlayback = useAgentPlayback();
2779
2847
  const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
2780
2848
  const agentPresence = usePlaybackSurface(playing, playbackId, {
@@ -2814,20 +2882,20 @@ var SpreadsheetEditor = ({
2814
2882
  },
2815
2883
  reveal: () => onPlaybackReveal?.()
2816
2884
  });
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);
2885
+ const scrollRef = (0, import_react39.useRef)(null);
2886
+ const formulaBarRef = (0, import_react39.useRef)(null);
2887
+ const cellInputRef = (0, import_react39.useRef)(null);
2888
+ const [resizingColId, setResizingColId] = (0, import_react39.useState)(null);
2889
+ const [hoveredColId, setHoveredColId] = (0, import_react39.useState)(null);
2890
+ const [resizeStartX, setResizeStartX] = (0, import_react39.useState)(0);
2891
+ const [resizeStartWidth, setResizeStartWidth] = (0, import_react39.useState)(0);
2824
2892
  const view = state.viewModel;
2825
2893
  const { window: viewWindow, onScroll: handleGridScroll } = useSpreadsheetViewport(scrollRef, view, {
2826
2894
  virtualize,
2827
2895
  merges: state.document.table?.merges,
2828
2896
  activeCell: state.activeCell
2829
2897
  });
2830
- const columnSlots = (0, import_react38.useMemo)(() => {
2898
+ const columnSlots = (0, import_react39.useMemo)(() => {
2831
2899
  const col = (viewCol) => ({ kind: "col", viewCol });
2832
2900
  if (!viewWindow.virtual) return view.columns.map(col);
2833
2901
  const slots = view.columns.slice(0, viewWindow.frozenColumns).map(col);
@@ -2836,11 +2904,11 @@ var SpreadsheetEditor = ({
2836
2904
  if (viewWindow.rightSpace > 0) slots.push({ kind: "space", key: "space:right", width: viewWindow.rightSpace });
2837
2905
  return slots;
2838
2906
  }, [view, viewWindow]);
2839
- const renderedColumns = (0, import_react38.useMemo)(
2907
+ const renderedColumns = (0, import_react39.useMemo)(
2840
2908
  () => columnSlots.flatMap((slot) => slot.kind === "col" ? [slot.viewCol] : []),
2841
2909
  [columnSlots]
2842
2910
  );
2843
- const rowSlots = (0, import_react38.useMemo)(() => {
2911
+ const rowSlots = (0, import_react39.useMemo)(() => {
2844
2912
  const row = (viewRow) => ({ kind: "row", viewRow });
2845
2913
  if (!viewWindow.virtual) return view.rows.map(row);
2846
2914
  const slots = view.rows.slice(0, viewWindow.frozenRows).map(row);
@@ -2851,16 +2919,16 @@ var SpreadsheetEditor = ({
2851
2919
  }, [view, viewWindow]);
2852
2920
  const { copyShortcutFallback } = useSpreadsheetClipboard(gridRef, state, readOnly);
2853
2921
  const { fillTarget, startFill, extendFill } = useFillHandle(state);
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);
2922
+ const [menu, setMenu] = (0, import_react39.useState)(null);
2923
+ const [panel, setPanel] = (0, import_react39.useState)(null);
2924
+ const [listMenu, setListMenu] = (0, import_react39.useState)(null);
2857
2925
  const overlay = state.conditionalFormatOverlay;
2858
2926
  const filter = state.document.table?.filter;
2859
- const filteredColIds = (0, import_react38.useMemo)(
2927
+ const filteredColIds = (0, import_react39.useMemo)(
2860
2928
  () => new Set(filter?.enabled ? filter.rules.map((r) => r.colId) : []),
2861
2929
  [filter]
2862
2930
  );
2863
- const handleCellContextMenu = (0, import_react38.useCallback)((rIdx, cIdx, e) => {
2931
+ const handleCellContextMenu = (0, import_react39.useCallback)((rIdx, cIdx, e) => {
2864
2932
  if (readOnly) return;
2865
2933
  e.preventDefault();
2866
2934
  if (state.editingCell) state.commitEditing();
@@ -2869,33 +2937,33 @@ var SpreadsheetEditor = ({
2869
2937
  }
2870
2938
  setMenu({ x: e.clientX, y: e.clientY, items: (0, import_spreadsheet8.getSpreadsheetMenuItems)(state.controller, { row: rIdx, col: cIdx }) });
2871
2939
  }, [readOnly, state]);
2872
- const nameSuggestions = (0, import_react38.useMemo)(
2940
+ const nameSuggestions = (0, import_react39.useMemo)(
2873
2941
  () => state.controller.getNameSuggestions(),
2874
2942
  // eslint-disable-next-line react-hooks/exhaustive-deps
2875
2943
  [state.controller, state.document]
2876
2944
  );
2877
- const activeRawValue = (0, import_react38.useMemo)(() => {
2945
+ const activeRawValue = (0, import_react39.useMemo)(() => {
2878
2946
  if (!state.activeCell) return "";
2879
2947
  const row = state.document.rows[state.activeCell.row];
2880
2948
  const col = state.document.columns[state.activeCell.col];
2881
2949
  if (!row || !col) return "";
2882
2950
  return state.getCell(row.id, col.id).raw;
2883
2951
  }, [state.activeCell, state.document]);
2884
- const activeSpill = (0, import_react38.useMemo)(
2952
+ const activeSpill = (0, import_react39.useMemo)(
2885
2953
  () => state.activeCell ? state.controller.getSpillAt(state.activeCell.row, state.activeCell.col) : null,
2886
2954
  // eslint-disable-next-line react-hooks/exhaustive-deps
2887
2955
  [state.controller, state.activeCell, state.document]
2888
2956
  );
2889
2957
  const spillFormula = activeSpill && !activeRawValue && activeSpill.key !== coordKey(state.activeCell) ? activeSpill.formula : "";
2890
- const coordLabel = (0, import_react38.useMemo)(() => {
2958
+ const coordLabel = (0, import_react39.useMemo)(() => {
2891
2959
  if (!state.activeCell) return "--";
2892
2960
  const colName = (0, import_spreadsheet8.indexToColName)(state.activeCell.col);
2893
2961
  return `${colName}${state.activeCell.row + 1}`;
2894
2962
  }, [state.activeCell]);
2895
- const [formulaDraft, setFormulaDraft] = (0, import_react38.useState)(null);
2963
+ const [formulaDraft, setFormulaDraft] = (0, import_react39.useState)(null);
2896
2964
  const activeColumn = state.activeCell ? state.document.columns[state.activeCell.col] : void 0;
2897
2965
  const formulaBarReadOnly = readOnly || !state.activeCell || !!activeColumn?.readOnly;
2898
- (0, import_react38.useEffect)(() => {
2966
+ (0, import_react39.useEffect)(() => {
2899
2967
  setFormulaDraft(null);
2900
2968
  }, [state.activeCell?.row, state.activeCell?.col]);
2901
2969
  const commitFormulaBar = () => {
@@ -2911,19 +2979,19 @@ var SpreadsheetEditor = ({
2911
2979
  }
2912
2980
  setFormulaDraft(null);
2913
2981
  };
2914
- const handleCellClick = (0, import_react38.useCallback)((rIdx, cIdx, e) => {
2982
+ const handleCellClick = (0, import_react39.useCallback)((rIdx, cIdx, e) => {
2915
2983
  if (state.editingCell && (state.editingCell.row !== rIdx || state.editingCell.col !== cIdx)) {
2916
2984
  state.commitEditing();
2917
2985
  }
2918
2986
  state.selectCell(rIdx, cIdx, e.shiftKey);
2919
2987
  }, [state]);
2920
- const handleCellDblClick = (0, import_react38.useCallback)((rIdx, cIdx) => {
2988
+ const handleCellDblClick = (0, import_react39.useCallback)((rIdx, cIdx) => {
2921
2989
  if (readOnly) return;
2922
2990
  const col = state.document.columns[cIdx];
2923
2991
  if (col?.readOnly) return;
2924
2992
  state.startEditing(rIdx, cIdx);
2925
2993
  }, [readOnly, state]);
2926
- const handleKeyDown = (0, import_react38.useCallback)((e) => {
2994
+ const handleKeyDown = (0, import_react39.useCallback)((e) => {
2927
2995
  if (state.editingCell) {
2928
2996
  if (e.key === "Enter") {
2929
2997
  e.preventDefault();
@@ -2995,12 +3063,12 @@ var SpreadsheetEditor = ({
2995
3063
  }
2996
3064
  }
2997
3065
  }, [readOnly, state, copyShortcutFallback]);
2998
- const activeListValues = (0, import_react38.useMemo)(
3066
+ const activeListValues = (0, import_react39.useMemo)(
2999
3067
  () => state.activeCell && !readOnly ? state.controller.getValidationListValues(state.activeCell.row, state.activeCell.col) : null,
3000
3068
  // eslint-disable-next-line react-hooks/exhaustive-deps
3001
3069
  [state.controller, state.activeCell, state.document, readOnly]
3002
3070
  );
3003
- const activeRule = (0, import_react38.useMemo)(
3071
+ const activeRule = (0, import_react39.useMemo)(
3004
3072
  () => state.activeCell ? state.controller.getDataValidationAt(state.activeCell.row, state.activeCell.col) : void 0,
3005
3073
  // eslint-disable-next-line react-hooks/exhaustive-deps
3006
3074
  [state.controller, state.activeCell, state.document]
@@ -3014,7 +3082,7 @@ var SpreadsheetEditor = ({
3014
3082
  const rect = td?.getBoundingClientRect();
3015
3083
  setListMenu({ x: rect ? rect.left : 0, y: rect ? rect.bottom : 0, row, col, values });
3016
3084
  }
3017
- (0, import_react38.useEffect)(() => {
3085
+ (0, import_react39.useEffect)(() => {
3018
3086
  if (!listMenu) return;
3019
3087
  const close = (e) => {
3020
3088
  if (!e.target?.closest?.('[aria-label="Allowed values"], .spreadsheet-list-arrow')) setListMenu(null);
@@ -3037,11 +3105,11 @@ var SpreadsheetEditor = ({
3037
3105
  else gridRef.current?.focus();
3038
3106
  });
3039
3107
  };
3040
- const stateRef = (0, import_react38.useRef)(state);
3108
+ const stateRef = (0, import_react39.useRef)(state);
3041
3109
  stateRef.current = state;
3042
- const onColumnResizeRef = (0, import_react38.useRef)(onColumnResize);
3110
+ const onColumnResizeRef = (0, import_react39.useRef)(onColumnResize);
3043
3111
  onColumnResizeRef.current = onColumnResize;
3044
- (0, import_react38.useEffect)(() => {
3112
+ (0, import_react39.useEffect)(() => {
3045
3113
  if (!resizingColId) return;
3046
3114
  if (typeof document !== "undefined") {
3047
3115
  document.body.style.cursor = "col-resize";
@@ -3092,7 +3160,7 @@ var SpreadsheetEditor = ({
3092
3160
  window.removeEventListener("mouseup", handleMouseUp);
3093
3161
  };
3094
3162
  }, [resizingColId, resizeStartX, resizeStartWidth]);
3095
- const measureElementContentWidth = (0, import_react38.useCallback)((el, container) => {
3163
+ const measureElementContentWidth = (0, import_react39.useCallback)((el, container) => {
3096
3164
  if (typeof document === "undefined") return 0;
3097
3165
  let maxW = el.scrollWidth || 0;
3098
3166
  const firstChild = el.firstElementChild;
@@ -3140,7 +3208,7 @@ var SpreadsheetEditor = ({
3140
3208
  }
3141
3209
  return maxW;
3142
3210
  }, []);
3143
- const autoFitColumn = (0, import_react38.useCallback)((colId, colIndex) => {
3211
+ const autoFitColumn = (0, import_react39.useCallback)((colId, colIndex) => {
3144
3212
  const col = state.document.columns.find((c) => c.id === colId);
3145
3213
  if (!col) return;
3146
3214
  let calculatedWidth = 0;
@@ -3176,12 +3244,12 @@ var SpreadsheetEditor = ({
3176
3244
  onColumnResize(updatedCol.id, updatedCol.width || 130);
3177
3245
  }
3178
3246
  }, [state, measureElementContentWidth, onColumnResize]);
3179
- const handleResizeDblClick = (0, import_react38.useCallback)((colId, colIndex, e) => {
3247
+ const handleResizeDblClick = (0, import_react39.useCallback)((colId, colIndex, e) => {
3180
3248
  e.preventDefault();
3181
3249
  e.stopPropagation();
3182
3250
  autoFitColumn(colId, colIndex);
3183
3251
  }, [autoFitColumn]);
3184
- const handleHeaderDblClick = (0, import_react38.useCallback)((colId, colIndex, e) => {
3252
+ const handleHeaderDblClick = (0, import_react39.useCallback)((colId, colIndex, e) => {
3185
3253
  const target = e.currentTarget;
3186
3254
  if (target) {
3187
3255
  const rect = target.getBoundingClientRect();
@@ -3573,19 +3641,19 @@ var SpreadsheetEditor = ({
3573
3641
  };
3574
3642
 
3575
3643
  // src/spreadsheet/NameManager.tsx
3576
- var import_react39 = require("react");
3644
+ var import_react40 = require("react");
3577
3645
  var import_spreadsheet9 = require("@pixerate/editor/spreadsheet");
3578
3646
  var import_jsx_runtime18 = require("react/jsx-runtime");
3579
3647
  var EMPTY_DRAFT = { original: null, name: "", refersTo: "=", scope: "", comment: "" };
3580
3648
  var NameManager = ({ state, readOnly = false, onClose, className = "" }) => {
3581
3649
  const { controller, sheets } = state;
3582
- const rows = (0, import_react39.useMemo)(
3650
+ const rows = (0, import_react40.useMemo)(
3583
3651
  () => (0, import_spreadsheet9.getNameManagerRows)(controller),
3584
3652
  // eslint-disable-next-line react-hooks/exhaustive-deps
3585
3653
  [controller, state.document, state.names]
3586
3654
  );
3587
- const [draft, setDraft] = (0, import_react39.useState)(EMPTY_DRAFT);
3588
- const [error, setError] = (0, import_react39.useState)(null);
3655
+ const [draft, setDraft] = (0, import_react40.useState)(EMPTY_DRAFT);
3656
+ const [error, setError] = (0, import_react40.useState)(null);
3589
3657
  const edit = (row) => {
3590
3658
  setError(null);
3591
3659
  setDraft({
@@ -3728,7 +3796,7 @@ var NameManager = ({ state, readOnly = false, onClose, className = "" }) => {
3728
3796
  };
3729
3797
 
3730
3798
  // src/slots.tsx
3731
- var import_react40 = require("react");
3799
+ var import_react41 = require("react");
3732
3800
  var import_jsx_runtime19 = require("react/jsx-runtime");
3733
3801
  var defaultSlots = {
3734
3802
  Button: (props) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
@@ -3750,121 +3818,121 @@ var defaultSlots = {
3750
3818
  props.onClose && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", onClick: props.onClose, className: "opacity-70 hover:opacity-100", children: "\xD7" })
3751
3819
  ] })
3752
3820
  };
3753
- var EditorSlotsContext = (0, import_react40.createContext)(defaultSlots);
3821
+ var EditorSlotsContext = (0, import_react41.createContext)(defaultSlots);
3754
3822
  function EditorSlotsProvider({ slots, children }) {
3755
- const mergedSlots = (0, import_react40.useMemo)(() => ({ ...defaultSlots, ...slots }), [slots]);
3823
+ const mergedSlots = (0, import_react41.useMemo)(() => ({ ...defaultSlots, ...slots }), [slots]);
3756
3824
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(EditorSlotsContext.Provider, { value: mergedSlots, children });
3757
3825
  }
3758
3826
  function useEditorSlots() {
3759
- return (0, import_react40.useContext)(EditorSlotsContext);
3827
+ return (0, import_react41.useContext)(EditorSlotsContext);
3760
3828
  }
3761
3829
 
3762
3830
  // src/image-editor/useImageEditor.ts
3763
- var import_react41 = require("react");
3831
+ var import_react42 = require("react");
3764
3832
  var import_image_editor = require("@pixerate/editor/image-editor");
3765
3833
  function useImageEditor(options = {}) {
3766
- const controllerRef = (0, import_react41.useRef)(null);
3834
+ const controllerRef = (0, import_react42.useRef)(null);
3767
3835
  if (!controllerRef.current) {
3768
3836
  controllerRef.current = new import_image_editor.ImageEditorController(options);
3769
3837
  }
3770
3838
  const controller = controllerRef.current;
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)(() => {
3839
+ const [state, setState] = (0, import_react42.useState)(() => controller.getState());
3840
+ const [historyTicks, setHistoryTicks] = (0, import_react42.useState)(0);
3841
+ const [histogram, setHistogram] = (0, import_react42.useState)(() => controller.getHistogram());
3842
+ (0, import_react42.useEffect)(() => controller.subscribeHistogram(setHistogram), [controller]);
3843
+ (0, import_react42.useEffect)(() => {
3776
3844
  const unsub = controller.subscribe((next) => {
3777
3845
  setState(next);
3778
3846
  setHistoryTicks((t) => t + 1);
3779
3847
  });
3780
3848
  return unsub;
3781
3849
  }, [controller]);
3782
- const loadedImageRef = (0, import_react41.useRef)(options.image);
3783
- (0, import_react41.useEffect)(() => {
3850
+ const loadedImageRef = (0, import_react42.useRef)(options.image);
3851
+ (0, import_react42.useEffect)(() => {
3784
3852
  if (options.image === loadedImageRef.current) return;
3785
3853
  loadedImageRef.current = options.image;
3786
3854
  if (options.image) {
3787
3855
  controller.loadImage(options.image);
3788
3856
  }
3789
3857
  }, [options.image, controller]);
3790
- const setTool = (0, import_react41.useCallback)((tool) => controller.setTool(tool), [controller]);
3791
- const setCrop = (0, import_react41.useCallback)(
3858
+ const setTool = (0, import_react42.useCallback)((tool) => controller.setTool(tool), [controller]);
3859
+ const setCrop = (0, import_react42.useCallback)(
3792
3860
  (crop, addToHistory = true) => controller.setCrop(crop, addToHistory),
3793
3861
  [controller]
3794
3862
  );
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)(
3863
+ const applyCropPreset = (0, import_react42.useCallback)((ratio) => controller.applyCropPreset(ratio), [controller]);
3864
+ const resetCrop = (0, import_react42.useCallback)(() => controller.resetCrop(), [controller]);
3865
+ const rotate = (0, import_react42.useCallback)((deg) => controller.rotate(deg), [controller]);
3866
+ const setRotation = (0, import_react42.useCallback)((deg) => controller.setRotation(deg), [controller]);
3867
+ const flipHorizontal = (0, import_react42.useCallback)(() => controller.flipHorizontal(), [controller]);
3868
+ const flipVertical = (0, import_react42.useCallback)(() => controller.flipVertical(), [controller]);
3869
+ const setAdjustments = (0, import_react42.useCallback)(
3802
3870
  (partial, commitToHistory = true) => controller.setAdjustments(partial, commitToHistory),
3803
3871
  [controller]
3804
3872
  );
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)(
3873
+ const resetAdjustments = (0, import_react42.useCallback)(() => controller.resetAdjustments(), [controller]);
3874
+ const upgradeProcess = (0, import_react42.useCallback)(() => controller.upgradeProcess(), [controller]);
3875
+ const addAdjustmentLayer = (0, import_react42.useCallback)(
3808
3876
  (init, index) => controller.addAdjustmentLayer(init, index),
3809
3877
  [controller]
3810
3878
  );
3811
- const updateAdjustmentLayer = (0, import_react41.useCallback)(
3879
+ const updateAdjustmentLayer = (0, import_react42.useCallback)(
3812
3880
  (id, update, commitToHistory = true) => controller.updateAdjustmentLayer(id, update, commitToHistory),
3813
3881
  [controller]
3814
3882
  );
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)(
3883
+ const removeAdjustmentLayer = (0, import_react42.useCallback)((id) => controller.removeAdjustmentLayer(id), [controller]);
3884
+ const moveAdjustmentLayer = (0, import_react42.useCallback)((id, to) => controller.moveAdjustmentLayer(id, to), [controller]);
3885
+ const toggleAdjustmentLayer = (0, import_react42.useCallback)(
3818
3886
  (id, enabled) => controller.toggleAdjustmentLayer(id, enabled),
3819
3887
  [controller]
3820
3888
  );
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)(
3889
+ const setDepthMask = (0, import_react42.useCallback)((partial) => controller.setDepthMask(partial), [controller]);
3890
+ const resetDepthMask = (0, import_react42.useCallback)(() => controller.resetDepthMask(), [controller]);
3891
+ const addAnnotation = (0, import_react42.useCallback)((ann) => controller.addAnnotation(ann), [controller]);
3892
+ const updateAnnotation = (0, import_react42.useCallback)(
3825
3893
  (id, partial, commitToHistory = true) => controller.updateAnnotation(id, partial, commitToHistory),
3826
3894
  [controller]
3827
3895
  );
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)(
3896
+ const removeAnnotation = (0, import_react42.useCallback)((id) => controller.removeAnnotation(id), [controller]);
3897
+ const clearAnnotations = (0, import_react42.useCallback)(() => controller.clearAnnotations(), [controller]);
3898
+ const selectAnnotation = (0, import_react42.useCallback)((id) => controller.selectAnnotation(id), [controller]);
3899
+ const undo = (0, import_react42.useCallback)(() => controller.undo(), [controller]);
3900
+ const redo = (0, import_react42.useCallback)(() => controller.redo(), [controller]);
3901
+ const reset = (0, import_react42.useCallback)(() => controller.reset(), [controller]);
3902
+ const zoomIn = (0, import_react42.useCallback)((factor) => controller.zoomIn(factor), [controller]);
3903
+ const zoomOut = (0, import_react42.useCallback)((factor) => controller.zoomOut(factor), [controller]);
3904
+ const resetZoom = (0, import_react42.useCallback)(() => controller.resetZoom(), [controller]);
3905
+ const setZoom = (0, import_react42.useCallback)((zoom) => controller.setZoom(zoom), [controller]);
3906
+ const setPan = (0, import_react42.useCallback)((pan) => controller.setPan(pan), [controller]);
3907
+ const setComparing = (0, import_react42.useCallback)((comp) => controller.setComparing(comp), [controller]);
3908
+ const loadImage = (0, import_react42.useCallback)((src) => controller.loadImage(src), [controller]);
3909
+ const toDataURL = (0, import_react42.useCallback)((opts) => controller.toDataURL(opts), [controller]);
3910
+ const toBlob = (0, import_react42.useCallback)((opts) => controller.toBlob(opts), [controller]);
3911
+ const toJSON = (0, import_react42.useCallback)(() => controller.toJSON(), [controller]);
3912
+ const loadJSON = (0, import_react42.useCallback)((data) => controller.loadJSON(data), [controller]);
3913
+ const renderMask = (0, import_react42.useCallback)(
3846
3914
  (opts) => controller.renderMask(opts),
3847
3915
  [controller]
3848
3916
  );
3849
- const toMaskDataURL = (0, import_react41.useCallback)(
3917
+ const toMaskDataURL = (0, import_react42.useCallback)(
3850
3918
  (opts) => controller.toMaskDataURL(opts),
3851
3919
  [controller]
3852
3920
  );
3853
- const toSourceDataURL = (0, import_react41.useCallback)(
3921
+ const toSourceDataURL = (0, import_react42.useCallback)(
3854
3922
  (opts) => controller.toSourceDataURL(opts),
3855
3923
  [controller]
3856
3924
  );
3857
- const applyInpaintedImage = (0, import_react41.useCallback)(
3925
+ const applyInpaintedImage = (0, import_react42.useCallback)(
3858
3926
  (newDataUrl, options2) => controller.applyInpaintedImage(newDataUrl, options2),
3859
3927
  [controller]
3860
3928
  );
3861
- const applyBackgroundRemovedImage = (0, import_react41.useCallback)(
3929
+ const applyBackgroundRemovedImage = (0, import_react42.useCallback)(
3862
3930
  (newDataUrl, options2) => controller.applyBackgroundRemovedImage(newDataUrl, options2),
3863
3931
  [controller]
3864
3932
  );
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)(
3933
+ const editorDocument = (0, import_react42.useMemo)(() => (0, import_image_editor.createImageEditorDocument)(controller), [controller]);
3934
+ (0, import_react42.useEffect)(() => () => editorDocument.destroy(), [editorDocument]);
3935
+ return (0, import_react42.useMemo)(
3868
3936
  () => ({
3869
3937
  controller,
3870
3938
  editorDocument,
@@ -3921,20 +3989,20 @@ function useImageEditor(options = {}) {
3921
3989
  }
3922
3990
  function useImageEffectsTools(registry, controller, options = {}) {
3923
3991
  const { id, namespace, readOnly, playbackSurface } = options;
3924
- (0, import_react41.useEffect)(() => {
3992
+ (0, import_react42.useEffect)(() => {
3925
3993
  if (!registry) return;
3926
3994
  return registry.register((0, import_image_editor.createImageEffectsToolProvider)(controller, { id, namespace, readOnly, playbackSurface }));
3927
3995
  }, [registry, controller, id, namespace, readOnly, playbackSurface]);
3928
3996
  }
3929
3997
 
3930
3998
  // src/image-editor/ImageEditor.tsx
3931
- var import_react83 = __toESM(require("react"), 1);
3999
+ var import_react84 = __toESM(require("react"), 1);
3932
4000
  var import_image_editor25 = require("@pixerate/editor/image-editor");
3933
4001
 
3934
4002
  // src/image-editor/ImageEditorCanvas.tsx
3935
- var import_react42 = require("react");
4003
+ var import_react43 = require("react");
3936
4004
  var import_image_editor2 = require("@pixerate/editor/image-editor");
3937
- var import_tools5 = require("@pixerate/editor/tools");
4005
+ var import_tools6 = require("@pixerate/editor/tools");
3938
4006
  var import_jsx_runtime20 = require("react/jsx-runtime");
3939
4007
  var ImageEditorCanvas = ({
3940
4008
  editor,
@@ -3963,18 +4031,18 @@ var ImageEditorCanvas = ({
3963
4031
  style
3964
4032
  }) => {
3965
4033
  const { state, controller } = editor;
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);
4034
+ const canvasRef = (0, import_react43.useRef)(null);
4035
+ const containerRef = (0, import_react43.useRef)(null);
4036
+ const rootRef = (0, import_react43.useRef)(null);
4037
+ const viewRef = (0, import_react43.useRef)({ width: 0, height: 0 });
4038
+ const modeRef = (0, import_react43.useRef)(mode);
3971
4039
  modeRef.current = mode;
3972
- const latest = (0, import_react42.useRef)({ onError, onTypeSessionChange, locate, locateElement, open, chromeRoot, onPlaybackReveal });
4040
+ const latest = (0, import_react43.useRef)({ onError, onTypeSessionChange, locate, locateElement, open, chromeRoot, onPlaybackReveal });
3973
4041
  latest.current = { onError, onTypeSessionChange, locate, locateElement, open, chromeRoot, onPlaybackReveal };
3974
4042
  const report = (source, message2) => latest.current.onError?.(source, message2);
3975
4043
  const ambientPlayback = useAgentPlayback();
3976
4044
  const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
3977
- const locateLayer = (0, import_react42.useMemo)(() => (0, import_image_editor2.createImagePlaybackLocator)(controller), [controller]);
4045
+ const locateLayer = (0, import_react43.useMemo)(() => (0, import_image_editor2.createImagePlaybackLocator)(controller), [controller]);
3978
4046
  const docToRoot = (p) => {
3979
4047
  const canvas = canvasRef.current;
3980
4048
  const root = rootRef.current;
@@ -4031,22 +4099,22 @@ var ImageEditorCanvas = ({
4031
4099
  fromViewport: clientToDoc,
4032
4100
  reveal: () => latest.current.onPlaybackReveal?.()
4033
4101
  });
4034
- const selectionOptionsRef = (0, import_react42.useRef)(selectionOptions);
4102
+ const selectionOptionsRef = (0, import_react43.useRef)(selectionOptions);
4035
4103
  selectionOptionsRef.current = selectionOptions;
4036
- const selectionGestureRef = (0, import_react42.useRef)(null);
4104
+ const selectionGestureRef = (0, import_react43.useRef)(null);
4037
4105
  if (!selectionGestureRef.current || selectionGestureRef.current.controller !== controller) {
4038
4106
  selectionGestureRef.current = new import_image_editor2.SelectionGesture(controller, () => selectionOptionsRef.current);
4039
4107
  }
4040
- const selectionDraftRef = (0, import_react42.useRef)(null);
4041
- const paintGestureRef = (0, import_react42.useRef)(null);
4042
- const paintControllerRef = (0, import_react42.useRef)(controller);
4108
+ const selectionDraftRef = (0, import_react43.useRef)(null);
4109
+ const paintGestureRef = (0, import_react43.useRef)(null);
4110
+ const paintControllerRef = (0, import_react43.useRef)(controller);
4043
4111
  if (!paintGestureRef.current || paintControllerRef.current !== controller) {
4044
4112
  paintGestureRef.current = new import_image_editor2.PaintGesture(controller);
4045
4113
  paintControllerRef.current = controller;
4046
4114
  }
4047
- const brushCursorRef = (0, import_react42.useRef)(null);
4048
- const ownTransformRef = (0, import_react42.useRef)(null);
4049
- const ownTransformControllerRef = (0, import_react42.useRef)(controller);
4115
+ const brushCursorRef = (0, import_react43.useRef)(null);
4116
+ const ownTransformRef = (0, import_react43.useRef)(null);
4117
+ const ownTransformControllerRef = (0, import_react43.useRef)(controller);
4050
4118
  if (!hostTransformTool && (!ownTransformRef.current || ownTransformControllerRef.current !== controller)) {
4051
4119
  ownTransformRef.current?.cancel();
4052
4120
  ownTransformRef.current = new import_image_editor2.FreeTransformTool(controller, {
@@ -4055,43 +4123,43 @@ var ImageEditorCanvas = ({
4055
4123
  ownTransformControllerRef.current = controller;
4056
4124
  }
4057
4125
  const transformTool = hostTransformTool ?? ownTransformRef.current;
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);
4126
+ const [, setTransformTick] = (0, import_react43.useState)(0);
4127
+ const [transformCursor, setTransformCursor] = (0, import_react43.useState)("default");
4128
+ (0, import_react43.useEffect)(() => () => ownTransformRef.current?.cancel(), []);
4129
+ const shapeOptionsRef = (0, import_react43.useRef)(shapeOptions);
4062
4130
  shapeOptionsRef.current = shapeOptions;
4063
- const typeOptionsRef = (0, import_react42.useRef)(typeOptions);
4131
+ const typeOptionsRef = (0, import_react43.useRef)(typeOptions);
4064
4132
  typeOptionsRef.current = typeOptions;
4065
- const shapeGestureRef = (0, import_react42.useRef)(null);
4066
- const typeToolRef = (0, import_react42.useRef)(null);
4067
- const shapeTypeControllerRef = (0, import_react42.useRef)(controller);
4133
+ const shapeGestureRef = (0, import_react43.useRef)(null);
4134
+ const typeToolRef = (0, import_react43.useRef)(null);
4135
+ const shapeTypeControllerRef = (0, import_react43.useRef)(controller);
4068
4136
  if (!shapeGestureRef.current || !typeToolRef.current || shapeTypeControllerRef.current !== controller) {
4069
4137
  typeToolRef.current?.finish();
4070
4138
  shapeGestureRef.current = new import_image_editor2.ShapeDrawGesture(controller, () => shapeOptionsRef.current);
4071
4139
  typeToolRef.current = new import_image_editor2.TypeToolGesture(controller, () => typeOptionsRef.current);
4072
4140
  shapeTypeControllerRef.current = controller;
4073
4141
  }
4074
- const pathGestureRef = (0, import_react42.useRef)(null);
4075
- const pathControllerRef = (0, import_react42.useRef)(controller);
4142
+ const pathGestureRef = (0, import_react43.useRef)(null);
4143
+ const pathControllerRef = (0, import_react43.useRef)(controller);
4076
4144
  if (!pathGestureRef.current || pathControllerRef.current !== controller) {
4077
4145
  pathGestureRef.current = new import_image_editor2.PathEditGesture(controller);
4078
4146
  pathControllerRef.current = controller;
4079
4147
  }
4080
- const typeInputRef = (0, import_react42.useRef)(null);
4081
- const [typeSession, setTypeSessionState] = (0, import_react42.useState)(typeToolRef.current.session);
4148
+ const typeInputRef = (0, import_react43.useRef)(null);
4149
+ const [typeSession, setTypeSessionState] = (0, import_react43.useState)(typeToolRef.current.session);
4082
4150
  const setTypeSession = (session) => {
4083
4151
  setTypeSessionState(session);
4084
4152
  latest.current.onTypeSessionChange?.(session);
4085
4153
  };
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)(
4154
+ const draftAnnotationRef = (0, import_react43.useRef)(null);
4155
+ const draftCropRef = (0, import_react43.useRef)(null);
4156
+ const cropDragInfoRef = (0, import_react43.useRef)(null);
4157
+ const annotationDragInfoRef = (0, import_react43.useRef)(null);
4158
+ const isDrawingRef = (0, import_react43.useRef)(false);
4159
+ const currentPathRef = (0, import_react43.useRef)([]);
4160
+ const dragStartPointRef = (0, import_react43.useRef)(null);
4161
+ const antsOffsetRef = (0, import_react43.useRef)(0);
4162
+ const renderCanvas = (0, import_react43.useCallback)(
4095
4163
  async (draftAnnotation, draftCrop) => {
4096
4164
  const canvas = canvasRef.current;
4097
4165
  const container = containerRef.current;
@@ -4124,17 +4192,17 @@ var ImageEditorCanvas = ({
4124
4192
  [controller, mode, fit, transformTool]
4125
4193
  );
4126
4194
  const marching = !!state.selection?.bounds && !state.quickMask;
4127
- (0, import_react42.useEffect)(() => {
4195
+ (0, import_react43.useEffect)(() => {
4128
4196
  if (!marching) return;
4129
4197
  return (0, import_image_editor2.startMarchingAnts)((offset) => {
4130
4198
  antsOffsetRef.current = offset;
4131
4199
  void renderCanvas();
4132
4200
  });
4133
4201
  }, [marching, renderCanvas]);
4134
- (0, import_react42.useEffect)(() => {
4202
+ (0, import_react43.useEffect)(() => {
4135
4203
  let drafting = false;
4136
4204
  return agentPresence.subscribe(
4137
- (0, import_tools5.trackPresenceDrag)({
4205
+ (0, import_tools6.trackPresenceDrag)({
4138
4206
  onDrag: (box) => {
4139
4207
  if (cropDragInfoRef.current || selectionGestureRef.current?.active) return;
4140
4208
  const draft = (0, import_image_editor2.agentDragDraft)(modeRef.current, box, controller.getState().imageDimensions);
@@ -4154,18 +4222,18 @@ var ImageEditorCanvas = ({
4154
4222
  })
4155
4223
  );
4156
4224
  }, [agentPresence, controller, renderCanvas]);
4157
- (0, import_react42.useEffect)(() => typeSession?.subscribe(() => void renderCanvas()), [typeSession, renderCanvas]);
4225
+ (0, import_react43.useEffect)(() => typeSession?.subscribe(() => void renderCanvas()), [typeSession, renderCanvas]);
4158
4226
  const finishTyping = () => {
4159
4227
  typeToolRef.current?.finish();
4160
4228
  setTypeSession(null);
4161
4229
  void renderCanvas();
4162
4230
  };
4163
- (0, import_react42.useEffect)(() => {
4231
+ (0, import_react43.useEffect)(() => {
4164
4232
  if (mode === "annotate" && state.activeTool === "type") return;
4165
4233
  if (typeToolRef.current?.session) finishTyping();
4166
4234
  }, [mode, state.activeTool, renderCanvas]);
4167
- const prevTypeSessionProp = (0, import_react42.useRef)(typeSessionProp);
4168
- (0, import_react42.useEffect)(() => {
4235
+ const prevTypeSessionProp = (0, import_react43.useRef)(typeSessionProp);
4236
+ (0, import_react43.useEffect)(() => {
4169
4237
  const was = prevTypeSessionProp.current;
4170
4238
  prevTypeSessionProp.current = typeSessionProp;
4171
4239
  if (was && typeSessionProp === null && typeToolRef.current?.session) finishTyping();
@@ -4192,7 +4260,7 @@ var ImageEditorCanvas = ({
4192
4260
  el.value = "";
4193
4261
  }
4194
4262
  };
4195
- (0, import_react42.useEffect)(() => transformTool.subscribe(() => {
4263
+ (0, import_react43.useEffect)(() => transformTool.subscribe(() => {
4196
4264
  setTransformTick((n) => n + 1);
4197
4265
  void renderCanvas();
4198
4266
  }), [transformTool, renderCanvas]);
@@ -4235,7 +4303,7 @@ var ImageEditorCanvas = ({
4235
4303
  transformTool.up();
4236
4304
  return true;
4237
4305
  };
4238
- (0, import_react42.useEffect)(() => {
4306
+ (0, import_react43.useEffect)(() => {
4239
4307
  if (typeof window === "undefined") return;
4240
4308
  const onKey = (e) => {
4241
4309
  if (transformTool.key(e)) e.preventDefault();
@@ -4243,7 +4311,7 @@ var ImageEditorCanvas = ({
4243
4311
  window.addEventListener("keydown", onKey);
4244
4312
  return () => window.removeEventListener("keydown", onKey);
4245
4313
  }, [transformTool]);
4246
- (0, import_react42.useEffect)(() => {
4314
+ (0, import_react43.useEffect)(() => {
4247
4315
  const raf = typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : (cb) => setTimeout(cb, 0);
4248
4316
  const caf = typeof cancelAnimationFrame !== "undefined" ? cancelAnimationFrame : (id) => clearTimeout(id);
4249
4317
  const animId = raf(() => {
@@ -4251,7 +4319,7 @@ var ImageEditorCanvas = ({
4251
4319
  });
4252
4320
  return () => caf(animId);
4253
4321
  }, [renderCanvas, state]);
4254
- (0, import_react42.useEffect)(() => {
4322
+ (0, import_react43.useEffect)(() => {
4255
4323
  const container = containerRef.current;
4256
4324
  if (!container) return;
4257
4325
  const { width, height } = (0, import_image_editor2.measureCanvasViewport)(container);
@@ -4311,7 +4379,7 @@ var ImageEditorCanvas = ({
4311
4379
  if (g.error) report("paint", g.error);
4312
4380
  }
4313
4381
  };
4314
- (0, import_react42.useEffect)(() => {
4382
+ (0, import_react43.useEffect)(() => {
4315
4383
  if (mode !== "select" || typeof window === "undefined") return;
4316
4384
  const onKey = (e) => {
4317
4385
  const target = e.target;
@@ -4335,7 +4403,7 @@ var ImageEditorCanvas = ({
4335
4403
  window.addEventListener("keydown", onKey);
4336
4404
  return () => window.removeEventListener("keydown", onKey);
4337
4405
  });
4338
- (0, import_react42.useEffect)(() => {
4406
+ (0, import_react43.useEffect)(() => {
4339
4407
  if (mode !== "annotate" || typeof window === "undefined") return;
4340
4408
  const onKey = (e) => {
4341
4409
  const target = e.target;
@@ -4350,7 +4418,7 @@ var ImageEditorCanvas = ({
4350
4418
  window.addEventListener("keydown", onKey);
4351
4419
  return () => window.removeEventListener("keydown", onKey);
4352
4420
  });
4353
- (0, import_react42.useEffect)(() => {
4421
+ (0, import_react43.useEffect)(() => {
4354
4422
  if (mode !== "paint" || typeof window === "undefined") return;
4355
4423
  const onKey = (e) => {
4356
4424
  if ((0, import_image_editor2.handlePaintShortcut)(controller, e)) e.preventDefault();
@@ -4757,7 +4825,7 @@ var ImageEditorCanvas = ({
4757
4825
  var import_image_editor3 = require("@pixerate/editor/image-editor");
4758
4826
 
4759
4827
  // src/image-editor/controls/controls.tsx
4760
- var import_react43 = require("react");
4828
+ var import_react44 = require("react");
4761
4829
 
4762
4830
  // src/image-editor/styles.ts
4763
4831
  var imageEditorFrameClass = "relative flex flex-col bg-background border border-border rounded-xl overflow-hidden shadow-sm text-foreground";
@@ -4783,12 +4851,12 @@ var imageSpinnerClass = "w-3.5 h-3.5 border-2 border-primary-foreground/30 borde
4783
4851
 
4784
4852
  // src/image-editor/controls/controls.tsx
4785
4853
  var import_jsx_runtime21 = require("react/jsx-runtime");
4786
- var ControlsContext = (0, import_react43.createContext)({});
4854
+ var ControlsContext = (0, import_react44.createContext)({});
4787
4855
  function ImageEditorControlsProvider({ controls, children }) {
4788
4856
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ControlsContext.Provider, { value: controls, children });
4789
4857
  }
4790
4858
  function useImageEditorControls() {
4791
- return (0, import_react43.useContext)(ControlsContext);
4859
+ return (0, import_react44.useContext)(ControlsContext);
4792
4860
  }
4793
4861
  function ImageCheckbox(props) {
4794
4862
  const Host = useImageEditorControls().Checkbox;
@@ -4871,7 +4939,7 @@ var ControlSlider = ({ spec, value, onChange, disabled, label, className }) => {
4871
4939
  };
4872
4940
 
4873
4941
  // src/image-editor/Histogram.tsx
4874
- var import_react44 = require("react");
4942
+ var import_react45 = require("react");
4875
4943
  var import_image_editor4 = require("@pixerate/editor/image-editor");
4876
4944
  var import_jsx_runtime23 = require("react/jsx-runtime");
4877
4945
  var FILL = {
@@ -4883,7 +4951,7 @@ var FILL = {
4883
4951
  var W = 256;
4884
4952
  var Histogram = ({ histogram, channel = "rgb", height = 64, className = "", style }) => {
4885
4953
  const channels = channel === "rgb" ? ["luminance", "red", "green", "blue"] : [channel];
4886
- const paths = (0, import_react44.useMemo)(
4954
+ const paths = (0, import_react45.useMemo)(
4887
4955
  () => histogram && histogram.samples > 0 ? channels.map((c) => ({ c, d: (0, import_image_editor4.histogramPath)(histogram, c, W, height) })) : [],
4888
4956
  // eslint-disable-next-line react-hooks/exhaustive-deps
4889
4957
  [histogram, channel, height]
@@ -4909,24 +4977,24 @@ var Histogram = ({ histogram, channel = "rgb", height = 64, className = "", styl
4909
4977
  );
4910
4978
  };
4911
4979
  function useImageHistogram(controller) {
4912
- const [histogram, setHistogram] = (0, import_react44.useState)(() => controller.getHistogram());
4913
- (0, import_react44.useEffect)(() => controller.subscribeHistogram(setHistogram), [controller]);
4980
+ const [histogram, setHistogram] = (0, import_react45.useState)(() => controller.getHistogram());
4981
+ (0, import_react45.useEffect)(() => controller.subscribeHistogram(setHistogram), [controller]);
4914
4982
  return histogram;
4915
4983
  }
4916
4984
 
4917
4985
  // src/image-editor/AdjustmentLayersPanel.tsx
4918
- var import_react46 = require("react");
4986
+ var import_react47 = require("react");
4919
4987
  var import_image_editor6 = require("@pixerate/editor/image-editor");
4920
4988
 
4921
4989
  // src/image-editor/CurvesEditor.tsx
4922
- var import_react45 = require("react");
4990
+ var import_react46 = require("react");
4923
4991
  var import_image_editor5 = require("@pixerate/editor/image-editor");
4924
4992
  var import_jsx_runtime24 = require("react/jsx-runtime");
4925
4993
  var BOX = 256;
4926
4994
  var STROKE = { master: "var(--foreground, #e2e8f0)", red: "#ef4444", green: "#22c55e", blue: "#3b82f6" };
4927
4995
  var CurvesEditor = ({ points, onChange, histogram, channel = "master", size = 200, className = "" }) => {
4928
- const svgRef = (0, import_react45.useRef)(null);
4929
- const [drag, setDrag] = (0, import_react45.useState)(null);
4996
+ const svgRef = (0, import_react46.useRef)(null);
4997
+ const [drag, setDrag] = (0, import_react46.useState)(null);
4930
4998
  const toBox = (e) => {
4931
4999
  const rect = svgRef.current?.getBoundingClientRect();
4932
5000
  if (!rect || !rect.width || !rect.height) return { x: 0, y: 0 };
@@ -5024,14 +5092,14 @@ var HueRangeStrip = ({ bounds }) => {
5024
5092
  };
5025
5093
  var AdjustmentLayersPanel = ({ controller, layers: layersProp, histogram, className = "" }) => {
5026
5094
  const follow = layersProp === void 0;
5027
- const [, setTick] = (0, import_react46.useState)(0);
5028
- (0, import_react46.useEffect)(() => follow ? controller.subscribe(() => setTick((n) => n + 1)) : void 0, [controller, follow]);
5095
+ const [, setTick] = (0, import_react47.useState)(0);
5096
+ (0, import_react47.useEffect)(() => follow ? controller.subscribe(() => setTick((n) => n + 1)) : void 0, [controller, follow]);
5029
5097
  const layers = layersProp ?? controller.getAdjustmentLayers();
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");
5098
+ const [newKind, setNewKind] = (0, import_react47.useState)("curves");
5099
+ const [selectedId, setSelectedId] = (0, import_react47.useState)(null);
5100
+ const [channel, setChannel] = (0, import_react47.useState)("master");
5101
+ const [range, setRange] = (0, import_react47.useState)(-1);
5102
+ const [tone, setTone] = (0, import_react47.useState)("midtones");
5035
5103
  const selected = layers.find((l) => l.id === selectedId) ?? null;
5036
5104
  const topFirst = [...layers].reverse();
5037
5105
  const setParam = (layer, path, value, commit = true) => controller.updateAdjustmentLayer(layer.id, { params: (0, import_image_editor6.setControlPath)(layer.params, path, value) }, commit);
@@ -5227,18 +5295,18 @@ var AdjustmentLayersPanel = ({ controller, layers: layersProp, histogram, classN
5227
5295
  };
5228
5296
 
5229
5297
  // src/image-editor/LayersPanel.tsx
5230
- var import_react51 = __toESM(require("react"), 1);
5298
+ var import_react52 = __toESM(require("react"), 1);
5231
5299
 
5232
5300
  // src/image-editor/LayerEffectsPanel.tsx
5233
- var import_react47 = require("react");
5301
+ var import_react48 = require("react");
5234
5302
  var import_raster = require("@pixerate/editor/raster");
5235
5303
  var import_jsx_runtime26 = require("react/jsx-runtime");
5236
5304
  var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) => {
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);
5305
+ const [, setTick] = (0, import_react48.useState)(0);
5306
+ (0, import_react48.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
5307
+ const [open, setOpen] = (0, import_react48.useState)(null);
5308
+ const [error, setError] = (0, import_react48.useState)(null);
5309
+ const commitNext = (0, import_react48.useRef)(true);
5242
5310
  const layer = layerId ? controller.getLayer(layerId) : controller.getActiveLayer();
5243
5311
  const model = (0, import_raster.layerEffectsPanel)(layer);
5244
5312
  const id = layer?.id;
@@ -5386,7 +5454,7 @@ var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) =>
5386
5454
  };
5387
5455
 
5388
5456
  // src/image-editor/EdgeColorPanel.tsx
5389
- var import_react48 = require("react");
5457
+ var import_react49 = require("react");
5390
5458
  var import_jsx_runtime27 = require("react/jsx-runtime");
5391
5459
  var SLIDERS = [
5392
5460
  { key: "decontaminate", label: "Decontaminate", hint: "Unmix the old background from a soft-edged mask" },
@@ -5394,8 +5462,8 @@ var SLIDERS = [
5394
5462
  { key: "ambient", label: "Cast", hint: "Tint the edge with what is behind the layer, live" }
5395
5463
  ];
5396
5464
  var EdgeColorPanel = ({ controller, layer, className = "" }) => {
5397
- const [error, setError] = (0, import_react48.useState)(null);
5398
- const commitNext = (0, import_react48.useRef)(true);
5465
+ const [error, setError] = (0, import_react49.useState)(null);
5466
+ const commitNext = (0, import_react49.useRef)(true);
5399
5467
  const info = controller.getEdgeColor(layer.id);
5400
5468
  const fixed = info.ambientSource !== "auto";
5401
5469
  const set = (change) => {
@@ -5472,12 +5540,12 @@ var EdgeColorPanel = ({ controller, layer, className = "" }) => {
5472
5540
  };
5473
5541
 
5474
5542
  // src/image-editor/VectorMaskEdgesPanel.tsx
5475
- var import_react49 = require("react");
5543
+ var import_react50 = require("react");
5476
5544
  var import_jsx_runtime28 = require("react/jsx-runtime");
5477
5545
  var MODES = ["hard", "feather", "matte"];
5478
5546
  var input = "w-12 bg-background border border-border rounded px-1 py-0.5 text-foreground";
5479
5547
  var VectorMaskEdgesPanel = ({ controller, layer, className = "" }) => {
5480
- const [error, setError] = (0, import_react49.useState)(null);
5548
+ const [error, setError] = (0, import_react50.useState)(null);
5481
5549
  const info = controller.getVectorMask(layer.id);
5482
5550
  if (!info) return null;
5483
5551
  const set = (e, mode, options = {}) => {
@@ -5522,17 +5590,17 @@ var VectorMaskEdgesPanel = ({ controller, layer, className = "" }) => {
5522
5590
  };
5523
5591
 
5524
5592
  // src/image-editor/SmartObjectPanel.tsx
5525
- var import_react50 = require("react");
5593
+ var import_react51 = require("react");
5526
5594
  var import_image_editor7 = require("@pixerate/editor/image-editor");
5527
5595
  var import_jsx_runtime29 = require("react/jsx-runtime");
5528
5596
  var button = imageIconButtonClass;
5529
5597
  var SmartObjectPanel = ({ controller, layerId, className }) => {
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);
5598
+ const [, setTick] = (0, import_react51.useState)(0);
5599
+ (0, import_react51.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
5600
+ const [open, setOpen] = (0, import_react51.useState)(null);
5601
+ const [error, setError] = (0, import_react51.useState)(null);
5602
+ const fileInput = (0, import_react51.useRef)(null);
5603
+ const commitNext = (0, import_react51.useRef)(true);
5536
5604
  const model = (0, import_image_editor7.smartObjectPanel)(controller, layerId);
5537
5605
  const id = model.layerId;
5538
5606
  const attempt = (fn) => {
@@ -5718,8 +5786,8 @@ var Thumbnail = ({
5718
5786
  selected,
5719
5787
  testId
5720
5788
  }) => {
5721
- const ref = (0, import_react51.useRef)(null);
5722
- (0, import_react51.useEffect)(() => {
5789
+ const ref = (0, import_react52.useRef)(null);
5790
+ (0, import_react52.useEffect)(() => {
5723
5791
  const canvas = ref.current;
5724
5792
  const ctx = canvas?.getContext("2d");
5725
5793
  if (!canvas || !ctx || !pixels || typeof ctx.createImageData !== "function") return;
@@ -5744,14 +5812,14 @@ var Thumbnail = ({
5744
5812
  );
5745
5813
  };
5746
5814
  var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "image", effects = true, smartObjects = true, className }) => {
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);
5815
+ const [, setTick] = (0, import_react52.useState)(0);
5816
+ (0, import_react52.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
5817
+ const [error, setError] = (0, import_react52.useState)(null);
5818
+ const [renaming, setRenaming] = (0, import_react52.useState)(null);
5819
+ const [menu, setMenu] = (0, import_react52.useState)(null);
5820
+ const [drag, setDrag] = (0, import_react52.useState)(null);
5821
+ const [psdNotes, setPsdNotes] = (0, import_react52.useState)([]);
5822
+ const fileInput = (0, import_react52.useRef)(null);
5755
5823
  const psdTask = async (fn) => {
5756
5824
  try {
5757
5825
  setError(null);
@@ -5760,7 +5828,7 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
5760
5828
  setError(err instanceof Error ? err.message : String(err));
5761
5829
  }
5762
5830
  };
5763
- const commitNext = (0, import_react51.useRef)(true);
5831
+ const commitNext = (0, import_react52.useRef)(true);
5764
5832
  const state = controller.getState();
5765
5833
  const maskView = controller.getMaskView();
5766
5834
  const rows = (0, import_image_editor8.layerPanelRows)(state.layers, state.activeLayerId);
@@ -5957,7 +6025,7 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
5957
6025
  const { layer } = row;
5958
6026
  const badge = (0, import_image_editor8.smartObjectBadge)(state.layers, layer);
5959
6027
  const filterRows = (0, import_image_editor8.smartFilterRows)(layer);
5960
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_react51.default.Fragment, { children: [
6028
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_react52.default.Fragment, { children: [
5961
6029
  /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
5962
6030
  "li",
5963
6031
  {
@@ -6278,21 +6346,21 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
6278
6346
  };
6279
6347
 
6280
6348
  // src/image-editor/ImageProviderEffectsPanel.tsx
6281
- var import_react61 = require("react");
6349
+ var import_react62 = require("react");
6282
6350
  var import_image_editor9 = require("@pixerate/editor/image-editor");
6283
6351
 
6284
6352
  // src/effects/useEffects.ts
6285
- var import_react52 = require("react");
6353
+ var import_react53 = require("react");
6286
6354
  function useEffects(host, provider) {
6287
- (0, import_react52.useEffect)(() => {
6355
+ (0, import_react53.useEffect)(() => {
6288
6356
  if (!host || !provider) return;
6289
6357
  return host.useEffects(provider);
6290
6358
  }, [host, provider]);
6291
6359
  }
6292
6360
  function useEffectDescription(provider, effect) {
6293
- const [state, setState] = (0, import_react52.useState)({ key: "", description: null, error: null });
6361
+ const [state, setState] = (0, import_react53.useState)({ key: "", description: null, error: null });
6294
6362
  const key = provider && effect ? `${provider.id}:${effect}` : "";
6295
- (0, import_react52.useEffect)(() => {
6363
+ (0, import_react53.useEffect)(() => {
6296
6364
  if (!provider || !effect) return;
6297
6365
  let live = true;
6298
6366
  Promise.resolve().then(() => provider.describe(effect)).then(
@@ -6307,14 +6375,14 @@ function useEffectDescription(provider, effect) {
6307
6375
  }
6308
6376
 
6309
6377
  // src/effects/EffectThumbnail.tsx
6310
- var import_react53 = require("react");
6378
+ var import_react54 = require("react");
6311
6379
  var import_effects = require("@pixerate/editor/effects");
6312
6380
  var import_jsx_runtime31 = require("react/jsx-runtime");
6313
6381
  var LABELS = { motion: "Motion", camera: "Camera", timing: "Timing", "text-treatment": "Text treatment" };
6314
6382
  function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
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)(() => {
6383
+ const ref = (0, import_react54.useRef)(null);
6384
+ const [failed, setFailed] = (0, import_react54.useState)(effect.kind in LABELS);
6385
+ (0, import_react54.useEffect)(() => {
6318
6386
  if (effect.kind in LABELS) return;
6319
6387
  let live = true;
6320
6388
  (0, import_effects.renderEffectThumbnail)(provider, effect, { width, height }).then(
@@ -6341,16 +6409,16 @@ function EffectThumbnail({ provider, effect, width = 96, height = 54, className
6341
6409
  }
6342
6410
 
6343
6411
  // src/effects/EffectsBrowser.tsx
6344
- var import_react54 = require("react");
6412
+ var import_react55 = require("react");
6345
6413
  var import_effects2 = require("@pixerate/editor/effects");
6346
6414
  var import_jsx_runtime32 = require("react/jsx-runtime");
6347
6415
  function EffectsBrowser({ provider, uses, kinds, filter, onPick, thumbnails = true, title = "Effects", className = "" }) {
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)(() => {
6416
+ const [all, setAll] = (0, import_react55.useState)([]);
6417
+ const [query, setQuery] = (0, import_react55.useState)("");
6418
+ const [category, setCategory] = (0, import_react55.useState)("");
6419
+ const [use, setUse] = (0, import_react55.useState)("");
6420
+ const [error, setError] = (0, import_react55.useState)(null);
6421
+ (0, import_react55.useEffect)(() => {
6354
6422
  if (!provider) return setAll([]);
6355
6423
  let live = true;
6356
6424
  Promise.resolve().then(() => provider.list()).then(
@@ -6361,8 +6429,8 @@ function EffectsBrowser({ provider, uses, kinds, filter, onPick, thumbnails = tr
6361
6429
  live = false;
6362
6430
  };
6363
6431
  }, [provider]);
6364
- const [found, setFound] = (0, import_react54.useState)([]);
6365
- (0, import_react54.useEffect)(() => {
6432
+ const [found, setFound] = (0, import_react55.useState)([]);
6433
+ (0, import_react55.useEffect)(() => {
6366
6434
  if (!provider) return setFound([]);
6367
6435
  let live = true;
6368
6436
  Promise.resolve().then(() => provider.search(query, { ...category ? { category } : {}, ...use ? { use } : {} })).then((list) => live && setFound(list), () => live && setFound([]));
@@ -6371,7 +6439,7 @@ function EffectsBrowser({ provider, uses, kinds, filter, onPick, thumbnails = tr
6371
6439
  };
6372
6440
  }, [provider, query, category, use]);
6373
6441
  const allowed = (e) => (!kinds || kinds.includes(e.kind)) && (0, import_effects2.effectOffered)(e, uses) && (!filter || filter(e));
6374
- const categories = (0, import_react54.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds, filter]);
6442
+ const categories = (0, import_react55.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds, filter]);
6375
6443
  const shown = found.filter(allowed);
6376
6444
  if (!provider)
6377
6445
  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." });
@@ -6419,12 +6487,12 @@ function EffectsBrowser({ provider, uses, kinds, filter, onPick, thumbnails = tr
6419
6487
  }
6420
6488
 
6421
6489
  // src/effects/EffectParameters.tsx
6422
- var import_react60 = __toESM(require("react"), 1);
6490
+ var import_react61 = __toESM(require("react"), 1);
6423
6491
  var import_effects3 = require("@pixerate/editor/effects");
6424
6492
  var import_parameters2 = require("@pixerate/editor/parameters");
6425
6493
 
6426
6494
  // src/parameters/fields.tsx
6427
- var import_react59 = require("react");
6495
+ var import_react60 = require("react");
6428
6496
  var import_parameters = require("@pixerate/editor/parameters");
6429
6497
 
6430
6498
  // src/color/index.ts
@@ -6437,7 +6505,7 @@ __export(color_exports, {
6437
6505
  });
6438
6506
 
6439
6507
  // src/color/ColorPicker.tsx
6440
- var import_react55 = require("react");
6508
+ var import_react56 = require("react");
6441
6509
  var import_color = require("@pixerate/editor/color");
6442
6510
  var import_jsx_runtime33 = require("react/jsx-runtime");
6443
6511
  var LOCAL_STORAGE_KEY = "pixerate:color:recent";
@@ -6477,24 +6545,24 @@ var ColorPicker = ({
6477
6545
  id,
6478
6546
  "aria-label": ariaLabel = "Color picker"
6479
6547
  }) => {
6480
- const generatedId = (0, import_react55.useId)();
6548
+ const generatedId = (0, import_react56.useId)();
6481
6549
  const pickerId = id || generatedId;
6482
- const [pickerState, setPickerState] = (0, import_react55.useState)(
6550
+ const [pickerState, setPickerState] = (0, import_react56.useState)(
6483
6551
  () => (0, import_color.pickerStateFromColor)(value) ?? DEFAULT_PICKER_STATE
6484
6552
  );
6485
- const stateRef = (0, import_react55.useRef)(pickerState);
6553
+ const stateRef = (0, import_react56.useRef)(pickerState);
6486
6554
  stateRef.current = pickerState;
6487
- (0, import_react55.useEffect)(() => {
6555
+ (0, import_react56.useEffect)(() => {
6488
6556
  const next = (0, import_color.pickerStateFromColor)(value, stateRef.current);
6489
6557
  if (next) {
6490
6558
  setPickerState(next);
6491
6559
  }
6492
6560
  }, [value]);
6493
- const [internalRecent, setInternalRecent] = (0, import_react55.useState)(
6561
+ const [internalRecent, setInternalRecent] = (0, import_react56.useState)(
6494
6562
  () => controlledRecent ? [] : readLocalRecents()
6495
6563
  );
6496
6564
  const activeRecent = controlledRecent ?? internalRecent;
6497
- const recordRecent = (0, import_react55.useCallback)(
6565
+ const recordRecent = (0, import_react56.useCallback)(
6498
6566
  (color) => {
6499
6567
  const updated = (0, import_color.pushRecentColor)(activeRecent, color, 12);
6500
6568
  if (!controlledRecent) {
@@ -6505,11 +6573,11 @@ var ColorPicker = ({
6505
6573
  },
6506
6574
  [activeRecent, controlledRecent, onRecentChange]
6507
6575
  );
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)(() => {
6576
+ const [textDraft, setTextDraft] = (0, import_react56.useState)(value);
6577
+ const [isInvalid, setIsInvalid] = (0, import_react56.useState)(false);
6578
+ const [isClipped, setIsClipped] = (0, import_react56.useState)(false);
6579
+ const isTypingRef = (0, import_react56.useRef)(false);
6580
+ (0, import_react56.useEffect)(() => {
6513
6581
  if (!isTypingRef.current) {
6514
6582
  setTextDraft(value);
6515
6583
  setIsInvalid(false);
@@ -6517,11 +6585,11 @@ var ColorPicker = ({
6517
6585
  setIsClipped(Boolean(parsed && !(0, import_color.inSrgbGamut)(parsed)));
6518
6586
  }
6519
6587
  }, [value]);
6520
- const [hasEyeDropper, setHasEyeDropper] = (0, import_react55.useState)(false);
6521
- (0, import_react55.useEffect)(() => {
6588
+ const [hasEyeDropper, setHasEyeDropper] = (0, import_react56.useState)(false);
6589
+ (0, import_react56.useEffect)(() => {
6522
6590
  setHasEyeDropper(typeof window !== "undefined" && "EyeDropper" in window);
6523
6591
  }, []);
6524
- const emitColorChange = (0, import_react55.useCallback)(
6592
+ const emitColorChange = (0, import_react56.useCallback)(
6525
6593
  (nextState) => {
6526
6594
  setPickerState(nextState);
6527
6595
  const hex = (0, import_color.pickerStateToHex)(nextState, alpha);
@@ -6529,10 +6597,10 @@ var ColorPicker = ({
6529
6597
  },
6530
6598
  [alpha, onChange]
6531
6599
  );
6532
- const latest = (0, import_react55.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
6600
+ const latest = (0, import_react56.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
6533
6601
  latest.current = { emitColorChange, recordRecent, onGestureEnd, alpha };
6534
- const endDragRef = (0, import_react55.useRef)(null);
6535
- (0, import_react55.useEffect)(() => () => endDragRef.current?.(), []);
6602
+ const endDragRef = (0, import_react56.useRef)(null);
6603
+ (0, import_react56.useEffect)(() => () => endDragRef.current?.(), []);
6536
6604
  const startDrag = (e, next) => {
6537
6605
  if (disabled) return;
6538
6606
  e.preventDefault();
@@ -6634,7 +6702,7 @@ var ColorPicker = ({
6634
6702
  } catch {
6635
6703
  }
6636
6704
  };
6637
- const contrastResult = (0, import_react55.useMemo)(() => {
6705
+ const contrastResult = (0, import_react56.useMemo)(() => {
6638
6706
  if (!contrastAgainst) return null;
6639
6707
  const fg = (0, import_color.parseColor)(value);
6640
6708
  const bg = (0, import_color.parseColor)(contrastAgainst);
@@ -7061,7 +7129,7 @@ var ColorPicker = ({
7061
7129
  };
7062
7130
 
7063
7131
  // src/color/DualColorPicker.tsx
7064
- var import_react56 = require("react");
7132
+ var import_react57 = require("react");
7065
7133
  var import_color2 = require("@pixerate/editor/color");
7066
7134
  var import_jsx_runtime34 = require("react/jsx-runtime");
7067
7135
  function DualColorPicker({
@@ -7078,8 +7146,8 @@ function DualColorPicker({
7078
7146
  disabled = false,
7079
7147
  className = ""
7080
7148
  }) {
7081
- const sameId = (0, import_react56.useId)();
7082
- const [internalScheme, setInternalScheme] = (0, import_react56.useState)("light");
7149
+ const sameId = (0, import_react57.useId)();
7150
+ const [internalScheme, setInternalScheme] = (0, import_react57.useState)("light");
7083
7151
  const activeScheme = controlledScheme ?? internalScheme;
7084
7152
  const handleSchemeSelect = (nextScheme) => {
7085
7153
  if (onSchemeChange) {
@@ -7090,7 +7158,7 @@ function DualColorPicker({
7090
7158
  };
7091
7159
  const dual = (0, import_color2.normalizeDualColor)(value) ?? { light: "#000000", dark: "#000000" };
7092
7160
  const isSame = dual.light.toLowerCase() === dual.dark.toLowerCase();
7093
- const [sameInBoth, setSameInBoth] = (0, import_react56.useState)(isSame);
7161
+ const [sameInBoth, setSameInBoth] = (0, import_react57.useState)(isSame);
7094
7162
  const handleSameToggle = (e) => {
7095
7163
  const nextSame = e.target.checked;
7096
7164
  setSameInBoth(nextSame);
@@ -7399,7 +7467,7 @@ function DualColorPicker({
7399
7467
  }
7400
7468
 
7401
7469
  // src/color/useColorScheme.ts
7402
- var import_react57 = require("react");
7470
+ var import_react58 = require("react");
7403
7471
  var import_color3 = require("@pixerate/editor/color");
7404
7472
  function getSnapshot(attribute) {
7405
7473
  if (typeof window === "undefined" || typeof document === "undefined") {
@@ -7424,7 +7492,7 @@ function getServerSnapshot() {
7424
7492
  function useColorScheme(options) {
7425
7493
  const override = options?.override;
7426
7494
  const attribute = options?.attribute;
7427
- const subscribe = (0, import_react57.useMemo)(() => {
7495
+ const subscribe = (0, import_react58.useMemo)(() => {
7428
7496
  return (callback) => {
7429
7497
  if (typeof window === "undefined" || typeof document === "undefined") {
7430
7498
  return () => {
@@ -7450,7 +7518,7 @@ function useColorScheme(options) {
7450
7518
  };
7451
7519
  };
7452
7520
  }, [attribute]);
7453
- const detected = (0, import_react57.useSyncExternalStore)(
7521
+ const detected = (0, import_react58.useSyncExternalStore)(
7454
7522
  subscribe,
7455
7523
  () => getSnapshot(attribute),
7456
7524
  getServerSnapshot
@@ -7467,11 +7535,11 @@ function useResolvedColor(value, scheme) {
7467
7535
  __reExport(color_exports, require("@pixerate/editor/color"));
7468
7536
 
7469
7537
  // src/parameters/controls.tsx
7470
- var import_react58 = require("react");
7538
+ var import_react59 = require("react");
7471
7539
  var import_jsx_runtime35 = require("react/jsx-runtime");
7472
- var ParameterComponentsContext = (0, import_react58.createContext)({});
7540
+ var ParameterComponentsContext = (0, import_react59.createContext)({});
7473
7541
  function useParameterComponents() {
7474
- return (0, import_react58.useContext)(ParameterComponentsContext);
7542
+ return (0, import_react59.useContext)(ParameterComponentsContext);
7475
7543
  }
7476
7544
  function resolveParameterComponents(explicit, context) {
7477
7545
  return {
@@ -7492,9 +7560,9 @@ var parameterInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-
7492
7560
  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";
7493
7561
  var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
7494
7562
  function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
7495
- const inputRef = (0, import_react59.useRef)(null);
7496
- const lastCommitted = (0, import_react59.useRef)(null);
7497
- (0, import_react59.useLayoutEffect)(() => {
7563
+ const inputRef = (0, import_react60.useRef)(null);
7564
+ const lastCommitted = (0, import_react60.useRef)(null);
7565
+ (0, import_react60.useLayoutEffect)(() => {
7498
7566
  lastCommitted.current = null;
7499
7567
  const el = inputRef.current;
7500
7568
  if (el && el.value !== value) el.value = value;
@@ -7505,9 +7573,9 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
7505
7573
  onCommit(text, el);
7506
7574
  lastCommitted.current = el.value === text ? text : null;
7507
7575
  };
7508
- const commitRef = (0, import_react59.useRef)(commit);
7576
+ const commitRef = (0, import_react60.useRef)(commit);
7509
7577
  commitRef.current = commit;
7510
- (0, import_react59.useEffect)(() => {
7578
+ (0, import_react60.useEffect)(() => {
7511
7579
  const el = inputRef.current;
7512
7580
  if (!el) return;
7513
7581
  const change = () => commitRef.current(el);
@@ -7582,7 +7650,7 @@ function ParameterSlider(props) {
7582
7650
  const ctx = useParameterComponents();
7583
7651
  const resolved = resolveParameterComponents(components, ctx);
7584
7652
  const CustomSlider = resolved.slider;
7585
- const dragging = (0, import_react59.useRef)(false);
7653
+ const dragging = (0, import_react60.useRef)(false);
7586
7654
  const start = () => {
7587
7655
  if (dragging.current) return;
7588
7656
  dragging.current = true;
@@ -7714,17 +7782,17 @@ function ParameterSelect(props) {
7714
7782
  }
7715
7783
  function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
7716
7784
  const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
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);
7785
+ const [open, setOpen] = (0, import_react60.useState)(false);
7786
+ const containerRef = (0, import_react60.useRef)(null);
7787
+ const buttonRef = (0, import_react60.useRef)(null);
7788
+ const popoverRef = (0, import_react60.useRef)(null);
7721
7789
  const alpha = !!field.alpha;
7722
7790
  const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
7723
7791
  const rgb = hex.slice(0, 7);
7724
7792
  const shown = alpha ? hex : rgb;
7725
7793
  const off = disabled || field.readOnly;
7726
7794
  const name = (0, import_parameters.parameterLabel)(field);
7727
- (0, import_react59.useEffect)(() => {
7795
+ (0, import_react60.useEffect)(() => {
7728
7796
  if (!open) return;
7729
7797
  const onPointerDown = (e) => {
7730
7798
  if (containerRef.current && !containerRef.current.contains(e.target)) {
@@ -7971,10 +8039,10 @@ function EffectParameters({
7971
8039
  className = "",
7972
8040
  components
7973
8041
  }) {
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);
8042
+ const fields = (0, import_react61.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
8043
+ const idBase = (0, import_react61.useId)();
8044
+ const gesture = import_react61.default.useRef(null);
8045
+ const count = import_react61.default.useRef(0);
7978
8046
  const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
7979
8047
  const handlePresetSelect = (name) => {
7980
8048
  if (!name) return;
@@ -8126,13 +8194,13 @@ function ImageEffectControls({ provider, effect, name, values, onChange, onPrese
8126
8194
  var import_jsx_runtime40 = require("react/jsx-runtime");
8127
8195
  var fmt = (ms) => `${(ms / 1e3).toFixed(ms < 1e4 ? 2 : 1)} s`;
8128
8196
  function ImageProviderEffectsPanel({ controller, className = "", components }) {
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);
8197
+ const [, setTick] = (0, import_react62.useState)(0);
8198
+ (0, import_react62.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
8199
+ const [browse, setBrowse] = (0, import_react62.useState)(null);
8200
+ const [clip, setClip] = (0, import_react62.useState)(false);
8201
+ const [message2, setMessage] = (0, import_react62.useState)(null);
8202
+ const [open, setOpen] = (0, import_react62.useState)(null);
8203
+ const [scrubbed, setScrubbed] = (0, import_react62.useState)(null);
8136
8204
  const provider = controller.effectsProvider;
8137
8205
  const state = controller.getState();
8138
8206
  const layer = state.activeLayerId ? (0, import_image_editor9.findLayer)(state.layers, state.activeLayerId)?.layer ?? null : null;
@@ -8140,7 +8208,7 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
8140
8208
  setMessage(null);
8141
8209
  Promise.resolve().then(work).catch((e) => setMessage(e instanceof Error ? e.message : String(e)));
8142
8210
  };
8143
- const drags = (0, import_react61.useRef)(/* @__PURE__ */ new Set());
8211
+ const drags = (0, import_react62.useRef)(/* @__PURE__ */ new Set());
8144
8212
  const commit = (gesture) => {
8145
8213
  if (gesture) {
8146
8214
  if (!drags.current.has(gesture)) {
@@ -8156,7 +8224,7 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
8156
8224
  const canFilter = !!provider && !!layer && layer.type !== "adjustment" && layer.type !== "annotation";
8157
8225
  const { description } = useEffectDescription(provider, generator?.effect);
8158
8226
  const timing = generator ? (0, import_image_editor9.effectLayerTiming)(generator, description) : null;
8159
- const scrub = (0, import_react61.useRef)({ next: null, busy: false, gesture: null });
8227
+ const scrub = (0, import_react62.useRef)({ next: null, busy: false, gesture: null });
8160
8228
  const scrubTo = (layerId, time) => {
8161
8229
  const s = scrub.current;
8162
8230
  setScrubbed(time);
@@ -8350,7 +8418,7 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
8350
8418
  }
8351
8419
 
8352
8420
  // src/image-editor/BrushOptionsBar.tsx
8353
- var import_react68 = require("react");
8421
+ var import_react69 = require("react");
8354
8422
  var import_image_editor11 = require("@pixerate/editor/image-editor");
8355
8423
  var import_image_editor12 = require("@pixerate/editor/image-editor");
8356
8424
 
@@ -8358,7 +8426,7 @@ var import_image_editor12 = require("@pixerate/editor/image-editor");
8358
8426
  var import_image_editor10 = require("@pixerate/editor/image-editor");
8359
8427
 
8360
8428
  // src/paint-editor/PaintGradientEditorView.tsx
8361
- var import_react62 = require("react");
8429
+ var import_react63 = require("react");
8362
8430
  var import_jsx_runtime41 = require("react/jsx-runtime");
8363
8431
  var button2 = "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700 disabled:opacity-40";
8364
8432
  var select = "rounded bg-slate-800 px-1 py-0.5 text-[11px]";
@@ -8380,7 +8448,7 @@ var PaintGradientEditorView = ({ value, onChange, colors, className, kit }) => {
8380
8448
  reversePaintGradient,
8381
8449
  updatePaintGradientStop
8382
8450
  } = kit;
8383
- const [selected, setSelected] = (0, import_react62.useState)(0);
8451
+ const [selected, setSelected] = (0, import_react63.useState)(0);
8384
8452
  const sel = Math.min(selected, value.stops.length - 1);
8385
8453
  const stop = value.stops[sel];
8386
8454
  const map = value.map;
@@ -8487,12 +8555,12 @@ var PaintGradientEditor = (props) => /* @__PURE__ */ (0, import_jsx_runtime42.js
8487
8555
  var import_brushes4 = require("@pixerate/editor/brushes");
8488
8556
 
8489
8557
  // src/brushes/BrushLibraryBrowser.tsx
8490
- var import_react63 = require("react");
8558
+ var import_react64 = require("react");
8491
8559
  var import_brushes = require("@pixerate/editor/brushes");
8492
8560
  var import_jsx_runtime43 = require("react/jsx-runtime");
8493
8561
  var Thumbnail2 = ({ image, label, style }) => {
8494
- const ref = (0, import_react63.useRef)(null);
8495
- (0, import_react63.useEffect)(() => {
8562
+ const ref = (0, import_react64.useRef)(null);
8563
+ (0, import_react64.useEffect)(() => {
8496
8564
  const canvas = ref.current;
8497
8565
  const ctx = canvas?.getContext("2d");
8498
8566
  if (!canvas || !ctx || !image || typeof image === "string" || typeof ctx.createImageData !== "function") return;
@@ -8506,8 +8574,8 @@ var Thumbnail2 = ({ image, label, style }) => {
8506
8574
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("canvas", { ref, role: "img", "aria-label": label, className: "rounded", style, width: image?.width, height: image?.height });
8507
8575
  };
8508
8576
  var BrushLibraryBrowser = ({ entries, activeId, onSelect, profile, thumbnail, thumbnailWidth = 112, thumbnailHeight = 32, className }) => {
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]);
8577
+ const [text, setText] = (0, import_react64.useState)("");
8578
+ const groups = (0, import_react64.useMemo)(() => (0, import_brushes.brushLibraryGroups)(entries, { text, profile }), [entries, text, profile]);
8511
8579
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: `flex flex-col gap-1 ${className ?? ""}`, "data-testid": "brush-library", children: [
8512
8580
  /* @__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" }),
8513
8581
  /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex flex-col gap-1.5", role: "listbox", "aria-label": "Brushes", children: [
@@ -8540,17 +8608,17 @@ var BrushLibraryBrowser = ({ entries, activeId, onSelect, profile, thumbnail, th
8540
8608
  };
8541
8609
 
8542
8610
  // src/brushes/BrushLibraryEditor.tsx
8543
- var import_react66 = require("react");
8611
+ var import_react67 = require("react");
8544
8612
  var import_brushes3 = require("@pixerate/editor/brushes");
8545
8613
 
8546
8614
  // src/paint-editor/shared.tsx
8547
- var import_react64 = require("react");
8615
+ var import_react65 = require("react");
8548
8616
  var import_jsx_runtime44 = require("react/jsx-runtime");
8549
8617
  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"}`;
8550
8618
  var button3 = "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700 disabled:opacity-40";
8551
8619
  var PixelCanvas = ({ pixels, label, className, style }) => {
8552
- const ref = (0, import_react64.useRef)(null);
8553
- (0, import_react64.useEffect)(() => {
8620
+ const ref = (0, import_react65.useRef)(null);
8621
+ (0, import_react65.useEffect)(() => {
8554
8622
  const canvas = ref.current;
8555
8623
  const ctx = canvas?.getContext("2d");
8556
8624
  if (!canvas || !ctx || !pixels || typeof ctx.createImageData !== "function") return;
@@ -8564,11 +8632,11 @@ var PixelCanvas = ({ pixels, label, className, style }) => {
8564
8632
  };
8565
8633
  var fmt2 = (c, v) => c.step >= 1 ? String(Math.round(v)) : v.toFixed(2);
8566
8634
  var PaintSlider = ({ control, value, onChange, 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);
8635
+ const [draft, setDraft] = (0, import_react65.useState)(null);
8636
+ const ref = (0, import_react65.useRef)(null);
8637
+ const commit = (0, import_react65.useRef)(onCommit);
8570
8638
  commit.current = onCommit;
8571
- (0, import_react64.useEffect)(() => {
8639
+ (0, import_react65.useEffect)(() => {
8572
8640
  const el = ref.current;
8573
8641
  if (!el) return;
8574
8642
  const done = () => {
@@ -8607,14 +8675,14 @@ var PaintSlider = ({ control, value, onChange, onCommit }) => {
8607
8675
  var ErrorLine = ({ error }) => error ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("p", { role: "alert", className: "text-[11px] text-rose-400", children: error }) : null;
8608
8676
 
8609
8677
  // src/brushes/BrushEditor.tsx
8610
- var import_react65 = __toESM(require("react"), 1);
8678
+ var import_react66 = __toESM(require("react"), 1);
8611
8679
  var import_brushes2 = require("@pixerate/editor/brushes");
8612
8680
  var import_jsx_runtime45 = require("react/jsx-runtime");
8613
8681
  var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, preview, previewBackground, onSave, saveLabel = "Save", onSaveAs, renderExtra, sources, onAddSource, className }) => {
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)("");
8682
+ const sections = (0, import_react66.useMemo)(() => (0, import_brushes2.brushEditorSections)(brush, profile, { sources }), [brush, profile, sources]);
8683
+ const scope = (0, import_react66.useMemo)(() => (0, import_brushes2.brushEditorScope)(brush, profile), [brush, profile]);
8684
+ const [problems, setProblems] = (0, import_react66.useState)(null);
8685
+ const [name, setName] = (0, import_react66.useState)("");
8618
8686
  const save = async (fn, after) => {
8619
8687
  try {
8620
8688
  await fn();
@@ -8643,7 +8711,7 @@ var BrushEditor = ({ brush, profile = import_brushes2.PAINT_PROFILE, onChange, p
8643
8711
  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 }),
8644
8712
  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: [
8645
8713
  /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "font-medium text-slate-300", children: s.title }),
8646
- s.controls.map((c) => /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_react65.default.Fragment, { children: [
8714
+ s.controls.map((c) => /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_react66.default.Fragment, { children: [
8647
8715
  /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(EditorControl, { control: c, onSet: set }),
8648
8716
  c.hint && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "text-[10px] leading-snug text-slate-400", "data-hint": c.path, children: c.hint }),
8649
8717
  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") })
@@ -8749,13 +8817,13 @@ var EditorControl = ({ control: c, onSet }) => {
8749
8817
  // src/brushes/BrushLibraryEditor.tsx
8750
8818
  var import_jsx_runtime46 = require("react/jsx-runtime");
8751
8819
  var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPaper = "#ffffff", previewColor, onSaved, onClose, className }) => {
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)(() => {
8820
+ const [original, setOriginal] = (0, import_react67.useState)(null);
8821
+ const [builtin, setBuiltin] = (0, import_react67.useState)(false);
8822
+ const [draft, setDraft] = (0, import_react67.useState)(null);
8823
+ const [status, setStatus] = (0, import_react67.useState)(null);
8824
+ const [preview, setPreview] = (0, import_react67.useState)(null);
8825
+ const [sources, setSources] = (0, import_react67.useState)([]);
8826
+ (0, import_react67.useEffect)(() => {
8759
8827
  let live = true;
8760
8828
  const read = () => void library.listSources().then((list) => live && setSources(list), () => void 0);
8761
8829
  read();
@@ -8765,7 +8833,7 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPap
8765
8833
  off();
8766
8834
  };
8767
8835
  }, [library]);
8768
- (0, import_react66.useEffect)(() => {
8836
+ (0, import_react67.useEffect)(() => {
8769
8837
  let live = true;
8770
8838
  setStatus(null);
8771
8839
  void (async () => {
@@ -8780,9 +8848,9 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPap
8780
8848
  };
8781
8849
  }, [library, brushId, profile]);
8782
8850
  const paper = renderPreview?.paper ?? previewPaper;
8783
- const colours = (0, import_react66.useMemo)(() => draft ? (0, import_brushes3.brushPreviewColours)(draft, { paper, profile }) : null, [draft, paper, profile]);
8851
+ const colours = (0, import_react67.useMemo)(() => draft ? (0, import_brushes3.brushPreviewColours)(draft, { paper, profile }) : null, [draft, paper, profile]);
8784
8852
  const colour = previewColor ?? colours?.color ?? "#475569";
8785
- (0, import_react66.useEffect)(() => {
8853
+ (0, import_react67.useEffect)(() => {
8786
8854
  if (!draft || !renderPreview) return;
8787
8855
  let live = true;
8788
8856
  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));
@@ -8790,7 +8858,7 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPap
8790
8858
  live = false;
8791
8859
  };
8792
8860
  }, [draft, renderPreview, colour]);
8793
- const check = (0, import_react66.useMemo)(() => draft ? (0, import_brushes3.checkBrushEdit)(original, draft, profile) : null, [original, draft, profile]);
8861
+ const check = (0, import_react67.useMemo)(() => draft ? (0, import_brushes3.checkBrushEdit)(original, draft, profile) : null, [original, draft, profile]);
8794
8862
  if (!draft) return null;
8795
8863
  const save = async (name) => {
8796
8864
  const saved = await (0, import_brushes3.saveBrushEdit)(library, { original, brush: draft, profile, ...name !== void 0 ? { name } : {} });
@@ -8851,12 +8919,12 @@ var BrushLibraryEditor = ({ library, brushId, profile, renderPreview, previewPap
8851
8919
  };
8852
8920
 
8853
8921
  // src/brushes/useBrushLibrary.ts
8854
- var import_react67 = require("react");
8922
+ var import_react68 = require("react");
8855
8923
  function useBrushLibrary(library, filter = {}) {
8856
- const [entries, setEntries] = (0, import_react67.useState)([]);
8924
+ const [entries, setEntries] = (0, import_react68.useState)([]);
8857
8925
  const { profile, ...rest } = filter;
8858
8926
  const key = `${profile?.id ?? ""}:${JSON.stringify(rest)}`;
8859
- (0, import_react67.useEffect)(() => {
8927
+ (0, import_react68.useEffect)(() => {
8860
8928
  if (!library) return;
8861
8929
  let live = true;
8862
8930
  const read = () => void library.list(filter).then((list) => live && setEntries(list), () => void 0);
@@ -8873,14 +8941,14 @@ function useBrushLibrary(library, filter = {}) {
8873
8941
  // src/image-editor/BrushOptionsBar.tsx
8874
8942
  var import_jsx_runtime47 = require("react/jsx-runtime");
8875
8943
  var BrushOptionsBar = ({ controller, showTools = true, renderBrushPreview, className }) => {
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);
8944
+ const [, setTick] = (0, import_react69.useState)(0);
8945
+ (0, import_react69.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
8946
+ const [error, setError] = (0, import_react69.useState)(null);
8879
8947
  const state = controller.getState();
8880
8948
  const { brush, foreground, background, mixer, mixerLoad, retouch, cloneSource, paint } = state.paint;
8881
8949
  const tool = state.activeTool;
8882
- const [presetsOpen, setPresetsOpen] = (0, import_react68.useState)(false);
8883
- const [editing, setEditing] = (0, import_react68.useState)(false);
8950
+ const [presetsOpen, setPresetsOpen] = (0, import_react69.useState)(false);
8951
+ const [editing, setEditing] = (0, import_react69.useState)(false);
8884
8952
  const presets = useBrushLibrary(presetsOpen ? controller.brushLibrary : null, { profile: import_brushes4.IMAGE_PROFILE });
8885
8953
  const presetName = presets.find((e) => e.brush.id === state.paint.brushPreset)?.brush.name ?? state.paint.brushPreset;
8886
8954
  const attempt = (fn) => {
@@ -9064,18 +9132,18 @@ var BrushOptionsBar = ({ controller, showTools = true, renderBrushPreview, class
9064
9132
  };
9065
9133
 
9066
9134
  // src/image-editor/ColorProfilePanel.tsx
9067
- var import_react69 = require("react");
9135
+ var import_react70 = require("react");
9068
9136
  var import_image_editor13 = require("@pixerate/editor/image-editor");
9069
9137
  var import_jsx_runtime48 = require("react/jsx-runtime");
9070
9138
  var chip2 = imageChipClass(false);
9071
9139
  var select2 = "rounded bg-muted px-1 py-0.5 text-[11px] text-foreground";
9072
9140
  var ColorProfilePanel = ({ controller, className }) => {
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);
9141
+ const [, setTick] = (0, import_react70.useState)(0);
9142
+ (0, import_react70.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
9143
+ const [target, setTarget] = (0, import_react70.useState)("display-p3");
9144
+ const [intent, setIntent] = (0, import_react70.useState)("relative");
9145
+ const [bpc, setBpc] = (0, import_react70.useState)(true);
9146
+ const [error, setError] = (0, import_react70.useState)(null);
9079
9147
  const view = (0, import_image_editor13.colorPanelView)(controller);
9080
9148
  const attempt = (fn) => {
9081
9149
  try {
@@ -9149,16 +9217,16 @@ var ColorProfilePanel = ({ controller, className }) => {
9149
9217
  };
9150
9218
 
9151
9219
  // src/image-editor/SelectionOptionsBar.tsx
9152
- var import_react73 = require("react");
9220
+ var import_react74 = require("react");
9153
9221
 
9154
9222
  // src/image-editor/SelectionRecipePanel.tsx
9155
- var import_react70 = require("react");
9223
+ var import_react71 = require("react");
9156
9224
  var import_image_editor14 = require("@pixerate/editor/image-editor");
9157
9225
  var import_jsx_runtime49 = require("react/jsx-runtime");
9158
9226
  var MODES2 = ["replace", "add", "subtract", "intersect"];
9159
9227
  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";
9160
9228
  var SelectionRecipePanel = ({ controller, className = "" }) => {
9161
- const [error, setError] = (0, import_react70.useState)(null);
9229
+ const [error, setError] = (0, import_react71.useState)(null);
9162
9230
  const recipe = controller.getSelectionRecipe();
9163
9231
  if (!recipe.live) return null;
9164
9232
  const run = (p) => {
@@ -9212,30 +9280,30 @@ var SelectionRecipePanel = ({ controller, className = "" }) => {
9212
9280
  var import_image_editor17 = require("@pixerate/editor/image-editor");
9213
9281
 
9214
9282
  // src/image-editor/SelectAndMaskWorkspace.tsx
9215
- var import_react71 = require("react");
9283
+ var import_react72 = require("react");
9216
9284
  var import_image_editor15 = require("@pixerate/editor/image-editor");
9217
9285
  var import_jsx_runtime50 = require("react/jsx-runtime");
9218
9286
  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";
9219
9287
  var toggle = (on) => `${button5} ${on ? "bg-primary text-primary-foreground border-primary" : ""}`;
9220
9288
  var SelectAndMaskWorkspace = ({ controller, onClose, className = "" }) => {
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);
9289
+ const session = (0, import_react72.useMemo)(() => new import_image_editor15.SelectAndMaskSession(controller), [controller]);
9290
+ const [, setRevision] = (0, import_react72.useState)(0);
9291
+ const [zoom, setZoom] = (0, import_react72.useState)(1);
9292
+ const [pan, setPan] = (0, import_react72.useState)({ x: 0, y: 0 });
9293
+ const [busy, setBusy] = (0, import_react72.useState)(false);
9294
+ const [error, setError] = (0, import_react72.useState)(null);
9295
+ const canvasRef = (0, import_react72.useRef)(null);
9296
+ const panFrom = (0, import_react72.useRef)(null);
9229
9297
  const settings = session.settings;
9230
9298
  const size = session.previewSize;
9231
- (0, import_react71.useEffect)(() => {
9299
+ (0, import_react72.useEffect)(() => {
9232
9300
  const off = session.subscribe(() => setRevision(session.revision));
9233
9301
  void session.open();
9234
9302
  return () => {
9235
9303
  off();
9236
9304
  };
9237
9305
  }, [session]);
9238
- (0, import_react71.useEffect)(() => {
9306
+ (0, import_react72.useEffect)(() => {
9239
9307
  const canvas = canvasRef.current;
9240
9308
  const ctx = canvas?.getContext?.("2d");
9241
9309
  if (!canvas || !ctx || !size.width || typeof ImageData === "undefined") return;
@@ -9254,7 +9322,7 @@ var SelectAndMaskWorkspace = ({ controller, onClose, className = "" }) => {
9254
9322
  setBusy(false);
9255
9323
  }
9256
9324
  };
9257
- (0, import_react71.useEffect)(() => {
9325
+ (0, import_react72.useEffect)(() => {
9258
9326
  const onKey = (e) => {
9259
9327
  const t = e.target;
9260
9328
  if (t && (t.tagName === "INPUT" || t.tagName === "SELECT" || t.tagName === "TEXTAREA")) return;
@@ -9473,31 +9541,31 @@ var SelectAndMaskWorkspace = ({ controller, onClose, className = "" }) => {
9473
9541
  };
9474
9542
 
9475
9543
  // src/image-editor/ContentAwareFillWorkspace.tsx
9476
- var import_react72 = require("react");
9544
+ var import_react73 = require("react");
9477
9545
  var import_image_editor16 = require("@pixerate/editor/image-editor");
9478
9546
  var import_jsx_runtime51 = require("react/jsx-runtime");
9479
9547
  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";
9480
9548
  var toggle2 = (on) => `${button6} ${on ? "bg-primary text-primary-foreground border-primary" : ""}`;
9481
9549
  var ContentAwareFillWorkspace = ({ controller, onClose, className = "" }) => {
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);
9550
+ const session = (0, import_react73.useMemo)(() => new import_image_editor16.ContentAwareFillSession(controller), [controller]);
9551
+ const [, setRevision] = (0, import_react73.useState)(0);
9552
+ const [zoom, setZoom] = (0, import_react73.useState)(1);
9553
+ const [pan, setPan] = (0, import_react73.useState)({ x: 0, y: 0 });
9554
+ const [busy, setBusy] = (0, import_react73.useState)(false);
9555
+ const [error, setError] = (0, import_react73.useState)(null);
9556
+ const sourceRef = (0, import_react73.useRef)(null);
9557
+ const previewRef = (0, import_react73.useRef)(null);
9558
+ const panFrom = (0, import_react73.useRef)(null);
9491
9559
  const settings = session.settings;
9492
9560
  const win = session.window;
9493
- (0, import_react72.useEffect)(() => {
9561
+ (0, import_react73.useEffect)(() => {
9494
9562
  const off = session.subscribe(() => setRevision(session.revision));
9495
9563
  void session.open();
9496
9564
  return () => {
9497
9565
  off();
9498
9566
  };
9499
9567
  }, [session]);
9500
- (0, import_react72.useEffect)(() => {
9568
+ (0, import_react73.useEffect)(() => {
9501
9569
  if (!win || typeof ImageData === "undefined") return;
9502
9570
  for (const [canvas, rgba] of [
9503
9571
  [sourceRef.current, session.renderSource()],
@@ -9521,7 +9589,7 @@ var ContentAwareFillWorkspace = ({ controller, onClose, className = "" }) => {
9521
9589
  setBusy(false);
9522
9590
  }
9523
9591
  };
9524
- (0, import_react72.useEffect)(() => {
9592
+ (0, import_react73.useEffect)(() => {
9525
9593
  const onKey = (e) => {
9526
9594
  const t = e.target;
9527
9595
  if (t && (t.tagName === "INPUT" || t.tagName === "SELECT" || t.tagName === "TEXTAREA")) return;
@@ -9707,15 +9775,15 @@ var SelectionOptionsBar = ({
9707
9775
  showTools = true,
9708
9776
  className = ""
9709
9777
  }) => {
9710
- const [radius, setRadius] = (0, import_react73.useState)(2);
9778
+ const [radius, setRadius] = (0, import_react74.useState)(2);
9711
9779
  const set = (patch) => onOptionsChange({ ...options, ...patch });
9712
9780
  const sel = selection === void 0 ? controller.getSelection() : selection;
9713
9781
  const display = selectionDisplay ?? (quickMask === void 0 ? controller.getSelectionDisplay() : quickMask ? "quickMask" : "ants");
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");
9782
+ const [preset, setPreset] = (0, import_react74.useState)("reds");
9783
+ const [rangeStatus, setRangeStatus] = (0, import_react74.useState)(null);
9784
+ const [colorStatus, setColorStatus] = (0, import_react74.useState)(null);
9785
+ const [strokeWidth, setStrokeWidth] = (0, import_react74.useState)(4);
9786
+ const [strokeLocation, setStrokeLocation] = (0, import_react74.useState)("outside");
9719
9787
  const edit = (fn) => {
9720
9788
  setColorStatus(null);
9721
9789
  try {
@@ -9748,8 +9816,8 @@ var SelectionOptionsBar = ({
9748
9816
  setRangeStatus(err instanceof Error ? err.message : String(err));
9749
9817
  }
9750
9818
  };
9751
- const [task, setTask] = (0, import_react73.useState)(null);
9752
- const taskAbort = (0, import_react73.useRef)(null);
9819
+ const [task, setTask] = (0, import_react74.useState)(null);
9820
+ const taskAbort = (0, import_react74.useRef)(null);
9753
9821
  const tracked = () => {
9754
9822
  const abort = new AbortController();
9755
9823
  taskAbort.current = abort;
@@ -9761,9 +9829,9 @@ var SelectionOptionsBar = ({
9761
9829
  setTask(null);
9762
9830
  };
9763
9831
  const failure = (err) => err?.name === "AbortError" ? "Cancelled." : err instanceof Error ? err.message : String(err);
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);
9832
+ const [subject, setSubject] = (0, import_react74.useState)("");
9833
+ const [segmenting, setSegmenting] = (0, import_react74.useState)(false);
9834
+ const [subjectStatus, setSubjectStatus] = (0, import_react74.useState)(null);
9767
9835
  const selectSubject = async () => {
9768
9836
  const target = subject.trim();
9769
9837
  const canSegment = Boolean(controller.segmentationProvider);
@@ -9780,10 +9848,10 @@ var SelectionOptionsBar = ({
9780
9848
  setSegmenting(false);
9781
9849
  }
9782
9850
  };
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);
9851
+ const [workspace, setWorkspace] = (0, import_react74.useState)(false);
9852
+ const [fillWorkspace, setFillWorkspace] = (0, import_react74.useState)(false);
9853
+ const [skying, setSkying] = (0, import_react74.useState)(false);
9854
+ const [skyStatus, setSkyStatus] = (0, import_react74.useState)(null);
9787
9855
  const selectSky = async () => {
9788
9856
  if (skying) return;
9789
9857
  setSkying(true);
@@ -9798,8 +9866,8 @@ var SelectionOptionsBar = ({
9798
9866
  setSkying(false);
9799
9867
  }
9800
9868
  };
9801
- const [focusing, setFocusing] = (0, import_react73.useState)(false);
9802
- const [focusStatus, setFocusStatus] = (0, import_react73.useState)(null);
9869
+ const [focusing, setFocusing] = (0, import_react74.useState)(false);
9870
+ const [focusStatus, setFocusStatus] = (0, import_react74.useState)(null);
9803
9871
  const selectFocusArea = async () => {
9804
9872
  if (focusing) return;
9805
9873
  setFocusing(true);
@@ -10221,18 +10289,18 @@ var SelectionOptionsBar = ({
10221
10289
  };
10222
10290
 
10223
10291
  // src/image-editor/RefineEdgePanel.tsx
10224
- var import_react77 = require("react");
10292
+ var import_react78 = require("react");
10225
10293
  var import_image_editor19 = require("@pixerate/editor/image-editor");
10226
10294
 
10227
10295
  // src/image-editor/MaskEdgeCheck.tsx
10228
- var import_react74 = __toESM(require("react"), 1);
10296
+ var import_react75 = __toESM(require("react"), 1);
10229
10297
  var import_image_editor18 = require("@pixerate/editor/image-editor");
10230
10298
  var import_jsx_runtime53 = require("react/jsx-runtime");
10231
10299
  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";
10232
10300
  var MaskEdgeCheck = ({ controller, selection, target = "selection", layerId, className = "" }) => {
10233
10301
  const sel = selection === void 0 ? controller.getSelection() : selection;
10234
- const [result, setResult] = (0, import_react74.useState)(null);
10235
- const [error, setError] = (0, import_react74.useState)(null);
10302
+ const [result, setResult] = (0, import_react75.useState)(null);
10303
+ const [error, setError] = (0, import_react75.useState)(null);
10236
10304
  const report = result && (target !== "selection" || result.for === sel) ? result.report : null;
10237
10305
  const check = () => {
10238
10306
  setError(null);
@@ -10254,7 +10322,7 @@ var MaskEdgeCheck = ({ controller, selection, target = "selection", layerId, cla
10254
10322
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("button", { type: "button", className: `${button7} self-start`, disabled: target === "selection" && !sel, onClick: check, children: "Check Edge" }),
10255
10323
  report && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
10256
10324
  /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("dl", { className: "grid grid-cols-[1fr_auto] gap-x-2 gap-y-0.5", children: [
10257
- rows.map((r) => /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_react74.default.Fragment, { children: [
10325
+ rows.map((r) => /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_react75.default.Fragment, { children: [
10258
10326
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("dt", { className: "text-muted-foreground", children: r.label }),
10259
10327
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("dd", { className: `font-mono text-right ${r.bad ? "text-destructive" : "text-foreground"}`, children: r.value })
10260
10328
  ] }, r.label)),
@@ -10272,13 +10340,13 @@ var MaskEdgeCheck = ({ controller, selection, target = "selection", layerId, cla
10272
10340
  };
10273
10341
 
10274
10342
  // src/image-editor/SelectionChangeCheck.tsx
10275
- var import_react75 = require("react");
10343
+ var import_react76 = require("react");
10276
10344
  var import_jsx_runtime54 = require("react/jsx-runtime");
10277
10345
  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";
10278
10346
  var SelectionChangeCheck = ({ controller, selection, className = "" }) => {
10279
10347
  const sel = selection === void 0 ? controller.getSelection() : selection;
10280
- const [result, setResult] = (0, import_react75.useState)(null);
10281
- const [error, setError] = (0, import_react75.useState)(null);
10348
+ const [result, setResult] = (0, import_react76.useState)(null);
10349
+ const [error, setError] = (0, import_react76.useState)(null);
10282
10350
  const diff = result && result.for === sel ? result.diff : null;
10283
10351
  const show = () => {
10284
10352
  setError(null);
@@ -10312,16 +10380,16 @@ var SelectionChangeCheck = ({ controller, selection, className = "" }) => {
10312
10380
  };
10313
10381
 
10314
10382
  // src/image-editor/SeparateSubjectPanel.tsx
10315
- var import_react76 = require("react");
10383
+ var import_react77 = require("react");
10316
10384
  var import_jsx_runtime55 = require("react/jsx-runtime");
10317
10385
  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";
10318
10386
  var SeparateSubjectPanel = ({ controller, selection, className = "" }) => {
10319
10387
  const sel = selection === void 0 ? controller.getSelection() : selection;
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);
10388
+ const [dilate, setDilate] = (0, import_react77.useState)(8);
10389
+ const [fill, setFill] = (0, import_react77.useState)(true);
10390
+ const [progress, setProgress] = (0, import_react77.useState)(null);
10391
+ const [error, setError] = (0, import_react77.useState)(null);
10392
+ const abort = (0, import_react77.useRef)(null);
10325
10393
  const run = async () => {
10326
10394
  setError(null);
10327
10395
  abort.current = new AbortController();
@@ -10379,15 +10447,15 @@ var import_jsx_runtime56 = require("react/jsx-runtime");
10379
10447
  var DEFAULT_PARAMS = { radius: 8, smartRadius: false, smooth: 0, feather: 0, contrast: 0, shiftEdge: 0 };
10380
10448
  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";
10381
10449
  var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
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);
10450
+ const [params, setParams] = (0, import_react78.useState)(DEFAULT_PARAMS);
10451
+ const [busy, setBusy] = (0, import_react78.useState)(false);
10452
+ const [error, setError] = (0, import_react78.useState)(null);
10453
+ const [layerId, setLayerId] = (0, import_react78.useState)("");
10454
+ const [newKind, setNewKind] = (0, import_react78.useState)("hueSaturation");
10455
+ const [output, setOutput] = (0, import_react78.useState)("selection");
10456
+ const [decontaminate, setDecontaminate] = (0, import_react78.useState)(0);
10457
+ const [objectAware, setObjectAware] = (0, import_react78.useState)(false);
10458
+ const [onlyUncertain, setOnlyUncertain] = (0, import_react78.useState)(false);
10391
10459
  const canObject = Boolean(controller.segmentationProvider);
10392
10460
  const toLayer = output !== "selection" && output !== "layer-mask";
10393
10461
  const sel = selection === void 0 ? controller.getSelection() : selection;
@@ -10586,13 +10654,13 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
10586
10654
  };
10587
10655
 
10588
10656
  // src/image-editor/ChannelsPanel.tsx
10589
- var import_react78 = require("react");
10657
+ var import_react79 = require("react");
10590
10658
  var import_image_editor20 = require("@pixerate/editor/image-editor");
10591
10659
  var import_jsx_runtime57 = require("react/jsx-runtime");
10592
10660
  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"}`;
10593
10661
  var ChannelThumb = ({ channel, size }) => {
10594
- const ref = (0, import_react78.useRef)(null);
10595
- (0, import_react78.useEffect)(() => {
10662
+ const ref = (0, import_react79.useRef)(null);
10663
+ (0, import_react79.useEffect)(() => {
10596
10664
  const canvas = ref.current;
10597
10665
  const ctx = canvas?.getContext("2d");
10598
10666
  if (!canvas || !ctx || typeof ctx.createImageData !== "function") return;
@@ -10606,12 +10674,12 @@ var ChannelThumb = ({ channel, size }) => {
10606
10674
  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" });
10607
10675
  };
10608
10676
  var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
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);
10677
+ const [, setTick] = (0, import_react79.useState)(0);
10678
+ (0, import_react79.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
10679
+ const [activeId, setActiveId] = (0, import_react79.useState)(null);
10680
+ const [renaming, setRenaming] = (0, import_react79.useState)(null);
10681
+ const [error, setError] = (0, import_react79.useState)(null);
10682
+ const fileInput = (0, import_react79.useRef)(null);
10615
10683
  const channels = controller.getChannels();
10616
10684
  const active = channels.find((c) => c.id === activeId) ?? null;
10617
10685
  const hasSelection = Boolean(controller.getSelection());
@@ -10737,17 +10805,17 @@ var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
10737
10805
  };
10738
10806
 
10739
10807
  // src/image-editor/PathsPanel.tsx
10740
- var import_react79 = require("react");
10808
+ var import_react80 = require("react");
10741
10809
  var import_image_editor21 = require("@pixerate/editor/image-editor");
10742
10810
  var import_jsx_runtime58 = require("react/jsx-runtime");
10743
10811
  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"}`;
10744
10812
  var PathsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
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);
10813
+ const [, setTick] = (0, import_react80.useState)(0);
10814
+ (0, import_react80.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
10815
+ const [renaming, setRenaming] = (0, import_react80.useState)(null);
10816
+ const [color, setColor] = (0, import_react80.useState)("#000000");
10817
+ const [width, setWidth] = (0, import_react80.useState)(2);
10818
+ const [error, setError] = (0, import_react80.useState)(null);
10751
10819
  const paths = controller.getPaths();
10752
10820
  const activeId = controller.getState().activePathId ?? null;
10753
10821
  const active = paths.find((p) => p.id === activeId) ?? null;
@@ -10847,13 +10915,13 @@ var PathsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
10847
10915
  };
10848
10916
 
10849
10917
  // src/image-editor/FreeTransformOptionsBar.tsx
10850
- var import_react80 = require("react");
10918
+ var import_react81 = require("react");
10851
10919
  var import_image_editor22 = require("@pixerate/editor/image-editor");
10852
10920
  var import_jsx_runtime59 = require("react/jsx-runtime");
10853
10921
  var round = (v, unit) => unit === "px" ? Math.round(v * 10) / 10 : Math.round(v * 100) / 100;
10854
10922
  var FreeTransformOptionsBar = ({ tool, className }) => {
10855
- const [, setTick] = (0, import_react80.useState)(0);
10856
- (0, import_react80.useEffect)(() => tool.subscribe(() => setTick((n) => n + 1)), [tool]);
10923
+ const [, setTick] = (0, import_react81.useState)(0);
10924
+ (0, import_react81.useEffect)(() => tool.subscribe(() => setTick((n) => n + 1)), [tool]);
10857
10925
  const bar = tool.bar();
10858
10926
  if (!tool.active || !bar) return null;
10859
10927
  const warp = tool.warpBar();
@@ -10985,13 +11053,13 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
10985
11053
  };
10986
11054
 
10987
11055
  // src/image-editor/ShapeOptionsBar.tsx
10988
- var import_react81 = require("react");
11056
+ var import_react82 = require("react");
10989
11057
  var import_image_editor23 = require("@pixerate/editor/image-editor");
10990
11058
  var import_jsx_runtime60 = require("react/jsx-runtime");
10991
11059
  var ShapeOptionsBar = ({ controller, options, onChange, showTools = true, className }) => {
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);
11060
+ const [, setTick] = (0, import_react82.useState)(0);
11061
+ (0, import_react82.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
11062
+ const [error, setError] = (0, import_react82.useState)(null);
10995
11063
  const active = controller.getActiveLayer();
10996
11064
  const shapeId = active?.type === "shape" ? active.id : null;
10997
11065
  const set = (change) => {
@@ -11070,16 +11138,16 @@ var ShapeOptionsBar = ({ controller, options, onChange, showTools = true, classN
11070
11138
  };
11071
11139
 
11072
11140
  // src/image-editor/TypeOptionsBar.tsx
11073
- var import_react82 = require("react");
11141
+ var import_react83 = require("react");
11074
11142
  var import_image_editor24 = require("@pixerate/editor/image-editor");
11075
11143
  var import_jsx_runtime61 = require("react/jsx-runtime");
11076
11144
  var ALIGN_LABELS = { left: "Left", center: "Centre", right: "Right", justify: "Justify" };
11077
11145
  var ORIENTATION_LABELS = { horizontal: "Horizontal", vertical: "Vertical" };
11078
11146
  var TypeOptionsBar = ({ controller, options, onChange, session, className }) => {
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);
11147
+ const [, setTick] = (0, import_react83.useState)(0);
11148
+ (0, import_react83.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
11149
+ (0, import_react83.useEffect)(() => session?.subscribe(() => setTick((n) => n + 1)), [session]);
11150
+ const [error, setError] = (0, import_react83.useState)(null);
11083
11151
  const active = controller.getActiveLayer();
11084
11152
  const typeId = !session && active?.type === "type" ? active.id : null;
11085
11153
  const here = session?.alive ? session.styleHere() : {};
@@ -11219,32 +11287,32 @@ var ImageEditor = ({
11219
11287
  return l.type === "pixel" && !!l.generator || l.type === "smart" && !!l.smartFilters?.filters.some((f) => f.kind === "effect") || l.type === "group" && l.children.some(has);
11220
11288
  });
11221
11289
  const legacyProcess = (0, import_image_editor25.normalizeProcessVersion)(state.adjustments.process) < import_image_editor25.LATEST_PROCESS_VERSION;
11222
- const [activeTab, setActiveTab] = (0, import_react83.useState)("crop");
11223
- const rootRef = (0, import_react83.useRef)(null);
11290
+ const [activeTab, setActiveTab] = (0, import_react84.useState)("crop");
11291
+ const rootRef = (0, import_react84.useRef)(null);
11224
11292
  const canvasMode = activeTab === "crop" || activeTab === "select" || activeTab === "paint" || activeTab === "annotate" ? activeTab : "none";
11225
- const activeTabRef = (0, import_react83.useRef)(activeTab);
11293
+ const activeTabRef = (0, import_react84.useRef)(activeTab);
11226
11294
  activeTabRef.current = activeTab;
11227
11295
  const openPanel = async (ref) => {
11228
11296
  if (ref.kind !== "panel" || activeTabRef.current === ref.id) return;
11229
11297
  rootRef.current?.querySelector(`[data-image-tab="${CSS.escape(ref.id)}"]`)?.click();
11230
11298
  await new Promise((resolve) => setTimeout(resolve, 60));
11231
11299
  };
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);
11300
+ const [activeCropRatio, setActiveCropRatio] = (0, import_react84.useState)(null);
11301
+ const [selectionOptions, setSelectionOptions] = (0, import_react84.useState)(import_image_editor25.DEFAULT_SELECTION_TOOL_OPTIONS);
11302
+ const [shapeOptions, setShapeOptions] = (0, import_react84.useState)(import_image_editor25.DEFAULT_SHAPE_TOOL_OPTIONS);
11303
+ const [typeOptions, setTypeOptions] = (0, import_react84.useState)(import_image_editor25.DEFAULT_TYPE_TOOL_OPTIONS);
11304
+ const [typeSession, setTypeSession] = (0, import_react84.useState)(null);
11305
+ const [selectionError, setSelectionError] = (0, import_react84.useState)(null);
11306
+ const [paintError, setPaintError] = (0, import_react84.useState)(null);
11307
+ const [shapeTypeError, setShapeTypeError] = (0, import_react84.useState)(null);
11240
11308
  const handleCanvasError = (source, message2) => {
11241
11309
  if (source === "paint") setPaintError(message2);
11242
11310
  else if (source === "select") setSelectionError(message2);
11243
11311
  else setShapeTypeError(message2);
11244
11312
  };
11245
11313
  const finishTyping = () => setTypeSession(null);
11246
- const transformToolRef = (0, import_react83.useRef)(null);
11247
- const transformControllerRef = (0, import_react83.useRef)(controller);
11314
+ const transformToolRef = (0, import_react84.useRef)(null);
11315
+ const transformControllerRef = (0, import_react84.useRef)(controller);
11248
11316
  if (!transformToolRef.current || transformControllerRef.current !== controller) {
11249
11317
  transformToolRef.current?.cancel();
11250
11318
  transformToolRef.current = new import_image_editor25.FreeTransformTool(controller, {
@@ -11253,16 +11321,16 @@ var ImageEditor = ({
11253
11321
  transformControllerRef.current = controller;
11254
11322
  }
11255
11323
  const transformTool = transformToolRef.current;
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");
11324
+ const [, setTransformTick] = (0, import_react84.useState)(0);
11325
+ (0, import_react84.useEffect)(() => transformTool.subscribe(() => setTransformTick((n) => n + 1)), [transformTool]);
11326
+ (0, import_react84.useEffect)(() => () => transformToolRef.current?.cancel(), []);
11327
+ const [inpaintPrompt, setInpaintPrompt] = (0, import_react84.useState)("");
11328
+ const [inpaintMaskMode, setInpaintMaskMode] = (0, import_react84.useState)("annotations");
11329
+ const [isRemovingBg, setIsRemovingBg] = (0, import_react84.useState)(false);
11330
+ const [isInpainting, setIsInpainting] = (0, import_react84.useState)(false);
11331
+ const [aiError, setAiError] = (0, import_react84.useState)(null);
11332
+ const [aiSuccess, setAiSuccess] = (0, import_react84.useState)(null);
11333
+ const [aiTarget, setAiTarget] = (0, import_react84.useState)("auto");
11266
11334
  const aiOptions = aiTarget === "auto" ? {} : { target: aiTarget };
11267
11335
  const effectiveOnInpaint = onInpaint || aiHooks?.onInpaint;
11268
11336
  const effectiveOnRemoveBg = onRemoveBackground || aiHooks?.onRemoveBackground;
@@ -11325,11 +11393,11 @@ var ImageEditor = ({
11325
11393
  setIsInpainting(false);
11326
11394
  }
11327
11395
  };
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)(() => {
11396
+ const [activeColor, setActiveColor] = (0, import_react84.useState)("#ef4444");
11397
+ const [strokeWidth, setStrokeWidth] = (0, import_react84.useState)(3);
11398
+ const [fontSize, setFontSize] = (0, import_react84.useState)(24);
11399
+ const [textInput, setTextInput] = (0, import_react84.useState)("");
11400
+ (0, import_react84.useEffect)(() => {
11333
11401
  if (activeTab === "crop" && editor.state.activeTool !== "crop") {
11334
11402
  editor.setTool("crop");
11335
11403
  }
@@ -11729,7 +11797,7 @@ var ImageEditor = ({
11729
11797
  )
11730
11798
  ] }),
11731
11799
  /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Histogram, { histogram: editor.histogram }),
11732
- import_image_editor25.IMAGE_ADJUSTMENT_CONTROLS.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_react83.default.Fragment, { children: [
11800
+ import_image_editor25.IMAGE_ADJUSTMENT_CONTROLS.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_react84.default.Fragment, { children: [
11733
11801
  /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
11734
11802
  ControlSlider,
11735
11803
  {
@@ -12223,7 +12291,7 @@ var ImageEditor = ({
12223
12291
  };
12224
12292
 
12225
12293
  // src/review/useReview.ts
12226
- var import_react84 = require("react");
12294
+ var import_react85 = require("react");
12227
12295
  var import_editor13 = require("@pixerate/editor");
12228
12296
  var EMPTY_COMMENTS = Object.freeze({
12229
12297
  threads: [],
@@ -12242,23 +12310,23 @@ function isCommentStore(value) {
12242
12310
  }
12243
12311
  function useComments(source) {
12244
12312
  const store = isCommentStore(source) ? source : (0, import_editor13.getCommentStore)(source);
12245
- const subscribe = (0, import_react84.useCallback)(
12313
+ const subscribe = (0, import_react85.useCallback)(
12246
12314
  (onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe,
12247
12315
  [store]
12248
12316
  );
12249
12317
  const getSnapshot2 = () => store?.getSnapshot() ?? EMPTY_COMMENTS;
12250
- const snapshot = (0, import_react84.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
12251
- return (0, import_react84.useMemo)(() => ({ ...snapshot, store }), [snapshot, store]);
12318
+ const snapshot = (0, import_react85.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
12319
+ return (0, import_react85.useMemo)(() => ({ ...snapshot, store }), [snapshot, store]);
12252
12320
  }
12253
12321
  function useTrackChanges(editor) {
12254
12322
  const store = (0, import_editor13.getTrackChangesStore)(editor ?? null);
12255
- const subscribe = (0, import_react84.useCallback)(
12323
+ const subscribe = (0, import_react85.useCallback)(
12256
12324
  (onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe,
12257
12325
  [store]
12258
12326
  );
12259
12327
  const getSnapshot2 = () => store?.getSnapshot() ?? EMPTY_TRACK_CHANGES;
12260
- const snapshot = (0, import_react84.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
12261
- return (0, import_react84.useMemo)(() => {
12328
+ const snapshot = (0, import_react85.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
12329
+ return (0, import_react85.useMemo)(() => {
12262
12330
  const run = (fn) => () => {
12263
12331
  if (editor && !editor.isDestroyed) fn(editor);
12264
12332
  };
@@ -12281,7 +12349,7 @@ function useTrackChanges(editor) {
12281
12349
  }
12282
12350
 
12283
12351
  // src/review/CommentsPanel.tsx
12284
- var import_react85 = require("react");
12352
+ var import_react86 = require("react");
12285
12353
  var import_editor14 = require("@pixerate/editor");
12286
12354
  var import_jsx_runtime63 = require("react/jsx-runtime");
12287
12355
  var buttonClass2 = "rounded px-2 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-50";
@@ -12297,7 +12365,7 @@ var CommentsPanel = ({
12297
12365
  emptyMessage = "No comments yet. Select text and add a comment."
12298
12366
  }) => {
12299
12367
  const { threads, activeThreadId, store } = useComments(storeProp ?? editor);
12300
- const [showResolved, setShowResolved] = (0, import_react85.useState)(showResolvedInitial);
12368
+ const [showResolved, setShowResolved] = (0, import_react86.useState)(showResolvedInitial);
12301
12369
  const author = authorProp ?? (0, import_editor14.getCommentAuthor)(editor) ?? { id: "anonymous", name: "Anonymous" };
12302
12370
  const visible = threads.filter((t) => showResolved || !t.resolved);
12303
12371
  const resolvedCount = threads.filter((t) => t.resolved).length;
@@ -12341,7 +12409,7 @@ var CommentThreadCard = ({
12341
12409
  author,
12342
12410
  formatTime
12343
12411
  }) => {
12344
- const [draft, setDraft] = (0, import_react85.useState)("");
12412
+ const [draft, setDraft] = (0, import_react86.useState)("");
12345
12413
  const isDraft = thread.body === "";
12346
12414
  const quote = thread.anchor?.quote ?? thread.lastQuote ?? "";
12347
12415
  const live = editor && !editor.isDestroyed ? editor : null;
@@ -12555,13 +12623,13 @@ var CommentButton = ({
12555
12623
  );
12556
12624
 
12557
12625
  // src/review/useDocumentCompare.ts
12558
- var import_react86 = require("react");
12626
+ var import_react87 = require("react");
12559
12627
  var import_editor15 = require("@pixerate/editor");
12560
12628
  function useDocumentCompare(editor, options) {
12561
- const [summary, setSummary] = (0, import_react86.useState)(null);
12562
- const defaults = (0, import_react86.useRef)(options);
12629
+ const [summary, setSummary] = (0, import_react87.useState)(null);
12630
+ const defaults = (0, import_react87.useRef)(options);
12563
12631
  defaults.current = options;
12564
- const compare = (0, import_react86.useCallback)(
12632
+ const compare = (0, import_react87.useCallback)(
12565
12633
  (original, revised, overrides) => {
12566
12634
  if (!editor || editor.isDestroyed) return null;
12567
12635
  const result = (0, import_editor15.applyDocumentComparison)(editor, original, revised, {
@@ -12573,8 +12641,8 @@ function useDocumentCompare(editor, options) {
12573
12641
  },
12574
12642
  [editor]
12575
12643
  );
12576
- const clear = (0, import_react86.useCallback)(() => setSummary(null), []);
12577
- return (0, import_react86.useMemo)(() => ({ summary, compare, clear }), [summary, compare, clear]);
12644
+ const clear = (0, import_react87.useCallback)(() => setSummary(null), []);
12645
+ return (0, import_react87.useMemo)(() => ({ summary, compare, clear }), [summary, compare, clear]);
12578
12646
  }
12579
12647
 
12580
12648
  // src/review/TrackedChangesList.tsx
@@ -12625,12 +12693,12 @@ var TrackedChangesList = ({
12625
12693
  };
12626
12694
 
12627
12695
  // src/commands/useCommandPalette.ts
12628
- var import_react87 = require("react");
12696
+ var import_react88 = require("react");
12629
12697
  var import_commands2 = require("@pixerate/editor/commands");
12630
12698
  function useCommandPalette(registry, options = {}) {
12631
- const optionsRef = (0, import_react87.useRef)(options);
12699
+ const optionsRef = (0, import_react88.useRef)(options);
12632
12700
  optionsRef.current = options;
12633
- const controller = (0, import_react87.useMemo)(
12701
+ const controller = (0, import_react88.useMemo)(
12634
12702
  () => (0, import_commands2.createCommandPaletteController)(registry, {
12635
12703
  context: () => {
12636
12704
  const c = optionsRef.current.context;
@@ -12651,9 +12719,9 @@ function useCommandPalette(registry, options = {}) {
12651
12719
  // eslint-disable-next-line react-hooks/exhaustive-deps
12652
12720
  [registry]
12653
12721
  );
12654
- const state = (0, import_react87.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
12722
+ const state = (0, import_react88.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
12655
12723
  const { hotkey, hotkeyTarget } = options;
12656
- (0, import_react87.useEffect)(() => {
12724
+ (0, import_react88.useEffect)(() => {
12657
12725
  if (!hotkey) return;
12658
12726
  const target = hotkeyTarget ?? (typeof window !== "undefined" ? window : null);
12659
12727
  if (!target) return;
@@ -12681,13 +12749,13 @@ function useCommandPalette(registry, options = {}) {
12681
12749
  }
12682
12750
 
12683
12751
  // src/commands/CommandPalette.tsx
12684
- var import_react88 = __toESM(require("react"), 1);
12752
+ var import_react89 = __toESM(require("react"), 1);
12685
12753
  var import_jsx_runtime67 = require("react/jsx-runtime");
12686
12754
  function HighlightedLabel({ item }) {
12687
12755
  if (item.labelIndices.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_jsx_runtime67.Fragment, { children: item.label });
12688
12756
  const marked = new Set(item.labelIndices);
12689
12757
  return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_jsx_runtime67.Fragment, { children: Array.from(item.label).map(
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)
12758
+ (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_react89.default.Fragment, { children: ch }, i)
12691
12759
  ) });
12692
12760
  }
12693
12761
  var CommandPalette = ({
@@ -12696,16 +12764,16 @@ var CommandPalette = ({
12696
12764
  emptyMessage = "No matching commands",
12697
12765
  className = ""
12698
12766
  }) => {
12699
- const inputRef = (0, import_react88.useRef)(null);
12700
- const listRef = (0, import_react88.useRef)(null);
12701
- const baseId = (0, import_react88.useId)();
12767
+ const inputRef = (0, import_react89.useRef)(null);
12768
+ const listRef = (0, import_react89.useRef)(null);
12769
+ const baseId = (0, import_react89.useId)();
12702
12770
  const listId = `${baseId}-list`;
12703
12771
  const optionId = (index) => `${baseId}-option-${index}`;
12704
12772
  const { open, query, items, activeIndex } = palette;
12705
- (0, import_react88.useEffect)(() => {
12773
+ (0, import_react89.useEffect)(() => {
12706
12774
  if (open) inputRef.current?.focus();
12707
12775
  }, [open]);
12708
- (0, import_react88.useEffect)(() => {
12776
+ (0, import_react89.useEffect)(() => {
12709
12777
  if (!open) return;
12710
12778
  const active = listRef.current?.querySelector('[aria-selected="true"]');
12711
12779
  active?.scrollIntoView?.({ block: "nearest" });
@@ -12781,12 +12849,12 @@ var CommandPalette = ({
12781
12849
  };
12782
12850
 
12783
12851
  // src/commands/useCommandShortcuts.ts
12784
- var import_react89 = require("react");
12852
+ var import_react90 = require("react");
12785
12853
  function useCommandShortcuts(registry, options = {}) {
12786
- const optionsRef = (0, import_react89.useRef)(options);
12854
+ const optionsRef = (0, import_react90.useRef)(options);
12787
12855
  optionsRef.current = options;
12788
12856
  const { enabled = true, target } = options;
12789
- (0, import_react89.useEffect)(() => {
12857
+ (0, import_react90.useEffect)(() => {
12790
12858
  if (!registry || !enabled) return;
12791
12859
  const eventTarget = target ?? (typeof window !== "undefined" ? window : null);
12792
12860
  if (!eventTarget) return;
@@ -12804,14 +12872,14 @@ function useCommandShortcuts(registry, options = {}) {
12804
12872
  }, [registry, enabled, target]);
12805
12873
  }
12806
12874
  function useRegisterCommands(registry, specs) {
12807
- (0, import_react89.useEffect)(() => {
12875
+ (0, import_react90.useEffect)(() => {
12808
12876
  if (!registry || !specs || specs.length === 0) return;
12809
12877
  return registry.register(specs);
12810
12878
  }, [registry, specs]);
12811
12879
  }
12812
12880
 
12813
12881
  // src/persistence/useAutosave.ts
12814
- var import_react90 = require("react");
12882
+ var import_react91 = require("react");
12815
12883
  var import_persistence = require("@pixerate/editor/persistence");
12816
12884
  var IDLE = {
12817
12885
  status: "idle",
@@ -12822,18 +12890,18 @@ var IDLE = {
12822
12890
  ready: false
12823
12891
  };
12824
12892
  function useAutosave(options) {
12825
- const optionsRef = (0, import_react90.useRef)(options);
12893
+ const optionsRef = (0, import_react91.useRef)(options);
12826
12894
  optionsRef.current = options;
12827
12895
  const { storage, key, history, dirty } = options;
12828
12896
  const recover = options.recover !== false;
12829
12897
  const flushOnHide = options.flushOnHide !== false;
12830
12898
  const ready = options.ready !== false;
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)(() => {
12899
+ const [controller, setController] = (0, import_react91.useState)(null);
12900
+ const [status, setStatus] = (0, import_react91.useState)(IDLE);
12901
+ const [recovery, setRecovery] = (0, import_react91.useState)(null);
12902
+ const [pendingRecovery, setPendingRecovery] = (0, import_react91.useState)(recover);
12903
+ const revisionsRef = (0, import_react91.useRef)(null);
12904
+ (0, import_react91.useEffect)(() => {
12837
12905
  const revisions = (0, import_persistence.createRevisionTracker)({ history, dirty });
12838
12906
  const o = optionsRef.current;
12839
12907
  const instance = (0, import_persistence.createAutosaveController)({
@@ -12880,10 +12948,10 @@ function useAutosave(options) {
12880
12948
  if (revisionsRef.current === revisions) revisionsRef.current = null;
12881
12949
  };
12882
12950
  }, [storage, key, history, dirty, recover]);
12883
- (0, import_react90.useEffect)(() => {
12951
+ (0, import_react91.useEffect)(() => {
12884
12952
  if (controller && ready && !pendingRecovery) controller.ready();
12885
12953
  }, [controller, ready, pendingRecovery]);
12886
- (0, import_react90.useEffect)(() => {
12954
+ (0, import_react91.useEffect)(() => {
12887
12955
  if (!controller || !flushOnHide || typeof window === "undefined") return;
12888
12956
  const flush = () => void controller.flushNow();
12889
12957
  const onVisibility = () => {
@@ -12896,33 +12964,33 @@ function useAutosave(options) {
12896
12964
  document.removeEventListener("visibilitychange", onVisibility);
12897
12965
  };
12898
12966
  }, [controller, flushOnHide]);
12899
- const restore = (0, import_react90.useCallback)(() => {
12967
+ const restore = (0, import_react91.useCallback)(() => {
12900
12968
  const snapshot = recovery?.snapshot;
12901
12969
  setRecovery(null);
12902
12970
  setPendingRecovery(false);
12903
12971
  return snapshot;
12904
12972
  }, [recovery]);
12905
- const discard = (0, import_react90.useCallback)(async () => {
12973
+ const discard = (0, import_react91.useCallback)(async () => {
12906
12974
  if (controller) await controller.discardRecovery();
12907
12975
  setRecovery(null);
12908
12976
  setPendingRecovery(false);
12909
12977
  }, [controller]);
12910
- const flushNow = (0, import_react90.useCallback)(async () => {
12978
+ const flushNow = (0, import_react91.useCallback)(async () => {
12911
12979
  await controller?.flushNow();
12912
12980
  }, [controller]);
12913
- const markClean = (0, import_react90.useCallback)(async () => {
12981
+ const markClean = (0, import_react91.useCallback)(async () => {
12914
12982
  revisionsRef.current?.markSaved();
12915
12983
  await controller?.markClean();
12916
12984
  }, [controller]);
12917
- const notifyChange = (0, import_react90.useCallback)(() => revisionsRef.current?.bump(), []);
12985
+ const notifyChange = (0, import_react91.useCallback)(() => revisionsRef.current?.bump(), []);
12918
12986
  return { status, recovery, pendingRecovery, restore, discard, flushNow, markClean, notifyChange, controller };
12919
12987
  }
12920
12988
 
12921
12989
  // src/persistence/useEditorAutosave.ts
12922
- var import_react91 = require("react");
12990
+ var import_react92 = require("react");
12923
12991
  var import_persistence2 = require("@pixerate/editor/persistence");
12924
12992
  function useEditorAutosave(doc, { collectAssetGarbage, ...options }) {
12925
- const storage = (0, import_react91.useMemo)(
12993
+ const storage = (0, import_react92.useMemo)(
12926
12994
  () => doc.assets ? (0, import_persistence2.withEditorAssets)(options.storage, doc.assets) : options.storage,
12927
12995
  [options.storage, doc.assets]
12928
12996
  );
@@ -12935,19 +13003,19 @@ function useEditorAutosave(doc, { collectAssetGarbage, ...options }) {
12935
13003
  history: doc
12936
13004
  });
12937
13005
  const take = autosave.restore;
12938
- const restore = (0, import_react91.useCallback)(() => {
13006
+ const restore = (0, import_react92.useCallback)(() => {
12939
13007
  const snapshot = take();
12940
13008
  return snapshot ? doc.loadDocument(snapshot, { history: "reset" }) : void 0;
12941
13009
  }, [take, doc]);
12942
13010
  const { markClean: clean, discard: drop } = autosave;
12943
13011
  const rawStorage = options.storage;
12944
- const gcRef = (0, import_react91.useRef)(collectAssetGarbage);
13012
+ const gcRef = (0, import_react92.useRef)(collectAssetGarbage);
12945
13013
  gcRef.current = collectAssetGarbage;
12946
- const markClean = (0, import_react91.useCallback)(async () => {
13014
+ const markClean = (0, import_react92.useCallback)(async () => {
12947
13015
  await clean();
12948
13016
  await (0, import_persistence2.collectRetiredEditorAssets)(rawStorage, doc, gcRef.current);
12949
13017
  }, [clean, rawStorage, doc]);
12950
- const discard = (0, import_react91.useCallback)(async () => {
13018
+ const discard = (0, import_react92.useCallback)(async () => {
12951
13019
  await drop();
12952
13020
  await (0, import_persistence2.collectRetiredEditorAssets)(rawStorage, doc, gcRef.current);
12953
13021
  }, [drop, rawStorage, doc]);
@@ -13010,20 +13078,20 @@ var RecoveryPrompt = ({
13010
13078
  };
13011
13079
 
13012
13080
  // src/persistence/useEditorSync.ts
13013
- var import_react92 = require("react");
13081
+ var import_react93 = require("react");
13014
13082
  var import_persistence4 = require("@pixerate/editor/persistence");
13015
13083
  function useEditorSync(doc, options) {
13016
- const optionsRef = (0, import_react92.useRef)(options);
13084
+ const optionsRef = (0, import_react93.useRef)(options);
13017
13085
  optionsRef.current = options;
13018
- const [controller, setController] = (0, import_react92.useState)(null);
13019
- const [status, setStatus] = (0, import_react92.useState)(() => ({
13086
+ const [controller, setController] = (0, import_react93.useState)(null);
13087
+ const [status, setStatus] = (0, import_react93.useState)(() => ({
13020
13088
  status: "idle",
13021
13089
  version: options.initialVersion ?? 0,
13022
13090
  savedVersion: options.initialVersion ?? 0,
13023
13091
  dirty: false,
13024
13092
  lastSavedAt: null
13025
13093
  }));
13026
- (0, import_react92.useEffect)(() => {
13094
+ (0, import_react93.useEffect)(() => {
13027
13095
  const { flushOnHide: _flushOnHide, ...initial } = optionsRef.current;
13028
13096
  const instance = (0, import_persistence4.createEditorRemoteSync)(doc, {
13029
13097
  ...initial,
@@ -13045,7 +13113,7 @@ function useEditorSync(doc, options) {
13045
13113
  };
13046
13114
  }, [doc]);
13047
13115
  const flushOnHide = options.flushOnHide ?? true;
13048
- (0, import_react92.useEffect)(() => {
13116
+ (0, import_react93.useEffect)(() => {
13049
13117
  if (!controller || !flushOnHide || typeof window === "undefined") return;
13050
13118
  const onVisibilityChange = () => {
13051
13119
  if (document.visibilityState === "hidden") void controller.flush();
@@ -13058,11 +13126,11 @@ function useEditorSync(doc, options) {
13058
13126
  window.removeEventListener("pagehide", onPageHide);
13059
13127
  };
13060
13128
  }, [controller, flushOnHide]);
13061
- const applyRemote = (0, import_react92.useCallback)(
13129
+ const applyRemote = (0, import_react93.useCallback)(
13062
13130
  (fn, remoteVersion) => controller ? controller.applyRemote(fn, remoteVersion) : fn(),
13063
13131
  [controller]
13064
13132
  );
13065
- return (0, import_react92.useMemo)(
13133
+ return (0, import_react93.useMemo)(
13066
13134
  () => ({
13067
13135
  status,
13068
13136
  version: status.version,
@@ -13081,17 +13149,17 @@ function useEditorSync(doc, options) {
13081
13149
  }
13082
13150
 
13083
13151
  // src/generation/useGenerationPlan.ts
13084
- var import_react93 = require("react");
13152
+ var import_react94 = require("react");
13085
13153
  var import_generation = require("@pixerate/editor/generation");
13086
13154
  function useGenerationPlan(request, capabilities, options = {}) {
13087
13155
  const key = JSON.stringify([request, capabilities, options]);
13088
- return (0, import_react93.useMemo)(() => (0, import_generation.planGenerationRequest)(request, capabilities, options), [key]);
13156
+ return (0, import_react94.useMemo)(() => (0, import_generation.planGenerationRequest)(request, capabilities, options), [key]);
13089
13157
  }
13090
13158
  function useJobProgress(options) {
13091
13159
  const { startedAt, expectedMs, done, now, intervalMs = 1e3 } = options;
13092
- const [tick, setTick] = (0, import_react93.useState)(() => Date.now());
13160
+ const [tick, setTick] = (0, import_react94.useState)(() => Date.now());
13093
13161
  const ticking = !done && now === void 0;
13094
- (0, import_react93.useEffect)(() => {
13162
+ (0, import_react94.useEffect)(() => {
13095
13163
  if (!ticking) return;
13096
13164
  setTick(Date.now());
13097
13165
  const id = setInterval(() => setTick(Date.now()), Math.max(16, intervalMs));
@@ -13101,7 +13169,7 @@ function useJobProgress(options) {
13101
13169
  }
13102
13170
 
13103
13171
  // src/generation/GenerationSettings.tsx
13104
- var import_react94 = require("react");
13172
+ var import_react95 = require("react");
13105
13173
  var import_generation2 = require("@pixerate/editor/generation");
13106
13174
  var import_jsx_runtime69 = require("react/jsx-runtime");
13107
13175
  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";
@@ -13184,8 +13252,8 @@ var GenerationSettings = ({
13184
13252
  renderReference,
13185
13253
  className = ""
13186
13254
  }) => {
13187
- const baseId = (0, import_react94.useId)();
13188
- const controls = (0, import_react94.useMemo)(() => (0, import_generation2.getGenerationControls)(capabilities), [capabilities]);
13255
+ const baseId = (0, import_react95.useId)();
13256
+ const controls = (0, import_react95.useMemo)(() => (0, import_generation2.getGenerationControls)(capabilities), [capabilities]);
13189
13257
  const computed = useGenerationPlan(value, capabilities, { strategy });
13190
13258
  const plan = planProp ?? computed;
13191
13259
  const slots = (0, import_generation2.getReferenceSlots)(capabilities, value);
@@ -13280,7 +13348,7 @@ var JobProgress = ({ title, className = "", ...options }) => {
13280
13348
  };
13281
13349
 
13282
13350
  // src/generation/AssetMentionChips.tsx
13283
- var import_react95 = require("react");
13351
+ var import_react96 = require("react");
13284
13352
  var import_generation3 = require("@pixerate/editor/generation");
13285
13353
  var import_jsx_runtime71 = require("react/jsx-runtime");
13286
13354
  var AssetMentionChips = ({
@@ -13292,14 +13360,14 @@ var AssetMentionChips = ({
13292
13360
  renderAsset,
13293
13361
  className = ""
13294
13362
  }) => {
13295
- const [open, setOpen] = (0, import_react95.useState)(null);
13296
- const rootRef = (0, import_react95.useRef)(null);
13297
- const chips = (0, import_react95.useMemo)(
13363
+ const [open, setOpen] = (0, import_react96.useState)(null);
13364
+ const rootRef = (0, import_react96.useRef)(null);
13365
+ const chips = (0, import_react96.useMemo)(
13298
13366
  () => (0, import_generation3.describeAssetMentions)((0, import_generation3.findTextMentions)(content), assets, capabilities),
13299
13367
  [content, assets, capabilities]
13300
13368
  );
13301
13369
  const options = roles ?? (capabilities ? (0, import_generation3.getAssetRoleOptions)(capabilities) : (0, import_generation3.defaultAssetRoleOptions)());
13302
- (0, import_react95.useEffect)(() => {
13370
+ (0, import_react96.useEffect)(() => {
13303
13371
  if (open === null) return;
13304
13372
  const onPointer = (event) => {
13305
13373
  if (!rootRef.current?.contains(event.target)) setOpen(null);
@@ -13394,15 +13462,15 @@ var AssetMentionChips = ({
13394
13462
  };
13395
13463
 
13396
13464
  // src/generation/GenerationHistory.tsx
13397
- var import_react96 = require("react");
13465
+ var import_react97 = require("react");
13398
13466
  var import_generation4 = require("@pixerate/editor/generation");
13399
13467
  var import_jsx_runtime72 = require("react/jsx-runtime");
13400
13468
  function useGenerationRecords(store, filter) {
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);
13469
+ const [records, setRecords] = (0, import_react97.useState)([]);
13470
+ const [loading, setLoading] = (0, import_react97.useState)(!!store);
13471
+ const [error, setError] = (0, import_react97.useState)(null);
13404
13472
  const filterKey = (0, import_generation4.stableStringify)(filter ?? {});
13405
- const refresh = (0, import_react96.useCallback)(async () => {
13473
+ const refresh = (0, import_react97.useCallback)(async () => {
13406
13474
  if (!store) {
13407
13475
  setRecords([]);
13408
13476
  setLoading(false);
@@ -13419,7 +13487,7 @@ function useGenerationRecords(store, filter) {
13419
13487
  setLoading(false);
13420
13488
  }
13421
13489
  }, [store, filterKey]);
13422
- (0, import_react96.useEffect)(() => {
13490
+ (0, import_react97.useEffect)(() => {
13423
13491
  void refresh();
13424
13492
  if (!store) return;
13425
13493
  return store.subscribe(() => void refresh());
@@ -13445,15 +13513,15 @@ var GenerationHistory = ({
13445
13513
  emptyText = "No generations yet.",
13446
13514
  className = ""
13447
13515
  }) => {
13448
- const [innerMode, setInnerMode] = (0, import_react96.useState)("exact");
13516
+ const [innerMode, setInnerMode] = (0, import_react97.useState)("exact");
13449
13517
  const mode = modeProp ?? innerMode;
13450
13518
  const setMode = (next) => {
13451
13519
  if (modeProp === void 0) setInnerMode(next);
13452
13520
  onModeChange?.(next);
13453
13521
  };
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)(
13522
+ const options = (0, import_react97.useMemo)(() => ({ templates, capabilities, assets, mode }), [templates, capabilities, assets, mode]);
13523
+ const results = (0, import_react97.useMemo)(() => records.map((record) => (0, import_generation4.recreateRequest)(record, options)), [records, options]);
13524
+ const models = (0, import_react97.useMemo)(
13457
13525
  () => capabilities ? Array.isArray(capabilities) ? capabilities : [capabilities] : [],
13458
13526
  [capabilities]
13459
13527
  );
@@ -13564,19 +13632,19 @@ var GenerationHistory = ({
13564
13632
  };
13565
13633
 
13566
13634
  // src/find-replace/useFindReplace.ts
13567
- var import_react97 = require("react");
13635
+ var import_react98 = require("react");
13568
13636
  var import_editor17 = require("@pixerate/editor");
13569
13637
  var noopUnsubscribe2 = () => {
13570
13638
  };
13571
13639
  function useFindReplace(editor) {
13572
13640
  const store = (0, import_editor17.getFindReplaceStore)(editor ?? null);
13573
- const subscribe = (0, import_react97.useCallback)(
13641
+ const subscribe = (0, import_react98.useCallback)(
13574
13642
  (onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe2,
13575
13643
  [store]
13576
13644
  );
13577
13645
  const getSnapshot2 = () => store?.getSnapshot() ?? import_editor17.EMPTY_FIND_REPLACE_SNAPSHOT;
13578
- const snapshot = (0, import_react97.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
13579
- return (0, import_react97.useMemo)(() => {
13646
+ const snapshot = (0, import_react98.useSyncExternalStore)(subscribe, getSnapshot2, getSnapshot2);
13647
+ return (0, import_react98.useMemo)(() => {
13580
13648
  const run = (fn) => {
13581
13649
  if (editor && !editor.isDestroyed && store) fn(editor);
13582
13650
  };
@@ -13600,7 +13668,7 @@ function useFindReplace(editor) {
13600
13668
  }
13601
13669
 
13602
13670
  // src/find-replace/FindReplaceBar.tsx
13603
- var import_react98 = require("react");
13671
+ var import_react99 = require("react");
13604
13672
  var import_editor18 = require("@pixerate/editor");
13605
13673
  var import_jsx_runtime73 = require("react/jsx-runtime");
13606
13674
  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";
@@ -13615,10 +13683,10 @@ var FindReplaceBar = ({
13615
13683
  onClose
13616
13684
  }) => {
13617
13685
  const find = useFindReplace(editor);
13618
- const findInput = (0, import_react98.useRef)(null);
13619
- const [moreOpen, setMoreOpen] = (0, import_react98.useState)(false);
13686
+ const findInput = (0, import_react99.useRef)(null);
13687
+ const [moreOpen, setMoreOpen] = (0, import_react99.useState)(false);
13620
13688
  const visible = find.available && (alwaysOpen || find.open);
13621
- (0, import_react98.useEffect)(() => {
13689
+ (0, import_react99.useEffect)(() => {
13622
13690
  if (!visible || find.focusRequest === 0) return;
13623
13691
  findInput.current?.focus();
13624
13692
  findInput.current?.select();
@@ -13762,12 +13830,12 @@ var FindReplaceBar = ({
13762
13830
  };
13763
13831
 
13764
13832
  // src/tables/useTableMenu.ts
13765
- var import_react99 = require("react");
13833
+ var import_react100 = require("react");
13766
13834
  var import_editor19 = require("@pixerate/editor");
13767
13835
  function useTableMenu(editor) {
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)(
13836
+ const store = (0, import_react100.useMemo)(() => (0, import_editor19.createTableStore)(editor), [editor]);
13837
+ const snapshot = (0, import_react100.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
13838
+ return (0, import_react100.useMemo)(
13771
13839
  () => ({
13772
13840
  ...snapshot,
13773
13841
  run: (action, params) => (0, import_editor19.runTableAction)(editor, action, params, { focus: true }),
@@ -13778,7 +13846,7 @@ function useTableMenu(editor) {
13778
13846
  }
13779
13847
 
13780
13848
  // src/tables/TableToolbar.tsx
13781
- var import_react100 = __toESM(require("react"), 1);
13849
+ var import_react101 = __toESM(require("react"), 1);
13782
13850
  var import_editor20 = require("@pixerate/editor");
13783
13851
  var import_jsx_runtime74 = require("react/jsx-runtime");
13784
13852
  var keepSelection2 = (event) => event.preventDefault();
@@ -13799,7 +13867,7 @@ var TableToolbar = ({
13799
13867
  const enabled = status === true;
13800
13868
  const active = item.active?.(table);
13801
13869
  const separator = index > 0 && items[index - 1].group !== item.group;
13802
- return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(import_react100.default.Fragment, { children: [
13870
+ return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(import_react101.default.Fragment, { children: [
13803
13871
  separator && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", { className: separatorClassName, "aria-hidden": "true" }),
13804
13872
  /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
13805
13873
  "button",
@@ -13823,7 +13891,7 @@ var TableToolbar = ({
13823
13891
  };
13824
13892
 
13825
13893
  // src/tables/InsertTableGrid.tsx
13826
- var import_react101 = require("react");
13894
+ var import_react102 = require("react");
13827
13895
  var import_jsx_runtime75 = require("react/jsx-runtime");
13828
13896
  var keepSelection3 = (event) => event.preventDefault();
13829
13897
  var InsertTableGrid = ({
@@ -13837,7 +13905,7 @@ var InsertTableGrid = ({
13837
13905
  onInsert
13838
13906
  }) => {
13839
13907
  const table = useTableMenu(editor);
13840
- const [hover, setHover] = (0, import_react101.useState)(null);
13908
+ const [hover, setHover] = (0, import_react102.useState)(null);
13841
13909
  const status = table.actions.insertTable;
13842
13910
  const disabled = !editor || !status.enabled;
13843
13911
  const insert = (size) => {
@@ -13904,14 +13972,14 @@ var TableBubbleMenu = ({
13904
13972
  var import_client2 = require("react-dom/client");
13905
13973
 
13906
13974
  // src/chart/ChartCanvas.tsx
13907
- var import_react103 = require("react");
13975
+ var import_react104 = require("react");
13908
13976
  var import_chart2 = require("@pixerate/editor/chart");
13909
13977
 
13910
13978
  // src/chart/useChartEditor.ts
13911
- var import_react102 = require("react");
13979
+ var import_react103 = require("react");
13912
13980
  var import_chart = require("@pixerate/editor/chart");
13913
13981
  function useChartState(controller) {
13914
- return (0, import_react102.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
13982
+ return (0, import_react103.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
13915
13983
  }
13916
13984
 
13917
13985
  // src/chart/ChartCanvas.tsx
@@ -13963,7 +14031,7 @@ function renderChartMark(mark, fontFamily, interactive) {
13963
14031
  }
13964
14032
  }
13965
14033
  function ChartPresenceLayer({ presence }) {
13966
- const { actors } = (0, import_react103.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
14034
+ const { actors } = (0, import_react104.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
13967
14035
  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: [
13968
14036
  /* @__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 }),
13969
14037
  /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("g", { transform: "translate(13 16)", children: [
@@ -13984,15 +14052,15 @@ function ChartTooltipContent({ tooltip }) {
13984
14052
  }
13985
14053
  function ChartCanvas({ controller, width = 640, height = 400, responsive = true, theme, editable = true, measureText, emptyMessage, className, presence, sceneRef, tooltip = false, renderTooltip }) {
13986
14054
  const state = useChartState(controller);
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);
14055
+ const wrapper = (0, import_react104.useRef)(null);
14056
+ const svg = (0, import_react104.useRef)(null);
14057
+ const drag = (0, import_react104.useRef)(null);
14058
+ const [measured, setMeasured] = (0, import_react104.useState)(null);
14059
+ const [frozen, setFrozen] = (0, import_react104.useState)(null);
13992
14060
  const tooltipMode = tooltip === true ? "point" : tooltip || null;
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)(() => {
14061
+ const [tip, setTip] = (0, import_react104.useState)(null);
14062
+ const [tipAt, setTipAt] = (0, import_react104.useState)({ left: 0, top: 0, flip: false });
14063
+ (0, import_react104.useEffect)(() => {
13996
14064
  const el = wrapper.current;
13997
14065
  if (!responsive || !el || typeof ResizeObserver === "undefined") return;
13998
14066
  const observer = new ResizeObserver(([entry]) => {
@@ -14003,8 +14071,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
14003
14071
  return () => observer.disconnect();
14004
14072
  }, [responsive]);
14005
14073
  const sceneWidth = responsive && measured || width;
14006
- const fullTheme = (0, import_react103.useMemo)(() => ({ ...import_chart2.CSS_VARIABLE_CHART_THEME, ...theme }), [theme]);
14007
- const scene = (0, import_react103.useMemo)(
14074
+ const fullTheme = (0, import_react104.useMemo)(() => ({ ...import_chart2.CSS_VARIABLE_CHART_THEME, ...theme }), [theme]);
14075
+ const scene = (0, import_react104.useMemo)(
14008
14076
  () => (0, import_chart2.layoutChart)(state.spec, {
14009
14077
  width: sceneWidth,
14010
14078
  height,
@@ -14021,8 +14089,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
14021
14089
  [state.spec, state.selection, state.raceFrame, sceneWidth, height, fullTheme, editable, measureText, emptyMessage, frozen]
14022
14090
  );
14023
14091
  if (sceneRef) sceneRef.current = scene;
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(), []);
14092
+ const byKey = (0, import_react104.useMemo)(() => new Map(scene.marks.map((m) => [m.key, m])), [scene]);
14093
+ (0, import_react104.useEffect)(() => () => drag.current?.end(), []);
14026
14094
  const scenePoint = (e) => (0, import_chart2.chartClientToScene)(scene, svg.current.getBoundingClientRect(), e.clientX, e.clientY);
14027
14095
  const onPointerDown = (e) => {
14028
14096
  if (!editable || e.button !== 0) return;
@@ -14115,7 +14183,7 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
14115
14183
  }
14116
14184
 
14117
14185
  // src/chart/ChartDataGrid.tsx
14118
- var import_react104 = require("react");
14186
+ var import_react105 = require("react");
14119
14187
  var import_chart3 = require("@pixerate/editor/chart");
14120
14188
 
14121
14189
  // src/chart/styles.ts
@@ -14130,9 +14198,9 @@ var chartCellClass = "h-7 w-full min-w-[4.5rem] bg-transparent px-2 text-right t
14130
14198
  // src/chart/ChartDataGrid.tsx
14131
14199
  var import_jsx_runtime78 = require("react/jsx-runtime");
14132
14200
  function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
14133
- const [draft, setDraft] = (0, import_react104.useState)(value);
14134
- const typing = (0, import_react104.useRef)(false);
14135
- (0, import_react104.useEffect)(() => {
14201
+ const [draft, setDraft] = (0, import_react105.useState)(value);
14202
+ const typing = (0, import_react105.useRef)(false);
14203
+ (0, import_react105.useEffect)(() => {
14136
14204
  if (!typing.current) setDraft(value);
14137
14205
  }, [value]);
14138
14206
  const commit = () => {
@@ -14170,7 +14238,7 @@ function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
14170
14238
  }
14171
14239
  function ChartTreeGrid({ controller, readOnly = false, className }) {
14172
14240
  const { spec } = useChartState(controller);
14173
- const [columns, setColumns] = (0, import_react104.useState)(1);
14241
+ const [columns, setColumns] = (0, import_react105.useState)(1);
14174
14242
  const rows = (0, import_chart3.chartTreeToRows)(spec.tree);
14175
14243
  const depth = Math.max(columns, (0, import_chart3.chartTreeDepth)(spec.tree));
14176
14244
  const labels = (0, import_chart3.chartTreeColumnLabels)(depth);
@@ -14358,7 +14426,7 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
14358
14426
  }
14359
14427
 
14360
14428
  // src/chart/ChartInspector.tsx
14361
- var import_react105 = require("react");
14429
+ var import_react106 = require("react");
14362
14430
  var import_chart4 = require("@pixerate/editor/chart");
14363
14431
  var import_jsx_runtime79 = require("react/jsx-runtime");
14364
14432
  var cap = (s) => s.charAt(0).toUpperCase() + s.slice(1);
@@ -14523,7 +14591,7 @@ function ErrorBarFields({ controller, series, which, idBase }) {
14523
14591
  }
14524
14592
  function ChartInspector({ controller, sections, className, swatches }) {
14525
14593
  const { spec, selectedSeries, selection, raceFrame, racePlaying } = useChartState(controller);
14526
- const idBase = (0, import_react105.useId)();
14594
+ const idBase = (0, import_react106.useId)();
14527
14595
  const show = (section) => !sections || sections.includes(section);
14528
14596
  const cartesian = (0, import_chart4.isCartesianChart)(spec.type);
14529
14597
  const family = (0, import_chart4.chartFamily)(spec);
@@ -14881,12 +14949,12 @@ function createReactChartNodeView(options = {}) {
14881
14949
  }
14882
14950
 
14883
14951
  // src/style/useStyle.ts
14884
- var import_react106 = require("react");
14885
- var import_tools6 = require("@pixerate/editor/tools");
14952
+ var import_react107 = require("react");
14953
+ var import_tools7 = require("@pixerate/editor/tools");
14886
14954
  var import_editor22 = require("@pixerate/editor");
14887
14955
  var message = (error) => error instanceof Error ? error.message : String(error);
14888
14956
  function useResolverTask(styles, run, deliver, deps) {
14889
- (0, import_react106.useEffect)(() => {
14957
+ (0, import_react107.useEffect)(() => {
14890
14958
  if (!styles || !run) {
14891
14959
  deliver({ value: null, error: null });
14892
14960
  return;
@@ -14913,7 +14981,7 @@ function useResolverTask(styles, run, deliver, deps) {
14913
14981
  }, [styles, ...deps]);
14914
14982
  }
14915
14983
  function useStyle(styles, domain) {
14916
- const [result, setResult] = (0, import_react106.useState)({ style: null, error: null });
14984
+ const [result, setResult] = (0, import_react107.useState)({ style: null, error: null });
14917
14985
  useResolverTask(
14918
14986
  styles,
14919
14987
  (s) => s.resolve(domain),
@@ -14923,7 +14991,7 @@ function useStyle(styles, domain) {
14923
14991
  return result;
14924
14992
  }
14925
14993
  function useStyleFindings(styles, domain, state, scope) {
14926
- const [result, setResult] = (0, import_react106.useState)({ report: null, style: null, error: null });
14994
+ const [result, setResult] = (0, import_react107.useState)({ report: null, style: null, error: null });
14927
14995
  useResolverTask(
14928
14996
  styles,
14929
14997
  (s) => s.check(domain, state, scope !== void 0 ? { scope } : {}),
@@ -14939,14 +15007,14 @@ function useStyleFindings(styles, domain, state, scope) {
14939
15007
  return result;
14940
15008
  }
14941
15009
  function useStyleChoices(styles, scope) {
14942
- const [state, setState] = (0, import_react106.useState)({ groups: null, error: null });
15010
+ const [state, setState] = (0, import_react107.useState)({ groups: null, error: null });
14943
15011
  useResolverTask(
14944
15012
  styles,
14945
15013
  (s) => s.choices(scope !== void 0 ? { scope } : {}),
14946
15014
  ({ value, error }) => setState({ groups: value, error }),
14947
15015
  [scope]
14948
15016
  );
14949
- const choose = (0, import_react106.useCallback)(
15017
+ const choose = (0, import_react107.useCallback)(
14950
15018
  async (name, options = {}) => {
14951
15019
  if (!styles) throw new Error("There is no style resolver to choose with.");
14952
15020
  try {
@@ -14961,21 +15029,21 @@ function useStyleChoices(styles, scope) {
14961
15029
  return { ...state, choose };
14962
15030
  }
14963
15031
  function useStyleSwatches(styles, domain, scope) {
14964
- const [state, setState] = (0, import_react106.useState)({ style: null, error: null });
15032
+ const [state, setState] = (0, import_react107.useState)({ style: null, error: null });
14965
15033
  useResolverTask(
14966
15034
  styles,
14967
15035
  (s) => s.resolve(domain, scope !== void 0 ? { scope } : {}),
14968
15036
  ({ value, error }) => setState({ style: value, error }),
14969
15037
  [domain, scope]
14970
15038
  );
14971
- return (0, import_react106.useMemo)(() => {
14972
- const { colors, fonts } = state.style ? (0, import_tools6.styleSwatches)(state.style) : { colors: [], fonts: [] };
15039
+ return (0, import_react107.useMemo)(() => {
15040
+ const { colors, fonts } = state.style ? (0, import_tools7.styleSwatches)(state.style) : { colors: [], fonts: [] };
14973
15041
  return { colors: colors.map((c) => c.color), swatches: colors, fonts, error: state.error };
14974
15042
  }, [state]);
14975
15043
  }
14976
15044
  function useRichTextStyleFindings(styles, editor, scope) {
14977
- const [doc, setDoc] = (0, import_react106.useState)(() => editor?.state.doc ?? null);
14978
- (0, import_react106.useEffect)(() => {
15045
+ const [doc, setDoc] = (0, import_react107.useState)(() => editor?.state.doc ?? null);
15046
+ (0, import_react107.useEffect)(() => {
14979
15047
  if (!editor) {
14980
15048
  setDoc(null);
14981
15049
  return;
@@ -14987,7 +15055,7 @@ function useRichTextStyleFindings(styles, editor, scope) {
14987
15055
  editor.off("update", onUpdate);
14988
15056
  };
14989
15057
  }, [editor]);
14990
- const state = (0, import_react106.useMemo)(() => doc ? (0, import_editor22.richTextStyleState)(doc) : null, [doc]);
15058
+ const state = (0, import_react107.useMemo)(() => doc ? (0, import_editor22.richTextStyleState)(doc) : null, [doc]);
14991
15059
  return useStyleFindings(state ? styles : null, "rich-text", state, scope);
14992
15060
  }
14993
15061
 
@@ -15170,6 +15238,8 @@ function StyleFindings({ report, onSelect, title = "House style", className = ""
15170
15238
  useStyleFindings,
15171
15239
  useStyleSwatches,
15172
15240
  useTableMenu,
15241
+ useTextChangeFeed,
15242
+ useTextProposals,
15173
15243
  useToolBridge,
15174
15244
  useToolRegistryView,
15175
15245
  useTrackChanges,