@gridsheet/preact-core 3.1.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,11 +1,9 @@
1
1
  import { h, render } from "preact";
2
- import { calcSideStyle, clampPopup, clampLeft, zoneToArea, focus, Lexer, getFunctionHelps, expandInput, y2r, x2c, resetInput, handleFormulaQuoteAutoClose, areaToZone, insertTextAtCursor, operations, isRefInsertable, COLOR_PALETTE, DEFAULT_WIDTH, DEFAULT_HEIGHT, between, makeSequence, p2a, MIN_HEIGHT, MIN_WIDTH, zoneShape, getLabel, FormulaError, Pending, insertRef, areaToRange, calcBelowPosition, hAlignTransform, among, getAreaInTabular, isFocus, Autofill, getCellRectPositions, a2p, virtualize, stripAddressAbsolute, stripSheetName, preventSafariBounce, smartScroll, isZoneNotSelected, Sheet, embedStyle, getMaxSizesFromCells, HEADER_HEIGHT, DEFAULT_ROW_KEY, SHEET_HEIGHT, HEADER_WIDTH, DEFAULT_COL_KEY, SHEET_WIDTH } from "@gridsheet/core";
3
- import { BaseFunction, BaseFunctionAsync, DEFAULT_HISTORY_LIMIT, FormulaError as FormulaError2, FormulaParser, Lexer as Lexer2, Pending as Pending2, PercentagePolicyMixin, Policy, RangeEntity, RefEntity, Registry, Sheet as Sheet2, Spilling, ThousandSeparatorPolicyMixin, Time, ValueEntity, a2p as a2p2, aa2oa, addressesToAreas, addressesToCols, addressesToRows, areaToRange as areaToRange2, areaToZone as areaToZone2, buildInitialCells, buildInitialCellsFromOrigin, c2x, ch, check, conditionArg, createBook, createBooleanMask, createRegistry, eachMatrix, ensureBoolean, ensureDate, ensureNumber, ensureString, matrixShape, oa2aa, operations as operations2, p2a as p2a2, r2y, rh, stripMatrix, toCellCols, toCellMatrix, toCellObject, toCellRows, toValueCols, toValueMatrix, toValueObject, toValueRows, x2c as x2c2, y2r as y2r2, zoneToArea as zoneToArea2 } from "@gridsheet/core";
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
4
  import { jsxs, jsx, Fragment } from "preact/compat/jsx-runtime";
5
5
  import React, { createContext, useRef, useContext, useLayoutEffect, useState, useMemo, useCallback, createPortal, memo, useEffect, createRef, useReducer } from "preact/compat";
6
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";
7
- import { u as useBrowser, s as setEditingAddress, w as write, a as setInputting, b as updateSheet, r as redo, c as undo, d as cut, e as setSearchQuery, f as setEntering, g as copy, h as select, i as arrow, j as escape, k as clear, l as walk, p as paste, m as setEditorHovering, n as setStore, o as setResizingPositionY, q as setResizingPositionX, t as filterRows, v as sortRows, x as removeCols, y as removeRows, z as insertColsRight, A as insertColsLeft, B as insertRowsBelow, C as insertRowsAbove, D as setContextMenuPosition, E as setColumnMenu, F as setRowMenu, G as isXSheetFocused, H as setEditorRect, I as choose, J as drag, K as setDragging, L as submitAutofill, M as setAutofillDraggingTo, N as selectCols, O as useDebounceCallback, P as selectRows, Q as search, R as setSearchCaseSensitive, S as setSearchRegex, T as setSearchRange, U as useBook, V as reducer, W as isMutationAction } from "./hooks-ykrgAwg5.mjs";
8
- import { X } from "./hooks-ykrgAwg5.mjs";
9
7
  const Context = createContext(
10
8
  {}
11
9
  );
@@ -25,14 +23,14 @@ const FunctionGuide = ({
25
23
  if (!el) {
26
24
  return;
27
25
  }
28
- calcSideStyle(el);
26
+ Z(el);
29
27
  });
30
28
  useLayoutEffect(() => {
31
29
  const el = ref.current;
32
30
  if (!el || left === void 0) {
33
31
  return;
34
32
  }
35
- clampPopup(el);
33
+ ee(el);
36
34
  });
37
35
  if (option) {
38
36
  return /* @__PURE__ */ jsxs(
@@ -50,7 +48,7 @@ const FunctionGuide = ({
50
48
  option.isFunction && /* @__PURE__ */ jsxs(Fragment, { children: [
51
49
  /* @__PURE__ */ jsx("div", { className: "gs-fn-guide1-example", children: option.example }),
52
50
  option.description && /* @__PURE__ */ jsx("div", { className: "gs-fn-guide1-desc", style: { whiteSpace: "pre-line" }, children: option.description }),
53
- option.defs && option.defs.length > 0 && /* @__PURE__ */ jsx("div", { className: "gs-fn-guide1-args", children: option.defs.map((arg, j) => {
51
+ option.defs && option.defs.length > 0 && /* @__PURE__ */ jsx("div", { className: "gs-fn-guide1-args", children: option.defs.map((arg, j2) => {
54
52
  var _a;
55
53
  return /* @__PURE__ */ jsxs("div", { className: "gs-fn-guide1-arg", children: [
56
54
  /* @__PURE__ */ jsx("span", { className: "gs-fn-guide1-arg-name", children: arg.name }),
@@ -61,7 +59,7 @@ const FunctionGuide = ({
61
59
  " — ",
62
60
  arg.description
63
61
  ] })
64
- ] }, j);
62
+ ] }, j2);
65
63
  }) })
66
64
  ] })
67
65
  ]
@@ -82,25 +80,25 @@ const FunctionGuide = ({
82
80
  const args = activeFunctionGuide.defs ?? [];
83
81
  const numIterable = args.filter((a) => a.variadic).length;
84
82
  const variadicStart = args.length - numIterable;
85
- return args.map((arg, j) => {
83
+ return args.map((arg, j2) => {
86
84
  let isActive;
87
85
  if (activeArgIndex < variadicStart) {
88
- isActive = activeArgIndex === j;
89
- } else if (numIterable > 0 && j >= variadicStart) {
86
+ isActive = activeArgIndex === j2;
87
+ } else if (numIterable > 0 && j2 >= variadicStart) {
90
88
  const offset = (activeArgIndex - variadicStart) % numIterable;
91
- isActive = j === variadicStart + offset;
89
+ isActive = j2 === variadicStart + offset;
92
90
  } else {
93
91
  isActive = false;
94
92
  }
95
93
  return /* @__PURE__ */ jsxs(React.Fragment, { children: [
96
- j > 0 ? ", " : "",
94
+ j2 > 0 ? ", " : "",
97
95
  /* @__PURE__ */ jsxs("span", { className: isActive ? "gs-active-arg" : "", children: [
98
96
  arg.optional ? "[" : "",
99
97
  arg.name,
100
98
  arg.variadic ? ", ..." : "",
101
99
  arg.optional ? "]" : ""
102
100
  ] })
103
- ] }, j);
101
+ ] }, j2);
104
102
  });
105
103
  })() }),
