@gridsheet/preact-core 3.3.0 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,12 +1,28 @@
1
1
  import { h, render } from "preact";
2
- import { Z, e as ee, K, R as Rs, j, $ as $t, y as yn, u as useBrowser, s as setEditingAddress, N, W, w as write, a as setInputting, b as updateSheet, E as Et, _, V, r as redo, c as undo, d as cut, f as Ee, g as setSearchQuery, h as setEntering, i as copy, k as select, l as arrow, m as escape, n as clear, v, o as walk, p as pn, X, q as paste, t as setEditorHovering, x as _n, z as setStore, A as submitAutofill, B as setDragging, C as setAutofillDraggingTo, D as drag, F as jt, J, G as setResizingPositionY, H as setResizingPositionX, I as Vr, L as jr, M as D, P as Pr, O as kr, Q as filterRows, S as sortRows, T as Xr, U as removeCols, Y as removeRows, a0 as insertColsRight, a1 as insertColsLeft, a2 as insertRowsBelow, a3 as insertRowsAbove, a4 as setContextMenuPosition, a5 as Rn, a6 as setColumnMenu, a7 as setRowMenu, a8 as isXSheetFocused, a9 as setEditorRect, aa as x, ab as k, ac as choose, ad as Y, ae as zr, af as J$1, ag as oe, ah as Wr, ai as Q, aj as U, ak as selectCols, al as useDebounceCallback, am as selectRows, an as En, ao as O, ap as N$1, aq as q, ar as Br, as as on, at as $, au as G, av as search, aw as setSearchCaseSensitive, ax as setSearchRegex, ay as rn, az as setSearchRange, aA as useBook, aB as $$1, aC as reducer, aD as re, aE as isMutationAction, aF as Cs, aG as Re, aH as vt, aI as Dr, aJ as _e, aK as Dt, aL as vr } from "./hooks-DroLjp9H.mjs";
3
- import { b8, b9, bq, ba, bp, bn, bd, bb, aZ, br, bo, aU, bc, aN, aR, aS, aT, aO, aP, aV, aY, bi, bl, a_, bk, a$, bj, bg, bh, bf, be, aQ, aM, aW, aX, bm, b7, b4, b5, b6, b3, b0, b1, b2, bs } from "./hooks-DroLjp9H.mjs";
4
- import { jsxs, jsx, Fragment } from "preact/compat/jsx-runtime";
5
- import React, { createContext, useRef, useContext, useLayoutEffect, useState, useMemo, useCallback, createPortal, memo, useEffect, createRef, useReducer } from "preact/compat";
6
- import { Children, Component, Fragment as Fragment2, PureComponent, StrictMode, Suspense, SuspenseList, cloneElement, render as render2, createContext as createContext2, createElement, createFactory, createPortal as createPortal2, createRef as createRef2, findDOMNode, forwardRef, hydrate, isValidElement, lazy, memo as memo2, unmountComponentAtNode, unstable_batchedUpdates, useCallback as useCallback2, useContext as useContext2, useDebugValue, useEffect as useEffect2, useImperativeHandle, useLayoutEffect as useLayoutEffect2, useMemo as useMemo2, useReducer as useReducer2, useRef as useRef2, useState as useState2, version } from "preact/compat";
2
+ import { f as fe, u as ue, p as pe, k as ks, _, t as te, D as Dn, a as useBrowser, s as setEditingAddress, o as oe, G, w as write, b as setInputting, c as updateSheet, d as bt, e as te$1, g as ae, r as redo, h as undo, i as cut, P as Pe, j as fillRight, l as setSearchQuery, m as setEntering, n as fillDown, q as copy, v as select, x as selectToDataEdge, y as arrow, z as escape, A as clear, R, B as walk, M as Mn, C as ee, E as paste, F as setEditorHovering, H as Pn, I as setStore, J as submitAutofill, K as setDragging, L as setAutofillDraggingTo, N as drag, O as he, Q as rt, S as setResizingPositionY, T as setResizingPositionX, U as nn, V as cn, W as M, X as qr, Z as Zr, Y as filterRows, $ as sortRows, a0 as an, a1 as removeCols, a2 as removeRows, a3 as insertColsRight, a4 as insertColsLeft, a5 as insertRowsBelow, a6 as insertRowsAbove, a7 as setContextMenuPosition, a8 as Ln, a9 as setColumnMenu, aa as setRowMenu, ab as isXSheetFocused, ac as setEditorRect, ad as S, ae as L, af as choose, ag as q, ah as rn, ai as ce, aj as be, ak as on, al as le, am as re, an as selectCols, ao as useDebounceCallback, ap as selectRows, aq as W, ar as Hn, as as Q, at as T, au as ge, av as se, aw as ne, ax as en, ay as bn, az as Z, aA as ie, aB as de, aC as search, aD as setSearchCaseSensitive, aE as setSearchRegex, aF as wn, aG as setSearchRange, aH as useBook, aI as Y, aJ as reducer, aK as me, aL as isAsyncMutationAction, aM as isMutationAction, aN as commitAsyncOp, aO as Hs, aP as $e, aQ as $t, aR as jr, aS as Le, aT as kt, aU as Gr } from "./hooks-BHtHkTAN.mjs";
3
+ import { bi, bj, bA, bk, bz, bx, bn as bn2, bl, b6, bB, by, b1, bm, aW, a_, a$, b0, aX, aY, b2, b5, bs, bv, b7, bu, b8, bt as bt2, bq, br, bp, bo, aZ, aV, b3, b4, bw, bh, be as be2, bf, bg, bd, b9, ba, bb, bc, bC } from "./hooks-BHtHkTAN.mjs";
4
+ import { jsx, jsxs, Fragment } from "preact/compat/jsx-runtime";
5
+ import React, { createContext, forwardRef, useState, useImperativeHandle, useRef, useContext, useLayoutEffect, useMemo, useCallback, createPortal, memo, useEffect, createRef, useReducer } from "preact/compat";
6
+ import { Children, Component, Fragment as Fragment2, PureComponent, StrictMode, Suspense, SuspenseList, cloneElement, render as render2, createContext as createContext2, createElement, createFactory, createPortal as createPortal2, createRef as createRef2, findDOMNode, forwardRef as forwardRef2, hydrate, isValidElement, lazy, memo as memo2, unmountComponentAtNode, unstable_batchedUpdates, useCallback as useCallback2, useContext as useContext2, useDebugValue, useEffect as useEffect2, useImperativeHandle as useImperativeHandle2, useLayoutEffect as useLayoutEffect2, useMemo as useMemo2, useReducer as useReducer2, useRef as useRef2, useState as useState2, version } from "preact/compat";
7
7
  const Context = createContext(
8
8
  {}
9
9
  );