106
104
  (() => {
@@ -150,7 +148,7 @@ const EditorOptions = ({
150
148
  return;
151
149
  }
152
150
  const width = ulRef.current.getBoundingClientRect().width;
153
- setAdjustedLeft(clampLeft(left, width));
151
+ setAdjustedLeft(K(left, width));
154
152
  }, [left, filteredOptions]);
155
153
  if (filteredOptions.length === 0) {
156
154
  return null;
@@ -177,11 +175,11 @@ const clip = (store) => {
177
175
  if (!sheet) {
178
176
  return { top: 0, left: 0, bottom: 0, right: 0 };
179
177
  }
180
- const { y, x } = choosing;
181
- const selectingArea = zoneToArea(selectingZone);
178
+ const { y, x: x2 } = choosing;
179
+ const selectingArea = Rs(selectingZone);
182
180
  let area = selectingArea;
183
181
  if (area.left === -1) {
184
- area = { top: y, left: x, bottom: y, right: x };
182
+ area = { top: y, left: x2, bottom: y, right: x2 };
185
183
  }
186
184
  const input = editorRef.current;
187
185
  const trimmed = sheet.trim(area);
@@ -208,7 +206,7 @@ const clip = (store) => {
208
206
  ]);
209
207
  } else if (input != null) {
210
208
  input.value = tsv;
211
- focus(input);
209
+ j(input);
212
210
  input.select();
213
211
  document.execCommand("copy");
214
212
  input.value = "";
@@ -233,8 +231,8 @@ const sheet2csv = (sheet, {
233
231
  }
234
232
  const cols = [];
235
233
  let rowIsEmpty = true;
236
- for (let x = sheet.left; x <= sheet.right; x++) {
237
- const point = { y, x };
234
+ for (let x2 = sheet.left; x2 <= sheet.right; x2++) {
235
+ const point = { y, x: x2 };
238
236
  const value = getter(sheet, point);
239
237
  if (value !== "") {
240
238
  rowIsEmpty = false;
@@ -269,8 +267,8 @@ const sheet2html = (sheet, {
269
267
  }
270
268
  const cols = [];
271
269
  let rowIsEmpty = true;
272
- for (let x = sheet.left; x <= sheet.right; x++) {
273
- const point = { y, x };
270
+ for (let x2 = sheet.left; x2 <= sheet.right; x2++) {
271
+ const point = { y, x: x2 };
274
272
  const value = getter(sheet, point);
275
273
  if (value !== "") {
276
274
  rowIsEmpty = false;
@@ -299,7 +297,7 @@ const useAutocomplete = ({ inputting, selectionStart, optionsAll, functions }) =
299
297
  if (isFormula && textBeforeCursor.length > 1) {
300
298
  try {
301
299
  const textToCursor = textBeforeCursor.slice(1);
302
- const lexer = new Lexer(textToCursor);
300
+ const lexer = new $t(textToCursor);
303
301
  lexer.tokenize();
304
302
  const functionStack = [];
305
303
  for (let i = 0; i < lexer.tokens.length; i++) {
@@ -326,7 +324,7 @@ const useAutocomplete = ({ inputting, selectionStart, optionsAll, functions }) =
326
324
  }
327
325
  if (functionStack.length > 0) {
328
326
  const activeItem = functionStack[functionStack.length - 1];
329
- const helps = getFunctionHelps(functions);
327
+ const helps = yn(functions);
330
328
  activeArgIndex2 = activeItem.argIndex;
331
329
  activeFunctionHelp2 = helps.find((h2) => h2.name === activeItem.name.toUpperCase()) || null;
332
330
  }
@@ -341,7 +339,7 @@ const useAutocomplete = ({ inputting, selectionStart, optionsAll, functions }) =
341
339
  let isOnAddress = false;
342
340
  if (isFormula) {
343
341
  try {
344
- const fullLexer = new Lexer(inputting.slice(1));
342
+ const fullLexer = new $t(inputting.slice(1));
345
343
  fullLexer.tokenize();
346
344
  let currentIndex = 1;
347
345
  for (const token of fullLexer.tokens) {
@@ -367,7 +365,7 @@ const useAutocomplete = ({ inputting, selectionStart, optionsAll, functions }) =
367
365
  }
368
366
  if (isFormula && !isOnAddress) {
369
367
  if (currentWord.length > 0 && !hasOpenParenAssigned) {
370
- filtered = getFunctionHelps(functions).map((help) => {
368
+ filtered = yn(functions).map((help) => {
371
369
  const keywordLower = help.name.toLowerCase();
372
370
  const startsWith = keywordLower.startsWith(currentWord);
373
371
  const index = startsWith ? 0 : -1;
@@ -517,7 +515,7 @@ const parseHTML = (html, onlyValue = false) => {
517
515
  }
518
516
  const cells = Array.from(row.querySelectorAll("td, th"));
519
517
  const result = [];
520
- let j = 0;
518
+ let j2 = 0;
521
519
  for (const cell of cells) {
522
520
  const value = ((_b = cell.textContent) == null ? void 0 : _b.trim()) ?? "";
523
521
  const style = onlyValue ? void 0 : (() => {
@@ -525,7 +523,7 @@ const parseHTML = (html, onlyValue = false) => {
525
523
  const parentStyle = parseStyleString(cell);
526
524
  return { ...parentStyle, ...childStyle };
527
525
  })();
528
- while (spans.has(`${i}-${++j}`)) {
526
+ while (spans.has(`${i}-${++j2}`)) {
529
527
  result.push({ value: "", style, skip: true });
530
528
  }
531
529
  result.push({ value, style });
@@ -533,7 +531,7 @@ const parseHTML = (html, onlyValue = false) => {
533
531
  const colSpan = parseInt(cell.getAttribute("colspan") ?? "1", 10);
534
532
  for (let r = 0; r < rowSpan; r++) {
535
533
  for (let c = 0; c < colSpan; c++) {
536
- spans.add(`${i + r}-${j + c}`);
534
+ spans.add(`${i + r}-${j2 + c}`);
537
535
  }
538
536
  }
539
537
  }
@@ -599,7 +597,7 @@ function parseStyleString(element) {
599
597
  if (rawKey === "height" || rawKey === "width") {
600
598
  return;
601
599
  }
602
- const key = rawKey.trim().replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
600
+ const key = rawKey.trim().replace(/-([a-z])/g, (_2, letter) => letter.toUpperCase());
603
601
  if (key === "float" || key === "display" || key.startsWith("padding")) {
604
602
  return;
605
603
  }
@@ -754,7 +752,10 @@ const Editor = ({ mode }) => {
754
752
  }
755
753
  const { bottom: top2, left: left2 } = rect;
756
754
  return createPortal(
757
- /* @__PURE__ */ jsxs(Fragment, { children: [
755
+ // Portaled to <body>, outside .gs-root1 / .gs-editor, so carry data-mode
756
+ // here too — otherwise the theme-specific styles (e.g. the dark function
757
+ // guide) never match and the help renders with the light palette.
758
+ /* @__PURE__ */ jsxs("div", { className: "gs-editor-portal", "data-mode": mode, children: [
758
759
  activeFunctionHelp && filteredOptions.length === 0 && (!selectingZone || selectingZone.endY === -1 && selectingZone.endX === -1) && /* @__PURE__ */ jsx(
759
760
  FunctionGuide,
760
761
  {
@@ -799,7 +800,7 @@ const Editor = ({ mode }) => {
799
800
  functions: sheet == null ? void 0 : sheet.registry.functions
800
801
  });
801
802
  useEffect(() => {
802
- focus(editorRef == null ? void 0 : editorRef.current);
803
+ j(editorRef == null ? void 0 : editorRef.current);
803
804
  }, [editorRef]);
804
805
  useEffect(() => {
805
806
  if (!sheet) {
@@ -824,14 +825,14 @@ const Editor = ({ mode }) => {
824
825
  sheet.registry.editingAddress = editingAddress;
825
826
  }, [editingAddress, sheet, sheetId]);
826
827
  useEffect(() => {
827
- expandInput(editorRef.current);
828
+ N(editorRef.current);
828
829
  }, [inputting, editingAddress, editorRef]);
829
- const { y, x } = choosing;
830
- const rowId = `${y2r(y)}`;
831
- const colId = x2c(x);
830
+ const { y, x: x2 } = choosing;
831
+ const rowId = `${Et(y)}`;
832
+ const colId = W(x2);
832
833
  const address = `${colId}${rowId}`;
833
834
  const editing = editingAddress === address;
834
- const cell = sheet == null ? void 0 : sheet.getCell({ y, x }, { resolution: "RAW" });
835
+ const cell = sheet == null ? void 0 : sheet.getCell({ y, x: x2 }, { resolution: "RAW" });
835
836
  const currentString = sheet ? sheet.getSerializedValue({ point: choosing, cell, resolution: "RAW" }) : "";
836
837
  const [before, setBefore] = useState(currentString);
837
838
  const writeCell = useCallback(
@@ -855,7 +856,7 @@ const Editor = ({ mode }) => {
855
856
  dispatch(setInputting(newValue));
856
857
  setTimeout(() => {
857
858
  if (editorRef.current) {
858
- focus(editorRef.current);
859
+ j(editorRef.current);
859
860
  editorRef.current.setSelectionRange(newCursor, newCursor);
860
861
  }
861
862
  }, 0);
@@ -879,14 +880,14 @@ const Editor = ({ mode }) => {
879
880
  }
880
881
  setBefore(currentString);
881
882
  dispatch(setInputting(currentString));
882
- resetInput(editorRef.current, sheet, choosing);
883
+ _(editorRef.current, sheet, choosing);
883
884
  }, [choosing, currentString, dispatch, editorRef, sheet]);
884
885
  const { y: top, x: left, height, width } = editorRect;
885
886
  const numLines = currentString.split("\n").length;
886
887
  const [isKeyDown, setIsKeyDown] = useState(false);
887
888
  const handleKeyDown = useCallback(
888
889
  (e) => {
889
- var _a2, _b2, _c, _d, _e, _f;
890
+ var _a2, _b2, _c, _d, _e2, _f;
890
891
  if (!sheet) {
891
892
  return;
892
893
  }
@@ -903,7 +904,7 @@ const Editor = ({ mode }) => {
903
904
  });
904
905
  }
905
906
  const input = e.currentTarget;
906
- if (handleFormulaQuoteAutoClose(e, inputting)) {
907
+ if (V(e, inputting)) {
907
908
  dispatch(setInputting(input.value));
908
909
  return false;
909
910
  }
@@ -944,7 +945,7 @@ const Editor = ({ mode }) => {
944
945
  return false;
945
946
  }
946
947
  } else if (e.altKey) {
947
- insertTextAtCursor(input, "\n");
948
+ v(input, "\n");
948
949
  dispatch(setInputting(input.value));
949
950
  e.preventDefault();
950
951
  return false;
@@ -975,7 +976,7 @@ const Editor = ({ mode }) => {
975
976
  return false;
976
977
  case "Backspace":
977
978
  if (!editing) {
978
- if (((_c = sheet.getSystem({ y, x })) == null ? void 0 : _c.spilledFrom) != null) {
979
+ if (((_c = sheet.getSystem({ y, x: x2 })) == null ? void 0 : _c.spilledFrom) != null) {
979
980
  e.preventDefault();
980
981
  return false;
981
982
  }
@@ -986,7 +987,7 @@ const Editor = ({ mode }) => {
986
987
  break;
987
988
  case "Delete":
988
989
  if (!editing) {
989
- if (((_d = sheet.getSystem({ y, x })) == null ? void 0 : _d.spilledFrom) != null) {
990
+ if (((_d = sheet.getSystem({ y, x: x2 })) == null ? void 0 : _d.spilledFrom) != null) {
990
991
  e.preventDefault();
991
992
  return false;
992
993
  }
@@ -1094,8 +1095,8 @@ const Editor = ({ mode }) => {
1094
1095
  if (!editing) {
1095
1096
  e.preventDefault();
1096
1097
  const area = clip(store);
1097
- dispatch(copy(areaToZone(area)));
1098
- focus(input);
1098
+ dispatch(copy(Ee(area)));
1099
+ j(input);
1099
1100
  return false;
1100
1101
  }
1101
1102
  return true;
@@ -1109,7 +1110,7 @@ const Editor = ({ mode }) => {
1109
1110
  dispatch(setSearchQuery(""));
1110
1111
  }
1111
1112
  dispatch(setEntering(false));
1112
- requestAnimationFrame(() => focus(searchInputRef.current));
1113
+ requestAnimationFrame(() => j(searchInputRef.current));
1113
1114
  return false;
1114
1115
  }
1115
1116
  }
@@ -1130,7 +1131,7 @@ const Editor = ({ mode }) => {
1130
1131
  if (e.ctrlKey || e.metaKey) {
1131
1132
  if (!editing) {
1132
1133
  e.preventDefault();
1133
- (_f = (_e = sheet.registry).onSave) == null ? void 0 : _f.call(_e, {
1134
+ (_f = (_e2 = sheet.registry).onSave) == null ? void 0 : _f.call(_e2, {
1134
1135
  sheet,
1135
1136
  points: {
1136
1137
  pointing: choosing,
@@ -1159,8 +1160,8 @@ const Editor = ({ mode }) => {
1159
1160
  if (!editing) {
1160
1161
  e.preventDefault();
1161
1162
  const area = clip(store);
1162
- dispatch(cut(areaToZone(area)));
1163
- focus(input);
1163
+ dispatch(cut(Ee(area)));
1164
+ j(input);
1164
1165
  return false;
1165
1166
  }
1166
1167
  }
@@ -1190,7 +1191,7 @@ const Editor = ({ mode }) => {
1190
1191
  if (e.ctrlKey || e.metaKey) {
1191
1192
  return false;
1192
1193
  }
1193
- if (operations.hasOperation(cell == null ? void 0 : cell.prevention, operations.Write)) {
1194
+ if (pn.hasOperation(cell == null ? void 0 : cell.prevention, pn.Write)) {
1194
1195
  console.warn("This cell is protected from writing.");
1195
1196
  return false;
1196
1197
  }
@@ -1231,7 +1232,7 @@ const Editor = ({ mode }) => {
1231
1232
  );
1232
1233
  const handleDoubleClick = useCallback(
1233
1234
  (e) => {
1234
- if (operations.hasOperation(cell == null ? void 0 : cell.prevention, operations.Write)) {
1235
+ if (pn.hasOperation(cell == null ? void 0 : cell.prevention, pn.Write)) {
1235
1236
  console.warn("This cell is protected from writing.");
1236
1237
  return;
1237
1238
  }
@@ -1252,7 +1253,7 @@ const Editor = ({ mode }) => {
1252
1253
  const handleBlur = useCallback(
1253
1254
  (e) => {
1254
1255
  setIsFocused(false);
1255
- if (isRefInsertable(e.currentTarget)) {
1256
+ if (X(e.currentTarget)) {
1256
1257
  return true;
1257
1258
  } else {
1258
1259
  if (editing) {
@@ -1265,7 +1266,7 @@ const Editor = ({ mode }) => {
1265
1266
  );
1266
1267
  const handleChange = useCallback(
1267
1268
  (e) => {
1268
- if (operations.hasOperation(cell == null ? void 0 : cell.prevention, operations.Write)) {
1269
+ if (pn.hasOperation(cell == null ? void 0 : cell.prevention, pn.Write)) {
1269
1270
  return;
1270
1271
  }
1271
1272
  dispatch(setInputting(e.currentTarget.value));
@@ -1302,7 +1303,7 @@ const Editor = ({ mode }) => {
1302
1303
  (e) => {
1303
1304
  var _a2, _b2;
1304
1305
  setShiftKey(false);
1305
- const selectingArea = zoneToArea(store.selectingZone);
1306
+ const selectingArea = Rs(store.selectingZone);
1306
1307
  (_b2 = sheet == null ? void 0 : (_a2 = sheet.registry).onKeyUp) == null ? void 0 : _b2.call(_a2, {
1307
1308
  e,
1308
1309
  points: {
@@ -1408,7 +1409,7 @@ const editorStyle = (text) => {
1408
1409
  if (text[0] !== "=") {
1409
1410
  return /* @__PURE__ */ jsx(Fragment, { children: text });
1410
1411
  }
1411
- const lexer = new Lexer(text.substring(1));
1412
+ const lexer = new $t(text.substring(1));
1412
1413
  lexer.tokenize();
1413
1414
  let palletIndex = 0;
1414
1415
  const exists = {};
@@ -1431,12 +1432,12 @@ const editorStyle = (text) => {
1431
1432
  {
1432
1433
  token,
1433
1434
  tokenKey,
1434
- color: COLOR_PALETTE[existsIndex % COLOR_PALETTE.length]
1435
+ color: _n[existsIndex % _n.length]
1435
1436
  },
1436
1437
  tokenKey
1437
1438
  );
1438
1439
  }
1439
- const color = COLOR_PALETTE[palletIndex % COLOR_PALETTE.length];
1440
+ const color = _n[palletIndex % _n.length];
1440
1441
  exists[normalizedToken] = palletIndex++;
1441
1442
  return /* @__PURE__ */ jsx(
1442
1443
  TokenSpan,
@@ -1491,6 +1492,8 @@ const StoreObserver = ({
1491
1492
  sheetName,
1492
1493
  sheetHeight,
1493
1494
  sheetWidth,
1495
+ fixedWidth,
1496
+ fixedHeight,
1494
1497
  sheetRef,
1495
1498
  storeRef,
1496
1499
  editingOnEnter,
@@ -1499,6 +1502,116 @@ const StoreObserver = ({
1499
1502
  const { store, dispatch } = useContext(Context);
1500
1503
  const { sheetReactive } = store;
1501
1504
  const sheet = sheetReactive.current;
1505
+ const dragRef = useRef({ store, dispatch });
1506
+ dragRef.current = { store, dispatch };
1507
+ useEffect(() => {
1508
+ let raf = 0;
1509
+ let running = false;
1510
+ let dead = false;
1511
+ let cx = 0;
1512
+ let cy = 0;
1513
+ let lastCell = "";
1514
+ let lastExtend = 0;
1515
+ const EDGE = 0;
1516
+ const SPEED = 18;
1517
+ const stop = () => {
1518
+ running = false;
1519
+ cancelAnimationFrame(raf);
1520
+ };
1521
+ const finish = () => {
1522
+ if (dead) {
1523
+ return;
1524
+ }
1525
+ dead = true;
1526
+ stop();
1527
+ const { store: s, dispatch: d } = dragRef.current;
1528
+ if (s.autofillDraggingTo) {
1529
+ d(submitAutofill(s.autofillDraggingTo));
1530
+ }
1531
+ if (s.dragging) {
1532
+ d(setDragging(false));
1533
+ }
1534
+ };
1535
+ const tick = () => {
1536
+ var _a, _b;
1537
+ if (dead || !running) {
1538
+ return;
1539
+ }
1540
+ const { store: s, dispatch: d } = dragRef.current;
1541
+ const el = (_a = s.tabularRef) == null ? void 0 : _a.current;
1542
+ if (!el || !(s.dragging || s.autofillDraggingTo)) {
1543
+ running = false;
1544
+ return;
1545
+ }
1546
+ const r = el.getBoundingClientRect();
1547
+ const dy = cy > r.bottom - EDGE ? SPEED : cy < r.top + EDGE ? -18 : 0;
1548
+ const dx = cx > r.right - EDGE ? SPEED : cx < r.left + EDGE ? -18 : 0;
1549
+ if (dy || dx) {
1550
+ el.scrollTop += dy;
1551
+ el.scrollLeft += dx;
1552
+ const px = Math.min(Math.max(cx, r.left + 1), r.right - 1);
1553
+ const py = Math.min(Math.max(cy, r.top + 1), r.bottom - 1);
1554
+ const cell = (_b = document.elementFromPoint(px, py)) == null ? void 0 : _b.closest(".gs-cell");
1555
+ if (cell) {
1556
+ const y = Number(cell.dataset.y);
1557
+ const x2 = Number(cell.dataset.x);
1558
+ const key = y + ":" + x2;
1559
+ const now = performance.now();
1560
+ if (!Number.isNaN(y) && !Number.isNaN(x2) && key !== lastCell && now - lastExtend > 80) {
1561
+ lastCell = key;
1562
+ lastExtend = now;
1563
+ d(s.autofillDraggingTo ? setAutofillDraggingTo({ x: x2, y }) : drag({ y, x: x2 }));
1564
+ }
1565
+ }
1566
+ }
1567
+ raf = requestAnimationFrame(tick);
1568
+ };
1569
+ const onMove = (e) => {
1570
+ if (e.buttons === 0) {
1571
+ const { store: s2 } = dragRef.current;
1572
+ if (!dead && (running || s2.autofillDraggingTo != null || s2.dragging)) {
1573
+ finish();
1574
+ }
1575
+ return;
1576
+ }
1577
+ cx = e.clientX;
1578
+ cy = e.clientY;
1579
+ const { store: s } = dragRef.current;
1580
+ if (!dead && !running && (s.dragging || s.autofillDraggingTo)) {
1581
+ running = true;
1582
+ lastCell = "";
1583
+ raf = requestAnimationFrame(tick);
1584
+ }
1585
+ };
1586
+ const onDown = () => {
1587
+ dead = false;
1588
+ };
1589
+ const onUp = () => {
1590
+ dead = true;
1591
+ stop();
1592
+ const { store: s, dispatch: d } = dragRef.current;
1593
+ if (s.autofillDraggingTo) {
1594
+ d(submitAutofill(s.autofillDraggingTo));
1595
+ }
1596
+ if (s.dragging) {
1597
+ d(setDragging(false));
1598
+ }
1599
+ };
1600
+ const onLeaveWindow = () => finish();
1601
+ window.addEventListener("mousedown", onDown, true);
1602
+ window.addEventListener("mousemove", onMove, true);
1603
+ window.addEventListener("mouseup", onUp, true);
1604
+ window.addEventListener("blur", onLeaveWindow);
1605
+ document.addEventListener("mouseleave", onLeaveWindow);
1606
+ return () => {
1607
+ window.removeEventListener("mousedown", onDown, true);
1608
+ window.removeEventListener("mousemove", onMove, true);
1609
+ window.removeEventListener("mouseup", onUp, true);
1610
+ window.removeEventListener("blur", onLeaveWindow);
1611
+ document.removeEventListener("mouseleave", onLeaveWindow);
1612
+ cancelAnimationFrame(raf);
1613
+ };
1614
+ }, []);
1502
1615
  useEffect(() => {
1503
1616
  if (!sheet) {
1504
1617
  return;
@@ -1546,6 +1659,9 @@ const StoreObserver = ({
1546
1659
  dispatch(setStore({ sheetWidth }));
1547
1660
  }
1548
1661
  }, [sheetWidth]);
1662
+ useEffect(() => {
1663
+ dispatch(setStore({ fixedWidth: !!fixedWidth, fixedHeight: !!fixedHeight }));
1664
+ }, [fixedWidth, fixedHeight]);
1549
1665
  useEffect(() => {
1550
1666
  if (typeof editingOnEnter !== "undefined") {
1551
1667
  dispatch(setStore({ editingOnEnter }));
@@ -1580,36 +1696,36 @@ const Resizer = () => {
1580
1696
  } = store;
1581
1697
  const sheet = sheetRef.current;
1582
1698
  const [y, startY, endY] = posY;
1583
- const [x, startX, endX] = posX;
1699
+ const [x2, startX, endX] = posX;
1584
1700
  if (mainRef.current == null || editorRef.current == null || !sheet) {
1585
1701
  return /* @__PURE__ */ jsx("div", { className: "gs-resizing gs-hidden" });
1586
1702
  }
1587
- const cell = sheet.getCell({ y: y === -1 ? 0 : y, x: x === -1 ? 0 : x }, { resolution: "SYSTEM" });
1703
+ const cell = sheet.getCell({ y: y === -1 ? 0 : y, x: x2 === -1 ? 0 : x2 }, { resolution: "SYSTEM" });
1588
1704
  const { y: offsetY, x: offsetX } = mainRef.current.getBoundingClientRect();
1589
- const baseWidth = (cell == null ? void 0 : cell.width) || DEFAULT_WIDTH;
1590
- const baseHeight = (cell == null ? void 0 : cell.height) || DEFAULT_HEIGHT;
1705
+ const baseWidth = (cell == null ? void 0 : cell.width) || jt;
1706
+ const baseHeight = (cell == null ? void 0 : cell.height) || J;
1591
1707
  const width = baseWidth + (endX - startX);
1592
1708
  const height = baseHeight + (endY - startY);
1593
1709
  const handleResizeEnd = () => {
1594
- const selectingArea = zoneToArea(selectingZone);
1710
+ const selectingArea = Rs(selectingZone);
1595
1711
  const { top, left, bottom, right } = selectingArea;
1596
1712
  const diff = {};
1597
- if (x !== -1) {
1598
- let xs = [x];
1599
- if (topHeaderSelecting && between({ start: left, end: right }, x)) {
1600
- xs = makeSequence(left, right + 1);
1713
+ if (x2 !== -1) {
1714
+ let xs = [x2];
1715
+ if (topHeaderSelecting && Vr({ start: left, end: right }, x2)) {
1716
+ xs = jr(left, right + 1);
1601
1717
  }
1602
- xs.forEach((x2) => {
1603
- diff[p2a({ y: 0, x: x2 })] = { width };
1718
+ xs.forEach((x22) => {
1719
+ diff[D({ y: 0, x: x22 })] = { width };
1604
1720
  });
1605
1721
  }
1606
1722
  if (y !== -1) {
1607
1723
  let ys = [y];
1608
- if (leftHeaderSelecting && between({ start: top, end: bottom }, y)) {
1609
- ys = makeSequence(top, bottom + 1);
1724
+ if (leftHeaderSelecting && Vr({ start: top, end: bottom }, y)) {
1725
+ ys = jr(top, bottom + 1);
1610
1726
  }
1611
1727
  ys.forEach((y2) => {
1612
- diff[p2a({ y: y2, x: 0 })] = { height };
1728
+ diff[D({ y: y2, x: 0 })] = { height };
1613
1729
  });
1614
1730
  }
1615
1731
  sheet.update({
@@ -1625,33 +1741,33 @@ const Resizer = () => {
1625
1741
  );
1626
1742
  dispatch(setResizingPositionY([-1, -1, -1]));
1627
1743
  dispatch(setResizingPositionX([-1, -1, -1]));
1628
- focus(editorRef.current);
1744
+ j(editorRef.current);
1629
1745
  };
1630
1746
  const handleResizeMove = (e) => {
1631
1747
  if (y !== -1) {
1632
1748
  let endY2 = e.clientY;
1633
1749
  const height2 = baseHeight + (endY2 - startY);
1634
- if (height2 < MIN_HEIGHT) {
1635
- endY2 += MIN_HEIGHT - height2;
1750
+ if (height2 < Pr) {
1751
+ endY2 += Pr - height2;
1636
1752
  }
1637
1753
  dispatch(setResizingPositionY([y, startY, endY2]));
1638
- } else if (x !== -1) {
1754
+ } else if (x2 !== -1) {
1639
1755
  let endX2 = e.clientX;
1640
1756
  const width2 = baseWidth + (endX2 - startX);
1641
- if (width2 < MIN_WIDTH) {
1642
- endX2 += MIN_WIDTH - width2;
1757
+ if (width2 < kr) {
1758
+ endX2 += kr - width2;
1643
1759
  }
1644
- dispatch(setResizingPositionX([x, startX, endX2]));
1760
+ dispatch(setResizingPositionX([x2, startX, endX2]));
1645
1761
  }
1646
1762
  };
1647
1763
  return /* @__PURE__ */ jsxs(
1648
1764
  "div",
1649
1765
  {
1650
- className: `gs-resizing ${y === -1 && x === -1 ? "gs-hidden" : ""}`,
1766
+ className: `gs-resizing ${y === -1 && x2 === -1 ? "gs-hidden" : ""}`,
1651
1767
  onMouseUp: handleResizeEnd,
1652
1768
  onMouseMove: handleResizeMove,
1653
1769
  children: [
1654
- /* @__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: [
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: [
1655
1771
  width,
1656
1772
  "px"
1657
1773
  ] }) }) }),
@@ -1696,14 +1812,14 @@ const Emitter = () => {
1696
1812
  const copier = async ({ store, dispatch }) => {
1697
1813
  const { editorRef } = store;
1698
1814
  const area = clip(store);
1699
- dispatch(copy(areaToZone(area)));
1700
- focus(editorRef.current);
1815
+ dispatch(copy(Ee(area)));
1816
+ j(editorRef.current);
1701
1817
  };
1702
1818
  const cutter = async ({ store, dispatch }) => {
1703
1819
  const { editorRef } = store;
1704
1820
  const area = clip(store);
1705
- dispatch(cut(areaToZone(area)));
1706
- focus(editorRef.current);
1821
+ dispatch(cut(Ee(area)));
1822
+ j(editorRef.current);
1707
1823
  };
1708
1824
  const paster = async ({ store, dispatch }, onlyValue = false) => {
1709
1825
  const { editorRef } = store;
@@ -1728,118 +1844,118 @@ const paster = async ({ store, dispatch }, onlyValue = false) => {
1728
1844
  }
1729
1845
  }
1730
1846
  dispatch(paste({ matrix: cells, onlyValue }));
1731
- focus(editorRef.current);
1847
+ j(editorRef.current);
1732
1848
  };
1733
1849
  const undoer = async ({ store, dispatch }) => {
1734
1850
  const { editorRef } = store;
1735
1851
  dispatch(undo(null));
1736
- focus(editorRef.current);
1852
+ j(editorRef.current);
1737
1853
  };
1738
1854
  const redoer = async ({ store, dispatch }) => {
1739
1855
  const { editorRef } = store;
1740
1856
  dispatch(redo(null));
1741
- focus(editorRef.current);
1857
+ j(editorRef.current);
1742
1858
  };
1743
1859
  const rowsInserterAbove = async ({ store, dispatch }) => {
1744
1860
  const { selectingZone, editorRef } = store;
1745
- const { top } = zoneToArea(selectingZone);
1746
- const numRows = zoneShape(selectingZone).rows;
1861
+ const { top } = Rs(selectingZone);
1862
+ const numRows = Xr(selectingZone).rows;
1747
1863
  dispatch(insertRowsAbove({ numRows, y: top, operator: "USER" }));
1748
- focus(editorRef.current);
1864
+ j(editorRef.current);
1749
1865
  };
1750
1866
  const rowsInserterBelow = async ({ store, dispatch }) => {
1751
1867
  const { selectingZone, editorRef } = store;
1752
- const { bottom } = zoneToArea(selectingZone);
1753
- const numRows = zoneShape(selectingZone).rows;
1868
+ const { bottom } = Rs(selectingZone);
1869
+ const numRows = Xr(selectingZone).rows;
1754
1870
  dispatch(insertRowsBelow({ numRows, y: bottom, operator: "USER" }));
1755
- focus(editorRef.current);
1871
+ j(editorRef.current);
1756
1872
  };
1757
1873
  const colsInserterLeft = async ({ store, dispatch }) => {
1758
1874
  const { selectingZone, editorRef } = store;
1759
- const { left } = zoneToArea(selectingZone);
1760
- const numCols = zoneShape(selectingZone).cols;
1875
+ const { left } = Rs(selectingZone);
1876
+ const numCols = Xr(selectingZone).cols;
1761
1877
  dispatch(insertColsLeft({ numCols, x: left, operator: "USER" }));
1762
- focus(editorRef.current);
1878
+ j(editorRef.current);
1763
1879
  };
1764
1880
  const colsInserterRight = async ({ store, dispatch }) => {
1765
1881
  const { selectingZone, editorRef } = store;
1766
- const { right } = zoneToArea(selectingZone);
1767
- const numCols = zoneShape(selectingZone).cols;
1882
+ const { right } = Rs(selectingZone);
1883
+ const numCols = Xr(selectingZone).cols;
1768
1884
  dispatch(insertColsRight({ numCols, x: right, operator: "USER" }));
1769
- focus(editorRef.current);
1885
+ j(editorRef.current);
1770
1886
  };
1771
1887
  const rowsRemover = async ({ store, dispatch }) => {
1772
1888
  const { selectingZone, editorRef } = store;
1773
- const { top } = zoneToArea(selectingZone);
1774
- const numRows = zoneShape(selectingZone).rows;
1889
+ const { top } = Rs(selectingZone);
1890
+ const numRows = Xr(selectingZone).rows;
1775
1891
  dispatch(removeRows({ numRows, y: top, operator: "USER" }));
1776
- focus(editorRef.current);
1892
+ j(editorRef.current);
1777
1893
  };
1778
1894
  const colsRemover = async ({ store, dispatch }) => {
1779
1895
  const { selectingZone, editorRef } = store;
1780
- const { left } = zoneToArea(selectingZone);
1781
- const numCols = zoneShape(selectingZone).cols;
1896
+ const { left } = Rs(selectingZone);
1897
+ const numCols = Xr(selectingZone).cols;
1782
1898
  dispatch(removeCols({ numCols, x: left, operator: "USER" }));
1783
- focus(editorRef.current);
1899
+ j(editorRef.current);
1784
1900
  };
1785
- const rowsSorterAsc = async ({ store, dispatch }, x) => {
1901
+ const rowsSorterAsc = async ({ store, dispatch }, x2) => {
1786
1902
  const sheet = store.sheetReactive.current;
1787
1903
  if (sheet && (sheet.hasPendingCells() || sheet.registry.asyncPending.size > 0)) {
1788
1904
  await sheet.waitForPending();
1789
1905
  }
1790
- dispatch(sortRows({ x, direction: "asc" }));
1791
- focus(store.editorRef.current);
1906
+ dispatch(sortRows({ x: x2, direction: "asc" }));
1907
+ j(store.editorRef.current);
1792
1908
  };
1793
- const rowsSorterDesc = async ({ store, dispatch }, x) => {
1909
+ const rowsSorterDesc = async ({ store, dispatch }, x2) => {
1794
1910
  const sheet = store.sheetReactive.current;
1795
1911
  if (sheet && (sheet.hasPendingCells() || sheet.registry.asyncPending.size > 0)) {
1796
1912
  await sheet.waitForPending();
1797
1913
  }
1798
- dispatch(sortRows({ x, direction: "desc" }));
1799
- focus(store.editorRef.current);
1914
+ dispatch(sortRows({ x: x2, direction: "desc" }));
1915
+ j(store.editorRef.current);
1800
1916
  };
1801
- const rowsFilterer = async ({ store, dispatch }, x, filter) => {
1917
+ const rowsFilterer = async ({ store, dispatch }, x2, filter) => {
1802
1918
  const sheet = store.sheetReactive.current;
1803
1919
  if (sheet && (sheet.hasPendingCells() || sheet.registry.asyncPending.size > 0)) {
1804
1920
  await sheet.waitForPending();
1805
1921
  }
1806
- dispatch(filterRows({ x, filter }));
1807
- focus(store.editorRef.current);
1922
+ dispatch(filterRows({ x: x2, filter }));
1923
+ j(store.editorRef.current);
1808
1924
  };
1809
- const rowsFilterClearer = async ({ store, dispatch }, x) => {
1810
- dispatch(filterRows({ x }));
1811
- focus(store.editorRef.current);
1925
+ const rowsFilterClearer = async ({ store, dispatch }, x2) => {
1926
+ dispatch(filterRows({ x: x2 }));
1927
+ j(store.editorRef.current);
1812
1928
  };
1813
1929
  const rowSortFixedToggler = ({ store, dispatch }, y) => {
1814
1930
  const sheet = store.sheetReactive.current;
1815
1931
  if (!sheet) {
1816
1932
  return;
1817
1933
  }
1818
- const addr = p2a({ y, x: 0 });
1934
+ const addr = D({ y, x: 0 });
1819
1935
  const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
1820
1936
  const next = !(rowCell == null ? void 0 : rowCell.sortFixed) || void 0;
1821
1937
  sheet.update({ diff: { [addr]: { sortFixed: next } }, partial: true });
1822
1938
  dispatch(updateSheet(sheet));
1823
- focus(store.editorRef.current);
1939
+ j(store.editorRef.current);
1824
1940
  };
1825
1941
  const rowFilterFixedToggler = ({ store, dispatch }, y) => {
1826
1942
  const sheet = store.sheetReactive.current;
1827
1943
  if (!sheet) {
1828
1944
  return;
1829
1945
  }
1830
- const addr = p2a({ y, x: 0 });
1946
+ const addr = D({ y, x: 0 });
1831
1947
  const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
1832
1948
  const next = !(rowCell == null ? void 0 : rowCell.filterFixed) || void 0;
1833
1949
  sheet.update({ diff: { [addr]: { filterFixed: next } }, partial: true });
1834
1950
  dispatch(updateSheet(sheet));
1835
- focus(store.editorRef.current);
1951
+ j(store.editorRef.current);
1836
1952
  };
1837
1953
  const searcher = async ({ store, dispatch }) => {
1838
1954
  if (typeof store.searchQuery === "undefined") {
1839
1955
  dispatch(setSearchQuery(""));
1840
1956
  }
1841
1957
  dispatch(setEntering(false));
1842
- requestAnimationFrame(() => focus(store.searchInputRef.current));
1958
+ requestAnimationFrame(() => j(store.searchInputRef.current));
1843
1959
  };
1844
1960
  const applyers = {
1845
1961
  copy: copier,
@@ -1868,12 +1984,12 @@ const rowInsertCount = (ctx, y) => {
1868
1984
  const isFullRow = selectingZone.startX === 1 && selectingZone.endX === ctx.sheet.numCols;
1869
1985
  return isFullRow && y >= selStart && y <= selEnd ? selEnd - selStart + 1 : 1;
1870
1986
  };
1871
- const colInsertCount = (ctx, x) => {
1987
+ const colInsertCount = (ctx, x2) => {
1872
1988
  const { selectingZone } = ctx;
1873
1989
  const selStart = Math.min(selectingZone.startX, selectingZone.endX);
1874
1990
  const selEnd = Math.max(selectingZone.startX, selectingZone.endX);
1875
1991
  const isFullCol = selectingZone.startY === 1 && selectingZone.endY === ctx.sheet.numRows;
1876
- return isFullCol && x >= selStart && x <= selEnd ? selEnd - selStart + 1 : 1;
1992
+ return isFullCol && x2 >= selStart && x2 <= selEnd ? selEnd - selStart + 1 : 1;
1877
1993
  };
1878
1994
  const defaultContextMenuDescriptors = [
1879
1995
  {
@@ -1904,92 +2020,92 @@ const defaultContextMenuDescriptors = [
1904
2020
  {
1905
2021
  id: "insert-rows-above",
1906
2022
  label: (ctx) => {
1907
- const n = zoneShape(ctx.selectingZone).rows;
2023
+ const n = Xr(ctx.selectingZone).rows;
1908
2024
  return `Insert ${n} row${n > 1 ? "s" : ""} above`;
1909
2025
  },
1910
2026
  visible: (ctx) => ctx.leftHeaderSelecting,
1911
2027
  disabled: (ctx) => {
1912
- const n = zoneShape(ctx.selectingZone).rows;
2028
+ const n = Xr(ctx.selectingZone).rows;
1913
2029
  const sheet = ctx.sheet;
1914
2030
  const rowCell = sheet.getCell({ y: ctx.choosing.y, x: 0 }, { resolution: "SYSTEM" });
1915
- return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || operations.hasOperation(rowCell == null ? void 0 : rowCell.prevention, operations.InsertRowsAbove);
2031
+ return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || pn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, pn.InsertRowsAbove);
1916
2032
  },
1917
- onClick: (ctx) => ctx.insertRowsAbove(ctx.choosing.y, zoneShape(ctx.selectingZone).rows)
2033
+ onClick: (ctx) => ctx.insertRowsAbove(ctx.choosing.y, Xr(ctx.selectingZone).rows)
1918
2034
  },
1919
2035
  {
1920
2036
  id: "insert-rows-below",
1921
2037
  label: (ctx) => {
1922
- const n = zoneShape(ctx.selectingZone).rows;
2038
+ const n = Xr(ctx.selectingZone).rows;
1923
2039
  return `Insert ${n} row${n > 1 ? "s" : ""} below`;
1924
2040
  },
1925
2041
  visible: (ctx) => ctx.leftHeaderSelecting,
1926
2042
  disabled: (ctx) => {
1927
- const n = zoneShape(ctx.selectingZone).rows;
2043
+ const n = Xr(ctx.selectingZone).rows;
1928
2044
  const sheet = ctx.sheet;
1929
2045
  const rowCell = sheet.getCell({ y: ctx.choosing.y, x: 0 }, { resolution: "SYSTEM" });
1930
- return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || operations.hasOperation(rowCell == null ? void 0 : rowCell.prevention, operations.InsertRowsBelow);
2046
+ return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || pn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, pn.InsertRowsBelow);
1931
2047
  },
1932
- onClick: (ctx) => ctx.insertRowsBelow(ctx.choosing.y, zoneShape(ctx.selectingZone).rows)
2048
+ onClick: (ctx) => ctx.insertRowsBelow(ctx.choosing.y, Xr(ctx.selectingZone).rows)
1933
2049
  },
1934
2050
  {
1935
2051
  id: "insert-cols-left",
1936
2052
  label: (ctx) => {
1937
- const n = zoneShape(ctx.selectingZone).cols;
2053
+ const n = Xr(ctx.selectingZone).cols;
1938
2054
  return `Insert ${n} column${n > 1 ? "s" : ""} left`;
1939
2055
  },
1940
2056
  visible: (ctx) => ctx.topHeaderSelecting,
1941
2057
  disabled: (ctx) => {
1942
- const n = zoneShape(ctx.selectingZone).cols;
2058
+ const n = Xr(ctx.selectingZone).cols;
1943
2059
  const sheet = ctx.sheet;
1944
2060
  const colCell = sheet.getCell({ y: 0, x: ctx.choosing.x }, { resolution: "SYSTEM" });
1945
- return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.InsertColsLeft);
2061
+ return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.InsertColsLeft);
1946
2062
  },
1947
- onClick: (ctx) => ctx.insertColsLeft(ctx.choosing.x, zoneShape(ctx.selectingZone).cols)
2063
+ onClick: (ctx) => ctx.insertColsLeft(ctx.choosing.x, Xr(ctx.selectingZone).cols)
1948
2064
  },
1949
2065
  {
1950
2066
  id: "insert-cols-right",
1951
2067
  label: (ctx) => {
1952
- const n = zoneShape(ctx.selectingZone).cols;
2068
+ const n = Xr(ctx.selectingZone).cols;
1953
2069
  return `Insert ${n} column${n > 1 ? "s" : ""} right`;
1954
2070
  },
1955
2071
  visible: (ctx) => ctx.topHeaderSelecting,
1956
2072
  disabled: (ctx) => {
1957
- const n = zoneShape(ctx.selectingZone).cols;
2073
+ const n = Xr(ctx.selectingZone).cols;
1958
2074
  const sheet = ctx.sheet;
1959
2075
  const colCell = sheet.getCell({ y: 0, x: ctx.choosing.x }, { resolution: "SYSTEM" });
1960
- return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.InsertColsRight);
2076
+ return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.InsertColsRight);
1961
2077
  },
1962
- onClick: (ctx) => ctx.insertColsRight(ctx.choosing.x, zoneShape(ctx.selectingZone).cols)
2078
+ onClick: (ctx) => ctx.insertColsRight(ctx.choosing.x, Xr(ctx.selectingZone).cols)
1963
2079
  },
1964
2080
  {
1965
2081
  id: "remove-rows",
1966
2082
  label: (ctx) => {
1967
- const n = zoneShape(ctx.selectingZone).rows;
2083
+ const n = Xr(ctx.selectingZone).rows;
1968
2084
  return `Remove ${n} row${n > 1 ? "s" : ""}`;
1969
2085
  },
1970
2086
  visible: (ctx) => ctx.leftHeaderSelecting,
1971
2087
  disabled: (ctx) => {
1972
- const n = zoneShape(ctx.selectingZone).rows;
2088
+ const n = Xr(ctx.selectingZone).rows;
1973
2089
  const sheet = ctx.sheet;
1974
2090
  const rowCell = sheet.getCell({ y: ctx.choosing.y, x: 0 }, { resolution: "SYSTEM" });
1975
- return sheet.minNumRows !== -1 && sheet.numRows - n < sheet.minNumRows || operations.hasOperation(rowCell == null ? void 0 : rowCell.prevention, operations.RemoveRows);
2091
+ return sheet.minNumRows !== -1 && sheet.numRows - n < sheet.minNumRows || pn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, pn.RemoveRows);
1976
2092
  },
1977
- onClick: (ctx) => ctx.removeRows(ctx.choosing.y, zoneShape(ctx.selectingZone).rows)
2093
+ onClick: (ctx) => ctx.removeRows(ctx.choosing.y, Xr(ctx.selectingZone).rows)
1978
2094
  },
1979
2095
  {
1980
2096
  id: "remove-cols",
1981
2097
  label: (ctx) => {
1982
- const n = zoneShape(ctx.selectingZone).cols;
2098
+ const n = Xr(ctx.selectingZone).cols;
1983
2099
  return `Remove ${n} column${n > 1 ? "s" : ""}`;
1984
2100
  },
1985
2101
  visible: (ctx) => ctx.topHeaderSelecting,
1986
2102
  disabled: (ctx) => {
1987
- const n = zoneShape(ctx.selectingZone).cols;
2103
+ const n = Xr(ctx.selectingZone).cols;
1988
2104
  const sheet = ctx.sheet;
1989
2105
  const colCell = sheet.getCell({ y: 0, x: ctx.choosing.x }, { resolution: "SYSTEM" });
1990
- return sheet.minNumCols !== -1 && sheet.numCols - n < sheet.minNumCols || operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.RemoveCols);
2106
+ return sheet.minNumCols !== -1 && sheet.numCols - n < sheet.minNumCols || pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.RemoveCols);
1991
2107
  },
1992
- onClick: (ctx) => ctx.removeCols(ctx.choosing.x, zoneShape(ctx.selectingZone).cols)
2108
+ onClick: (ctx) => ctx.removeCols(ctx.choosing.x, Xr(ctx.selectingZone).cols)
1993
2109
  },
1994
2110
  { type: "divider" },
1995
2111
  {
@@ -2050,7 +2166,7 @@ const defaultRowMenuDescriptors = [
2050
2166
  const n = rowInsertCount(ctx, y);
2051
2167
  const sheet = ctx.sheet;
2052
2168
  const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
2053
- return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || operations.hasOperation(rowCell == null ? void 0 : rowCell.prevention, operations.InsertRowsAbove);
2169
+ return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || pn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, pn.InsertRowsAbove);
2054
2170
  },
2055
2171
  onClick: (ctx, y) => ctx.insertRowsAbove(y, rowInsertCount(ctx, y))
2056
2172
  },
@@ -2064,7 +2180,7 @@ const defaultRowMenuDescriptors = [
2064
2180
  const n = rowInsertCount(ctx, y);
2065
2181
  const sheet = ctx.sheet;
2066
2182
  const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
2067
- return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || operations.hasOperation(rowCell == null ? void 0 : rowCell.prevention, operations.InsertRowsBelow);
2183
+ return sheet.maxNumRows !== -1 && sheet.numRows + n > sheet.maxNumRows || pn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, pn.InsertRowsBelow);
2068
2184
  },
2069
2185
  onClick: (ctx, y) => ctx.insertRowsBelow(y, rowInsertCount(ctx, y))
2070
2186
  },
@@ -2078,7 +2194,7 @@ const defaultRowMenuDescriptors = [
2078
2194
  const n = rowInsertCount(ctx, y);
2079
2195
  const sheet = ctx.sheet;
2080
2196
  const rowCell = sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
2081
- return sheet.minNumRows !== -1 && sheet.numRows - n < sheet.minNumRows || operations.hasOperation(rowCell == null ? void 0 : rowCell.prevention, operations.RemoveRows);
2197
+ return sheet.minNumRows !== -1 && sheet.numRows - n < sheet.minNumRows || pn.hasOperation(rowCell == null ? void 0 : rowCell.prevention, pn.RemoveRows);
2082
2198
  },
2083
2199
  onClick: (ctx, y) => ctx.removeRows(y, rowInsertCount(ctx, y))
2084
2200
  },
@@ -2110,6 +2226,8 @@ const defaultRowMenuDescriptors = [
2110
2226
  }
2111
2227
  ];
2112
2228
  const defaultColMenuDescriptors = [
2229
+ { type: "component", componentId: "col-label" },
2230
+ { type: "divider" },
2113
2231
  { type: "component", componentId: "col-filter" },
2114
2232
  { type: "divider" },
2115
2233
  { type: "component", componentId: "col-sort" },
@@ -2141,45 +2259,45 @@ const defaultColMenuDescriptors = [
2141
2259
  { type: "divider" },
2142
2260
  {
2143
2261
  id: "insert-cols-left",
2144
- label: (ctx, x) => {
2145
- const n = colInsertCount(ctx, x);
2262
+ label: (ctx, x2) => {
2263
+ const n = colInsertCount(ctx, x2);
2146
2264
  return `Insert ${n} column${n > 1 ? "s" : ""} left`;
2147
2265
  },
2148
- disabled: (ctx, x) => {
2149
- const n = colInsertCount(ctx, x);
2266
+ disabled: (ctx, x2) => {
2267
+ const n = colInsertCount(ctx, x2);
2150
2268
  const sheet = ctx.sheet;
2151
- const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2152
- return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.InsertColsLeft);
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);
2153
2271
  },
2154
- onClick: (ctx, x) => ctx.insertColsLeft(x, colInsertCount(ctx, x))
2272
+ onClick: (ctx, x2) => ctx.insertColsLeft(x2, colInsertCount(ctx, x2))
2155
2273
  },
2156
2274
  {
2157
2275
  id: "insert-cols-right",
2158
- label: (ctx, x) => {
2159
- const n = colInsertCount(ctx, x);
2276
+ label: (ctx, x2) => {
2277
+ const n = colInsertCount(ctx, x2);
2160
2278
  return `Insert ${n} column${n > 1 ? "s" : ""} right`;
2161
2279
  },
2162
- disabled: (ctx, x) => {
2163
- const n = colInsertCount(ctx, x);
2280
+ disabled: (ctx, x2) => {
2281
+ const n = colInsertCount(ctx, x2);
2164
2282
  const sheet = ctx.sheet;
2165
- const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2166
- return sheet.maxNumCols !== -1 && sheet.numCols + n > sheet.maxNumCols || operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.InsertColsRight);
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);
2167
2285
  },
2168
- onClick: (ctx, x) => ctx.insertColsRight(x, colInsertCount(ctx, x))
2286
+ onClick: (ctx, x2) => ctx.insertColsRight(x2, colInsertCount(ctx, x2))
2169
2287
  },
2170
2288
  {
2171
2289
  id: "remove-cols",
2172
- label: (ctx, x) => {
2173
- const n = colInsertCount(ctx, x);
2290
+ label: (ctx, x2) => {
2291
+ const n = colInsertCount(ctx, x2);
2174
2292
  return `Remove ${n} column${n > 1 ? "s" : ""}`;
2175
2293
  },
2176
- disabled: (ctx, x) => {
2177
- const n = colInsertCount(ctx, x);
2294
+ disabled: (ctx, x2) => {
2295
+ const n = colInsertCount(ctx, x2);
2178
2296
  const sheet = ctx.sheet;
2179
- const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2180
- return sheet.minNumCols !== -1 && sheet.numCols - n < sheet.minNumCols || operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.RemoveCols);
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);
2181
2299
  },
2182
- onClick: (ctx, x) => ctx.removeCols(x, colInsertCount(ctx, x))
2300
+ onClick: (ctx, x2) => ctx.removeCols(x2, colInsertCount(ctx, x2))
2183
2301
  },
2184
2302
  { type: "divider" },
2185
2303
  {
@@ -2187,9 +2305,7 @@ const defaultColMenuDescriptors = [
2187
2305
  label: "Search",
2188
2306
  shortcuts: ["F"],
2189
2307
  onClick: (ctx) => ctx.search()
2190
- },
2191
- { type: "divider" },
2192
- { type: "component", componentId: "col-label" }
2308
+ }
2193
2309
  ];
2194
2310
  function buildMenuContext(store, dispatch, close) {
2195
2311
  const props = { store, dispatch };
@@ -2214,38 +2330,38 @@ function buildMenuContext(store, dispatch, close) {
2214
2330
  removeRows: (y, numRows) => {
2215
2331
  dispatch(removeRows({ numRows, y, operator: "USER" }));
2216
2332
  },
2217
- insertColsLeft: (x, numCols) => {
2218
- dispatch(insertColsLeft({ numCols, x, operator: "USER" }));
2333
+ insertColsLeft: (x2, numCols) => {
2334
+ dispatch(insertColsLeft({ numCols, x: x2, operator: "USER" }));
2219
2335
  },
2220
- insertColsRight: (x, numCols) => {
2221
- dispatch(insertColsRight({ numCols, x, operator: "USER" }));
2336
+ insertColsRight: (x2, numCols) => {
2337
+ dispatch(insertColsRight({ numCols, x: x2, operator: "USER" }));
2222
2338
  },
2223
- removeCols: (x, numCols) => {
2224
- dispatch(removeCols({ numCols, x, operator: "USER" }));
2339
+ removeCols: (x2, numCols) => {
2340
+ dispatch(removeCols({ numCols, x: x2, operator: "USER" }));
2225
2341
  },
2226
- sortRows: async (x, direction) => {
2342
+ sortRows: async (x2, direction) => {
2227
2343
  if (direction === "asc") {
2228
- await rowsSorterAsc(props, x);
2344
+ await rowsSorterAsc(props, x2);
2229
2345
  } else {
2230
- await rowsSorterDesc(props, x);
2346
+ await rowsSorterDesc(props, x2);
2231
2347
  }
2232
2348
  },
2233
- filterRows: async (x, filter) => {
2349
+ filterRows: async (x2, filter) => {
2234
2350
  if (filter) {
2235
- await rowsFilterer(props, x, filter);
2351
+ await rowsFilterer(props, x2, filter);
2236
2352
  } else {
2237
- rowsFilterClearer(props, x);
2353
+ rowsFilterClearer(props, x2);
2238
2354
  }
2239
2355
  },
2240
- clearFilter: (x) => rowsFilterClearer(props, x),
2356
+ clearFilter: (x2) => rowsFilterClearer(props, x2),
2241
2357
  toggleSortFixed: (y) => rowSortFixedToggler(props, y),
2242
2358
  toggleFilterFixed: (y) => rowFilterFixedToggler(props, y),
2243
2359
  search: () => searcher(props),
2244
- updateColLabel: (x, label) => {
2360
+ updateColLabel: (x2, label) => {
2245
2361
  if (!sheet) {
2246
2362
  return;
2247
2363
  }
2248
- const addr = p2a({ y: 0, x });
2364
+ const addr = D({ y: 0, x: x2 });
2249
2365
  sheet.update({
2250
2366
  diff: { [addr]: { label: label || void 0 } },
2251
2367
  partial: true,
@@ -2296,10 +2412,10 @@ const MenuItem = ({
2296
2412
  shortcuts != null && shortcuts.length > 0 && /* @__PURE__ */ jsx("div", { className: "gs-menu-shortcut", children: shortcuts.map((shortcut, i) => /* @__PURE__ */ jsxs("span", { children: [
2297
2413
  i > 0 && /* @__PURE__ */ jsx("span", { className: "gs-menu-shortcut-sep", children: ", " }),
2298
2414
  /* @__PURE__ */ jsx("span", { className: "gs-menu-shortcut-badge", children: shortcut.split("+").map(
2299
- (part, j, arr) => j < arr.length - 1 ? /* @__PURE__ */ jsxs("span", { children: [
2415
+ (part, j2, arr) => j2 < arr.length - 1 ? /* @__PURE__ */ jsxs("span", { children: [
2300
2416
  part,
2301
2417
  "+"
2302
- ] }, j) : /* @__PURE__ */ jsx("span", { className: "gs-menu-underline", children: part }, j)
2418
+ ] }, j2) : /* @__PURE__ */ jsx("span", { className: "gs-menu-underline", children: part }, j2)
2303
2419
  ) })
2304
2420
  ] }, i)) })
2305
2421
  ]
@@ -2314,7 +2430,7 @@ const ContextMenu = () => {
2314
2430
  const menuRef = useRef(null);
2315
2431
  useEffect(() => {
2316
2432
  if (menuRef.current) {
2317
- clampPopup(menuRef.current);
2433
+ ee(menuRef.current);
2318
2434
  }
2319
2435
  });
2320
2436
  if (top === -1) {
@@ -2380,7 +2496,7 @@ const METHOD_LABELS = {
2380
2496
  };
2381
2497
  const NO_VALUE_METHODS = ["blank", "nonblank"];
2382
2498
  const DEFAULT_CONDITION = { method: "eq", value: [""] };
2383
- const FilterSection = ({ x, close, onWaiting }) => {
2499
+ const FilterSection = ({ x: x2, close, onWaiting }) => {
2384
2500
  const { store, dispatch } = useContext(Context);
2385
2501
  const { sheetReactive: sheetRef } = store;
2386
2502
  const sheet = sheetRef.current;
@@ -2394,11 +2510,11 @@ const FilterSection = ({ x, close, onWaiting }) => {
2394
2510
  }
2395
2511
  },
2396
2512
  // eslint-disable-next-line react-hooks/exhaustive-deps
2397
- [x]
2513
+ [x2]
2398
2514
  );
2399
2515
  useEffect(() => {
2400
2516
  if (sheet) {
2401
- const colCell2 = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2517
+ const colCell2 = sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
2402
2518
  const existing = colCell2 == null ? void 0 : colCell2.filter;
2403
2519
  if (existing && existing.conditions.length > 0) {
2404
2520
  setConditions(existing.conditions.map((c) => ({ ...c, value: [...c.value] })));
@@ -2408,7 +2524,7 @@ const FilterSection = ({ x, close, onWaiting }) => {
2408
2524
  setMode("or");
2409
2525
  }
2410
2526
  }
2411
- }, [x, sheet]);
2527
+ }, [x2, sheet]);
2412
2528
  const handleCancel = useCallback(() => {
2413
2529
  setPending(null);
2414
2530
  onWaiting == null ? void 0 : onWaiting(null);
@@ -2467,7 +2583,7 @@ const FilterSection = ({ x, close, onWaiting }) => {
2467
2583
  if (prev.length <= 1) {
2468
2584
  return [{ ...DEFAULT_CONDITION, value: [""] }];
2469
2585
  }
2470
- return prev.filter((_, i) => i !== index);
2586
+ return prev.filter((_2, i) => i !== index);
2471
2587
  });
2472
2588
  }, []);
2473
2589
  const handleApplyFilter = useCallback(() => {
@@ -2475,15 +2591,15 @@ const FilterSection = ({ x, close, onWaiting }) => {
2475
2591
  if (NO_VALUE_METHODS.includes(c.method)) {
2476
2592
  return true;
2477
2593
  }
2478
- return c.value.some((v) => v.trim() !== "");
2594
+ return c.value.some((v2) => v2.trim() !== "");
2479
2595
  });
2480
- setPending({ x, conditions: valid, mode });
2481
- }, [x, conditions, mode]);
2596
+ setPending({ x: x2, conditions: valid, mode });
2597
+ }, [x2, conditions, mode]);
2482
2598
  const handleResetColumn = useCallback(() => {
2483
2599
  setPending(null);
2484
- dispatch(filterRows({ x }));
2600
+ dispatch(filterRows({ x: x2 }));
2485
2601
  close();
2486
- }, [dispatch, x, close]);
2602
+ }, [dispatch, x2, close]);
2487
2603
  const handleResetAll = useCallback(() => {
2488
2604
  setPending(null);
2489
2605
  dispatch(filterRows({}));
@@ -2492,8 +2608,8 @@ const FilterSection = ({ x, close, onWaiting }) => {
2492
2608
  if (!sheet) {
2493
2609
  return null;
2494
2610
  }
2495
- const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2496
- const filterDisabled = operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.Filter);
2611
+ const colCell = sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
2612
+ const filterDisabled = pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.Filter);
2497
2613
  const hasAnyFilter = sheet.hasActiveFilters();
2498
2614
  return /* @__PURE__ */ jsx("li", { className: `gs-column-menu-filter${filterDisabled ? " gs-disabled" : ""}`, children: /* @__PURE__ */ jsxs(Fragment, { children: [
2499
2615
  /* @__PURE__ */ jsxs("div", { className: "gs-filter-header", children: [
@@ -2585,7 +2701,7 @@ const FilterSection = ({ x, close, onWaiting }) => {
2585
2701
  ] }) });
2586
2702
  };
2587
2703
  registerMenuComponent("col-filter", FilterSection);
2588
- const SortSection = ({ x, close, onWaiting }) => {
2704
+ const SortSection = ({ x: x2, close, onWaiting }) => {
2589
2705
  const { store, dispatch } = useContext(Context);
2590
2706
  const { sheetReactive: sheetRef } = store;
2591
2707
  const sheet = sheetRef.current;
@@ -2631,8 +2747,8 @@ const SortSection = ({ x, close, onWaiting }) => {
2631
2747
  if (!sheet) {
2632
2748
  return null;
2633
2749
  }
2634
- const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2635
- const sortDisabled = operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.Sort);
2750
+ const colCell = sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
2751
+ const sortDisabled = pn.hasOperation(colCell == null ? void 0 : colCell.prevention, pn.Sort);
2636
2752
  return /* @__PURE__ */ jsxs("li", { className: `gs-menu-item gs-column-menu-sort${sortDisabled ? " gs-disabled" : ""}`, children: [
2637
2753
  /* @__PURE__ */ jsx("div", { className: "gs-menu-name", children: "Sort:" }),
2638
2754
  /* @__PURE__ */ jsxs("div", { className: "gs-sort-buttons", children: [
@@ -2643,7 +2759,7 @@ const SortSection = ({ x, close, onWaiting }) => {
2643
2759
  onClick: (e) => {
2644
2760
  e.stopPropagation();
2645
2761
  if (!sortDisabled) {
2646
- setPending({ x, direction: "asc" });
2762
+ setPending({ x: x2, direction: "asc" });
2647
2763
  }
2648
2764
  },
2649
2765
  disabled: sortDisabled,
@@ -2657,7 +2773,7 @@ const SortSection = ({ x, close, onWaiting }) => {
2657
2773
  onClick: (e) => {
2658
2774
  e.stopPropagation();
2659
2775
  if (!sortDisabled) {
2660
- setPending({ x, direction: "desc" });
2776
+ setPending({ x: x2, direction: "desc" });
2661
2777
  }
2662
2778
  },
2663
2779
  disabled: sortDisabled,
@@ -2668,23 +2784,35 @@ const SortSection = ({ x, close, onWaiting }) => {
2668
2784
  ] });
2669
2785
  };
2670
2786
  registerMenuComponent("col-sort", SortSection);
2671
- const LabelSection = ({ x, close }) => {
2787
+ const LabelSection = ({ x: x2, close }) => {
2672
2788
  const { store, dispatch } = useContext(Context);
2673
2789
  const { sheetReactive: sheetRef } = store;
2674
2790
  const sheet = sheetRef.current;
2675
2791
  const labelInputRef = useRef(null);
2676
2792
  const [label, setLabel] = useState("");
2677
2793
  useEffect(() => {
2794
+ var _a;
2678
2795
  if (sheet) {
2679
- const colCell2 = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2796
+ const colCell2 = sheet.getCell({ y: 0, x: x2 }, { resolution: "SYSTEM" });
2680
2797
  setLabel((colCell2 == null ? void 0 : colCell2.label) ?? "");
2681
2798
  }
2682
- }, [x, sheet]);
2799
+ if ((_a = store.columnMenuState) == null ? void 0 : _a.focusLabel) {
2800
+ requestAnimationFrame(
2801
+ () => requestAnimationFrame(() => {
2802
+ const input = labelInputRef.current;
2803
+ if (input) {
2804
+ input.focus();
2805
+ input.setSelectionRange(0, input.value.length);
2806
+ }
2807
+ })
2808
+ );
2809
+ }
2810
+ }, [x2, sheet]);
2683
2811
  const handleApplyLabel = useCallback(() => {
2684
2812
  if (!sheet) {
2685
2813
  return;
2686
2814
  }
2687
- const address = p2a({ y: 0, x });
2815
+ const address = D({ y: 0, x: x2 });
2688
2816
  sheet.update({
2689
2817
  diff: { [address]: { label: label || void 0 } },
2690
2818
  partial: true,
@@ -2702,13 +2830,13 @@ const LabelSection = ({ x, close }) => {
2702
2830
  });
2703
2831
  dispatch(setStore({ sheetReactive: { current: sheet } }));
2704
2832
  close();
2705
- }, [dispatch, x, label, close, sheet, store.selectingZone, store.choosing]);
2833
+ }, [dispatch, x2, label, close, sheet, store.selectingZone, store.choosing]);
2706
2834
  if (!sheet) {
2707
2835
  return null;
2708
2836
  }
2709
- const colCell = sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
2710
- const labelDisabled = operations.hasOperation(colCell == null ? void 0 : colCell.prevention, operations.SetLabel);
2711
- const labelPlaceholder = getLabel(sheet, colCell == null ? void 0 : colCell.label, { y: 0, x }, x) ?? x2c(x);
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);
2712
2840
  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: [
2713
2841
  /* @__PURE__ */ jsx("div", { className: "gs-label-input-label", children: "Label:" }),
2714
2842
  /* @__PURE__ */ jsx(
@@ -2742,12 +2870,12 @@ const ColumnMenu = () => {
2742
2870
  const { store, dispatch } = useContext(Context);
2743
2871
  const { columnMenuState, editorRef, colMenu } = store;
2744
2872
  const sheet = store.sheetReactive.current;
2745
- const x = columnMenuState == null ? void 0 : columnMenuState.x;
2873
+ const x2 = columnMenuState == null ? void 0 : columnMenuState.x;
2746
2874
  const position = columnMenuState == null ? void 0 : columnMenuState.position;
2747
2875
  const [waitingState, setWaitingState] = useState(null);
2748
2876
  const handleClose = useCallback(() => {
2749
2877
  dispatch(setColumnMenu(null));
2750
- focus(editorRef.current);
2878
+ j(editorRef.current);
2751
2879
  }, [dispatch, editorRef]);
2752
2880
  const handleWaiting = useCallback(
2753
2881
  (message, cancel) => {
@@ -2759,7 +2887,7 @@ const ColumnMenu = () => {
2759
2887
  },
2760
2888
  [handleClose]
2761
2889
  );
2762
- if (!columnMenuState || !sheet || x == null || !position) {
2890
+ if (!columnMenuState || !sheet || x2 == null || !position) {
2763
2891
  return null;
2764
2892
  }
2765
2893
  const ctx = buildMenuContext(store, dispatch, handleClose);
@@ -2784,7 +2912,7 @@ const ColumnMenu = () => {
2784
2912
  children: /* @__PURE__ */ jsx("ul", { className: "gs-menu-items", children: colMenu.map((descriptor, index) => {
2785
2913
  var _a;
2786
2914
  if (descriptor.type === "component") {
2787
- const visible2 = !descriptor.visible || descriptor.visible(ctx, x);
2915
+ const visible2 = !descriptor.visible || descriptor.visible(ctx, x2);
2788
2916
  if (!visible2) {
2789
2917
  return null;
2790
2918
  }
@@ -2792,7 +2920,7 @@ const ColumnMenu = () => {
2792
2920
  if (!Section) {
2793
2921
  return null;
2794
2922
  }
2795
- return /* @__PURE__ */ jsx(Section, { x, close: handleClose, onWaiting: handleWaiting }, index);
2923
+ return /* @__PURE__ */ jsx(Section, { x: x2, close: handleClose, onWaiting: handleWaiting }, index);
2796
2924
  }
2797
2925
  if (descriptor.type === "divider") {
2798
2926
  if (descriptor.visible && !descriptor.visible(ctx)) {
@@ -2800,13 +2928,13 @@ const ColumnMenu = () => {
2800
2928
  }
2801
2929
  return /* @__PURE__ */ jsx(MenuDivider, {}, index);
2802
2930
  }
2803
- const visible = !descriptor.visible || descriptor.visible(ctx, x);
2931
+ const visible = !descriptor.visible || descriptor.visible(ctx, x2);
2804
2932
  if (!visible) {
2805
2933
  return null;
2806
2934
  }
2807
- const disabled = ((_a = descriptor.disabled) == null ? void 0 : _a.call(descriptor, ctx, x)) ?? false;
2808
- const label = typeof descriptor.label === "function" ? descriptor.label(ctx, x) : descriptor.label;
2809
- const shortcuts = typeof descriptor.shortcuts === "function" ? descriptor.shortcuts(ctx, x) : descriptor.shortcuts;
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;
2810
2938
  return /* @__PURE__ */ jsx(
2811
2939
  MenuItem,
2812
2940
  {
@@ -2815,7 +2943,7 @@ const ColumnMenu = () => {
2815
2943
  disabled,
2816
2944
  testId: descriptor.id ? `${descriptor.id}-item` : void 0,
2817
2945
  onClick: () => {
2818
- descriptor.onClick(ctx, x);
2946
+ descriptor.onClick(ctx, x2);
2819
2947
  dispatch(setColumnMenu(null));
2820
2948
  }
2821
2949
  },
@@ -2881,7 +3009,7 @@ const RowMenu = () => {
2881
3009
  const position = rowMenuState == null ? void 0 : rowMenuState.position;
2882
3010
  const handleClose = () => {
2883
3011
  dispatch(setRowMenu(null));
2884
- focus(editorRef.current);
3012
+ j(editorRef.current);
2885
3013
  };
2886
3014
  if (!rowMenuState || !sheet || y == null || !position) {
2887
3015
  return null;
@@ -2915,10 +3043,10 @@ const safePreventDefault = (e) => {
2915
3043
  e.preventDefault();
2916
3044
  }
2917
3045
  };
2918
- const Cell = memo(({ y, x }) => {
3046
+ const Cell = memo(({ y, x: x$1 }) => {
2919
3047
  var _a;
2920
- const rowId = y2r(y);
2921
- const colId = x2c(x);
3048
+ const rowId = Et(y);
3049
+ const colId = W(x$1);
2922
3050
  const address = `${colId}${rowId}`;
2923
3051
  const { store, dispatch } = useContext(Context);
2924
3052
  const isFirstPointed = useRef(true);
@@ -2938,9 +3066,9 @@ const Cell = memo(({ y, x }) => {
2938
3066
  const sheet = sheetReactive.current;
2939
3067
  const xSheetFocused = isXSheetFocused(store);
2940
3068
  const lastFocused = sheet == null ? void 0 : sheet.registry.lastFocused;
2941
- const selectingArea = zoneToArea(selectingZone);
3069
+ const selectingArea = Rs(selectingZone);
2942
3070
  const editing = editingAddress === address;
2943
- const pointed = choosing.y === y && choosing.x === x;
3071
+ const pointed = choosing.y === y && choosing.x === x$1;
2944
3072
  const _setEditorRect = useCallback(() => {
2945
3073
  var _a2;
2946
3074
  const rect = (_a2 = cellRef.current) == null ? void 0 : _a2.getBoundingClientRect();
@@ -2963,7 +3091,7 @@ const Cell = memo(({ y, x }) => {
2963
3091
  }
2964
3092
  isFirstPointed.current = false;
2965
3093
  }, [pointed, editing, _setEditorRect]);
2966
- const cell = sheet == null ? void 0 : sheet.getCell({ y, x }, { resolution: "SYSTEM" });
3094
+ const cell = sheet == null ? void 0 : sheet.getCell({ y, x: x$1 }, { resolution: "SYSTEM" });
2967
3095
  const writeCell = useCallback(
2968
3096
  (value) => {
2969
3097
  dispatch(write({ value }));
@@ -2980,10 +3108,10 @@ const Cell = memo(({ y, x }) => {
2980
3108
  let rendered;
2981
3109
  try {
2982
3110
  if (sheet) {
2983
- rendered = sheet.render({ sheet, point: { y, x }, apply, value: void 0 });
3111
+ rendered = sheet.render({ sheet, point: { y, x: x$1 }, apply, value: void 0 });
2984
3112
  }
2985
3113
  } catch (e) {
2986
- if (FormulaError.is(e)) {
3114
+ if (x.is(e)) {
2987
3115
  errorMessage = e.message;
2988
3116
  rendered = e.code;
2989
3117
  } else {
@@ -2991,8 +3119,8 @@ const Cell = memo(({ y, x }) => {
2991
3119
  rendered = "#UNKNOWN";
2992
3120
  }
2993
3121
  }
2994
- const [, v] = (sheet == null ? void 0 : sheet.getSolvedCache({ y, x })) ?? [void 0, void 0];
2995
- const isPendingCell = Pending.is(v);
3122
+ const [, v2] = (sheet == null ? void 0 : sheet.getSolvedCache({ y, x: x$1 })) ?? [void 0, void 0];
3123
+ const isPendingCell = k.is(v2);
2996
3124
  const input = editorRef.current;
2997
3125
  const editingAnywhere = !!((sheet == null ? void 0 : sheet.registry.editingAddress) || editingAddress);
2998
3126
  const handleDragStart = useCallback(
@@ -3012,25 +3140,25 @@ const Cell = memo(({ y, x }) => {
3012
3140
  if (editingAnywhere && input) {
3013
3141
  input.blur();
3014
3142
  }
3015
- dispatch(choose({ y, x }));
3016
- dispatch(select({ startY: y, startX: x, endY: y, endX: x }));
3143
+ dispatch(choose({ y, x: x$1 }));
3144
+ dispatch(select({ startY: y, startX: x$1, endY: y, endX: x$1 }));
3017
3145
  return true;
3018
3146
  }
3019
3147
  if (e.shiftKey) {
3020
- dispatch(drag({ y, x }));
3148
+ dispatch(drag({ y, x: x$1 }));
3021
3149
  } else {
3022
- dispatch(select({ startY: y, startX: x, endY: -1, endX: -1 }));
3150
+ dispatch(select({ startY: y, startX: x$1, endY: -1, endX: -1 }));
3023
3151
  }
3024
3152
  dispatch(setDragging(true));
3025
3153
  const fullAddress = `${sheet.sheetPrefix(!xSheetFocused)}${address}`;
3026
3154
  if (editingAnywhere) {
3027
- const inserted = insertRef({ input: lastFocused || null, ref: fullAddress });
3155
+ const inserted = Y({ input: lastFocused || null, ref: fullAddress });
3028
3156
  if (inserted) {
3029
3157
  return false;
3030
3158
  }
3031
3159
  }
3032
3160
  sheet.registry.lastFocused = input;
3033
- focus(input);
3161
+ j(input);
3034
3162
  dispatch(setEditingAddress(""));
3035
3163
  if (autofillDraggingTo) {
3036
3164
  return false;
@@ -3039,7 +3167,7 @@ const Cell = memo(({ y, x }) => {
3039
3167
  writeCell(input.value);
3040
3168
  }
3041
3169
  if (!e.shiftKey) {
3042
- dispatch(choose({ y, x }));
3170
+ dispatch(choose({ y, x: x$1 }));
3043
3171
  }
3044
3172
  return true;
3045
3173
  },
@@ -3053,16 +3181,11 @@ const Cell = memo(({ y, x }) => {
3053
3181
  }
3054
3182
  safePreventDefault(e);
3055
3183
  dispatch(setDragging(false));
3056
- if (autofillDraggingTo) {
3057
- dispatch(submitAutofill(autofillDraggingTo));
3058
- focus(input);
3059
- return false;
3060
- }
3061
3184
  if (editingAnywhere) {
3062
3185
  dispatch(drag({ y: -1, x: -1 }));
3063
3186
  }
3064
3187
  },
3065
- [autofillDraggingTo, editingAnywhere, input]
3188
+ [editingAnywhere]
3066
3189
  );
3067
3190
  const handleDragging = useCallback(
3068
3191
  (e) => {
@@ -3078,7 +3201,7 @@ const Cell = memo(({ y, x }) => {
3078
3201
  safePreventDefault(e);
3079
3202
  e.stopPropagation();
3080
3203
  if (autofillDraggingTo) {
3081
- dispatch(setAutofillDraggingTo({ x, y }));
3204
+ dispatch(setAutofillDraggingTo({ x: x$1, y }));
3082
3205
  return false;
3083
3206
  }
3084
3207
  if (leftHeaderSelecting) {
@@ -3086,17 +3209,17 @@ const Cell = memo(({ y, x }) => {
3086
3209
  return false;
3087
3210
  }
3088
3211
  if (topHeaderSelecting) {
3089
- dispatch(drag({ y: sheet.numRows, x }));
3212
+ dispatch(drag({ y: sheet.numRows, x: x$1 }));
3090
3213
  return false;
3091
3214
  }
3092
- if (editingAnywhere && !isRefInsertable(lastFocused || null)) {
3215
+ if (editingAnywhere && !X(lastFocused || null)) {
3093
3216
  return false;
3094
3217
  }
3095
- dispatch(drag({ y, x }));
3218
+ dispatch(drag({ y, x: x$1 }));
3096
3219
  if (editingAnywhere) {
3097
- const newArea = zoneToArea({ ...selectingZone, endY: y, endX: x });
3098
- const fullRange = `${sheet.sheetPrefix(!xSheetFocused)}${areaToRange(newArea)}`;
3099
- insertRef({ input: lastFocused || null, ref: fullRange });
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 });
3100
3223
  }
3101
3224
  return true;
3102
3225
  },
@@ -3113,11 +3236,11 @@ const Cell = memo(({ y, x }) => {
3113
3236
  );
3114
3237
  const handleAutofillMouseDown = useCallback(
3115
3238
  (e) => {
3116
- dispatch(setAutofillDraggingTo({ x, y }));
3239
+ dispatch(setAutofillDraggingTo({ x: x$1, y }));
3117
3240
  dispatch(setDragging(true));
3118
3241
  e.stopPropagation();
3119
3242
  },
3120
- [dispatch, x, y]
3243
+ [dispatch, x$1, y]
3121
3244
  );
3122
3245
  const handleErrorTriangleEnter = useCallback(() => {
3123
3246
  var _a2;
@@ -3125,7 +3248,7 @@ const Cell = memo(({ y, x }) => {
3125
3248
  if (!rect) {
3126
3249
  return;
3127
3250
  }
3128
- setErrorTooltipPos(calcBelowPosition(rect));
3251
+ setErrorTooltipPos(J$1(rect));
3129
3252
  }, []);
3130
3253
  const handleErrorTriangleLeave = useCallback(() => {
3131
3254
  setErrorTooltipPos(null);
@@ -3158,7 +3281,7 @@ const Cell = memo(({ y, x }) => {
3158
3281
  if (!editing && pointed && selectingArea.bottom === -1) {
3159
3282
  return "gs-autofill-drag";
3160
3283
  }
3161
- if (selectingArea.bottom === y && selectingArea.right === x) {
3284
+ if (selectingArea.bottom === y && selectingArea.right === x$1) {
3162
3285
  return "gs-autofill-drag";
3163
3286
  }
3164
3287
  return "gs-autofill-drag gs-hidden";
@@ -3167,19 +3290,19 @@ const Cell = memo(({ y, x }) => {
3167
3290
  return null;
3168
3291
  }
3169
3292
  if (!input) {
3170
- 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: [
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: [
3171
3294
  /* @__PURE__ */ jsx("div", { className: "gs-cell-inner", children: /* @__PURE__ */ jsx("div", { className: "gs-cell-rendered" }) }),
3172
3295
  /* @__PURE__ */ jsx("div", { className: "gs-autofill-drag" })
3173
- ] }) }, x);
3296
+ ] }) }, x$1);
3174
3297
  }
3175
3298
  return /* @__PURE__ */ jsx(
3176
3299
  "td",
3177
3300
  {
3178
3301
  ref: cellRef,
3179
- "data-x": x,
3302
+ "data-x": x$1,
3180
3303
  "data-y": y,
3181
3304
  "data-address": address,
3182
- className: `gs-cell ${among(selectingArea, { y, x }) ? "gs-selecting" : ""} ${pointed ? "gs-choosing" : ""} ${editing ? "gs-editing" : ""} ${isPendingCell ? "gs-pending" : ""}`,
3305
+ className: `gs-cell ${Wr(selectingArea, { y, x: x$1 }) ? "gs-selecting" : ""} ${pointed ? "gs-choosing" : ""} ${editing ? "gs-editing" : ""} ${isPendingCell ? "gs-pending" : ""}`,
3183
3306
  style: {
3184
3307
  ...cell == null ? void 0 : cell.style
3185
3308
  },
@@ -3234,7 +3357,7 @@ const Cell = memo(({ y, x }) => {
3234
3357
  style: {
3235
3358
  top: errorTooltipPos.y + 4,
3236
3359
  left: errorTooltipPos.x,
3237
- transform: hAlignTransform(errorTooltipPos.hAlign)
3360
+ transform: oe(errorTooltipPos.hAlign)
3238
3361
  },
3239
3362
  children: errorMessage
3240
3363
  }
@@ -3244,7 +3367,7 @@ const Cell = memo(({ y, x }) => {
3244
3367
  }
3245
3368
  )
3246
3369
  },
3247
- x
3370
+ x$1
3248
3371
  );
3249
3372
  });
3250
3373
  const acceleration = 0.4;
@@ -3265,6 +3388,8 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
3265
3388
  editingAddress
3266
3389
  } = store;
3267
3390
  const sheet = sheetRef.current;
3391
+ const storeRef = useRef(store);
3392
+ storeRef.current = store;
3268
3393
  let isScrolling = false;
3269
3394
  const xSheetFocused = isXSheetFocused(store);
3270
3395
  const editingAnywhere = !!((sheet == null ? void 0 : sheet.registry.editingAddress) || editingAddress);
@@ -3281,14 +3406,14 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
3281
3406
  vertical = e.pageY > bottom ? 1 : e.pageY < top ? -1 : 0;
3282
3407
  }
3283
3408
  }
3284
- const area = getAreaInTabular(tabularRef.current);
3285
- let { endX: x, endY: y } = selectingZone;
3409
+ const area = Q(tabularRef.current);
3410
+ let { endX: x2, endY: y } = selectingZone;
3286
3411
  if (horizontal) {
3287
- x = horizontal > 0 ? area.right : area.left;
3412
+ x2 = horizontal > 0 ? area.right : area.left;
3288
3413
  } else if (vertical) {
3289
3414
  y = vertical > 0 ? area.bottom : area.top;
3290
3415
  }
3291
- return { x, y };
3416
+ return { x: x2, y };
3292
3417
  },
3293
3418
  [sheet, horizontal, vertical, selectingZone]
3294
3419
  );
@@ -3297,6 +3422,15 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
3297
3422
  if (!isScrolling || tabularRef.current === null || !sheet) {
3298
3423
  return;
3299
3424
  }
3425
+ const live = storeRef.current;
3426
+ if (!live.dragging && !live.autofillDraggingTo) {
3427
+ if (scrollRef.current !== null) {
3428
+ cancelAnimationFrame(scrollRef.current);
3429
+ scrollRef.current = null;
3430
+ }
3431
+ isScrolling = false;
3432
+ return;
3433
+ }
3300
3434
  const now = (/* @__PURE__ */ new Date()).getTime();
3301
3435
  if (now - lastScrollTime > 1e3) {
3302
3436
  currentSpeed = 0;
@@ -3306,20 +3440,20 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
3306
3440
  left: currentSpeed * horizontal,
3307
3441
  top: currentSpeed * vertical
3308
3442
  });
3309
- focus(editorRef.current);
3310
- const { x, y } = getDestEdge(e);
3311
- if (autofillDraggingTo) {
3312
- const { y: curY, x: curX } = autofillDraggingTo;
3313
- dispatch(setAutofillDraggingTo({ y: y === -1 ? curY : y, x: x === -1 ? curX : x }));
3443
+ j(editorRef.current);
3444
+ const { x: x2, y } = getDestEdge(e);
3445
+ if (live.autofillDraggingTo) {
3446
+ const { y: curY, x: curX } = live.autofillDraggingTo;
3447
+ dispatch(setAutofillDraggingTo({ y: y === -1 ? curY : y, x: x2 === -1 ? curX : x2 }));
3314
3448
  } else {
3315
3449
  if (editingAnywhere) {
3316
- const newArea = zoneToArea({ ...selectingZone, endY: y, endX: x });
3450
+ const newArea = Rs({ ...selectingZone, endY: y, endX: x2 });
3317
3451
  const sheetPrefix = sheet.sheetPrefix(!xSheetFocused);
3318
- const sheetRange = areaToRange(newArea);
3452
+ const sheetRange = zr(newArea);
3319
3453
  const fullRange = `${sheetPrefix}${sheetRange}`;
3320
- insertRef({ input: editorRef.current, ref: fullRange });
3454
+ Y({ input: editorRef.current, ref: fullRange });
3321
3455
  }
3322
- dispatch(drag({ y, x }));
3456
+ dispatch(drag({ y, x: x2 }));
3323
3457
  }
3324
3458
  currentSpeed = Math.min(currentSpeed + acceleration, maxSpeed);
3325
3459
  scrollRef.current = requestAnimationFrame(() => scrollStep(e));
@@ -3362,23 +3496,23 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
3362
3496
  scrollRef.current = null;
3363
3497
  }
3364
3498
  isScrolling = false;
3365
- if (!isFocus(searchInputRef.current)) {
3366
- focus(editorRef.current);
3499
+ if (!U(searchInputRef.current)) {
3500
+ j(editorRef.current);
3367
3501
  }
3368
3502
  }, []);
3369
3503
  const handleMouseUp = useCallback(
3370
3504
  (e) => {
3371
3505
  e.preventDefault();
3372
3506
  e.stopPropagation();
3373
- const area = getAreaInTabular(tabularRef.current);
3507
+ const area = Q(tabularRef.current);
3374
3508
  if (area.bottom === -1 || area.right === -1) {
3375
3509
  return;
3376
3510
  }
3377
- const { x, y } = getDestEdge(e);
3511
+ const { x: x2, y } = getDestEdge(e);
3378
3512
  if (autofillDraggingTo) {
3379
3513
  const { y: curY, x: curX } = autofillDraggingTo;
3380
- dispatch(submitAutofill({ y: y === -1 ? curY : y, x: x === -1 ? curX : x }));
3381
- focus(editorRef.current);
3514
+ dispatch(submitAutofill({ y: y === -1 ? curY : y, x: x2 === -1 ? curX : x2 }));
3515
+ j(editorRef.current);
3382
3516
  } else {
3383
3517
  if (editingAnywhere) {
3384
3518
  dispatch(drag({ y: -1, x: -1 }));
@@ -3401,7 +3535,9 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
3401
3535
  useEffect(() => {
3402
3536
  return stopScroll;
3403
3537
  }, [stopScroll]);
3404
- if (!editorRef.current || !dragging && !autofillDraggingTo) {
3538
+ const t = tabularRef.current;
3539
+ const cannotScrollHere = !!t && (horizontal > 0 && t.scrollLeft + t.clientWidth >= t.scrollWidth - 1 || horizontal < 0 && t.scrollLeft <= 0 || vertical > 0 && t.scrollTop + t.clientHeight >= t.scrollHeight - 1 || vertical < 0 && t.scrollTop <= 0);
3540
+ if (!editorRef.current || !dragging && !autofillDraggingTo || cannotScrollHere) {
3405
3541
  return /* @__PURE__ */ jsx("div", { className: `gs-scroll-handle gs-hidden ${className}` });
3406
3542
  }
3407
3543
  return /* @__PURE__ */ jsx(
@@ -3417,8 +3553,8 @@ function ScrollHandle({ style, horizontal = 0, vertical = 0, className = "" }) {
3417
3553
  }
3418
3554
  );
3419
3555
  }
3420
- const HeaderCellTop = memo(({ x }) => {
3421
- const colId = x2c(x);
3556
+ const HeaderCellTop = memo(({ x: x2 }) => {
3557
+ const colId = W(x2);
3422
3558
  const { store, dispatch } = useContext(Context);
3423
3559
  const {
3424
3560
  sheetReactive: sheetRef,
@@ -3433,8 +3569,8 @@ const HeaderCellTop = memo(({ x }) => {
3433
3569
  columnMenuState
3434
3570
  } = store;
3435
3571
  const sheet = sheetRef.current;
3436
- const col = sheet == null ? void 0 : sheet.getCell({ y: 0, x }, { resolution: "SYSTEM" });
3437
- const width = (col == null ? void 0 : col.width) || DEFAULT_WIDTH;
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;
3438
3574
  const hasFilter = !!((col == null ? void 0 : col.filter) && col.filter.conditions.length > 0);
3439
3575
  const xSheetFocused = isXSheetFocused(store);
3440
3576
  const lastFocused = sheet == null ? void 0 : sheet.registry.lastFocused;
@@ -3446,7 +3582,7 @@ const HeaderCellTop = memo(({ x }) => {
3446
3582
  [choosing]
3447
3583
  );
3448
3584
  const handleResizeMouseDown = useCallback((e) => {
3449
- dispatch(setResizingPositionX([x, e.clientX, e.clientX]));
3585
+ dispatch(setResizingPositionX([x2, e.clientX, e.clientX]));
3450
3586
  e.stopPropagation();
3451
3587
  safePreventDefault(e);
3452
3588
  }, []);
@@ -3464,26 +3600,26 @@ const HeaderCellTop = memo(({ x }) => {
3464
3600
  if (editingAnywhere && editorRef.current) {
3465
3601
  editorRef.current.blur();
3466
3602
  }
3467
- dispatch(choose({ y: 1, x }));
3468
- dispatch(select({ startY: 1, startX: x, endY: sheet.numRows, endX: x }));
3603
+ dispatch(choose({ y: 1, x: x2 }));
3604
+ dispatch(select({ startY: 1, startX: x2, endY: sheet.numRows, endX: x2 }));
3469
3605
  return true;
3470
3606
  }
3471
- dispatch(select({ startY: 1, startX: x, endY: -1, endX: x }));
3607
+ dispatch(select({ startY: 1, startX: x2, endY: -1, endX: x2 }));
3472
3608
  const fullAddress = `${sheet.sheetPrefix(!xSheetFocused)}${colId}:${colId}`;
3473
3609
  if (editingAnywhere) {
3474
- const inserted = insertRef({ input: lastFocused || null, ref: fullAddress });
3610
+ const inserted = Y({ input: lastFocused || null, ref: fullAddress });
3475
3611
  if (inserted) {
3476
- dispatch(select({ startY: sheet.numRows, startX: x, endY: 0, endX: x }));
3612
+ dispatch(select({ startY: sheet.numRows, startX: x2, endY: 0, endX: x2 }));
3477
3613
  return false;
3478
3614
  }
3479
3615
  }
3480
- let startX = e.shiftKey ? selectingZone.startX : x;
3616
+ let startX = e.shiftKey ? selectingZone.startX : x2;
3481
3617
  if (startX === -1) {
3482
3618
  startX = choosing.x;
3483
3619
  }
3484
3620
  dispatch(
3485
3621
  selectCols({
3486
- range: { start: startX, end: x },
3622
+ range: { start: startX, end: x2 },
3487
3623
  numRows: sheet.numRows
3488
3624
  })
3489
3625
  );
@@ -3492,7 +3628,7 @@ const HeaderCellTop = memo(({ x }) => {
3492
3628
  }
3493
3629
  dispatch(setEditingAddress(""));
3494
3630
  dispatch(setDragging(true));
3495
- focus(editorRef.current);
3631
+ j(editorRef.current);
3496
3632
  if (autofillDraggingTo) {
3497
3633
  return false;
3498
3634
  }
@@ -3519,7 +3655,7 @@ const HeaderCellTop = memo(({ x }) => {
3519
3655
  safePreventDefault(e);
3520
3656
  dispatch(setDragging(false));
3521
3657
  if (autofillDraggingTo) {
3522
- focus(editorRef.current);
3658
+ j(editorRef.current);
3523
3659
  return false;
3524
3660
  }
3525
3661
  },
@@ -3535,27 +3671,27 @@ const HeaderCellTop = memo(({ x }) => {
3535
3671
  safePreventDefault(e);
3536
3672
  e.stopPropagation();
3537
3673
  if (autofillDraggingTo) {
3538
- dispatch(setAutofillDraggingTo({ y: 1, x }));
3674
+ dispatch(setAutofillDraggingTo({ y: 1, x: x2 }));
3539
3675
  return false;
3540
3676
  }
3541
3677
  if (editingAnywhere) {
3542
- const newArea = zoneToArea({ ...selectingZone, endY: 1, endX: x });
3543
- const [left, right] = [x2c(newArea.left), x2c(newArea.right)];
3678
+ const newArea = Rs({ ...selectingZone, endY: 1, endX: x2 });
3679
+ const [left, right] = [W(newArea.left), W(newArea.right)];
3544
3680
  const fullRange = `${sheet.sheetPrefix(!xSheetFocused)}${left}:${right}`;
3545
- insertRef({ input: lastFocused || null, ref: fullRange });
3681
+ Y({ input: lastFocused || null, ref: fullRange });
3546
3682
  }
3547
3683
  if (autofillDraggingTo == null) {
3548
3684
  const { startY } = selectingZone;
3549
3685
  if (startY === 1) {
3550
- dispatch(drag({ y: sheet.numRows, x }));
3686
+ dispatch(drag({ y: sheet.numRows, x: x2 }));
3551
3687
  } else {
3552
- dispatch(drag({ y: 1, x }));
3688
+ dispatch(drag({ y: 1, x: x2 }));
3553
3689
  }
3554
3690
  }
3555
3691
  return false;
3556
3692
  }, 100);
3557
3693
  if (!sheet) {
3558
- 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: [
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: [
3559
3695
  /* @__PURE__ */ jsx(ScrollHandle, { style: { position: "absolute" }, vertical: -1 }),
3560
3696
  /* @__PURE__ */ jsx("div", { className: "gs-resizer" })
3561
3697
  ] }) }) });
@@ -3563,9 +3699,26 @@ const HeaderCellTop = memo(({ x }) => {
3563
3699
  return /* @__PURE__ */ jsx(
3564
3700
  "th",
3565
3701
  {
3566
- "data-x": x,
3567
- className: `gs-th gs-th-top ${choosing.x === x ? "gs-choosing" : ""} ${between({ start: selectingZone.startX, end: selectingZone.endX }, x) ? topHeaderSelecting ? "gs-th-selecting" : "gs-selecting" : ""}`,
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" : ""}`,
3568
3704
  style: { ...col == null ? void 0 : col.style, width, minWidth: width, maxWidth: width },
3705
+ onDoubleClick: (e) => {
3706
+ const target = e.target;
3707
+ if (target.closest(".gs-resizer, .gs-menu-btn")) {
3708
+ return;
3709
+ }
3710
+ if (pn.hasOperation(col == null ? void 0 : col.prevention, pn.ColumnMenu)) {
3711
+ return;
3712
+ }
3713
+ e.stopPropagation();
3714
+ const inner = e.currentTarget.querySelector(".gs-th-inner");
3715
+ const rect = (inner ?? e.currentTarget).getBoundingClientRect();
3716
+ const alreadySelected = Vr({ start: selectingZone.startX, end: selectingZone.endX }, x2) && selectingZone.startY === 1 && selectingZone.endY === sheet.numRows;
3717
+ if (!alreadySelected) {
3718
+ dispatch(selectCols({ range: { start: x2, end: x2 }, numRows: sheet.numRows }));
3719
+ }
3720
+ dispatch(setColumnMenu({ x: x2, position: { y: rect.bottom, x: rect.left }, focusLabel: true }));
3721
+ },
3569
3722
  onContextMenu: (e) => {
3570
3723
  if (contextMenu.length > 0) {
3571
3724
  e.stopPropagation();
@@ -3595,7 +3748,7 @@ const HeaderCellTop = memo(({ x }) => {
3595
3748
  }
3596
3749
  ),
3597
3750
  (() => {
3598
- const displayedLabel = getLabel(sheet, col == null ? void 0 : col.label, { y: 0, x }, x) ?? colId;
3751
+ const displayedLabel = Rn(sheet, col == null ? void 0 : col.label, { y: 0, x: x2 }, x2) ?? colId;
3599
3752
  if (displayedLabel !== colId) {
3600
3753
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3601
3754
  /* @__PURE__ */ jsx("span", { className: "gs-col-addr", children: colId }),
@@ -3604,10 +3757,10 @@ const HeaderCellTop = memo(({ x }) => {
3604
3757
  }
3605
3758
  return displayedLabel;
3606
3759
  })(),
3607
- !operations.hasOperation(col == null ? void 0 : col.prevention, operations.ColumnMenu) && /* @__PURE__ */ jsx(
3760
+ !pn.hasOperation(col == null ? void 0 : col.prevention, pn.ColumnMenu) && /* @__PURE__ */ jsx(
3608
3761
  "button",
3609
3762
  {
3610
- className: `gs-menu-btn gs-column-menu-btn ${hasFilter ? "gs-filtered" : ""} ${(columnMenuState == null ? void 0 : columnMenuState.x) === x ? "gs-active" : ""}`,
3763
+ className: `gs-menu-btn gs-column-menu-btn ${hasFilter ? "gs-filtered" : ""} ${(columnMenuState == null ? void 0 : columnMenuState.x) === x2 ? "gs-active" : ""}`,
3611
3764
  onMouseDown: (e) => {
3612
3765
  e.stopPropagation();
3613
3766
  e.preventDefault();
@@ -3624,14 +3777,14 @@ const HeaderCellTop = memo(({ x }) => {
3624
3777
  return;
3625
3778
  }
3626
3779
  const rect = btn.getBoundingClientRect();
3627
- if ((columnMenuState == null ? void 0 : columnMenuState.x) === x) {
3780
+ if ((columnMenuState == null ? void 0 : columnMenuState.x) === x2) {
3628
3781
  dispatch(setColumnMenu(null));
3629
3782
  } else {
3630
- const alreadySelected = between({ start: selectingZone.startX, end: selectingZone.endX }, x) && selectingZone.startY === 1 && selectingZone.endY === sheet.numRows;
3783
+ const alreadySelected = Vr({ start: selectingZone.startX, end: selectingZone.endX }, x2) && selectingZone.startY === 1 && selectingZone.endY === sheet.numRows;
3631
3784
  if (!alreadySelected) {
3632
- dispatch(selectCols({ range: { start: x, end: x }, numRows: sheet.numRows }));
3785
+ dispatch(selectCols({ range: { start: x2, end: x2 }, numRows: sheet.numRows }));
3633
3786
  }
3634
- dispatch(setColumnMenu({ x, position: { y: rect.bottom, x: rect.left } }));
3787
+ dispatch(setColumnMenu({ x: x2, position: { y: rect.bottom, x: rect.left } }));
3635
3788
  }
3636
3789
  },
3637
3790
  children: "⋮"
@@ -3642,7 +3795,7 @@ const HeaderCellTop = memo(({ x }) => {
3642
3795
  {
3643
3796
  className: `
3644
3797
  gs-resizer
3645
- ${operations.hasOperation(col == null ? void 0 : col.prevention, operations.Resize) ? "gs-protected" : ""}
3798
+ ${pn.hasOperation(col == null ? void 0 : col.prevention, pn.Resize) ? "gs-protected" : ""}
3646
3799
  ${dragging ? "gs-hidden" : ""}`,
3647
3800
  style: { height: sheet.headerHeight },
3648
3801
  onMouseDown: handleResizeMouseDown,
@@ -3656,7 +3809,7 @@ const HeaderCellTop = memo(({ x }) => {
3656
3809
  );
3657
3810
  });
3658
3811
  const HeaderCellLeft = memo(({ y }) => {
3659
- const rowId = `${y2r(y)}`;
3812
+ const rowId = `${Et(y)}`;
3660
3813
  const { store, dispatch } = useContext(Context);
3661
3814
  const {
3662
3815
  choosing,
@@ -3672,7 +3825,7 @@ const HeaderCellLeft = memo(({ y }) => {
3672
3825
  } = store;
3673
3826
  const sheet = sheetRef.current;
3674
3827
  const row = sheet == null ? void 0 : sheet.getCell({ y, x: 0 }, { resolution: "SYSTEM" });
3675
- const height = (row == null ? void 0 : row.height) || DEFAULT_HEIGHT;
3828
+ const height = (row == null ? void 0 : row.height) || J;
3676
3829
  const xSheetFocused = isXSheetFocused(store);
3677
3830
  const lastFocused = sheet == null ? void 0 : sheet.registry.lastFocused;
3678
3831
  const editingAnywhere = !!((sheet == null ? void 0 : sheet.registry.editingAddress) || editingAddress);
@@ -3708,7 +3861,7 @@ const HeaderCellLeft = memo(({ y }) => {
3708
3861
  dispatch(select({ startY: y, startX: 1, endY: y, endX: -1 }));
3709
3862
  const fullAddress = `${sheet.sheetPrefix(!xSheetFocused)}${rowId}:${rowId}`;
3710
3863
  if (editingAnywhere) {
3711
- const inserted = insertRef({ input: lastFocused || null, ref: fullAddress });
3864
+ const inserted = Y({ input: lastFocused || null, ref: fullAddress });
3712
3865
  if (inserted) {
3713
3866
  dispatch(select({ startY: y, startX: sheet.numCols, endY: y, endX: 0 }));
3714
3867
  return false;
@@ -3729,7 +3882,7 @@ const HeaderCellLeft = memo(({ y }) => {
3729
3882
  }
3730
3883
  dispatch(setEditingAddress(""));
3731
3884
  dispatch(setDragging(true));
3732
- focus(editorRef.current);
3885
+ j(editorRef.current);
3733
3886
  if (autofillDraggingTo) {
3734
3887
  return false;
3735
3888
  }
@@ -3756,7 +3909,7 @@ const HeaderCellLeft = memo(({ y }) => {
3756
3909
  safePreventDefault(e);
3757
3910
  dispatch(setDragging(false));
3758
3911
  if (autofillDraggingTo) {
3759
- focus(editorRef.current);
3912
+ j(editorRef.current);
3760
3913
  return false;
3761
3914
  }
3762
3915
  },
@@ -3776,10 +3929,10 @@ const HeaderCellLeft = memo(({ y }) => {
3776
3929
  return false;
3777
3930
  }
3778
3931
  if (editingAnywhere) {
3779
- const newArea = zoneToArea({ ...selectingZone, endY: y, endX: 1 });
3780
- const [top, bottom] = [y2r(newArea.top), y2r(newArea.bottom)];
3932
+ const newArea = Rs({ ...selectingZone, endY: y, endX: 1 });
3933
+ const [top, bottom] = [Et(newArea.top), Et(newArea.bottom)];
3781
3934
  const fullRange = `${sheet.sheetPrefix(!xSheetFocused)}${top}:${bottom}`;
3782
- insertRef({ input: lastFocused || null, ref: fullRange });
3935
+ Y({ input: lastFocused || null, ref: fullRange });
3783
3936
  }
3784
3937
  if (autofillDraggingTo == null) {
3785
3938
  const { startX } = selectingZone;
@@ -3810,7 +3963,7 @@ const HeaderCellLeft = memo(({ y }) => {
3810
3963
  "th",
3811
3964
  {
3812
3965
  "data-y": y,
3813
- className: `gs-th gs-th-left ${choosing.y === y ? "gs-choosing" : ""} ${between({ 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" : ""}`,
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" : ""}`,
3814
3967
  style: { ...row == null ? void 0 : row.style, height },
3815
3968
  onContextMenu: handleContextMenu,
3816
3969
  children: /* @__PURE__ */ jsx(
@@ -3832,8 +3985,8 @@ const HeaderCellLeft = memo(({ y }) => {
3832
3985
  horizontal: -1
3833
3986
  }
3834
3987
  ),
3835
- getLabel(sheet, row == null ? void 0 : row.label, { y, x: 0 }, y) ?? rowId,
3836
- !operations.hasOperation(row == null ? void 0 : row.prevention, operations.RowMenu) && /* @__PURE__ */ jsx(
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(
3837
3990
  "button",
3838
3991
  {
3839
3992
  className: `gs-menu-btn gs-row-menu-btn ${(rowMenuState == null ? void 0 : rowMenuState.y) === y ? "gs-active" : ""}`,
@@ -3856,7 +4009,7 @@ const HeaderCellLeft = memo(({ y }) => {
3856
4009
  if ((rowMenuState == null ? void 0 : rowMenuState.y) === y) {
3857
4010
  dispatch(setRowMenu(null));
3858
4011
  } else {
3859
- const alreadySelected = between({ start: selectingZone.startY, end: selectingZone.endY }, y) && selectingZone.startX === 1 && selectingZone.endX === sheet.numCols;
4012
+ const alreadySelected = Vr({ start: selectingZone.startY, end: selectingZone.endY }, y) && selectingZone.startX === 1 && selectingZone.endX === sheet.numCols;
3860
4013
  if (!alreadySelected) {
3861
4014
  dispatch(selectRows({ range: { start: y, end: y }, numCols: sheet.numCols }));
3862
4015
  }
@@ -3871,7 +4024,7 @@ const HeaderCellLeft = memo(({ y }) => {
3871
4024
  {
3872
4025
  className: `
3873
4026
  gs-resizer
3874
- ${operations.hasOperation(row == null ? void 0 : row.prevention, operations.Resize) ? "gs-protected" : ""}
4027
+ ${pn.hasOperation(row == null ? void 0 : row.prevention, pn.Resize) ? "gs-protected" : ""}
3875
4028
  ${dragging ? "gs-hidden" : ""}`,
3876
4029
  style: { width: sheet.headerWidth },
3877
4030
  onMouseDown: handleResizeMouseDown
@@ -3891,19 +4044,19 @@ const COLOR_CUTTING = "#0077ff";
3891
4044
  const SEARCH_MATCHING_BACKGROUND = "rgba(0, 200, 100, 0.2)";
3892
4045
  const COLOR_SEARCH_MATCHING = "#00aa78";
3893
4046
  const COLOR_AUTOFILL = "#0077aa";
3894
- const fillRect = (ctx, x, y, width, height, color) => {
4047
+ const fillRect = (ctx, x2, y, width, height, color) => {
3895
4048
  ctx.fillStyle = color;
3896
- ctx.fillRect(x, y, width, height);
4049
+ ctx.fillRect(x2, y, width, height);
3897
4050
  };
3898
- const drawRect = (ctx, x, y, width, height, color, lineWidth = 2, dashPattern = [], fillColor) => {
4051
+ const drawRect = (ctx, x2, y, width, height, color, lineWidth = 2, dashPattern = [], fillColor) => {
3899
4052
  if (fillColor) {
3900
4053
  ctx.fillStyle = fillColor;
3901
- ctx.fillRect(x, y, width, height);
4054
+ ctx.fillRect(x2, y, width, height);
3902
4055
  }
3903
4056
  ctx.strokeStyle = color;
3904
4057
  ctx.lineWidth = lineWidth;
3905
4058
  ctx.setLineDash(dashPattern);
3906
- ctx.strokeRect(x + lineWidth / 2, y + lineWidth / 2, width - lineWidth, height - lineWidth);
4059
+ ctx.strokeRect(x2 + lineWidth / 2, y + lineWidth / 2, width - lineWidth, height - lineWidth);
3907
4060
  ctx.setLineDash([]);
3908
4061
  };
3909
4062
  const drawAreaRectViewport = (ctx, sheet, scrollTop, scrollLeft, viewW, viewH, area, color, lineWidth = 2, dashPattern = [], fillColor) => {
@@ -3911,8 +4064,8 @@ const drawAreaRectViewport = (ctx, sheet, scrollTop, scrollLeft, viewW, viewH, a
3911
4064
  if (top === -1 || left === -1 || bottom === -1 || right === -1) {
3912
4065
  return;
3913
4066
  }
3914
- const topLeft = getCellRectPositions(sheet, { y: top, x: left });
3915
- const bottomRight = getCellRectPositions(sheet, { y: bottom, x: right });
4067
+ const topLeft = O(sheet, { y: top, x: left });
4068
+ const bottomRight = O(sheet, { y: bottom, x: right });
3916
4069
  const x1 = topLeft.left - scrollLeft;
3917
4070
  const y1 = topLeft.top - scrollTop;
3918
4071
  const x2 = bottomRight.right - scrollLeft;
@@ -3972,16 +4125,16 @@ const CellStateOverlay = ({ refs = {} }) => {
3972
4125
  ctx.beginPath();
3973
4126
  ctx.rect(headerW, headerH, w - headerW, h2 - headerH);
3974
4127
  ctx.clip();
3975
- const selectingArea = zoneToArea(selectingZone);
4128
+ const selectingArea = Rs(selectingZone);
3976
4129
  drawAreaRectViewport(ctx, sheet, scrollTop, scrollLeft, w, h2, selectingArea, COLOR_SELECTED, 1, [], SELECTING_FILL);
3977
4130
  if (autofillDraggingTo) {
3978
- const autofill = new Autofill(storeRef.current, autofillDraggingTo);
4131
+ const autofill = new En(storeRef.current, autofillDraggingTo);
3979
4132
  drawAreaRectViewport(ctx, sheet, scrollTop, scrollLeft, w, h2, autofill.wholeArea, COLOR_AUTOFILL, 1, [5, 5]);
3980
4133
  }
3981
4134
  {
3982
- const { y, x } = choosing;
3983
- if (y !== -1 && x !== -1) {
3984
- const pos = getCellRectPositions(sheet, { y, x });
4135
+ const { y, x: x2 } = choosing;
4136
+ if (y !== -1 && x2 !== -1) {
4137
+ const pos = O(sheet, { y, x: x2 });
3985
4138
  const vx = pos.left - scrollLeft;
3986
4139
  const vy = pos.top - scrollTop;
3987
4140
  drawRect(ctx, vx, vy, pos.width, pos.height, COLOR_POINTED, 2, []);
@@ -3989,13 +4142,13 @@ const CellStateOverlay = ({ refs = {} }) => {
3989
4142
  }
3990
4143
  const { copyingSheetId, copyingZone, cutting } = registry;
3991
4144
  if (sheet.id === copyingSheetId) {
3992
- const copyingArea = zoneToArea(copyingZone);
4145
+ const copyingArea = Rs(copyingZone);
3993
4146
  const color = cutting ? COLOR_CUTTING : COLOR_COPYING;
3994
4147
  const dashPattern = cutting ? [4, 4] : [6, 4];
3995
4148
  drawAreaRectViewport(ctx, sheet, scrollTop, scrollLeft, w, h2, copyingArea, color, 2.5, dashPattern);
3996
4149
  }
3997
4150
  Object.entries(refs).forEach(([ref, i]) => {
3998
- const palette = COLOR_PALETTE[i % COLOR_PALETTE.length];
4151
+ const palette = _n[i % _n.length];
3999
4152
  try {
4000
4153
  const refArea = sheet.rangeToArea(ref);
4001
4154
  drawAreaRectViewport(ctx, sheet, scrollTop, scrollLeft, w, h2, refArea, palette, 2, [5, 5]);
@@ -4003,8 +4156,8 @@ const CellStateOverlay = ({ refs = {} }) => {
4003
4156
  }
4004
4157
  });
4005
4158
  matchingCells.forEach((address, index) => {
4006
- const { y, x } = a2p(address);
4007
- const pos = getCellRectPositions(sheet, { y, x });
4159
+ const { y, x: x2 } = N$1(address);
4160
+ const pos = O(sheet, { y, x: x2 });
4008
4161
  const vx = pos.left - scrollLeft;
4009
4162
  const vy = pos.top - scrollTop;
4010
4163
  if (vx + pos.width < 0 || vx > w || vy + pos.height < 0 || vy > h2) {
@@ -4026,21 +4179,21 @@ const CellStateOverlay = ({ refs = {} }) => {
4026
4179
  ctx.restore();
4027
4180
  const numCols = sheet.numCols;
4028
4181
  const numRows = sheet.numRows;
4029
- for (let x = 1; x <= numCols; x++) {
4182
+ for (let x2 = 1; x2 <= numCols; x2++) {
4030
4183
  let color = null;
4031
4184
  let backgroundColor = null;
4032
- if (between({ start: selectingZone.startX, end: selectingZone.endX }, x)) {
4185
+ if (Vr({ start: selectingZone.startX, end: selectingZone.endX }, x2)) {
4033
4186
  color = "rgba(80, 180, 255, 1)";
4034
4187
  backgroundColor = topHeaderSelecting ? "rgba(128, 128, 128, 0.25)" : "rgba(0, 119, 255, 0.05)";
4035
4188
  }
4036
- if (choosing.x === x) {
4189
+ if (choosing.x === x2) {
4037
4190
  color = COLOR_POINTED;
4038
4191
  backgroundColor = topHeaderSelecting ? "rgba(128, 128, 128, 0.45)" : "rgba(0, 119, 255, 0.15)";
4039
4192
  }
4040
4193
  if (!color) {
4041
4194
  continue;
4042
4195
  }
4043
- const pos = getCellRectPositions(sheet, { y: 1, x });
4196
+ const pos = O(sheet, { y: 1, x: x2 });
4044
4197
  const left = pos.left - scrollLeft;
4045
4198
  if (left + pos.width < headerW || left > w) {
4046
4199
  continue;
@@ -4065,7 +4218,7 @@ const CellStateOverlay = ({ refs = {} }) => {
4065
4218
  }
4066
4219
  let color = null;
4067
4220
  let backgroundColor = null;
4068
- if (between({ start: selectingZone.startY, end: selectingZone.endY }, y)) {
4221
+ if (Vr({ start: selectingZone.startY, end: selectingZone.endY }, y)) {
4069
4222
  color = "rgba(80, 180, 255, 1)";
4070
4223
  backgroundColor = leftHeaderSelecting ? "rgba(128, 128, 128, 0.25)" : "rgba(0, 119, 255, 0.05)";
4071
4224
  }
@@ -4076,7 +4229,7 @@ const CellStateOverlay = ({ refs = {} }) => {
4076
4229
  if (!color) {
4077
4230
  continue;
4078
4231
  }
4079
- const pos = getCellRectPositions(sheet, { y, x: 1 });
4232
+ const pos = O(sheet, { y, x: 1 });
4080
4233
  const top = pos.top - scrollTop;
4081
4234
  if (top + pos.height < headerH || top > h2) {
4082
4235
  continue;
@@ -4165,7 +4318,7 @@ const CellStateOverlay = ({ refs = {} }) => {
4165
4318
  );
4166
4319
  };
4167
4320
  const Tabular = () => {
4168
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
4321
+ var _a, _b, _c, _d, _e2, _f, _g, _h, _i;
4169
4322
  const [palette, setPalette] = useState({});
4170
4323
  const { store, dispatch } = useContext(Context);
4171
4324
  const {
@@ -4176,6 +4329,8 @@ const Tabular = () => {
4176
4329
  mainRef,
4177
4330
  sheetWidth,
4178
4331
  sheetHeight,
4332
+ fixedWidth,
4333
+ fixedHeight,
4179
4334
  inputting,
4180
4335
  leftHeaderSelecting,
4181
4336
  topHeaderSelecting,
@@ -4183,6 +4338,24 @@ const Tabular = () => {
4183
4338
  } = store;
4184
4339
  const sheet = sheetReactive.current;
4185
4340
  const [virtualized, setVirtualized] = useState(null);
4341
+ useEffect(() => {
4342
+ const t = tabularRef.current;
4343
+ const m = mainRef.current;
4344
+ if (!t || !m) {
4345
+ return;
4346
+ }
4347
+ const raf = requestAnimationFrame(() => {
4348
+ const ox = String(t.scrollWidth > t.clientWidth + 1);
4349
+ const oy = String(t.scrollHeight > t.clientHeight + 1);
4350
+ if (m.getAttribute("data-overflow-x") !== ox) {
4351
+ m.setAttribute("data-overflow-x", ox);
4352
+ }
4353
+ if (m.getAttribute("data-overflow-y") !== oy) {
4354
+ m.setAttribute("data-overflow-y", oy);
4355
+ }
4356
+ });
4357
+ return () => cancelAnimationFrame(raf);
4358
+ });
4186
4359
  const handleMouseMove = useCallback((e) => {
4187
4360
  e.preventDefault();
4188
4361
  e.stopPropagation();
@@ -4190,7 +4363,7 @@ const Tabular = () => {
4190
4363
  const handleScroll = useCallback(
4191
4364
  (e) => {
4192
4365
  if (sheet) {
4193
- setVirtualized(virtualize(sheet, e.currentTarget));
4366
+ setVirtualized(q(sheet, e.currentTarget));
4194
4367
  }
4195
4368
  },
4196
4369
  [sheetReactive]
@@ -4224,17 +4397,17 @@ const Tabular = () => {
4224
4397
  }
4225
4398
  const palette2 = {};
4226
4399
  const paletteBySheetName = {};
4227
- const lexer = new Lexer(inputting.substring(1));
4400
+ const lexer = new $t(inputting.substring(1));
4228
4401
  lexer.tokenize();
4229
4402
  let i = 0;
4230
4403
  for (const token of lexer.tokens) {
4231
4404
  if (token.type === "REF" || token.type === "RANGE") {
4232
- const normalizedRef = stripAddressAbsolute(token.stringify());
4405
+ const normalizedRef = Br(token.stringify());
4233
4406
  const splitterIndex = normalizedRef.indexOf("!");
4234
4407
  if (splitterIndex !== -1) {
4235
4408
  const sheetName = normalizedRef.substring(0, splitterIndex);
4236
4409
  const ref = normalizedRef.substring(splitterIndex + 1);
4237
- const stripped = stripSheetName(sheetName);
4410
+ const stripped = on(sheetName);
4238
4411
  const upperRef = ref.toUpperCase();
4239
4412
  if (paletteBySheetName[stripped] == null) {
4240
4413
  paletteBySheetName[stripped] = {};
@@ -4257,14 +4430,14 @@ const Tabular = () => {
4257
4430
  if (!sheet) {
4258
4431
  return;
4259
4432
  }
4260
- sheet.registry.choosingAddress = p2a(choosing);
4433
+ sheet.registry.choosingAddress = D(choosing);
4261
4434
  sheet.registry.choosingSheetId = sheet.id;
4262
4435
  }, [choosing]);
4263
4436
  useEffect(() => {
4264
4437
  if (!sheet) {
4265
4438
  return;
4266
4439
  }
4267
- setVirtualized(virtualize(sheet, tabularRef.current));
4440
+ setVirtualized(q(sheet, tabularRef.current));
4268
4441
  }, [
4269
4442
  tabularRef.current,
4270
4443
  sheetReactive,
@@ -4278,7 +4451,7 @@ const Tabular = () => {
4278
4451
  if (!el) {
4279
4452
  return;
4280
4453
  }
4281
- return preventSafariBounce(el);
4454
+ return $(el);
4282
4455
  }, [sheetReactive]);
4283
4456
  useEffect(() => {
4284
4457
  if (!sheet || !sheet.eager || !sheet.registry.ready) {
@@ -4298,8 +4471,10 @@ const Tabular = () => {
4298
4471
  {
4299
4472
  className: "gs-tabular",
4300
4473
  style: {
4301
- width: sheetWidth === -1 ? void 0 : Math.min(sheetWidth, sheet.totalWidth),
4302
- height: sheetHeight === -1 ? void 0 : Math.min(sheetHeight, sheet.totalHeight)
4474
+ // When a size is explicitly configured, keep that box so a smaller grid can be
4475
+ // centered within it (see .gs-tabular in tabular.less); otherwise shrink to fit.
4476
+ width: sheetWidth === -1 ? void 0 : fixedWidth ? sheetWidth : Math.min(sheetWidth, sheet.totalWidth),
4477
+ height: sheetHeight === -1 ? void 0 : fixedHeight ? sheetHeight : Math.min(sheetHeight, sheet.totalHeight)
4303
4478
  },
4304
4479
  ref: tabularRef,
4305
4480
  onMouseMove: handleMouseMove,
@@ -4368,7 +4543,7 @@ const Tabular = () => {
4368
4543
  style: { width: ((_c = virtualized == null ? void 0 : virtualized.adjuster) == null ? void 0 : _c.left) ?? 1 }
4369
4544
  }
4370
4545
  ),
4371
- (_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)),
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)),
4372
4547
  /* @__PURE__ */ jsx(
4373
4548
  "th",
4374
4549
  {
@@ -4386,7 +4561,7 @@ const Tabular = () => {
4386
4561
  }
4387
4562
  ),
4388
4563
  /* @__PURE__ */ jsx("td", { className: "gs-adjuster gs-adjuster-vertical" }),
4389
- (_h = virtualized == null ? void 0 : virtualized.xs) == null ? void 0 : _h.map((x) => /* @__PURE__ */ jsx("td", { className: "gs-adjuster gs-adjuster-vertical" }, x)),
4564
+ (_h = virtualized == null ? void 0 : virtualized.xs) == null ? void 0 : _h.map((x2) => /* @__PURE__ */ jsx("td", { className: "gs-adjuster gs-adjuster-vertical" }, x2)),
4390
4565
  /* @__PURE__ */ jsx("th", { className: `gs-adjuster gs-adjuster-horizontal gs-adjuster-vertical` })
4391
4566
  ] }) }),
4392
4567
  /* @__PURE__ */ jsx("tbody", { className: "gs-sheet-body-data", children: (_i = virtualized == null ? void 0 : virtualized.ys) == null ? void 0 : _i.map((y) => {
@@ -4394,7 +4569,7 @@ const Tabular = () => {
4394
4569
  return /* @__PURE__ */ jsxs("tr", { className: `gs-row ${y % 2 === 0 ? "gs-row-even" : "gs-row-odd"}`, children: [
4395
4570
  /* @__PURE__ */ jsx(HeaderCellLeft, { y }),
4396
4571
  /* @__PURE__ */ jsx("td", { className: "gs-adjuster gs-adjuster-horizontal gs-adjuster-horizontal-left" }),
4397
- (_a2 = virtualized == null ? void 0 : virtualized.xs) == null ? void 0 : _a2.map((x) => /* @__PURE__ */ jsx(Cell, { y, x }, x)),
4572
+ (_a2 = virtualized == null ? void 0 : virtualized.xs) == null ? void 0 : _a2.map((x2) => /* @__PURE__ */ jsx(Cell, { y, x: x2 }, x2)),
4398
4573
  /* @__PURE__ */ jsx("td", { className: "gs-adjuster gs-adjuster-horizontal gs-adjuster-horizontal-right" })
4399
4574
  ] }, y);
4400
4575
  }) })
@@ -4423,11 +4598,11 @@ const FormulaBar = ({ ready }) => {
4423
4598
  } = store;
4424
4599
  const sheet = sheetRef.current;
4425
4600
  const hlRef = useRef(null);
4426
- const address = choosing.x === -1 ? "" : p2a(choosing);
4601
+ const address = choosing.x === -1 ? "" : D(choosing);
4427
4602
  const cell = sheet == null ? void 0 : sheet.getCell(choosing, { resolution: "SYSTEM" });
4428
4603
  const spilledFromAddress = (_a = sheet == null ? void 0 : sheet.getSystem(choosing)) == null ? void 0 : _a.spilledFrom;
4429
- const originPoint = spilledFromAddress ? a2p(spilledFromAddress) : void 0;
4430
- const originAddress = originPoint != null ? p2a(originPoint) : void 0;
4604
+ const originPoint = spilledFromAddress ? N$1(spilledFromAddress) : void 0;
4605
+ const originAddress = originPoint != null ? D(originPoint) : void 0;
4431
4606
  useEffect(() => {
4432
4607
  var _a2;
4433
4608
  if (!sheet) {
@@ -4444,7 +4619,7 @@ const FormulaBar = ({ ready }) => {
4444
4619
  dispatch(write({ value }));
4445
4620
  }
4446
4621
  dispatch(setEditingAddress(""));
4447
- focus(editorRef.current);
4622
+ j(editorRef.current);
4448
4623
  },
4449
4624
  [before]
4450
4625
  );
@@ -4525,10 +4700,6 @@ const FormulaBar = ({ ready }) => {
4525
4700
  return true;
4526
4701
  }
4527
4702
  const input = e.currentTarget;
4528
- if (handleFormulaQuoteAutoClose(e, inputting)) {
4529
- dispatch(setInputting(input.value));
4530
- return false;
4531
- }
4532
4703
  switch (e.key) {
4533
4704
  case "Tab":
4534
4705
  e.preventDefault();
@@ -4540,7 +4711,7 @@ const FormulaBar = ({ ready }) => {
4540
4711
  dispatch(setInputting(newValue));
4541
4712
  setTimeout(() => {
4542
4713
  if (largeEditorRef.current) {
4543
- focus(largeEditorRef.current);
4714
+ j(largeEditorRef.current);
4544
4715
  largeEditorRef.current.setSelectionRange(newCursor, newCursor);
4545
4716
  }
4546
4717
  }, 0);
@@ -4571,7 +4742,7 @@ const FormulaBar = ({ ready }) => {
4571
4742
  dispatch(setInputting(newValue));
4572
4743
  setTimeout(() => {
4573
4744
  if (largeEditorRef.current) {
4574
- focus(largeEditorRef.current);
4745
+ j(largeEditorRef.current);
4575
4746
  largeEditorRef.current.setSelectionRange(newCursor, newCursor);
4576
4747
  }
4577
4748
  }, 0);
@@ -4580,7 +4751,7 @@ const FormulaBar = ({ ready }) => {
4580
4751
  }
4581
4752
  }
4582
4753
  if (e.altKey) {
4583
- insertTextAtCursor(input, "\n");
4754
+ v(input, "\n");
4584
4755
  } else {
4585
4756
  writeCell(input.value);
4586
4757
  dispatch(setInputting(""));
@@ -4602,7 +4773,7 @@ const FormulaBar = ({ ready }) => {
4602
4773
  dispatch(setInputting(before));
4603
4774
  dispatch(setEditingAddress(""));
4604
4775
  e.preventDefault();
4605
- focus(editorRef.current);
4776
+ j(editorRef.current);
4606
4777
  break;
4607
4778
  }
4608
4779
  case "a":
@@ -4621,7 +4792,7 @@ const FormulaBar = ({ ready }) => {
4621
4792
  break;
4622
4793
  }
4623
4794
  const cell2 = sheet.getCell(choosing, { resolution: "SYSTEM" });
4624
- if (operations.hasOperation(cell2 == null ? void 0 : cell2.prevention, operations.Write)) {
4795
+ if (pn.hasOperation(cell2 == null ? void 0 : cell2.prevention, pn.Write)) {
4625
4796
  console.warn("This cell is protected from writing.");
4626
4797
  e.preventDefault();
4627
4798
  }
@@ -4654,7 +4825,7 @@ const FormulaBar = ({ ready }) => {
4654
4825
  dispatch(setInputting(newValue));
4655
4826
  setTimeout(() => {
4656
4827
  if (largeEditorRef.current) {
4657
- focus(largeEditorRef.current);
4828
+ j(largeEditorRef.current);
4658
4829
  largeEditorRef.current.setSelectionRange(newCursor, newCursor);
4659
4830
  }
4660
4831
  }, 0);
@@ -4666,7 +4837,7 @@ const FormulaBar = ({ ready }) => {
4666
4837
  if (!sheet) {
4667
4838
  return /* @__PURE__ */ jsxs("label", { className: "gs-formula-bar gs-hidden", style, children: [
4668
4839
  /* @__PURE__ */ jsx("div", { className: "gs-selecting-address" }),
4669
- /* @__PURE__ */ jsx("div", { className: "gs-fx", children: "Fx" }),
4840
+ /* @__PURE__ */ jsx("div", { className: "gs-fx", children: "fx" }),
4670
4841
  /* @__PURE__ */ jsx("div", { className: "gs-formula-bar-editor-inner", children: /* @__PURE__ */ jsx("textarea", {}) })
4671
4842
  ] });
4672
4843
  }
@@ -4719,7 +4890,7 @@ const FormulaBar = ({ ready }) => {
4719
4890
  children: [
4720
4891
  /* @__PURE__ */ jsx(ScrollHandle, { style: { position: "absolute", left: 0, top: 0, zIndex: 2 }, vertical: -1 }),
4721
4892
  /* @__PURE__ */ jsx("div", { className: "gs-selecting-address", children: originAddress != null ? originAddress : address }),
4722
- /* @__PURE__ */ jsx("div", { className: "gs-fx", children: "Fx" }),
4893
+ /* @__PURE__ */ jsx("div", { className: "gs-fx", children: "fx" }),
4723
4894
  /* @__PURE__ */ jsxs("div", { className: "gs-formula-bar-editor-inner", children: [
4724
4895
  /* @__PURE__ */ jsx(
4725
4896
  "div",
@@ -4829,15 +5000,15 @@ const SearchBar = () => {
4829
5000
  if (!matchingCell || !sheet) {
4830
5001
  return;
4831
5002
  }
4832
- const point = a2p(matchingCell);
5003
+ const point = N$1(matchingCell);
4833
5004
  if (typeof point === "undefined") {
4834
5005
  return;
4835
5006
  }
4836
- smartScroll(sheet, tabularRef.current, point);
5007
+ G(sheet, tabularRef.current, point);
4837
5008
  }, [searchQuery, matchingCellIndex, searchCaseSensitive, searchRegex, sheet, tabularRef]);
4838
5009
  const handleProgressClick = useCallback((e) => {
4839
5010
  const input = e.currentTarget.previousSibling;
4840
- (input == null ? void 0 : input.nodeName) === "INPUT" && focus(input);
5011
+ (input == null ? void 0 : input.nodeName) === "INPUT" && j(input);
4841
5012
  }, []);
4842
5013
  const handleSearchClick = useCallback(() => {
4843
5014
  dispatch(search(1));
@@ -4850,7 +5021,7 @@ const SearchBar = () => {
4850
5021
  if (e.key === "Escape") {
4851
5022
  const el = editorRef == null ? void 0 : editorRef.current;
4852
5023
  if (el) {
4853
- focus(el);
5024
+ j(el);
4854
5025
  }
4855
5026
  dispatch(setSearchQuery(void 0));
4856
5027
  }
@@ -4877,7 +5048,7 @@ const SearchBar = () => {
4877
5048
  if (!selectingZone) {
4878
5049
  return false;
4879
5050
  }
4880
- if (isZoneNotSelected(selectingZone)) {
5051
+ if (rn(selectingZone)) {
4881
5052
  return false;
4882
5053
  }
4883
5054
  const { startY, startX, endY, endX } = selectingZone;
@@ -4888,8 +5059,8 @@ const SearchBar = () => {
4888
5059
  return "";
4889
5060
  }
4890
5061
  const { startY, startX, endY, endX } = selectingZone;
4891
- const topLeft = `${x2c(Math.min(startX, endX))}${y2r(Math.min(startY, endY))}`;
4892
- const bottomRight = `${x2c(Math.max(startX, endX))}${y2r(Math.max(startY, endY))}`;
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))}`;
4893
5064
  return `${topLeft}:${bottomRight}`;
4894
5065
  }, [selectingZone, hasSelection]);
4895
5066
  const handleRangeClick = useCallback(() => {
@@ -4912,13 +5083,13 @@ const SearchBar = () => {
4912
5083
  return "";
4913
5084
  }
4914
5085
  const { startY, startX, endY, endX } = searchRange;
4915
- const topLeft = `${x2c(startX)}${y2r(startY)}`;
4916
- const bottomRight = `${x2c(endX)}${y2r(endY)}`;
5086
+ const topLeft = `${W(startX)}${Et(startY)}`;
5087
+ const bottomRight = `${W(endX)}${Et(endY)}`;
4917
5088
  return `${topLeft}:${bottomRight}`;
4918
5089
  }, [searchRange]);
4919
5090
  const handleCloseClick = useCallback(() => {
4920
5091
  dispatch(setSearchQuery(void 0));
4921
- focus(editorRef.current);
5092
+ j(editorRef.current);
4922
5093
  }, [editorRef]);
4923
5094
  if (typeof searchQuery === "undefined") {
4924
5095
  return null;
@@ -5004,7 +5175,26 @@ function GridSheet({
5004
5175
  book: initialBook
5005
5176
  }) {
5006
5177
  var _a, _b, _c;
5007
- const { sheetResize, showFormulaBar = true, mode = "light" } = options;
5178
+ const {
5179
+ sheetResize,
5180
+ showFormulaBar = true,
5181
+ mode = "light",
5182
+ density = "compact",
5183
+ gridLines = "all",
5184
+ formulaBarBorders = { all: true },
5185
+ matrixBorders = { all: true }
5186
+ } = options;
5187
+ const bw = (b, side) => b[side] ?? b.all ?? false ? "1px" : "0";
5188
+ 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")
5197
+ };
5008
5198
  const rootRef = useRef(null);
5009
5199
  const flashRef = useRef(null);
5010
5200
  const mainRef = useRef(null);
@@ -5036,7 +5226,7 @@ function GridSheet({
5036
5226
  console.debug("GridSheet: sheetName is not provided, using default name:", sheetName);
5037
5227
  }
5038
5228
  const { limits, contextMenu, rowMenu, colMenu, eager } = options;
5039
- const sheet = new Sheet({
5229
+ const sheet = new $$1({
5040
5230
  limits,
5041
5231
  name: sheetName,
5042
5232
  registry,
@@ -5069,6 +5259,8 @@ function GridSheet({
5069
5259
  dragging: false,
5070
5260
  sheetHeight: 0,
5071
5261
  sheetWidth: 0,
5262
+ fixedWidth: false,
5263
+ fixedHeight: false,
5072
5264
  entering: false,
5073
5265
  matchingCells: [],
5074
5266
  matchingCellIndex: 0,
@@ -5094,10 +5286,17 @@ function GridSheet({
5094
5286
  () => initialState
5095
5287
  );
5096
5288
  useEffect(() => {
5097
- embedStyle();
5289
+ re();
5098
5290
  }, []);
5099
5291
  const fillWidth = typeof options.sheetWidth === "string";
5100
5292
  const fillHeight = typeof options.sheetHeight === "string";
5293
+ const matrixAlignment = options.matrixAlignment ?? "none";
5294
+ const centersWidth = matrixAlignment === "horizontal" || matrixAlignment === "both";
5295
+ const centersHeight = matrixAlignment === "vertical" || matrixAlignment === "both";
5296
+ const [resizedWidth, setResizedWidth] = useState(false);
5297
+ const [resizedHeight, setResizedHeight] = useState(false);
5298
+ const fixedWidth = centersWidth && (options.sheetWidth != null || resizedWidth);
5299
+ const fixedHeight = centersHeight && (options.sheetHeight != null || resizedHeight);
5101
5300
  const [sheetHeight, setSheetHeight] = useState(
5102
5301
  typeof (options == null ? void 0 : options.sheetHeight) === "number" ? options.sheetHeight : estimateSheetHeight(initialCells)
5103
5302
  );
@@ -5111,6 +5310,12 @@ function GridSheet({
5111
5310
  }
5112
5311
  let first = true;
5113
5312
  const ro = new ResizeObserver(() => {
5313
+ if (el.style.width) {
5314
+ setResizedWidth(true);
5315
+ }
5316
+ if (el.style.height) {
5317
+ setResizedHeight(true);
5318
+ }
5114
5319
  if (first) {
5115
5320
  first = false;
5116
5321
  if (!fillWidth && !fillHeight) {
@@ -5160,15 +5365,19 @@ function GridSheet({
5160
5365
  ref: rootRef,
5161
5366
  "data-sheet-name": sheetName,
5162
5367
  "data-mode": mode,
5368
+ "data-density": density,
5369
+ "data-gridlines": gridLines,
5370
+ "data-matrix-align": matrixAlignment,
5163
5371
  "data-rows": ((_a = store.sheetReactive.current) == null ? void 0 : _a.numRows) ?? 0,
5164
5372
  "data-cols": ((_b = store.sheetReactive.current) == null ? void 0 : _b.numCols) ?? 0,
5165
5373
  style: fillWidth || fillHeight ? {
5374
+ ...borderVars,
5166
5375
  // inline-flex (when width isn't filled) keeps the prior shrink-to-content width.
5167
5376
  display: fillWidth ? "flex" : "inline-flex",
5168
5377
  flexDirection: "column",
5169
5378
  ...fillWidth ? { width: options.sheetWidth } : null,
5170
5379
  ...fillHeight ? { height: options.sheetHeight } : null
5171
- } : void 0,
5380
+ } : borderVars,
5172
5381
  children: [
5173
5382
  /* @__PURE__ */ jsx("div", { className: "gs-flash-overlay", ref: flashRef }),
5174
5383
  /* @__PURE__ */ jsx(ScrollHandle, { style: { position: "fixed", top: 0, left: 0 } }),
@@ -5194,7 +5403,12 @@ function GridSheet({
5194
5403
  children: [
5195
5404
  /* @__PURE__ */ jsx(Editor, { mode }),
5196
5405
  /* @__PURE__ */ jsx(Tabular, {}),
5197
- /* @__PURE__ */ jsx(StoreObserver, { ...{ ...options, sheetHeight, sheetWidth, sheetName, sheetRef, storeRef } }),
5406
+ /* @__PURE__ */ jsx(
5407
+ StoreObserver,
5408
+ {
5409
+ ...{ ...options, sheetHeight, sheetWidth, fixedWidth, fixedHeight, sheetName, sheetRef, storeRef }
5410
+ }
5411
+ ),
5198
5412
  /* @__PURE__ */ jsx(ContextMenu, {}),
5199
5413
  /* @__PURE__ */ jsx(ColumnMenu, {}),
5200
5414
  /* @__PURE__ */ jsx(RowMenu, {}),
@@ -5209,28 +5423,28 @@ function GridSheet({
5209
5423
  ) });
5210
5424
  }
5211
5425
  const estimateSheetHeight = (initialCells) => {
5212
- var _a, _b, _c, _d, _e;
5213
- const auto = getMaxSizesFromCells(initialCells);
5214
- let estimatedHeight = ((_a = initialCells[0]) == null ? void 0 : _a.height) ?? HEADER_HEIGHT;
5426
+ var _a, _b, _c, _d, _e2;
5427
+ const auto = Cs(initialCells);
5428
+ let estimatedHeight = ((_a = initialCells[0]) == null ? void 0 : _a.height) ?? Re;
5215
5429
  for (let y = 1; y <= auto.numRows; y++) {
5216
- const row = y2r(y);
5217
- 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[DEFAULT_ROW_KEY]) == null ? void 0 : _d.height) || ((_e = initialCells == null ? void 0 : initialCells.default) == null ? void 0 : _e.height) || DEFAULT_HEIGHT;
5218
- if (estimatedHeight + height > SHEET_HEIGHT) {
5219
- return SHEET_HEIGHT;
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;
5220
5434
  }
5221
5435
  estimatedHeight += height;
5222
5436
  }
5223
5437
  return estimatedHeight + 3;
5224
5438
  };
5225
5439
  const estimateSheetWidth = (initialCells) => {
5226
- var _a, _b, _c, _d, _e;
5227
- const auto = getMaxSizesFromCells(initialCells);
5228
- let estimatedWidth = ((_a = initialCells[0]) == null ? void 0 : _a.width) ?? HEADER_WIDTH;
5229
- for (let x = 1; x <= auto.numCols; x++) {
5230
- const col = x2c(x);
5231
- 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[DEFAULT_COL_KEY]) == null ? void 0 : _d.width) || ((_e = initialCells == null ? void 0 : initialCells.default) == null ? void 0 : _e.width) || DEFAULT_WIDTH;
5232
- if (estimatedWidth + width > SHEET_WIDTH) {
5233
- return SHEET_WIDTH;
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;
5234
5448
  }
5235
5449
  estimatedWidth += width;
5236
5450
  }
@@ -5271,70 +5485,70 @@ function makeBorder(options) {
5271
5485
  return result;
5272
5486
  }
5273
5487
  export {
5274
- BaseFunction,
5275
- BaseFunctionAsync,
5488
+ b8 as BaseFunction,
5489
+ b9 as BaseFunctionAsync,
5276
5490
  CheckboxPolicyMixin,
5277
5491
  Children,
5278
5492
  Component,
5279
- DEFAULT_HISTORY_LIMIT,
5280
- FormulaError2 as FormulaError,
5281
- FormulaParser,
5493
+ bq as DEFAULT_HISTORY_LIMIT,
5494
+ x as FormulaError,
5495
+ ba as FormulaParser,
5282
5496
  Fragment2 as Fragment,
5283
5497
  GridSheet,
5284
- Lexer2 as Lexer,
5498
+ $t as Lexer,
5285
5499
  MenuDivider,
5286
5500
  MenuItem,
5287
- Pending2 as Pending,
5288
- PercentagePolicyMixin,
5501
+ k as Pending,
5502
+ bp as PercentagePolicyMixin,
5289
5503
  PluginBase,
5290
- Policy,
5504
+ bn as Policy,
5291
5505
  PureComponent,
5292
- RangeEntity,
5293
- RefEntity,
5294
- Registry,
5295
- Sheet2 as Sheet,
5296
- Spilling,
5506
+ bd as RangeEntity,
5507
+ bb as RefEntity,
5508
+ aZ as Registry,
5509
+ $$1 as Sheet,
5510
+ br as Spilling,
5297
5511
  StrictMode,
5298
5512
  Suspense,
5299
5513
  SuspenseList,
5300
- ThousandSeparatorPolicyMixin,
5301
- Time,
5302
- ValueEntity,
5303
- a2p2 as a2p,
5304
- aa2oa,
5305
- addressesToAreas,
5306
- addressesToCols,
5307
- addressesToRows,
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,
5308
5522
  applyers,
5309
- areaToRange2 as areaToRange,
5310
- areaToZone2 as areaToZone,
5311
- buildInitialCells,
5312
- buildInitialCellsFromOrigin,
5313
- c2x,
5314
- ch,
5315
- check,
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,
5316
5530
  clip,
5317
5531
  cloneElement,
5318
5532
  render2 as compatRender,
5319
- conditionArg,
5320
- createBook,
5321
- createBooleanMask,
5533
+ bl as conditionArg,
5534
+ a_ as createBook,
5535
+ bk as createBooleanMask,
5322
5536
  createContext2 as createContext,
5323
5537
  createElement,
5324
5538
  createFactory,
5325
5539
  createPortal2 as createPortal,
5326
5540
  createRef2 as createRef,
5327
- createRegistry,
5541
+ a$ as createRegistry,
5328
5542
  createSheetRef,
5329
5543
  createStoreRef,
5330
5544
  defaultColMenuDescriptors,
5331
5545
  defaultContextMenuDescriptors,
5332
5546
  defaultRowMenuDescriptors,
5333
- eachMatrix,
5334
- ensureBoolean,
5335
- ensureDate,
5336
- ensureNumber,
5337
- ensureString,
5547
+ bj as eachMatrix,
5548
+ bg as ensureBoolean,
5549
+ bh as ensureDate,
5550
+ bf as ensureNumber,
5551
+ be as ensureString,
5338
5552
  findDOMNode,
5339
5553
  forwardRef,
5340
5554
  h,
@@ -5342,25 +5556,25 @@ export {
5342
5556
  isValidElement,
5343
5557
  lazy,
5344
5558
  makeBorder,
5345
- matrixShape,
5559
+ aQ as matrixShape,
5346
5560
  memo2 as memo,
5347
- oa2aa,
5348
- operations2 as operations,
5349
- p2a2 as p2a,
5350
- r2y,
5561
+ aM as oa2aa,
5562
+ pn as operations,
5563
+ D as p2a,
5564
+ aW as r2y,
5351
5565
  registerMenuComponent,
5352
5566
  render,
5353
- rh,
5567
+ aX as rh,
5354
5568
  sheet2csv,
5355
- stripMatrix,
5356
- toCellCols,
5357
- toCellMatrix,
5358
- toCellObject,
5359
- toCellRows,
5360
- toValueCols,
5361
- toValueMatrix,
5362
- toValueObject,
5363
- toValueRows,
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,
5364
5578
  unmountComponentAtNode,
5365
5579
  unstable_batchedUpdates,
5366
5580
  updateSheet,
@@ -5379,10 +5593,10 @@ export {
5379
5593
  useSheetRef,
5380
5594
  useState2 as useState,
5381
5595
  useStoreRef,
5382
- X as userActions,
5596
+ bs as userActions,
5383
5597
  version,
5384
- x2c2 as x2c,
5385
- y2r2 as y2r,
5386
- zoneToArea2 as zoneToArea
5598
+ W as x2c,
5599
+ Et as y2r,
5600
+ Rs as zoneToArea
5387
5601
  };
5388
5602
  //# sourceMappingURL=index.js.map