10
+ const ProgressOverlay = ({ progress, label = "Loading" }) => {
11
+ const determinate = progress != null;
12
+ const pct = determinate ? Math.max(0, Math.min(100, Math.round(progress * 100))) : 0;
13
+ return /* @__PURE__ */ jsx("div", { className: "gs-progress-overlay", children: /* @__PURE__ */ jsxs("div", { className: "gs-progress-box", children: [
14
+ /* @__PURE__ */ jsxs("div", { className: "gs-progress-head", children: [
15
+ /* @__PURE__ */ jsx("span", { className: "gs-loading-spinner" }),
16
+ /* @__PURE__ */ jsx("span", { children: determinate ? `${label}… ${pct}%` : `${label}…` })
17
+ ] }),
18
+ determinate && /* @__PURE__ */ jsx("div", { className: "gs-progress-track", children: /* @__PURE__ */ jsx("div", { className: "gs-progress-fill", style: { width: `${pct}%` } }) })
19
+ ] }) });
20
+ };
21
+ const AsyncProgressOverlay = forwardRef(({ label }, ref) => {
22
+ const [progress, setProgress] = useState(0);
23
+ useImperativeHandle(ref, () => ({ setProgress }), []);
24
+ return /* @__PURE__ */ jsx(ProgressOverlay, { progress, label });
25
+ });
10
26
  const FunctionGuide = ({
11
27
  option,
12
28
  activeFunctionGuide,
@@ -23,14 +39,14 @@ const FunctionGuide = ({
23
39
  if (!el) {
24
40
  return;
25
41
  }
26
- Z(el);
42
+ fe(el);
27
43
  });
28
44
  useLayoutEffect(() => {
29
45
  const el = ref.current;
30
46
  if (!el || left === void 0) {
31
47
  return;
32
48
  }
33
- ee(el);
49
+ ue(el);
34
50
  });
35
51
  if (option) {
36
52
  return /* @__PURE__ */ jsxs(
@@ -48,7 +64,7 @@ const FunctionGuide = ({
48
64
  option.isFunction && /* @__PURE__ */ jsxs(Fragment, { children: [
49
65
  /* @__PURE__ */ jsx("div", { className: "gs-fn-guide1-example", children: option.example }),
50
66
  option.description && /* @__PURE__ */ jsx("div", { className: "gs-fn-guide1-desc", style: { whiteSpace: "pre-line" }, children: option.description }),
51
- option.defs && option.defs.length > 0 && /* @__PURE__ */ jsx("div", { className: "gs-fn-guide1-args", children: option.defs.map((arg, j2) => {
67
+ option.defs && option.defs.length > 0 && /* @__PURE__ */ jsx("div", { className: "gs-fn-guide1-args", children: option.defs.map((arg, j) => {
52
68
  var _a;
53
69
  return /* @__PURE__ */ jsxs("div", { className: "gs-fn-guide1-arg", children: [
54
70
  /* @__PURE__ */ jsx("span", { className: "gs-fn-guide1-arg-name", children: arg.name }),
@@ -59,7 +75,7 @@ const FunctionGuide = ({
59
75
  " — ",
60
76
  arg.description
61
77
  ] })
62
- ] }, j2);
78
+ ] }, j);
63
79
  }) })
64
80
  ] })
65
81
  ]
@@ -80,25 +96,25 @@ const FunctionGuide = ({
80
96
  const args = activeFunctionGuide.defs ?? [];
81
97
  const numIterable = args.filter((a) => a.variadic).length;
82
98
  const variadicStart = args.length - numIterable;
83
- return args.map((arg, j2) => {
99
+ return args.map((arg, j) => {
84
100
  let isActive;
85
101
  if (activeArgIndex < variadicStart) {
86
- isActive = activeArgIndex === j2;
87
- } else if (numIterable > 0 && j2 >= variadicStart) {
102
+ isActive = activeArgIndex === j;
103
+ } else if (numIterable > 0 && j >= variadicStart) {
88
104
  const offset = (activeArgIndex - variadicStart) % numIterable;
89
- isActive = j2 === variadicStart + offset;
105
+ isActive = j === variadicStart + offset;
90
106
  } else {
91
107
  isActive = false;
92
108
  }
93
109
  return /* @__PURE__ */ jsxs(React.Fragment, { children: [
94
- j2 > 0 ? ", " : "",
110
+ j > 0 ? ", " : "",
95
111
  /* @__PURE__ */ jsxs("span", { className: isActive ? "gs-active-arg" : "", children: [
96
112
  arg.optional ? "[" : "",
97
113
  arg.name,
98
114
  arg.variadic ? ", ..." : "",
99
115
  arg.optional ? "]" : ""
100
116
  ] })
101
- ] }, j2);
117
+ ] }, j);
102
118
  });
103
119
  })() }),
104
120
  (() => {
@@ -148,7 +164,7 @@ const EditorOptions = ({
148
164
  return;
149
165
  }
150
166
  const width = ulRef.current.getBoundingClientRect().width;
151
- setAdjustedLeft(K(left, width));
167
+ setAdjustedLeft(pe(left, width));
152
168
  }, [left, filteredOptions]);
153
169
  if (filteredOptions.length === 0) {
154
170
  return null;
@@ -175,11 +191,11 @@ const clip = (store) => {
175
191
  if (!sheet) {
176
192
  return { top: 0, left: 0, bottom: 0, right: 0 };
177
193
  }
178
- const { y, x: x2 } = choosing;
179
- const selectingArea = Rs(selectingZone);
194
+ const { y, x } = choosing;
195
+ const selectingArea = ks(selectingZone);
180
196
  let area = selectingArea;
181
197
  if (area.left === -1) {
182
- area = { top: y, left: x2, bottom: y, right: x2 };
198
+ area = { top: y, left: x, bottom: y, right: x };
183
199
  }
184
200
  const input = editorRef.current;
185
201
  const trimmed = sheet.trim(area);
@@ -206,7 +222,7 @@ const clip = (store) => {
206
222
  ]);
207
223
  } else if (input != null) {
208
224
  input.value = tsv;
209
- j(input);
225
+ _(input);
210
226
  input.select();
211
227
  document.execCommand("copy");
212
228
  input.value = "";
@@ -231,8 +247,8 @@ const sheet2csv = (sheet, {
231
247
  }
232
248
  const cols = [];
233
249
  let rowIsEmpty = true;
234
- for (let x2 = sheet.left; x2 <= sheet.right; x2++) {
235
- const point = { y, x: x2 };
250
+ for (let x = sheet.left; x <= sheet.right; x++) {
251
+ const point = { y, x };
236
252
  const value = getter(sheet, point);
237
253
  if (value !== "") {
238
254
  rowIsEmpty = false;
@@ -267,8 +283,8 @@ const sheet2html = (sheet, {
267
283
  }
268
284
  const cols = [];
269
285
  let rowIsEmpty = true;
270
- for (let x2 = sheet.left; x2 <= sheet.right; x2++) {
271
- const point = { y, x: x2 };
286
+ for (let x = sheet.left; x <= sheet.right; x++) {
287
+ const point = { y, x };
272
288
  const value = getter(sheet, point);
273
289
  if (value !== "") {
274
290
  rowIsEmpty = false;
@@ -297,7 +313,7 @@ const useAutocomplete = ({ inputting, selectionStart, optionsAll, functions }) =
297
313
  if (isFormula && textBeforeCursor.length > 1) {
298
314
  try {
299
315
  const textToCursor = textBeforeCursor.slice(1);
300
- const lexer = new $t(textToCursor);
316
+ const lexer = new te(textToCursor);
301
317
  lexer.tokenize();
302
318
  const functionStack = [];
303
319
  for (let i = 0; i < lexer.tokens.length; i++) {
@@ -324,7 +340,7 @@ const useAutocomplete = ({ inputting, selectionStart, optionsAll, functions }) =
324
340
  }
325
341
  if (functionStack.length > 0) {
326
342
  const activeItem = functionStack[functionStack.length - 1];
327
- const helps = yn(functions);
343
+ const helps = Dn(functions);
328
344
  activeArgIndex2 = activeItem.argIndex;
329
345
  activeFunctionHelp2 = helps.find((h2) => h2.name === activeItem.name.toUpperCase()) || null;
330
346
  }
@@ -339,7 +355,7 @@ const useAutocomplete = ({ inputting, selectionStart, optionsAll, functions }) =
339
355
  let isOnAddress = false;
340
356
  if (isFormula) {
341
357
  try {
342
- const fullLexer = new $t(inputting.slice(1));
358
+ const fullLexer = new te(inputting.slice(1));
343
359
  fullLexer.tokenize();
344
360
  let currentIndex = 1;
345
361
  for (const token of fullLexer.tokens) {
@@ -365,7 +381,7 @@ const useAutocomplete = ({ inputting, selectionStart, optionsAll, functions }) =
365
381
  }
366
382
  if (isFormula && !isOnAddress) {
367
383
  if (currentWord.length > 0 && !hasOpenParenAssigned) {
368
- filtered = yn(functions).map((help) => {
384
+ filtered = Dn(functions).map((help) => {
369
385
  const keywordLower = help.name.toLowerCase();
370
386
  const startsWith = keywordLower.startsWith(currentWord);
371
387
  const index = startsWith ? 0 : -1;
@@ -515,7 +531,7 @@ const parseHTML = (html, onlyValue = false) => {
515
531
  }
516
532
  const cells = Array.from(row.querySelectorAll("td, th"));
517
533
  const result = [];
518
- let j2 = 0;
534
+ let j = 0;
519
535
  for (const cell of cells) {
520
536
  const value = ((_b = cell.textContent) == null ? void 0 : _b.trim()) ?? "";
521
537
  const style = onlyValue ? void 0 : (() => {
@@ -523,7 +539,7 @@ const parseHTML = (html, onlyValue = false) => {
523
539
  const parentStyle = parseStyleString(cell);
524
540
  return { ...parentStyle, ...childStyle };
525
541
  })();
526
- while (spans.has(`${i}-${++j2}`)) {
542
+ while (spans.has(`${i}-${++j}`)) {
527
543
  result.push({ value: "", style, skip: true });
528
544
  }
529
545
  result.push({ value, style });
@@ -531,7 +547,7 @@ const parseHTML = (html, onlyValue = false) => {
531
547
  const colSpan = parseInt(cell.getAttribute("colspan") ?? "1", 10);
532
548
  for (let r = 0; r < rowSpan; r++) {
533
549
  for (let c = 0; c < colSpan; c++) {
534
- spans.add(`${i + r}-${j2 + c}`);
550
+ spans.add(`${i + r}-${j + c}`);
535
551
  }
536
552
  }
537
553
  }
@@ -800,7 +816,7 @@ const Editor = ({ mode }) => {
800
816
  functions: sheet == null ? void 0 : sheet.registry.functions
801
817
  });
802
818
  useEffect(() => {
803
- j(editorRef == null ? void 0 : editorRef.current);
819
+ _(editorRef == null ? void 0 : editorRef.current);
804
820
  }, [editorRef]);
805
821
  useEffect(() => {
806
822
  if (!sheet) {
@@ -825,14 +841,14 @@ const Editor = ({ mode }) => {
825
841
  sheet.registry.editingAddress = editingAddress;
826
842
  }, [editingAddress, sheet, sheetId]);
827
843
  useEffect(() => {
828
- N(editorRef.current);
844
+ oe(editorRef.current);
829
845
  }, [inputting, editingAddress, editorRef]);
830
- const { y, x: x2 } = choosing;
831
- const rowId = `${Et(y)}`;
832
- const colId = W(x2);
846
+ const { y, x } = choosing;
847
+ const rowId = `${bt(y)}`;
848
+ const colId = G(x);
833
849
  const address = `${colId}${rowId}`;
834
850
  const editing = editingAddress === address;
835
- const cell = sheet == null ? void 0 : sheet.getCell({ y, x: x2 }, { resolution: "RAW" });
851
+ const cell = sheet == null ? void 0 : sheet.getCell({ y, x }, { resolution: "RAW" });
836
852
  const currentString = sheet ? sheet.getSerializedValue({ point: choosing, cell, resolution: "RAW" }) : "";
837
853
  const [before, setBefore] = useState(currentString);
838
854
  const writeCell = useCallback(
@@ -856,7 +872,7 @@ const Editor = ({ mode }) => {
856
872
  dispatch(setInputting(newValue));
857
873
  setTimeout(() => {
858
874
  if (editorRef.current) {
859
- j(editorRef.current);
875
+ _(editorRef.current);
860
876
  editorRef.current.setSelectionRange(newCursor, newCursor);
861
877
  }
862
878
  }, 0);
@@ -880,14 +896,14 @@ const Editor = ({ mode }) => {
880
896
  }
881
897
  setBefore(currentString);
882
898
  dispatch(setInputting(currentString));
883
- _(editorRef.current, sheet, choosing);
899
+ te$1(editorRef.current, sheet, choosing);
884
900
  }, [choosing, currentString, dispatch, editorRef, sheet]);
885
901
  const { y: top, x: left, height, width } = editorRect;
886
902
  const numLines = currentString.split("\n").length;
887
903
  const [isKeyDown, setIsKeyDown] = useState(false);
888
904
  const handleKeyDown = useCallback(
889
905
  (e) => {
890
- var _a2, _b2, _c, _d, _e2, _f;
906
+ var _a2, _b2, _c, _d, _e, _f;
891
907
  if (!sheet) {
892
908
  return;
893
909
  }
@@ -904,7 +920,7 @@ const Editor = ({ mode }) => {
904
920
  });
905
921
  }
906
922
  const input = e.currentTarget;
907
- if (V(e, inputting)) {
923
+ if (ae(e, inputting)) {
908
924
  dispatch(setInputting(input.value));
909
925
  return false;
910
926
  }
@@ -945,7 +961,7 @@ const Editor = ({ mode }) => {
945
961
  return false;
946
962
  }
947
963
  } else if (e.altKey) {
948
- v(input, "\n");
964
+ R(input, "\n");
949
965
  dispatch(setInputting(input.value));
950
966
  e.preventDefault();
951
967
  return false;
@@ -976,7 +992,7 @@ const Editor = ({ mode }) => {
976
992
  return false;
977
993
  case "Backspace":
978
994
  if (!editing) {
979
- if (((_c = sheet.getSystem({ y, x: x2 })) == null ? void 0 : _c.spilledFrom) != null) {
995
+ if (((_c = sheet.getSystem({ y, x })) == null ? void 0 : _c.spilledFrom) != null) {
980
996
  e.preventDefault();
981
997
  return false;
982
998
  }
@@ -987,7 +1003,7 @@ const Editor = ({ mode }) => {
987
1003
  break;
988
1004
  case "Delete":
989
1005
  if (!editing) {
990
- if (((_d = sheet.getSystem({ y, x: x2 })) == null ? void 0 : _d.spilledFrom) != null) {
1006
+ if (((_d = sheet.getSystem({ y, x })) == null ? void 0 : _d.spilledFrom) != null) {
991
1007
  e.preventDefault();
992
1008
  return false;
993
1009
  }
@@ -1014,6 +1030,11 @@ const Editor = ({ mode }) => {
1014
1030
  return false;
1015
1031
  case "ArrowLeft":
1016
1032
  if (!editing) {
1033
+ if ((e.ctrlKey || e.metaKey) && shiftKey2) {
1034
+ e.preventDefault();
1035
+ dispatch(selectToDataEdge({ deltaY: 0, deltaX: -1 }));
1036
+ return false;
1037
+ }
1017
1038
  dispatch(
1018
1039
  arrow({
1019
1040
  shiftKey: shiftKey2,
@@ -1028,6 +1049,11 @@ const Editor = ({ mode }) => {
1028
1049
  break;
1029
1050
  case "ArrowUp":
1030
1051
  if (!editing) {
1052
+ if ((e.ctrlKey || e.metaKey) && shiftKey2) {
1053
+ e.preventDefault();
1054
+ dispatch(selectToDataEdge({ deltaY: -1, deltaX: 0 }));
1055
+ return false;
1056
+ }
1031
1057
  dispatch(
1032
1058
  arrow({
1033
1059
  shiftKey: shiftKey2,
@@ -1045,6 +1071,11 @@ const Editor = ({ mode }) => {
1045
1071
  break;
1046
1072
  case "ArrowRight":
1047
1073
  if (!editing) {
1074
+ if ((e.ctrlKey || e.metaKey) && shiftKey2) {
1075
+ e.preventDefault();
1076
+ dispatch(selectToDataEdge({ deltaY: 0, deltaX: 1 }));
1077
+ return false;
1078
+ }
1048
1079
  dispatch(
1049
1080
  arrow({
1050
1081
  shiftKey: shiftKey2,
@@ -1059,6 +1090,11 @@ const Editor = ({ mode }) => {
1059
1090
  break;
1060
1091
  case "ArrowDown":
1061
1092
  if (!editing) {
1093
+ if ((e.ctrlKey || e.metaKey) && shiftKey2) {
1094
+ e.preventDefault();
1095
+ dispatch(selectToDataEdge({ deltaY: 1, deltaX: 0 }));
1096
+ return false;
1097
+ }
1062
1098
  dispatch(
1063
1099
  arrow({
1064
1100
  shiftKey: shiftKey2,
@@ -1095,13 +1131,23 @@ const Editor = ({ mode }) => {
1095
1131
  if (!editing) {
1096
1132
  e.preventDefault();
1097
1133
  const area = clip(store);
1098
- dispatch(copy(Ee(area)));
1099
- j(input);
1134
+ dispatch(copy(Pe(area)));
1135
+ _(input);
1100
1136
  return false;
1101
1137
  }
1102
1138
  return true;
1103
1139
  }
1104
1140
  break;
1141
+ case "d":
1142
+ if (e.ctrlKey || e.metaKey) {
1143
+ if (!editing) {
1144
+ e.preventDefault();
1145
+ dispatch(fillDown(null));
1146
+ requestAnimationFrame(() => dispatch(setInputting("")));
1147
+ return false;
1148
+ }
1149
+ }
1150
+ break;
1105
1151
  case "f":
1106
1152
  if (e.ctrlKey || e.metaKey) {
1107
1153
  if (!editing) {
@@ -1110,13 +1156,21 @@ const Editor = ({ mode }) => {
1110
1156
  dispatch(setSearchQuery(""));
1111
1157
  }
1112
1158
  dispatch(setEntering(false));
1113
- requestAnimationFrame(() => j(searchInputRef.current));
1159
+ requestAnimationFrame(() => _(searchInputRef.current));
1114
1160
  return false;
1115
1161
  }
1116
1162
  }
1117
1163
  break;
1118
1164
  case "r":
1119
- // R
1165
+ if (e.ctrlKey || e.metaKey) {
1166
+ if (!editing) {
1167
+ e.preventDefault();
1168
+ dispatch(fillRight(null));
1169
+ requestAnimationFrame(() => dispatch(setInputting("")));
1170
+ return false;
1171
+ }
1172
+ }
1173
+ break;
1120
1174
  case "y":
1121
1175
  if (e.ctrlKey || e.metaKey) {
1122
1176
  if (!editing) {
@@ -1131,7 +1185,7 @@ const Editor = ({ mode }) => {
1131
1185
  if (e.ctrlKey || e.metaKey) {
1132
1186
  if (!editing) {
1133
1187
  e.preventDefault();
1134
- (_f = (_e2 = sheet.registry).onSave) == null ? void 0 : _f.call(_e2, {
1188
+ (_f = (_e = sheet.registry).onSave) == null ? void 0 : _f.call(_e, {
1135
1189
  sheet,
1136
1190
  points: {
1137
1191
  pointing: choosing,
@@ -1160,8 +1214,8 @@ const Editor = ({ mode }) => {
1160
1214
  if (!editing) {
1161
1215
  e.preventDefault();
1162
1216
  const area = clip(store);
1163
- dispatch(cut(Ee(area)));
1164
- j(input);
1217
+ dispatch(cut(Pe(area)));
1218
+ _(input);
1165
1219
  return false;
1166
1220
  }
1167
1221
  }
@@ -1191,7 +1245,7 @@ const Editor = ({ mode }) => {
1191
1245
  if (e.ctrlKey || e.metaKey) {
1192
1246
  return false;
1193
1247
  }
1194
- if (pn.hasOperation(cell == null ? void 0 : cell.prevention, pn.Write)) {
1248
+ if (Mn.hasOperation(cell == null ? void 0 : cell.prevention, Mn.Write)) {
1195
1249
  console.warn("This cell is protected from writing.");
1196
1250
  return false;
1197
1251
  }
@@ -1232,7 +1286,7 @@ const Editor = ({ mode }) => {
1232
1286
  );
1233
1287
  const handleDoubleClick = useCallback(
1234
1288
  (e) => {
1235
- if (pn.hasOperation(cell == null ? void 0 : cell.prevention, pn.Write)) {
1289
+ if (Mn.hasOperation(cell == null ? void 0 : cell.prevention, Mn.Write)) {
1236
1290
  console.warn("This cell is protected from writing.");
1237
1291
  return;
1238
1292
  }
@@ -1253,7 +1307,7 @@ const Editor = ({ mode }) => {
1253
1307
  const handleBlur = useCallback(
1254
1308
  (e) => {
1255
1309
  setIsFocused(false);
1256
- if (X(e.currentTarget)) {
1310
+ if (ee(e.currentTarget)) {
1257
1311
  return true;
1258
1312
  } else {
1259
1313
  if (editing) {
@@ -1266,7 +1320,7 @@ const Editor = ({ mode }) => {
1266
1320
  );
1267
1321
  const handleChange = useCallback(
1268
1322
  (e) => {
1269
- if (pn.hasOperation(cell == null ? void 0 : cell.prevention, pn.Write)) {
1323
+ if (Mn.hasOperation(cell == null ? void 0 : cell.prevention, Mn.Write)) {
1270
1324
  return;
1271
1325
  }
1272
1326
  dispatch(setInputting(e.currentTarget.value));
@@ -1303,7 +1357,7 @@ const Editor = ({ mode }) => {
1303
1357
  (e) => {
1304
1358
  var _a2, _b2;
1305
1359
  setShiftKey(false);
1306
- const selectingArea = Rs(store.selectingZone);
1360
+ const selectingArea = ks(store.selectingZone);
1307
1361
  (_b2 = sheet == null ? void 0 : (_a2 = sheet.registry).onKeyUp) == null ? void 0 : _b2.call(_a2, {
1308
1362
  e,
1309
1363
  points: {
@@ -1409,7 +1463,7 @@ const editorStyle = (text) => {
1409
1463
  if (text[0] !== "=") {
1410
1464
  return /* @__PURE__ */ jsx(Fragment, { children: text });
1411
1465
  }
1412
- const lexer = new $t(text.substring(1));
1466
+ const lexer = new te(text.substring(1));
1413
1467
  lexer.tokenize();
1414
1468
  let palletIndex = 0;
1415
1469
  const exists = {};
@@ -1432,12 +1486,12 @@ const editorStyle = (text) => {
1432
1486
  {
1433
1487
  token,
1434
1488
  tokenKey,
1435
- color: _n[existsIndex % _n.length]
1489
+ color: Pn[existsIndex % Pn.length]
1436
1490
  },
1437
1491
  tokenKey
1438
1492
  );
1439
1493
  }
1440
- const color = _n[palletIndex % _n.length];
1494
+ const color = Pn[palletIndex % Pn.length];
1441
1495
  exists[normalizedToken] = palletIndex++;
1442
1496
  return /* @__PURE__ */ jsx(
1443
1497
  TokenSpan,
@@ -1554,13 +1608,13 @@ const StoreObserver = ({
1554
1608
  const cell = (_b = document.elementFromPoint(px, py)) == null ? void 0 : _b.closest(".gs-cell");
1555
1609
  if (cell) {
1556
1610
  const y = Number(cell.dataset.y);
1557
- const x2 = Number(cell.dataset.x);
1558
- const key = y + ":" + x2;
1611
+ const x = Number(cell.dataset.x);
1612
+ const key = y + ":" + x;
1559
1613
  const now = performance.now();
1560
- if (!Number.isNaN(y) && !Number.isNaN(x2) && key !== lastCell && now - lastExtend > 80) {
1614
+ if (!Number.isNaN(y) && !Number.isNaN(x) && key !== lastCell && now - lastExtend > 80) {
1561
1615
  lastCell = key;
1562
1616
  lastExtend = now;
1563
- d(s.autofillDraggingTo ? setAutofillDraggingTo({ x: x2, y }) : drag({ y, x: x2 }));
1617
+ d(s.autofillDraggingTo ? setAutofillDraggingTo({ x, y }) : drag({ y, x }));
1564
1618
  }
1565
1619
  }
1566
1620
  }
@@ -1696,36 +1750,36 @@ const Resizer = () => {
1696
1750
  } = store;
1697
1751
  const sheet = sheetRef.current;
1698
1752
  const [y, startY, endY] = posY;
1699
- const [x2, startX, endX] = posX;
1753
+ const [x, startX, endX] = posX;
1700
1754
  if (mainRef.current == null || editorRef.current == null || !sheet) {
1701
1755
  return /* @__PURE__ */ jsx("div", { className: "gs-resizing gs-hidden" });
1702
1756
  }
1703
- const cell = sheet.getCell({ y: y === -1 ? 0 : y, x: x2 === -1 ? 0 : x2 }, { resolution: "SYSTEM" });
1757
+ const cell = sheet.getCell({ y: y === -1 ? 0 : y, x: x === -1 ? 0 : x }, { resolution: "SYSTEM" });
1704
1758
  const { y: offsetY, x: offsetX } = mainRef.current.getBoundingClientRect();
1705
- const baseWidth = (cell == null ? void 0 : cell.width) || jt;
1706
- const baseHeight = (cell == null ? void 0 : cell.height) || J;
1759
+ const baseWidth = (cell == null ? void 0 : cell.width) || he;
1760
+ const baseHeight = (cell == null ? void 0 : cell.height) || rt;
1707
1761
  const width = baseWidth + (endX - startX);
1708
1762
  const height = baseHeight + (endY - startY);
1709
1763
  const handleResizeEnd = () => {
1710
- const selectingArea = Rs(selectingZone);
1764
+ const selectingArea = ks(selectingZone);
1711
1765
  const { top, left, bottom, right } = selectingArea;
1712
1766
  const diff = {};
1713
- if (x2 !== -1) {
1714
- let xs = [x2];
1715
- if (topHeaderSelecting && Vr({ start: left, end: right }, x2)) {
1716
- xs = jr(left, right + 1);
1767
+ if (x !== -1) {
1768
+ let xs = [x];
1769
+ if (topHeaderSelecting && nn({ start: left, end: right }, x)) {
1770
+ xs = cn(left, right + 1);
1717
1771
  }
1718
- xs.forEach((x22) => {
1719
- diff[D({ y: 0, x: x22 })] = { width };
1772
+ xs.forEach((x2) => {
1773
+ diff[M({ y: 0, x: x2 })] = { width };
1720
1774
  });
1721
1775
  }
1722
1776
  if (y !== -1) {
1723
1777
  let ys = [y];
1724
- if (leftHeaderSelecting && Vr({ start: top, end: bottom }, y)) {
1725
- ys = jr(top, bottom + 1);
1778
+ if (leftHeaderSelecting && nn({ start: top, end: bottom }, y)) {
1779
+ ys = cn(top, bottom + 1);
1726
1780
  }
1727
1781
  ys.forEach((y2) => {
1728
- diff[D({ y: y2, x: 0 })] = { height };
1782
+ diff[M({ y: y2, x: 0 })] = { height };
1729
1783
  });
1730
1784
  }
1731
1785
  sheet.update({
@@ -1741,33 +1795,33 @@ const Resizer = () => {
1741
1795
  );
1742
1796
  dispatch(setResizingPositionY([-1, -1, -1]));
1743
1797
  dispatch(setResizingPositionX([-1, -1, -1]));
1744
- j(editorRef.current);
1798
+ _(editorRef.current);
1745
1799
  };
1746
1800
  const handleResizeMove = (e) => {
1747
1801
  if (y !== -1) {
1748
1802
  let endY2 = e.clientY;
1749
1803
  const height2 = baseHeight + (endY2 - startY);
1750
- if (height2 < Pr) {
1751
- endY2 += Pr - height2;
1804
+ if (height2 < qr) {
1805
+ endY2 += qr - height2;
1752
1806
  }
1753
1807
  dispatch(setResizingPositionY([y, startY, endY2]));
1754
- } else if (x2 !== -1) {
1808
+ } else if (x !== -1) {
1755
1809
  let endX2 = e.clientX;
1756
1810
  const width2 = baseWidth + (endX2 - startX);
1757
- if (width2 < kr) {
1758
- endX2 += kr - width2;
1811
+ if (width2 < Zr) {
1812
+ endX2 += Zr - width2;
1759
1813
  }
1760
- dispatch(setResizingPositionX([x2, startX, endX2]));
1814
+ dispatch(setResizingPositionX([x, startX, endX2]));
1761
1815
  }
1762
1816
  };
1763
1817
  return /* @__PURE__ */ jsxs(
1764
1818
  "div",
1765
1819
  {
1766
- className: `gs-resizing ${y === -1 && x2 === -1 ? "gs-hidden" : ""}`,
1820
+ className: `gs-resizing ${y === -1 && x === -1 ? "gs-hidden" : ""}`,
1767
1821
  onMouseUp: handleResizeEnd,
1768
1822
  onMouseMove: handleResizeMove,
1769
1823
  children: [
1770
- /* @__PURE__ */ jsx("div", { className: `gs-line-vertical ${x2 === -1 ? "gs-hidden" : ""}`, children: /* @__PURE__ */ jsx("div", { className: "gs-line", style: { width: 1, height: "100%", left: endX - offsetX }, children: /* @__PURE__ */ jsxs("span", { style: { left: "-50%" }, children: [
1824
+ /* @__PURE__ */ jsx("div", { className: `gs-line-vertical ${x === -1 ? "gs-hidden" : ""}`, children: /* @__PURE__ */ jsx("div", { className: "gs-line", style: { width: 1, height: "100%", left: endX - offsetX }, children: /* @__PURE__ */ jsxs("span", { style: { left: "-50%" }, children: [
1771
1825
  width,
1772
1826
  "px"
1773
1827
  ] }) }) }),
@@ -1812,14 +1866,14 @@ const Emitter = () => {
1812
1866
  const copier = async ({ store, dispatch }) => {
1813
1867
  const { editorRef } = store;
1814
1868
  const area = clip(store);
1815
- dispatch(copy(Ee(area)));
1816
- j(editorRef.current);
1869
+ dispatch(copy(Pe(area)));
1870
+ _(editorRef.current);
1817
1871
  };
1818
1872
  const cutter = async ({ store, dispatch }) => {
1819
1873
  const { editorRef } = store;
1820
1874
  const area = clip(store);
1821
- dispatch(cut(Ee(area)));
1822
- j(editorRef.current);
1875
+ dispatch(cut(Pe(area)));
1876
+ _(editorRef.current);
1823
1877
  };
1824
1878
  const paster = async ({ store, dispatch }, onlyValue = false) => {
1825
1879
  const { editorRef } = store;
@@ -1844,118 +1898,118 @@ const paster = async ({ store, dispatch }, onlyValue = false) => {
1844
1898
  }
1845
1899
  }
1846
1900
  dispatch(paste({ matrix: cells, onlyValue }));
1847
- j(editorRef.current);
1901
+ _(editorRef.current);
1848
1902
  };
1849
1903
  const undoer = async ({ store, dispatch }) => {
1850
1904
  const { editorRef } = store;
1851
1905
  dispatch(undo(null));
1852
- j(editorRef.current);
1906
+ _(editorRef.current);
1853
1907
  };
1854
1908
  const redoer = async ({ store, dispatch }) => {
1855
1909
  const { editorRef } = store;
1856
1910
  dispatch(redo(null));
1857
- j(editorRef.current);
1911
+ _(editorRef.current);
1858
1912
  };
1859
1913
  const rowsInserterAbove = async ({ store, dispatch }) => {
1860
1914
  const { selectingZone, editorRef } = store;
1861
- const { top } = Rs(selectingZone);
1862
- const numRows = Xr(selectingZone).rows;
1915
+ const { top } = ks(selectingZone);
1916
+ const numRows = an(selectingZone).rows;
1863
1917
  dispatch(insertRowsAbove({ numRows, y: top, operator: "USER" }));
1864
- j(editorRef.current);
1918
+ _(editorRef.current);
1865
1919
  };
1866
1920
  const rowsInserterBelow = async ({ store, dispatch }) => {
1867
1921
  const { selectingZone, editorRef } = store;
1868
- const { bottom } = Rs(selectingZone);
1869
- const numRows = Xr(selectingZone).rows;
1922
+ const { bottom } = ks(selectingZone);
1923
+ const numRows = an(selectingZone).rows;
1870
1924
  dispatch(insertRowsBelow({ numRows, y: bottom, operator: "USER" }));
1871
- j(editorRef.current);
1925
+ _(editorRef.current);
1872
1926
  };
1873
1927
  const colsInserterLeft = async ({ store, dispatch }) => {
1874
1928
  const { selectingZone, editorRef } = store;
1875
- const { left } = Rs(selectingZone);
1876
- const numCols = Xr(selectingZone).cols;
1929
+ const { left } = ks(selectingZone);
1930
+ const numCols = an(selectingZone).cols;
1877
1931
  dispatch(insertColsLeft({ numCols, x: left, operator: "USER" }));
1878
- j(editorRef.current);
1932
+ _(editorRef.current);
1879
1933
  };
1880
1934
  const colsInserterRight = async ({ store, dispatch }) => {
1881
1935
  const { selectingZone, editorRef } = store;
1882
- const { right } = Rs(selectingZone);
1883
- const numCols = Xr(selectingZone).cols;
1936
+ const { right } = ks(selectingZone);
1937
+ const numCols = an(selectingZone).cols;
1884
1938
  dispatch(insertColsRight({ numCols, x: right, operator: "USER" }));
1885
- j(editorRef.current);
1939
+ _(editorRef.current);
1886
1940
  };
1887
1941
  const rowsRemover = async ({ store, dispatch }) => {
1888
1942
  const { selectingZone, editorRef } = store;
1889
- const { top } = Rs(selectingZone);
1890
- const numRows = Xr(selectingZone).rows;
1943
+ const { top } = ks(selectingZone);
1944
+ const numRows = an(selectingZone).rows;
1891
1945
  dispatch(removeRows({ numRows, y: top, operator: "USER" }));
1892
- j(editorRef.current);
1946
+ _(editorRef.current);
1893
1947
  };
1894
1948
  const colsRemover = async ({ store, dispatch }) => {
1895
1949
  const { selectingZone, editorRef } = store;
1896
- const { left } = Rs(selectingZone);
1897
- const numCols = Xr(selectingZone).cols;
1950
+ const { left } = ks(selectingZone);
1951
+ const numCols = an(selectingZone).cols;
1898
1952
  dispatch(removeCols({ numCols, x: left, operator: "USER" }));
1899
- j(editorRef.current);
1953
+ _(editorRef.current);
1900
1954
  };
1901
- const rowsSorterAsc = async ({ store, dispatch }, x2) => {
1955
+ const rowsSorterAsc = async ({ store, dispatch }, x) => {
1902
1956
  const sheet = store.sheetReactive.current;
1903
1957
  if (sheet && (sheet.hasPendingCells() || sheet.registry.asyncPending.size > 0)) {
1904
1958
  await sheet.waitForPending();
1905
1959
  }
1906
- dispatch(sortRows({ x: x2, direction: "asc" }));
1907
- j(store.editorRef.current);
1960
+ dispatch(sortRows({ x, direction: "asc" }));
1961
+ _(store.editorRef.current);
1908
1962
  };
1909
- const rowsSorterDesc = async ({ store, dispatch }, x2) => {
1963
+ const rowsSorterDesc = async ({ store, dispatch }, x) => {
1910
1964
  const sheet = store.sheetReactive.current;
1911
1965
  if (sheet && (sheet.hasPendingCells() || sheet.registry.asyncPending.size > 0)) {
1912
1966
  await sheet.waitForPending();
1913
1967
  }
1914
- dispatch(sortRows({ x: x2, direction: "desc" }));
1915
- j(store.editorRef.current);
1968
+ dispatch(sortRows({ x, direction: "desc" }));
1969
+ _(store.editorRef.current);
1916
1970
  };
1917
- const rowsFilterer = async ({ store, dispatch }, x2, filter) => {
1971
+ const rowsFilterer = async ({ store, dispatch }, x, filter) => {
1918
1972
  const sheet = store.sheetReactive.current;
1919
1973
  if (sheet && (sheet.hasPendingCells() || sheet.registry.asyncPending.size > 0)) {
1920
1974
  await sheet.waitForPending();
1921
1975
  }
1922
- dispatch(filterRows({ x: x2, filter }));
1923
- j(store.editorRef.current);
1976
+ dispatch(filterRows({ x, filter }));
1977
+ _(store.editorRef.current);
1924
1978
  };
1925
- const rowsFilterClearer = async ({ store, dispatch }, x2) => {
1926
- dispatch(filterRows({ x: x2 }));
1927
- j(store.editorRef.current);
1979
+ const rowsFilterClearer = async ({ store, dispatch }, x) => {
1980
+ dispatch(filterRows({ x }));
1981
+ _(store.editorRef.current);
1928
1982
  };
1929
1983
  const rowSortFixedToggler = ({ store, dispatch }, y) => {
1930
1984
  const sheet = store.sheetReactive.current;
1931
1985
  if (!sheet) {
1932
1986
  return;
1933
1987
  }
1934
- const addr = D({ y, x: 0 });
1988
+ const addr = M({ y, x: 0 });
1935
1989
  const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
1936
1990
  const next = !(rowCell == null ? void 0 : rowCell.sortFixed) || void 0;
1937
1991
  sheet.update({ diff: { [addr]: { sortFixed: next } }, partial: true });
1938
1992
  dispatch(updateSheet(sheet));
1939
- j(store.editorRef.current);
1993
+ _(store.editorRef.current);
1940
1994
  };
1941
1995
  const rowFilterFixedToggler = ({ store, dispatch }, y) => {
1942
1996
  const sheet = store.sheetReactive.current;
1943
1997
  if (!sheet) {
1944
1998
  return;
1945
1999
  }
1946
- const addr = D({ y, x: 0 });
2000
+ const addr = M({ y, x: 0 });
1947
2001
  const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
1948
2002
  const next = !(rowCell == null ? void 0 : rowCell.filterFixed) || void 0;
1949
2003
  sheet.update({ diff: { [addr]: { filterFixed: next } }, partial: true });
1950
2004
  dispatch(updateSheet(sheet));
1951
- j(store.editorRef.current);
2005
+ _(store.editorRef.current);
1952
2006
  };
1953
2007
  const searcher = async ({ store, dispatch }) => {
1954
2008
  if (typeof store.searchQuery === "undefined") {
1955
2009
  dispatch(setSearchQuery(""));
1956
2010
  }
1957
2011
  dispatch(setEntering(false));
1958
- requestAnimationFrame(() => j(store.searchInputRef.current));
2012
+ requestAnimationFrame(() => _(store.searchInputRef.current));
1959
2013
  };
1960
2014
  const applyers = {
1961
2015
  copy: copier,
@@ -1984,12 +2038,12 @@ const rowInsertCount = (ctx, y) => {
1984
2038
  const isFullRow = selectingZone.startX === 1 && selectingZone.endX === ctx.sheet.numCols;
1985
2039
  return isFullRow && y >= selStart && y <= selEnd ? selEnd - selStart + 1 : 1;
1986
2040
  };
1987
- const colInsertCount = (ctx, x2) => {
2041
+ const colInsertCount = (ctx, x) => {
1988
2042
  const { selectingZone } = ctx;
1989
2043
  const selStart = Math.min(selectingZone.startX, selectingZone.endX);
1990
2044
  const selEnd = Math.max(selectingZone.startX, selectingZone.endX);
1991
2045
  const isFullCol = selectingZone.startY === 1 && selectingZone.endY === ctx.sheet.numRows;
1992
- return isFullCol && x2 >= selStart && x2 <= selEnd ? selEnd - selStart + 1 : 1;
2046
+ return isFullCol && x >= selStart && x <= selEnd ? selEnd - selStart + 1 : 1;
1993
2047
  };
1994
2048
  const defaultContextMenuDescriptors = [
1995
2049
  {
@@ -2020,92 +2074,92 @@ const defaultContextMenuDescriptors = [
2020
2074
  {
2021
2075
  id: "insert-rows-above",
2022
2076
  label: (ctx) => {
2023
- const n = Xr(ctx.selectingZone).rows;
2077
+ const n = an(ctx.selectingZone).rows;
2024
2078
  return `Insert ${n} row${n > 1 ? "s" : ""} above`;
2025
2079
  },
2026
2080
  visible: (ctx) => ctx.leftHeaderSelecting,
2027
2081
  disabled: (ctx) => {
2028
- const n = Xr(ctx.selectingZone).rows;
2082
+ const n = an(ctx.selectingZone).rows;
2029
2083
  const sheet = ctx.sheet;
2030
2084
  const rowCell = sheet.getCell({ y: ctx.choosing.y, x: 0 }, { resolution: "SYSTEM" });
2031
- return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || pn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, pn.InsertRowsAbove);
2085
+ return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || Mn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, Mn.InsertRowsAbove);
2032
2086
  },
2033
- onClick: (ctx) => ctx.insertRowsAbove(ctx.choosing.y, Xr(ctx.selectingZone).rows)
2087
+ onClick: (ctx) => ctx.insertRowsAbove(ctx.choosing.y, an(ctx.selectingZone).rows)
2034
2088
  },
2035
2089
  {
2036
2090
  id: "insert-rows-below",
2037
2091
  label: (ctx) => {
2038
- const n = Xr(ctx.selectingZone).rows;
2092
+ const n = an(ctx.selectingZone).rows;
2039
2093
  return `Insert ${n} row${n > 1 ? "s" : ""} below`;
2040
2094
  },
2041
2095
  visible: (ctx) => ctx.leftHeaderSelecting,
2042
2096
  disabled: (ctx) => {
2043
- const n = Xr(ctx.selectingZone).rows;
2097
+ const n = an(ctx.selectingZone).rows;
2044
2098
  const sheet = ctx.sheet;
2045
2099
  const rowCell = sheet.getCell({ y: ctx.choosing.y, x: 0 }, { resolution: "SYSTEM" });
2046
- return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || pn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, pn.InsertRowsBelow);
2100
+ return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || Mn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, Mn.InsertRowsBelow);
2047
2101
  },
2048
- onClick: (ctx) => ctx.insertRowsBelow(ctx.choosing.y, Xr(ctx.selectingZone).rows)
2102
+ onClick: (ctx) => ctx.insertRowsBelow(ctx.choosing.y, an(ctx.selectingZone).rows)
2049
2103
  },
2050
2104
  {
2051
2105
  id: "insert-cols-left",
2052
2106
  label: (ctx) => {
2053
- const n = Xr(ctx.selectingZone).cols;
2107
+ const n = an(ctx.selectingZone).cols;
2054
2108
  return `Insert ${n} column${n > 1 ? "s" : ""} left`;
2055
2109
  },
2056
2110
  visible: (ctx) => ctx.topHeaderSelecting,
2057
2111
  disabled: (ctx) => {
2058
- const n = Xr(ctx.selectingZone).cols;
2112
+ const n = an(ctx.selectingZone).cols;
2059
2113
  const sheet = ctx.sheet;
2060
2114
  const colCell = sheet.getCell({ y: 0, x: ctx.choosing.x }, { resolution: "SYSTEM" });
2061
- return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.InsertColsLeft);
2115
+ return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || Mn.hasOperation(colCell == null ? void 0 : colCell.prevention, Mn.InsertColsLeft);
2062
2116
  },
2063
- onClick: (ctx) => ctx.insertColsLeft(ctx.choosing.x, Xr(ctx.selectingZone).cols)
2117
+ onClick: (ctx) => ctx.insertColsLeft(ctx.choosing.x, an(ctx.selectingZone).cols)
2064
2118
  },
2065
2119
  {
2066
2120
  id: "insert-cols-right",
2067
2121
  label: (ctx) => {
2068
- const n = Xr(ctx.selectingZone).cols;
2122
+ const n = an(ctx.selectingZone).cols;
2069
2123
  return `Insert ${n} column${n > 1 ? "s" : ""} right`;
2070
2124
  },
2071
2125
  visible: (ctx) => ctx.topHeaderSelecting,
2072
2126
  disabled: (ctx) => {
2073
- const n = Xr(ctx.selectingZone).cols;
2127
+ const n = an(ctx.selectingZone).cols;
2074
2128
  const sheet = ctx.sheet;
2075
2129
  const colCell = sheet.getCell({ y: 0, x: ctx.choosing.x }, { resolution: "SYSTEM" });
2076
- return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.InsertColsRight);
2130
+ return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || Mn.hasOperation(colCell == null ? void 0 : colCell.prevention, Mn.InsertColsRight);
2077
2131
  },
2078
- onClick: (ctx) => ctx.insertColsRight(ctx.choosing.x, Xr(ctx.selectingZone).cols)
2132
+ onClick: (ctx) => ctx.insertColsRight(ctx.choosing.x, an(ctx.selectingZone).cols)
2079
2133
  },
2080
2134
  {
2081
2135
  id: "remove-rows",
2082
2136
  label: (ctx) => {
2083
- const n = Xr(ctx.selectingZone).rows;
2137
+ const n = an(ctx.selectingZone).rows;
2084
2138
  return `Remove ${n} row${n > 1 ? "s" : ""}`;
2085
2139
  },
2086
2140
  visible: (ctx) => ctx.leftHeaderSelecting,
2087
2141
  disabled: (ctx) => {
2088
- const n = Xr(ctx.selectingZone).rows;
2142
+ const n = an(ctx.selectingZone).rows;
2089
2143
  const sheet = ctx.sheet;
2090
2144
  const rowCell = sheet.getCell({ y: ctx.choosing.y, x: 0 }, { resolution: "SYSTEM" });
2091
- return sheet.minNumRows !== -1 && sheet.numRows - n < sheet.minNumRows || pn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, pn.RemoveRows);
2145
+ return sheet.minNumRows !== -1 && sheet.numRows - n < sheet.minNumRows || Mn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, Mn.RemoveRows);
2092
2146
  },
2093
- onClick: (ctx) => ctx.removeRows(ctx.choosing.y, Xr(ctx.selectingZone).rows)
2147
+ onClick: (ctx) => ctx.removeRows(ctx.choosing.y, an(ctx.selectingZone).rows)
2094
2148
  },
2095
2149
  {
2096
2150
  id: "remove-cols",
2097
2151
  label: (ctx) => {
2098
- const n = Xr(ctx.selectingZone).cols;
2152
+ const n = an(ctx.selectingZone).cols;
2099
2153
  return `Remove ${n} column${n > 1 ? "s" : ""}`;
2100
2154
  },
2101
2155
  visible: (ctx) => ctx.topHeaderSelecting,
2102
2156
  disabled: (ctx) => {
2103
- const n = Xr(ctx.selectingZone).cols;
2157
+ const n = an(ctx.selectingZone).cols;
2104
2158
  const sheet = ctx.sheet;
2105
2159
  const colCell = sheet.getCell({ y: 0, x: ctx.choosing.x }, { resolution: "SYSTEM" });
2106
- return sheet.minNumCols !== -1 && sheet.numCols - n < sheet.minNumCols || pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.RemoveCols);
2160
+ return sheet.minNumCols !== -1 && sheet.numCols - n < sheet.minNumCols || Mn.hasOperation(colCell == null ? void 0 : colCell.prevention, Mn.RemoveCols);
2107
2161
  },
2108
- onClick: (ctx) => ctx.removeCols(ctx.choosing.x, Xr(ctx.selectingZone).cols)
2162
+ onClick: (ctx) => ctx.removeCols(ctx.choosing.x, an(ctx.selectingZone).cols)
2109
2163
  },
2110
2164
  { type: "divider" },
2111
2165
  {
@@ -2166,7 +2220,7 @@ const defaultRowMenuDescriptors = [
2166
2220
  const n = rowInsertCount(ctx, y);
2167
2221
  const sheet = ctx.sheet;
2168
2222
  const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
2169
- return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || pn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, pn.InsertRowsAbove);
2223
+ return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || Mn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, Mn.InsertRowsAbove);
2170
2224
  },
2171
2225
  onClick: (ctx, y) => ctx.insertRowsAbove(y, rowInsertCount(ctx, y))
2172
2226
  },
@@ -2180,7 +2234,7 @@ const defaultRowMenuDescriptors = [
2180
2234
  const n = rowInsertCount(ctx, y);
2181
2235
  const sheet = ctx.sheet;
2182
2236
  const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
2183
- return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || pn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, pn.InsertRowsBelow);
2237
+ return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || Mn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, Mn.InsertRowsBelow);
2184
2238
  },
2185
2239
  onClick: (ctx, y) => ctx.insertRowsBelow(y, rowInsertCount(ctx, y))
2186
2240
  },
@@ -2194,7 +2248,7 @@ const defaultRowMenuDescriptors = [
2194
2248
  const n = rowInsertCount(ctx, y);
2195
2249
  const sheet = ctx.sheet;
2196
2250
  const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
2197
- return sheet.minNumRows !== -1 && sheet.numRows - n < sheet.minNumRows || pn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, pn.RemoveRows);
2251
+ return sheet.minNumRows !== -1 && sheet.numRows - n < sheet.minNumRows || Mn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, Mn.RemoveRows);
2198
2252
  },
2199
2253
  onClick: (ctx, y) => ctx.removeRows(y, rowInsertCount(ctx, y))
2200
2254
  },
@@ -2259,45 +2313,45 @@ const defaultColMenuDescriptors = [
2259
2313
  { type: "divider" },
2260
2314
  {
2261
2315
  id: "insert-cols-left",
2262
- label: (ctx, x2) => {
2263
- const n = colInsertCount(ctx, x2);
2316
+ label: (ctx, x) => {
2317
+ const n = colInsertCount(ctx, x);
2264
2318
  return `Insert ${n} column${n > 1 ? "s" : ""} left`;
2265
2319
  },
2266
- disabled: (ctx, x2) => {
2267
- const n = colInsertCount(ctx, x2);
2320
+ disabled: (ctx, x) => {
2321
+ const n = colInsertCount(ctx, x);
2268
2322
  const sheet = ctx.sheet;
2269
- const colCell = sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
2270
- return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.InsertColsLeft);
2323
+ const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2324
+ return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || Mn.hasOperation(colCell == null ? void 0 : colCell.prevention, Mn.InsertColsLeft);
2271
2325
  },
2272
- onClick: (ctx, x2) => ctx.insertColsLeft(x2, colInsertCount(ctx, x2))
2326
+ onClick: (ctx, x) => ctx.insertColsLeft(x, colInsertCount(ctx, x))
2273
2327
  },
2274
2328
  {
2275
2329
  id: "insert-cols-right",
2276
- label: (ctx, x2) => {
2277
- const n = colInsertCount(ctx, x2);
2330
+ label: (ctx, x) => {
2331
+ const n = colInsertCount(ctx, x);
2278
2332
  return `Insert ${n} column${n > 1 ? "s" : ""} right`;
2279
2333
  },
2280
- disabled: (ctx, x2) => {
2281
- const n = colInsertCount(ctx, x2);
2334
+ disabled: (ctx, x) => {
2335
+ const n = colInsertCount(ctx, x);
2282
2336
  const sheet = ctx.sheet;
2283
- const colCell = sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
2284
- return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.InsertColsRight);
2337
+ const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2338
+ return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || Mn.hasOperation(colCell == null ? void 0 : colCell.prevention, Mn.InsertColsRight);
2285
2339
  },
2286
- onClick: (ctx, x2) => ctx.insertColsRight(x2, colInsertCount(ctx, x2))
2340
+ onClick: (ctx, x) => ctx.insertColsRight(x, colInsertCount(ctx, x))
2287
2341
  },
2288
2342
  {
2289
2343
  id: "remove-cols",
2290
- label: (ctx, x2) => {
2291
- const n = colInsertCount(ctx, x2);
2344
+ label: (ctx, x) => {
2345
+ const n = colInsertCount(ctx, x);
2292
2346
  return `Remove ${n} column${n > 1 ? "s" : ""}`;
2293
2347
  },
2294
- disabled: (ctx, x2) => {
2295
- const n = colInsertCount(ctx, x2);
2348
+ disabled: (ctx, x) => {
2349
+ const n = colInsertCount(ctx, x);
2296
2350
  const sheet = ctx.sheet;
2297
- const colCell = sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
2298
- return sheet.minNumCols !== -1 && sheet.numCols - n < sheet.minNumCols || pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.RemoveCols);
2351
+ const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2352
+ return sheet.minNumCols !== -1 && sheet.numCols - n < sheet.minNumCols || Mn.hasOperation(colCell == null ? void 0 : colCell.prevention, Mn.RemoveCols);
2299
2353
  },
2300
- onClick: (ctx, x2) => ctx.removeCols(x2, colInsertCount(ctx, x2))
2354
+ onClick: (ctx, x) => ctx.removeCols(x, colInsertCount(ctx, x))
2301
2355
  },
2302
2356
  { type: "divider" },
2303
2357
  {
@@ -2330,38 +2384,38 @@ function buildMenuContext(store, dispatch, close) {
2330
2384
  removeRows: (y, numRows) => {
2331
2385
  dispatch(removeRows({ numRows, y, operator: "USER" }));
2332
2386
  },
2333
- insertColsLeft: (x2, numCols) => {
2334
- dispatch(insertColsLeft({ numCols, x: x2, operator: "USER" }));
2387
+ insertColsLeft: (x, numCols) => {
2388
+ dispatch(insertColsLeft({ numCols, x, operator: "USER" }));
2335
2389
  },
2336
- insertColsRight: (x2, numCols) => {
2337
- dispatch(insertColsRight({ numCols, x: x2, operator: "USER" }));
2390
+ insertColsRight: (x, numCols) => {
2391
+ dispatch(insertColsRight({ numCols, x, operator: "USER" }));
2338
2392
  },
2339
- removeCols: (x2, numCols) => {
2340
- dispatch(removeCols({ numCols, x: x2, operator: "USER" }));
2393
+ removeCols: (x, numCols) => {
2394
+ dispatch(removeCols({ numCols, x, operator: "USER" }));
2341
2395
  },
2342
- sortRows: async (x2, direction) => {
2396
+ sortRows: async (x, direction) => {
2343
2397
  if (direction === "asc") {
2344
- await rowsSorterAsc(props, x2);
2398
+ await rowsSorterAsc(props, x);
2345
2399
  } else {
2346
- await rowsSorterDesc(props, x2);
2400
+ await rowsSorterDesc(props, x);
2347
2401
  }
2348
2402
  },
2349
- filterRows: async (x2, filter) => {
2403
+ filterRows: async (x, filter) => {
2350
2404
  if (filter) {
2351
- await rowsFilterer(props, x2, filter);
2405
+ await rowsFilterer(props, x, filter);
2352
2406
  } else {
2353
- rowsFilterClearer(props, x2);
2407
+ rowsFilterClearer(props, x);
2354
2408
  }
2355
2409
  },
2356
- clearFilter: (x2) => rowsFilterClearer(props, x2),
2410
+ clearFilter: (x) => rowsFilterClearer(props, x),
2357
2411
  toggleSortFixed: (y) => rowSortFixedToggler(props, y),
2358
2412
  toggleFilterFixed: (y) => rowFilterFixedToggler(props, y),
2359
2413
  search: () => searcher(props),
2360
- updateColLabel: (x2, label) => {
2414
+ updateColLabel: (x, label) => {
2361
2415
  if (!sheet) {
2362
2416
  return;
2363
2417
  }
2364
- const addr = D({ y: 0, x: x2 });
2418
+ const addr = M({ y: 0, x });
2365
2419
  sheet.update({
2366
2420
  diff: { [addr]: { label: label || void 0 } },
2367
2421
  partial: true,
@@ -2412,10 +2466,10 @@ const MenuItem = ({
2412
2466
  shortcuts != null && shortcuts.length > 0 && /* @__PURE__ */ jsx("div", { className: "gs-menu-shortcut", children: shortcuts.map((shortcut, i) => /* @__PURE__ */ jsxs("span", { children: [
2413
2467
  i > 0 && /* @__PURE__ */ jsx("span", { className: "gs-menu-shortcut-sep", children: ", " }),
2414
2468
  /* @__PURE__ */ jsx("span", { className: "gs-menu-shortcut-badge", children: shortcut.split("+").map(
2415
- (part, j2, arr) => j2 < arr.length - 1 ? /* @__PURE__ */ jsxs("span", { children: [
2469
+ (part, j, arr) => j < arr.length - 1 ? /* @__PURE__ */ jsxs("span", { children: [
2416
2470
  part,
2417
2471
  "+"
2418
- ] }, j2) : /* @__PURE__ */ jsx("span", { className: "gs-menu-underline", children: part }, j2)
2472
+ ] }, j) : /* @__PURE__ */ jsx("span", { className: "gs-menu-underline", children: part }, j)
2419
2473
  ) })
2420
2474
  ] }, i)) })
2421
2475
  ]
@@ -2423,6 +2477,129 @@ const MenuItem = ({
2423
2477
  );
2424
2478
  };
2425
2479
  const MenuDivider = () => /* @__PURE__ */ jsx("li", { className: "gs-menu-divider" });
2480
+ const MenuNodes = ({ items, ctx, args, onSelect, renderComponent }) => {
2481
+ return /* @__PURE__ */ jsx(Fragment, { children: items.map((d, i) => {
2482
+ var _a, _b;
2483
+ if (d.type === "divider") {
2484
+ if (d.visible && !d.visible(ctx, ...args)) {
2485
+ return null;
2486
+ }
2487
+ return /* @__PURE__ */ jsx(MenuDivider, {}, i);
2488
+ }
2489
+ if (d.type === "component") {
2490
+ if (d.visible && !d.visible(ctx, ...args)) {
2491
+ return null;
2492
+ }
2493
+ return renderComponent && d.componentId ? renderComponent(d.componentId, i) : null;
2494
+ }
2495
+ if (d.visible && !d.visible(ctx, ...args)) {
2496
+ return null;
2497
+ }
2498
+ const label = typeof d.label === "function" ? d.label(ctx, ...args) : d.label ?? "";
2499
+ const disabled = ((_a = d.disabled) == null ? void 0 : _a.call(d, ctx, ...args)) ?? false;
2500
+ if (d.type === "submenu") {
2501
+ return /* @__PURE__ */ jsx(
2502
+ SubmenuNode,
2503
+ {
2504
+ label,
2505
+ disabled,
2506
+ testId: d.id,
2507
+ items: d.children ?? [],
2508
+ ctx,
2509
+ args,
2510
+ onSelect,
2511
+ renderComponent
2512
+ },
2513
+ i
2514
+ );
2515
+ }
2516
+ const shortcuts = typeof d.shortcuts === "function" ? d.shortcuts(ctx, ...args) : d.shortcuts;
2517
+ const checked = (_b = d.checked) == null ? void 0 : _b.call(d, ctx, ...args);
2518
+ return /* @__PURE__ */ jsx(
2519
+ MenuItem,
2520
+ {
2521
+ label,
2522
+ shortcuts,
2523
+ disabled,
2524
+ checked,
2525
+ testId: d.id ? `${d.id}-item` : void 0,
2526
+ onClick: () => {
2527
+ var _a2;
2528
+ (_a2 = d.onClick) == null ? void 0 : _a2.call(d, ctx, ...args);
2529
+ onSelect();
2530
+ }
2531
+ },
2532
+ i
2533
+ );
2534
+ }) });
2535
+ };
2536
+ const SubmenuNode = ({ label, disabled, testId, items, ctx, args, onSelect, renderComponent }) => {
2537
+ const [open, setOpen] = useState(false);
2538
+ const liRef = useRef(null);
2539
+ const flyoutRef = useRef(null);
2540
+ const [pos, setPos] = useState(null);
2541
+ useLayoutEffect(() => {
2542
+ if (!open || disabled) {
2543
+ setPos(null);
2544
+ return;
2545
+ }
2546
+ const li = liRef.current;
2547
+ const fly = flyoutRef.current;
2548
+ if (!li || !fly) {
2549
+ return;
2550
+ }
2551
+ const p = li.getBoundingClientRect();
2552
+ const f = fly.getBoundingClientRect();
2553
+ const margin = 6;
2554
+ let left = p.right;
2555
+ if (left + f.width > window.innerWidth - margin) {
2556
+ left = p.left - f.width;
2557
+ if (left < margin) {
2558
+ left = Math.max(margin, window.innerWidth - f.width - margin);
2559
+ }
2560
+ }
2561
+ let top = p.top;
2562
+ if (top + f.height > window.innerHeight - margin) {
2563
+ top = window.innerHeight - f.height - margin;
2564
+ }
2565
+ if (top < margin) {
2566
+ top = margin;
2567
+ }
2568
+ setPos({ left, top });
2569
+ }, [open, disabled]);
2570
+ return /* @__PURE__ */ jsxs(
2571
+ "li",
2572
+ {
2573
+ ref: liRef,
2574
+ className: `gs-menu-item gs-submenu-parent ${disabled ? "gs-disabled" : "gs-enabled"}`,
2575
+ "data-testid": testId ? `${testId}-item` : void 0,
2576
+ onMouseEnter: () => setOpen(true),
2577
+ onMouseLeave: () => setOpen(false),
2578
+ onClick: (e) => {
2579
+ e.stopPropagation();
2580
+ setOpen(true);
2581
+ },
2582
+ children: [
2583
+ /* @__PURE__ */ jsx("div", { className: "gs-menu-name", children: label }),
2584
+ /* @__PURE__ */ jsx("span", { className: "gs-submenu-arrow", children: "▸" }),
2585
+ open && !disabled && /* @__PURE__ */ jsx(
2586
+ "ul",
2587
+ {
2588
+ ref: flyoutRef,
2589
+ className: "gs-menu-items gs-submenu-flyout",
2590
+ style: {
2591
+ position: "fixed",
2592
+ left: pos ? pos.left : -9999,
2593
+ top: pos ? pos.top : -9999,
2594
+ visibility: pos ? "visible" : "hidden"
2595
+ },
2596
+ children: /* @__PURE__ */ jsx(MenuNodes, { items, ctx, args, onSelect, renderComponent })
2597
+ }
2598
+ )
2599
+ ]
2600
+ }
2601
+ );
2602
+ };
2426
2603
  const ContextMenu = () => {
2427
2604
  const { store, dispatch } = useContext(Context);
2428
2605
  const { contextMenuPosition, contextMenu } = store;
@@ -2430,7 +2607,7 @@ const ContextMenu = () => {
2430
2607
  const menuRef = useRef(null);
2431
2608
  useEffect(() => {
2432
2609
  if (menuRef.current) {
2433
- ee(menuRef.current);
2610
+ ue(menuRef.current);
2434
2611
  }
2435
2612
  });
2436
2613
  if (top === -1) {
@@ -2447,38 +2624,7 @@ const ContextMenu = () => {
2447
2624
  close();
2448
2625
  return false;
2449
2626
  },
2450
- children: /* @__PURE__ */ jsx("div", { ref: menuRef, className: "gs-context-menu", style: { top, left }, children: /* @__PURE__ */ jsx("ul", { className: "gs-menu-items", children: contextMenu.map((d, i) => {
2451
- var _a, _b;
2452
- if (d.type === "divider") {
2453
- if (d.visible && !d.visible(ctx)) {
2454
- return null;
2455
- }
2456
- return /* @__PURE__ */ jsx(MenuDivider, {}, i);
2457
- }
2458
- if (d.type === "component") {
2459
- return null;
2460
- }
2461
- const visible = !d.visible || d.visible(ctx);
2462
- if (!visible) {
2463
- return null;
2464
- }
2465
- const disabled = ((_a = d.disabled) == null ? void 0 : _a.call(d, ctx)) ?? false;
2466
- const label = typeof d.label === "function" ? d.label(ctx) : d.label;
2467
- const shortcuts = typeof d.shortcuts === "function" ? d.shortcuts(ctx) : d.shortcuts;
2468
- const checked = (_b = d.checked) == null ? void 0 : _b.call(d, ctx);
2469
- return /* @__PURE__ */ jsx(
2470
- MenuItem,
2471
- {
2472
- label,
2473
- shortcuts,
2474
- disabled,
2475
- checked,
2476
- testId: d.id ? `${d.id}-item` : void 0,
2477
- onClick: () => d.onClick(ctx)
2478
- },
2479
- i
2480
- );
2481
- }) }) })
2627
+ children: /* @__PURE__ */ jsx("div", { ref: menuRef, className: "gs-context-menu", style: { top, left }, children: /* @__PURE__ */ jsx("ul", { className: "gs-menu-items", children: /* @__PURE__ */ jsx(MenuNodes, { items: contextMenu, ctx, args: [], onSelect: close }) }) })
2482
2628
  }
2483
2629
  );
2484
2630
  };
@@ -2496,7 +2642,7 @@ const METHOD_LABELS = {
2496
2642
  };
2497
2643
  const NO_VALUE_METHODS = ["blank", "nonblank"];
2498
2644
  const DEFAULT_CONDITION = { method: "eq", value: [""] };
2499
- const FilterSection = ({ x: x2, close, onWaiting }) => {
2645
+ const FilterSection = ({ x, close, onWaiting }) => {
2500
2646
  const { store, dispatch } = useContext(Context);
2501
2647
  const { sheetReactive: sheetRef } = store;
2502
2648
  const sheet = sheetRef.current;
@@ -2510,11 +2656,11 @@ const FilterSection = ({ x: x2, close, onWaiting }) => {
2510
2656
  }
2511
2657
  },
2512
2658
  // eslint-disable-next-line react-hooks/exhaustive-deps
2513
- [x2]
2659
+ [x]
2514
2660
  );
2515
2661
  useEffect(() => {
2516
2662
  if (sheet) {
2517
- const colCell2 = sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
2663
+ const colCell2 = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2518
2664
  const existing = colCell2 == null ? void 0 : colCell2.filter;
2519
2665
  if (existing && existing.conditions.length > 0) {
2520
2666
  setConditions(existing.conditions.map((c) => ({ ...c, value: [...c.value] })));
@@ -2524,7 +2670,7 @@ const FilterSection = ({ x: x2, close, onWaiting }) => {
2524
2670
  setMode("or");
2525
2671
  }
2526
2672
  }
2527
- }, [x2, sheet]);
2673
+ }, [x, sheet]);
2528
2674
  const handleCancel = useCallback(() => {
2529
2675
  setPending(null);
2530
2676
  onWaiting == null ? void 0 : onWaiting(null);
@@ -2591,15 +2737,15 @@ const FilterSection = ({ x: x2, close, onWaiting }) => {
2591
2737
  if (NO_VALUE_METHODS.includes(c.method)) {
2592
2738
  return true;
2593
2739
  }
2594
- return c.value.some((v2) => v2.trim() !== "");
2740
+ return c.value.some((v) => v.trim() !== "");
2595
2741
  });
2596
- setPending({ x: x2, conditions: valid, mode });
2597
- }, [x2, conditions, mode]);
2742
+ setPending({ x, conditions: valid, mode });
2743
+ }, [x, conditions, mode]);
2598
2744
  const handleResetColumn = useCallback(() => {
2599
2745
  setPending(null);
2600
- dispatch(filterRows({ x: x2 }));
2746
+ dispatch(filterRows({ x }));
2601
2747
  close();
2602
- }, [dispatch, x2, close]);
2748
+ }, [dispatch, x, close]);
2603
2749
  const handleResetAll = useCallback(() => {
2604
2750
  setPending(null);
2605
2751
  dispatch(filterRows({}));
@@ -2608,8 +2754,8 @@ const FilterSection = ({ x: x2, close, onWaiting }) => {
2608
2754
  if (!sheet) {
2609
2755
  return null;
2610
2756
  }
2611
- const colCell = sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
2612
- const filterDisabled = pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.Filter);
2757
+ const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2758
+ const filterDisabled = Mn.hasOperation(colCell == null ? void 0 : colCell.prevention, Mn.Filter);
2613
2759
  const hasAnyFilter = sheet.hasActiveFilters();
2614
2760
  return /* @__PURE__ */ jsx("li", { className: `gs-column-menu-filter${filterDisabled ? " gs-disabled" : ""}`, children: /* @__PURE__ */ jsxs(Fragment, { children: [
2615
2761
  /* @__PURE__ */ jsxs("div", { className: "gs-filter-header", children: [
@@ -2701,7 +2847,7 @@ const FilterSection = ({ x: x2, close, onWaiting }) => {
2701
2847
  ] }) });
2702
2848
  };
2703
2849
  registerMenuComponent("col-filter", FilterSection);
2704
- const SortSection = ({ x: x2, close, onWaiting }) => {
2850
+ const SortSection = ({ x, close, onWaiting }) => {
2705
2851
  const { store, dispatch } = useContext(Context);
2706
2852
  const { sheetReactive: sheetRef } = store;
2707
2853
  const sheet = sheetRef.current;
@@ -2747,8 +2893,8 @@ const SortSection = ({ x: x2, close, onWaiting }) => {
2747
2893
  if (!sheet) {
2748
2894
  return null;
2749
2895
  }
2750
- const colCell = sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
2751
- const sortDisabled = pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.Sort);
2896
+ const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2897
+ const sortDisabled = Mn.hasOperation(colCell == null ? void 0 : colCell.prevention, Mn.Sort);
2752
2898
  return /* @__PURE__ */ jsxs("li", { className: `gs-menu-item gs-column-menu-sort${sortDisabled ? " gs-disabled" : ""}`, children: [
2753
2899
  /* @__PURE__ */ jsx("div", { className: "gs-menu-name", children: "Sort:" }),
2754
2900
  /* @__PURE__ */ jsxs("div", { className: "gs-sort-buttons", children: [
@@ -2759,7 +2905,7 @@ const SortSection = ({ x: x2, close, onWaiting }) => {
2759
2905
  onClick: (e) => {
2760
2906
  e.stopPropagation();
2761
2907
  if (!sortDisabled) {
2762
- setPending({ x: x2, direction: "asc" });
2908
+ setPending({ x, direction: "asc" });
2763
2909
  }
2764
2910
  },
2765
2911
  disabled: sortDisabled,
@@ -2773,7 +2919,7 @@ const SortSection = ({ x: x2, close, onWaiting }) => {
2773
2919
  onClick: (e) => {
2774
2920
  e.stopPropagation();
2775
2921
  if (!sortDisabled) {
2776
- setPending({ x: x2, direction: "desc" });
2922
+ setPending({ x, direction: "desc" });
2777
2923
  }
2778
2924
  },
2779
2925
  disabled: sortDisabled,
@@ -2784,7 +2930,7 @@ const SortSection = ({ x: x2, close, onWaiting }) => {
2784
2930
  ] });
2785
2931
  };
2786
2932
  registerMenuComponent("col-sort", SortSection);
2787
- const LabelSection = ({ x: x2, close }) => {
2933
+ const LabelSection = ({ x, close }) => {
2788
2934
  const { store, dispatch } = useContext(Context);
2789
2935
  const { sheetReactive: sheetRef } = store;
2790
2936
  const sheet = sheetRef.current;
@@ -2793,7 +2939,7 @@ const LabelSection = ({ x: x2, close }) => {
2793
2939
  useEffect(() => {
2794
2940
  var _a;
2795
2941
  if (sheet) {
2796
- const colCell2 = sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
2942
+ const colCell2 = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2797
2943
  setLabel((colCell2 == null ? void 0 : colCell2.label) ?? "");
2798
2944
  }
2799
2945
  if ((_a = store.columnMenuState) == null ? void 0 : _a.focusLabel) {
@@ -2807,12 +2953,12 @@ const LabelSection = ({ x: x2, close }) => {
2807
2953
  })
2808
2954
  );
2809
2955
  }
2810
- }, [x2, sheet]);
2956
+ }, [x, sheet]);
2811
2957
  const handleApplyLabel = useCallback(() => {
2812
2958
  if (!sheet) {
2813
2959
  return;
2814
2960
  }
2815
- const address = D({ y: 0, x: x2 });
2961
+ const address = M({ y: 0, x });
2816
2962
  sheet.update({
2817
2963
  diff: { [address]: { label: label || void 0 } },
2818
2964
  partial: true,
@@ -2830,13 +2976,13 @@ const LabelSection = ({ x: x2, close }) => {
2830
2976
  });
2831
2977
  dispatch(setStore({ sheetReactive: { current: sheet } }));
2832
2978
  close();
2833
- }, [dispatch, x2, label, close, sheet, store.selectingZone, store.choosing]);
2979
+ }, [dispatch, x, label, close, sheet, store.selectingZone, store.choosing]);
2834
2980
  if (!sheet) {
2835
2981
  return null;
2836
2982
  }
2837
- const colCell = sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
2838
- const labelDisabled = pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.SetLabel);
2839
- const labelPlaceholder = Rn(sheet, colCell == null ? void 0 : colCell.label, { y: 0, x: x2 }, x2) ?? W(x2);
2983
+ const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2984
+ const labelDisabled = Mn.hasOperation(colCell == null ? void 0 : colCell.prevention, Mn.SetLabel);
2985
+ const labelPlaceholder = Ln(sheet, colCell == null ? void 0 : colCell.label, { y: 0, x }, x) ?? G(x);
2840
2986
  return /* @__PURE__ */ jsx("li", { className: `gs-menu-item gs-column-menu-label${labelDisabled ? " gs-disabled" : ""}`, children: /* @__PURE__ */ jsxs("label", { className: "gs-label-input-row", children: [
2841
2987
  /* @__PURE__ */ jsx("div", { className: "gs-label-input-label", children: "Label:" }),
2842
2988
  /* @__PURE__ */ jsx(
@@ -2870,12 +3016,12 @@ const ColumnMenu = () => {
2870
3016
  const { store, dispatch } = useContext(Context);
2871
3017
  const { columnMenuState, editorRef, colMenu } = store;
2872
3018
  const sheet = store.sheetReactive.current;
2873
- const x2 = columnMenuState == null ? void 0 : columnMenuState.x;
3019
+ const x = columnMenuState == null ? void 0 : columnMenuState.x;
2874
3020
  const position = columnMenuState == null ? void 0 : columnMenuState.position;
2875
3021
  const [waitingState, setWaitingState] = useState(null);
2876
3022
  const handleClose = useCallback(() => {
2877
3023
  dispatch(setColumnMenu(null));
2878
- j(editorRef.current);
3024
+ _(editorRef.current);
2879
3025
  }, [dispatch, editorRef]);
2880
3026
  const handleWaiting = useCallback(
2881
3027
  (message, cancel) => {
@@ -2887,7 +3033,7 @@ const ColumnMenu = () => {
2887
3033
  },
2888
3034
  [handleClose]
2889
3035
  );
2890
- if (!columnMenuState || !sheet || x2 == null || !position) {
3036
+ if (!columnMenuState || !sheet || x == null || !position) {
2891
3037
  return null;
2892
3038
  }
2893
3039
  const ctx = buildMenuContext(store, dispatch, handleClose);
@@ -2909,47 +3055,19 @@ const ColumnMenu = () => {
2909
3055
  className: "gs-column-menu",
2910
3056
  style: { top: position.y, left: position.x, display: waitingState ? "none" : void 0 },
2911
3057
  onClick: (e) => e.stopPropagation(),
2912
- children: /* @__PURE__ */ jsx("ul", { className: "gs-menu-items", children: colMenu.map((descriptor, index) => {
2913
- var _a;
2914
- if (descriptor.type === "component") {
2915
- const visible2 = !descriptor.visible || descriptor.visible(ctx, x2);
2916
- if (!visible2) {
2917
- return null;
2918
- }
2919
- const Section = getMenuComponent(descriptor.componentId);
2920
- if (!Section) {
2921
- return null;
2922
- }
2923
- return /* @__PURE__ */ jsx(Section, { x: x2, close: handleClose, onWaiting: handleWaiting }, index);
2924
- }
2925
- if (descriptor.type === "divider") {
2926
- if (descriptor.visible && !descriptor.visible(ctx)) {
2927
- return null;
3058
+ children: /* @__PURE__ */ jsx("ul", { className: "gs-menu-items", children: /* @__PURE__ */ jsx(
3059
+ MenuNodes,
3060
+ {
3061
+ items: colMenu,
3062
+ ctx,
3063
+ args: [x],
3064
+ onSelect: () => dispatch(setColumnMenu(null)),
3065
+ renderComponent: (componentId, key) => {
3066
+ const Section = getMenuComponent(componentId);
3067
+ return Section ? /* @__PURE__ */ jsx(Section, { x, close: handleClose, onWaiting: handleWaiting }, key) : null;
2928
3068
  }
2929
- return /* @__PURE__ */ jsx(MenuDivider, {}, index);
2930
- }
2931
- const visible = !descriptor.visible || descriptor.visible(ctx, x2);
2932
- if (!visible) {
2933
- return null;
2934
3069
  }
2935
- const disabled = ((_a = descriptor.disabled) == null ? void 0 : _a.call(descriptor, ctx, x2)) ?? false;
2936
- const label = typeof descriptor.label === "function" ? descriptor.label(ctx, x2) : descriptor.label;
2937
- const shortcuts = typeof descriptor.shortcuts === "function" ? descriptor.shortcuts(ctx, x2) : descriptor.shortcuts;
2938
- return /* @__PURE__ */ jsx(
2939
- MenuItem,
2940
- {
2941
- label,
2942
- shortcuts,
2943
- disabled,
2944
- testId: descriptor.id ? `${descriptor.id}-item` : void 0,
2945
- onClick: () => {
2946
- descriptor.onClick(ctx, x2);
2947
- dispatch(setColumnMenu(null));
2948
- }
2949
- },
2950
- index
2951
- );
2952
- }) })
3070
+ ) })
2953
3071
  }
2954
3072
  ),
2955
3073
  waitingState && /* @__PURE__ */ jsxs(
@@ -2969,38 +3087,6 @@ const ColumnMenu = () => {
2969
3087
  }
2970
3088
  );
2971
3089
  };
2972
- function renderRowDescriptor(descriptor, ctx, y, index, close) {
2973
- var _a;
2974
- if (descriptor.type === "divider") {
2975
- return /* @__PURE__ */ jsx(MenuDivider, {}, index);
2976
- }
2977
- if (descriptor.type === "component") {
2978
- return null;
2979
- }
2980
- const visible = !descriptor.visible || descriptor.visible(ctx, y);
2981
- if (!visible) {
2982
- return null;
2983
- }
2984
- const disabled = ((_a = descriptor.disabled) == null ? void 0 : _a.call(descriptor, ctx, y)) ?? false;
2985
- const label = typeof descriptor.label === "function" ? descriptor.label(ctx, y) : descriptor.label;
2986
- const shortcuts = typeof descriptor.shortcuts === "function" ? descriptor.shortcuts(ctx, y) : descriptor.shortcuts;
2987
- const checked = descriptor.checked != null ? descriptor.checked(ctx, y) : void 0;
2988
- return /* @__PURE__ */ jsx(
2989
- MenuItem,
2990
- {
2991
- label,
2992
- shortcuts,
2993
- disabled,
2994
- checked,
2995
- testId: descriptor.id ? `${descriptor.id}-item` : void 0,
2996
- onClick: () => {
2997
- descriptor.onClick(ctx, y);
2998
- close();
2999
- }
3000
- },
3001
- index
3002
- );
3003
- }
3004
3090
  const RowMenu = () => {
3005
3091
  const { store, dispatch } = useContext(Context);
3006
3092
  const { rowMenuState, sheetReactive: sheetRef, editorRef, rowMenu } = store;
@@ -3009,7 +3095,7 @@ const RowMenu = () => {
3009
3095
  const position = rowMenuState == null ? void 0 : rowMenuState.position;
3010
3096
  const handleClose = () => {
3011
3097
  dispatch(setRowMenu(null));
3012
- j(editorRef.current);
3098
+ _(editorRef.current);
3013
3099
  };
3014
3100
  if (!rowMenuState || !sheet || y == null || !position) {
3015
3101
  return null;
@@ -3024,7 +3110,7 @@ const RowMenu = () => {
3024
3110
  handleClose();
3025
3111
  return false;
3026
3112
  },
3027
- children: /* @__PURE__ */ jsx("div", { className: "gs-row-menu", style: { top: position.y, left: position.x }, onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx("ul", { className: "gs-menu-items", children: rowMenu.map((descriptor, index) => renderRowDescriptor(descriptor, ctx, y, index, handleClose)) }) })
3113
+ children: /* @__PURE__ */ jsx("div", { className: "gs-row-menu", style: { top: position.y, left: position.x }, onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx("ul", { className: "gs-menu-items", children: /* @__PURE__ */ jsx(MenuNodes, { items: rowMenu, ctx, args: [y], onSelect: handleClose }) }) })
3028
3114
  }
3029
3115
  );
3030
3116
  };
@@ -3043,10 +3129,10 @@ const safePreventDefault = (e) => {
3043
3129
  e.preventDefault();
3044
3130
  }
3045
3131
  };
3046
- const Cell = memo(({ y, x: x$1 }) => {
3132
+ const Cell = memo(({ y, x }) => {
3047
3133
  var _a;
3048
- const rowId = Et(y);
3049
- const colId = W(x$1);
3134
+ const rowId = bt(y);
3135
+ const colId = G(x);
3050
3136
  const address = `${colId}${rowId}`;
3051
3137
  const { store, dispatch } = useContext(Context);
3052
3138
  const isFirstPointed = useRef(true);
@@ -3066,9 +3152,9 @@ const Cell = memo(({ y, x: x$1 }) => {
3066
3152
  const sheet = sheetReactive.current;
3067
3153
  const xSheetFocused = isXSheetFocused(store);
3068
3154
  const lastFocused = sheet == null ? void 0 : sheet.registry.lastFocused;
3069
- const selectingArea = Rs(selectingZone);
3155
+ const selectingArea = ks(selectingZone);
3070
3156
  const editing = editingAddress === address;
3071
- const pointed = choosing.y === y && choosing.x === x$1;
3157
+ const pointed = choosing.y === y && choosing.x === x;
3072
3158
  const _setEditorRect = useCallback(() => {
3073
3159
  var _a2;
3074
3160
  const rect = (_a2 = cellRef.current) == null ? void 0 : _a2.getBoundingClientRect();
@@ -3091,7 +3177,7 @@ const Cell = memo(({ y, x: x$1 }) => {
3091
3177
  }
3092
3178
  isFirstPointed.current = false;
3093
3179
  }, [pointed, editing, _setEditorRect]);
3094
- const cell = sheet == null ? void 0 : sheet.getCell({ y, x: x$1 }, { resolution: "SYSTEM" });
3180
+ const cell = sheet == null ? void 0 : sheet.getCell({ y, x }, { resolution: "SYSTEM" });
3095
3181
  const writeCell = useCallback(
3096
3182
  (value) => {
3097
3183
  dispatch(write({ value }));
@@ -3108,10 +3194,10 @@ const Cell = memo(({ y, x: x$1 }) => {
3108
3194
  let rendered;
3109
3195
  try {
3110
3196
  if (sheet) {
3111
- rendered = sheet.render({ sheet, point: { y, x: x$1 }, apply, value: void 0 });
3197
+ rendered = sheet.render({ sheet, point: { y, x }, apply, value: void 0 });
3112
3198
  }
3113
3199
  } catch (e) {
3114
- if (x.is(e)) {
3200
+ if (S.is(e)) {
3115
3201
  errorMessage = e.message;
3116
3202
  rendered = e.code;
3117
3203
  } else {
@@ -3119,8 +3205,8 @@ const Cell = memo(({ y, x: x$1 }) => {
3119
3205
  rendered = "#UNKNOWN";
3120
3206
  }
3121
3207
  }
3122
- const [, v2] = (sheet == null ? void 0 : sheet.getSolvedCache({ y, x: x$1 })) ?? [void 0, void 0];
3123
- const isPendingCell = k.is(v2);
3208
+ const [, v] = (sheet == null ? void 0 : sheet.getSolvedCache({ y, x })) ?? [void 0, void 0];
3209
+ const isPendingCell = L.is(v);
3124
3210
  const input = editorRef.current;
3125
3211
  const editingAnywhere = !!((sheet == null ? void 0 : sheet.registry.editingAddress) || editingAddress);
3126
3212
  const handleDragStart = useCallback(
@@ -3140,25 +3226,25 @@ const Cell = memo(({ y, x: x$1 }) => {
3140
3226
  if (editingAnywhere && input) {
3141
3227
  input.blur();
3142
3228
  }
3143
- dispatch(choose({ y, x: x$1 }));
3144
- dispatch(select({ startY: y, startX: x$1, endY: y, endX: x$1 }));
3229
+ dispatch(choose({ y, x }));
3230
+ dispatch(select({ startY: y, startX: x, endY: y, endX: x }));
3145
3231
  return true;
3146
3232
  }
3147
3233
  if (e.shiftKey) {
3148
- dispatch(drag({ y, x: x$1 }));
3234
+ dispatch(drag({ y, x }));
3149
3235
  } else {
3150
- dispatch(select({ startY: y, startX: x$1, endY: -1, endX: -1 }));
3236
+ dispatch(select({ startY: y, startX: x, endY: -1, endX: -1 }));
3151
3237
  }
3152
3238
  dispatch(setDragging(true));
3153
3239
  const fullAddress = `${sheet.sheetPrefix(!xSheetFocused)}${address}`;
3154
3240
  if (editingAnywhere) {
3155
- const inserted = Y({ input: lastFocused || null, ref: fullAddress });
3241
+ const inserted = q({ input: lastFocused || null, ref: fullAddress });
3156
3242
  if (inserted) {
3157
3243
  return false;
3158
3244
  }
3159
3245
  }
3160
3246
  sheet.registry.lastFocused = input;
3161
- j(input);
3247
+ _(input);
3162
3248
  dispatch(setEditingAddress(""));
3163
3249
  if (autofillDraggingTo) {
3164
3250
  return false;
@@ -3167,7 +3253,7 @@ const Cell = memo(({ y, x: x$1 }) => {
3167
3253
  writeCell(input.value);
3168
3254
  }
3169
3255
  if (!e.shiftKey) {
3170
- dispatch(choose({ y, x: x$1 }));
3256
+ dispatch(choose({ y, x }));
3171
3257
  }
3172
3258
  return true;
3173
3259
  },
@@ -3201,7 +3287,7 @@ const Cell = memo(({ y, x: x$1 }) => {
3201
3287
  safePreventDefault(e);
3202
3288
  e.stopPropagation();
3203
3289
  if (autofillDraggingTo) {
3204
- dispatch(setAutofillDraggingTo({ x: x$1, y }));
3290
+ dispatch(setAutofillDraggingTo({ x, y }));
3205
3291
  return false;
3206
3292
  }
3207
3293
  if (leftHeaderSelecting) {
@@ -3209,17 +3295,17 @@ const Cell = memo(({ y, x: x$1 }) => {
3209
3295
  return false;
3210
3296
  }
3211
3297
  if (topHeaderSelecting) {
3212
- dispatch(drag({ y: sheet.numRows, x: x$1 }));
3298
+ dispatch(drag({ y: sheet.numRows, x }));
3213
3299
  return false;
3214
3300
  }
3215
- if (editingAnywhere && !X(lastFocused || null)) {
3301
+ if (editingAnywhere && !ee(lastFocused || null)) {
3216
3302
  return false;
3217
3303
  }
3218
- dispatch(drag({ y, x: x$1 }));
3304
+ dispatch(drag({ y, x }));
3219
3305
  if (editingAnywhere) {
3220
- const newArea = Rs({ ...selectingZone, endY: y, endX: x$1 });
3221
- const fullRange = `${sheet.sheetPrefix(!xSheetFocused)}${zr(newArea)}`;
3222
- Y({ input: lastFocused || null, ref: fullRange });
3306
+ const newArea = ks({ ...selectingZone, endY: y, endX: x });
3307
+ const fullRange = `${sheet.sheetPrefix(!xSheetFocused)}${rn(newArea)}`;
3308
+ q({ input: lastFocused || null, ref: fullRange });
3223
3309
  }
3224
3310
  return true;
3225
3311
  },
@@ -3236,11 +3322,11 @@ const Cell = memo(({ y, x: x$1 }) => {
3236
3322
  );
3237
3323
  const handleAutofillMouseDown = useCallback(
3238
3324
  (e) => {
3239
- dispatch(setAutofillDraggingTo({ x: x$1, y }));
3325
+ dispatch(setAutofillDraggingTo({ x, y }));
3240
3326
  dispatch(setDragging(true));
3241
3327
  e.stopPropagation();
3242
3328
  },
3243
- [dispatch, x$1, y]
3329
+ [dispatch, x, y]
3244
3330
  );
3245
3331
  const handleErrorTriangleEnter = useCallback(() => {
3246
3332
  var _a2;
@@ -3248,7 +3334,7 @@ const Cell = memo(({ y, x: x$1 }) => {
3248
3334
  if (!rect) {
3249
3335
  return;
3250
3336
  }
3251
- setErrorTooltipPos(J$1(rect));
3337
+ setErrorTooltipPos(ce(rect));
3252
3338
  }, []);
3253
3339
  const handleErrorTriangleLeave = useCallback(() => {
3254
3340
  setErrorTooltipPos(null);
@@ -3281,7 +3367,7 @@ const Cell = memo(({ y, x: x$1 }) => {
3281
3367
  if (!editing && pointed && selectingArea.bottom === -1) {
3282
3368
  return "gs-autofill-drag";
3283
3369
  }
3284
- if (selectingArea.bottom === y && selectingArea.right === x$1) {
3370
+ if (selectingArea.bottom === y && selectingArea.right === x) {
3285
3371
  return "gs-autofill-drag";
3286
3372
  }
3287
3373
  return "gs-autofill-drag gs-hidden";
@@ -3290,19 +3376,19 @@ const Cell = memo(({ y, x: x$1 }) => {
3290
3376
  return null;
3291
3377
  }
3292
3378
  if (!input) {
3293
- return /* @__PURE__ */ jsx("td", { "data-x": x$1, "data-y": y, "data-address": address, className: "gs-cell gs-hidden", children: /* @__PURE__ */ jsxs("div", { className: "gs-cell-inner-wrap", children: [
3379
+ return /* @__PURE__ */ jsx("td", { "data-x": x, "data-y": y, "data-address": address, className: "gs-cell gs-hidden", children: /* @__PURE__ */ jsxs("div", { className: "gs-cell-inner-wrap", children: [
3294
3380
  /* @__PURE__ */ jsx("div", { className: "gs-cell-inner", children: /* @__PURE__ */ jsx("div", { className: "gs-cell-rendered" }) }),
3295
3381
  /* @__PURE__ */ jsx("div", { className: "gs-autofill-drag" })
3296
- ] }) }, x$1);
3382
+ ] }) }, x);
3297
3383
  }
3298
3384
  return /* @__PURE__ */ jsx(
3299
3385
  "td",
3300
3386
  {
3301
3387
  ref: cellRef,
3302
- "data-x": x$1,
3388
+ "data-x": x,
3303
3389
  "data-y": y,
3304
3390
  "data-address": address,
3305
- className: `gs-cell ${Wr(selectingArea, { y, x: x$1 }) ? "gs-selecting" : ""} ${pointed ? "gs-choosing" : ""} ${editing ? "gs-editing" : ""} ${isPendingCell ? "gs-pending" : ""}`,
3391
+ className: `gs-cell ${on(selectingArea, { y, x }) ? "gs-selecting" : ""} ${pointed ? "gs-choosing" : ""} ${editing ? "gs-editing" : ""} ${isPendingCell ? "gs-pending" : ""}`,
3306
3392
  style: {
3307
3393
  ...cell == null ? void 0 : cell.style
3308
3394
  },
@@ -3357,7 +3443,7 @@ const Cell = memo(({ y, x: x$1 }) => {
3357
3443
  style: {
3358
3444
  top: errorTooltipPos.y + 4,
3359
3445
  left: errorTooltipPos.x,
3360
- transform: oe(errorTooltipPos.hAlign)
3446
+ transform: be(errorTooltipPos.hAlign)
3361
3447
  },
3362
3448
  children: errorMessage
3363
3449
  }
@@ -3367,7 +3453,7 @@ const Cell = memo(({ y, x: x$1 }) => {
3367
3453
  }
3368
3454
  )
3369
3455
  },
3370
- x$1
3456
+ x
3371
3457
  );
3372
3458
  });
3373
3459
  const acceleration = 0.4;
@@ -3406,14 +3492,14 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
3406
3492
  vertical = e.pageY > bottom ? 1 : e.pageY < top ? -1 : 0;
3407
3493
  }
3408
3494
  }
3409
- const area = Q(tabularRef.current);
3410
- let { endX: x2, endY: y } = selectingZone;
3495
+ const area = le(tabularRef.current);
3496
+ let { endX: x, endY: y } = selectingZone;
3411
3497
  if (horizontal) {
3412
- x2 = horizontal > 0 ? area.right : area.left;
3498
+ x = horizontal > 0 ? area.right : area.left;
3413
3499
  } else if (vertical) {
3414
3500
  y = vertical > 0 ? area.bottom : area.top;
3415
3501
  }
3416
- return { x: x2, y };
3502
+ return { x, y };
3417
3503
  },
3418
3504
  [sheet, horizontal, vertical, selectingZone]
3419
3505
  );
@@ -3440,20 +3526,20 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
3440
3526
  left: currentSpeed * horizontal,
3441
3527
  top: currentSpeed * vertical
3442
3528
  });
3443
- j(editorRef.current);
3444
- const { x: x2, y } = getDestEdge(e);
3529
+ _(editorRef.current);
3530
+ const { x, y } = getDestEdge(e);
3445
3531
  if (live.autofillDraggingTo) {
3446
3532
  const { y: curY, x: curX } = live.autofillDraggingTo;
3447
- dispatch(setAutofillDraggingTo({ y: y === -1 ? curY : y, x: x2 === -1 ? curX : x2 }));
3533
+ dispatch(setAutofillDraggingTo({ y: y === -1 ? curY : y, x: x === -1 ? curX : x }));
3448
3534
  } else {
3449
3535
  if (editingAnywhere) {
3450
- const newArea = Rs({ ...selectingZone, endY: y, endX: x2 });
3536
+ const newArea = ks({ ...selectingZone, endY: y, endX: x });
3451
3537
  const sheetPrefix = sheet.sheetPrefix(!xSheetFocused);
3452
- const sheetRange = zr(newArea);
3538
+ const sheetRange = rn(newArea);
3453
3539
  const fullRange = `${sheetPrefix}${sheetRange}`;
3454
- Y({ input: editorRef.current, ref: fullRange });
3540
+ q({ input: editorRef.current, ref: fullRange });
3455
3541
  }
3456
- dispatch(drag({ y, x: x2 }));
3542
+ dispatch(drag({ y, x }));
3457
3543
  }
3458
3544
  currentSpeed = Math.min(currentSpeed + acceleration, maxSpeed);
3459
3545
  scrollRef.current = requestAnimationFrame(() => scrollStep(e));
@@ -3496,23 +3582,23 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
3496
3582
  scrollRef.current = null;
3497
3583
  }
3498
3584
  isScrolling = false;
3499
- if (!U(searchInputRef.current)) {
3500
- j(editorRef.current);
3585
+ if (!re(searchInputRef.current)) {
3586
+ _(editorRef.current);
3501
3587
  }
3502
3588
  }, []);
3503
3589
  const handleMouseUp = useCallback(
3504
3590
  (e) => {
3505
3591
  e.preventDefault();
3506
3592
  e.stopPropagation();
3507
- const area = Q(tabularRef.current);
3593
+ const area = le(tabularRef.current);
3508
3594
  if (area.bottom === -1 || area.right === -1) {
3509
3595
  return;
3510
3596
  }
3511
- const { x: x2, y } = getDestEdge(e);
3597
+ const { x, y } = getDestEdge(e);
3512
3598
  if (autofillDraggingTo) {
3513
3599
  const { y: curY, x: curX } = autofillDraggingTo;
3514
- dispatch(submitAutofill({ y: y === -1 ? curY : y, x: x2 === -1 ? curX : x2 }));
3515
- j(editorRef.current);
3600
+ dispatch(submitAutofill({ y: y === -1 ? curY : y, x: x === -1 ? curX : x }));
3601
+ _(editorRef.current);
3516
3602
  } else {
3517
3603
  if (editingAnywhere) {
3518
3604
  dispatch(drag({ y: -1, x: -1 }));
@@ -3553,8 +3639,8 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
3553
3639
  }
3554
3640
  );
3555
3641
  }
3556
- const HeaderCellTop = memo(({ x: x2 }) => {
3557
- const colId = W(x2);
3642
+ const HeaderCellTop = memo(({ x }) => {
3643
+ const colId = G(x);
3558
3644
  const { store, dispatch } = useContext(Context);
3559
3645
  const {
3560
3646
  sheetReactive: sheetRef,
@@ -3569,8 +3655,8 @@ const HeaderCellTop = memo(({ x: x2 }) => {
3569
3655
  columnMenuState
3570
3656
  } = store;
3571
3657
  const sheet = sheetRef.current;
3572
- const col = sheet == null ? void 0 : sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
3573
- const width = (col == null ? void 0 : col.width) || jt;
3658
+ const col = sheet == null ? void 0 : sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
3659
+ const width = (col == null ? void 0 : col.width) || he;
3574
3660
  const hasFilter = !!((col == null ? void 0 : col.filter) && col.filter.conditions.length > 0);
3575
3661
  const xSheetFocused = isXSheetFocused(store);
3576
3662
  const lastFocused = sheet == null ? void 0 : sheet.registry.lastFocused;
@@ -3582,7 +3668,7 @@ const HeaderCellTop = memo(({ x: x2 }) => {
3582
3668
  [choosing]
3583
3669
  );
3584
3670
  const handleResizeMouseDown = useCallback((e) => {
3585
- dispatch(setResizingPositionX([x2, e.clientX, e.clientX]));
3671
+ dispatch(setResizingPositionX([x, e.clientX, e.clientX]));
3586
3672
  e.stopPropagation();
3587
3673
  safePreventDefault(e);
3588
3674
  }, []);
@@ -3600,26 +3686,26 @@ const HeaderCellTop = memo(({ x: x2 }) => {
3600
3686
  if (editingAnywhere && editorRef.current) {
3601
3687
  editorRef.current.blur();
3602
3688
  }
3603
- dispatch(choose({ y: 1, x: x2 }));
3604
- dispatch(select({ startY: 1, startX: x2, endY: sheet.numRows, endX: x2 }));
3689
+ dispatch(choose({ y: 1, x }));
3690
+ dispatch(select({ startY: 1, startX: x, endY: sheet.numRows, endX: x }));
3605
3691
  return true;
3606
3692
  }
3607
- dispatch(select({ startY: 1, startX: x2, endY: -1, endX: x2 }));
3693
+ dispatch(select({ startY: 1, startX: x, endY: -1, endX: x }));
3608
3694
  const fullAddress = `${sheet.sheetPrefix(!xSheetFocused)}${colId}:${colId}`;
3609
3695
  if (editingAnywhere) {
3610
- const inserted = Y({ input: lastFocused || null, ref: fullAddress });
3696
+ const inserted = q({ input: lastFocused || null, ref: fullAddress });
3611
3697
  if (inserted) {
3612
- dispatch(select({ startY: sheet.numRows, startX: x2, endY: 0, endX: x2 }));
3698
+ dispatch(select({ startY: sheet.numRows, startX: x, endY: 0, endX: x }));
3613
3699
  return false;
3614
3700
  }
3615
3701
  }
3616
- let startX = e.shiftKey ? selectingZone.startX : x2;
3702
+ let startX = e.shiftKey ? selectingZone.startX : x;
3617
3703
  if (startX === -1) {
3618
3704
  startX = choosing.x;
3619
3705
  }
3620
3706
  dispatch(
3621
3707
  selectCols({
3622
- range: { start: startX, end: x2 },
3708
+ range: { start: startX, end: x },
3623
3709
  numRows: sheet.numRows
3624
3710
  })
3625
3711
  );
@@ -3628,7 +3714,7 @@ const HeaderCellTop = memo(({ x: x2 }) => {
3628
3714
  }
3629
3715
  dispatch(setEditingAddress(""));
3630
3716
  dispatch(setDragging(true));
3631
- j(editorRef.current);
3717
+ _(editorRef.current);
3632
3718
  if (autofillDraggingTo) {
3633
3719
  return false;
3634
3720
  }
@@ -3655,7 +3741,7 @@ const HeaderCellTop = memo(({ x: x2 }) => {
3655
3741
  safePreventDefault(e);
3656
3742
  dispatch(setDragging(false));
3657
3743
  if (autofillDraggingTo) {
3658
- j(editorRef.current);
3744
+ _(editorRef.current);
3659
3745
  return false;
3660
3746
  }
3661
3747
  },
@@ -3671,27 +3757,27 @@ const HeaderCellTop = memo(({ x: x2 }) => {
3671
3757
  safePreventDefault(e);
3672
3758
  e.stopPropagation();
3673
3759
  if (autofillDraggingTo) {
3674
- dispatch(setAutofillDraggingTo({ y: 1, x: x2 }));
3760
+ dispatch(setAutofillDraggingTo({ y: 1, x }));
3675
3761
  return false;
3676
3762
  }
3677
3763
  if (editingAnywhere) {
3678
- const newArea = Rs({ ...selectingZone, endY: 1, endX: x2 });
3679
- const [left, right] = [W(newArea.left), W(newArea.right)];
3764
+ const newArea = ks({ ...selectingZone, endY: 1, endX: x });
3765
+ const [left, right] = [G(newArea.left), G(newArea.right)];
3680
3766
  const fullRange = `${sheet.sheetPrefix(!xSheetFocused)}${left}:${right}`;
3681
- Y({ input: lastFocused || null, ref: fullRange });
3767
+ q({ input: lastFocused || null, ref: fullRange });
3682
3768
  }
3683
3769
  if (autofillDraggingTo == null) {
3684
3770
  const { startY } = selectingZone;
3685
3771
  if (startY === 1) {
3686
- dispatch(drag({ y: sheet.numRows, x: x2 }));
3772
+ dispatch(drag({ y: sheet.numRows, x }));
3687
3773
  } else {
3688
- dispatch(drag({ y: 1, x: x2 }));
3774
+ dispatch(drag({ y: 1, x }));
3689
3775
  }
3690
3776
  }
3691
3777
  return false;
3692
3778
  }, 100);
3693
3779
  if (!sheet) {
3694
- return /* @__PURE__ */ jsx("th", { "data-x": x2, className: "gs-th gs-th-top gs-hidden", children: /* @__PURE__ */ jsx("div", { className: "gs-th-inner-wrap", children: /* @__PURE__ */ jsxs("div", { className: "gs-th-inner", children: [
3780
+ return /* @__PURE__ */ jsx("th", { "data-x": x, className: "gs-th gs-th-top gs-hidden", children: /* @__PURE__ */ jsx("div", { className: "gs-th-inner-wrap", children: /* @__PURE__ */ jsxs("div", { className: "gs-th-inner", children: [
3695
3781
  /* @__PURE__ */ jsx(ScrollHandle, { style: { position: "absolute" }, vertical: -1 }),
3696
3782
  /* @__PURE__ */ jsx("div", { className: "gs-resizer" })
3697
3783
  ] }) }) });
@@ -3699,25 +3785,25 @@ const HeaderCellTop = memo(({ x: x2 }) => {
3699
3785
  return /* @__PURE__ */ jsx(
3700
3786
  "th",
3701
3787
  {
3702
- "data-x": x2,
3703
- className: `gs-th gs-th-top ${choosing.x === x2 ? "gs-choosing" : ""} ${Vr({ start: selectingZone.startX, end: selectingZone.endX }, x2) ? topHeaderSelecting ? "gs-th-selecting" : "gs-selecting" : ""}`,
3788
+ "data-x": x,
3789
+ className: `gs-th gs-th-top ${choosing.x === x ? "gs-choosing" : ""} ${nn({ start: selectingZone.startX, end: selectingZone.endX }, x) ? topHeaderSelecting ? "gs-th-selecting" : "gs-selecting" : ""}`,
3704
3790
  style: { ...col == null ? void 0 : col.style, width, minWidth: width, maxWidth: width },
3705
3791
  onDoubleClick: (e) => {
3706
3792
  const target = e.target;
3707
3793
  if (target.closest(".gs-resizer, .gs-menu-btn")) {
3708
3794
  return;
3709
3795
  }
3710
- if (pn.hasOperation(col == null ? void 0 : col.prevention, pn.ColumnMenu)) {
3796
+ if (Mn.hasOperation(col == null ? void 0 : col.prevention, Mn.ColumnMenu)) {
3711
3797
  return;
3712
3798
  }
3713
3799
  e.stopPropagation();
3714
3800
  const inner = e.currentTarget.querySelector(".gs-th-inner");
3715
3801
  const rect = (inner ?? e.currentTarget).getBoundingClientRect();
3716
- const alreadySelected = Vr({ start: selectingZone.startX, end: selectingZone.endX }, x2) && selectingZone.startY === 1 && selectingZone.endY === sheet.numRows;
3802
+ const alreadySelected = nn({ start: selectingZone.startX, end: selectingZone.endX }, x) && selectingZone.startY === 1 && selectingZone.endY === sheet.numRows;
3717
3803
  if (!alreadySelected) {
3718
- dispatch(selectCols({ range: { start: x2, end: x2 }, numRows: sheet.numRows }));
3804
+ dispatch(selectCols({ range: { start: x, end: x }, numRows: sheet.numRows }));
3719
3805
  }
3720
- dispatch(setColumnMenu({ x: x2, position: { y: rect.bottom, x: rect.left }, focusLabel: true }));
3806
+ dispatch(setColumnMenu({ x, position: { y: rect.bottom, x: rect.left }, focusLabel: true }));
3721
3807
  },
3722
3808
  onContextMenu: (e) => {
3723
3809
  if (contextMenu.length > 0) {
@@ -3748,7 +3834,7 @@ const HeaderCellTop = memo(({ x: x2 }) => {
3748
3834
  }
3749
3835
  ),
3750
3836
  (() => {
3751
- const displayedLabel = Rn(sheet, col == null ? void 0 : col.label, { y: 0, x: x2 }, x2) ?? colId;
3837
+ const displayedLabel = Ln(sheet, col == null ? void 0 : col.label, { y: 0, x }, x) ?? colId;
3752
3838
  if (displayedLabel !== colId) {
3753
3839
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3754
3840
  /* @__PURE__ */ jsx("span", { className: "gs-col-addr", children: colId }),
@@ -3757,10 +3843,10 @@ const HeaderCellTop = memo(({ x: x2 }) => {
3757
3843
  }
3758
3844
  return displayedLabel;
3759
3845
  })(),
3760
- !pn.hasOperation(col == null ? void 0 : col.prevention, pn.ColumnMenu) && /* @__PURE__ */ jsx(
3846
+ !Mn.hasOperation(col == null ? void 0 : col.prevention, Mn.ColumnMenu) && /* @__PURE__ */ jsx(
3761
3847
  "button",
3762
3848
  {
3763
- className: `gs-menu-btn gs-column-menu-btn ${hasFilter ? "gs-filtered" : ""} ${(columnMenuState == null ? void 0 : columnMenuState.x) === x2 ? "gs-active" : ""}`,
3849
+ className: `gs-menu-btn gs-column-menu-btn ${hasFilter ? "gs-filtered" : ""} ${(columnMenuState == null ? void 0 : columnMenuState.x) === x ? "gs-active" : ""}`,
3764
3850
  onMouseDown: (e) => {
3765
3851
  e.stopPropagation();
3766
3852
  e.preventDefault();
@@ -3777,14 +3863,14 @@ const HeaderCellTop = memo(({ x: x2 }) => {
3777
3863
  return;
3778
3864
  }
3779
3865
  const rect = btn.getBoundingClientRect();
3780
- if ((columnMenuState == null ? void 0 : columnMenuState.x) === x2) {
3866
+ if ((columnMenuState == null ? void 0 : columnMenuState.x) === x) {
3781
3867
  dispatch(setColumnMenu(null));
3782
3868
  } else {
3783
- const alreadySelected = Vr({ start: selectingZone.startX, end: selectingZone.endX }, x2) && selectingZone.startY === 1 && selectingZone.endY === sheet.numRows;
3869
+ const alreadySelected = nn({ start: selectingZone.startX, end: selectingZone.endX }, x) && selectingZone.startY === 1 && selectingZone.endY === sheet.numRows;
3784
3870
  if (!alreadySelected) {
3785
- dispatch(selectCols({ range: { start: x2, end: x2 }, numRows: sheet.numRows }));
3871
+ dispatch(selectCols({ range: { start: x, end: x }, numRows: sheet.numRows }));
3786
3872
  }
3787
- dispatch(setColumnMenu({ x: x2, position: { y: rect.bottom, x: rect.left } }));
3873
+ dispatch(setColumnMenu({ x, position: { y: rect.bottom, x: rect.left } }));
3788
3874
  }
3789
3875
  },
3790
3876
  children: "⋮"
@@ -3795,7 +3881,7 @@ const HeaderCellTop = memo(({ x: x2 }) => {
3795
3881
  {
3796
3882
  className: `
3797
3883
  gs-resizer
3798
- ${pn.hasOperation(col == null ? void 0 : col.prevention, pn.Resize) ? "gs-protected" : ""}
3884
+ ${Mn.hasOperation(col == null ? void 0 : col.prevention, Mn.Resize) ? "gs-protected" : ""}
3799
3885
  ${dragging ? "gs-hidden" : ""}`,
3800
3886
  style: { height: sheet.headerHeight },
3801
3887
  onMouseDown: handleResizeMouseDown,
@@ -3809,7 +3895,7 @@ const HeaderCellTop = memo(({ x: x2 }) => {
3809
3895
  );
3810
3896
  });
3811
3897
  const HeaderCellLeft = memo(({ y }) => {
3812
- const rowId = `${Et(y)}`;
3898
+ const rowId = `${bt(y)}`;
3813
3899
  const { store, dispatch } = useContext(Context);
3814
3900
  const {
3815
3901
  choosing,
@@ -3825,7 +3911,7 @@ const HeaderCellLeft = memo(({ y }) => {
3825
3911
  } = store;
3826
3912
  const sheet = sheetRef.current;
3827
3913
  const row = sheet == null ? void 0 : sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
3828
- const height = (row == null ? void 0 : row.height) || J;
3914
+ const height = (row == null ? void 0 : row.height) || rt;
3829
3915
  const xSheetFocused = isXSheetFocused(store);
3830
3916
  const lastFocused = sheet == null ? void 0 : sheet.registry.lastFocused;
3831
3917
  const editingAnywhere = !!((sheet == null ? void 0 : sheet.registry.editingAddress) || editingAddress);
@@ -3861,7 +3947,7 @@ const HeaderCellLeft = memo(({ y }) => {
3861
3947
  dispatch(select({ startY: y, startX: 1, endY: y, endX: -1 }));
3862
3948
  const fullAddress = `${sheet.sheetPrefix(!xSheetFocused)}${rowId}:${rowId}`;
3863
3949
  if (editingAnywhere) {
3864
- const inserted = Y({ input: lastFocused || null, ref: fullAddress });
3950
+ const inserted = q({ input: lastFocused || null, ref: fullAddress });
3865
3951
  if (inserted) {
3866
3952
  dispatch(select({ startY: y, startX: sheet.numCols, endY: y, endX: 0 }));
3867
3953
  return false;
@@ -3882,7 +3968,7 @@ const HeaderCellLeft = memo(({ y }) => {
3882
3968
  }
3883
3969
  dispatch(setEditingAddress(""));
3884
3970
  dispatch(setDragging(true));
3885
- j(editorRef.current);
3971
+ _(editorRef.current);
3886
3972
  if (autofillDraggingTo) {
3887
3973
  return false;
3888
3974
  }
@@ -3909,7 +3995,7 @@ const HeaderCellLeft = memo(({ y }) => {
3909
3995
  safePreventDefault(e);
3910
3996
  dispatch(setDragging(false));
3911
3997
  if (autofillDraggingTo) {
3912
- j(editorRef.current);
3998
+ _(editorRef.current);
3913
3999
  return false;
3914
4000
  }
3915
4001
  },
@@ -3929,10 +4015,10 @@ const HeaderCellLeft = memo(({ y }) => {
3929
4015
  return false;
3930
4016
  }
3931
4017
  if (editingAnywhere) {
3932
- const newArea = Rs({ ...selectingZone, endY: y, endX: 1 });
3933
- const [top, bottom] = [Et(newArea.top), Et(newArea.bottom)];
4018
+ const newArea = ks({ ...selectingZone, endY: y, endX: 1 });
4019
+ const [top, bottom] = [bt(newArea.top), bt(newArea.bottom)];
3934
4020
  const fullRange = `${sheet.sheetPrefix(!xSheetFocused)}${top}:${bottom}`;
3935
- Y({ input: lastFocused || null, ref: fullRange });
4021
+ q({ input: lastFocused || null, ref: fullRange });
3936
4022
  }
3937
4023
  if (autofillDraggingTo == null) {
3938
4024
  const { startX } = selectingZone;
@@ -3963,7 +4049,7 @@ const HeaderCellLeft = memo(({ y }) => {
3963
4049
  "th",
3964
4050
  {
3965
4051
  "data-y": y,
3966
- className: `gs-th gs-th-left ${choosing.y === y ? "gs-choosing" : ""} ${Vr({ start: selectingZone.startY, end: selectingZone.endY }, y) ? leftHeaderSelecting ? "gs-th-selecting" : "gs-selecting" : ""} ${(row == null ? void 0 : row.filterFixed) ? "gs-filter-fixed" : ""} ${(row == null ? void 0 : row.sortFixed) ? "gs-sort-fixed" : ""}`,
4052
+ className: `gs-th gs-th-left ${choosing.y === y ? "gs-choosing" : ""} ${nn({ start: selectingZone.startY, end: selectingZone.endY }, y) ? leftHeaderSelecting ? "gs-th-selecting" : "gs-selecting" : ""} ${(row == null ? void 0 : row.filterFixed) ? "gs-filter-fixed" : ""} ${(row == null ? void 0 : row.sortFixed) ? "gs-sort-fixed" : ""}`,
3967
4053
  style: { ...row == null ? void 0 : row.style, height },
3968
4054
  onContextMenu: handleContextMenu,
3969
4055
  children: /* @__PURE__ */ jsx(
@@ -3985,8 +4071,8 @@ const HeaderCellLeft = memo(({ y }) => {
3985
4071
  horizontal: -1
3986
4072
  }
3987
4073
  ),
3988
- Rn(sheet, row == null ? void 0 : row.label, { y, x: 0 }, y) ?? rowId,
3989
- !pn.hasOperation(row == null ? void 0 : row.prevention, pn.RowMenu) && /* @__PURE__ */ jsx(
4074
+ Ln(sheet, row == null ? void 0 : row.label, { y, x: 0 }, y) ?? rowId,
4075
+ !Mn.hasOperation(row == null ? void 0 : row.prevention, Mn.RowMenu) && /* @__PURE__ */ jsx(
3990
4076
  "button",
3991
4077
  {
3992
4078
  className: `gs-menu-btn gs-row-menu-btn ${(rowMenuState == null ? void 0 : rowMenuState.y) === y ? "gs-active" : ""}`,
@@ -4009,7 +4095,7 @@ const HeaderCellLeft = memo(({ y }) => {
4009
4095
  if ((rowMenuState == null ? void 0 : rowMenuState.y) === y) {
4010
4096
  dispatch(setRowMenu(null));
4011
4097
  } else {
4012
- const alreadySelected = Vr({ start: selectingZone.startY, end: selectingZone.endY }, y) && selectingZone.startX === 1 && selectingZone.endX === sheet.numCols;
4098
+ const alreadySelected = nn({ start: selectingZone.startY, end: selectingZone.endY }, y) && selectingZone.startX === 1 && selectingZone.endX === sheet.numCols;
4013
4099
  if (!alreadySelected) {
4014
4100
  dispatch(selectRows({ range: { start: y, end: y }, numCols: sheet.numCols }));
4015
4101
  }
@@ -4024,7 +4110,7 @@ const HeaderCellLeft = memo(({ y }) => {
4024
4110
  {
4025
4111
  className: `
4026
4112
  gs-resizer
4027
- ${pn.hasOperation(row == null ? void 0 : row.prevention, pn.Resize) ? "gs-protected" : ""}
4113
+ ${Mn.hasOperation(row == null ? void 0 : row.prevention, Mn.Resize) ? "gs-protected" : ""}
4028
4114
  ${dragging ? "gs-hidden" : ""}`,
4029
4115
  style: { width: sheet.headerWidth },
4030
4116
  onMouseDown: handleResizeMouseDown
@@ -4044,19 +4130,19 @@ const COLOR_CUTTING = "#0077ff";
4044
4130
  const SEARCH_MATCHING_BACKGROUND = "rgba(0, 200, 100, 0.2)";
4045
4131
  const COLOR_SEARCH_MATCHING = "#00aa78";
4046
4132
  const COLOR_AUTOFILL = "#0077aa";
4047
- const fillRect = (ctx, x2, y, width, height, color) => {
4133
+ const fillRect = (ctx, x, y, width, height, color) => {
4048
4134
  ctx.fillStyle = color;
4049
- ctx.fillRect(x2, y, width, height);
4135
+ ctx.fillRect(x, y, width, height);
4050
4136
  };
4051
- const drawRect = (ctx, x2, y, width, height, color, lineWidth = 2, dashPattern = [], fillColor) => {
4137
+ const drawRect = (ctx, x, y, width, height, color, lineWidth = 2, dashPattern = [], fillColor) => {
4052
4138
  if (fillColor) {
4053
4139
  ctx.fillStyle = fillColor;
4054
- ctx.fillRect(x2, y, width, height);
4140
+ ctx.fillRect(x, y, width, height);
4055
4141
  }
4056
4142
  ctx.strokeStyle = color;
4057
4143
  ctx.lineWidth = lineWidth;
4058
4144
  ctx.setLineDash(dashPattern);
4059
- ctx.strokeRect(x2 + lineWidth / 2, y + lineWidth / 2, width - lineWidth, height - lineWidth);
4145
+ ctx.strokeRect(x + lineWidth / 2, y + lineWidth / 2, width - lineWidth, height - lineWidth);
4060
4146
  ctx.setLineDash([]);
4061
4147
  };
4062
4148
  const drawAreaRectViewport = (ctx, sheet, scrollTop, scrollLeft, viewW, viewH, area, color, lineWidth = 2, dashPattern = [], fillColor) => {
@@ -4064,8 +4150,8 @@ const drawAreaRectViewport = (ctx, sheet, scrollTop, scrollLeft, viewW, viewH, a
4064
4150
  if (top === -1 || left === -1 || bottom === -1 || right === -1) {
4065
4151
  return;
4066
4152
  }
4067
- const topLeft = O(sheet, { y: top, x: left });
4068
- const bottomRight = O(sheet, { y: bottom, x: right });
4153
+ const topLeft = Q(sheet, { y: top, x: left });
4154
+ const bottomRight = Q(sheet, { y: bottom, x: right });
4069
4155
  const x1 = topLeft.left - scrollLeft;
4070
4156
  const y1 = topLeft.top - scrollTop;
4071
4157
  const x2 = bottomRight.right - scrollLeft;
@@ -4117,7 +4203,7 @@ const CellStateOverlay = ({ refs = {} }) => {
4117
4203
  ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
4118
4204
  ctx.clearRect(0, 0, w, h2);
4119
4205
  const { registry } = sheet;
4120
- const scrollTop = container.scrollTop;
4206
+ const scrollTop = W(sheet, container.scrollTop, container.clientHeight);
4121
4207
  const scrollLeft = container.scrollLeft;
4122
4208
  const headerW = sheet.headerWidth;
4123
4209
  const headerH = sheet.headerHeight;
@@ -4125,16 +4211,16 @@ const CellStateOverlay = ({ refs = {} }) => {
4125
4211
  ctx.beginPath();
4126
4212
  ctx.rect(headerW, headerH, w - headerW, h2 - headerH);
4127
4213
  ctx.clip();
4128
- const selectingArea = Rs(selectingZone);
4214
+ const selectingArea = ks(selectingZone);
4129
4215
  drawAreaRectViewport(ctx, sheet, scrollTop, scrollLeft, w, h2, selectingArea, COLOR_SELECTED, 1, [], SELECTING_FILL);
4130
4216
  if (autofillDraggingTo) {
4131
- const autofill = new En(storeRef.current, autofillDraggingTo);
4217
+ const autofill = new Hn(storeRef.current, autofillDraggingTo);
4132
4218
  drawAreaRectViewport(ctx, sheet, scrollTop, scrollLeft, w, h2, autofill.wholeArea, COLOR_AUTOFILL, 1, [5, 5]);
4133
4219
  }
4134
4220
  {
4135
- const { y, x: x2 } = choosing;
4136
- if (y !== -1 && x2 !== -1) {
4137
- const pos = O(sheet, { y, x: x2 });
4221
+ const { y, x } = choosing;
4222
+ if (y !== -1 && x !== -1) {
4223
+ const pos = Q(sheet, { y, x });
4138
4224
  const vx = pos.left - scrollLeft;
4139
4225
  const vy = pos.top - scrollTop;
4140
4226
  drawRect(ctx, vx, vy, pos.width, pos.height, COLOR_POINTED, 2, []);
@@ -4142,13 +4228,13 @@ const CellStateOverlay = ({ refs = {} }) => {
4142
4228
  }
4143
4229
  const { copyingSheetId, copyingZone, cutting } = registry;
4144
4230
  if (sheet.id === copyingSheetId) {
4145
- const copyingArea = Rs(copyingZone);
4231
+ const copyingArea = ks(copyingZone);
4146
4232
  const color = cutting ? COLOR_CUTTING : COLOR_COPYING;
4147
4233
  const dashPattern = cutting ? [4, 4] : [6, 4];
4148
4234
  drawAreaRectViewport(ctx, sheet, scrollTop, scrollLeft, w, h2, copyingArea, color, 2.5, dashPattern);
4149
4235
  }
4150
4236
  Object.entries(refs).forEach(([ref, i]) => {
4151
- const palette = _n[i % _n.length];
4237
+ const palette = Pn[i % Pn.length];
4152
4238
  try {
4153
4239
  const refArea = sheet.rangeToArea(ref);
4154
4240
  drawAreaRectViewport(ctx, sheet, scrollTop, scrollLeft, w, h2, refArea, palette, 2, [5, 5]);
@@ -4156,8 +4242,8 @@ const CellStateOverlay = ({ refs = {} }) => {
4156
4242
  }
4157
4243
  });
4158
4244
  matchingCells.forEach((address, index) => {
4159
- const { y, x: x2 } = N$1(address);
4160
- const pos = O(sheet, { y, x: x2 });
4245
+ const { y, x } = T(address);
4246
+ const pos = Q(sheet, { y, x });
4161
4247
  const vx = pos.left - scrollLeft;
4162
4248
  const vy = pos.top - scrollTop;
4163
4249
  if (vx + pos.width < 0 || vx > w || vy + pos.height < 0 || vy > h2) {
@@ -4177,23 +4263,23 @@ const CellStateOverlay = ({ refs = {} }) => {
4177
4263
  );
4178
4264
  });
4179
4265
  ctx.restore();
4180
- const numCols = sheet.numCols;
4181
- const numRows = sheet.numRows;
4182
- for (let x2 = 1; x2 <= numCols; x2++) {
4266
+ const [firstCol, lastCol] = ge(sheet, scrollLeft, w);
4267
+ const [firstRow, lastRow] = se(sheet, scrollTop, h2);
4268
+ for (let x = firstCol; x <= lastCol; x++) {
4183
4269
  let color = null;
4184
4270
  let backgroundColor = null;
4185
- if (Vr({ start: selectingZone.startX, end: selectingZone.endX }, x2)) {
4271
+ if (nn({ start: selectingZone.startX, end: selectingZone.endX }, x)) {
4186
4272
  color = "rgba(80, 180, 255, 1)";
4187
4273
  backgroundColor = topHeaderSelecting ? "rgba(128, 128, 128, 0.25)" : "rgba(0, 119, 255, 0.05)";
4188
4274
  }
4189
- if (choosing.x === x2) {
4275
+ if (choosing.x === x) {
4190
4276
  color = COLOR_POINTED;
4191
4277
  backgroundColor = topHeaderSelecting ? "rgba(128, 128, 128, 0.45)" : "rgba(0, 119, 255, 0.15)";
4192
4278
  }
4193
4279
  if (!color) {
4194
4280
  continue;
4195
4281
  }
4196
- const pos = O(sheet, { y: 1, x: x2 });
4282
+ const pos = Q(sheet, { y: 1, x });
4197
4283
  const left = pos.left - scrollLeft;
4198
4284
  if (left + pos.width < headerW || left > w) {
4199
4285
  continue;
@@ -4212,13 +4298,13 @@ const CellStateOverlay = ({ refs = {} }) => {
4212
4298
  ctx.stroke();
4213
4299
  }
4214
4300
  }
4215
- for (let y = 1; y <= numRows; y++) {
4301
+ for (let y = firstRow; y <= lastRow; y++) {
4216
4302
  if (sheet.isRowFiltered(y)) {
4217
4303
  continue;
4218
4304
  }
4219
4305
  let color = null;
4220
4306
  let backgroundColor = null;
4221
- if (Vr({ start: selectingZone.startY, end: selectingZone.endY }, y)) {
4307
+ if (nn({ start: selectingZone.startY, end: selectingZone.endY }, y)) {
4222
4308
  color = "rgba(80, 180, 255, 1)";
4223
4309
  backgroundColor = leftHeaderSelecting ? "rgba(128, 128, 128, 0.25)" : "rgba(0, 119, 255, 0.05)";
4224
4310
  }
@@ -4229,7 +4315,7 @@ const CellStateOverlay = ({ refs = {} }) => {
4229
4315
  if (!color) {
4230
4316
  continue;
4231
4317
  }
4232
- const pos = O(sheet, { y, x: 1 });
4318
+ const pos = Q(sheet, { y, x: 1 });
4233
4319
  const top = pos.top - scrollTop;
4234
4320
  if (top + pos.height < headerH || top > h2) {
4235
4321
  continue;
@@ -4318,7 +4404,7 @@ const CellStateOverlay = ({ refs = {} }) => {
4318
4404
  );
4319
4405
  };
4320
4406
  const Tabular = () => {
4321
- var _a, _b, _c, _d, _e2, _f, _g, _h, _i;
4407
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
4322
4408
  const [palette, setPalette] = useState({});
4323
4409
  const { store, dispatch } = useContext(Context);
4324
4410
  const {
@@ -4363,7 +4449,7 @@ const Tabular = () => {
4363
4449
  const handleScroll = useCallback(
4364
4450
  (e) => {
4365
4451
  if (sheet) {
4366
- setVirtualized(q(sheet, e.currentTarget));
4452
+ setVirtualized(ne(sheet, e.currentTarget));
4367
4453
  }
4368
4454
  },
4369
4455
  [sheetReactive]
@@ -4397,17 +4483,17 @@ const Tabular = () => {
4397
4483
  }
4398
4484
  const palette2 = {};
4399
4485
  const paletteBySheetName = {};
4400
- const lexer = new $t(inputting.substring(1));
4486
+ const lexer = new te(inputting.substring(1));
4401
4487
  lexer.tokenize();
4402
4488
  let i = 0;
4403
4489
  for (const token of lexer.tokens) {
4404
4490
  if (token.type === "REF" || token.type === "RANGE") {
4405
- const normalizedRef = Br(token.stringify());
4491
+ const normalizedRef = en(token.stringify());
4406
4492
  const splitterIndex = normalizedRef.indexOf("!");
4407
4493
  if (splitterIndex !== -1) {
4408
4494
  const sheetName = normalizedRef.substring(0, splitterIndex);
4409
4495
  const ref = normalizedRef.substring(splitterIndex + 1);
4410
- const stripped = on(sheetName);
4496
+ const stripped = bn(sheetName);
4411
4497
  const upperRef = ref.toUpperCase();
4412
4498
  if (paletteBySheetName[stripped] == null) {
4413
4499
  paletteBySheetName[stripped] = {};
@@ -4430,14 +4516,14 @@ const Tabular = () => {
4430
4516
  if (!sheet) {
4431
4517
  return;
4432
4518
  }
4433
- sheet.registry.choosingAddress = D(choosing);
4519
+ sheet.registry.choosingAddress = M(choosing);
4434
4520
  sheet.registry.choosingSheetId = sheet.id;
4435
4521
  }, [choosing]);
4436
4522
  useEffect(() => {
4437
4523
  if (!sheet) {
4438
4524
  return;
4439
4525
  }
4440
- setVirtualized(q(sheet, tabularRef.current));
4526
+ setVirtualized(ne(sheet, tabularRef.current));
4441
4527
  }, [
4442
4528
  tabularRef.current,
4443
4529
  sheetReactive,
@@ -4451,7 +4537,7 @@ const Tabular = () => {
4451
4537
  if (!el) {
4452
4538
  return;
4453
4539
  }
4454
- return $(el);
4540
+ return Z(el);
4455
4541
  }, [sheetReactive]);
4456
4542
  useEffect(() => {
4457
4543
  if (!sheet || !sheet.eager || !sheet.registry.ready) {
@@ -4485,7 +4571,9 @@ const Tabular = () => {
4485
4571
  className: "gs-tabular-inner",
4486
4572
  style: {
4487
4573
  width: sheet.totalWidth,
4488
- height: sheet.totalHeight,
4574
+ // Physical scroll height is capped below the browser's ~2^24px precision limit;
4575
+ // virtualize() maps this back to the sheet's full virtual height (see SCROLL_CAP).
4576
+ height: ie(sheet),
4489
4577
  overflow: "clip"
4490
4578
  },
4491
4579
  children: [
@@ -4543,7 +4631,7 @@ const Tabular = () => {
4543
4631
  style: { width: ((_c = virtualized == null ? void 0 : virtualized.adjuster) == null ? void 0 : _c.left) ?? 1 }
4544
4632
  }
4545
4633
  ),
4546
- (_e2 = (_d = virtualized == null ? void 0 : virtualized.xs) == null ? void 0 : _d.map) == null ? void 0 : _e2.call(_d, (x2) => /* @__PURE__ */ jsx(HeaderCellTop, { x: x2 }, x2)),
4634
+ (_e = (_d = virtualized == null ? void 0 : virtualized.xs) == null ? void 0 : _d.map) == null ? void 0 : _e.call(_d, (x) => /* @__PURE__ */ jsx(HeaderCellTop, { x }, x)),
4547
4635
  /* @__PURE__ */ jsx(
4548
4636
  "th",
4549
4637
  {
@@ -4561,7 +4649,7 @@ const Tabular = () => {
4561
4649
  }
4562
4650
  ),
4563
4651
  /* @__PURE__ */ jsx("td", { className: "gs-adjuster gs-adjuster-vertical" }),
4564
- (_h = virtualized == null ? void 0 : virtualized.xs) == null ? void 0 : _h.map((x2) => /* @__PURE__ */ jsx("td", { className: "gs-adjuster gs-adjuster-vertical" }, x2)),
4652
+ (_h = virtualized == null ? void 0 : virtualized.xs) == null ? void 0 : _h.map((x) => /* @__PURE__ */ jsx("td", { className: "gs-adjuster gs-adjuster-vertical" }, x)),
4565
4653
  /* @__PURE__ */ jsx("th", { className: `gs-adjuster gs-adjuster-horizontal gs-adjuster-vertical` })
4566
4654
  ] }) }),
4567
4655
  /* @__PURE__ */ jsx("tbody", { className: "gs-sheet-body-data", children: (_i = virtualized == null ? void 0 : virtualized.ys) == null ? void 0 : _i.map((y) => {
@@ -4569,7 +4657,7 @@ const Tabular = () => {
4569
4657
  return /* @__PURE__ */ jsxs("tr", { className: `gs-row ${y % 2 === 0 ? "gs-row-even" : "gs-row-odd"}`, children: [
4570
4658
  /* @__PURE__ */ jsx(HeaderCellLeft, { y }),
4571
4659
  /* @__PURE__ */ jsx("td", { className: "gs-adjuster gs-adjuster-horizontal gs-adjuster-horizontal-left" }),
4572
- (_a2 = virtualized == null ? void 0 : virtualized.xs) == null ? void 0 : _a2.map((x2) => /* @__PURE__ */ jsx(Cell, { y, x: x2 }, x2)),
4660
+ (_a2 = virtualized == null ? void 0 : virtualized.xs) == null ? void 0 : _a2.map((x) => /* @__PURE__ */ jsx(Cell, { y, x }, x)),
4573
4661
  /* @__PURE__ */ jsx("td", { className: "gs-adjuster gs-adjuster-horizontal gs-adjuster-horizontal-right" })
4574
4662
  ] }, y);
4575
4663
  }) })
@@ -4598,11 +4686,11 @@ const FormulaBar = ({ ready }) => {
4598
4686
  } = store;
4599
4687
  const sheet = sheetRef.current;
4600
4688
  const hlRef = useRef(null);
4601
- const address = choosing.x === -1 ? "" : D(choosing);
4689
+ const address = choosing.x === -1 ? "" : M(choosing);
4602
4690
  const cell = sheet == null ? void 0 : sheet.getCell(choosing, { resolution: "SYSTEM" });
4603
4691
  const spilledFromAddress = (_a = sheet == null ? void 0 : sheet.getSystem(choosing)) == null ? void 0 : _a.spilledFrom;
4604
- const originPoint = spilledFromAddress ? N$1(spilledFromAddress) : void 0;
4605
- const originAddress = originPoint != null ? D(originPoint) : void 0;
4692
+ const originPoint = spilledFromAddress ? T(spilledFromAddress) : void 0;
4693
+ const originAddress = originPoint != null ? M(originPoint) : void 0;
4606
4694
  useEffect(() => {
4607
4695
  var _a2;
4608
4696
  if (!sheet) {
@@ -4619,7 +4707,7 @@ const FormulaBar = ({ ready }) => {
4619
4707
  dispatch(write({ value }));
4620
4708
  }
4621
4709
  dispatch(setEditingAddress(""));
4622
- j(editorRef.current);
4710
+ _(editorRef.current);
4623
4711
  },
4624
4712
  [before]
4625
4713
  );
@@ -4711,7 +4799,7 @@ const FormulaBar = ({ ready }) => {
4711
4799
  dispatch(setInputting(newValue));
4712
4800
  setTimeout(() => {
4713
4801
  if (largeEditorRef.current) {
4714
- j(largeEditorRef.current);
4802
+ _(largeEditorRef.current);
4715
4803
  largeEditorRef.current.setSelectionRange(newCursor, newCursor);
4716
4804
  }
4717
4805
  }, 0);
@@ -4742,7 +4830,7 @@ const FormulaBar = ({ ready }) => {
4742
4830
  dispatch(setInputting(newValue));
4743
4831
  setTimeout(() => {
4744
4832
  if (largeEditorRef.current) {
4745
- j(largeEditorRef.current);
4833
+ _(largeEditorRef.current);
4746
4834
  largeEditorRef.current.setSelectionRange(newCursor, newCursor);
4747
4835
  }
4748
4836
  }, 0);
@@ -4751,7 +4839,7 @@ const FormulaBar = ({ ready }) => {
4751
4839
  }
4752
4840
  }
4753
4841
  if (e.altKey) {
4754
- v(input, "\n");
4842
+ R(input, "\n");
4755
4843
  } else {
4756
4844
  writeCell(input.value);
4757
4845
  dispatch(setInputting(""));
@@ -4773,7 +4861,7 @@ const FormulaBar = ({ ready }) => {
4773
4861
  dispatch(setInputting(before));
4774
4862
  dispatch(setEditingAddress(""));
4775
4863
  e.preventDefault();
4776
- j(editorRef.current);
4864
+ _(editorRef.current);
4777
4865
  break;
4778
4866
  }
4779
4867
  case "a":
@@ -4792,7 +4880,7 @@ const FormulaBar = ({ ready }) => {
4792
4880
  break;
4793
4881
  }
4794
4882
  const cell2 = sheet.getCell(choosing, { resolution: "SYSTEM" });
4795
- if (pn.hasOperation(cell2 == null ? void 0 : cell2.prevention, pn.Write)) {
4883
+ if (Mn.hasOperation(cell2 == null ? void 0 : cell2.prevention, Mn.Write)) {
4796
4884
  console.warn("This cell is protected from writing.");
4797
4885
  e.preventDefault();
4798
4886
  }
@@ -4825,7 +4913,7 @@ const FormulaBar = ({ ready }) => {
4825
4913
  dispatch(setInputting(newValue));
4826
4914
  setTimeout(() => {
4827
4915
  if (largeEditorRef.current) {
4828
- j(largeEditorRef.current);
4916
+ _(largeEditorRef.current);
4829
4917
  largeEditorRef.current.setSelectionRange(newCursor, newCursor);
4830
4918
  }
4831
4919
  }, 0);
@@ -5000,15 +5088,15 @@ const SearchBar = () => {
5000
5088
  if (!matchingCell || !sheet) {
5001
5089
  return;
5002
5090
  }
5003
- const point = N$1(matchingCell);
5091
+ const point = T(matchingCell);
5004
5092
  if (typeof point === "undefined") {
5005
5093
  return;
5006
5094
  }
5007
- G(sheet, tabularRef.current, point);
5095
+ de(sheet, tabularRef.current, point);
5008
5096
  }, [searchQuery, matchingCellIndex, searchCaseSensitive, searchRegex, sheet, tabularRef]);
5009
5097
  const handleProgressClick = useCallback((e) => {
5010
5098
  const input = e.currentTarget.previousSibling;
5011
- (input == null ? void 0 : input.nodeName) === "INPUT" && j(input);
5099
+ (input == null ? void 0 : input.nodeName) === "INPUT" && _(input);
5012
5100
  }, []);
5013
5101
  const handleSearchClick = useCallback(() => {
5014
5102
  dispatch(search(1));
@@ -5021,7 +5109,7 @@ const SearchBar = () => {
5021
5109
  if (e.key === "Escape") {
5022
5110
  const el = editorRef == null ? void 0 : editorRef.current;
5023
5111
  if (el) {
5024
- j(el);
5112
+ _(el);
5025
5113
  }
5026
5114
  dispatch(setSearchQuery(void 0));
5027
5115
  }
@@ -5048,7 +5136,7 @@ const SearchBar = () => {
5048
5136
  if (!selectingZone) {
5049
5137
  return false;
5050
5138
  }
5051
- if (rn(selectingZone)) {
5139
+ if (wn(selectingZone)) {
5052
5140
  return false;
5053
5141
  }
5054
5142
  const { startY, startX, endY, endX } = selectingZone;
@@ -5059,8 +5147,8 @@ const SearchBar = () => {
5059
5147
  return "";
5060
5148
  }
5061
5149
  const { startY, startX, endY, endX } = selectingZone;
5062
- const topLeft = `${W(Math.min(startX, endX))}${Et(Math.min(startY, endY))}`;
5063
- const bottomRight = `${W(Math.max(startX, endX))}${Et(Math.max(startY, endY))}`;
5150
+ const topLeft = `${G(Math.min(startX, endX))}${bt(Math.min(startY, endY))}`;
5151
+ const bottomRight = `${G(Math.max(startX, endX))}${bt(Math.max(startY, endY))}`;
5064
5152
  return `${topLeft}:${bottomRight}`;
5065
5153
  }, [selectingZone, hasSelection]);
5066
5154
  const handleRangeClick = useCallback(() => {
@@ -5083,13 +5171,13 @@ const SearchBar = () => {
5083
5171
  return "";
5084
5172
  }
5085
5173
  const { startY, startX, endY, endX } = searchRange;
5086
- const topLeft = `${W(startX)}${Et(startY)}`;
5087
- const bottomRight = `${W(endX)}${Et(endY)}`;
5174
+ const topLeft = `${G(startX)}${bt(startY)}`;
5175
+ const bottomRight = `${G(endX)}${bt(endY)}`;
5088
5176
  return `${topLeft}:${bottomRight}`;
5089
5177
  }, [searchRange]);
5090
5178
  const handleCloseClick = useCallback(() => {
5091
5179
  dispatch(setSearchQuery(void 0));
5092
- j(editorRef.current);
5180
+ _(editorRef.current);
5093
5181
  }, [editorRef]);
5094
5182
  if (typeof searchQuery === "undefined") {
5095
5183
  return null;
@@ -5172,7 +5260,8 @@ function GridSheet({
5172
5260
  options = {},
5173
5261
  className,
5174
5262
  style,
5175
- book: initialBook
5263
+ book: initialBook,
5264
+ loading: loadingProp
5176
5265
  }) {
5177
5266
  var _a, _b, _c;
5178
5267
  const {
@@ -5184,16 +5273,16 @@ function GridSheet({
5184
5273
  formulaBarBorders = { all: true },
5185
5274
  matrixBorders = { all: true }
5186
5275
  } = options;
5187
- const bw = (b, side) => b[side] ?? b.all ?? false ? "1px" : "0";
5276
+ const bw2 = (b, side) => b[side] ?? b.all ?? false ? "1px" : "0";
5188
5277
  const borderVars = {
5189
- "--gs-fb-bl": bw(formulaBarBorders, "left"),
5190
- "--gs-fb-bt": bw(formulaBarBorders, "top"),
5191
- "--gs-fb-br": bw(formulaBarBorders, "right"),
5192
- "--gs-fb-bb": bw(formulaBarBorders, "bottom"),
5193
- "--gs-mx-bl": bw(matrixBorders, "left"),
5194
- "--gs-mx-bt": bw(matrixBorders, "top"),
5195
- "--gs-mx-br": bw(matrixBorders, "right"),
5196
- "--gs-mx-bb": bw(matrixBorders, "bottom")
5278
+ "--gs-fb-bl": bw2(formulaBarBorders, "left"),
5279
+ "--gs-fb-bt": bw2(formulaBarBorders, "top"),
5280
+ "--gs-fb-br": bw2(formulaBarBorders, "right"),
5281
+ "--gs-fb-bb": bw2(formulaBarBorders, "bottom"),
5282
+ "--gs-mx-bl": bw2(matrixBorders, "left"),
5283
+ "--gs-mx-bt": bw2(matrixBorders, "top"),
5284
+ "--gs-mx-br": bw2(matrixBorders, "right"),
5285
+ "--gs-mx-bb": bw2(matrixBorders, "bottom")
5197
5286
  };
5198
5287
  const rootRef = useRef(null);
5199
5288
  const flashRef = useRef(null);
@@ -5226,7 +5315,7 @@ function GridSheet({
5226
5315
  console.debug("GridSheet: sheetName is not provided, using default name:", sheetName);
5227
5316
  }
5228
5317
  const { limits, contextMenu, rowMenu, colMenu, eager } = options;
5229
- const sheet = new $$1({
5318
+ const sheet = new Y({
5230
5319
  limits,
5231
5320
  name: sheetName,
5232
5321
  registry,
@@ -5276,7 +5365,8 @@ function GridSheet({
5276
5365
  columnMenuState: null,
5277
5366
  rowMenuState: null,
5278
5367
  editorHovering: true,
5279
- mode: "light"
5368
+ mode: "light",
5369
+ pendingAsyncOp: null
5280
5370
  };
5281
5371
  return store2;
5282
5372
  });
@@ -5286,7 +5376,7 @@ function GridSheet({
5286
5376
  () => initialState
5287
5377
  );
5288
5378
  useEffect(() => {
5289
- re();
5379
+ me();
5290
5380
  }, []);
5291
5381
  const fillWidth = typeof options.sheetWidth === "string";
5292
5382
  const fillHeight = typeof options.sheetHeight === "string";
@@ -5340,24 +5430,74 @@ function GridSheet({
5340
5430
  }
5341
5431
  }, [options.sheetWidth]);
5342
5432
  const [loading, setLoading] = useState(false);
5343
- useEffect(() => {
5344
- if (loading) {
5345
- setLoading(false);
5346
- }
5347
- });
5433
+ const latestStoreRef = useRef(store);
5434
+ latestStoreRef.current = store;
5348
5435
  const wrappedDispatch = useCallback(
5349
5436
  (action) => {
5350
- if (!isMutationAction(action.type)) {
5437
+ const async = isAsyncMutationAction(action.type);
5438
+ const mutating = isMutationAction(action.type);
5439
+ if (latestStoreRef.current.pendingAsyncOp != null && (async || mutating)) {
5440
+ return;
5441
+ }
5442
+ if (async) {
5351
5443
  dispatch(action);
5352
5444
  return;
5353
5445
  }
5354
- setLoading(true);
5355
- requestAnimationFrame(() => {
5446
+ if (!mutating) {
5356
5447
  dispatch(action);
5357
- });
5448
+ return;
5449
+ }
5450
+ setLoading(true);
5451
+ requestAnimationFrame(
5452
+ () => requestAnimationFrame(() => {
5453
+ dispatch(action);
5454
+ setLoading(false);
5455
+ })
5456
+ );
5358
5457
  },
5359
5458
  [dispatch]
5360
5459
  );
5460
+ const overlayRef = useRef(null);
5461
+ const pendingAsyncOp = store.pendingAsyncOp;
5462
+ useEffect(() => {
5463
+ if (pendingAsyncOp == null) {
5464
+ return;
5465
+ }
5466
+ let cancelled = false;
5467
+ const raf = requestAnimationFrame(
5468
+ () => requestAnimationFrame(async () => {
5469
+ var _a2;
5470
+ if (cancelled) {
5471
+ return;
5472
+ }
5473
+ try {
5474
+ const nextSheet = await pendingAsyncOp.run((ratio) => {
5475
+ var _a3;
5476
+ (_a3 = overlayRef.current) == null ? void 0 : _a3.setProgress(ratio);
5477
+ });
5478
+ if (!cancelled) {
5479
+ dispatch(
5480
+ commitAsyncOp({
5481
+ sheet: nextSheet,
5482
+ selectingZone: pendingAsyncOp.selectingZone,
5483
+ finalize: pendingAsyncOp.finalize
5484
+ })
5485
+ );
5486
+ (_a2 = pendingAsyncOp.postCommit) == null ? void 0 : _a2.call(pendingAsyncOp);
5487
+ }
5488
+ } catch (e) {
5489
+ console.error("[gridsheet] async op failed:", e);
5490
+ if (!cancelled) {
5491
+ dispatch(commitAsyncOp({ sheet: latestStoreRef.current.sheetReactive.current, selectingZone: pendingAsyncOp.selectingZone }));
5492
+ }
5493
+ }
5494
+ })
5495
+ );
5496
+ return () => {
5497
+ cancelled = true;
5498
+ cancelAnimationFrame(raf);
5499
+ };
5500
+ }, [pendingAsyncOp, dispatch]);
5361
5501
  return /* @__PURE__ */ jsx(Context.Provider, { value: { store, dispatch: wrappedDispatch }, children: /* @__PURE__ */ jsxs(
5362
5502
  "div",
5363
5503
  {
@@ -5414,7 +5554,22 @@ function GridSheet({
5414
5554
  /* @__PURE__ */ jsx(RowMenu, {}),
5415
5555
  /* @__PURE__ */ jsx(Resizer, {}),
5416
5556
  /* @__PURE__ */ jsx(Emitter, {}),
5417
- loading && /* @__PURE__ */ jsx("div", { className: "gs-loading-overlay", children: /* @__PURE__ */ jsx("div", { className: "gs-loading-spinner" }) })
5557
+ store.pendingAsyncOp != null ? (
5558
+ // Chunked async mutation (large fill/paste): imperative progress, grid not re-rendered.
5559
+ /* @__PURE__ */ jsx(AsyncProgressOverlay, { ref: overlayRef, label: store.pendingAsyncOp.label })
5560
+ ) : loading ? (
5561
+ // Internal sync mutation in flight: brief indeterminate spinner.
5562
+ /* @__PURE__ */ jsx("div", { className: "gs-loading-overlay", children: /* @__PURE__ */ jsx("div", { className: "gs-loading-spinner" }) })
5563
+ ) : loadingProp ? (
5564
+ // Consumer-driven initial loading (data not ready yet).
5565
+ /* @__PURE__ */ jsx(
5566
+ ProgressOverlay,
5567
+ {
5568
+ progress: typeof loadingProp === "object" ? loadingProp.progress ?? null : null,
5569
+ label: typeof loadingProp === "object" ? loadingProp.label : void 0
5570
+ }
5571
+ )
5572
+ ) : null
5418
5573
  ]
5419
5574
  }
5420
5575
  )
@@ -5423,28 +5578,28 @@ function GridSheet({
5423
5578
  ) });
5424
5579
  }
5425
5580
  const estimateSheetHeight = (initialCells) => {
5426
- var _a, _b, _c, _d, _e2;
5427
- const auto = Cs(initialCells);
5428
- let estimatedHeight = ((_a = initialCells[0]) == null ? void 0 : _a.height) ?? Re;
5581
+ var _a, _b, _c, _d, _e;
5582
+ const auto = Hs(initialCells);
5583
+ let estimatedHeight = ((_a = initialCells[0]) == null ? void 0 : _a.height) ?? $e;
5429
5584
  for (let y = 1; y <= auto.numRows; y++) {
5430
- const row = Et(y);
5431
- const height = ((_b = initialCells == null ? void 0 : initialCells[row]) == null ? void 0 : _b.height) || ((_c = initialCells == null ? void 0 : initialCells["0" + row]) == null ? void 0 : _c.height) || ((_d = initialCells == null ? void 0 : initialCells[vt]) == null ? void 0 : _d.height) || ((_e2 = initialCells == null ? void 0 : initialCells.default) == null ? void 0 : _e2.height) || J;
5432
- if (estimatedHeight + height > Dr) {
5433
- return Dr;
5585
+ const row = bt(y);
5586
+ const height = ((_b = initialCells == null ? void 0 : initialCells[row]) == null ? void 0 : _b.height) || ((_c = initialCells == null ? void 0 : initialCells["0" + row]) == null ? void 0 : _c.height) || ((_d = initialCells == null ? void 0 : initialCells[$t]) == null ? void 0 : _d.height) || ((_e = initialCells == null ? void 0 : initialCells.default) == null ? void 0 : _e.height) || rt;
5587
+ if (estimatedHeight + height > jr) {
5588
+ return jr;
5434
5589
  }
5435
5590
  estimatedHeight += height;
5436
5591
  }
5437
5592
  return estimatedHeight + 3;
5438
5593
  };
5439
5594
  const estimateSheetWidth = (initialCells) => {
5440
- var _a, _b, _c, _d, _e2;
5441
- const auto = Cs(initialCells);
5442
- let estimatedWidth = ((_a = initialCells[0]) == null ? void 0 : _a.width) ?? _e;
5443
- for (let x2 = 1; x2 <= auto.numCols; x2++) {
5444
- const col = W(x2);
5445
- const width = ((_b = initialCells == null ? void 0 : initialCells[col]) == null ? void 0 : _b.width) || ((_c = initialCells == null ? void 0 : initialCells[col + "0"]) == null ? void 0 : _c.width) || ((_d = initialCells == null ? void 0 : initialCells[Dt]) == null ? void 0 : _d.width) || ((_e2 = initialCells == null ? void 0 : initialCells.default) == null ? void 0 : _e2.width) || jt;
5446
- if (estimatedWidth + width > vr) {
5447
- return vr;
5595
+ var _a, _b, _c, _d, _e;
5596
+ const auto = Hs(initialCells);
5597
+ let estimatedWidth = ((_a = initialCells[0]) == null ? void 0 : _a.width) ?? Le;
5598
+ for (let x = 1; x <= auto.numCols; x++) {
5599
+ const col = G(x);
5600
+ const width = ((_b = initialCells == null ? void 0 : initialCells[col]) == null ? void 0 : _b.width) || ((_c = initialCells == null ? void 0 : initialCells[col + "0"]) == null ? void 0 : _c.width) || ((_d = initialCells == null ? void 0 : initialCells[kt]) == null ? void 0 : _d.width) || ((_e = initialCells == null ? void 0 : initialCells.default) == null ? void 0 : _e.width) || he;
5601
+ if (estimatedWidth + width > Gr) {
5602
+ return Gr;
5448
5603
  }
5449
5604
  estimatedWidth += width;
5450
5605
  }
@@ -5485,96 +5640,99 @@ function makeBorder(options) {
5485
5640
  return result;
5486
5641
  }
5487
5642
  export {
5488
- b8 as BaseFunction,
5489
- b9 as BaseFunctionAsync,
5643
+ bi as BaseFunction,
5644
+ bj as BaseFunctionAsync,
5490
5645
  CheckboxPolicyMixin,
5491
5646
  Children,
5492
5647
  Component,
5493
- bq as DEFAULT_HISTORY_LIMIT,
5494
- x as FormulaError,
5495
- ba as FormulaParser,
5648
+ bA as DEFAULT_HISTORY_LIMIT,
5649
+ S as FormulaError,
5650
+ bk as FormulaParser,
5496
5651
  Fragment2 as Fragment,
5497
5652
  GridSheet,
5498
- $t as Lexer,
5653
+ te as Lexer,
5499
5654
  MenuDivider,
5500
5655
  MenuItem,
5501
- k as Pending,
5502
- bp as PercentagePolicyMixin,
5656
+ L as Pending,
5657
+ bz as PercentagePolicyMixin,
5503
5658
  PluginBase,
5504
- bn as Policy,
5659
+ bx as Policy,
5660
+ ProgressOverlay,
5505
5661
  PureComponent,
5506
- bd as RangeEntity,
5507
- bb as RefEntity,
5508
- aZ as Registry,
5509
- $$1 as Sheet,
5510
- br as Spilling,
5662
+ bn2 as RangeEntity,
5663
+ bl as RefEntity,
5664
+ b6 as Registry,
5665
+ Y as Sheet,
5666
+ bB as Spilling,
5511
5667
  StrictMode,
5512
5668
  Suspense,
5513
5669
  SuspenseList,
5514
- bo as ThousandSeparatorPolicyMixin,
5515
- aU as Time,
5516
- bc as ValueEntity,
5517
- N$1 as a2p,
5518
- aN as aa2oa,
5519
- aR as addressesToAreas,
5520
- aS as addressesToCols,
5521
- aT as addressesToRows,
5670
+ by as ThousandSeparatorPolicyMixin,
5671
+ b1 as Time,
5672
+ bm as ValueEntity,
5673
+ T as a2p,
5674
+ aW as aa2oa,
5675
+ a_ as addressesToAreas,
5676
+ a$ as addressesToCols,
5677
+ b0 as addressesToRows,
5522
5678
  applyers,
5523
- zr as areaToRange,
5524
- Ee as areaToZone,
5525
- aO as buildInitialCells,
5526
- aP as buildInitialCellsFromOrigin,
5527
- aV as c2x,
5528
- aY as ch,
5529
- bi as check,
5679
+ rn as areaToRange,
5680
+ Pe as areaToZone,
5681
+ aX as buildInitialCells,
5682
+ aY as buildInitialCellsFromOrigin,
5683
+ b2 as c2x,
5684
+ b5 as ch,
5685
+ bs as check,
5530
5686
  clip,
5531
5687
  cloneElement,
5532
5688
  render2 as compatRender,
5533
- bl as conditionArg,
5534
- a_ as createBook,
5535
- bk as createBooleanMask,
5689
+ bv as conditionArg,
5690
+ b7 as createBook,
5691
+ bu as createBooleanMask,
5536
5692
  createContext2 as createContext,
5537
5693
  createElement,
5538
5694
  createFactory,
5539
5695
  createPortal2 as createPortal,
5540
5696
  createRef2 as createRef,
5541
- a$ as createRegistry,
5697
+ b8 as createRegistry,
5542
5698
  createSheetRef,
5543
5699
  createStoreRef,
5544
5700
  defaultColMenuDescriptors,
5545
5701
  defaultContextMenuDescriptors,
5546
5702
  defaultRowMenuDescriptors,
5547
- bj as eachMatrix,
5548
- bg as ensureBoolean,
5549
- bh as ensureDate,
5550
- bf as ensureNumber,
5551
- be as ensureString,
5703
+ bt2 as eachMatrix,
5704
+ me as embedStyle,
5705
+ bq as ensureBoolean,
5706
+ br as ensureDate,
5707
+ bp as ensureNumber,
5708
+ bo as ensureString,
5552
5709
  findDOMNode,
5553
- forwardRef,
5710
+ forwardRef2 as forwardRef,
5554
5711
  h,
5555
5712
  hydrate,
5556
5713
  isValidElement,
5557
5714
  lazy,
5558
5715
  makeBorder,
5559
- aQ as matrixShape,
5716
+ aZ as matrixShape,
5560
5717
  memo2 as memo,
5561
- aM as oa2aa,
5562
- pn as operations,
5563
- D as p2a,
5564
- aW as r2y,
5718
+ aV as oa2aa,
5719
+ Mn as operations,
5720
+ M as p2a,
5721
+ b3 as r2y,
5565
5722
  registerMenuComponent,
5566
5723
  render,
5567
- aX as rh,
5724
+ b4 as rh,
5568
5725
  sheet2csv,
5569
- bm as stripMatrix,
5570
- b7 as toCellCols,
5571
- b4 as toCellMatrix,
5572
- b5 as toCellObject,
5573
- b6 as toCellRows,
5574
- b3 as toValueCols,
5575
- b0 as toValueMatrix,
5576
- b1 as toValueObject,
5577
- b2 as toValueRows,
5726
+ bw as stripMatrix,
5727
+ bh as toCellCols,
5728
+ be2 as toCellMatrix,
5729
+ bf as toCellObject,
5730
+ bg as toCellRows,
5731
+ bd as toValueCols,
5732
+ b9 as toValueMatrix,
5733
+ ba as toValueMatrixAsync,
5734
+ bb as toValueObject,
5735
+ bc as toValueRows,
5578
5736
  unmountComponentAtNode,
5579
5737
  unstable_batchedUpdates,
5580
5738
  updateSheet,
@@ -5583,7 +5741,7 @@ export {
5583
5741
  useContext2 as useContext,
5584
5742
  useDebugValue,
5585
5743
  useEffect2 as useEffect,
5586
- useImperativeHandle,
5744
+ useImperativeHandle2 as useImperativeHandle,
5587
5745
  useInitialPluginContext,
5588
5746
  useLayoutEffect2 as useLayoutEffect,
5589
5747
  useMemo2 as useMemo,
@@ -5593,10 +5751,10 @@ export {
5593
5751
  useSheetRef,
5594
5752
  useState2 as useState,
5595
5753
  useStoreRef,
5596
- bs as userActions,
5754
+ bC as userActions,
5597
5755
  version,
5598
- W as x2c,
5599
- Et as y2r,
5600
- Rs as zoneToArea
5756
+ G as x2c,
5757
+ bt as y2r,
5758
+ ks as zoneToArea
5601
5759
  };
5602
5760
  //# sourceMappingURL=index.js.map