@sheetxl/grid-react 0.4.22 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,54 +1,54 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._sheetxl-grid_h9wwa_7{position:relative;box-sizing:border-box;user-select:none}._sheetxl-grid_h9wwa_7 *{box-sizing:border-box!important}._sheetxl-grid_h9wwa_7 *:focus{outline:none}._sheetxl-grid_h9wwa_7 .cell-container{position:absolute;overflow:visible;white-space:pre}._sheetxl-grid_h9wwa_7 .cell-container>*{inset:0;position:absolute}._sheetxl-grid_h9wwa_7 .sheetxl-stage{contain:strict}._sheetxl-grid_h9wwa_7 .sheetxl-stage>*{contain:strict}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
- import { jsx as Ee, jsxs as Zt, Fragment as _n } from "react/jsx-runtime";
3
- import { useCallbackRef as D, HorizontalAlignment as mn, KeyCodes as zt, ReactUtils as Z, MouseButtonCodes as jn, useSynchronizedPointerHandler as un, useId as To, useFullscreenPortal as go, SimpleCommand as ae, KeyModifiers as de, useImperativeElement as fo, ScrollPane as Oo } from "@sheetxl/utils-react";
4
- import { useRef as ue, useReducer as Zn, useState as gt, useEffect as bt, useCallback as z, useLayoutEffect as Qt, useMemo as Ae, memo as Nt, forwardRef as Jt, version as zo, createElement as wo, useImperativeHandle as Lo } from "react";
5
- import { CoordUtils as $, CommonUtils as Ht, RangeOrientation as Ut, Direction as f, AnchorLocation as _e } from "@sheetxl/utils";
6
- import { createPortal as xo } from "react-dom";
2
+ import { jsx as Ce, jsxs as Qt, Fragment as Qn } from "react/jsx-runtime";
3
+ import { useCallbackRef as L, HorizontalAlignment as mn, KeyCodes as Lt, ReactUtils as _, MouseButtonCodes as Xn, useSynchronizedPointerHandler as un, useId as Oo, useFullscreenPortal as fo, SimpleCommand as ae, KeyModifiers as de, useImperativeElement as wo, ScrollPane as Lo } from "@sheetxl/utils-react";
4
+ import { useRef as ie, useReducer as Ln, useState as dt, useEffect as pt, useCallback as $, useLayoutEffect as _t, useMemo as Ve, memo as Kt, forwardRef as en, version as zo, createElement as xo, useImperativeHandle as $o } from "react";
5
+ import { CoordUtils as F, CommonUtils as Nt, RangeOrientation as Ht, Direction as w, AnchorLocation as _e } from "@sheetxl/utils";
6
+ import { createPortal as po } from "react-dom";
7
7
  /**
8
- * @license @sheetxl/grid-react - Grid React - Advanced grid component for React - v0.4.22
8
+ * @license @sheetxl/grid-react - Grid React - Advanced grid component for React - v0.5.1
9
9
  *
10
10
  * (C) 2025-present SheetXL Inc. & Michael T. Ford
11
11
  * License: The license can be found at https://www.sheetxl.com/license.
12
12
  */
13
- const dn = ({ itemType: t, index: n, itemSize: o, instanceProps: r, scale: c = 1 }) => {
14
- let a, i, l;
15
- t === "column" ? (a = r.columnMetadataMap, i = r.lastMeasuredColumnIndex, l = r.recalcColumnIndices) : (a = r.rowMetadataMap, i = r.lastMeasuredRowIndex, l = r.recalcRowIndices);
13
+ const dn = ({ itemType: t, index: n, itemSize: o, instanceProps: r, scale: s = 1 }) => {
14
+ let c, i, l;
15
+ t === "column" ? (c = r.columnMetadataMap, i = r.lastMeasuredColumnIndex, l = r.recalcColumnIndices) : (c = r.rowMetadataMap, i = r.lastMeasuredRowIndex, l = r.recalcRowIndices);
16
16
  const h = l.length > 0;
17
17
  if (n > i) {
18
- let T = 0;
18
+ let k = 0;
19
19
  if (i >= 0) {
20
- const B = a[i];
21
- T = B.offset + B.size;
20
+ const A = c[i];
21
+ k = A.offset + A.size;
22
22
  }
23
- for (let B = i + 1; B <= n; B++) {
24
- let R = h ? l.includes(B) ? o(B) * c : a[B]?.size || o(B) * c : o(B) * c;
25
- a[B] = { offset: T, size: R }, T += R;
23
+ for (let A = i + 1; A <= n; A++) {
24
+ let E = h ? l.includes(A) ? o(A) * s : c[A]?.size || o(A) * s : o(A) * s;
25
+ c[A] = { offset: k, size: E }, k += E;
26
26
  }
27
27
  t === "column" ? r.lastMeasuredColumnIndex = n : r.lastMeasuredRowIndex = n;
28
28
  }
29
- return a[n], a[n];
30
- }, Jn = ({ itemType: t, itemSize: n, itemCount: o, instanceProps: r, offset: c, scale: a }) => {
29
+ return c[n], c[n];
30
+ }, eo = ({ itemType: t, itemSize: n, itemCount: o, instanceProps: r, offset: s, scale: c }) => {
31
31
  let i, l;
32
32
  t === "column" ? (i = r.columnMetadataMap, l = r.lastMeasuredColumnIndex) : (i = r.rowMetadataMap, l = r.lastMeasuredRowIndex);
33
33
  let h = 0;
34
- return h = (l > 0 ? i[l].offset : 0) >= c ? po({ itemType: t, itemSize: n, instanceProps: r, high: l, low: 0, offset: c, scale: a }) : $o({ itemType: t, itemSize: n, itemCount: o, instanceProps: r, index: Math.max(0, l), offset: c, scale: a }), h = Math.min(h, o), h;
35
- }, po = ({ itemType: t, itemSize: n, instanceProps: o, high: r, low: c, offset: a, scale: i }) => {
36
- for (; c <= r; ) {
37
- const l = c + Math.floor((r - c) / 2), h = dn({ itemType: t, itemSize: n, index: l, instanceProps: o, scale: i }).offset;
38
- if (h === a) return l;
39
- h < a ? c = l + 1 : h > a && (r = l - 1);
34
+ return h = (l > 0 ? i[l].offset : 0) >= s ? mo({ itemType: t, itemSize: n, instanceProps: r, high: l, low: 0, offset: s, scale: c }) : Bo({ itemType: t, itemSize: n, itemCount: o, instanceProps: r, index: Math.max(0, l), offset: s, scale: c }), h = Math.min(h, o), h;
35
+ }, mo = ({ itemType: t, itemSize: n, instanceProps: o, high: r, low: s, offset: c, scale: i }) => {
36
+ for (; s <= r; ) {
37
+ const l = s + Math.floor((r - s) / 2), h = dn({ itemType: t, itemSize: n, index: l, instanceProps: o, scale: i }).offset;
38
+ if (h === c) return l;
39
+ h < c ? s = l + 1 : h > c && (r = l - 1);
40
40
  }
41
- return c > 0 ? c - 1 : 0;
42
- }, $o = ({ itemType: t, itemSize: n, itemCount: o, instanceProps: r, index: c, offset: a, scale: i }) => {
41
+ return s > 0 ? s - 1 : 0;
42
+ }, Bo = ({ itemType: t, itemSize: n, itemCount: o, instanceProps: r, index: s, offset: c, scale: i }) => {
43
43
  let l = 1;
44
- for (; c < o && dn({ itemType: t, itemSize: n, index: c, instanceProps: r, scale: i }).offset < a; ) c += l, l *= 2;
45
- return po({ itemType: t, itemSize: n, instanceProps: r, high: Math.min(c, o - 1), low: Math.floor(c / 2), offset: a, scale: i });
46
- }, Bo = (t) => {
47
- const { rowCount: n, columnCount: o, defaultRowHeight: r, getRowHeight: c, defaultColumnWidth: a, getColumnWidth: i } = t || {}, l = ue({ columnMetadataMap: {}, rowMetadataMap: {}, lastMeasuredColumnIndex: -1, lastMeasuredRowIndex: -1, recalcColumnIndices: [], recalcRowIndices: [] }), h = D((k) => Jn({ itemType: "row", itemCount: n, itemSize: c ?? (() => r ?? 20), instanceProps: l.current, offset: k }), [n, c, r]), T = D((k) => k === -1 ? 0 : dn({ itemType: "row", index: k, itemSize: c ?? (() => r ?? 20), instanceProps: l.current }).offset, [c, r]), B = D((k) => dn({ itemType: "row", index: k, itemSize: c ?? (() => r ?? 20), instanceProps: l.current }).size, [c, r]), R = D((k) => Jn({ itemType: "column", itemCount: o, itemSize: i ?? (() => a ?? 75), instanceProps: l.current, offset: k }), [o, i, a]), P = D((k) => k === -1 ? 0 : dn({ itemType: "column", index: k, itemSize: i ?? (() => a ?? 75), instanceProps: l.current }).offset, [i, a]), L = D((k) => dn({ itemType: "column", index: k, itemSize: i ?? (() => a ?? 75), instanceProps: l.current }).size, [i, a]), [ce, J] = Zn((k) => k + 1, 0), oe = () => ({ getRowOffset: T, getColOffset: P, getRowIndex: h, getColIndex: R }), [$e, te] = gt(() => t ? oe() : null);
48
- return bt(() => {
49
- te(t ? oe() : null);
50
- }, [ce, n, o, a, r, B, L]), $e;
51
- }, mo = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ~`!@#$%^&*()-_=+[{]};:'\",<.>/?|\\", eo = (t) => {
44
+ for (; s < o && dn({ itemType: t, itemSize: n, index: s, instanceProps: r, scale: i }).offset < c; ) s += l, l *= 2;
45
+ return mo({ itemType: t, itemSize: n, instanceProps: r, high: Math.min(s, o - 1), low: Math.floor(s / 2), offset: c, scale: i });
46
+ }, Ao = (t) => {
47
+ const { rowCount: n, columnCount: o, defaultRowHeight: r, getRowHeight: s, defaultColumnWidth: c, getColumnWidth: i } = t || {}, l = ie({ columnMetadataMap: {}, rowMetadataMap: {}, lastMeasuredColumnIndex: -1, lastMeasuredRowIndex: -1, recalcColumnIndices: [], recalcRowIndices: [] }), h = L((R) => eo({ itemType: "row", itemCount: n, itemSize: s ?? (() => r ?? 20), instanceProps: l.current, offset: R }), [n, s, r]), k = L((R) => R === -1 ? 0 : dn({ itemType: "row", index: R, itemSize: s ?? (() => r ?? 20), instanceProps: l.current }).offset, [s, r]), A = L((R) => dn({ itemType: "row", index: R, itemSize: s ?? (() => r ?? 20), instanceProps: l.current }).size, [s, r]), E = L((R) => eo({ itemType: "column", itemCount: o, itemSize: i ?? (() => c ?? 75), instanceProps: l.current, offset: R }), [o, i, c]), P = L((R) => R === -1 ? 0 : dn({ itemType: "column", index: R, itemSize: i ?? (() => c ?? 75), instanceProps: l.current }).offset, [i, c]), z = L((R) => dn({ itemType: "column", index: R, itemSize: i ?? (() => c ?? 75), instanceProps: l.current }).size, [i, c]), [Y, j] = Ln((R) => R + 1, 0), ee = () => ({ getRowOffset: k, getColOffset: P, getRowIndex: h, getColIndex: E }), [Ie, Z] = dt(() => t ? ee() : null);
48
+ return pt(() => {
49
+ Z(t ? ee() : null);
50
+ }, [Y, n, o, c, r, A, z]), Ie;
51
+ }, vo = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ~`!@#$%^&*()-_=+[{]};:'\",<.>/?|\\", to = (t) => {
52
52
  if (!t) return null;
53
53
  if (t.eventType === "start") return { type: t.eventType };
54
54
  if (t.eventType === "submit") return { type: t.eventType };
@@ -60,171 +60,171 @@ const dn = ({ itemType: t, index: n, itemSize: o, instanceProps: r, scale: c = 1
60
60
  return t.activeCoords && (n.activeCoords = t.activeCoords), n;
61
61
  }
62
62
  return { type: t.eventType ?? "unknown" };
63
- }, Ao = (t) => !0, Fo = (t) => !!t && !(t.ctrlKey || t.metaKey || t.altKey || t.isComposing) && (!(t.shiftKey || t.key !== "F2" && t.key !== " " && t.key !== "Backspace") || (!t.shiftKey || t.key !== " ") && mo.indexOf(t.key) !== -1), Vo = (t) => !!t && t.type === "dblclick" && { editMode: !0 }, Wo = (t) => {
64
- const { session: n, refLatestCoords: o, handleSubmitEdit: r, handleCancelEdit: c, cellBounds: a, isInBounds: i, getCellEditor: l, propsEditor: h, borderStrokeFill: T = "rgb(33, 115, 70)", borderStrokeWidth: B = 2, alignment: R = mn.Left, style: P, ...L } = t, ce = ue(null), J = ue(null), [oe, $e] = gt(!1), te = n.coords, k = z(async (ge) => {
65
- if (ce.current?.getBoundingClientRect()) {
63
+ }, Fo = (t) => !0, Vo = (t) => !!t && !(t.ctrlKey || t.metaKey || t.altKey || t.isComposing) && (!(t.shiftKey || t.key !== "F2" && t.key !== " " && t.key !== "Backspace") || (!t.shiftKey || t.key !== " ") && vo.indexOf(t.key) !== -1), Wo = (t) => !!t && t.type === "dblclick" && { editMode: !0 }, Uo = (t) => {
64
+ const { session: n, refLatestCoords: o, handleSubmitEdit: r, handleCancelEdit: s, cellBounds: c, isInBounds: i, getCellEditor: l, propsEditor: h, borderStrokeFill: k = "rgb(33, 115, 70)", borderStrokeWidth: A = 2, alignment: E = mn.Left, style: P, ...z } = t, Y = ie(null), j = ie(null), [ee, Ie] = dt(!1), Z = n.coords, R = $(async (ge) => {
65
+ if (Y.current?.getBoundingClientRect()) {
66
66
  if (ge.eventType === "keyboard") {
67
- const O = ge.event, p = new KeyboardEvent(O.type, { bubbles: !0, cancelable: !0, view: window, key: O.key, code: O.code, location: O.location, repeat: O.repeat, isComposing: O.isComposing, charCode: O.charCode, keyCode: O.keyCode, which: O.which, ctrlKey: O.ctrlKey, shiftKey: O.shiftKey, altKey: O.altKey, metaKey: O.metaKey });
68
- p.isSynthetic = !0, p.key, J.current?.dispatchEvent(p);
67
+ const B = ge.event, p = new KeyboardEvent(B.type, { bubbles: !0, cancelable: !0, view: window, key: B.key, code: B.code, location: B.location, repeat: B.repeat, isComposing: B.isComposing, charCode: B.charCode, keyCode: B.keyCode, which: B.which, ctrlKey: B.ctrlKey, shiftKey: B.shiftKey, altKey: B.altKey, metaKey: B.metaKey });
68
+ p.isSynthetic = !0, p.key, j.current?.dispatchEvent(p);
69
69
  } else ge.eventType === "pointer" || console.warn("unsupported event type", ge);
70
- await new Promise((O) => requestAnimationFrame(O));
70
+ await new Promise((B) => requestAnimationFrame(B));
71
71
  }
72
72
  }, []);
73
- bt(() => {
74
- const ge = J.current;
75
- return $e(!0), J.current.startEdit?.(n.startEvent), (async () => {
76
- n.editorRefs.push(ge), n.editorRefsDispatchEditorEvent.push(k);
77
- const Ce = [...n.events];
78
- for (let O = 0; O < Ce.length; O++) await k(Ce[O]);
73
+ pt(() => {
74
+ const ge = j.current;
75
+ return Ie(!0), j.current.startEdit?.(n.startEvent), (async () => {
76
+ n.editorRefs.push(ge), n.editorRefsDispatchEditorEvent.push(R);
77
+ const Se = [...n.events];
78
+ for (let B = 0; B < Se.length; B++) await R(Se[B]);
79
79
  n.onMount(ge);
80
80
  })(), () => {
81
- const Ce = n.editorRefs.indexOf(ge);
82
- Ce !== -1 && n.editorRefs.splice(Ce, 1), n.onUnmount(ge);
81
+ const Se = n.editorRefs.indexOf(ge);
82
+ Se !== -1 && n.editorRefs.splice(Se, 1), n.onUnmount(ge);
83
83
  };
84
84
  }, []);
85
- const Q = z(() => r(n), []), Se = z(() => {
86
- c(n);
87
- }, []), A = o.current && $.isEqualCells(o.current, te), me = i && A && oe, Ve = l({ autoFocus: !!n.startEvent?.autoFocus, ...h, onSubmitEdit: Q, onCancelEdit: Se, ref: J }, te), Te = a.x + Z.boundPixel(-B / 2), We = Z.boundPixel(a.width + B / 2, !0);
88
- return Ee("div", { tabIndex: 0, ref: ce, style: { background: void 0, ...P, opacity: me ? P?.opacity ?? 1 : 0, pointerEvents: "auto", position: "absolute", boxSizing: "border-box", top: `${a.y + Z.boundPixel(-B / 2)}px`, height: Z.boundPixel(a.height + B / 2, !0), left: `${Te}px`, width: We }, ...L, children: Ee("div", { className: "editor-container", style: { position: "absolute", boxSizing: "border-box", left: `${Z.boundPixel(1)}px`, top: `${Z.boundPixel(1)}px`, width: Z.boundPixel(a.width - 2, !0), height: Z.boundPixel(a.height - 2, !0), outline: `${B}px ${T} solid`, boxShadow: "rgba(60,64,67,.35) 2px 2px 6px 3px", maxHeight: "100%", overflow: "hidden", display: "flex" }, children: Ve }) });
89
- }, gr = (t) => {
90
- const { view: n, canEdit: o = Ao, getCellEditor: r, onBeforeStartEdit: c, onStartEdit: a, onSubmitEdit: i, onCancelEdit: l, onDoneEdit: h, isEditorStartKeyEvent: T = Fo, isEditorStartPointerEvent: B = Vo, containerProps: R, borderStrokeFill: P, borderStrokeWidth: L = 2, getRangeCoords: ce = null, activeCoords: J, alignment: oe = mn.Left } = t, [$e, te] = gt(!1), [k, Q] = gt(void 0), Se = D((M, S, Pe, le, xe, Ue) => {
85
+ const U = $(() => r(n), []), he = $(() => {
86
+ s(n);
87
+ }, []), M = o.current && F.isEqualCells(o.current, Z), se = i && M && ee, Ue = l({ autoFocus: !!n.startEvent?.autoFocus, ...h, onSubmitEdit: U, onCancelEdit: he, ref: j }, Z), ke = c.x + _.boundPixel(-A / 2), He = _.boundPixel(c.width + A / 2, !0);
88
+ return Ce("div", { tabIndex: 0, ref: Y, style: { background: void 0, ...P, opacity: se ? P?.opacity ?? 1 : 0, pointerEvents: "auto", position: "absolute", boxSizing: "border-box", top: `${c.y + _.boundPixel(-A / 2)}px`, height: _.boundPixel(c.height + A / 2, !0), left: `${ke}px`, width: He }, ...z, children: Ce("div", { className: "editor-container", style: { position: "absolute", boxSizing: "border-box", left: `${_.boundPixel(1)}px`, top: `${_.boundPixel(1)}px`, width: _.boundPixel(c.width - 2, !0), height: _.boundPixel(c.height - 2, !0), outline: `${A}px ${k} solid`, boxShadow: "rgba(60,64,67,.35) 2px 2px 6px 3px", maxHeight: "100%", overflow: "hidden", display: "flex" }, children: Ue }) });
89
+ }, vr = (t) => {
90
+ const { view: n, canEdit: o = Fo, getCellEditor: r, onBeforeStartEdit: s, onStartEdit: c, onSubmitEdit: i, onCancelEdit: l, onDoneEdit: h, isEditorStartKeyEvent: k = Vo, isEditorStartPointerEvent: A = Wo, containerProps: E, borderStrokeFill: P, borderStrokeWidth: z = 2, getRangeCoords: Y = null, activeCoords: j, alignment: ee = mn.Left } = t, [Ie, Z] = dt(!1), [R, U] = dt(void 0), he = L((D, S, Me, re, xe, Ne) => {
91
91
  if (!S) return null;
92
- const et = xe?.(S, M), Ct = M.getRangeCoordsBounds(et), tt = M.toClipBounds(Ct), Kt = Ct, ft = M.getZoom();
93
- if (!tt) return null;
94
- Pe && (Pe *= ft), le && (le *= ft);
95
- let m = Kt, ie = !1;
96
- if (Pe !== void 0) {
97
- let Ge = { ...et }, ln = 0;
98
- for (; !ie && m.width <= Pe && ln < 20; ) {
92
+ const ot = xe?.(S, D), Et = D.getRangeCoordsBounds(ot), rt = D.toClipBounds(Et), qt = Et, wt = D.getZoom();
93
+ if (!rt) return null;
94
+ Me && (Me *= wt), re && (re *= wt);
95
+ let m = qt, le = !1;
96
+ if (Me !== void 0) {
97
+ let Qe = { ...ot }, ln = 0;
98
+ for (; !le && m.width <= Me && ln < 20; ) {
99
99
  ln++, ln > 19 && console.warn("max width reached");
100
- const Gt = M.getTotalRangeCoords(), kt = M.getLayout();
101
- Ue === mn.Left ? Ge.colEnd + 1 < Gt.colEnd ? Ge.colEnd = kt.getColIndex(m.x + Pe) : ie = !0 : Ue === mn.Right ? Ge.colStart - 1 >= 0 ? Ge.colStart = kt.getColIndex(m.x - (Pe - m.width)) : ie = !0 : Ue === mn.Center && Ge.colEnd + 1 < Gt.colEnd && Ge.colStart - 1 >= 0 ? (Ge.colStart = kt.getColIndex(m.x - (Pe - m.width) / 2), Ge.colEnd = kt.getColIndex(m.x + m.width + (Pe - m.width) / 2)) : ie = !0, ie || (m = M.getRangeCoordsBounds(Ge));
100
+ const Zt = D.getTotalRangeCoords(), Pt = D.getLayout();
101
+ Ne === mn.Left ? Qe.colEnd + 1 < Zt.colEnd ? Qe.colEnd = Pt.getColIndex(m.x + Me) : le = !0 : Ne === mn.Right ? Qe.colStart - 1 >= 0 ? Qe.colStart = Pt.getColIndex(m.x - (Me - m.width)) : le = !0 : Ne === mn.Center && Qe.colEnd + 1 < Zt.colEnd && Qe.colStart - 1 >= 0 ? (Qe.colStart = Pt.getColIndex(m.x - (Me - m.width) / 2), Qe.colEnd = Pt.getColIndex(m.x + m.width + (Me - m.width) / 2)) : le = !0, le || (m = D.getRangeCoordsBounds(Qe));
102
102
  }
103
103
  }
104
- m.height = Kt.height, le !== void 0 && (m.height = Math.max(le + 1, Kt.height));
105
- const { width: Xe, height: dt } = M.getViewportSize();
106
- return { x: m.x ?? 0, y: m.y ?? 0, height: Math.min(dt - m.y, m.height) + 1, width: Math.min(Xe - m.x, m.width) + 1 };
107
- }, [oe]), A = D(o, [o]), me = z(() => {
104
+ m.height = qt.height, re !== void 0 && (m.height = Math.max(re + 1, qt.height));
105
+ const { width: Je, height: ht } = D.getViewportSize();
106
+ return { x: m.x ?? 0, y: m.y ?? 0, height: Math.min(ht - m.y, m.height) + 1, width: Math.min(Je - m.x, m.width) + 1 };
107
+ }, [ee]), M = L(o, [o]), se = $(() => {
108
108
  n?.getStage()?.focus();
109
- }, [n]), Ve = ue(null), Te = D((M) => {
110
- c?.(M), X(), te(!0), Ve.current = null;
111
- }, [c]), We = D((M) => {
112
- a?.(M.coords);
113
- }, [a]), ge = D((M) => {
114
- M.isSubmitted || M.isCancelled || (p.current.isEditorClosed = !0, me(), M.isCancelled = !0, l?.(M.coords), X());
115
- }, [l]), Ce = D((M) => {
116
- if (M.isSubmitted || M.isCancelled) return !1;
109
+ }, [n]), Ue = ie(null), ke = L((D) => {
110
+ s?.(D), T(), Z(!0), Ue.current = null;
111
+ }, [s]), He = L((D) => {
112
+ c?.(D.coords);
113
+ }, [c]), ge = L((D) => {
114
+ D.isSubmitted || D.isCancelled || (p.current.isEditorClosed = !0, se(), D.isCancelled = !0, l?.(D.coords), T());
115
+ }, [l]), Se = L((D) => {
116
+ if (D.isSubmitted || D.isCancelled) return !1;
117
117
  try {
118
- return Ve.current = M.coords, M.isEditorClosing = !0, M.isSubmitted = !0, M.isEditorSubmitted || (M.isEditorSubmitted = !0, M.editorRefs[0]?.submitEdit?.()), M.coords, i?.(M.coords), M.isEditorClosed = !0, me(), X(), !0;
118
+ return Ue.current = D.coords, D.isEditorClosing = !0, D.isSubmitted = !0, D.isEditorSubmitted || (D.isEditorSubmitted = !0, D.editorRefs[0]?.submitEdit?.()), D.coords, i?.(D.coords), D.isEditorClosed = !0, se(), T(), !0;
119
119
  } catch (S) {
120
- throw M.isEditorClosing = !1, M.isSubmitted = !1, S;
120
+ throw D.isEditorClosing = !1, D.isSubmitted = !1, S;
121
121
  }
122
- }, [i]), O = D((M) => {
123
- te(!1), h?.(M.coords), X();
124
- }, [h]), p = ue(null), Ke = ue(null), qe = ue(null), F = ue([]), [re, W] = Zn((M) => M + 1, 0), X = z((M) => {
125
- M && F.current.push(M), W();
126
- }, []), se = D((M) => {
127
- if (M.defaultPrevented || M.isSynthetic || !n) return;
128
- const S = n?.getCellCoordsFromClient(M.clientX, M.clientY);
129
- S && X({ eventType: "pointer", event: M, coords: S });
130
- }, [n]), Lt = D((M) => {
131
- const S = M.nativeEvent;
132
- se(S);
133
- }, [n]), mt = D((M) => {
134
- if (M.defaultPrevented || M.isSynthetic || !n?.getStage()) return;
135
- const S = Ke.current;
136
- T(M, S) && (M.stopPropagation(), M.preventDefault()), M.key, X({ eventType: "keyboard", event: M, coords: S });
122
+ }, [i]), B = L((D) => {
123
+ Z(!1), h?.(D.coords), T();
124
+ }, [h]), p = ie(null), je = ie(null), Ye = ie(null), ne = ie([]), [Ee, J] = Ln((D) => D + 1, 0), T = $((D) => {
125
+ D && ne.current.push(D), J();
126
+ }, []), X = L((D) => {
127
+ if (D.defaultPrevented || D.isSynthetic || !n) return;
128
+ const S = n?.getCellCoordsFromClient(D.clientX, D.clientY);
129
+ S && T({ eventType: "pointer", event: D, coords: S });
130
+ }, [n]), Mt = L((D) => {
131
+ const S = D.nativeEvent;
132
+ X(S);
133
+ }, [n]), Ct = L((D) => {
134
+ if (D.defaultPrevented || D.isSynthetic || !n?.getStage()) return;
135
+ const S = je.current;
136
+ k(D, S) && (D.stopPropagation(), D.preventDefault()), D.key, T({ eventType: "keyboard", event: D, coords: S });
137
137
  }, [n]);
138
- Qt(() => {
139
- const M = (le, xe) => {
140
- const Ue = xe?.cell ?? le;
141
- if (!Ue) return null;
142
- const et = Ue;
143
- if (!A(Ue)) return null;
144
- Te?.(Ue);
145
- const Ct = Ht.uuidV4();
146
- xe = Object.freeze({ autoFocus: !0, ...xe }), qe.current = Ue;
147
- const tt = { coords: et, startEvent: xe, uuid: Ct, isMounted: !1, isStarted: !1, isSubmitted: !1, isEditorSubmitted: !1, isEditorClosing: !1, isEditorClosed: !1, isCancelled: !1, events: [], editorRefsDispatchEditorEvent: [], editorRefs: [], onMount: (Kt) => {
148
- tt.isMounted || (tt.isMounted = !0, X());
149
- }, onUnmount: (Kt) => {
150
- if (tt.editorRefs.length === 0) {
151
- const ft = () => {
152
- tt.isMounted = !1, X();
138
+ _t(() => {
139
+ const D = (re, xe) => {
140
+ const Ne = xe?.cell ?? re;
141
+ if (!Ne) return null;
142
+ const ot = Ne;
143
+ if (!M(Ne)) return null;
144
+ ke?.(Ne);
145
+ const Et = Nt.uuidV4();
146
+ xe = Object.freeze({ autoFocus: !0, ...xe }), Ye.current = Ne;
147
+ const rt = { coords: ot, startEvent: xe, uuid: Et, isMounted: !1, isStarted: !1, isSubmitted: !1, isEditorSubmitted: !1, isEditorClosing: !1, isEditorClosed: !1, isCancelled: !1, events: [], editorRefsDispatchEditorEvent: [], editorRefs: [], onMount: (qt) => {
148
+ rt.isMounted || (rt.isMounted = !0, T());
149
+ }, onUnmount: (qt) => {
150
+ if (rt.editorRefs.length === 0) {
151
+ const wt = () => {
152
+ rt.isMounted = !1, T();
153
153
  };
154
- if (document.activeElement !== document.body) ft();
154
+ if (document.activeElement !== document.body) wt();
155
155
  else {
156
- const m = (ie) => {
157
- ie.defaultPrevented || ie.target !== document.body || mt(ie);
156
+ const m = (le) => {
157
+ le.defaultPrevented || le.target !== document.body || Ct(le);
158
158
  };
159
159
  window.addEventListener("keydown", m, !0), n.getStage()?.addEventListener("focusin", () => {
160
- window.removeEventListener("keydown", m), ft();
161
- }, { once: !0 }), me();
160
+ window.removeEventListener("keydown", m), wt();
161
+ }, { once: !0 }), se();
162
162
  }
163
163
  }
164
164
  } };
165
- return tt;
165
+ return rt;
166
166
  };
167
- if (F.current.length <= 0 && !p.current) return;
168
- const S = F.current[0];
169
- eo(S), ((le) => {
170
- const xe = [], Ue = le?.length ?? 0;
171
- for (let et = 0; et < Ue; et++) {
172
- const Ct = le[et];
173
- xe.push(eo(Ct));
167
+ if (ne.current.length <= 0 && !p.current) return;
168
+ const S = ne.current[0];
169
+ to(S), ((re) => {
170
+ const xe = [], Ne = re?.length ?? 0;
171
+ for (let ot = 0; ot < Ne; ot++) {
172
+ const Et = re[ot];
173
+ xe.push(to(Et));
174
174
  }
175
- })(F.current), p.current, p.current;
176
- let Pe = p.current;
175
+ })(ne.current), p.current, p.current;
176
+ let Me = p.current;
177
177
  if (p.current) {
178
178
  if (p.current.isDone) p.current = null;
179
179
  else if (p.current.isSubmitted || p.current.isCancelled) {
180
180
  if (p.current.isMounted) return;
181
- p.current.isDone || (O(p.current), p.current.isDone = !0);
181
+ p.current.isDone || (B(p.current), p.current.isDone = !0);
182
182
  }
183
183
  }
184
184
  if (S) {
185
185
  if (S.eventType === "start") {
186
- const le = S, xe = le.startEvent?.cell ?? Ke.current;
187
- p.current && $.isEqualCells(p.current.coords, xe) || (p.current = M(xe, le.startEvent));
186
+ const re = S, xe = re.startEvent?.cell ?? je.current;
187
+ p.current && F.isEqualCells(p.current.coords, xe) || (p.current = D(xe, re.startEvent));
188
188
  } else if (S.eventType === "keyboard") {
189
- const le = S.event;
189
+ const re = S.event;
190
190
  if (p.current) {
191
191
  let xe = !1;
192
- switch (le.which) {
193
- case zt.Left:
194
- case zt.Right:
195
- case zt.Up:
196
- case zt.Down:
197
- case zt.Enter:
198
- case zt.Tab:
192
+ switch (re.which) {
193
+ case Lt.Left:
194
+ case Lt.Right:
195
+ case Lt.Up:
196
+ case Lt.Down:
197
+ case Lt.Enter:
198
+ case Lt.Tab:
199
199
  xe = !0;
200
200
  }
201
201
  if (!xe) {
202
202
  p.current.events.push(S);
203
- for (let Ue = 0; Ue < p.current.editorRefsDispatchEditorEvent.length; Ue++) p.current.editorRefsDispatchEditorEvent[Ue](S);
203
+ for (let Ne = 0; Ne < p.current.editorRefsDispatchEditorEvent.length; Ne++) p.current.editorRefsDispatchEditorEvent[Ne](S);
204
204
  }
205
- } else if (T(le, S.coords)) {
205
+ } else if (k(re, S.coords)) {
206
206
  let xe;
207
- const Ue = M(xe?.cell ?? Ke.current, xe);
208
- Ue && Ue.events.push(S), p.current = Ue;
207
+ const Ne = D(xe?.cell ?? je.current, xe);
208
+ Ne && Ne.events.push(S), p.current = Ne;
209
209
  }
210
210
  } else if (S.eventType === "pointer") {
211
- const le = S.event;
211
+ const re = S.event;
212
212
  if (p.current) {
213
213
  p.current.events.push(S);
214
214
  for (let xe = 0; xe < p.current.editorRefsDispatchEditorEvent.length; xe++) p.current.editorRefsDispatchEditorEvent[xe](S);
215
215
  } else {
216
- const xe = S?.coords ?? Ke.current, Ue = B(le, xe);
217
- if (Ue) {
218
- let et;
219
- typeof et != "boolean" && (et = Ue);
220
- const Ct = M(xe, et);
221
- Ct && Ct.events.push(S), p.current = Ct;
216
+ const xe = S?.coords ?? je.current, Ne = A(re, xe);
217
+ if (Ne) {
218
+ let ot;
219
+ typeof ot != "boolean" && (ot = Ne);
220
+ const Et = D(xe, ot);
221
+ Et && Et.events.push(S), p.current = Et;
222
222
  }
223
223
  }
224
224
  } else if (S.eventType === "submit") {
225
225
  if (p.current && !p.current.isSubmitted && !p.current.isCancelled) {
226
226
  if (!p.current.isMounted) return;
227
- Ce(p.current);
227
+ Se(p.current);
228
228
  }
229
229
  } else if (S.eventType === "cancel") {
230
230
  if (p.current && !p.current.isSubmitted && !p.current.isCancelled) {
@@ -232,361 +232,393 @@ const dn = ({ itemType: t, index: n, itemSize: o, instanceProps: r, scale: c = 1
232
232
  ge(p.current);
233
233
  }
234
234
  } else if (S.eventType === "coordsChange") {
235
- const le = S;
236
- if (Ke.current = le.activeCoords, p.current, p.current && !p.current.isSubmitted && !p.current.isCancelled) {
235
+ const re = S;
236
+ if (je.current = re.activeCoords, p.current, p.current && !p.current.isSubmitted && !p.current.isCancelled) {
237
237
  if (!p.current.isMounted) return;
238
238
  try {
239
- Ce(p.current);
239
+ Se(p.current);
240
240
  } catch {
241
241
  }
242
242
  }
243
243
  }
244
244
  }
245
- F.current.length > 0 && (F.current.shift(), X()), F.current.length === 0 && (!p.current || p.current.isEditorClosing || p.current.isEditorClosed ? !p.current && Pe && me() : p.current.isMounted && !p.current.isStarted && (p.current.isStarted = !0, p.current.startEvent.autoFocus && (typeof p.current.startEvent.autoFocus == "string" ? p.current.editorRefs[0]?.autoFocus(p.current.startEvent.autoFocus) : p.current.editorRefs[0]?.autoFocus()), We?.(p.current), requestAnimationFrame(() => {
245
+ ne.current.length > 0 && (ne.current.shift(), T()), ne.current.length === 0 && (!p.current || p.current.isEditorClosing || p.current.isEditorClosed ? !p.current && Me && se() : p.current.isMounted && !p.current.isStarted && (p.current.isStarted = !0, p.current.startEvent.autoFocus && (typeof p.current.startEvent.autoFocus == "string" ? p.current.editorRefs[0]?.autoFocus(p.current.startEvent.autoFocus) : p.current.editorRefs[0]?.autoFocus()), He?.(p.current), requestAnimationFrame(() => {
246
246
  n && p.current?.coords && n.scrollCellCoordsIntoView(p.current.coords);
247
247
  })));
248
- }, [re]), bt(() => {
249
- qe.current = J;
250
- const M = p.current?.coords;
251
- $.isEqualCells(M, J) || (p.current && (p.current.isEditorClosing = !0), X({ eventType: "coordsChange", activeCoords: J }));
252
- }, [J]);
253
- const st = z((M) => {
254
- mt(M.nativeEvent);
255
- }, []), { width: at = 0, height: fe = 0 } = k ?? { width: 0, height: 0 }, en = D(r, [r]);
256
- return { overlay: D((M) => {
248
+ }, [Ee]), pt(() => {
249
+ Ye.current = j;
250
+ const D = p.current?.coords;
251
+ F.isEqualCells(D, j) || (p.current && (p.current.isEditorClosing = !0), T({ eventType: "coordsChange", activeCoords: j }));
252
+ }, [j]);
253
+ const ft = $((D) => {
254
+ Ct(D.nativeEvent);
255
+ }, []), { width: ut = 0, height: fe = 0 } = R ?? { width: 0, height: 0 }, Wt = L(r, [r]);
256
+ return { overlay: L((D) => {
257
257
  if (!p.current || p.current.isEditorClosed) return p.current, null;
258
258
  p.current.coords;
259
- let S = Se(M, p.current.coords, at, fe, ce, oe), Pe = !0;
260
- S && S.width !== 0 && S.height !== 0 || (S = { x: 0, y: 0, width: at, height: at }, Pe = !1);
261
- const le = M.getZoom(), xe = { containerBounds: { x: 0, y: 0, width: S.width / le, height: S.height / le }, setNaturalDimensions: Q, zoom: le };
262
- return Ee(Wo, { session: p.current, refLatestCoords: qe, handleSubmitEdit: Ce, handleCancelEdit: ge, cellBounds: S, borderStrokeWidth: L, borderStrokeFill: P, isInBounds: Pe, getCellEditor: en, propsEditor: xe, alignment: oe, ...R }, "editor:" + p.current.uuid);
263
- }, [r, ce, re, at, fe, oe, L, P]), startEdit: z((M) => {
264
- X({ eventType: "start", startEvent: M });
265
- }, []), submitEdit: z(() => {
266
- X({ eventType: "submit" });
267
- }, []), cancelEdit: z(() => {
268
- X({ eventType: "cancel" });
269
- }, []), onKeyboardEvent: st, onPointerEvent: Lt, onKeyboardEventNative: mt, onPointerEventNative: se, isEditing: $e };
270
- }, fr = ({ gridRef: t, gridMainRef: n, orientation: o = Ut.Row, headerCount: r, selectionPolicy: c = "multiple", newSelectionMode: a = "clear", alwaysScrollToActiveCoords: i = !0, onDragStart: l, onDragEnd: h, pointerDownInterceptor: T, pointerMoveInterceptor: B, onPointerUp: R, newSelection: P, modifySelection: L, appendSelection: ce, clearSelections: J }) => {
271
- const oe = r ?? ((o === Ut.Row ? t.current?.rowCount : t.current?.columnCount) || 0), $e = ue(null), te = ue(null), k = ue(!1), Q = ue(null), Se = z((O) => o === Ut.Column ? { rowIndex: 0, colIndex: O.colIndex } : { rowIndex: O.rowIndex, colIndex: 0 }, [o]), A = z((O) => o === Ut.Column ? { rowIndex: n.current ? n.current.rowCount - 1 : 0, colIndex: O.colIndex } : { rowIndex: O.rowIndex, colIndex: n.current ? n.current.columnCount - 1 : 0 }, [o]), me = (O) => {
272
- te.current = A(O), L(te.current, $e.current);
273
- }, Ve = z((O, p) => {
259
+ let S = he(D, p.current.coords, ut, fe, Y, ee), Me = !0;
260
+ S && S.width !== 0 && S.height !== 0 || (S = { x: 0, y: 0, width: ut, height: ut }, Me = !1);
261
+ const re = D.getZoom(), xe = { containerBounds: { x: 0, y: 0, width: S.width / re, height: S.height / re }, setNaturalDimensions: U, zoom: re };
262
+ return Ce(Uo, { session: p.current, refLatestCoords: Ye, handleSubmitEdit: Se, handleCancelEdit: ge, cellBounds: S, borderStrokeWidth: z, borderStrokeFill: P, isInBounds: Me, getCellEditor: Wt, propsEditor: xe, alignment: ee, ...E }, "editor:" + p.current.uuid);
263
+ }, [r, Y, Ee, ut, fe, ee, z, P]), startEdit: $((D) => {
264
+ T({ eventType: "start", startEvent: D });
265
+ }, []), submitEdit: $(() => {
266
+ T({ eventType: "submit" });
267
+ }, []), cancelEdit: $(() => {
268
+ T({ eventType: "cancel" });
269
+ }, []), onKeyboardEvent: ft, onPointerEvent: Mt, onKeyboardEventNative: Ct, onPointerEventNative: X, isEditing: Ie };
270
+ };
271
+ var Ho = function() {
272
+ }, So = typeof window < "u", No = So ? _t : pt, no = { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, bottom: 0, right: 0 };
273
+ const yo = So && window.ResizeObserver !== void 0 ? function() {
274
+ var t = dt(null), n = t[0], o = t[1], r = dt(no), s = r[0], c = r[1], i = Ve(function() {
275
+ return new window.ResizeObserver(function(l) {
276
+ if (l[0]) {
277
+ var h = l[0].contentRect, k = h.x, A = h.y, E = h.width, P = h.height, z = h.top, Y = h.left, j = h.bottom, ee = h.right;
278
+ c({ x: k, y: A, width: E, height: P, top: z, left: Y, bottom: j, right: ee });
279
+ }
280
+ });
281
+ }, []);
282
+ return No(function() {
283
+ if (n) return i.observe(n), function() {
284
+ i.disconnect();
285
+ };
286
+ }, [n]), [o, s];
287
+ } : function() {
288
+ return [Ho, no];
289
+ }, Ko = 3, qo = 0.1, jo = 50, Kn = (t) => ({ x: t.x, y: t.y, width: t.width, height: t.height, top: t.top, left: t.left, right: t.right, bottom: t.bottom });
290
+ function Yo(t = {}) {
291
+ const { threshold: n = qo, stillnessThreshold: o = Ko, maxHierarchyDepth: r = jo } = t, [s, c] = yo(), i = ie(null), [l, h] = Ln((Y) => Y + 1, 0), k = ie(void 0), A = ie({ x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, right: 0, bottom: 0 }), E = $((Y) => {
292
+ i.current = Y, typeof s == "function" && s(Y);
293
+ }, [s]), [P, z] = dt(c);
294
+ return pt(() => {
295
+ c && !P && z(c);
296
+ }, [c, P]), pt(() => {
297
+ const Y = i.current;
298
+ if (!Y) return;
299
+ let j = !1, ee = 0;
300
+ const Ie = () => {
301
+ if (!Y) return;
302
+ const M = Y.getBoundingClientRect(), se = A.current;
303
+ Math.abs(M.x - se.x) > n || Math.abs(M.y - se.y) > n || Math.abs(M.width - se.width) > n || Math.abs(M.height - se.height) > n ? (j || (j = !0, z(Kn(M)), h()), ee = 0) : ee++, j && ee >= o && (j = !1, z(Kn(M)), h()), A.current = Kn(M), k.current = requestAnimationFrame(Ie);
304
+ };
305
+ k.current = requestAnimationFrame(Ie);
306
+ const Z = (M) => {
307
+ j = !0, h();
308
+ }, R = (M) => {
309
+ j = !1, ee = o, h();
310
+ };
311
+ let U = Y;
312
+ const he = [];
313
+ for (; U && U !== document.documentElement && (U.addEventListener("animationstart", Z, !0), U.addEventListener("animationend", R, !0), U.addEventListener("transitionstart", Z, !0), U.addEventListener("transitionend", R, !0), he.push(U), U = U.parentElement, !(he.length > r)); ) ;
314
+ return () => {
315
+ k.current && cancelAnimationFrame(k.current), he.forEach((M) => {
316
+ M.removeEventListener("animationstart", Z, !0), M.removeEventListener("animationend", R, !0), M.removeEventListener("transitionstart", Z, !0), M.removeEventListener("transitionend", R, !0);
317
+ });
318
+ };
319
+ }, [l, c, n, o, r]), [E, P];
320
+ }
321
+ const Sr = ({ gridRef: t, gridMainRef: n, orientation: o = Ht.Row, headerCount: r, selectionPolicy: s = "multiple", newSelectionMode: c = "clear", alwaysScrollToActiveCoords: i = !0, onDragStart: l, onDragEnd: h, pointerDownInterceptor: k, pointerMoveInterceptor: A, onPointerUp: E, newSelection: P, modifySelection: z, appendSelection: Y, clearSelections: j }) => {
322
+ const ee = r ?? ((o === Ht.Row ? t.current?.rowCount : t.current?.columnCount) || 0), Ie = ie(null), Z = ie(null), R = ie(!1), U = ie(null), he = $((B) => o === Ht.Column ? { rowIndex: 0, colIndex: B.colIndex } : { rowIndex: B.rowIndex, colIndex: 0 }, [o]), M = $((B) => o === Ht.Column ? { rowIndex: n.current ? n.current.rowCount - 1 : 0, colIndex: B.colIndex } : { rowIndex: B.rowIndex, colIndex: n.current ? n.current.columnCount - 1 : 0 }, [o]), se = (B) => {
323
+ Z.current = M(B), z(Z.current, Ie.current);
324
+ }, Ue = $((B, p) => {
274
325
  if (!t.current) return;
275
- const Ke = t.current.getViewFromClient(O, p)?.getCellCoordsFromClient(O, p);
276
- return Ke ? (o === Ut.Column ? Ke.rowIndex = n.current.getViewport().rowStart : Ke.colIndex = n.current.getViewport().colStart, Ke) : void 0;
277
- }, []), Te = z((O, p = !1) => {
278
- let Ke = O;
279
- return p || (Ke = { ...O }, o === Ut.Row ? delete Ke.colIndex : delete Ke.rowIndex), n.current?.scrollCellCoordsIntoView(Ke);
280
- }, [o]), We = D(h, [h]), ge = D(l, [l]), Ce = Ae(() => ({ onPointerDown: (O) => {
281
- if (!t || !t.current || O.nativeEvent.defaultPrevented) return;
282
- const p = Ve(O.nativeEvent.clientX, O.nativeEvent.clientY);
326
+ const je = t.current.getViewFromClient(B, p)?.getCellCoordsFromClient(B, p);
327
+ return je ? (o === Ht.Column ? je.rowIndex = n.current.getViewport().rowStart : je.colIndex = n.current.getViewport().colStart, je) : void 0;
328
+ }, []), ke = $((B, p = !1) => {
329
+ let je = B;
330
+ return p || (je = { ...B }, o === Ht.Row ? delete je.colIndex : delete je.rowIndex), n.current?.scrollCellCoordsIntoView(je);
331
+ }, [o]), He = L(h, [h]), ge = L(l, [l]), Se = Ve(() => ({ onPointerDown: (B) => {
332
+ if (!t || !t.current || B.nativeEvent.defaultPrevented) return;
333
+ const p = Ue(B.nativeEvent.clientX, B.nativeEvent.clientY);
283
334
  if (!p) return;
284
- O.nativeEvent.which, jn.Right;
285
- const Ke = O.nativeEvent.shiftKey, qe = O.nativeEvent.ctrlKey || O.nativeEvent.metaKey;
286
- if (T?.(O, p) === !1) return;
287
- ge?.(), k.current = !0;
288
- const F = n.current?.getViewFromClient(O.nativeEvent.clientX, O.nativeEvent.clientY), re = ((W, X) => o === Ut.Column ? { ...W, rowIndex: X.rowStart } : { ...W, colIndex: X.colStart })(p, F.getVisibleRangeCoords());
289
- if (Ke) me(p);
335
+ B.nativeEvent.which, Xn.Right;
336
+ const je = B.nativeEvent.shiftKey, Ye = B.nativeEvent.ctrlKey || B.nativeEvent.metaKey;
337
+ if (k?.(B, p) === !1) return;
338
+ ge?.(), R.current = !0;
339
+ const ne = n.current?.getViewFromClient(B.nativeEvent.clientX, B.nativeEvent.clientY), Ee = ((J, T) => o === Ht.Column ? { ...J, rowIndex: T.rowStart } : { ...J, colIndex: T.colStart })(p, ne.getVisibleRangeCoords());
340
+ if (je) se(p);
290
341
  else {
291
- if (qe) return ((W, X = W, se) => {
292
- $e.current = Se(W), te.current = A(X), ce($e.current, te.current, se);
293
- })(p, p, re), void (i && Te(re, !0));
294
- ((W, X = W, se) => {
295
- $e.current = Se(W), te.current = A(X), P($e.current, te.current, se);
296
- })(p, p, re), me(p), i && Te(re, !0);
342
+ if (Ye) return ((J, T = J, X) => {
343
+ Ie.current = he(J), Z.current = M(T), Y(Ie.current, Z.current, X);
344
+ })(p, p, Ee), void (i && ke(Ee, !0));
345
+ ((J, T = J, X) => {
346
+ Ie.current = he(J), Z.current = M(T), P(Ie.current, Z.current, X);
347
+ })(p, p, Ee), se(p), i && ke(Ee, !0);
297
348
  }
298
- }, onPointerMoveOrWait: Ht.throttle((O) => {
299
- if (!k.current || !t?.current) return;
300
- const p = Ve(O.clientX, O.clientY);
301
- if (p && B?.(O, p) !== !1) {
302
- if ($.isEqualCells(Q.current, p)) return J();
303
- me(p), Te(p);
349
+ }, onPointerMoveOrWait: Nt.throttle((B) => {
350
+ if (!R.current || !t?.current) return;
351
+ const p = Ue(B.clientX, B.clientY);
352
+ if (p && A?.(B, p) !== !1) {
353
+ if (F.isEqualCells(U.current, p)) return j();
354
+ se(p), ke(p);
304
355
  }
305
- }, 60), onPointerUp: (O) => {
306
- k.current = !1, We?.(), R?.(O);
307
- }, processTouch: !0, consumeTouch: !0 }), [c, i, oe, a, J, T, R]);
308
- return { onPointerDown: D(un(Ce), []), getCellCoordsFromClient: Ve };
309
- }, Fe = (t, n, o) => {
356
+ }, 60), onPointerUp: (B) => {
357
+ R.current = !1, He?.(), E?.(B);
358
+ }, processTouch: !0, consumeTouch: !0 }), [s, i, ee, c, j, k, E]);
359
+ return { onPointerDown: L(un(Se), []), getCellCoordsFromClient: Ue };
360
+ }, We = (t, n, o) => {
310
361
  if (!t) return n;
311
362
  let r = n;
312
- const c = o === f.Right || o === f.Down;
363
+ const s = o === w.Right || o === w.Down;
313
364
  for (; ; ) {
314
- const a = t(r, !c);
315
- if (a === 0) return r;
316
- c ? r += a : r -= a;
365
+ const c = t(r, !s);
366
+ if (c === 0) return r;
367
+ s ? r += c : r -= c;
317
368
  }
318
369
  }, Pn = (t, n, o) => {
319
370
  const r = [];
320
- let c = n;
321
- for (; c <= o; ) {
322
- const a = Math.max(0, t(c));
323
- a === 0 ? (r.push(c), c++) : c += a;
371
+ let s = n;
372
+ for (; s <= o; ) {
373
+ const c = Math.max(0, t(s));
374
+ c === 0 ? (r.push(s), s++) : s += c;
324
375
  }
325
376
  return r;
326
- }, Uo = (t, n, o, r, c, a) => {
327
- if (!n) return a;
377
+ }, Xo = (t, n, o, r, s, c) => {
378
+ if (!n) return c;
328
379
  let { rowIndex: i, colIndex: l } = t;
329
380
  switch (r) {
330
- case f.Down: {
331
- i = Fe(o, Math.min(i + 1, a), r);
381
+ case w.Down: {
382
+ i = We(o, Math.min(i + 1, c), r);
332
383
  let h = n({ rowIndex: i, colIndex: l });
333
- for (; !h && i < a; ) i = Fe(o, Math.min(++i, a), r), h = n({ rowIndex: i, colIndex: l });
384
+ for (; !h && i < c; ) i = We(o, Math.min(++i, c), r), h = n({ rowIndex: i, colIndex: l });
334
385
  return i;
335
386
  }
336
- case f.Up: {
337
- i = Fe(o, Math.max(i - 1, a), r);
387
+ case w.Up: {
388
+ i = We(o, Math.max(i - 1, c), r);
338
389
  let h = n({ rowIndex: i, colIndex: l });
339
- for (; !h && i > a; ) i = Fe(o, Math.max(--i, a), r), h = n({ rowIndex: i, colIndex: l });
390
+ for (; !h && i > c; ) i = We(o, Math.max(--i, c), r), h = n({ rowIndex: i, colIndex: l });
340
391
  return i;
341
392
  }
342
- case f.Right: {
343
- l = Fe(o, Math.min(l + 1, a), r);
393
+ case w.Right: {
394
+ l = We(o, Math.min(l + 1, c), r);
344
395
  let h = n({ rowIndex: i, colIndex: l });
345
- for (; !h && l < a; ) l = Fe(o, Math.min(++l, a), r), h = n({ rowIndex: i, colIndex: l });
396
+ for (; !h && l < c; ) l = We(o, Math.min(++l, c), r), h = n({ rowIndex: i, colIndex: l });
346
397
  return l;
347
398
  }
348
- case f.Left: {
349
- l = Fe(o, Math.max(l - 1, a), r);
399
+ case w.Left: {
400
+ l = We(o, Math.max(l - 1, c), r);
350
401
  let h = n({ rowIndex: i, colIndex: l });
351
- for (; !h && l > a; ) l = Fe(o, Math.max(--l, a), r), h = n({ rowIndex: i, colIndex: l });
402
+ for (; !h && l > c; ) l = We(o, Math.max(--l, c), r), h = n({ rowIndex: i, colIndex: l });
352
403
  return l;
353
404
  }
354
405
  default:
355
- return a;
406
+ return c;
356
407
  }
357
- }, Ho = (t, n = () => !0, o, r, c, a) => {
408
+ }, Go = (t, n = () => !0, o, r, s, c) => {
358
409
  let { rowIndex: i, colIndex: l } = t;
359
410
  switch (r) {
360
- case f.Down: {
361
- i = Fe(o, Math.min(i + 1, a), r);
411
+ case w.Down: {
412
+ i = We(o, Math.min(i + 1, c), r);
362
413
  let h = n?.({ rowIndex: i, colIndex: l });
363
- for (; h && i < a; ) i = Fe(o, Math.min(++i, a), r), h = n?.({ rowIndex: i, colIndex: l });
414
+ for (; h && i < c; ) i = We(o, Math.min(++i, c), r), h = n?.({ rowIndex: i, colIndex: l });
364
415
  return n?.({ rowIndex: i, colIndex: l }) ? i : i - 1;
365
416
  }
366
- case f.Up: {
367
- i = Fe(o, Math.max(i - 1, a), r);
417
+ case w.Up: {
418
+ i = We(o, Math.max(i - 1, c), r);
368
419
  let h = n?.({ rowIndex: i, colIndex: l });
369
- for (; h && i > a; ) i = Fe(o, Math.max(--i, a), r), h = n?.({ rowIndex: i, colIndex: l });
420
+ for (; h && i > c; ) i = We(o, Math.max(--i, c), r), h = n?.({ rowIndex: i, colIndex: l });
370
421
  return n?.({ rowIndex: i, colIndex: l }) ? i : i + 1;
371
422
  }
372
- case f.Right: {
373
- l = Fe(o, Math.min(l + 1, a), r);
423
+ case w.Right: {
424
+ l = We(o, Math.min(l + 1, c), r);
374
425
  let h = n?.({ rowIndex: i, colIndex: l });
375
- for (; h && l < a; ) l = Fe(o, Math.min(++l, a), r), h = n?.({ rowIndex: i, colIndex: l });
426
+ for (; h && l < c; ) l = We(o, Math.min(++l, c), r), h = n?.({ rowIndex: i, colIndex: l });
376
427
  return n?.({ rowIndex: i, colIndex: l }) ? l : l - 1;
377
428
  }
378
- case f.Left: {
379
- l = Fe(o, Math.max(l - 1, a), r);
429
+ case w.Left: {
430
+ l = We(o, Math.max(l - 1, c), r);
380
431
  let h = n?.({ rowIndex: i, colIndex: l });
381
- for (; h && l > a; ) l = Fe(o, Math.max(--l, a), r), h = n?.({ rowIndex: i, colIndex: l });
432
+ for (; h && l > c; ) l = We(o, Math.max(--l, c), r), h = n?.({ rowIndex: i, colIndex: l });
382
433
  return n?.({ rowIndex: i, colIndex: l }) ? l : l + 1;
383
434
  }
384
435
  default:
385
436
  return null;
386
437
  }
387
- }, No = (t, n, o, r, c, a) => {
388
- if (!n) return a;
438
+ }, Zo = (t, n, o, r, s, c) => {
439
+ if (!n) return c;
389
440
  let i, { rowIndex: l, colIndex: h } = t;
390
- r === f.Down ? i = { rowIndex: l + 1, colIndex: h } : r === f.Up ? i = { rowIndex: l - 1, colIndex: h } : r === f.Right ? i = { rowIndex: l, colIndex: h + 1 } : r === f.Left && (i = { rowIndex: l, colIndex: h - 1 });
391
- const T = n(t), B = n(i);
392
- var R, P;
393
- return (P = B, !(R = T) && !P || !R && P || R && !P ? Uo : Ho)(t, n, o, r, !1, a) ?? a;
394
- }, to = (t, n) => `${t}:${n}`, no = (t, n, o, r, c, a) => {
395
- if (o - n >= c - r) return r;
441
+ r === w.Down ? i = { rowIndex: l + 1, colIndex: h } : r === w.Up ? i = { rowIndex: l - 1, colIndex: h } : r === w.Right ? i = { rowIndex: l, colIndex: h + 1 } : r === w.Left && (i = { rowIndex: l, colIndex: h - 1 });
442
+ const k = n(t), A = n(i);
443
+ var E, P;
444
+ return (P = A, !(E = k) && !P || !E && P || E && !P ? Xo : Go)(t, n, o, r, !1, c) ?? c;
445
+ }, oo = (t, n) => `${t}:${n}`, ro = (t, n, o, r, s, c) => {
446
+ if (o - n >= s - r) return r;
396
447
  let i = r;
397
- return t === "nearest" && (r - n > 0 ? t = "start" : o - c > 0 && (t = "end")), t === "start" ? i = n : t === "end" ? i = o - (c - r) : t === "center" && (i = n + (o - n) / 2 - (c - r) / 2), Math.max(0, Math.min(i, a - (c - r)));
398
- }, oo = (t, n, o, r) => (console.log("todo: implement convertToVisibleRanges"), t), Yn = (t, n = f.Right, o, r, c, a = null) => {
399
- if (a && $.isEqualSelectionCoords(a, t)) return t;
448
+ return t === "nearest" && (r - n > 0 ? t = "start" : o - s > 0 && (t = "end")), t === "start" ? i = n : t === "end" ? i = o - (s - r) : t === "center" && (i = n + (o - n) / 2 - (s - r) / 2), Math.max(0, Math.min(i, c - (s - r)));
449
+ }, lo = (t, n, o, r) => (console.log("todo: implement convertToVisibleRanges"), t), Gn = (t, n = w.Right, o, r, s, c = null) => {
450
+ if (c && F.isEqualSelectionCoords(c, t)) return t;
400
451
  const i = t.ranges[t.rangeIndex];
401
- if (!$.isRangesIntersect({ rowStart: t.cell.rowIndex, colStart: t.cell.colIndex, rowEnd: t.cell.rowIndex, colEnd: t.cell.colIndex }, i)) return t;
452
+ if (!F.isRangesIntersect({ rowStart: t.cell.rowIndex, colStart: t.cell.colIndex, rowEnd: t.cell.rowIndex, colEnd: t.cell.colIndex }, i)) return t;
402
453
  let l = { ...t.cell }, h = t.rangeIndex;
403
454
  switch (n) {
404
- case f.Right:
405
- l.colIndex = Fe(c, l.colIndex + 1, n);
455
+ case w.Right:
456
+ l.colIndex = We(s, l.colIndex + 1, n);
406
457
  break;
407
- case f.Left:
408
- l.colIndex = Fe(c, l.colIndex - 1, n);
458
+ case w.Left:
459
+ l.colIndex = We(s, l.colIndex - 1, n);
409
460
  break;
410
- case f.Down:
411
- l.rowIndex = Fe(r, l.rowIndex + 1, n);
461
+ case w.Down:
462
+ l.rowIndex = We(r, l.rowIndex + 1, n);
412
463
  break;
413
- case f.Up:
414
- l.rowIndex = Fe(r, l.rowIndex - 1, n);
464
+ case w.Up:
465
+ l.rowIndex = We(r, l.rowIndex - 1, n);
415
466
  }
416
- const T = (P) => {
467
+ const k = (P) => {
417
468
  if (P) {
418
469
  h = t.rangeIndex >= t.ranges.length - 1 ? 0 : t.rangeIndex + 1;
419
- const L = t.ranges[h];
420
- l = { colIndex: L.colStart, rowIndex: L.rowStart };
470
+ const z = t.ranges[h];
471
+ l = { colIndex: z.colStart, rowIndex: z.rowStart };
421
472
  } else {
422
473
  h = t.rangeIndex <= 0 ? t.ranges.length - 1 : t.rangeIndex - 1;
423
- const L = t.ranges[h];
424
- l = { colIndex: L.colEnd, rowIndex: L.rowEnd };
474
+ const z = t.ranges[h];
475
+ l = { colIndex: z.colEnd, rowIndex: z.rowEnd };
425
476
  }
426
477
  };
427
- if (n === f.Right && l.colIndex > i.colEnd && l.rowIndex === i.rowEnd) T(!0);
428
- else if (n === f.Left && l.colIndex < i.colStart && l.rowIndex === i.rowStart) T(!1);
429
- else if (n === f.Down && l.colIndex === i.colEnd && l.rowIndex > i.rowEnd) T(!0);
430
- else if (n === f.Up && l.colIndex === i.colStart && l.rowIndex < i.rowStart) T(!1);
478
+ if (n === w.Right && l.colIndex > i.colEnd && l.rowIndex === i.rowEnd) k(!0);
479
+ else if (n === w.Left && l.colIndex < i.colStart && l.rowIndex === i.rowStart) k(!1);
480
+ else if (n === w.Down && l.colIndex === i.colEnd && l.rowIndex > i.rowEnd) k(!0);
481
+ else if (n === w.Up && l.colIndex === i.colStart && l.rowIndex < i.rowStart) k(!1);
431
482
  else {
432
- let P = l.rowIndex, L = l.colIndex;
483
+ let P = l.rowIndex, z = l.colIndex;
433
484
  switch (n) {
434
- case f.Right:
435
- L > i.colEnd && (P = Fe(r, P + 1, n), L = i.colStart, P > i.rowEnd && (P = i.rowStart));
485
+ case w.Right:
486
+ z > i.colEnd && (P = We(r, P + 1, n), z = i.colStart, P > i.rowEnd && (P = i.rowStart));
436
487
  break;
437
- case f.Left:
438
- L < i.colStart && (P = Fe(r, P - 1, n), L = i.colEnd, P < i.rowStart && (P = i.rowEnd));
488
+ case w.Left:
489
+ z < i.colStart && (P = We(r, P - 1, n), z = i.colEnd, P < i.rowStart && (P = i.rowEnd));
439
490
  break;
440
- case f.Down:
441
- P > i.rowEnd && (L = Fe(c, L + 1, n), P = i.rowStart, L > i.colEnd && (L = i.colStart));
491
+ case w.Down:
492
+ P > i.rowEnd && (z = We(s, z + 1, n), P = i.rowStart, z > i.colEnd && (z = i.colStart));
442
493
  break;
443
- case f.Up:
444
- P < i.rowStart && (L = Fe(c, L - 1, n), P = i.rowEnd, L < i.colStart && (L = i.colEnd));
494
+ case w.Up:
495
+ P < i.rowStart && (z = We(s, z - 1, n), P = i.rowEnd, z < i.colStart && (z = i.colEnd));
445
496
  }
446
- l = { rowIndex: P, colIndex: L };
497
+ l = { rowIndex: P, colIndex: z };
447
498
  }
448
- let B = o(l);
449
- if (!$.isRangeWithinRange(B, i)) {
450
- const P = $.intersectRanges(B, i);
451
- P && (B = P);
499
+ let A = o(l);
500
+ if (!F.isRangeWithinRange(A, i)) {
501
+ const P = F.intersectRanges(A, i);
502
+ P && (A = P);
452
503
  }
453
- let R = { rowStart: Fe(r, B.rowStart, f.Down), colStart: Fe(c, B.colStart, f.Right), rowEnd: Fe(r, B.rowEnd, f.Up), colEnd: Fe(c, B.colEnd, f.Left) };
454
- if (R.rowStart !== l.rowIndex || R.colStart !== l.colIndex) {
504
+ let E = { rowStart: We(r, A.rowStart, w.Down), colStart: We(s, A.colStart, w.Right), rowEnd: We(r, A.rowEnd, w.Up), colEnd: We(s, A.colEnd, w.Left) };
505
+ if (E.rowStart !== l.rowIndex || E.colStart !== l.colIndex) {
455
506
  switch (n) {
456
- case f.Right:
457
- t.ranges[h].colStart === R.colStart && t.ranges[h].colEnd === R.colEnd && (l.rowIndex = R.rowEnd), l.colIndex = R.colEnd;
507
+ case w.Right:
508
+ t.ranges[h].colStart === E.colStart && t.ranges[h].colEnd === E.colEnd && (l.rowIndex = E.rowEnd), l.colIndex = E.colEnd;
458
509
  break;
459
- case f.Left:
460
- t.ranges[h].colStart === R.colStart && t.ranges[h].colEnd === R.colEnd && (l.rowIndex = R.rowStart), l.rowIndex === R.rowStart ? l.colIndex = R.colStart + 1 : l.colIndex = R.colStart;
510
+ case w.Left:
511
+ t.ranges[h].colStart === E.colStart && t.ranges[h].colEnd === E.colEnd && (l.rowIndex = E.rowStart), l.rowIndex === E.rowStart ? l.colIndex = E.colStart + 1 : l.colIndex = E.colStart;
461
512
  break;
462
- case f.Down:
463
- t.ranges[h].rowStart === R.rowStart && t.ranges[h].rowEnd === R.rowEnd && (l.colIndex = R.colEnd), l.rowIndex = R.rowEnd;
513
+ case w.Down:
514
+ t.ranges[h].rowStart === E.rowStart && t.ranges[h].rowEnd === E.rowEnd && (l.colIndex = E.colEnd), l.rowIndex = E.rowEnd;
464
515
  break;
465
- case f.Up:
466
- t.ranges[h].rowStart === R.rowStart && t.ranges[h].rowEnd === R.rowEnd && (l.colIndex = R.colStart), l.colIndex === R.colStart ? l.rowIndex = R.rowStart + 1 : l.rowIndex = R.rowStart;
516
+ case w.Up:
517
+ t.ranges[h].rowStart === E.rowStart && t.ranges[h].rowEnd === E.rowEnd && (l.colIndex = E.colStart), l.colIndex === E.colStart ? l.rowIndex = E.rowStart + 1 : l.rowIndex = E.rowStart;
467
518
  }
468
- return Yn({ cell: l, ranges: t.ranges, rangeIndex: h }, n, o, r, c, a ?? t);
519
+ return Gn({ cell: l, ranges: t.ranges, rangeIndex: h }, n, o, r, s, c ?? t);
469
520
  }
470
521
  return { ranges: t.ranges, cell: l, rangeIndex: h };
471
- }, ro = (t, n) => {
472
- let o, r = 0, c = 0;
473
- return n.colStart < t.colStart ? (o = f.Left, r = t.colStart - n.colStart, c = n.colStart) : n.colEnd > t.colEnd ? (o = f.Right, r = n.colEnd - t.colEnd, c = n.colEnd) : n.rowStart < t.rowStart ? (o = f.Up, r = t.rowStart - n.rowStart, c = n.rowStart) : n.rowEnd > t.rowEnd && (o = f.Down, r = n.rowEnd - t.rowEnd, c = n.rowEnd), { direction: o, amount: r, index: c };
522
+ }, io = (t, n) => {
523
+ let o, r = 0, s = 0;
524
+ return n.colStart < t.colStart ? (o = w.Left, r = t.colStart - n.colStart, s = n.colStart) : n.colEnd > t.colEnd ? (o = w.Right, r = n.colEnd - t.colEnd, s = n.colEnd) : n.rowStart < t.rowStart ? (o = w.Up, r = t.rowStart - n.rowStart, s = n.rowStart) : n.rowEnd > t.rowEnd && (o = w.Down, r = n.rowEnd - t.rowEnd, s = n.rowEnd), { direction: o, amount: r, index: s };
474
525
  }, On = (t, n = !1, o, r) => {
475
526
  if (!o) return 0;
476
- const c = !n, a = c ? 1 : -1;
477
- let i = o(c ? t : t + 1), l = o(c ? t + 1 : t), h = t + (c ? 2 : -1), T = 0;
478
- for (; (l - i) * a <= 0; ) {
479
- if (c && h - 1 > r + 1 || !c && h + 1 < r) return T;
480
- i = l, l = o(h), h += a, T++;
527
+ const s = !n, c = s ? 1 : -1;
528
+ let i = o(s ? t : t + 1), l = o(s ? t + 1 : t), h = t + (s ? 2 : -1), k = 0;
529
+ for (; (l - i) * c <= 0; ) {
530
+ if (s && h - 1 > r + 1 || !s && h + 1 < r) return k;
531
+ i = l, l = o(h), h += c, k++;
481
532
  }
482
- return T;
483
- }, lo = (t, n, o, r, c) => {
484
- const a = {};
533
+ return k;
534
+ }, co = (t, n, o, r, s) => {
535
+ const c = {};
485
536
  let i = null, l = null;
486
- for (let h = 0; h <= o.length && o[h] <= c; h++) {
487
- const T = o[h];
488
- if (T < r) continue;
489
- const B = i === T ? l : n ? t.getColOffset(T) : t.getRowOffset(T), R = n ? t.getColOffset(T + 1) : t.getRowOffset(T + 1);
490
- i = T + 1, l = R, a[T] = Object.freeze({ offset: B, size: R - B, spanIndex: h });
537
+ for (let h = 0; h <= o.length && o[h] <= s; h++) {
538
+ const k = o[h];
539
+ if (k < r) continue;
540
+ const A = i === k ? l : n ? t.getColOffset(k) : t.getRowOffset(k), E = n ? t.getColOffset(k + 1) : t.getRowOffset(k + 1);
541
+ i = k + 1, l = E, c[k] = Object.freeze({ offset: A, size: E - A, spanIndex: h });
491
542
  }
492
- return Object.freeze(a);
493
- }, io = (t, n, o) => {
494
- const r = t.getColOffset(n.colStart) + (o?.left ?? 0), c = t.getRowOffset(n.rowStart) + (o?.top ?? 0);
495
- return { x: r, y: c, width: t.getColOffset(n.colEnd + 1) + (o?.right ?? 0) - (o?.left ?? 0) - r, height: t.getRowOffset(n.rowEnd + 1) + (o?.bottom ?? 0) - (o?.top ?? 0) - c };
496
- }, Ko = (t, n, o) => !!o && !(t < o.x || t > o.x + o.width) && !(n < o.y || n > o.y + o.height), Nn = (t, n = !0) => `M ${Z.boundPixel(t.left)} ${Z.boundPixel(t.top)} L ${Z.boundPixel(t.right, !0)} ${Z.boundPixel(t.top)} L ${Z.boundPixel(t.right, !0)} ${Z.boundPixel(t.bottom, !0)} L ${Z.boundPixel(t.left)} ${Z.boundPixel(t.bottom, !0)} L ${Z.boundPixel(t.left)} ${Z.boundPixel(t.top)} ${n ? "Z" : ""}`, co = (t) => {
497
- const { linePoints: n, bounds: o, pathProps: r, style: c, ...a } = t;
498
- return Ee("svg", { width: `${Z.boundPixel(o.width, !0)}`, height: `${Z.boundPixel(o.height, !0)}`, viewBox: `0 0 ${Z.boundPixel(o.width, !0)} ${Z.boundPixel(o.height, !0)}`, style: { position: "absolute", left: `${Z.boundPixel(o.x)}px`, top: `${Z.boundPixel(o.y)}px`, width: `${Z.boundPixel(o.width, !0)}px`, height: `${Z.boundPixel(o.height, !0)}px`, pointerEvents: "none", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top, width, height", willChange: "left, top, width, height, stroke-dashoffset", ...c }, ...a, children: Ee("path", { d: `M ${Z.boundPixel(n[0])} ${Z.boundPixel(n[1])} L ${Z.boundPixel(n[2])} ${Z.boundPixel(n[3])}`, fill: "none", vectorEffect: "non-scaling-stroke", stroke: "black", ...r }) });
499
- }, qo = (t) => {
500
- const { x: n = 0, y: o = 0, width: r = 0, height: c = 0, fill: a, stroke: i, strokeWidth: l = 0, strokeDasharray: h, strokeDashoffset: T, clipPath: B, pathBounds: R, pathProps: P, style: L, ...ce } = t, J = o, oe = n, $e = r, te = c;
501
- let k = null;
502
- if (a) {
503
- let Q = Nn({ top: 0, left: 0, bottom: te, right: $e });
504
- R && (Q = Q + " " + Nn({ top: R.y - J, left: R.x - oe, bottom: R.height + R.y - J, right: R.width + R.x - oe })), k = [Ee("path", { d: Q, fill: a, stroke: "none", fillRule: "evenodd" }, "fill")];
543
+ return Object.freeze(c);
544
+ }, so = (t, n, o) => {
545
+ const r = t.getColOffset(n.colStart) + (o?.left ?? 0), s = t.getRowOffset(n.rowStart) + (o?.top ?? 0);
546
+ return { x: r, y: s, width: t.getColOffset(n.colEnd + 1) + (o?.right ?? 0) - (o?.left ?? 0) - r, height: t.getRowOffset(n.rowEnd + 1) + (o?.bottom ?? 0) - (o?.top ?? 0) - s };
547
+ }, Jo = (t, n, o) => !!o && !(t < o.x || t > o.x + o.width) && !(n < o.y || n > o.y + o.height), qn = (t, n = !0) => `M ${_.boundPixel(t.left)} ${_.boundPixel(t.top)} L ${_.boundPixel(t.right, !0)} ${_.boundPixel(t.top)} L ${_.boundPixel(t.right, !0)} ${_.boundPixel(t.bottom, !0)} L ${_.boundPixel(t.left)} ${_.boundPixel(t.bottom, !0)} L ${_.boundPixel(t.left)} ${_.boundPixel(t.top)} ${n ? "Z" : ""}`, ao = (t) => {
548
+ const { linePoints: n, bounds: o, pathProps: r, style: s, ...c } = t;
549
+ return Ce("svg", { width: `${_.boundPixel(o.width, !0)}`, height: `${_.boundPixel(o.height, !0)}`, viewBox: `0 0 ${_.boundPixel(o.width, !0)} ${_.boundPixel(o.height, !0)}`, style: { position: "absolute", left: `${_.boundPixel(o.x)}px`, top: `${_.boundPixel(o.y)}px`, width: `${_.boundPixel(o.width, !0)}px`, height: `${_.boundPixel(o.height, !0)}px`, pointerEvents: "none", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top, width, height", willChange: "left, top, width, height, stroke-dashoffset", ...s }, ...c, children: Ce("path", { d: `M ${_.boundPixel(n[0])} ${_.boundPixel(n[1])} L ${_.boundPixel(n[2])} ${_.boundPixel(n[3])}`, fill: "none", vectorEffect: "non-scaling-stroke", stroke: "black", ...r }) });
550
+ }, Qo = (t) => {
551
+ const { x: n = 0, y: o = 0, width: r = 0, height: s = 0, fill: c, stroke: i, strokeWidth: l = 0, strokeDasharray: h, strokeDashoffset: k, clipPath: A, pathBounds: E, pathProps: P, style: z, ...Y } = t, j = o, ee = n, Ie = r, Z = s;
552
+ let R = null;
553
+ if (c) {
554
+ let U = qn({ top: 0, left: 0, bottom: Z, right: Ie });
555
+ E && (U = U + " " + qn({ top: E.y - j, left: E.x - ee, bottom: E.height + E.y - j, right: E.width + E.x - ee })), R = [Ce("path", { d: U, fill: c, stroke: "none", fillRule: "evenodd" }, "fill")];
505
556
  }
506
- return Zt("svg", { width: `${Z.boundPixel(r, !0)}`, height: `${Z.boundPixel(c, !0)}`, viewBox: `0 0 ${Z.boundPixel(r, !0)} ${Z.boundPixel(c, !0)}`, preserveAspectRatio: "none", style: { position: "absolute", left: `${Z.boundPixel(n)}px`, top: `${Z.boundPixel(o)}px`, pointerEvents: "none", transitionDuration: "0ms", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top, width, height", willChange: "left, top, width, height, stroke-dashoffset", boxShadow: "rgb(60 64 67 / 5%) 0px 1px 4px 2px, rgb(255 255 255 / 15%) 0px 0px 2px 1px", overflow: "visible", ...L }, ...ce, children: [k, Ee("path", { d: Nn({ top: 0, left: 0, right: $e, bottom: te }), fill: "none", strokeDasharray: h, strokeDashoffset: T, stroke: i, vectorEffect: "non-scaling-stroke", strokeWidth: l, ...P })] });
507
- }, jo = (t) => {
557
+ return Qt("svg", { width: `${_.boundPixel(r, !0)}`, height: `${_.boundPixel(s, !0)}`, viewBox: `0 0 ${_.boundPixel(r, !0)} ${_.boundPixel(s, !0)}`, preserveAspectRatio: "none", style: { position: "absolute", left: `${_.boundPixel(n)}px`, top: `${_.boundPixel(o)}px`, pointerEvents: "none", transitionDuration: "0ms", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top, width, height", willChange: "left, top, width, height, stroke-dashoffset", boxShadow: "rgb(60 64 67 / 5%) 0px 1px 4px 2px, rgb(255 255 255 / 15%) 0px 0px 2px 1px", overflow: "visible", ...z }, ...Y, children: [R, Ce("path", { d: qn({ top: 0, left: 0, right: Ie, bottom: Z }), fill: "none", strokeDasharray: h, strokeDashoffset: k, stroke: i, vectorEffect: "non-scaling-stroke", strokeWidth: l, ...P })] });
558
+ }, _o = (t) => {
508
559
  const { key: n, ...o } = t;
509
- return Ee(vo, { ...o }, n);
510
- }, vo = Nt((t) => {
511
- const { stroke: n, fill: o, x: r = 0, y: c = 0, width: a = 0, height: i = 0, style: l, isAnimatedStroke: h, animatedStrokeProps: T, range: B, cell: R, ...P } = t, L = h || !!T, ce = { name: "walking-offset", dashGap: 2, speed: 50, dashLength: 8, ...T };
512
- let J = ce.dashGap + ce.dashLength;
513
- const oe = ce.speed * J, $e = To().replaceAll(":", ""), te = `${ce.name}-${$e}`;
514
- let k;
515
- return bt(() => {
516
- if (!L) return;
517
- const Q = `@keyframes ${te} {
560
+ return Ce(bo, { ...o }, n);
561
+ }, bo = Kt((t) => {
562
+ const { stroke: n, fill: o, x: r = 0, y: s = 0, width: c = 0, height: i = 0, style: l, isAnimatedStroke: h, animatedStrokeProps: k, range: A, cell: E, ...P } = t, z = h || !!k, Y = { name: "walking-offset", dashGap: 2, speed: 50, dashLength: 8, ...k };
563
+ let j = Y.dashGap + Y.dashLength;
564
+ const ee = Y.speed * j, Ie = Oo().replaceAll(":", ""), Z = `${Y.name}-${Ie}`;
565
+ let R;
566
+ return pt(() => {
567
+ if (!z) return;
568
+ const U = `@keyframes ${Z} {
518
569
  to {
519
570
  stroke-dashoffset: 0px;
520
571
  }
521
- }`, Se = document.createElement("style");
522
- return Se.appendChild(document.createTextNode(Q)), document.head.appendChild(Se), Se.sheet.insertRule(Q, 0), () => {
523
- document.head.removeChild(Se);
572
+ }`, he = document.createElement("style");
573
+ return he.appendChild(document.createTextNode(U)), document.head.appendChild(he), he.sheet.insertRule(U, 0), () => {
574
+ document.head.removeChild(he);
524
575
  };
525
- }, [L]), L && (k = { strokeDasharray: `${ce.dashLength}px ${ce.dashGap}px`, strokeDashoffset: `${J}px`, animation: `${te} ${oe}ms linear infinite`, willChange: "stroke-dashoffset" }), Ee(qo, { x: r, y: c, width: a, height: i, stroke: n, fill: o, shapeRendering: "crispEdges", style: { ...k, ...l }, ...P });
576
+ }, [z]), z && (R = { strokeDasharray: `${Y.dashLength}px ${Y.dashGap}px`, strokeDashoffset: `${j}px`, animation: `${Z} ${ee}ms linear infinite`, willChange: "stroke-dashoffset" }), Ce(Qo, { x: r, y: s, width: c, height: i, stroke: n, fill: o, shapeRendering: "crispEdges", style: { ...R, ...l }, ...P });
526
577
  });
527
- function So(t) {
578
+ function Co(t) {
528
579
  var n, o, r = "";
529
580
  if (typeof t == "string" || typeof t == "number") r += t;
530
581
  else if (typeof t == "object") if (Array.isArray(t)) {
531
- var c = t.length;
532
- for (n = 0; n < c; n++) t[n] && (o = So(t[n])) && (r && (r += " "), r += o);
582
+ var s = t.length;
583
+ for (n = 0; n < s; n++) t[n] && (o = Co(t[n])) && (r && (r += " "), r += o);
533
584
  } else for (o in t) t[o] && (r && (r += " "), r += o);
534
585
  return r;
535
586
  }
536
587
  function rn() {
537
- for (var t, n, o = 0, r = "", c = arguments.length; o < c; o++) (t = arguments[o]) && (n = So(t)) && (r && (r += " "), r += n);
588
+ for (var t, n, o = 0, r = "", s = arguments.length; o < s; o++) (t = arguments[o]) && (n = Co(t)) && (r && (r += " "), r += n);
538
589
  return r;
539
590
  }
540
- vo.displayName = "Selection";
541
- const yo = Nt(Jt((t, n) => {
542
- const { x: o = 0, y: r = 0, borderWidth: c = 1, size: a = 6, borderStroke: i, corner: l, style: h, className: T, background: B, ...R } = t;
591
+ bo.displayName = "Selection";
592
+ const Io = Kt(en((t, n) => {
593
+ const { x: o = 0, y: r = 0, borderWidth: s = 1, size: c = 6, borderStroke: i, corner: l, style: h, className: k, background: A, ...E } = t;
543
594
  if (o === 0 || r === 0) return null;
544
- let P = !0, L = !0, ce = !0, J = !0;
595
+ let P = !0, z = !0, Y = !0, j = !0;
545
596
  switch (l) {
546
597
  case "tl":
547
- P = !1, L = !1;
598
+ P = !1, z = !1;
548
599
  break;
549
600
  case "bl":
550
- P = !1, J = !1;
601
+ P = !1, j = !1;
551
602
  break;
552
603
  case "br":
553
- ce = !1, J = !1;
604
+ Y = !1, j = !1;
554
605
  break;
555
606
  case "tr":
556
- L = !1, ce = !1;
607
+ z = !1, Y = !1;
557
608
  }
558
- return Ee("div", { className: rn("fill-handle", T), style: { position: "absolute", left: o - (a + (P ? c : 0)) / 2, top: r - (a + (L ? c : 0)) / 2, width: a, height: a, borderLeft: P ? `${c}px ${i}` : void 0, borderTop: L ? `${c}px ${i}` : void 0, borderRight: ce ? `${c}px ${i}` : void 0, borderBottom: J ? `${c}px ${i}` : void 0, background: B, cursor: "crosshair", pointerEvents: "all", transitionDuration: "0ms", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top", willChange: "left, top", ...h }, tabIndex: -1, ...R });
609
+ return Ce("div", { className: rn("fill-handle", k), style: { position: "absolute", left: o - (c + (P ? s : 0)) / 2, top: r - (c + (z ? s : 0)) / 2, width: c, height: c, borderLeft: P ? `${s}px ${i}` : void 0, borderTop: z ? `${s}px ${i}` : void 0, borderRight: Y ? `${s}px ${i}` : void 0, borderBottom: j ? `${s}px ${i}` : void 0, background: A, cursor: "crosshair", pointerEvents: "all", transitionDuration: "0ms", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top", willChange: "left, top", ...h }, tabIndex: -1, ...E });
559
610
  }));
560
- yo.displayName = "FillHandle";
561
- var Yo = function() {
562
- }, bo = typeof window < "u", Xo = bo ? Qt : bt, so = { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, bottom: 0, right: 0 };
563
- const Co = bo && window.ResizeObserver !== void 0 ? function() {
564
- var t = gt(null), n = t[0], o = t[1], r = gt(so), c = r[0], a = r[1], i = Ae(function() {
565
- return new window.ResizeObserver(function(l) {
566
- if (l[0]) {
567
- var h = l[0].contentRect, T = h.x, B = h.y, R = h.width, P = h.height, L = h.top, ce = h.left, J = h.bottom, oe = h.right;
568
- a({ x: T, y: B, width: R, height: P, top: L, left: ce, bottom: J, right: oe });
569
- }
570
- });
571
- }, []);
572
- return Xo(function() {
573
- if (n) return i.observe(n), function() {
574
- i.disconnect();
575
- };
576
- }, [n]), [o, c];
577
- } : function() {
578
- return [Yo, so];
579
- };
580
- function Kn(t, n) {
611
+ function jn(t, n) {
581
612
  if (typeof t == "function") return t(n);
582
613
  t && (t.current = n);
583
614
  }
584
- var Go = parseInt(zo.split(".")[0], 10) >= 19 ? function(t) {
615
+ Io.displayName = "FillHandle";
616
+ var er = parseInt(zo.split(".")[0], 10) >= 19 ? function(t) {
585
617
  return (n) => {
586
618
  const o = [];
587
619
  for (const r of t) {
588
- const c = Kn(r, n), a = typeof c == "function";
589
- o.push(a ? c : () => Kn(r, null));
620
+ const s = jn(r, n), c = typeof s == "function";
621
+ o.push(c ? s : () => jn(r, null));
590
622
  }
591
623
  return () => {
592
624
  for (const r of o) r();
@@ -594,1257 +626,1266 @@ var Go = parseInt(zo.split(".")[0], 10) >= 19 ? function(t) {
594
626
  };
595
627
  } : function(t) {
596
628
  return (n) => {
597
- for (const o of t) Kn(o, n);
629
+ for (const o of t) jn(o, n);
598
630
  };
599
631
  };
600
- const Xn = Nt(Jt((t, n) => {
601
- const { range: o, view: r, anchor: c, borderStroke: a = "rgb(33, 115, 70)", background: i = "white", borderWidth: l = 1.5, size: h = 22, style: T, className: B, selectionTouchPointerHandler: R, onTouchSelectStart: P, onTouchSelectEnd: L, currentTouchAnchor: ce, scrollableElement: J, scrollableRoot: oe = document.body, ...$e } = t, te = D(P, [P]), k = D(L, [L]), { bounds: Q, coordsPivot: Se, key: A } = Ae(() => {
632
+ const tr = _.detectIt().supportsTouchEvents, Zn = Kt(en((t, n) => {
633
+ const { range: o, view: r, anchor: s, borderStroke: c = "rgb(33, 115, 70)", background: i = "white", borderWidth: l = 1.5, size: h = 22, style: k, className: A, selectionTouchPointerHandler: E, onTouchSelectStart: P, onTouchSelectEnd: z, currentTouchAnchor: Y, scrollableElement: j, scrollableRoot: ee, ...Ie } = t;
634
+ if (!tr) return null;
635
+ const Z = L(P, [P]), R = L(z, [z]), { bounds: U, coordsPivot: he, key: M } = Ve(() => {
602
636
  if (!o || !r) return null;
603
- let F = null, re = null;
604
- switch (c) {
637
+ let Ee = null, J = null;
638
+ switch (s) {
605
639
  case "tl":
606
- F = { colIndex: o.colEnd, rowIndex: o.rowEnd }, re = { colIndex: o.colStart, rowIndex: o.rowStart };
640
+ Ee = { colIndex: o.colEnd, rowIndex: o.rowEnd }, J = { colIndex: o.colStart, rowIndex: o.rowStart };
607
641
  break;
608
642
  case "br":
609
- F = { colIndex: o.colStart, rowIndex: o.rowStart }, re = { colIndex: o.colEnd, rowIndex: o.rowEnd };
643
+ Ee = { colIndex: o.colStart, rowIndex: o.rowStart }, J = { colIndex: o.colEnd, rowIndex: o.rowEnd };
610
644
  break;
611
645
  case "t":
612
646
  case "l":
613
- F = { colIndex: o.colEnd, rowIndex: o.rowEnd };
647
+ Ee = { colIndex: o.colEnd, rowIndex: o.rowEnd };
614
648
  break;
615
649
  case "b":
616
- F = { colIndex: o.colStart, rowIndex: o.rowStart };
650
+ Ee = { colIndex: o.colStart, rowIndex: o.rowStart };
617
651
  break;
618
652
  case "r":
619
- F = { colIndex: o.colStart, rowIndex: o.rowEnd };
653
+ Ee = { colIndex: o.colStart, rowIndex: o.rowEnd };
620
654
  }
621
- let W = r.getRangeCoordsBounds(re ? { rowStart: re.rowIndex, colStart: re.colIndex, rowEnd: re.rowIndex, colEnd: re.colIndex } : o);
622
- const X = r.getBounds(), se = r.getViewportSize(), Lt = X.x, mt = X.y, st = se.width, at = se.height;
623
- switch (c) {
655
+ let T = r.getRangeCoordsBounds(J ? { rowStart: J.rowIndex, colStart: J.colIndex, rowEnd: J.rowIndex, colEnd: J.colIndex } : o);
656
+ const X = r.getBounds(), Mt = r.getViewportSize(), Ct = X.x, ft = X.y, ut = Mt.width, fe = Mt.height;
657
+ switch (s) {
624
658
  case "tl":
625
659
  break;
626
660
  case "br":
627
- W.x = W.x + W.width, W.y = W.y + W.height;
661
+ T.x = T.x + T.width, T.y = T.y + T.height;
628
662
  break;
629
663
  case "t":
630
- W.x = st / 2 - Lt;
664
+ T.x = ut / 2 - Ct;
631
665
  break;
632
666
  case "b":
633
- W.x = st / 2 - Lt, W.y = W.y + W.height;
667
+ T.x = ut / 2 - Ct, T.y = T.y + T.height;
634
668
  break;
635
669
  case "l":
636
- W.y = at / 2 - mt;
670
+ T.y = fe / 2 - ft;
637
671
  break;
638
672
  case "r":
639
- W.x = W.x + W.width, W.y = at / 2 - mt;
673
+ T.x = T.x + T.width, T.y = fe / 2 - ft;
640
674
  }
641
- const fe = r.toClipBounds(W, 0);
642
- return !fe || fe.width <= 0 || fe.height <= 0 || W.x < 0 || W.y < 0 || W.x > st || W.y > at ? { bounds: null, coordsAnchor: null, coordsPivot: null, key: null } : { bounds: W, coordsAnchor: null, coordsPivot: F, key: "touchSelect-" + r.getAnchor() + "-" + c };
643
- }, [o, r, c]), me = ue(null), Ve = Ae(() => {
644
- const F = (re) => c === "t" || c === "b" ? { ...re, colIndex: void 0 } : c === "l" || c === "r" ? { ...re, rowIndex: void 0 } : re;
645
- return { processTouch: !0, consumeTouch: !0, onPointerDown: (re, W) => {
646
- const X = F(r.getCellCoordsFromClient(re.clientX, re.clientY));
647
- return me.current = { coordsPivot: Se }, te?.(c), R.onSelectionPointerDown(re, W, r, X, Se, !1, !0);
648
- }, onPointerMoveOrWait: (re, W, X) => {
649
- const se = F(r.getCellCoordsFromClient(re.clientX, re.clientY));
650
- return R.onSelectionPointerMoveOrWait(re, W, X, r, se, me.current?.coordsPivot, !0, !0);
651
- }, onPointerUp: (re, W, X) => (me.current = null, k?.(c), R.onPointerUp(re, W, X)) };
652
- }, [R, o, r, c]), Te = un(Ve), [We, { y: ge, x: Ce }] = Co(), O = ue(null), { getPortalContainer: p } = go(), [Ke, qe] = gt(null);
653
- return bt(() => {
654
- const F = O.current?.getBoundingClientRect();
655
- if (!F || !Q) return void qe(null);
656
- let re = 0, W = 0, X = J;
657
- for (; X; ) re += X.scrollLeft, W += X.scrollTop, X = oe && X === oe.parentElement ? null : X.parentElement;
658
- qe(xo(Ee("div", { className: rn("touch-select-handle", B), ref: n, style: { position: "absolute", left: re + (F?.x ?? 0) - (h + l) / 2, top: W + (F?.y ?? 0) - (h + l) / 2, width: h, height: h, borderWidth: `${l}px`, border: a, borderRadius: "50%", background: i, boxShadow: `0 0 0 1.5px ${i}`, cursor: "grab", pointerEvents: "all", opacity: ce ? 0 : 1, transitionDuration: "160ms", transitionProperty: "opacity", ...T }, tabIndex: -1, onPointerDown: Te, ...$e }), oe ?? p(), A));
659
- }, [ge, Ce, Q?.x, Q?.y, Q?.width, Q?.height, B, ce, i, h, l, a, J]), Q ? Zt(_n, { children: [Ee("div", { ref: Go([We, O]), style: { position: "absolute", left: Q.x, top: Q.y, opacity: 0 } }), Ke] }) : null;
675
+ const Wt = r.toClipBounds(T, 0);
676
+ return !Wt || Wt.width <= 0 || Wt.height <= 0 || T.x < 0 || T.y < 0 || T.x > ut || T.y > fe ? { bounds: null, coordsAnchor: null, coordsPivot: null, key: null } : { bounds: T, coordsAnchor: null, coordsPivot: Ee, key: "touchSelect-" + r.getAnchor() + "-" + s };
677
+ }, [o, r, s]), se = ie(null), Ue = Ve(() => {
678
+ const Ee = (J) => s === "t" || s === "b" ? { ...J, colIndex: void 0 } : s === "l" || s === "r" ? { ...J, rowIndex: void 0 } : J;
679
+ return { processTouch: !0, consumeTouch: !0, onPointerDown: (J, T) => {
680
+ const X = Ee(r.getCellCoordsFromClient(J.clientX, J.clientY));
681
+ return se.current = { coordsPivot: he }, Z?.(s), E.onSelectionPointerDown(J, T, r, X, he, !1, !0);
682
+ }, onPointerMoveOrWait: (J, T, X) => {
683
+ const Mt = Ee(r.getCellCoordsFromClient(J.clientX, J.clientY));
684
+ return E.onSelectionPointerMoveOrWait(J, T, X, r, Mt, se.current?.coordsPivot, !0, !0);
685
+ }, onPointerUp: (J, T, X) => (se.current = null, R?.(s), E.onPointerUp(J, T, X)) };
686
+ }, [E, o, r, s]), ke = un(Ue), [He, { y: ge, x: Se }] = Yo(), B = ie(null), { getPortalContainer: p, isFullscreen: je } = fo(), [Ye, ne] = dt(null);
687
+ return pt(() => {
688
+ const Ee = B.current?.getBoundingClientRect();
689
+ if (!Ee || !U) return void ne(null);
690
+ let J = 0, T = 0, X = j;
691
+ for (; X; ) J += X.scrollLeft, T += X.scrollTop, X = ee && X === ee.parentElement ? null : X.parentElement;
692
+ ne(po(Ce("div", { className: rn("touch-select-handle", A), ref: n, style: { position: "absolute", left: J + (Ee?.x ?? 0) - (h + l) / 2, top: T + (Ee?.y ?? 0) - (h + l) / 2, width: h, height: h, borderWidth: `${l}px`, border: c, borderRadius: "50%", background: i, boxShadow: `0 0 0 1.5px ${i}`, cursor: "grab", pointerEvents: "all", opacity: Y ? 0 : 1, transitionDuration: "160ms", transitionProperty: "opacity", ...k }, tabIndex: -1, onPointerDown: ke, ...Ie }), ee ?? p(), M));
693
+ }, [ge, Se, U?.x, U?.y, U?.width, U?.height, A, Y, i, h, l, c, j, je]), U ? Qt(Qn, { children: [Ce("div", { ref: er([He, B]), style: { position: "absolute", left: U.x, top: U.y, opacity: 0 } }), Ye] }) : null;
660
694
  }));
661
- Xn.displayName = "TouchSelectHandle";
662
- const Vt = -10, _o = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd: 0 }), Io = Object.freeze({ colIndex: 0, rowIndex: 0 }), Gn = Object.freeze([]), $t = (t) => {
695
+ Zn.displayName = "TouchSelectHandle";
696
+ const Vt = -10, nr = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd: 0 }), Eo = Object.freeze({ colIndex: 0, rowIndex: 0 }), Jn = Object.freeze([]), $t = (t) => {
663
697
  if (t && t.cell && t.ranges && t.rangeIndex > -1 && t.rangeIndex <= t.ranges.length) return t;
664
- const n = { cell: null, ranges: t?.ranges ?? Gn };
665
- return n.rangeIndex = t?.rangeIndex ?? n.ranges.length - 1, n.cell = t?.cell, !n.cell && n.ranges.length > 0 && (n.cell = { rowIndex: n.ranges[n.rangeIndex].rowStart, colIndex: n.ranges[n.rangeIndex].colStart }), n.cell || (n.cell = Io), $.isEqualSelectionCoords(n, t) ? t : n;
698
+ const n = { cell: null, ranges: t?.ranges ?? Jn };
699
+ return n.rangeIndex = t?.rangeIndex ?? n.ranges.length - 1, n.cell = t?.cell, !n.cell && n.ranges.length > 0 && (n.cell = { rowIndex: n.ranges[n.rangeIndex].rowStart, colIndex: n.ranges[n.rangeIndex].colStart }), n.cell || (n.cell = Eo), F.isEqualSelectionCoords(n, t) ? t : n;
666
700
  }, Dn = (t, n, o) => {
667
- const r = t.getVisibleRangeCoords(), c = t.getScrollOrientation();
668
- !c.horizontal && (n.colIndex > r.colEnd || n.colIndex < r.colStart) && (n = { ...n, colIndex: n.colIndex > r.colEnd ? r.colEnd + 1 : r.colEnd - 1 }, t = o.current.getViewFromLocation(_e.Center)), !c.vertical && (n.rowIndex > r.rowEnd || n.rowIndex < r.rowStart) && (n = { ...n, rowIndex: n.rowIndex > r.rowEnd ? r.rowEnd + 1 : r.rowEnd - 1 }, t = o.current.getViewFromLocation(_e.Center)), t.scrollCellCoordsIntoView(n);
669
- }, Zo = () => !1, wr = ({ gridRef: t, commands: n, layout: o, selection: r, onSelectionChange: c, onSelectionDragStart: a, onSelectionDragEnd: i, selectionPolicy: l = "multiple", newSelectionMode: h = "clear", allowDeselectSelection: T = !0, onFillPreview: B, onFillCancel: R, onFillDone: P, onFill: L, disableFillDrag: ce = !L, fillHandleBorderColor: J = "white", hiddenRowsAt: oe, hiddenColumnsAt: $e, isContentfulCell: te, contentfulCellFinder: k = No, getDataCoords: Q, alwaysScrollToActiveCoords: Se = !1, selectionBounds: A, pointerDownInterceptor: me, pointerMoveInterceptor: Ve, mergedRanges: Te, canSelectionSpanMergedCells: We = Zo, onMoveDragStart: ge, onMoveDragUpdate: Ce, onMoveDragEnd: O, onMoveDragDone: p, selectionRenderer: Ke = jo, disableMoveDrag: qe = !O, getCellCoordsAsRangeCoords: F = $.cellToRange, moveDragHitSize: re = 6, moveDragOutlineSize: W = 4, selectionBackgroundColor: X = "rgba(16, 124, 65, 0.1)", selectionBorderColor: se = "rgb(33, 115, 70)", selectionRemoveBorderColor: Lt = "rgb(255, 0, 0)", selectionRemoveBackgroundColor: mt = "rgba(250, 10, 10, 0.1)", disableTouchSelection: st = !1, touchSelectHandleProps: at }) => {
670
- const fe = z(() => ({ top: A?.top ?? 0, left: A?.left ?? 0, bottom: t.current?.rowCount - 1 || 0, right: t.current?.columnCount - 1 || 0 }), []), en = D(L, [L]), M = D(B, [B]), S = D(R, [R]), Pe = D(P, [P]), le = D(te, [te]), xe = D(Ke, [Ke]), Ue = D((e, s = !1) => On(e, s, o.getRowOffset, s ? fe().bottom : fe().top), [o?.getRowOffset]), et = D(oe ?? Ue, [oe]), Ct = D((e, s = !1) => On(e, s, o.getColOffset, s ? fe().right : fe().left), [o?.getColOffset]), tt = D($e ?? Ct, [$e]), [Kt, ft] = gt(() => $t(r)), m = Ae(() => $t(Kt), [Kt]), ie = ue(m), Xe = ue(!0);
671
- Qt(Ht.throttle(() => {
672
- ft((e) => {
673
- Xe.current = !0;
674
- const s = $t(r);
675
- return $.isEqualSelectionCoords(s, e) ? e : s;
701
+ const r = t.getVisibleRangeCoords(), s = t.getScrollOrientation();
702
+ !s.horizontal && (n.colIndex > r.colEnd || n.colIndex < r.colStart) && (n = { ...n, colIndex: n.colIndex > r.colEnd ? r.colEnd + 1 : r.colEnd - 1 }, t = o.current.getViewFromLocation(_e.Center)), !s.vertical && (n.rowIndex > r.rowEnd || n.rowIndex < r.rowStart) && (n = { ...n, rowIndex: n.rowIndex > r.rowEnd ? r.rowEnd + 1 : r.rowEnd - 1 }, t = o.current.getViewFromLocation(_e.Center)), t.scrollCellCoordsIntoView(n);
703
+ }, or = () => !1, yr = ({ gridRef: t, commands: n, layout: o, selection: r, onSelectionChange: s, onSelectionDragStart: c, onSelectionDragEnd: i, selectionPolicy: l = "multiple", newSelectionMode: h = "clear", allowDeselectSelection: k = !0, onFillPreview: A, onFillCancel: E, onFillDone: P, onFill: z, disableFillDrag: Y = !z, fillHandleBorderColor: j = "white", hiddenRowsAt: ee, hiddenColumnsAt: Ie, isContentfulCell: Z, contentfulCellFinder: R = Zo, getDataCoords: U, alwaysScrollToActiveCoords: he = !1, selectionBounds: M, pointerDownInterceptor: se, pointerMoveInterceptor: Ue, mergedRanges: ke, canSelectionSpanMergedCells: He = or, onMoveDragStart: ge, onMoveDragUpdate: Se, onMoveDragEnd: B, onMoveDragDone: p, selectionRenderer: je = _o, disableMoveDrag: Ye = !B, getCellCoordsAsRangeCoords: ne = F.cellToRange, moveDragHitSize: Ee = 6, moveDragOutlineSize: J = 4, selectionBackgroundColor: T = "rgba(16, 124, 65, 0.1)", selectionBorderColor: X = "rgb(33, 115, 70)", selectionRemoveBorderColor: Mt = "rgb(255, 0, 0)", selectionRemoveBackgroundColor: Ct = "rgba(250, 10, 10, 0.1)", disableTouchSelection: ft = !1, touchSelectHandleProps: ut }) => {
704
+ const fe = $(() => ({ top: M?.top ?? 0, left: M?.left ?? 0, bottom: t.current?.rowCount - 1 || 0, right: t.current?.columnCount - 1 || 0 }), []), Wt = L(z, [z]), D = L(A, [A]), S = L(E, [E]), Me = L(P, [P]), re = L(Z, [Z]), xe = L(je, [je]), Ne = L((e, a = !1) => On(e, a, o.getRowOffset, a ? fe().bottom : fe().top), [o?.getRowOffset]), ot = L(ee ?? Ne, [ee]), Et = L((e, a = !1) => On(e, a, o.getColOffset, a ? fe().right : fe().left), [o?.getColOffset]), rt = L(Ie ?? Et, [Ie]), [qt, wt] = dt(() => $t(r)), m = Ve(() => $t(qt), [qt]), le = ie(m), Je = ie(!0);
705
+ _t(Nt.throttle(() => {
706
+ wt((e) => {
707
+ Je.current = !0;
708
+ const a = $t(r);
709
+ return F.isEqualSelectionCoords(a, e) ? e : a;
676
710
  });
677
- }, 0), [r]), Qt(() => {
678
- ie.current = m;
679
- }, [m]), bt(() => {
680
- Xe.current || !c || $.isEqualSelectionCoords(r, m) || c(m);
711
+ }, 0), [r]), _t(() => {
712
+ le.current = m;
713
+ }, [m]), pt(() => {
714
+ Je.current || !s || F.isEqualSelectionCoords(r, m) || s(m);
681
715
  }, [m]);
682
- const dt = z((e) => {
683
- ft((s) => {
684
- Xe.current = !1, s = $t(s);
685
- let u = typeof e == "function" ? e(s.ranges) : e ?? Gn;
686
- if ($.isEqualRangesArrays(u, s.ranges)) return s;
687
- let d = Math.max(u.length ? 0 : -1, Math.min(s.rangeIndex, u.length - 1)), x = s.cell;
688
- d === -1 || $.isCellWithinRange(x, u[d]) || (x = { rowIndex: u[d].rowStart, colIndex: u[d].colStart }), u.length === 1 && $.isSingleCell(u[0]) && $.isCellWithinRange(x, u[0]) && (u = [], d = -1);
689
- const E = { cell: x, ranges: u, rangeIndex: d };
690
- return $.isEqualSelectionCoords(E, s) ? s : E;
716
+ const ht = $((e) => {
717
+ wt((a) => {
718
+ Je.current = !1, a = $t(a);
719
+ let u = typeof e == "function" ? e(a.ranges) : e ?? Jn;
720
+ if (F.isEqualRangesArrays(u, a.ranges)) return a;
721
+ let d = Math.max(u.length ? 0 : -1, Math.min(a.rangeIndex, u.length - 1)), f = a.cell;
722
+ d === -1 || F.isCellWithinRange(f, u[d]) || (f = { rowIndex: u[d].rowStart, colIndex: u[d].colStart }), u.length === 1 && F.isSingleCell(u[0]) && F.isCellWithinRange(f, u[0]) && (u = [], d = -1);
723
+ const I = { cell: f, ranges: u, rangeIndex: d };
724
+ return F.isEqualSelectionCoords(I, a) ? a : I;
691
725
  });
692
- }, []), Ge = D((e) => {
693
- ft((s) => {
694
- Xe.current = !1, s = $t(s);
695
- const u = e ?? Io, d = F(u);
696
- if (!$.isSingleCell(d) && s.ranges.length === 0) return { ranges: [d], rangeIndex: 0, cell: u };
697
- if ($.isEqualCells(u, s.cell)) return s;
698
- let x = s.ranges, E = s.rangeIndex;
699
- s.ranges.length === 1 && ($.isSingleCell(s.ranges[0]) && $.isCellWithinRange(u, s.ranges[0]) || !$.isCellWithinRange(u, s.ranges[0])) && (x = [], E = -1);
700
- const w = { ranges: x, rangeIndex: E, cell: u };
701
- return $.isEqualSelectionCoords(w, s) ? s : w;
726
+ }, []), Qe = L((e) => {
727
+ wt((a) => {
728
+ Je.current = !1, a = $t(a);
729
+ const u = e ?? Eo, d = ne(u);
730
+ if (!F.isSingleCell(d) && a.ranges.length === 0) return { ranges: [d], rangeIndex: 0, cell: u };
731
+ if (F.isEqualCells(u, a.cell)) return a;
732
+ let f = a.ranges, I = a.rangeIndex;
733
+ a.ranges.length === 1 && (F.isSingleCell(a.ranges[0]) && F.isCellWithinRange(u, a.ranges[0]) || !F.isCellWithinRange(u, a.ranges[0])) && (f = [], I = -1);
734
+ const x = { ranges: f, rangeIndex: I, cell: u };
735
+ return F.isEqualSelectionCoords(x, a) ? a : x;
702
736
  });
703
- }, [F]), [ln, Gt] = gt(null), [kt, hn] = gt(null), Xt = ue(null), [Oe, Wt] = gt(null), wt = ue(null), Bt = ue(null), [vn, cn] = gt(null), He = ue(null), Be = ue(null), tn = ue(Te);
704
- bt(() => {
705
- tn.current = Te;
706
- }, [Te]);
707
- const xt = D((e, s = { inline: "nearest", block: "nearest" }) => {
737
+ }, [ne]), [ln, Zt] = dt(null), [Pt, hn] = dt(null), Gt = ie(null), [Pe, Ut] = dt(null), mt = ie(null), Bt = ie(null), [vn, cn] = dt(null), Ke = ie(null), Ae = ie(null), tn = ie(ke);
738
+ pt(() => {
739
+ tn.current = ke;
740
+ }, [ke]);
741
+ const vt = L((e, a = { inline: "nearest", block: "nearest" }) => {
708
742
  let { rowIndex: u, colIndex: d } = e;
709
- u === void 0 && m?.cell && (u = m.cell.rowIndex), d === void 0 && m?.cell && (d = m.cell.colIndex), u !== void 0 && d !== void 0 && t.current?.scrollCellCoordsIntoView({ rowIndex: u, colIndex: d }, s);
710
- }, [m]), qt = z((e) => {
711
- const s = fe();
712
- return e.rowIndex < s.top || e.colIndex < s.left || e.colIndex > s.right || e.rowIndex > s.bottom;
713
- }, []), ze = D((e, s) => {
743
+ u === void 0 && m?.cell && (u = m.cell.rowIndex), d === void 0 && m?.cell && (d = m.cell.colIndex), u !== void 0 && d !== void 0 && t.current?.scrollCellCoordsIntoView({ rowIndex: u, colIndex: d }, a);
744
+ }, [m]), jt = $((e) => {
745
+ const a = fe();
746
+ return e.rowIndex < a.top || e.colIndex < a.left || e.colIndex > a.right || e.rowIndex > a.bottom;
747
+ }, []), De = L((e, a) => {
714
748
  if (!t?.current) return null;
715
- const u = { rowStart: Math.min(e.rowIndex, s.rowIndex), colStart: Math.min(e.colIndex, s.colIndex), rowEnd: Math.max(e.rowIndex, s.rowIndex), colEnd: Math.max(e.colIndex, s.colIndex) };
716
- if (We?.(u)) return u;
717
- const x = F(e), E = F(s), w = { rowStart: Math.min(x.rowStart, E.rowStart), colStart: Math.min(x.colStart, E.colStart), rowEnd: Math.max(x.rowEnd, E.rowEnd), colEnd: Math.max(x.colEnd, E.colEnd) };
718
- let j;
719
- return typeof tn.current == "function" ? j = tn.current(w) : Te && (j = Te), j ? $.extendRangeToUnionRanges(w, j) : w;
720
- }, [We, F]), je = D((e, s, u) => {
721
- const d = e.ranges.length > 0 ? e.ranges[e.rangeIndex] : { rowStart: e.cell.rowIndex, colStart: e.cell.colIndex, rowEnd: e.cell.rowIndex, colEnd: e.cell.colIndex }, x = { rowStart: Math.min(s.rowIndex ?? d.rowStart, u.rowIndex ?? d.rowStart), colStart: Math.min(s.colIndex ?? d.colStart, u.colIndex ?? d.colStart), rowEnd: Math.max(s.rowIndex ?? d.rowEnd, u.rowIndex ?? d.rowEnd), colEnd: Math.max(s.colIndex ?? d.colEnd, u.colIndex ?? d.colEnd) }, E = { rowIndex: x.rowStart, colIndex: x.colStart }, w = { rowIndex: x.rowEnd, colIndex: x.colEnd };
722
- if (!(qt(E) || qt(w)))
723
- return ze(E, w);
724
- }, [ze]), ut = D((e, s, u) => {
725
- if (l === "single" || !ie.current) return;
726
- const d = je(ie.current, e, s ?? ie.current.cell);
749
+ const u = { rowStart: Math.min(e.rowIndex, a.rowIndex), colStart: Math.min(e.colIndex, a.colIndex), rowEnd: Math.max(e.rowIndex, a.rowIndex), colEnd: Math.max(e.colIndex, a.colIndex) };
750
+ if (He?.(u)) return u;
751
+ const f = ne(e), I = ne(a), x = { rowStart: Math.min(f.rowStart, I.rowStart), colStart: Math.min(f.colStart, I.colStart), rowEnd: Math.max(f.rowEnd, I.rowEnd), colEnd: Math.max(f.colEnd, I.colEnd) };
752
+ let G;
753
+ return typeof tn.current == "function" ? G = tn.current(x) : ke && (G = ke), G ? F.extendRangeToUnionRanges(x, G) : x;
754
+ }, [He, ne]), Xe = L((e, a, u) => {
755
+ const d = e.ranges.length > 0 ? e.ranges[e.rangeIndex] : { rowStart: e.cell.rowIndex, colStart: e.cell.colIndex, rowEnd: e.cell.rowIndex, colEnd: e.cell.colIndex }, f = { rowStart: Math.min(a.rowIndex ?? d.rowStart, u.rowIndex ?? d.rowStart), colStart: Math.min(a.colIndex ?? d.colStart, u.colIndex ?? d.colStart), rowEnd: Math.max(a.rowIndex ?? d.rowEnd, u.rowIndex ?? d.rowEnd), colEnd: Math.max(a.colIndex ?? d.colEnd, u.colIndex ?? d.colEnd) }, I = { rowIndex: f.rowStart, colIndex: f.colStart }, x = { rowIndex: f.rowEnd, colIndex: f.colEnd };
756
+ if (!(jt(I) || jt(x)))
757
+ return De(I, x);
758
+ }, [De]), gt = L((e, a, u) => {
759
+ if (l === "single" || !le.current) return;
760
+ const d = Xe(le.current, e, a ?? le.current.cell);
727
761
  if (!d) return;
728
- const x = ie.current.rangeIndex;
729
- dt((E) => E.length ? E.map((w, j) => x === j ? d : w) : [d]), u && d && Ge({ colIndex: d.colStart, rowIndex: d.rowStart });
730
- }, []), vt = z((e, s, u) => {
731
- if (!ie.current) return;
732
- e = { ...ie.current?.cell, ...e }, s = s ?? e;
733
- const d = je(ie.current, e, s);
762
+ const f = le.current.rangeIndex;
763
+ ht((I) => I.length ? I.map((x, G) => f === G ? d : x) : [d]), u && d && Qe({ colIndex: d.colStart, rowIndex: d.rowStart });
764
+ }, []), It = $((e, a, u) => {
765
+ if (!le.current) return;
766
+ e = { ...le.current?.cell, ...e }, a = a ?? e;
767
+ const d = Xe(le.current, e, a);
734
768
  if (!d) return;
735
- const x = { rowIndex: d.rowStart, colIndex: d.colStart }, E = { ...x, ...u };
736
- h === "clear" ? (He.current = E, _t()) : h === "modify" ? ut(x) : Le(x), Ge(E);
737
- }, []), Le = z((e, s = e, u) => {
738
- l !== "multiple" || !e || qt(e) || qt(s) || ft((d) => {
739
- Xe.current = !1, d = $t(d);
740
- const x = ze(e, s);
741
- if (!x) return d;
742
- let E = d.ranges.length > 0 ? [...d.ranges] : [ze(d.cell, d.cell)];
743
- E.push(x);
744
- const w = { ranges: E, cell: { rowIndex: x.rowStart, colIndex: x.colStart, ...u }, rangeIndex: E.length - 1 };
745
- return $.isEqualSelectionCoords(w, d) ? d : w;
769
+ const f = { rowIndex: d.rowStart, colIndex: d.colStart }, I = { ...f, ...u };
770
+ h === "clear" ? (Ke.current = I, Jt()) : h === "modify" ? gt(f) : Te(f), Qe(I);
771
+ }, []), Te = $((e, a = e, u) => {
772
+ l !== "multiple" || !e || jt(e) || jt(a) || wt((d) => {
773
+ Je.current = !1, d = $t(d);
774
+ const f = De(e, a);
775
+ if (!f) return d;
776
+ let I = d.ranges.length > 0 ? [...d.ranges] : [De(d.cell, d.cell)];
777
+ I.push(f);
778
+ const x = { ranges: I, cell: { rowIndex: f.rowStart, colIndex: f.colStart, ...u }, rangeIndex: I.length - 1 };
779
+ return F.isEqualSelectionCoords(x, d) ? d : x;
746
780
  });
747
- }, []), _t = () => {
748
- dt(Gn);
749
- }, Pt = Z.detectIt().primaryInput === "touch", Ze = ue(null), It = ue(null), Dt = ue(null), sn = Ae(() => ({ onPointerDown: (e) => {
781
+ }, []), Jt = () => {
782
+ ht(Jn);
783
+ }, Dt = _.detectIt().primaryInput === "touch", et = ie(null), Rt = ie(null), Tt = ie(null), sn = Ve(() => ({ onPointerDown: (e) => {
750
784
  if (!t || !t.current) return !1;
751
- const s = e.nativeEvent, u = t.current.getViewFromClient(s.clientX, s.clientY);
752
- if (s.pointerType === "touch" || s.type === "touchstart") return It.current = { topLeft: u.getScrollTopLeft(), point: { x: s.clientX, y: s.clientY } }, !0;
785
+ const a = e.nativeEvent, u = t.current.getViewFromClient(a.clientX, a.clientY);
786
+ if (a.pointerType === "touch" || a.type === "touchstart") return Rt.current = { topLeft: u.getScrollTopLeft(), point: { x: a.clientX, y: a.clientY } }, !0;
753
787
  const d = u.getCellCoordsFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY);
754
788
  if (!d) return !1;
755
- Ze.current = { anchor: u.getAnchor(), coords: d }, Be.current = null;
756
- const x = e.nativeEvent.which === jn.Right;
757
- if (x && $.indexOfCoords(d, m.ranges) !== -1)
789
+ et.current = { anchor: u.getAnchor(), coords: d }, Ae.current = null;
790
+ const f = e.nativeEvent.which === Xn.Right;
791
+ if (f && F.indexOfCoords(d, m.ranges) !== -1)
758
792
  return !1;
759
- const E = e.nativeEvent.shiftKey, w = e.nativeEvent.ctrlKey || e.nativeEvent.metaKey, j = w, V = T, U = m.ranges.length > 0, _ = w && V;
760
- if (me?.(e, d, m) === !1) return !1;
761
- a?.(ie.current, e.nativeEvent);
762
- const be = !x && l !== "single";
763
- if (E) return ut(d), be;
764
- const q = $.isEqualCells(d, m.cell);
765
- if (j) {
766
- if (q && (!_ || !U)) return be;
767
- if (w && $.indexOfCoords(d, m.ranges) !== -1 && V) {
768
- wt.current = d;
769
- const H = ze(d, d);
770
- return Bt.current = H, Wt(H), be;
793
+ const I = e.nativeEvent.shiftKey, x = e.nativeEvent.ctrlKey || e.nativeEvent.metaKey, G = x, H = k, N = m.ranges.length > 0, te = x && H;
794
+ if (se?.(e, d, m) === !1) return !1;
795
+ c?.(le.current, e.nativeEvent);
796
+ const ve = !f && l !== "single";
797
+ if (I) return gt(d), ve;
798
+ const q = F.isEqualCells(d, m.cell);
799
+ if (G) {
800
+ if (q && (!te || !N)) return ve;
801
+ if (x && F.indexOfCoords(d, m.ranges) !== -1 && H) {
802
+ mt.current = d;
803
+ const K = De(d, d);
804
+ return Bt.current = K, Ut(K), ve;
771
805
  }
772
- return Le(d), be;
806
+ return Te(d), ve;
773
807
  }
774
- Se && xt(d), q && m.ranges.length === 0 || vt(d);
775
- }, onPointerMoveOrWait: Ht.throttle((e, s) => {
776
- if (!t?.current || e.pointerType === "touch" || e.type === "touchmove" || !Ze.current) return;
777
- const u = Ze.current.anchor;
778
- let d = t.current.getViewFromLocation(u), x = d.getCellCoordsFromClient(e.clientX, e.clientY);
779
- if (!$.isEqualCells(x, Ze.current?.coords) && (Ze.current = { anchor: u, coords: x }, x && Ve?.(e, x, ie.current) !== !1)) {
780
- if (wt.current) {
781
- const E = { rowStart: Math.min(x.rowIndex, wt.current.rowIndex), colStart: Math.min(x.colIndex, wt.current.colIndex), rowEnd: Math.max(x.rowIndex, wt.current.rowIndex), colEnd: Math.max(x.colIndex, wt.current.colIndex) }, w = { rowIndex: E.rowStart, colIndex: E.colStart }, j = { rowIndex: E.rowEnd, colIndex: E.colEnd };
782
- if (qt(w) || qt(j)) return;
783
- const V = ze(w, j);
784
- Bt.current = V, Wt(V);
785
- } else ut(x);
786
- Dt.current = s, Dn(d, x, t);
808
+ he && vt(d), q && m.ranges.length === 0 || It(d);
809
+ }, onPointerMoveOrWait: Nt.throttle((e, a) => {
810
+ if (!t?.current || e.pointerType === "touch" || e.type === "touchmove" || !et.current) return;
811
+ const u = et.current.anchor;
812
+ let d = t.current.getViewFromLocation(u), f = d.getCellCoordsFromClient(e.clientX, e.clientY);
813
+ if (!F.isEqualCells(f, et.current?.coords) && (et.current = { anchor: u, coords: f }, f && Ue?.(e, f, le.current) !== !1)) {
814
+ if (mt.current) {
815
+ const I = { rowStart: Math.min(f.rowIndex, mt.current.rowIndex), colStart: Math.min(f.colIndex, mt.current.colIndex), rowEnd: Math.max(f.rowIndex, mt.current.rowIndex), colEnd: Math.max(f.colIndex, mt.current.colIndex) }, x = { rowIndex: I.rowStart, colIndex: I.colStart }, G = { rowIndex: I.rowEnd, colIndex: I.colEnd };
816
+ if (jt(x) || jt(G)) return;
817
+ const H = De(x, G);
818
+ Bt.current = H, Ut(H);
819
+ } else gt(f);
820
+ Tt.current = a, Dn(d, f, t);
787
821
  }
788
822
  }, 60), onPointerUp: (e) => {
789
- if (Ze.current = null, e.pointerType === "touch" || e.type === "touchend") {
790
- if (It.current) {
791
- const u = t.current.getViewFromClient(It.current.point.x, It.current.point.y), d = u.getScrollTopLeft();
792
- if (d.left === It.current.topLeft.left && d.top === It.current.topLeft.top) {
793
- const x = u.getCellCoordsFromClient(It.current.point.x, It.current.point.y);
794
- vt(x);
823
+ if (et.current = null, e.pointerType === "touch" || e.type === "touchend") {
824
+ if (Rt.current) {
825
+ const u = t.current.getViewFromClient(Rt.current.point.x, Rt.current.point.y), d = u.getScrollTopLeft();
826
+ if (d.left === Rt.current.topLeft.left && d.top === Rt.current.topLeft.top) {
827
+ const f = u.getCellCoordsFromClient(Rt.current.point.x, Rt.current.point.y);
828
+ It(f);
795
829
  }
796
830
  }
797
- return It.current = null, void (Ze.current = null);
831
+ return Rt.current = null, void (et.current = null);
798
832
  }
799
833
  try {
800
- i?.(ie.current, e);
834
+ i?.(le.current, e);
801
835
  } catch (u) {
802
836
  console.warn(u);
803
837
  }
804
- if (!wt.current) return;
805
- const s = Bt.current;
806
- wt.current = null, Bt.current = null, Wt(null), ft((u) => {
807
- if (Xe.current = !1, (u = $t(u)).ranges.length === 0) return u;
808
- let d = [], x = -1, E = u.cell;
809
- for (let j = 0; j < u.ranges.length; j++) {
810
- const V = u.ranges[j];
811
- if ($.isRangesIntersect(V, s)) {
812
- const U = Ht.subtractRect({ top: V.rowStart, left: V.colStart, bottom: V.rowEnd + 1, right: V.colEnd + 1 }, { top: s.rowStart, left: s.colStart, bottom: s.rowEnd + 1, right: s.colEnd + 1 });
813
- for (let _ = 0; _ < U.length; _++) {
814
- const be = { rowStart: U[_].top, colStart: U[_].left, rowEnd: U[_].bottom - 1, colEnd: U[_].right - 1 };
815
- d.push(be), $.isCellWithinRange(u.cell, be) && (x = d.length - 1);
838
+ if (!mt.current) return;
839
+ const a = Bt.current;
840
+ mt.current = null, Bt.current = null, Ut(null), wt((u) => {
841
+ if (Je.current = !1, (u = $t(u)).ranges.length === 0) return u;
842
+ let d = [], f = -1, I = u.cell;
843
+ for (let G = 0; G < u.ranges.length; G++) {
844
+ const H = u.ranges[G];
845
+ if (F.isRangesIntersect(H, a)) {
846
+ const N = Nt.subtractRect({ top: H.rowStart, left: H.colStart, bottom: H.rowEnd + 1, right: H.colEnd + 1 }, { top: a.rowStart, left: a.colStart, bottom: a.rowEnd + 1, right: a.colEnd + 1 });
847
+ for (let te = 0; te < N.length; te++) {
848
+ const ve = { rowStart: N[te].top, colStart: N[te].left, rowEnd: N[te].bottom - 1, colEnd: N[te].right - 1 };
849
+ d.push(ve), F.isCellWithinRange(u.cell, ve) && (f = d.length - 1);
816
850
  }
817
- } else d.push(V);
818
- d.length > 0 && x === -1 && $.isCellWithinRange(u.cell, V) && (x = d.length - 1, E = { rowIndex: d[d.length - 1].rowStart, colIndex: d[d.length - 1].colStart });
851
+ } else d.push(H);
852
+ d.length > 0 && f === -1 && F.isCellWithinRange(u.cell, H) && (f = d.length - 1, I = { rowIndex: d[d.length - 1].rowStart, colIndex: d[d.length - 1].colStart });
819
853
  }
820
- const w = { cell: E, rangeIndex: x, ranges: d };
821
- return $.isEqualSelectionCoords(w, u) ? u : w;
854
+ const x = { cell: I, rangeIndex: f, ranges: d };
855
+ return F.isEqualSelectionCoords(x, u) ? u : x;
822
856
  });
823
- }, processTouch: !0, consumeTouch: !1 }), [m, l, T, Se, h]), zn = D(un(sn), []), Ln = Ae(() => ({ onSelectionPointerDown: (e, s, u, d, x = m.cell, E = Se, w = e.nativeEvent.shiftKey, j = !1) => {
857
+ }, processTouch: !0, consumeTouch: !1 }), [m, l, k, he, h]), zn = L(un(sn), []), $n = Ve(() => ({ onSelectionPointerDown: (e, a, u, d, f = m.cell, I = he, x = e.nativeEvent.shiftKey, G = !1) => {
824
858
  if (!t || !t.current) return !1;
825
859
  e.stopPropagation(), e.preventDefault(), e.nativeEvent.stopImmediatePropagation();
826
- const V = u ?? t.current.getViewFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY), U = d ?? V.getCellCoordsFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY);
827
- if (!U) return !1;
828
- Ze.current = { anchor: V.getAnchor(), coords: U }, Be.current = null;
829
- const _ = e.nativeEvent.which === jn.Right;
830
- if (_ && $.indexOfCoords(U, m.ranges) !== -1)
860
+ const H = u ?? t.current.getViewFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY), N = d ?? H.getCellCoordsFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY);
861
+ if (!N) return !1;
862
+ et.current = { anchor: H.getAnchor(), coords: N }, Ae.current = null;
863
+ const te = e.nativeEvent.which === Xn.Right;
864
+ if (te && F.indexOfCoords(N, m.ranges) !== -1)
831
865
  return !1;
832
- const be = e.nativeEvent.ctrlKey || e.nativeEvent.metaKey, q = be, H = T, ct = m.ranges.length > 0, b = be && H;
833
- if (me?.(e, U, m) === !1) return !1;
834
- a?.(ie.current, e.nativeEvent);
835
- const pe = !_ && l !== "single";
836
- if (w) return ut(U, x, j), pe;
837
- const pt = $.isEqualCells(U, x);
866
+ const ve = e.nativeEvent.ctrlKey || e.nativeEvent.metaKey, q = ve, K = k, at = m.ranges.length > 0, C = ve && K;
867
+ if (se?.(e, N, m) === !1) return !1;
868
+ c?.(le.current, e.nativeEvent);
869
+ const pe = !te && l !== "single";
870
+ if (x) return gt(N, f, G), pe;
871
+ const bt = F.isEqualCells(N, f);
838
872
  if (q) {
839
- if (pt && (!b || !ct)) return pe;
840
- if (b && $.indexOfCoords(U, m.ranges) !== -1 && H) {
841
- wt.current = U;
842
- const we = ze(U, U);
843
- return Bt.current = we, Wt(we), pe;
873
+ if (bt && (!C || !at)) return pe;
874
+ if (C && F.indexOfCoords(N, m.ranges) !== -1 && K) {
875
+ mt.current = N;
876
+ const we = De(N, N);
877
+ return Bt.current = we, Ut(we), pe;
844
878
  }
845
- return Le(U), pe;
879
+ return Te(N), pe;
846
880
  }
847
- E && xt(U), pt && m.ranges.length === 0 || vt(U);
848
- }, onSelectionPointerMoveOrWait: (e, s, u, d, x, E = m.cell, w = !0, j = !1) => {
849
- if (!t?.current || (e.stopPropagation(), e.preventDefault(), e.stopImmediatePropagation(), !Ze.current)) return;
850
- const V = Ze.current.anchor;
851
- let U = d ?? t.current.getViewFromLocation(V), _ = x ?? U.getCellCoordsFromClient(e.clientX, e.clientY);
852
- if (!$.isEqualCells(_, Ze.current?.coords) && (Ze.current = { anchor: V, coords: _ }, _ && Ve?.(e, _, ie.current) !== !1)) {
853
- if (wt.current) {
854
- const be = { rowStart: Math.min(_.rowIndex, wt.current.rowIndex), colStart: Math.min(_.colIndex, wt.current.colIndex), rowEnd: Math.max(_.rowIndex, wt.current.rowIndex), colEnd: Math.max(_.colIndex, wt.current.colIndex) }, q = { rowIndex: be.rowStart, colIndex: be.colStart }, H = { rowIndex: be.rowEnd, colIndex: be.colEnd };
855
- if (qt(q) || qt(H)) return;
856
- const ct = ze(q, H);
857
- Bt.current = ct, Wt(ct);
858
- } else ut(_, E, j);
859
- w && Dn(U, _, t);
881
+ I && vt(N), bt && m.ranges.length === 0 || It(N);
882
+ }, onSelectionPointerMoveOrWait: (e, a, u, d, f, I = m.cell, x = !0, G = !1) => {
883
+ if (!t?.current || (e.stopPropagation(), e.preventDefault(), e.stopImmediatePropagation(), !et.current)) return;
884
+ const H = et.current.anchor;
885
+ let N = d ?? t.current.getViewFromLocation(H), te = f ?? N.getCellCoordsFromClient(e.clientX, e.clientY);
886
+ if (!F.isEqualCells(te, et.current?.coords) && (et.current = { anchor: H, coords: te }, te && Ue?.(e, te, le.current) !== !1)) {
887
+ if (mt.current) {
888
+ const ve = { rowStart: Math.min(te.rowIndex, mt.current.rowIndex), colStart: Math.min(te.colIndex, mt.current.colIndex), rowEnd: Math.max(te.rowIndex, mt.current.rowIndex), colEnd: Math.max(te.colIndex, mt.current.colIndex) }, q = { rowIndex: ve.rowStart, colIndex: ve.colStart }, K = { rowIndex: ve.rowEnd, colIndex: ve.colEnd };
889
+ if (jt(q) || jt(K)) return;
890
+ const at = De(q, K);
891
+ Bt.current = at, Ut(at);
892
+ } else gt(te, I, G);
893
+ x && Dn(N, te, t);
860
894
  }
861
895
  }, onPointerUp: (e) => {
862
- Ze.current = null, e.stopPropagation(), e.preventDefault(), e.stopImmediatePropagation();
896
+ et.current = null, e.stopPropagation(), e.preventDefault(), e.stopImmediatePropagation();
863
897
  try {
864
- i?.(ie.current, e);
898
+ i?.(le.current, e);
865
899
  } catch (u) {
866
900
  console.warn(u);
867
901
  }
868
- if (!wt.current) return;
869
- const s = Bt.current;
870
- wt.current = null, Bt.current = null, Wt(null), ft((u) => {
871
- if (Xe.current = !1, (u = $t(u)).ranges.length === 0) return u;
872
- let d = [], x = -1, E = u.cell;
873
- for (let j = 0; j < u.ranges.length; j++) {
874
- const V = u.ranges[j];
875
- if ($.isRangesIntersect(V, s)) {
876
- const U = Ht.subtractRect({ top: V.rowStart, left: V.colStart, bottom: V.rowEnd + 1, right: V.colEnd + 1 }, { top: s.rowStart, left: s.colStart, bottom: s.rowEnd + 1, right: s.colEnd + 1 });
877
- for (let _ = 0; _ < U.length; _++) {
878
- const be = { rowStart: U[_].top, colStart: U[_].left, rowEnd: U[_].bottom - 1, colEnd: U[_].right - 1 };
879
- d.push(be), $.isCellWithinRange(u.cell, be) && (x = d.length - 1);
902
+ if (!mt.current) return;
903
+ const a = Bt.current;
904
+ mt.current = null, Bt.current = null, Ut(null), wt((u) => {
905
+ if (Je.current = !1, (u = $t(u)).ranges.length === 0) return u;
906
+ let d = [], f = -1, I = u.cell;
907
+ for (let G = 0; G < u.ranges.length; G++) {
908
+ const H = u.ranges[G];
909
+ if (F.isRangesIntersect(H, a)) {
910
+ const N = Nt.subtractRect({ top: H.rowStart, left: H.colStart, bottom: H.rowEnd + 1, right: H.colEnd + 1 }, { top: a.rowStart, left: a.colStart, bottom: a.rowEnd + 1, right: a.colEnd + 1 });
911
+ for (let te = 0; te < N.length; te++) {
912
+ const ve = { rowStart: N[te].top, colStart: N[te].left, rowEnd: N[te].bottom - 1, colEnd: N[te].right - 1 };
913
+ d.push(ve), F.isCellWithinRange(u.cell, ve) && (f = d.length - 1);
880
914
  }
881
- } else d.push(V);
882
- d.length > 0 && x === -1 && $.isCellWithinRange(u.cell, V) && (x = d.length - 1, E = { rowIndex: d[d.length - 1].rowStart, colIndex: d[d.length - 1].colStart });
915
+ } else d.push(H);
916
+ d.length > 0 && f === -1 && F.isCellWithinRange(u.cell, H) && (f = d.length - 1, I = { rowIndex: d[d.length - 1].rowStart, colIndex: d[d.length - 1].colStart });
883
917
  }
884
- const w = { cell: E, rangeIndex: x, ranges: d };
885
- return $.isEqualSelectionCoords(w, u) ? u : w;
918
+ const x = { cell: I, rangeIndex: f, ranges: d };
919
+ return F.isEqualSelectionCoords(x, u) ? u : x;
886
920
  });
887
- } }), [m, l, T, Se, h]), Je = D((e, s = !1, u = !1, d = 0) => {
921
+ } }), [m, l, k, he, h]), nt = L((e, a = !1, u = !1, d = 0) => {
888
922
  if (!t.current || !m.cell) return;
889
- let x = m.cell, E = m.cell;
890
- if (s && m.ranges.length > 0) {
891
- const b = m.ranges[m.rangeIndex], pe = m.cell;
923
+ let f = m.cell, I = m.cell;
924
+ if (a && m.ranges.length > 0) {
925
+ const C = m.ranges[m.rangeIndex], pe = m.cell;
892
926
  switch (e) {
893
- case f.Up:
894
- E = { rowIndex: pe.rowIndex === b.rowStart ? b.rowEnd : b.rowStart, colIndex: b.colEnd }, x = { rowIndex: pe.rowIndex === b.rowStart ? b.rowStart : b.rowEnd, colIndex: b.colStart };
927
+ case w.Up:
928
+ I = { rowIndex: pe.rowIndex === C.rowStart ? C.rowEnd : C.rowStart, colIndex: C.colEnd }, f = { rowIndex: pe.rowIndex === C.rowStart ? C.rowStart : C.rowEnd, colIndex: C.colStart };
895
929
  break;
896
- case f.Down:
897
- E = { rowIndex: pe.rowIndex === b.rowEnd ? b.rowStart : b.rowEnd, colIndex: b.colEnd }, x = { rowIndex: pe.rowIndex === b.rowEnd ? b.rowEnd : b.rowStart, colIndex: b.colStart };
930
+ case w.Down:
931
+ I = { rowIndex: pe.rowIndex === C.rowEnd ? C.rowStart : C.rowEnd, colIndex: C.colEnd }, f = { rowIndex: pe.rowIndex === C.rowEnd ? C.rowEnd : C.rowStart, colIndex: C.colStart };
898
932
  break;
899
- case f.Left:
900
- E = { rowIndex: b.rowEnd, colIndex: pe.colIndex === b.colStart ? b.colEnd : b.colStart }, x = { rowIndex: b.rowStart, colIndex: pe.colIndex === b.colStart ? b.colStart : b.colEnd };
933
+ case w.Left:
934
+ I = { rowIndex: C.rowEnd, colIndex: pe.colIndex === C.colStart ? C.colEnd : C.colStart }, f = { rowIndex: C.rowStart, colIndex: pe.colIndex === C.colStart ? C.colStart : C.colEnd };
901
935
  break;
902
- case f.Right:
903
- E = { rowIndex: b.rowEnd, colIndex: pe.colIndex === b.colEnd ? b.colStart : b.colEnd }, x = { rowIndex: b.rowStart, colIndex: pe.colIndex === b.colEnd ? b.colEnd : b.colStart };
936
+ case w.Right:
937
+ I = { rowIndex: C.rowEnd, colIndex: pe.colIndex === C.colEnd ? C.colStart : C.colEnd }, f = { rowIndex: C.rowStart, colIndex: pe.colIndex === C.colEnd ? C.colEnd : C.colStart };
904
938
  }
905
939
  }
906
- const w = F(E);
907
- let { rowStart: j, colStart: V } = w;
908
- const U = fe();
909
- if (Be.current) switch (e) {
910
- case f.Up:
911
- case f.Down:
912
- Be.current.colIndex >= w.colStart && Be.current.colIndex <= w.colEnd && (V = Be.current.colIndex);
940
+ const x = ne(I);
941
+ let { rowStart: G, colStart: H } = x;
942
+ const N = fe();
943
+ if (Ae.current) switch (e) {
944
+ case w.Up:
945
+ case w.Down:
946
+ Ae.current.colIndex >= x.colStart && Ae.current.colIndex <= x.colEnd && (H = Ae.current.colIndex);
913
947
  break;
914
- case f.Left:
915
- case f.Right:
916
- Be.current.rowIndex >= w.rowStart && Be.current.rowIndex <= w.rowEnd && (j = Be.current.rowIndex);
948
+ case w.Left:
949
+ case w.Right:
950
+ Ae.current.rowIndex >= x.rowStart && Ae.current.rowIndex <= x.rowEnd && (G = Ae.current.rowIndex);
917
951
  }
918
952
  if (!d) {
919
953
  switch (e) {
920
- case f.Up:
921
- j = Fe(et, Math.max(w.rowStart - 1, U.top), e);
954
+ case w.Up:
955
+ G = We(ot, Math.max(x.rowStart - 1, N.top), e);
922
956
  break;
923
- case f.Down:
924
- j = Fe(et, Math.min(w.rowEnd + 1, U.bottom), e);
957
+ case w.Down:
958
+ G = We(ot, Math.min(x.rowEnd + 1, N.bottom), e);
925
959
  break;
926
- case f.Left:
927
- V = Fe(tt, Math.max(w.colStart - 1, U.left), e);
960
+ case w.Left:
961
+ H = We(rt, Math.max(x.colStart - 1, N.left), e);
928
962
  break;
929
- case f.Right:
930
- V = Fe(tt, Math.min(w.colEnd + 1, U.right), e);
963
+ case w.Right:
964
+ H = We(rt, Math.min(x.colEnd + 1, N.right), e);
931
965
  }
932
966
  if (u) switch (e) {
933
- case f.Up:
934
- j = k({ ...E, colIndex: m.cell.colIndex }, le, et, e, !1, Math.max(U.top, et(U.top, !1)));
967
+ case w.Up:
968
+ G = R({ ...I, colIndex: m.cell.colIndex }, re, ot, e, !1, Math.max(N.top, ot(N.top, !1)));
935
969
  break;
936
- case f.Down:
937
- j = k({ ...E, colIndex: m.cell.colIndex }, le, et, e, !1, Math.min(U.bottom, U.bottom - et(U.bottom, !0)));
970
+ case w.Down:
971
+ G = R({ ...I, colIndex: m.cell.colIndex }, re, ot, e, !1, Math.min(N.bottom, N.bottom - ot(N.bottom, !0)));
938
972
  break;
939
- case f.Left:
940
- V = k({ ...E, rowIndex: m.cell.rowIndex }, le, tt, e, !1, Math.max(U.left, tt(U.left, !1)));
973
+ case w.Left:
974
+ H = R({ ...I, rowIndex: m.cell.rowIndex }, re, rt, e, !1, Math.max(N.left, rt(N.left, !1)));
941
975
  break;
942
- case f.Right:
943
- V = k({ ...E, rowIndex: m.cell.rowIndex }, le, tt, e, !1, Math.min(U.right, U.right - tt(U.right, !0)));
976
+ case w.Right:
977
+ H = R({ ...I, rowIndex: m.cell.rowIndex }, re, rt, e, !1, Math.min(N.right, N.right - rt(N.right, !0)));
944
978
  }
945
979
  }
946
- let _ = null;
980
+ let te = null;
947
981
  if (d) {
948
- let b = 0;
982
+ let C = 0;
949
983
  switch (e) {
950
- case f.Up:
951
- b = o.getRowOffset(j + 1), j = Math.max(U.top, o.getRowIndex(b - d)), _ = { top: o.getRowOffset(j + 1) - (b - t.current.getScrollPosition().top) };
984
+ case w.Up:
985
+ C = o.getRowOffset(G + 1), G = Math.max(N.top, o.getRowIndex(C - d)), te = { top: o.getRowOffset(G + 1) - (C - t.current.getScrollPosition().top) };
952
986
  break;
953
- case f.Down:
954
- b = o.getRowOffset(j), j = Math.min(U.bottom, o.getRowIndex(b + d)), _ = { top: o.getRowOffset(j) - (b - t.current.getScrollPosition().top) };
987
+ case w.Down:
988
+ C = o.getRowOffset(G), G = Math.min(N.bottom, o.getRowIndex(C + d)), te = { top: o.getRowOffset(G) - (C - t.current.getScrollPosition().top) };
955
989
  break;
956
- case f.Left:
957
- b = o.getColOffset(V + 1), V = Math.max(U.left, o.getColIndex(b - d)), _ = { left: o.getColOffset(V + 1) - (b - t.current.getScrollPosition().left) };
990
+ case w.Left:
991
+ C = o.getColOffset(H + 1), H = Math.max(N.left, o.getColIndex(C - d)), te = { left: o.getColOffset(H + 1) - (C - t.current.getScrollPosition().left) };
958
992
  break;
959
- case f.Right:
960
- b = o.getColOffset(V), V = Math.min(U.right, o.getColIndex(b + d)), _ = { left: o.getColOffset(V) - (b - t.current.getScrollPosition().left) };
993
+ case w.Right:
994
+ C = o.getColOffset(H), H = Math.min(N.right, o.getColIndex(C + d)), te = { left: o.getColOffset(H) - (C - t.current.getScrollPosition().left) };
961
995
  }
962
996
  }
963
- const be = { rowIndex: j, colIndex: V }, q = F(be), H = { rowIndex: q.rowStart, colIndex: q.colStart };
964
- s || (Be.current = be);
965
- const ct = $.isEqualCells(He.current, H) && $.isEqualCells(He.current, x);
966
- if (s && !ct ? ut(H, x) : vt(H), _) t.current.scrollTo(_);
997
+ const ve = { rowIndex: G, colIndex: H }, q = ne(ve), K = { rowIndex: q.rowStart, colIndex: q.colStart };
998
+ a || (Ae.current = ve);
999
+ const at = F.isEqualCells(Ke.current, K) && F.isEqualCells(Ke.current, f);
1000
+ if (a && !at ? gt(K, f) : It(K), te) t.current.scrollTo(te);
967
1001
  else {
968
- if (s && He.current) {
969
- const b = fe();
970
- if (e === f.Right && He.current.colIndex === b.left || e === f.Left && He.current.colIndex === b.right || e === f.Up && He.current.rowIndex === b.bottom || e === f.Down && He.current.rowIndex === b.top) return;
1002
+ if (a && Ke.current) {
1003
+ const C = fe();
1004
+ if (e === w.Right && Ke.current.colIndex === C.left || e === w.Left && Ke.current.colIndex === C.right || e === w.Up && Ke.current.rowIndex === C.bottom || e === w.Down && Ke.current.rowIndex === C.top) return;
971
1005
  }
972
- e === f.Left || e === f.Right ? xt({ colIndex: be.colIndex }) : e !== f.Up && e !== f.Down || xt({ rowIndex: be.rowIndex });
1006
+ e === w.Left || e === w.Right ? vt({ colIndex: ve.colIndex }) : e !== w.Up && e !== w.Down || vt({ rowIndex: ve.rowIndex });
973
1007
  }
974
- }, [m, F]), jt = D((e) => {
1008
+ }, [m, ne]), Yt = L((e) => {
975
1009
  if (!t.current) return;
976
- if (m.ranges.length === 0) return void Je(e);
977
- const s = F(m.cell);
978
- if ($.isEqualRangesArrays([s], m.ranges)) return void Je(e);
979
- const u = Yn(m, e, F, et, tt);
980
- ft((d) => {
981
- Xe.current = !1, d = $t(d);
982
- const x = { ...d, cell: u.cell, rangeIndex: u.rangeIndex };
983
- return $.isEqualSelectionCoords(x, d) ? d : x;
984
- }), u.cell && xt(u.cell);
985
- }, [m, F]), $n = z(() => {
1010
+ if (m.ranges.length === 0) return void nt(e);
1011
+ const a = ne(m.cell);
1012
+ if (F.isEqualRangesArrays([a], m.ranges)) return void nt(e);
1013
+ const u = Gn(m, e, ne, ot, rt);
1014
+ wt((d) => {
1015
+ Je.current = !1, d = $t(d);
1016
+ const f = { ...d, cell: u.cell, rangeIndex: u.rangeIndex };
1017
+ return F.isEqualSelectionCoords(f, d) ? d : f;
1018
+ }), u.cell && vt(u.cell);
1019
+ }, [m, ne]), Bn = $(() => {
986
1020
  const e = fe();
987
- ut({ rowIndex: e.top }, { rowIndex: e.bottom });
988
- }, []), Bn = z(() => {
1021
+ gt({ rowIndex: e.top }, { rowIndex: e.bottom });
1022
+ }, []), An = $(() => {
989
1023
  const e = fe();
990
- ut({ colIndex: e.left }, { colIndex: e.right });
991
- }, []), nn = D(() => {
992
- m.cell && t?.current && xt(m.cell);
993
- }, [m.cell]), Sn = z((e = !1) => {
994
- const s = { rowIndex: fe().top };
995
- e ? ut(s) : vt(s), xt(s);
996
- }, []), yn = z((e = !1) => {
997
- const s = { rowIndex: fe().bottom };
998
- e ? ut(s) : vt(s), xt(s);
999
- }, []), gn = z((e = !1) => {
1000
- const s = { colIndex: fe().left };
1001
- e ? ut(s) : vt(s), xt(s);
1002
- }, []), an = z((e = !1) => {
1003
- const s = fe(), u = { rowIndex: s.top, colIndex: s.left };
1004
- e ? ut(u) : vt(u), xt(u);
1005
- }, []), fn = z((e = !1) => {
1006
- const s = fe(), u = { colIndex: Q?.()?.colEnd ?? s.right };
1007
- e ? ut(u) : vt(u), xt(u);
1008
- }, [Q]), on = z((e = !1) => {
1009
- const s = fe(), u = { rowIndex: Q?.()?.rowEnd ?? s.bottom, colIndex: Q?.()?.colEnd ?? s.right };
1010
- e ? ut(u) : vt(u), xt(u);
1011
- }, [Q]), wn = D((e) => {
1024
+ gt({ colIndex: e.left }, { colIndex: e.right });
1025
+ }, []), nn = L(() => {
1026
+ m.cell && t?.current && vt(m.cell);
1027
+ }, [m.cell]), Sn = $((e = !1) => {
1028
+ const a = { rowIndex: fe().top };
1029
+ e ? gt(a) : It(a), vt(a);
1030
+ }, []), yn = $((e = !1) => {
1031
+ const a = { rowIndex: fe().bottom };
1032
+ e ? gt(a) : It(a), vt(a);
1033
+ }, []), gn = $((e = !1) => {
1034
+ const a = { colIndex: fe().left };
1035
+ e ? gt(a) : It(a), vt(a);
1036
+ }, []), an = $((e = !1) => {
1037
+ const a = fe(), u = { rowIndex: a.top, colIndex: a.left };
1038
+ e ? gt(u) : It(u), vt(u);
1039
+ }, []), fn = $((e = !1) => {
1040
+ const a = fe(), u = { colIndex: U?.()?.colEnd ?? a.right };
1041
+ e ? gt(u) : It(u), vt(u);
1042
+ }, [U]), on = $((e = !1) => {
1043
+ const a = fe(), u = { rowIndex: U?.()?.rowEnd ?? a.bottom, colIndex: U?.()?.colEnd ?? a.right };
1044
+ e ? gt(u) : It(u), vt(u);
1045
+ }, [U]), wn = L((e) => {
1012
1046
  if (!t.current || m.ranges.length <= 1) return;
1013
- const s = e === f.Left || e === f.Up;
1014
- let u = m.rangeIndex + (s ? -1 : 1);
1047
+ const a = e === w.Left || e === w.Up;
1048
+ let u = m.rangeIndex + (a ? -1 : 1);
1015
1049
  u < 0 ? u = m.ranges.length - 1 : u > m.ranges.length - 1 && (u = 0);
1016
- const d = m.ranges[u], x = Yn({ cell: { rowIndex: d.rowEnd, colIndex: d.colEnd }, rangeIndex: 0, ranges: [d] }, f.Right, F, et, tt);
1017
- ft((E) => {
1018
- Xe.current = !1, E = $t(E);
1019
- const w = { ...E, cell: x.cell, rangeIndex: u };
1020
- return $.isEqualSelectionCoords(w, E) ? E : w;
1021
- }), x.cell && xt(x.cell);
1022
- }, [m, F]), An = D(() => {
1023
- const e = oo(m);
1024
- ft((s) => {
1025
- Xe.current = !1, s = $t(s);
1026
- const u = { ...s, visibleSelection: e };
1027
- return $.isEqualSelectionCoords(u, s) ? s : u;
1028
- }), e.cell && xt(e.cell);
1029
- }, [m, F]), Fn = D(() => {
1050
+ const d = m.ranges[u], f = Gn({ cell: { rowIndex: d.rowEnd, colIndex: d.colEnd }, rangeIndex: 0, ranges: [d] }, w.Right, ne, ot, rt);
1051
+ wt((I) => {
1052
+ Je.current = !1, I = $t(I);
1053
+ const x = { ...I, cell: f.cell, rangeIndex: u };
1054
+ return F.isEqualSelectionCoords(x, I) ? I : x;
1055
+ }), f.cell && vt(f.cell);
1056
+ }, [m, ne]), Fn = L(() => {
1057
+ const e = lo(m);
1058
+ wt((a) => {
1059
+ Je.current = !1, a = $t(a);
1060
+ const u = { ...a, visibleSelection: e };
1061
+ return F.isEqualSelectionCoords(u, a) ? a : u;
1062
+ }), e.cell && vt(e.cell);
1063
+ }, [m, ne]), Vn = L(() => {
1030
1064
  if (!t.current || m.ranges.length === 0) return;
1031
- const e = m.cell, s = m.ranges[m.rangeIndex], u = oo({ cell: e, rangeIndex: 0, ranges: [s] }), d = u.ranges[u.rangeIndex];
1032
- let x;
1033
- x = d.rowStart === e.rowIndex && d.colStart === e.colIndex ? { rowIndex: d.rowStart, colIndex: d.colEnd } : d.rowStart === e.rowIndex && d.colEnd === e.colIndex ? { rowIndex: d.rowEnd, colIndex: d.colStart } : d.rowEnd === e.rowIndex && d.colStart === e.colIndex ? { rowIndex: d.rowEnd, colIndex: d.colEnd } : { rowIndex: d.rowStart, colIndex: d.colStart }, ft((E) => {
1034
- E = $t(E);
1035
- const w = { ...E, cell: x };
1036
- return $.isEqualSelectionCoords(w, E) ? E : w;
1037
- }), x && xt(x);
1038
- }, [m, F]), bn = z((e = !1) => {
1039
- Je(f.Down, e, !1, t.current.getDimensions().containerHeight);
1040
- }, []), At = z((e = !1) => {
1041
- Je(f.Up, e, !1, t.current.getDimensions().containerHeight);
1042
- }, []), Cn = z((e = !1) => {
1043
- Je(f.Right, e, !1, t.current.getDimensions().containerWidth);
1044
- }, []), xn = z((e = !1) => {
1045
- Je(f.Left, e, !1, t.current.getDimensions().containerWidth);
1046
- }, []), In = z(() => {
1047
- jt(f.Left);
1048
- }, []), En = z(() => {
1049
- jt(f.Right);
1050
- }, []), Vn = z(() => {
1051
- jt(f.Up);
1052
- }, []), Wn = z(() => {
1053
- jt(f.Down);
1054
- }, []), pn = z(() => {
1055
- wn(f.Left);
1056
- }, []), Un = z(() => {
1057
- wn(f.Right);
1058
- }, []), Hn = z(() => {
1059
- Fn();
1060
- }, []), Rn = z(() => {
1061
- Je(f.Left, !1, !1);
1062
- }, []), g = z(() => {
1063
- Je(f.Left, !0, !1);
1064
- }, []), v = z(() => {
1065
- Je(f.Left, !1, !0);
1066
- }, []), y = z(() => {
1067
- Je(f.Left, !0, !0);
1068
- }, []), C = z(() => {
1069
- Je(f.Right, !1, !1);
1070
- }, []), I = z(() => {
1071
- Je(f.Right, !0, !1);
1072
- }, []), Y = z(() => {
1073
- Je(f.Right, !1, !0);
1074
- }, []), N = z(() => {
1075
- Je(f.Right, !0, !0);
1076
- }, []), ee = z(() => {
1077
- Je(f.Up, !1, !1);
1078
- }, []), ne = z(() => {
1079
- Je(f.Up, !0, !1);
1080
- }, []), K = z(() => {
1081
- Je(f.Up, !1, !0);
1082
- }, []), De = z(() => {
1083
- Je(f.Up, !0, !0);
1084
- }, []), Qe = z(() => {
1085
- Je(f.Down, !1, !1);
1086
- }, []), Re = z(() => {
1087
- Je(f.Down, !0, !1);
1088
- }, []), Me = z(() => {
1089
- Je(f.Down, !1, !0);
1090
- }, []), nt = z(() => {
1091
- Je(f.Down, !0, !0);
1092
- }, []), Ne = z(() => {
1093
- dt((e) => e.slice(0, -1));
1094
- }, []), St = Ae(() => {
1065
+ const e = m.cell, a = m.ranges[m.rangeIndex], u = lo({ cell: e, rangeIndex: 0, ranges: [a] }), d = u.ranges[u.rangeIndex];
1066
+ let f;
1067
+ f = d.rowStart === e.rowIndex && d.colStart === e.colIndex ? { rowIndex: d.rowStart, colIndex: d.colEnd } : d.rowStart === e.rowIndex && d.colEnd === e.colIndex ? { rowIndex: d.rowEnd, colIndex: d.colStart } : d.rowEnd === e.rowIndex && d.colStart === e.colIndex ? { rowIndex: d.rowEnd, colIndex: d.colEnd } : { rowIndex: d.rowStart, colIndex: d.colStart }, wt((I) => {
1068
+ I = $t(I);
1069
+ const x = { ...I, cell: f };
1070
+ return F.isEqualSelectionCoords(x, I) ? I : x;
1071
+ }), f && vt(f);
1072
+ }, [m, ne]), bn = $((e = !1) => {
1073
+ nt(w.Down, e, !1, t.current.getDimensions().containerHeight);
1074
+ }, []), At = $((e = !1) => {
1075
+ nt(w.Up, e, !1, t.current.getDimensions().containerHeight);
1076
+ }, []), Cn = $((e = !1) => {
1077
+ nt(w.Right, e, !1, t.current.getDimensions().containerWidth);
1078
+ }, []), xn = $((e = !1) => {
1079
+ nt(w.Left, e, !1, t.current.getDimensions().containerWidth);
1080
+ }, []), In = $(() => {
1081
+ Yt(w.Left);
1082
+ }, []), En = $(() => {
1083
+ Yt(w.Right);
1084
+ }, []), Wn = $(() => {
1085
+ Yt(w.Up);
1086
+ }, []), Un = $(() => {
1087
+ Yt(w.Down);
1088
+ }, []), pn = $(() => {
1089
+ wn(w.Left);
1090
+ }, []), Hn = $(() => {
1091
+ wn(w.Right);
1092
+ }, []), Nn = $(() => {
1093
+ Vn();
1094
+ }, []), Rn = $(() => {
1095
+ nt(w.Left, !1, !1);
1096
+ }, []), g = $(() => {
1097
+ nt(w.Left, !0, !1);
1098
+ }, []), v = $(() => {
1099
+ nt(w.Left, !1, !0);
1100
+ }, []), O = $(() => {
1101
+ nt(w.Left, !0, !0);
1102
+ }, []), b = $(() => {
1103
+ nt(w.Right, !1, !1);
1104
+ }, []), y = $(() => {
1105
+ nt(w.Right, !0, !1);
1106
+ }, []), V = $(() => {
1107
+ nt(w.Right, !1, !0);
1108
+ }, []), Q = $(() => {
1109
+ nt(w.Right, !0, !0);
1110
+ }, []), oe = $(() => {
1111
+ nt(w.Up, !1, !1);
1112
+ }, []), ce = $(() => {
1113
+ nt(w.Up, !0, !1);
1114
+ }, []), W = $(() => {
1115
+ nt(w.Up, !1, !0);
1116
+ }, []), ye = $(() => {
1117
+ nt(w.Up, !0, !0);
1118
+ }, []), Ge = $(() => {
1119
+ nt(w.Down, !1, !1);
1120
+ }, []), Oe = $(() => {
1121
+ nt(w.Down, !0, !1);
1122
+ }, []), ze = $(() => {
1123
+ nt(w.Down, !1, !0);
1124
+ }, []), qe = $(() => {
1125
+ nt(w.Down, !0, !0);
1126
+ }, []), Re = $(() => {
1127
+ ht((e) => e.slice(0, -1));
1128
+ }, []), St = Ve(() => {
1095
1129
  const e = fe();
1096
- return ((s, u, d, x, E) => {
1097
- for (let w = 0; w < s.length; w++) {
1098
- const j = s[w];
1099
- if (j.rowStart === u && j.colStart === d && j.rowEnd === x && j.colEnd === E) return !0;
1130
+ return ((a, u, d, f, I) => {
1131
+ for (let x = 0; x < a.length; x++) {
1132
+ const G = a[x];
1133
+ if (G.rowStart === u && G.colStart === d && G.rowEnd === f && G.colEnd === I) return !0;
1100
1134
  }
1101
1135
  return !1;
1102
1136
  })(m.ranges, e.top, e.left, e.bottom, e.right);
1103
- }, [A, m.ranges]), rt = z((e, s = !0) => {
1104
- He.current = e, Ge(e), s && e && t?.current && xt(e);
1105
- }, []), G = D((e = !0) => {
1106
- const s = Xt.current;
1107
- if (!ie.current?.cell) return;
1108
- const u = ie.current?.ranges, d = ie.current?.cell;
1109
- if (!d || !s || !s) return;
1110
- let x = null;
1111
- if (x = u.length > 0 ? u[u.length - 1] : F(d), x.colEnd >= x.colStart && x.rowEnd >= x.rowStart) {
1112
- const E = ro(x, s);
1113
- let w = e ? en : M;
1137
+ }, [M, m.ranges]), it = $((e, a = !0) => {
1138
+ Ke.current = e, Qe(e), a && e && t?.current && vt(e);
1139
+ }, []), Be = L((e = !0) => {
1140
+ const a = Gt.current;
1141
+ if (!le.current?.cell) return;
1142
+ const u = le.current?.ranges, d = le.current?.cell;
1143
+ if (!d || !a || !a) return;
1144
+ let f = null;
1145
+ if (f = u.length > 0 ? u[u.length - 1] : ne(d), f.colEnd >= f.colStart && f.rowEnd >= f.rowStart) {
1146
+ const I = io(f, a);
1147
+ let x = e ? Wt : D;
1114
1148
  try {
1115
- w?.(x, s, E.direction);
1116
- } catch (j) {
1117
- console.warn(j);
1149
+ x?.(f, a, I.direction);
1150
+ } catch (G) {
1151
+ console.warn(G);
1118
1152
  } finally {
1119
- e && Pe?.();
1153
+ e && Me?.();
1120
1154
  }
1121
1155
  }
1122
- }, [F]), ot = ue(null), Tt = Ae(() => ({ onPointerDown: (e, s) => {
1123
- if (Dt.current = s, !t || !t.current) return !1;
1156
+ }, [ne]), be = ie(null), lt = Ve(() => ({ onPointerDown: (e, a) => {
1157
+ if (Tt.current = a, !t || !t.current) return !1;
1124
1158
  const u = t.current.getViewFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY), d = u?.getCellCoordsFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY);
1125
- d && (e.stopPropagation(), Gt("crosshair"), ot.current = { anchor: u.getAnchor(), coords: d });
1126
- }, onPointerMoveOrWait: (e, s) => {
1127
- if (ce || !t?.current || !ie.current || !ot.current) return;
1128
- const u = ot.current.anchor;
1129
- let d = t.current.getViewFromLocation(u), x = d.getCellCoordsFromClient(e.clientX, e.clientY);
1159
+ d && (e.stopPropagation(), Zt("crosshair"), be.current = { anchor: u.getAnchor(), coords: d });
1160
+ }, onPointerMoveOrWait: (e, a) => {
1161
+ if (Y || !t?.current || !le.current || !be.current) return;
1162
+ const u = be.current.anchor;
1163
+ let d = t.current.getViewFromLocation(u), f = d.getCellCoordsFromClient(e.clientX, e.clientY);
1164
+ if (!f) return;
1165
+ be.current = { anchor: u, coords: f };
1166
+ const I = le.current.ranges;
1167
+ let x = De(le.current.cell, f);
1130
1168
  if (!x) return;
1131
- ot.current = { anchor: u, coords: x };
1132
- const E = ie.current.ranges;
1133
- let w = ze(ie.current.cell, x);
1134
- if (!w) return;
1135
- const j = E.length > 0, V = j ? E[E.length - 1] : F(ie.current.cell);
1136
- if (!w) return;
1137
- const U = w.rowStart < V.rowStart ? f.Up : w.rowEnd > V.rowEnd ? f.Down : w.colEnd > V.colEnd ? f.Right : f.Left, _ = fe();
1138
- U === f.Left && (w = { ...V, colStart: Math.max(_.left, w.colStart) }), U === f.Up && (w = { ...V, rowStart: Math.max(_.top, w.rowStart) }), U === f.Right && (w = { ...V, colEnd: Math.min(_.right, w.colEnd) }), U === f.Down && (w = { ...V, rowEnd: Math.min(_.bottom, w.rowEnd) });
1139
- const be = ro(V, w);
1140
- if (!We?.(V)) {
1169
+ const G = I.length > 0, H = G ? I[I.length - 1] : ne(le.current.cell);
1170
+ if (!x) return;
1171
+ const N = x.rowStart < H.rowStart ? w.Up : x.rowEnd > H.rowEnd ? w.Down : x.colEnd > H.colEnd ? w.Right : w.Left, te = fe();
1172
+ N === w.Left && (x = { ...H, colStart: Math.max(te.left, x.colStart) }), N === w.Up && (x = { ...H, rowStart: Math.max(te.top, x.rowStart) }), N === w.Right && (x = { ...H, colEnd: Math.min(te.right, x.colEnd) }), N === w.Down && (x = { ...H, rowEnd: Math.min(te.bottom, x.rowEnd) });
1173
+ const ve = io(H, x);
1174
+ if (!He?.(H)) {
1141
1175
  let q;
1142
- typeof tn.current == "function" ? q = tn.current(V) : Te && (q = Te), w = ((H, ct, b, pe, pt, we) => {
1143
- const he = { ...ct };
1144
- if (b.length === 0) return he;
1145
- if (pt === f.Left) {
1146
- const it = H.colEnd + 1 - H.colStart;
1147
- he.colStart = H.colStart - Math.ceil(we / it) * it, he.colStart < pe.left && (he.colStart = he.colStart + Math.ceil((pe.left - he.colStart) / it) * it);
1148
- } else if (pt === f.Right) {
1149
- const it = H.colEnd + 1 - H.colStart;
1150
- he.colEnd = H.colEnd + Math.ceil(we / it) * it, he.colEnd > pe.right && (he.colEnd = he.colEnd - Math.ceil((pe.right - he.colEnd) / it) * it);
1151
- } else if (pt === f.Up) {
1152
- const it = H.rowEnd + 1 - H.rowStart;
1153
- he.rowStart = H.rowStart - Math.ceil(we / it) * it, he.rowStart < pe.top && (he.rowStart = he.rowStart + Math.ceil((pe.top - he.rowStart) / it) * it);
1154
- } else if (pt === f.Down) {
1155
- const it = H.rowEnd + 1 - H.rowStart;
1156
- he.rowEnd = H.rowEnd + Math.ceil(we / it) * it, he.rowEnd > pe.bottom && (he.rowEnd = he.rowEnd - Math.ceil((pe.bottom - he.rowEnd) / it) * it);
1176
+ typeof tn.current == "function" ? q = tn.current(H) : ke && (q = ke), x = ((K, at, C, pe, bt, we) => {
1177
+ const ue = { ...at };
1178
+ if (C.length === 0) return ue;
1179
+ if (bt === w.Left) {
1180
+ const st = K.colEnd + 1 - K.colStart;
1181
+ ue.colStart = K.colStart - Math.ceil(we / st) * st, ue.colStart < pe.left && (ue.colStart = ue.colStart + Math.ceil((pe.left - ue.colStart) / st) * st);
1182
+ } else if (bt === w.Right) {
1183
+ const st = K.colEnd + 1 - K.colStart;
1184
+ ue.colEnd = K.colEnd + Math.ceil(we / st) * st, ue.colEnd > pe.right && (ue.colEnd = ue.colEnd - Math.ceil((pe.right - ue.colEnd) / st) * st);
1185
+ } else if (bt === w.Up) {
1186
+ const st = K.rowEnd + 1 - K.rowStart;
1187
+ ue.rowStart = K.rowStart - Math.ceil(we / st) * st, ue.rowStart < pe.top && (ue.rowStart = ue.rowStart + Math.ceil((pe.top - ue.rowStart) / st) * st);
1188
+ } else if (bt === w.Down) {
1189
+ const st = K.rowEnd + 1 - K.rowStart;
1190
+ ue.rowEnd = K.rowEnd + Math.ceil(we / st) * st, ue.rowEnd > pe.bottom && (ue.rowEnd = ue.rowEnd - Math.ceil((pe.bottom - ue.rowEnd) / st) * st);
1157
1191
  }
1158
- return he;
1159
- })(V, w, q, _, be.direction, be.amount);
1192
+ return ue;
1193
+ })(H, x, q, te, ve.direction, ve.amount);
1160
1194
  }
1161
- if (j && $.isRangeWithinRange(w, V) && (w = null), !$.isEqualRanges(w, Xt.current)) {
1162
- if (hn(w), Xt.current = w, !w) {
1195
+ if (G && F.isRangeWithinRange(x, H) && (x = null), !F.isEqualRanges(x, Gt.current)) {
1196
+ if (hn(x), Gt.current = x, !x) {
1163
1197
  try {
1164
1198
  S?.();
1165
1199
  } catch {
1166
1200
  }
1167
- return void Pe?.();
1201
+ return void Me?.();
1168
1202
  }
1169
- G(!1);
1203
+ Be(!1);
1170
1204
  }
1171
- Dt.current = s, Dn(d, x, t);
1172
- }, onPointerUp: (e, s) => {
1173
- Dt.current = s, Promise.resolve(G(!0)).finally(() => {
1174
- Pe?.(), hn(null), Xt.current = null, ot.current = null, Gt(null), t.current?.focus();
1205
+ Tt.current = a, Dn(d, f, t);
1206
+ }, onPointerUp: (e, a) => {
1207
+ Tt.current = a, Promise.resolve(Be(!0)).finally(() => {
1208
+ Me?.(), hn(null), Gt.current = null, be.current = null, Zt(null), t.current?.focus();
1175
1209
  });
1176
- } }), [F]), Mt = un(Tt), ke = Ae(() => ({ onPointerDown: Mt }), [Mt]), [Ie, Ye] = gt(null), ye = ue(null), ve = Ae(() => ({ onPointerDown: (e, s) => {
1177
- if (Dt.current = s, !t || !t.current) return !1;
1210
+ } }), [ne]), Ot = un(lt), me = Ve(() => ({ onPointerDown: Ot }), [Ot]), [Ze, kt] = dt(null), Fe = ie(null), tt = Ve(() => ({ onPointerDown: (e, a) => {
1211
+ if (Tt.current = a, !t || !t.current) return !1;
1178
1212
  const u = t.current.getViewFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY), d = u?.getCellCoordsFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY);
1179
1213
  if (!d) return;
1180
- if (me?.(e, d, m) === !1) return !1;
1181
- e.stopPropagation(), Gt("default");
1182
- const x = u.getRelativePointFromClient(0, 0), E = ie.current?.ranges[ie.current?.ranges.length - 1] ?? $.cellToRange(ie.current?.cell), w = u.toClipBounds(u.getRangeCoordsBounds(E)), j = { x: 0, y: 0 };
1183
- w.x - x.x > e.nativeEvent.clientX ? j.x = e.nativeEvent.clientX - (w.x - x.x) : e.nativeEvent.clientX >= w.x - x.x + w.width && (j.x = Math.max(0, e.nativeEvent.clientX - (w.x - x.x + w.width)) + 1), w.y - x.y > e.nativeEvent.clientY ? j.y = e.nativeEvent.clientY - (w.y - x.y) : e.nativeEvent.clientY >= w.y - x.y + w.height && (j.y = Math.max(0, e.nativeEvent.clientY - (w.y - x.y + w.height)) + 1), ge?.(E, e.nativeEvent, s), ye.current = { range: E, anchor: u.getAnchor(), cell: d, isMoving: !1, extrusion: j };
1184
- }, onPointerMoveOrWait: (e, s, u) => {
1185
- if (qe || !t?.current || !ie.current || !ye.current) return;
1186
- const d = e.clientX - u.clientX, x = e.clientY - u.clientY;
1187
- if (ye.current.isMoving = ye.current.isMoving || Math.abs(d) > Math.max(1, 2) || Math.abs(x) > Math.max(1, 2) || performance.now() - u.timeStamp > 500, !ye.current.isMoving) return;
1188
- const E = ye.current.anchor, w = ye.current.extrusion;
1189
- let j = t.current.getViewFromLocation(E), V = j.getCellCoordsFromClient(e.clientX - w.x, e.clientY - w.y, !0);
1190
- if (!V) return;
1191
- const U = ye.current.cell, _ = ye.current.range, be = fe(), q = _.colEnd - _.colStart + 1, H = Math.min(Math.max(0, U.colIndex - _.colStart), q - 1), ct = Math.min(be.right - q + 1, Math.max(be.left, V.colIndex - H)), b = _.rowEnd - _.rowStart + 1, pe = Math.min(Math.max(0, U.rowIndex - _.rowStart), b - 1), pt = Math.min(be.bottom - b + 1, Math.max(be.top, V.rowIndex - pe)), we = { colStart: ct, colEnd: ct + q - 1, rowStart: pt, rowEnd: pt + b - 1 };
1192
- $.isEqualRanges(Ie, we) && !((he) => !he || !Dt.current || Dt.current.ctrlKey !== he.ctrlKey || Dt.current.shiftKey !== he.shiftKey || Dt.current.altKey !== he.altKey || Dt.current.metaKey !== he.metaKey)(e) || (Ye(we), Ce?.(we, e, s)), Dt.current = s, Dn(j, V, t);
1193
- }, onPointerUp: (e, s) => {
1194
- Dt.current = s;
1214
+ if (se?.(e, d, m) === !1) return !1;
1215
+ e.stopPropagation(), Zt("default");
1216
+ const f = u.getRelativePointFromClient(0, 0), I = le.current?.ranges[le.current?.ranges.length - 1] ?? F.cellToRange(le.current?.cell), x = u.toClipBounds(u.getRangeCoordsBounds(I)), G = { x: 0, y: 0 };
1217
+ x.x - f.x > e.nativeEvent.clientX ? G.x = e.nativeEvent.clientX - (x.x - f.x) : e.nativeEvent.clientX >= x.x - f.x + x.width && (G.x = Math.max(0, e.nativeEvent.clientX - (x.x - f.x + x.width)) + 1), x.y - f.y > e.nativeEvent.clientY ? G.y = e.nativeEvent.clientY - (x.y - f.y) : e.nativeEvent.clientY >= x.y - f.y + x.height && (G.y = Math.max(0, e.nativeEvent.clientY - (x.y - f.y + x.height)) + 1), ge?.(I, e.nativeEvent, a), Fe.current = { range: I, anchor: u.getAnchor(), cell: d, isMoving: !1, extrusion: G };
1218
+ }, onPointerMoveOrWait: (e, a, u) => {
1219
+ if (Ye || !t?.current || !le.current || !Fe.current) return;
1220
+ const d = e.clientX - u.clientX, f = e.clientY - u.clientY;
1221
+ if (Fe.current.isMoving = Fe.current.isMoving || Math.abs(d) > Math.max(1, 2) || Math.abs(f) > Math.max(1, 2) || performance.now() - u.timeStamp > 500, !Fe.current.isMoving) return;
1222
+ const I = Fe.current.anchor, x = Fe.current.extrusion;
1223
+ let G = t.current.getViewFromLocation(I), H = G.getCellCoordsFromClient(e.clientX - x.x, e.clientY - x.y, !0);
1224
+ if (!H) return;
1225
+ const N = Fe.current.cell, te = Fe.current.range, ve = fe(), q = te.colEnd - te.colStart + 1, K = Math.min(Math.max(0, N.colIndex - te.colStart), q - 1), at = Math.min(ve.right - q + 1, Math.max(ve.left, H.colIndex - K)), C = te.rowEnd - te.rowStart + 1, pe = Math.min(Math.max(0, N.rowIndex - te.rowStart), C - 1), bt = Math.min(ve.bottom - C + 1, Math.max(ve.top, H.rowIndex - pe)), we = { colStart: at, colEnd: at + q - 1, rowStart: bt, rowEnd: bt + C - 1 };
1226
+ F.isEqualRanges(Ze, we) && !((ue) => !ue || !Tt.current || Tt.current.ctrlKey !== ue.ctrlKey || Tt.current.shiftKey !== ue.shiftKey || Tt.current.altKey !== ue.altKey || Tt.current.metaKey !== ue.metaKey)(e) || (kt(we), Se?.(we, e, a)), Tt.current = a, Dn(G, H, t);
1227
+ }, onPointerUp: (e, a) => {
1228
+ Tt.current = a;
1195
1229
  const u = () => {
1196
- Ye(null), ye.current = null, Gt(null), t.current?.focus();
1230
+ kt(null), Fe.current = null, Zt(null), t.current?.focus();
1197
1231
  };
1198
- if (!ye.current) return void u();
1199
- const d = ye.current.range, x = Ie;
1200
- O?.(d, e, s), Promise.resolve(d && x && p?.(d, x, e, s)).finally(() => {
1232
+ if (!Fe.current) return void u();
1233
+ const d = Fe.current.range, f = Ze;
1234
+ B?.(d, e, a), Promise.resolve(d && f && p?.(d, f, e, a)).finally(() => {
1201
1235
  u();
1202
1236
  });
1203
- } }), [Ie]), lt = un(ve), ht = Ae(() => ({ onPointerDown: lt }), [lt]), Et = ue(null), Ot = Ae(() => {
1204
- const e = $.isEqualSelectionCoords(m, Et.current) ? Et.current : m;
1205
- return Et.current = e, e;
1206
- }, [m]), yt = z((e) => {
1207
- let s = null, u = "br";
1208
- const d = [], x = { stroke: J, fill: X, strokeWidth: 0.5 }, E = (q, H, ct) => {
1209
- const b = e.toClipBounds(e.getRangeCoordsBounds(q), Vt);
1210
- if (!b) return;
1211
- b.x = b.width > 0 ? b.x : b.x - x.strokeWidth / 2, b.y = b.height > 0 ? b.y : b.y - x.strokeWidth / 2, b.width = Math.max(b.width, x.strokeWidth), b.height = Math.max(b.height, x.strokeWidth);
1212
- const pe = { key: `selection-fill-${H}`, range: q, ...b, ...x };
1213
- if (ct) {
1214
- const pt = e.getCellCoordsAsRangeCoords(ct);
1215
- pe.cell = ct, pe.pathBounds = e.toClipBounds(e.getRangeCoordsBounds(pt), Vt), pe.pathBounds && (pe.pathBounds.width <= 0 || pe.pathBounds.height <= 0) && (delete pe.pathBounds, delete pe.cell);
1237
+ } }), [Ze]), $e = un(tt), Le = Ve(() => ({ onPointerDown: $e }), [$e]), xt = ie(null), ct = Ve(() => {
1238
+ const e = F.isEqualSelectionCoords(m, xt.current) ? xt.current : m;
1239
+ return xt.current = e, e;
1240
+ }, [m]), yt = $((e) => {
1241
+ let a = null, u = "br";
1242
+ const d = [], f = { stroke: j, fill: T, strokeWidth: 0.5 }, I = (q, K, at) => {
1243
+ const C = e.toClipBounds(e.getRangeCoordsBounds(q), Vt);
1244
+ if (!C) return;
1245
+ C.x = C.width > 0 ? C.x : C.x - f.strokeWidth / 2, C.y = C.height > 0 ? C.y : C.y - f.strokeWidth / 2, C.width = Math.max(C.width, f.strokeWidth), C.height = Math.max(C.height, f.strokeWidth);
1246
+ const pe = { key: `selection-fill-${K}`, range: q, ...C, ...f };
1247
+ if (at) {
1248
+ const bt = e.getCellCoordsAsRangeCoords(at);
1249
+ pe.cell = at, pe.pathBounds = e.toClipBounds(e.getRangeCoordsBounds(bt), Vt), pe.pathBounds && (pe.pathBounds.width <= 0 || pe.pathBounds.height <= 0) && (delete pe.pathBounds, delete pe.cell);
1216
1250
  }
1217
1251
  return xe(pe);
1218
1252
  };
1219
- let w = m ? $t(m) : null;
1220
- const j = w?.cell ? e.getCellCoordsAsRangeCoords(w?.cell) : _o;
1221
- !w || w.ranges && w.ranges.length !== 0 || (w = { ranges: [j], rangeIndex: 0, cell: w.cell });
1222
- for (let q = 0; w && q < w.ranges.length; q++) {
1223
- const H = w.ranges[q], ct = E(H, q, q === w.rangeIndex ? w.cell : null);
1224
- ct && d.push(ct);
1225
- const b = 2, pe = 0.5, pt = e.toClipBounds(e.getRangeCoordsBounds(H, { top: 0, left: 0, right: 0, bottom: 0 }), Vt);
1226
- if (pt) {
1227
- const we = (w.ranges.length, 4);
1228
- d.push(xe({ range: H, key: `selection-inside-edge-${q}`, x: pt.x - 1, y: pt.y - 1, width: Math.max(pt.width + 1, 0), height: Math.max(pt.height + 1, 0), style: { overflow: "hidden" }, stroke: J, strokeWidth: we }));
1253
+ let x = m ? $t(m) : null;
1254
+ const G = x?.cell ? e.getCellCoordsAsRangeCoords(x?.cell) : nr;
1255
+ !x || x.ranges && x.ranges.length !== 0 || (x = { ranges: [G], rangeIndex: 0, cell: x.cell });
1256
+ for (let q = 0; x && q < x.ranges.length; q++) {
1257
+ const K = x.ranges[q], at = I(K, q, q === x.rangeIndex ? x.cell : null);
1258
+ at && d.push(at);
1259
+ const C = 2, pe = 0.5, bt = e.toClipBounds(e.getRangeCoordsBounds(K, { top: 0, left: 0, right: 0, bottom: 0 }), Vt);
1260
+ if (bt) {
1261
+ const we = (x.ranges.length, 4);
1262
+ d.push(xe({ range: K, key: `selection-inside-edge-${q}`, x: bt.x - 1, y: bt.y - 1, width: Math.max(bt.width + 1, 0), height: Math.max(bt.height + 1, 0), style: { overflow: "hidden" }, stroke: j, strokeWidth: we }));
1229
1263
  }
1230
- if (w.ranges.length === 1) {
1231
- const we = e.toClipBounds(e.getRangeCoordsBounds(H), Vt);
1264
+ if (x.ranges.length === 1) {
1265
+ const we = e.toClipBounds(e.getRangeCoordsBounds(K), Vt);
1232
1266
  if (we) {
1233
- qe || d.push(xe({ range: H, key: `move-selection-hit-box-${q}`, x: we.width > 1 ? we.x : we.x - (re / 2 + 1), y: we.height > 1 ? we.y : we.y - (re / 2 + 1), width: Math.max(we.width + 2, 1), height: Math.max(we.height + 2, 1), stroke: "transparent", style: { boxShadow: "none" }, pathProps: { cursor: Ie ? void 0 : "move", pointerEvents: "stroke" }, strokeWidth: re, ...ht }));
1234
- const he = b;
1235
- d.push(xe({ range: H, key: `selection-single-${q}`, x: we.x - he / 2, y: we.y - he / 2, width: Math.max(we.width + he / 2, 1), height: Math.max(we.height + he / 2, 1), stroke: se, strokeWidth: he }));
1267
+ Ye || d.push(xe({ range: K, key: `move-selection-hit-box-${q}`, x: we.width > 1 ? we.x : we.x - (Ee / 2 + 1), y: we.height > 1 ? we.y : we.y - (Ee / 2 + 1), width: Math.max(we.width + 2, 1), height: Math.max(we.height + 2, 1), stroke: "transparent", style: { boxShadow: "none" }, pathProps: { cursor: Ze ? void 0 : "move", pointerEvents: "stroke" }, strokeWidth: Ee, ...Le }));
1268
+ const ue = C;
1269
+ d.push(xe({ range: K, key: `selection-single-${q}`, x: we.x - ue / 2, y: we.y - ue / 2, width: Math.max(we.width + ue / 2, 1), height: Math.max(we.height + ue / 2, 1), stroke: X, strokeWidth: ue }));
1236
1270
  }
1237
1271
  } else {
1238
- const we = e.toClipBounds(e.getRangeCoordsBounds(H, { top: -1, left: -1, right: -2, bottom: -2 }), Vt);
1239
- we && d.push(xe({ range: H, key: `selection-multi-${q}`, x: we.width > 1 ? we.x : we.x - pe / 2, y: we.height > 1 ? we.y : we.y - pe / 2, width: Math.max(we.width, pe) + 1, height: Math.max(we.height, pe) + 1, stroke: se, style: { overflow: "hidden" }, strokeWidth: 2 }));
1272
+ const we = e.toClipBounds(e.getRangeCoordsBounds(K, { top: -1, left: -1, right: -2, bottom: -2 }), Vt);
1273
+ we && d.push(xe({ range: K, key: `selection-multi-${q}`, x: we.width > 1 ? we.x : we.x - pe / 2, y: we.height > 1 ? we.y : we.y - pe / 2, width: Math.max(we.width, pe) + 1, height: Math.max(we.height, pe) + 1, stroke: X, style: { overflow: "hidden" }, strokeWidth: 2 }));
1240
1274
  }
1241
- if (w.ranges.length > 1 && q === w.rangeIndex) {
1242
- const we = e.getCellCoordsAsRangeCoords(w.cell), he = e.toClipBounds(e.getRangeCoordsBounds(we, { top: 1, left: 1, right: -1, bottom: -1 }), Vt);
1243
- he && d.push(xe({ range: H, key: `selection-anchor-${q}`, x: he.x, y: he.y, width: Math.max(he.width, pe), height: Math.max(he.height, pe), stroke: se, style: { overflow: "hidden" }, strokeWidth: 2 }));
1275
+ if (x.ranges.length > 1 && q === x.rangeIndex) {
1276
+ const we = e.getCellCoordsAsRangeCoords(x.cell), ue = e.toClipBounds(e.getRangeCoordsBounds(we, { top: 1, left: 1, right: -1, bottom: -1 }), Vt);
1277
+ ue && d.push(xe({ range: K, key: `selection-anchor-${q}`, x: ue.x, y: ue.y, width: Math.max(ue.width, pe), height: Math.max(ue.height, pe), stroke: X, style: { overflow: "hidden" }, strokeWidth: 2 }));
1244
1278
  }
1245
- if (q === w.ranges.length - 1) {
1246
- s = null, u = null;
1247
- const we = H.rowStart === fe().top && H.rowEnd === fe().bottom, he = H.colStart === fe().left && H.colEnd === fe().right, it = e.getRangeCoordsBounds(H);
1279
+ if (q === x.ranges.length - 1) {
1280
+ a = null, u = null;
1281
+ const we = K.rowStart === fe().top && K.rowEnd === fe().bottom, ue = K.colStart === fe().left && K.colEnd === fe().right, st = e.getRangeCoordsBounds(K);
1248
1282
  let Ft = null;
1249
- if (we || he) {
1250
- if (Ft = e.toClipBounds(it, Vt), Object.keys(e.allViews()).length > 1) {
1251
- const Mn = e.getVisibleRangeCoords(), Qn = e.allViews()[_e.TopLeft], Po = e.allViews()[_e.Top], Do = e.allViews()[_e.Left], kn = e.getAnchor();
1252
- (he && (kn === _e.Top && Qn || kn === _e.Center && Do || !$.isCellWithinRange({ colIndex: H.colStart, rowIndex: H.rowEnd }, Mn) && !$.isCellWithinRange({ colIndex: H.colStart, rowIndex: H.rowEnd + 1 }, Mn)) || we && (kn === _e.Left && Qn || kn === _e.Center && Po || !$.isCellWithinRange({ colIndex: H.colEnd, rowIndex: H.rowStart }, Mn) && !$.isCellWithinRange({ colIndex: H.colEnd + 1, rowIndex: H.rowStart }, Mn))) && (Ft = null);
1283
+ if (we || ue) {
1284
+ if (Ft = e.toClipBounds(st, Vt), Object.keys(e.allViews()).length > 1) {
1285
+ const Mn = e.getVisibleRangeCoords(), _n = e.allViews()[_e.TopLeft], Do = e.allViews()[_e.Top], To = e.allViews()[_e.Left], kn = e.getAnchor();
1286
+ (ue && (kn === _e.Top && _n || kn === _e.Center && To || !F.isCellWithinRange({ colIndex: K.colStart, rowIndex: K.rowEnd }, Mn) && !F.isCellWithinRange({ colIndex: K.colStart, rowIndex: K.rowEnd + 1 }, Mn)) || we && (kn === _e.Left && _n || kn === _e.Center && Do || !F.isCellWithinRange({ colIndex: K.colEnd, rowIndex: K.rowStart }, Mn) && !F.isCellWithinRange({ colIndex: K.colEnd + 1, rowIndex: K.rowStart }, Mn))) && (Ft = null);
1253
1287
  }
1254
- } else Ft = e.toClipBounds(it, Vt);
1288
+ } else Ft = e.toClipBounds(st, Vt);
1255
1289
  if (!Ft || Ft.width === 0 || Ft.height === 0) continue;
1256
- s = { x: Ft.x + Ft.width + 1, y: Ft.y + Ft.height + 1 }, Ft.width === 0 || Ft.height === 0 || H.rowStart === fe().top && H.colStart === fe().left && H.rowEnd === fe().bottom && H.colEnd === fe().right || (we ? (s.y = b, u = "tr") : he && (s.x = b, u = "bl"));
1290
+ a = { x: Ft.x + Ft.width + 1, y: Ft.y + Ft.height + 1 }, Ft.width === 0 || Ft.height === 0 || K.rowStart === fe().top && K.colStart === fe().left && K.rowEnd === fe().bottom && K.colEnd === fe().right || (we ? (a.y = C, u = "tr") : ue && (a.x = C, u = "bl"));
1257
1291
  }
1258
1292
  }
1259
- let V = null;
1260
- if (Oe) {
1261
- const q = e.toClipBounds(e.getRangeCoordsBounds(Oe, { top: 0, left: 0, right: 0, bottom: 0 }), Vt);
1262
- q && (V = xe({ ...x, range: Oe, key: "remove-selection", x: q.x, y: q.y, width: q.width, height: q.height, strokeWidth: 2, stroke: Lt, fill: mt }));
1293
+ let H = null;
1294
+ if (Pe) {
1295
+ const q = e.toClipBounds(e.getRangeCoordsBounds(Pe, { top: 0, left: 0, right: 0, bottom: 0 }), Vt);
1296
+ q && (H = xe({ ...f, range: Pe, key: "remove-selection", x: q.x, y: q.y, width: q.width, height: q.height, strokeWidth: 2, stroke: Mt, fill: Ct }));
1263
1297
  }
1264
- let U = null;
1265
- if (kt) {
1266
- const q = e.toClipBounds(e.getRangeCoordsBounds(kt, { top: 0, left: 0, right: 0, bottom: 0 }), Vt);
1267
- q && (U = xe({ range: kt, key: "selection-fill-outline", x: q.x - 2 / 2, y: q.y - 2 / 2, width: q.width + 2 / 2, height: q.height + 2 / 2, strokeWidth: 2, stroke: se, strokeDasharray: "3 2" }));
1298
+ let N = null;
1299
+ if (Pt) {
1300
+ const q = e.toClipBounds(e.getRangeCoordsBounds(Pt, { top: 0, left: 0, right: 0, bottom: 0 }), Vt);
1301
+ q && (N = xe({ range: Pt, key: "selection-fill-outline", x: q.x - 2 / 2, y: q.y - 2 / 2, width: q.width + 2 / 2, height: q.height + 2 / 2, strokeWidth: 2, stroke: X, strokeDasharray: "3 2" }));
1268
1302
  }
1269
- let _ = null;
1270
- !ce && s && !Ie && (_ = wo(yo, { ...s, corner: u, size: 7.5, borderStroke: `${J} solid`, style: { borderRadius: 1 }, background: se, ...ke, key: "fillHandle" }));
1271
- const be = [...d];
1272
- if (V && be.push(V), U && be.push(U), _ && be.push(_), !st && Pt && w?.ranges.length === 1 && w.ranges[w.ranges.length - 1]) {
1273
- const q = w.ranges[w.ranges.length - 1], H = q.rowStart === fe().top && q.rowEnd === fe().bottom, ct = q.colStart === fe().left && q.colEnd === fe().right, b = { view: e, range: q, borderStroke: `${se} solid`, background: J, selectionTouchPointerHandler: Ln, ...at, onTouchSelectStart: (pe) => cn(pe), onTouchSelectEnd: () => cn(null), currentTouchAnchor: vn };
1274
- be.push(Ee(Xn, { anchor: ct ? "b" : H ? "r" : "br", scrollableElement: t.current, ...b }, "touch-select-handle-after")), be.push(Ee(Xn, { anchor: ct ? "t" : H ? "l" : "tl", scrollableElement: t.current, ...b }, "touch-select-handle-before"));
1303
+ let te = null;
1304
+ !Y && a && !Ze && (te = xo(Io, { ...a, corner: u, size: 7.5, borderStroke: `${j} solid`, style: { borderRadius: 1 }, background: X, ...me, key: "fillHandle" }));
1305
+ const ve = [...d];
1306
+ if (H && ve.push(H), N && ve.push(N), te && ve.push(te), !ft && Dt && x?.ranges.length === 1 && x.ranges[x.ranges.length - 1]) {
1307
+ const q = x.ranges[x.ranges.length - 1], K = q.rowStart === fe().top && q.rowEnd === fe().bottom, at = q.colStart === fe().left && q.colEnd === fe().right, C = { view: e, range: q, borderStroke: `${X} solid`, background: j, selectionTouchPointerHandler: $n, ...ut, onTouchSelectStart: (pe) => cn(pe), onTouchSelectEnd: () => cn(null), currentTouchAnchor: vn };
1308
+ ve.push(Ce(Zn, { anchor: at ? "b" : K ? "r" : "br", scrollableElement: t.current, ...C }, "touch-select-handle-after")), ve.push(Ce(Zn, { anchor: at ? "t" : K ? "l" : "tl", scrollableElement: t.current, ...C }, "touch-select-handle-before"));
1275
1309
  }
1276
- if (Ie) {
1277
- const q = e.toClipBounds(e.getRangeCoordsBounds(Ie, { top: 1, left: 1, right: 1, bottom: 1 }), Vt);
1278
- q && be.push(xe({ range: Ie, key: "selection-move-outline", x: q.x - W / 2, y: q.y - W / 2, width: Math.max(q.width + W / 2, 1), height: Math.max(q.height + W / 2, 1), stroke: se, style: { boxShadow: "none", transitionDuration: "70ms", transitionTimingFunction: "ease-in", transitionProperty: "left, top, width, height", willChange: "left, top, width, height" }, strokeWidth: W }));
1310
+ if (Ze) {
1311
+ const q = e.toClipBounds(e.getRangeCoordsBounds(Ze, { top: 1, left: 1, right: 1, bottom: 1 }), Vt);
1312
+ q && ve.push(xe({ range: Ze, key: "selection-move-outline", x: q.x - J / 2, y: q.y - J / 2, width: Math.max(q.width + J / 2, 1), height: Math.max(q.height + J / 2, 1), stroke: X, style: { boxShadow: "none", transitionDuration: "70ms", transitionTimingFunction: "ease-in", transitionProperty: "left, top, width, height", willChange: "left, top, width, height" }, strokeWidth: J }));
1279
1313
  }
1280
- return Ee("div", { children: be }, "selection");
1281
- }, [Ot, Oe, ce, kt, qe, Ie, fe, J, se, X, Lt, mt, st, at, vn]), Rt = Ae(() => {
1314
+ return Ce("div", { children: ve }, "selection");
1315
+ }, [ct, Pe, Y, Pt, Ye, Ze, fe, j, X, T, Mt, Ct, ft, ut, vn]), zt = Ve(() => {
1282
1316
  const e = () => t.current;
1283
- return [new ae("moveToPageDown", e, { label: "Page Down", description: "Shift viewport down one page.", shortcut: [{ key: "PageDown" }] }, () => bn(!1)), new ae("selectToPageDown", e, { label: "Select To Page Down", description: "Shift viewport and select down one page.", shortcut: [{ key: "PageDown", modifiers: [de.Shift] }] }, () => bn(!0)), new ae("moveToPageRight", e, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [de.Alt] }] }, () => Cn(!1)), new ae("selectToPageRight", e, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [de.Alt, de.Shift] }] }, () => Cn(!0)), new ae("moveToPageUp", e, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp" }] }, () => At(!1)), new ae("selectToPageUp", e, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp", modifiers: [de.Shift] }] }, () => At(!0)), new ae("moveToPageLeft", e, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [de.Alt] }] }, () => xn(!1)), new ae("selectToPageLeft", e, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [de.Alt, de.Shift] }] }, () => xn(!0)), new ae("selectColumn", e, { label: "Select Column", description: "Select the columns for the selected cells.", shortcut: { key: "Space", modifiers: [de.Ctrl] } }, $n), new ae("selectRow", e, { label: "Select Row", description: "Select the rows for the selected cells.", shortcut: { key: "Space", modifiers: [de.Shift] } }, Bn), new ae("selectToColumnStart", e, { label: "Select To Column Start", description: "Select the columns to the beginning of the sheet." }, () => Sn(!0)), new ae("selectToColumnEnd", e, { label: "Select To Column End", description: "Select the columns to the end of the sheet." }, () => yn(!0)), new ae("moveToRowStart", e, { label: "Move to Row Home", description: "Move to the beginning of the row.", shortcut: [{ key: "Home" }] }, () => gn(!1)), new ae("selectToRowStart", e, { label: "Select to Row Home", description: "Select to the beginning of the row.", shortcut: [{ key: "Home", modifiers: [de.Shift] }] }, () => gn(!0)), new ae("moveToSheetStart", e, { label: "Move to Sheet Home", description: "Move to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [de.Ctrl] }] }, () => an(!1)), new ae("selectToSheetStart", e, { label: "Select to Sheet Home", description: "Select to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [de.Ctrl, de.Shift] }] }, () => an(!0)), new ae("moveToRowEnd", e, { label: "Move to Row End", description: "Move to the end of the row.", shortcut: [{ key: "End" }] }, () => fn(!1)), new ae("selectToRowEnd", e, { label: "Select to Row End", description: "Select to the end of the row.", shortcut: [{ key: "End", modifiers: [de.Shift] }] }, () => fn(!0)), new ae("moveToSheetEnd", e, { label: "Move to Sheet End", description: "Move to the end of the sheet.", shortcut: [{ key: "End", modifiers: [de.Ctrl] }] }, () => on(!1)), new ae("selectToSheetEnd", e, { label: "Select to Sheet End", description: "Select to the end of the sheet.", shortcut: [{ key: "End", modifiers: [de.Ctrl, de.Shift] }] }, () => on(!0)), new ae("scrollToActiveCoords", e, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell.", shortcut: { key: "Backspace", modifiers: [de.Ctrl] } }, nn), new ae("scrollToActiveCoordsClearSelection", e, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell and clear selection.", shortcut: { key: "Backspace", modifiers: [de.Shift] } }, () => {
1284
- _t(), rt(m.cell, !0);
1285
- }), new ae("traverseSelectionRight", e, { label: "Traverse Right", description: "Traverse the selection moving rightward.", shortcut: { key: "Tab" } }, En), new ae("traverseSelectionLeft", e, { label: "Traverse Left", description: "Traverse the selection moving leftward.", shortcut: { key: "Tab", modifiers: [de.Shift] } }, In), new ae("traverseSelectionDown", e, { label: "Traverse Down", description: "Traverse the selection moving downward.", shortcut: [{ key: "Enter" }, { key: "NumpadEnter" }] }, Wn), new ae("traverseSelectionUp", e, { label: "Traverse Up", description: "Traverse the selection moving upward.", shortcut: [{ key: "Enter", modifiers: [de.Shift] }, { key: "NumpadEnter", modifiers: [de.Shift] }] }, Vn), new ae("moveLeft", e, { label: "Move Left", description: "Move active cell to the left.", shortcut: [{ key: "ArrowLeft" }] }, Rn), new ae("selectLeft", e, { label: "Select Left", description: "Extend selection left.", shortcut: [{ key: "ArrowLeft", modifiers: [de.Shift] }] }, g), new ae("moveContentfulLeft", e, { label: "Move Left Contentful", description: "Move left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [de.Ctrl] }] }, v), new ae("selectContentfulLeft", e, { label: "Select Left Contentful", description: "Extend selection left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [de.Ctrl, de.Shift] }] }, y), new ae("moveRight", e, { label: "Move Right", description: "Move active cell to the right.", shortcut: [{ key: "ArrowRight" }] }, C), new ae("selectRight", e, { label: "Select Right", description: "Extend selection right.", shortcut: [{ key: "ArrowRight", modifiers: [de.Shift] }] }, I), new ae("moveContentfulRight", e, { label: "Move Right Contentful", description: "Move right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [de.Ctrl] }] }, Y), new ae("selectContentfulRight", e, { label: "Select Right Contentful", description: "Extend selection right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [de.Ctrl, de.Shift] }] }, N), new ae("moveUp", e, { label: "Move Up", description: "Move active cell to the up.", shortcut: [{ key: "ArrowUp" }] }, ee), new ae("selectUp", e, { label: "Select Up", description: "Extend selection up.", shortcut: [{ key: "ArrowUp", modifiers: [de.Shift] }] }, ne), new ae("moveContentfulUp", e, { label: "Move Up Contentful", description: "Move up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [de.Ctrl] }] }, K), new ae("selectContentfulUp", e, { label: "Select Up Contentful", description: "Extend selection up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [de.Ctrl, de.Shift] }] }, De), new ae("moveDown", e, { label: "Move Down", description: "Move active cell to the down.", shortcut: [{ key: "ArrowDown" }] }, Qe), new ae("selectDown", e, { label: "Select Down", description: "Extend selection down.", shortcut: [{ key: "ArrowDown", modifiers: [de.Shift] }] }, Re), new ae("moveContentfulDown", e, { label: "Move Down Contentful", description: "Move down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [de.Ctrl] }] }, Me), new ae("selectContentfulDown", e, { label: "Select Down Contentful", description: "Extend selection down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [de.Ctrl, de.Shift] }] }, nt), new ae("selectVisible", e, { label: "Select Visible", description: "Select visible cells only.", shortcut: { key: ";", modifiers: [de.Alt] } }, An), new ae("traverseSelectionPreviousRange", e, { label: "Traverse Previous Range", description: "Traverse the selection to the previous range.", shortcut: { key: "ArrowLeft", modifiers: [de.Ctrl, de.Alt] } }, pn), new ae("traverseSelectionNextRange", e, { label: "Traverse Next Range", description: "Traverse the selection to the next range.", shortcut: { key: "ArrowRight", modifiers: [de.Ctrl, de.Alt] } }, Un), new ae("traverseSelectionCorners", e, { label: "Traverse Corners", description: "Traverse the selection through the corners of the selected range.", shortcut: { key: ".", modifiers: [de.Ctrl] } }, Hn)];
1317
+ return [new ae("moveToPageDown", e, { label: "Page Down", description: "Shift viewport down one page.", shortcut: [{ key: "PageDown" }] }, () => bn(!1)), new ae("selectToPageDown", e, { label: "Select To Page Down", description: "Shift viewport and select down one page.", shortcut: [{ key: "PageDown", modifiers: [de.Shift] }] }, () => bn(!0)), new ae("moveToPageRight", e, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [de.Alt] }] }, () => Cn(!1)), new ae("selectToPageRight", e, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [de.Alt, de.Shift] }] }, () => Cn(!0)), new ae("moveToPageUp", e, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp" }] }, () => At(!1)), new ae("selectToPageUp", e, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp", modifiers: [de.Shift] }] }, () => At(!0)), new ae("moveToPageLeft", e, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [de.Alt] }] }, () => xn(!1)), new ae("selectToPageLeft", e, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [de.Alt, de.Shift] }] }, () => xn(!0)), new ae("selectColumn", e, { label: "Select Column", description: "Select the columns for the selected cells.", shortcut: { key: "Space", modifiers: [de.Ctrl] } }, Bn), new ae("selectRow", e, { label: "Select Row", description: "Select the rows for the selected cells.", shortcut: { key: "Space", modifiers: [de.Shift] } }, An), new ae("selectToColumnStart", e, { label: "Select To Column Start", description: "Select the columns to the beginning of the sheet." }, () => Sn(!0)), new ae("selectToColumnEnd", e, { label: "Select To Column End", description: "Select the columns to the end of the sheet." }, () => yn(!0)), new ae("moveToRowStart", e, { label: "Move to Row Home", description: "Move to the beginning of the row.", shortcut: [{ key: "Home" }] }, () => gn(!1)), new ae("selectToRowStart", e, { label: "Select to Row Home", description: "Select to the beginning of the row.", shortcut: [{ key: "Home", modifiers: [de.Shift] }] }, () => gn(!0)), new ae("moveToSheetStart", e, { label: "Move to Sheet Home", description: "Move to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [de.Ctrl] }] }, () => an(!1)), new ae("selectToSheetStart", e, { label: "Select to Sheet Home", description: "Select to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [de.Ctrl, de.Shift] }] }, () => an(!0)), new ae("moveToRowEnd", e, { label: "Move to Row End", description: "Move to the end of the row.", shortcut: [{ key: "End" }] }, () => fn(!1)), new ae("selectToRowEnd", e, { label: "Select to Row End", description: "Select to the end of the row.", shortcut: [{ key: "End", modifiers: [de.Shift] }] }, () => fn(!0)), new ae("moveToSheetEnd", e, { label: "Move to Sheet End", description: "Move to the end of the sheet.", shortcut: [{ key: "End", modifiers: [de.Ctrl] }] }, () => on(!1)), new ae("selectToSheetEnd", e, { label: "Select to Sheet End", description: "Select to the end of the sheet.", shortcut: [{ key: "End", modifiers: [de.Ctrl, de.Shift] }] }, () => on(!0)), new ae("scrollToActiveCoords", e, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell.", shortcut: { key: "Backspace", modifiers: [de.Ctrl] } }, nn), new ae("scrollToActiveCoordsClearSelection", e, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell and clear selection.", shortcut: { key: "Backspace", modifiers: [de.Shift] } }, () => {
1318
+ Jt(), it(m.cell, !0);
1319
+ }), new ae("traverseSelectionRight", e, { label: "Traverse Right", description: "Traverse the selection moving rightward.", shortcut: { key: "Tab" } }, En), new ae("traverseSelectionLeft", e, { label: "Traverse Left", description: "Traverse the selection moving leftward.", shortcut: { key: "Tab", modifiers: [de.Shift] } }, In), new ae("traverseSelectionDown", e, { label: "Traverse Down", description: "Traverse the selection moving downward.", shortcut: [{ key: "Enter" }, { key: "NumpadEnter" }] }, Un), new ae("traverseSelectionUp", e, { label: "Traverse Up", description: "Traverse the selection moving upward.", shortcut: [{ key: "Enter", modifiers: [de.Shift] }, { key: "NumpadEnter", modifiers: [de.Shift] }] }, Wn), new ae("moveLeft", e, { label: "Move Left", description: "Move active cell to the left.", shortcut: [{ key: "ArrowLeft" }] }, Rn), new ae("selectLeft", e, { label: "Select Left", description: "Extend selection left.", shortcut: [{ key: "ArrowLeft", modifiers: [de.Shift] }] }, g), new ae("moveContentfulLeft", e, { label: "Move Left Contentful", description: "Move left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [de.Ctrl] }] }, v), new ae("selectContentfulLeft", e, { label: "Select Left Contentful", description: "Extend selection left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [de.Ctrl, de.Shift] }] }, O), new ae("moveRight", e, { label: "Move Right", description: "Move active cell to the right.", shortcut: [{ key: "ArrowRight" }] }, b), new ae("selectRight", e, { label: "Select Right", description: "Extend selection right.", shortcut: [{ key: "ArrowRight", modifiers: [de.Shift] }] }, y), new ae("moveContentfulRight", e, { label: "Move Right Contentful", description: "Move right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [de.Ctrl] }] }, V), new ae("selectContentfulRight", e, { label: "Select Right Contentful", description: "Extend selection right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [de.Ctrl, de.Shift] }] }, Q), new ae("moveUp", e, { label: "Move Up", description: "Move active cell to the up.", shortcut: [{ key: "ArrowUp" }] }, oe), new ae("selectUp", e, { label: "Select Up", description: "Extend selection up.", shortcut: [{ key: "ArrowUp", modifiers: [de.Shift] }] }, ce), new ae("moveContentfulUp", e, { label: "Move Up Contentful", description: "Move up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [de.Ctrl] }] }, W), new ae("selectContentfulUp", e, { label: "Select Up Contentful", description: "Extend selection up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [de.Ctrl, de.Shift] }] }, ye), new ae("moveDown", e, { label: "Move Down", description: "Move active cell to the down.", shortcut: [{ key: "ArrowDown" }] }, Ge), new ae("selectDown", e, { label: "Select Down", description: "Extend selection down.", shortcut: [{ key: "ArrowDown", modifiers: [de.Shift] }] }, Oe), new ae("moveContentfulDown", e, { label: "Move Down Contentful", description: "Move down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [de.Ctrl] }] }, ze), new ae("selectContentfulDown", e, { label: "Select Down Contentful", description: "Extend selection down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [de.Ctrl, de.Shift] }] }, qe), new ae("selectVisible", e, { label: "Select Visible", description: "Select visible cells only.", shortcut: { key: ";", modifiers: [de.Alt] } }, Fn), new ae("traverseSelectionPreviousRange", e, { label: "Traverse Previous Range", description: "Traverse the selection to the previous range.", shortcut: { key: "ArrowLeft", modifiers: [de.Ctrl, de.Alt] } }, pn), new ae("traverseSelectionNextRange", e, { label: "Traverse Next Range", description: "Traverse the selection to the next range.", shortcut: { key: "ArrowRight", modifiers: [de.Ctrl, de.Alt] } }, Hn), new ae("traverseSelectionCorners", e, { label: "Traverse Corners", description: "Traverse the selection through the corners of the selected range.", shortcut: { key: ".", modifiers: [de.Ctrl] } }, Nn)];
1286
1320
  }, []);
1287
- return Ae(() => {
1288
- n?.addCommands(Rt, !0);
1289
- }, [n]), { selection: Ot, setSelectionCell: rt, setSelectionRanges: dt, overlay: yt, cursor: ln, onPointerDown: zn, clearLastSelection: Ne, newSelection: vt, modifySelection: ut, appendSelection: Le, clearSelections: _t, isEntire: St, navigate: Je, navigateSelection: jt };
1321
+ return Ve(() => {
1322
+ n?.addCommands(zt, !0);
1323
+ }, [n]), { selection: ct, setSelectionCell: it, setSelectionRanges: ht, overlay: yt, cursor: ln, onPointerDown: zn, clearLastSelection: Re, newSelection: It, modifySelection: gt, appendSelection: Te, clearSelections: Jt, isEntire: St, navigate: nt, navigateSelection: Yt };
1290
1324
  };
1291
1325
  function Tn(t, n) {
1292
1326
  if (!t) throw new Error("Invariant failed");
1293
1327
  }
1294
- const ao = { "sheetxl-grid": "_sheetxl-grid_h9wwa_7" }, Qo = Object.freeze({ top: 0, left: 0 }), Jo = Object.freeze({ bottom: -4, right: -4 }), er = Object.freeze({ horizontal: !0, vertical: !0 }), uo = [_e.TopLeft, _e.Top, _e.Left, _e.Center], xr = 150, Yt = 3e3, qn = {}, Eo = Nt(Jt((t, n) => {
1295
- const { width: o, height: r, rowCount: c = 1, columnCount: a = 1, defaultRowHeight: i, defaultColumnWidth: l, getRowHeight: h, getColumnWidth: T, layout: B, onViewportScroll: R, onImmediateScroll: P, showGridLines: L = !0, gridLineColor: ce = "rgb(224, 224, 224)", gridLineRowsProps: J, gridLineColumnsProps: oe, clipCells: $e = !0, cursor: te, freezeLeft: k = 0, freezeTop: Q = 0, freezeLeftProps: Se, freezeTopProps: A, cellRenderer: me, onViewportChange: Ve, onFirstRender: Te, overlayRenderer: We, overlayProps: ge, overlays: Ce, overlaysProps: O, allowOverlaysOverflow: p = !1, stageProps: Ke, stageWrapper: qe = null, hiddenRowsAt: F, hiddenColumnsAt: re, hiddenCellAt: W, getVisibleCells: X, zoom: se = 1, enableMouseWheel: Lt = !0, onWheelScroll: mt, getCellCoordsAsRangeCoords: st = $.cellToRange, scrollPoint: at = Qo, style: fe = {}, ...en } = t;
1296
- Tn(me), Tn(!t?.children);
1297
- const M = D(P, [P]), S = D(Ve, [Ve]), Pe = D(R, [R]), le = D(mt, [mt]), xe = D(Te, [Te]), Ue = ue(null), et = ue(null), Ct = ue(null), [tt, Kt] = Zn((g) => g + 1, 0), [ft, m] = gt({ left: at?.left ?? 0, top: at?.top ?? 0, horizontalScrollDirection: null, verticalScrollDirection: null }), ie = ue(null), Xe = ue(ft), { top: dt, left: Ge, verticalScrollDirection: ln, horizontalScrollDirection: Gt } = ft, kt = ue(!1), hn = Bo({ rowCount: c, columnCount: a, defaultRowHeight: i, defaultColumnWidth: l, getRowHeight: h, getColumnWidth: T }), Xt = ue(null), Oe = Ae(() => {
1298
- const g = B || hn;
1299
- return Xt.current = null, { getColOffset: (v) => g.getColOffset(v) * se, getColIndex: (v) => g.getColIndex(v / se), getRowOffset: (v) => g.getRowOffset(v) * se, getRowIndex: (v) => g.getRowIndex(v / se) };
1300
- }, [hn, B, se]), Wt = (g, v, y) => {
1301
- const C = (v?.left ?? 0) + 0, I = (v?.top ?? 0) + 0;
1302
- return { getColOffset: (Y) => g.getColOffset(Y) - C, getColIndex: (Y) => g.getColIndex(Y + C), getRowOffset: (Y) => g.getRowOffset(Y) - I, getRowIndex: (Y) => g.getRowIndex(Y + I) };
1303
- }, wt = z((g, v = !1) => On(g, v, Oe.getRowOffset, v ? 0 : c), [c, Oe?.getRowOffset]), Bt = D(F ?? wt, [F]), vn = z((g, v = !1) => On(g, v, Oe.getColOffset, v ? a : 0), [a, Oe?.getColOffset]), cn = D(re ?? vn, [re]), He = Ae(() => Math.min(o ?? 800, Oe.getColOffset(a)), [Oe.getColOffset, a, o]), Be = Ae(() => Math.min(r ?? 600, Oe.getRowOffset(c)), [Oe.getRowOffset, c, r]), tn = z((g) => {
1304
- Ht.canUseDOM && setTimeout(() => {
1305
- Ue.current?.focus({ preventScroll: !0, ...g });
1328
+ const uo = { "sheetxl-grid": "_sheetxl-grid_h9wwa_7" }, rr = Object.freeze({ top: 0, left: 0 }), lr = Object.freeze({ bottom: -4, right: -4 }), ir = Object.freeze({ horizontal: !0, vertical: !0 }), ho = [_e.TopLeft, _e.Top, _e.Left, _e.Center], br = 150, Xt = 3e3, Yn = {}, Ro = Kt(en((t, n) => {
1329
+ const { width: o, height: r, rowCount: s = 1, columnCount: c = 1, defaultRowHeight: i, defaultColumnWidth: l, getRowHeight: h, getColumnWidth: k, layout: A, onViewportScroll: E, onImmediateScroll: P, showGridLines: z = !0, gridLineColor: Y = "rgb(224, 224, 224)", gridLineRowsProps: j, gridLineColumnsProps: ee, clipCells: Ie = !0, cursor: Z, freezeLeft: R = 0, freezeTop: U = 0, freezeLeftProps: he, freezeTopProps: M, cellRenderer: se, onViewportChange: Ue, onFirstRender: ke, overlayRenderer: He, overlayProps: ge, overlays: Se, overlaysProps: B, allowOverlaysOverflow: p = !1, stageProps: je, stageWrapper: Ye = null, hiddenRowsAt: ne, hiddenColumnsAt: Ee, hiddenCellAt: J, getVisibleCells: T, zoom: X = 1, enableMouseWheel: Mt = !0, onWheelScroll: Ct, getCellCoordsAsRangeCoords: ft = F.cellToRange, scrollPoint: ut = rr, style: fe = {}, ...Wt } = t;
1330
+ Tn(se), Tn(!t?.children);
1331
+ const D = L(P, [P]), S = L(Ue, [Ue]), Me = L(E, [E]), re = L(Ct, [Ct]), xe = L(ke, [ke]), Ne = ie(null), ot = ie(null), Et = ie(null), [rt, qt] = Ln((g) => g + 1, 0), [wt, m] = dt({ left: ut?.left ?? 0, top: ut?.top ?? 0, horizontalScrollDirection: null, verticalScrollDirection: null }), le = ie(null), Je = ie(wt), { top: ht, left: Qe, verticalScrollDirection: ln, horizontalScrollDirection: Zt } = wt, Pt = ie(!1), hn = Ao({ rowCount: s, columnCount: c, defaultRowHeight: i, defaultColumnWidth: l, getRowHeight: h, getColumnWidth: k }), Gt = ie(null), Pe = Ve(() => {
1332
+ const g = A || hn;
1333
+ return Gt.current = null, { getColOffset: (v) => g.getColOffset(v) * X, getColIndex: (v) => g.getColIndex(v / X), getRowOffset: (v) => g.getRowOffset(v) * X, getRowIndex: (v) => g.getRowIndex(v / X) };
1334
+ }, [hn, A, X]), Ut = (g, v, O) => {
1335
+ const b = (v?.left ?? 0) + 0, y = (v?.top ?? 0) + 0;
1336
+ return { getColOffset: (V) => g.getColOffset(V) - b, getColIndex: (V) => g.getColIndex(V + b), getRowOffset: (V) => g.getRowOffset(V) - y, getRowIndex: (V) => g.getRowIndex(V + y) };
1337
+ }, mt = $((g, v = !1) => On(g, v, Pe.getRowOffset, v ? 0 : s), [s, Pe?.getRowOffset]), Bt = L(ne ?? mt, [ne]), vn = $((g, v = !1) => On(g, v, Pe.getColOffset, v ? c : 0), [c, Pe?.getColOffset]), cn = L(Ee ?? vn, [Ee]), Ke = Ve(() => Math.min(o ?? 800, Pe.getColOffset(c)), [Pe.getColOffset, c, o]), Ae = Ve(() => Math.min(r ?? 600, Pe.getRowOffset(s)), [Pe.getRowOffset, s, r]), tn = $((g) => {
1338
+ Nt.canUseDOM && setTimeout(() => {
1339
+ Ne.current?.focus({ preventScroll: !0, ...g });
1306
1340
  }, 0);
1307
- }, []), xt = z((g) => Ue.current?.contains(g) || et.current?.contains(g), []);
1308
- bt(() => {
1309
- kt.current && (ie.current && ie.current.left !== Xe.current?.left && ie.current.top !== Xe.current?.top || (ie.current = null, Pe?.({ left: Ge, top: dt })));
1310
- }, [Ge, dt]);
1311
- const qt = D(() => ({ top: dt, left: Ge }), [dt, Ge]), ze = Ae(() => {
1341
+ }, []), vt = $((g) => Ne.current?.contains(g) || ot.current?.contains(g), []);
1342
+ pt(() => {
1343
+ Pt.current && (le.current && le.current.left !== Je.current?.left && le.current.top !== Je.current?.top || (le.current = null, Me?.({ left: Qe, top: ht })));
1344
+ }, [Qe, ht]);
1345
+ const jt = L(() => ({ top: ht, left: Qe }), [ht, Qe]), De = Ve(() => {
1312
1346
  const g = [];
1313
- let v = 0, y = 0;
1314
- typeof Q == "number" ? v = Q : (v = Q.index ?? 0, y = (Q.scrollOffset ?? 0) * se);
1315
- const C = y, I = Oe.getRowOffset(v), Y = I - C;
1347
+ let v = 0, O = 0;
1348
+ typeof U == "number" ? v = U : (v = U.index ?? 0, O = (U.scrollOffset ?? 0) * X);
1349
+ const b = O, y = Pe.getRowOffset(v), V = y - b;
1316
1350
  if (v > 0) {
1317
- const Qe = Wt(Oe, { top: y + Oe.getRowOffset(0) }), Re = Oe.getRowIndex(C), Me = Oe.getRowIndex(I - 1);
1318
- let nt;
1319
- g[1] = { minIndex: Re, maxIndex: Me, minCoord: 0, maxCoord: v - 1, minBounds: 0, maxBounds: Y, visibleIndices: () => nt || (nt = Object.freeze(Pn(Bt, Re, Me)), nt), layout: Qe, maxVirtualBounds: I, scrollOffset: y, freezeOffset: y };
1351
+ const Ge = Ut(Pe, { top: O + Pe.getRowOffset(0) }), Oe = Pe.getRowIndex(b), ze = Pe.getRowIndex(y - 1);
1352
+ let qe;
1353
+ g[1] = { minIndex: Oe, maxIndex: ze, minCoord: 0, maxCoord: v - 1, minBounds: 0, maxBounds: V, visibleIndices: () => qe || (qe = Object.freeze(Pn(Bt, Oe, ze)), qe), layout: Ge, maxVirtualBounds: y, scrollOffset: O, freezeOffset: O };
1320
1354
  }
1321
- const N = Math.max(0, Be - Y), ee = Wt(Oe, { top: dt + Y }), ne = ee.getRowIndex(0), K = ee.getRowIndex(N);
1322
- let De;
1323
- return g[0] = { minIndex: ne, maxIndex: K, minCoord: v, maxCoord: c - 1, minBounds: Y, maxBounds: N, visibleIndices: () => De || (De = Object.freeze(Pn(Bt, ne, K)), De), layout: ee, maxVirtualBounds: Oe.getRowOffset(c), scrollOffset: dt, freezeOffset: (v > 0 ? Oe.getRowOffset(v) : 0) - y }, g;
1324
- }, [Oe.getRowIndex, Oe.getRowOffset, Bt, Be, c, Q, dt, se]), je = Ae(() => {
1355
+ const Q = Math.max(0, Ae - V), oe = Ut(Pe, { top: ht + V }), ce = oe.getRowIndex(0), W = oe.getRowIndex(Q);
1356
+ let ye;
1357
+ return g[0] = { minIndex: ce, maxIndex: W, minCoord: v, maxCoord: s - 1, minBounds: V, maxBounds: Q, visibleIndices: () => ye || (ye = Object.freeze(Pn(Bt, ce, W)), ye), layout: oe, maxVirtualBounds: Pe.getRowOffset(s), scrollOffset: ht, freezeOffset: (v > 0 ? Pe.getRowOffset(v) : 0) - O }, g;
1358
+ }, [Pe.getRowIndex, Pe.getRowOffset, Bt, Ae, s, U, ht, X]), Xe = Ve(() => {
1325
1359
  const g = [];
1326
- let v = 0, y = 0;
1327
- typeof k == "number" ? v = k : (v = k.index ?? 0, y = (k.scrollOffset ?? 0) * se);
1328
- const C = y, I = Oe.getColOffset(v), Y = I - C;
1360
+ let v = 0, O = 0;
1361
+ typeof R == "number" ? v = R : (v = R.index ?? 0, O = (R.scrollOffset ?? 0) * X);
1362
+ const b = O, y = Pe.getColOffset(v), V = y - b;
1329
1363
  if (v > 0) {
1330
- const Qe = Wt(Oe, { left: y + Oe.getColOffset(0) }), Re = Oe.getColIndex(C), Me = Oe.getColIndex(I - 1);
1331
- let nt;
1332
- g[1] = { minIndex: Re, maxIndex: Me, minCoord: 0, maxCoord: v - 1, minBounds: 0, maxBounds: Y, visibleIndices: () => nt || (nt = Object.freeze(Pn(cn, Re, Me)), nt), layout: Qe, maxVirtualBounds: I, scrollOffset: y, freezeOffset: y };
1364
+ const Ge = Ut(Pe, { left: O + Pe.getColOffset(0) }), Oe = Pe.getColIndex(b), ze = Pe.getColIndex(y - 1);
1365
+ let qe;
1366
+ g[1] = { minIndex: Oe, maxIndex: ze, minCoord: 0, maxCoord: v - 1, minBounds: 0, maxBounds: V, visibleIndices: () => qe || (qe = Object.freeze(Pn(cn, Oe, ze)), qe), layout: Ge, maxVirtualBounds: y, scrollOffset: O, freezeOffset: O };
1333
1367
  }
1334
- const N = Math.max(0, He - Y), ee = Wt(Oe, { left: Ge + Y }), ne = ee.getColIndex(0), K = ee.getColIndex(N);
1335
- let De;
1336
- return g[0] = { minIndex: ne, maxIndex: K, minCoord: v, maxCoord: a - 1, minBounds: Y, maxBounds: N, visibleIndices: () => De || (De = Object.freeze(Pn(cn, ne, K)), De), layout: ee, maxVirtualBounds: Oe.getColOffset(a), scrollOffset: Ge, freezeOffset: (v > 0 ? Oe.getColOffset(v) : 0) - y }, g;
1337
- }, [Oe.getColIndex, Oe.getColOffset, cn, He, a, k, Ge, se]), ut = ue({}), vt = ue([]), Le = Ae(() => {
1368
+ const Q = Math.max(0, Ke - V), oe = Ut(Pe, { left: Qe + V }), ce = oe.getColIndex(0), W = oe.getColIndex(Q);
1369
+ let ye;
1370
+ return g[0] = { minIndex: ce, maxIndex: W, minCoord: v, maxCoord: c - 1, minBounds: V, maxBounds: Q, visibleIndices: () => ye || (ye = Object.freeze(Pn(cn, ce, W)), ye), layout: oe, maxVirtualBounds: Pe.getColOffset(c), scrollOffset: Qe, freezeOffset: (v > 0 ? Pe.getColOffset(v) : 0) - O }, g;
1371
+ }, [Pe.getColIndex, Pe.getColOffset, cn, Ke, c, R, Qe, X]), gt = ie({}), It = ie([]), Te = Ve(() => {
1338
1372
  let g = {};
1339
- const v = (C, I, Y, N, ee) => {
1340
- const ne = { vertical: N?.vertical || !1, horizontal: N?.horizontal || !1 };
1341
- if (C >= je.length || I >= ze.length) return null;
1342
- const K = { rowStart: ze[I].minIndex, colStart: je[C].minIndex, rowEnd: ze[I].maxIndex, colEnd: je[C].maxIndex };
1343
- if (K.rowStart > K.rowEnd || K.colStart > K.colEnd) return null;
1344
- const De = { getColIndex: (ke) => je[C].layout.getColIndex(ke), getColOffset: (ke) => je[C].layout.getColOffset(ke), getRowIndex: (ke) => ze[I].layout.getRowIndex(ke), getRowOffset: (ke) => ze[I].layout.getRowOffset(ke) }, Qe = Object.freeze({ left: ee?.left ?? 0, top: ee?.top ?? 0, right: ee?.right ?? 0, bottom: ee?.bottom ?? 0 }), Re = Object.freeze({ x: je[C].minBounds, y: ze[I].minBounds, width: je[C].maxBounds, height: ze[I].maxBounds }), Me = (ke, Ie) => io(De, ke ?? K, Ie), nt = { width: je[C].maxVirtualBounds, height: ze[I].maxVirtualBounds }, Ne = { left: je[C].scrollOffset, top: ze[I].scrollOffset }, St = { left: je[C].freezeOffset, top: ze[I].freezeOffset }, rt = { width: He, height: Be };
1345
- let G = null, ot = null;
1346
- const Tt = (St.top + (N.vertical ? Ne.top : 0)) / se, Mt = (St.left + (N.horizontal ? Ne.left : 0)) / se;
1347
- return { getStage: () => Ue.current ?? null, getVisibleRangeCoords: () => K, toClipBounds: (ke, Ie) => {
1348
- let Ye, ye = 0;
1349
- return Ie === void 0 || typeof Ie == "number" ? (Ye = Me(K), ye = Ie) : Ye = Ie, ((ve, lt, ht = 0) => {
1350
- if (ve.x > lt.width || ve.y > lt.height) return null;
1351
- const Et = { left: ve.x, top: ve.y, bottom: ve.height + ve.y, right: ve.width + ve.x }, Ot = { left: lt.x + ht, top: lt.y + ht, bottom: lt.height - 2 * ht + lt.y, right: lt.width - 2 * ht + lt.x }, yt = { left: Math.max(Et.left, Ot.left), top: Math.max(Et.top, Ot.top), bottom: Math.min(Et.bottom, Ot.bottom), right: Math.min(Et.right, Ot.right) }, Rt = { x: yt.left, y: yt.top, width: yt.right - yt.left, height: yt.bottom - yt.top };
1352
- return Rt.height < 0 || Rt.width < 0 ? null : Rt;
1353
- })(ke ?? { x: 0, y: 0, width: Re.width, height: Re.height }, Ye, ye);
1354
- }, toViewBounds: (ke) => Mt === 0 && Tt === 0 && se === 1 ? ke : { x: (ke.x - Mt) * se, y: (ke.y - Tt) * se, width: ke.width * se, height: ke.height * se }, toAbsoluteBounds: (ke) => Mt === 0 && Tt === 0 && se === 1 ? ke : { x: ke.x / se + Mt, y: ke.y / se + Tt, width: ke.width / se, height: ke.height / se }, getRelativePointFromClient: (ke, Ie) => {
1355
- const Ye = sn(ke, Ie);
1356
- return { x: Ye.x - Re.x, y: Ye.y - Re.y };
1357
- }, getLayout: () => De, getCellCoordsAsRangeCoords: st, getVisibleColumns: () => je[C].visibleIndices(), getVisibleRows: () => ze[I].visibleIndices(), getVisibleColumnOffsets: () => (G || (G = lo(je[C].layout, !0, je[C].visibleIndices(), K.colStart, K.colEnd)), G), getVisibleRowOffsets: () => (ot || (ot = lo(ze[I].layout, !1, ze[I].visibleIndices(), K.rowStart, K.rowEnd)), ot), getTotalRangeCoords: () => ({ colStart: je[C].minCoord, colEnd: je[C].maxCoord, rowStart: ze[I].minCoord, rowEnd: ze[I].maxCoord }), getRangeCoordsBounds: Me, scrollCellCoordsIntoView: (ke, Ie) => gn(ke, Ie, Y), getCellCoordsFromClient: (ke, Ie, Ye = !1) => {
1358
- const ye = sn(ke, Ie);
1359
- if (!ye) return null;
1360
- const ve = De.getColIndex(ye.x - Re.x), lt = { rowIndex: De.getRowIndex(ye.y - Re.y), colIndex: ve };
1361
- if (Ye) return lt;
1362
- const ht = st(lt);
1363
- return { rowIndex: ht.rowStart, colIndex: ht.colStart };
1364
- }, getZoom: () => se, getAnchor: () => Y, getBounds: () => Re, getInsets: () => Qe, getTotalSize: () => nt, getViewportSize: () => rt, getScrollTopLeft: () => Ne, getFreezeTopLeft: () => St, getScrollOrientation: () => ne, allViews: () => g };
1373
+ const v = (b, y, V, Q, oe) => {
1374
+ const ce = { vertical: Q?.vertical || !1, horizontal: Q?.horizontal || !1 };
1375
+ if (b >= Xe.length || y >= De.length) return null;
1376
+ const W = { rowStart: De[y].minIndex, colStart: Xe[b].minIndex, rowEnd: De[y].maxIndex, colEnd: Xe[b].maxIndex };
1377
+ if (W.rowStart > W.rowEnd || W.colStart > W.colEnd) return null;
1378
+ const ye = { getColIndex: (me) => Xe[b].layout.getColIndex(me), getColOffset: (me) => Xe[b].layout.getColOffset(me), getRowIndex: (me) => De[y].layout.getRowIndex(me), getRowOffset: (me) => De[y].layout.getRowOffset(me) }, Ge = Object.freeze({ left: oe?.left ?? 0, top: oe?.top ?? 0, right: oe?.right ?? 0, bottom: oe?.bottom ?? 0 }), Oe = Object.freeze({ x: Xe[b].minBounds, y: De[y].minBounds, width: Xe[b].maxBounds, height: De[y].maxBounds }), ze = (me, Ze) => so(ye, me ?? W, Ze), qe = { width: Xe[b].maxVirtualBounds, height: De[y].maxVirtualBounds }, Re = { left: Xe[b].scrollOffset, top: De[y].scrollOffset }, St = { left: Xe[b].freezeOffset, top: De[y].freezeOffset }, it = { width: Ke, height: Ae };
1379
+ let Be = null, be = null;
1380
+ const lt = (St.top + (Q.vertical ? Re.top : 0)) / X, Ot = (St.left + (Q.horizontal ? Re.left : 0)) / X;
1381
+ return { getStage: () => Ne.current ?? null, getVisibleRangeCoords: () => W, toClipBounds: (me, Ze) => {
1382
+ let kt, Fe = 0;
1383
+ return Ze === void 0 || typeof Ze == "number" ? (kt = ze(W), Fe = Ze) : kt = Ze, ((tt, $e, Le = 0) => {
1384
+ if (tt.x > $e.width || tt.y > $e.height) return null;
1385
+ const xt = { left: tt.x, top: tt.y, bottom: tt.height + tt.y, right: tt.width + tt.x }, ct = { left: $e.x + Le, top: $e.y + Le, bottom: $e.height - 2 * Le + $e.y, right: $e.width - 2 * Le + $e.x }, yt = { left: Math.max(xt.left, ct.left), top: Math.max(xt.top, ct.top), bottom: Math.min(xt.bottom, ct.bottom), right: Math.min(xt.right, ct.right) }, zt = { x: yt.left, y: yt.top, width: yt.right - yt.left, height: yt.bottom - yt.top };
1386
+ return zt.height < 0 || zt.width < 0 ? null : zt;
1387
+ })(me ?? { x: 0, y: 0, width: Oe.width, height: Oe.height }, kt, Fe);
1388
+ }, toViewBounds: (me) => Ot === 0 && lt === 0 && X === 1 ? me : { x: (me.x - Ot) * X, y: (me.y - lt) * X, width: me.width * X, height: me.height * X }, toAbsoluteBounds: (me) => Ot === 0 && lt === 0 && X === 1 ? me : { x: me.x / X + Ot, y: me.y / X + lt, width: me.width / X, height: me.height / X }, getRelativePointFromClient: (me, Ze) => {
1389
+ const kt = sn(me, Ze);
1390
+ return { x: kt.x - Oe.x, y: kt.y - Oe.y };
1391
+ }, getLayout: () => ye, getCellCoordsAsRangeCoords: ft, getVisibleColumns: () => Xe[b].visibleIndices(), getVisibleRows: () => De[y].visibleIndices(), getVisibleColumnOffsets: () => (Be || (Be = co(Xe[b].layout, !0, Xe[b].visibleIndices(), W.colStart, W.colEnd)), Be), getVisibleRowOffsets: () => (be || (be = co(De[y].layout, !1, De[y].visibleIndices(), W.rowStart, W.rowEnd)), be), getTotalRangeCoords: () => ({ colStart: Xe[b].minCoord, colEnd: Xe[b].maxCoord, rowStart: De[y].minCoord, rowEnd: De[y].maxCoord }), getRangeCoordsBounds: ze, scrollCellCoordsIntoView: (me, Ze) => gn(me, Ze, V), getCellCoordsFromClient: (me, Ze, kt = !1) => {
1392
+ const Fe = sn(me, Ze);
1393
+ if (!Fe) return null;
1394
+ const tt = ye.getColIndex(Fe.x - Oe.x), $e = { rowIndex: ye.getRowIndex(Fe.y - Oe.y), colIndex: tt };
1395
+ if (kt) return $e;
1396
+ const Le = ft($e);
1397
+ return { rowIndex: Le.rowStart, colIndex: Le.colStart };
1398
+ }, getZoom: () => X, getAnchor: () => V, getBounds: () => Oe, getInsets: () => Ge, getTotalSize: () => qe, getViewportSize: () => it, getScrollTopLeft: () => Re, getFreezeTopLeft: () => St, getScrollOrientation: () => ce, allViews: () => g };
1365
1399
  };
1366
- let y = g[_e.Center] = v(0, 0, _e.Center, er, Jo);
1367
- return y && (g[_e.Center] = y), y = v(0, 1, _e.Top, { horizontal: !0 }), y && (g[_e.Top] = y), y = v(1, 0, _e.Left, { vertical: !0 }), y && (g[_e.Left] = y), y = v(1, 1, _e.TopLeft, {}), y && (g[_e.TopLeft] = y), ut.current = null, g = Object.freeze(g);
1368
- }, [ze, je, st]), _t = Object.keys(Le), Pt = je[0]?.maxVirtualBounds ?? 0, Ze = ze[0]?.maxVirtualBounds ?? 0, It = Ae(() => ({ left: je[1] ? je[1].layout.getColOffset(je[1].maxIndex + 1) : 0, top: ze[1] ? ze[1].layout.getRowOffset(ze[1].maxIndex + 1) : 0 }), [Le]);
1369
- bt(() => {
1370
- if (vt.current.length > 0) {
1371
- for (let g = 0; g < vt.current.length; g++) vt.current[g]();
1372
- vt.current = [];
1400
+ let O = g[_e.Center] = v(0, 0, _e.Center, ir, lr);
1401
+ return O && (g[_e.Center] = O), O = v(0, 1, _e.Top, { horizontal: !0 }), O && (g[_e.Top] = O), O = v(1, 0, _e.Left, { vertical: !0 }), O && (g[_e.Left] = O), O = v(1, 1, _e.TopLeft, {}), O && (g[_e.TopLeft] = O), gt.current = null, g = Object.freeze(g);
1402
+ }, [De, Xe, ft]), Jt = Object.keys(Te), Dt = Xe[0]?.maxVirtualBounds ?? 0, et = De[0]?.maxVirtualBounds ?? 0, Rt = Ve(() => ({ left: Xe[1] ? Xe[1].layout.getColOffset(Xe[1].maxIndex + 1) : 0, top: De[1] ? De[1].layout.getRowOffset(De[1].maxIndex + 1) : 0 }), [Te]);
1403
+ pt(() => {
1404
+ if (It.current.length > 0) {
1405
+ for (let g = 0; g < It.current.length; g++) It.current[g]();
1406
+ It.current = [];
1373
1407
  }
1374
- }, [Le]);
1375
- const Dt = D(() => ({ containerWidth: He, containerHeight: Be, totalWidth: Pt, totalHeight: Ze }), [He, Be, Oe]);
1376
- bt(() => {
1377
- !ie.current && kt.current && S({ top: dt, left: Ge, width: He, height: Be, totalWidth: Pt, totalHeight: Ze });
1378
- }, [dt, Ge, Pt, Ze]), bt(() => {
1379
- kt.current && S({ top: dt, left: Ge, width: He, height: Be, totalWidth: Pt, totalHeight: Ze });
1380
- }, [He, Be]);
1381
- const sn = z((g, v) => {
1408
+ }, [Te]);
1409
+ const Tt = L(() => ({ containerWidth: Ke, containerHeight: Ae, totalWidth: Dt, totalHeight: et }), [Ke, Ae, Pe]);
1410
+ pt(() => {
1411
+ !le.current && Pt.current && S({ top: ht, left: Qe, width: Ke, height: Ae, totalWidth: Dt, totalHeight: et });
1412
+ }, [ht, Qe, Dt, et]), pt(() => {
1413
+ Pt.current && S({ top: ht, left: Qe, width: Ke, height: Ae, totalWidth: Dt, totalHeight: et });
1414
+ }, [Ke, Ae]);
1415
+ const sn = $((g, v) => {
1382
1416
  Tn(typeof g == "number" && typeof v == "number");
1383
- const y = Ue.current?.getBoundingClientRect();
1384
- return y ? { x: g - y.x, y: v - y.y } : { x: g, y: v };
1385
- }, []), zn = D((g) => Le[g] || null, [Le]), Ln = D((g, v) => {
1386
- if (Object.keys(Le).length === 1) return Le[_e.Center];
1387
- const y = sn(g, v);
1388
- if (!y) return null;
1389
- const { x: C, y: I } = y;
1390
- let Y = null;
1391
- const N = uo;
1392
- for (let ee = 0; !Y && ee < N.length; ee++) {
1393
- const ne = Le[N[ee]];
1394
- ne && Ko(C, I, ne.getBounds()) && (Y = ne);
1417
+ const O = Ne.current?.getBoundingClientRect();
1418
+ return O ? { x: g - O.x, y: v - O.y } : { x: g, y: v };
1419
+ }, []), zn = L((g) => Te[g] || null, [Te]), $n = L((g, v) => {
1420
+ if (Object.keys(Te).length === 1) return Te[_e.Center];
1421
+ const O = sn(g, v);
1422
+ if (!O) return null;
1423
+ const { x: b, y } = O;
1424
+ let V = null;
1425
+ const Q = ho, oe = Q.length;
1426
+ for (let ce = 0; !V && ce < oe; ce++) {
1427
+ const W = Te[Q[ce]];
1428
+ W && Jo(b, y, W.getBounds()) && (V = W);
1395
1429
  }
1396
- return Y || (Y = Le[_e.Center]), Y;
1397
- }, [Le, st]), Je = D(() => Le[_e.Center].getVisibleRangeCoords(), [Le[_e.Center]]), jt = ue(null), $n = z(() => {
1398
- jt.current !== null && Ht.cancelTimeout(jt.current), jt.current = Ht.requestTimeout(Bn, 150);
1399
- }, []), Bn = z(() => {
1400
- jt.current = null, m((g) => {
1430
+ return V || (V = Te[_e.Center]), V;
1431
+ }, [Te, ft]), nt = L(() => Te[_e.Center].getVisibleRangeCoords(), [Te[_e.Center]]), Yt = ie(null), Bn = $(() => {
1432
+ Yt.current !== null && Nt.cancelTimeout(Yt.current), Yt.current = Nt.requestTimeout(An, 150);
1433
+ }, []), An = $(() => {
1434
+ Yt.current = null, m((g) => {
1401
1435
  const v = { ...g, verticalScrollDirection: null, horizontalScrollDirection: null };
1402
- return Xe.current = v, v;
1436
+ return Je.current = v, v;
1403
1437
  });
1404
- }, []), nn = D((g) => {
1405
- const v = g?.left ?? g?.[0], y = g?.top ?? g?.[1], C = v !== void 0 ? Math.min(Pt - He, Math.max(je?.[1]?.scrollOffset ?? 0, v)) : Xe.current.left, I = y !== void 0 ? Math.min(Ze - Be, Math.max(ze?.[1]?.scrollOffset ?? 0, y)) : Xe.current.top;
1406
- if (Xe.current.left === C && Xe.current.top === I) return;
1407
- let Y = null, N = null;
1408
- Xe.current.left > C ? Y = f.Left : Xe.current.left < C && (Y = f.Right), Xe.current.top > I ? N = f.Up : Xe.current.top < I && (N = f.Down), Ht.throttle(() => {
1409
- m((ee) => {
1410
- const ne = { ...ee, left: C, top: I, horizontalScrollDirection: Y, verticalScrollDirection: N };
1411
- return Xe.current = ne, ne;
1438
+ }, []), nn = L((g) => {
1439
+ const v = g?.left ?? g?.[0], O = g?.top ?? g?.[1], b = v !== void 0 ? Math.min(Dt - Ke, Math.max(Xe?.[1]?.scrollOffset ?? 0, v)) : Je.current.left, y = O !== void 0 ? Math.min(et - Ae, Math.max(De?.[1]?.scrollOffset ?? 0, O)) : Je.current.top;
1440
+ if (Je.current.left === b && Je.current.top === y) return;
1441
+ let V = null, Q = null;
1442
+ Je.current.left > b ? V = w.Left : Je.current.left < b && (V = w.Right), Je.current.top > y ? Q = w.Up : Je.current.top < y && (Q = w.Down), Nt.throttle(() => {
1443
+ m((oe) => {
1444
+ const ce = { ...oe, left: b, top: y, horizontalScrollDirection: V, verticalScrollDirection: Q };
1445
+ return Je.current = ce, ce;
1412
1446
  });
1413
- }, 17)(), ie.current?.top === I && ie.current?.left === C || (ie.current = { left: C, top: I }, M({ left: C, top: I }), S({ left: C, top: I, width: He, height: Be, totalWidth: Pt, totalHeight: Ze })), $n();
1414
- }, [Pt, Ze, ze, je]);
1415
- bt(() => {
1416
- ie.current || nn({ left: Ge, top: dt });
1417
- }, [Pt, He, Ze, Be]), Qt(() => {
1418
- ie.current = { left: at?.left, top: at?.top }, nn(ie.current);
1419
- }, [at?.left, at?.top]);
1420
- const Sn = D((g) => {
1421
- const v = g?.left ?? g?.[0], y = g?.top ?? g?.[1], C = g?.behavior ?? "auto", I = { left: Xe.current.left + (v ?? 0), top: Xe.current.top + (y ?? 0) };
1422
- C && (I.behavior = C), nn(I);
1423
- }, [Pt, He, Ze, Be]), yn = z((g) => {
1447
+ }, 17)(), le.current?.top === y && le.current?.left === b || (le.current = { left: b, top: y }, D({ left: b, top: y }), S({ left: b, top: y, width: Ke, height: Ae, totalWidth: Dt, totalHeight: et })), Bn();
1448
+ }, [Dt, et, De, Xe]);
1449
+ pt(() => {
1450
+ le.current || nn({ left: Qe, top: ht });
1451
+ }, [Dt, Ke, et, Ae]), _t(() => {
1452
+ le.current = { left: ut?.left, top: ut?.top }, nn(le.current);
1453
+ }, [ut?.left, ut?.top]);
1454
+ const Sn = L((g) => {
1455
+ const v = g?.left ?? g?.[0], O = g?.top ?? g?.[1], b = g?.behavior ?? "auto", y = { left: Je.current.left + (v ?? 0), top: Je.current.top + (O ?? 0) };
1456
+ b && (y.behavior = b), nn(y);
1457
+ }, [Dt, Ke, et, Ae]), yn = $((g) => {
1424
1458
  let v = null;
1425
- if (Object.keys(Le).length > 1) {
1426
- const y = uo;
1427
- for (let C = 0; !v && C < y.length; C++) {
1428
- const I = Le[y[C]];
1429
- I && $.isCellWithinRange(g, I.getVisibleRangeCoords()) && (v = I);
1459
+ if (Object.keys(Te).length > 1) {
1460
+ const O = ho, b = O.length;
1461
+ for (let y = 0; !v && y < b; y++) {
1462
+ const V = Te[O[y]];
1463
+ V && F.isCellWithinRange(g, V.getVisibleRangeCoords()) && (v = V);
1430
1464
  }
1431
1465
  }
1432
- return v || (v = Le[_e.Center]), v;
1433
- }, [Le]), gn = D((g, v = { inline: "nearest", block: "nearest" }, y = null) => {
1434
- const C = { rowIndex: 0, colIndex: 0, ...g };
1435
- let I = null;
1436
- if (y !== null) {
1437
- if (I = Le[y], I === null) return new Promise((rt, G) => {
1438
- G("Invalid view");
1466
+ return v || (v = Te[_e.Center]), v;
1467
+ }, [Te]), gn = L((g, v = { inline: "nearest", block: "nearest" }, O = null) => {
1468
+ const b = { rowIndex: 0, colIndex: 0, ...g };
1469
+ let y = null;
1470
+ if (O !== null) {
1471
+ if (y = Te[O], y === null) return new Promise((it, Be) => {
1472
+ Be("Invalid view");
1439
1473
  });
1440
- } else I = yn(C);
1441
- const Y = st(C), N = I.getLayout(), ee = N.getColOffset(Y.colStart), ne = N.getRowOffset(Y.rowStart), K = N.getColOffset(Y.colEnd + 1), De = N.getRowOffset(Y.rowEnd + 1), Qe = I.getBounds(), Re = I.getTotalSize(), Me = I.getScrollTopLeft(), nt = ((rt, G, ot = !0) => (ot = ot === !0 ? { block: "start", inline: "end" } : ot === !1 ? { block: "end", inline: "end" } : { block: "end", inline: "end", ...ot }, { left: no(ot.inline, rt.x, rt.x + rt.width, G.left, G.left + G.width, G.totalWidth), top: no(ot.block, rt.y, rt.y + rt.height, G.top, G.top + G.height, G.totalHeight) }))({ x: ee + Me.left, y: ne + Me.top, width: K - ee, height: De - ne }, { left: Me.left, top: Me.top, width: Qe.width, height: Qe.height, totalWidth: Re.width, totalHeight: Re.height }, v), Ne = { ...nt };
1442
- Ne.left > Ge ? Ne.left += 20 : Ne.left < Ge && (Ne.left -= 0), Ne.top > dt ? Ne.top += 20 : Ne.top < dt && (Ne.top -= 0);
1443
- const St = I.getScrollOrientation();
1444
- return St.horizontal && g.colIndex !== void 0 || delete Ne.left, St.vertical && g.rowIndex !== void 0 || delete Ne.top, new Promise((rt, G) => {
1474
+ } else y = yn(b);
1475
+ const V = ft(b), Q = y.getLayout(), oe = Q.getColOffset(V.colStart), ce = Q.getRowOffset(V.rowStart), W = Q.getColOffset(V.colEnd + 1), ye = Q.getRowOffset(V.rowEnd + 1), Ge = y.getBounds(), Oe = y.getTotalSize(), ze = y.getScrollTopLeft(), qe = ((it, Be, be = !0) => (be = be === !0 ? { block: "start", inline: "end" } : be === !1 ? { block: "end", inline: "end" } : { block: "end", inline: "end", ...be }, { left: ro(be.inline, it.x, it.x + it.width, Be.left, Be.left + Be.width, Be.totalWidth), top: ro(be.block, it.y, it.y + it.height, Be.top, Be.top + Be.height, Be.totalHeight) }))({ x: oe + ze.left, y: ce + ze.top, width: W - oe, height: ye - ce }, { left: ze.left, top: ze.top, width: Ge.width, height: Ge.height, totalWidth: Oe.width, totalHeight: Oe.height }, v), Re = { ...qe };
1476
+ Re.left > Qe ? Re.left += 20 : Re.left < Qe && (Re.left -= 0), Re.top > ht ? Re.top += 20 : Re.top < ht && (Re.top -= 0);
1477
+ const St = y.getScrollOrientation();
1478
+ return St.horizontal && g.colIndex !== void 0 || delete Re.left, St.vertical && g.rowIndex !== void 0 || delete Re.top, new Promise((it, Be) => {
1445
1479
  try {
1446
- nn(Ne), rt(Ne);
1447
- } catch (ot) {
1448
- G(ot);
1480
+ nn(Re), it(Re);
1481
+ } catch (be) {
1482
+ Be(be);
1449
1483
  }
1450
1484
  });
1451
- }, [Pt, Ze, Le, st]), an = D((g) => {
1485
+ }, [Dt, et, Te, ft]), an = L((g) => {
1452
1486
  const v = g.shiftKey;
1453
1487
  g.preventDefault();
1454
- const { deltaX: y, deltaY: C, deltaMode: I } = g;
1455
- if (Ct.current || le?.(g) === !1) return;
1456
- let N = v ? C : y, ee = C;
1457
- const ne = v || Math.abs(N) > Math.abs(ee);
1458
- I === 1 && (ee *= 0), Ct.current = window.requestAnimationFrame(() => {
1459
- Ct.current = null, Sn(ne ? { left: N } : { top: ee });
1488
+ const { deltaX: O, deltaY: b, deltaMode: y } = g;
1489
+ if (Et.current || re?.(g) === !1) return;
1490
+ let Q = v ? b : O, oe = b;
1491
+ const ce = v || Math.abs(Q) > Math.abs(oe);
1492
+ y === 1 && (oe *= 0), Et.current = window.requestAnimationFrame(() => {
1493
+ Et.current = null, Sn(ce ? { left: Q } : { top: oe });
1460
1494
  });
1461
- }, [Pt, He, Ze, Be, le]), fn = z((g = null) => {
1462
- Xt.current = null, ut.current = null, Kt();
1495
+ }, [Dt, Ke, et, Ae, re]), fn = $((g = null) => {
1496
+ Gt.current = null, gt.current = null, qt();
1463
1497
  }, []);
1464
- Qt(() => {
1498
+ _t(() => {
1465
1499
  fn();
1466
- }, [me]);
1467
- const on = fo(n, () => ({ stage: Ue.current, focus: tn, contains: xt, invalidate: fn, scrollTo: nn, scrollBy: Sn, scrollCellCoordsIntoView: gn, getScrollPosition: qt, getDimensions: Dt, getViewport: Je, handleWheel: an, rowCount: c, columnCount: a, getLayout: () => Oe, getRelativePointFromClient: sn, getViewFromClient: Ln, getViewFromCellCoords: yn, getViewFromLocation: zn, onViewChangeOnce: (g) => {
1468
- vt.current.push(g);
1469
- } }), [c, a, Le]);
1470
- bt(() => (Lt && on.current?.addEventListener("wheel", an, { passive: !1 }), kt.current = !0, ie.current = null, () => {
1500
+ }, [se]);
1501
+ const on = wo(n, () => ({ stage: Ne.current, focus: tn, contains: vt, invalidate: fn, scrollTo: nn, scrollBy: Sn, scrollCellCoordsIntoView: gn, getScrollPosition: jt, getDimensions: Tt, getViewport: nt, handleWheel: an, rowCount: s, columnCount: c, getLayout: () => Pe, getRelativePointFromClient: sn, getViewFromClient: $n, getViewFromCellCoords: yn, getViewFromLocation: zn, onViewChangeOnce: (g) => {
1502
+ It.current.push(g);
1503
+ } }), [s, c, Te]);
1504
+ pt(() => (Mt && on.current?.addEventListener("wheel", an, { passive: !1 }), Pt.current = !0, le.current = null, () => {
1471
1505
  on.current?.removeEventListener("wheel", an);
1472
- }), [Lt]);
1473
- const wn = ue([]), An = (g, v) => {
1474
- !g || !We || (wn.current = [], v.push(((y, C) => {
1475
- const I = `view:${y.getAnchor()}:overlay:${v.length}`, Y = We?.({ key: I, view: y }, (ee) => wn.current[C] = ee);
1476
- if (!Y) return null;
1477
- const N = y.getBounds();
1478
- return Ee("div", { style: { position: "absolute", left: "0px", top: "0px", width: `${N.width}px`, height: `${N.height}px`, overflow: "hidden" }, children: Y }, `overlay-${y.getAnchor()}-${C}`);
1506
+ }), [Mt]);
1507
+ const wn = ie([]), Fn = (g, v) => {
1508
+ !g || !He || (wn.current = [], v.push(((O, b) => {
1509
+ const y = `view:${O.getAnchor()}:overlay:${v.length}`, V = He?.({ key: y, view: O }, (oe) => wn.current[b] = oe);
1510
+ if (!V) return null;
1511
+ const Q = O.getBounds();
1512
+ return Ce("div", { style: { position: "absolute", left: "0px", top: "0px", width: `${Q.width}px`, height: `${Q.height}px`, overflow: "hidden" }, children: V }, `overlay-${O.getAnchor()}-${b}`);
1479
1513
  })(g, 0)));
1480
- }, Fn = Ae(() => {
1481
- const g = {}, v = Object.keys(Le);
1482
- for (let y = 0; y < v.length; y++) {
1483
- const C = v[y], I = [];
1484
- An(Le[C], I), g[C] = { overlays: I };
1514
+ }, Vn = Ve(() => {
1515
+ const g = {}, v = Object.keys(Te), O = v.length;
1516
+ for (let b = 0; b < O; b++) {
1517
+ const y = v[b], V = [];
1518
+ Fn(Te[y], V), g[y] = { overlays: V };
1485
1519
  }
1486
1520
  return g;
1487
- }, [tt, We, c, a, ze, je]), bn = (g, v, y, C, I, Y, N) => {
1521
+ }, [rt, He, s, c, De, Xe]), bn = (g, v, O, b, y, V, Q) => {
1488
1522
  if (!g) return;
1489
- const ee = g.getVisibleColumns(), ne = g.getVisibleRows();
1490
- if (ee.length === 0 || ne.length === 0) return;
1491
- let K = null;
1492
- if (X) K = X(g);
1523
+ const oe = g.getVisibleColumns(), ce = g.getVisibleRows();
1524
+ if (oe.length === 0 || ce.length === 0) return;
1525
+ let W = null;
1526
+ if (T) W = T(g);
1493
1527
  else {
1494
- K = [];
1495
- for (let Ie = 0; Ie < ne.length; Ie++) for (let Ye = 0; Ye < ee.length; Ye++) {
1496
- const ye = { rowIndex: ne[Ie], colIndex: ee[Ye] };
1497
- if (W?.(ye)) continue;
1498
- const ve = { coords: ye, range: st(ye) };
1499
- K.push(ve);
1528
+ W = [];
1529
+ const Fe = ce.length, tt = oe.length;
1530
+ for (let $e = 0; $e < Fe; $e++) {
1531
+ const Le = ce[$e];
1532
+ for (let xt = 0; xt < tt; xt++) {
1533
+ const ct = { rowIndex: Le, colIndex: oe[xt] };
1534
+ if (J?.(ct)) continue;
1535
+ const yt = { coords: ct, range: ft(ct) };
1536
+ W.push(yt);
1537
+ }
1500
1538
  }
1501
1539
  }
1502
- const De = g.getVisibleColumnOffsets(), Qe = g.getVisibleRowOffsets(), Re = g.getScrollTopLeft(), Me = g.getFreezeTopLeft(), nt = Re.left + Me.left, Ne = Re.top + Me.top, St = Math.trunc(nt / Yt), rt = Math.trunc(Ne / Yt), G = {}, ot = (Ie, Ye, ye, ve, lt) => {
1503
- const ht = `view:${Ie.getAnchor()}:cell:${to(Ye.rowIndex, Ye.colIndex)}`, Et = ve.x, Ot = ve.y, yt = Math.trunc((nt + Et) / Yt) - St, Rt = Math.trunc((Ne + Ot) / Yt) - rt;
1504
- G[Rt] || (G[Rt] = {});
1505
- let e = G[Rt][yt];
1506
- e || (e = G[Rt][yt] = []);
1507
- let s = Y?.get(ht);
1508
- if (!s) {
1509
- const u = (nt + Et) % Yt, d = (Ne + Ot) % Yt;
1510
- s = me({ key: ht, coords: Ye, bounds: ve, zoom: se, range: ye, view: Ie, value: lt, style: { left: Z.boundPixel(u), top: Z.boundPixel(d), width: Z.boundPixel(ve.width, !0), height: Z.boundPixel(ve.height, !0) } });
1540
+ const ye = g.getVisibleColumnOffsets(), Ge = g.getVisibleRowOffsets(), Oe = g.getScrollTopLeft(), ze = g.getFreezeTopLeft(), qe = Oe.left + ze.left, Re = Oe.top + ze.top, St = Math.trunc(qe / Xt), it = Math.trunc(Re / Xt), Be = {}, be = (Fe, tt, $e, Le, xt) => {
1541
+ const ct = `view:${Fe.getAnchor()}:cell:${oo(tt.rowIndex, tt.colIndex)}`, yt = Le.x, zt = Le.y, e = Math.trunc((qe + yt) / Xt) - St, a = Math.trunc((Re + zt) / Xt) - it;
1542
+ Be[a] || (Be[a] = {});
1543
+ let u = Be[a][e];
1544
+ u || (u = Be[a][e] = []);
1545
+ let d = V?.get(ct);
1546
+ if (!d) {
1547
+ const f = (qe + yt) % Xt, I = (Re + zt) % Xt;
1548
+ d = se({ key: ct, coords: tt, bounds: Le, zoom: X, range: $e, view: Fe, value: xt, style: { left: _.boundPixel(f), top: _.boundPixel(I), width: _.boundPixel(Le.width, !0), height: _.boundPixel(Le.height, !0) } });
1511
1549
  }
1512
- N?.set(ht, s), e.push(s);
1513
- };
1514
- for (let Ie = 0; K && Ie < K.length; Ie++) {
1515
- const Ye = K[Ie], ye = Ye?.coords ?? Ye;
1516
- if (!ye) continue;
1517
- const ve = Ye?.range ?? { rowStart: ye.rowIndex, colStart: ye.colIndex, rowEnd: ye.rowIndex, colEnd: ye.colIndex }, lt = g.getVisibleRangeCoords();
1518
- if (!$.isRangesIntersect(ve, lt) && !$.isRangeWithinRange(ve, lt)) continue;
1519
- const ht = ve && !$.isSingleCell(ve);
1520
- if (!ht && W?.(ye)) continue;
1521
- const Et = ye.rowIndex, Ot = ye.colIndex, yt = Qe[Et], Rt = De[Ot];
1522
- let e = null;
1523
- yt && Rt && (e = { x: Rt.offset, y: yt.offset, width: Rt.size, height: yt.size });
1524
- const s = to(ve.rowStart, ve.colStart);
1525
- if (ht) {
1526
- if (I.has(s)) continue;
1527
- I.add(s), ve.rowEnd - ve.rowStart > 0 && y.push(ve), ve.colEnd - ve.colStart > 0 && C.push(ve);
1550
+ Q?.set(ct, d), u.push(d);
1551
+ }, lt = W.length;
1552
+ for (let Fe = 0; W && Fe < lt; Fe++) {
1553
+ const tt = W[Fe], $e = tt?.coords ?? tt;
1554
+ if (!$e) continue;
1555
+ const Le = tt?.range ?? { rowStart: $e.rowIndex, colStart: $e.colIndex, rowEnd: $e.rowIndex, colEnd: $e.colIndex }, xt = g.getVisibleRangeCoords();
1556
+ if (!F.isRangesIntersect(Le, xt) && !F.isRangeWithinRange(Le, xt)) continue;
1557
+ const ct = Le && !F.isSingleCell(Le);
1558
+ if (!ct && J?.($e)) continue;
1559
+ const yt = $e.rowIndex, zt = $e.colIndex, e = Ge[yt], a = ye[zt];
1560
+ let u = null;
1561
+ e && a && (u = { x: a.offset, y: e.offset, width: a.size, height: e.size });
1562
+ const d = oo(Le.rowStart, Le.colStart);
1563
+ if (ct) {
1564
+ if (y.has(d)) continue;
1565
+ y.add(d), Le.rowEnd - Le.rowStart > 0 && O.push(Le), Le.colEnd - Le.colStart > 0 && b.push(Le);
1528
1566
  }
1529
- if (ht && (e = io(g.getLayout(), ve)), !e) {
1530
- console.warn("no bounds for cell", s);
1567
+ if (ct && (u = so(g.getLayout(), Le)), !u) {
1568
+ console.warn("no bounds for cell", d);
1531
1569
  continue;
1532
1570
  }
1533
- const u = Ye?.value;
1534
- ot(g, ye, ve, e, u);
1571
+ const f = tt?.value;
1572
+ be(g, $e, Le, u, f);
1535
1573
  }
1536
- const Tt = nt % Yt, Mt = Ne % Yt, ke = Object.keys(G);
1537
- for (let Ie = 0; Ie < ke.length; Ie++) {
1538
- const Ye = G[ke[Ie]];
1539
- if (!Ye) continue;
1540
- const ye = Object.keys(Ye);
1541
- for (let ve = 0; ve < ye.length; ve++) {
1542
- const lt = Ye[ye[ve]];
1543
- if (!lt) continue;
1544
- const ht = parseInt(ke[Ie]), Et = parseInt(ye[ve]), Ot = ht + rt, yt = Et + St, Rt = `view:${g.getAnchor()}:segment:${yt}:${Ot}`;
1545
- v.push(Ee("div", { className: "cell-container", style: { transform: `translate(${Z.boundPixel(Et * Yt - Tt, !0)}px, ${Z.boundPixel(ht * Yt - Mt, !0)}px)`, willChange: "transform" }, children: lt }, Rt));
1574
+ const Ot = qe % Xt, me = Re % Xt, Ze = Object.keys(Be), kt = Ze.length;
1575
+ for (let Fe = 0; Fe < kt; Fe++) {
1576
+ const tt = Ze[Fe], $e = Be[tt];
1577
+ if (!$e) continue;
1578
+ const Le = Object.keys($e), xt = Le.length;
1579
+ for (let ct = 0; ct < xt; ct++) {
1580
+ const yt = Le[ct], zt = $e[yt];
1581
+ if (!zt) continue;
1582
+ const e = parseInt(tt), a = parseInt(yt), u = e + it, d = a + St, f = `view:${g.getAnchor()}:segment:${d}:${u}`;
1583
+ v.push(Ce("div", { className: "cell-container", style: { transform: `translate(${_.boundPixel(a * Xt - Ot, !0)}px, ${_.boundPixel(e * Xt - me, !0)}px)`, willChange: "transform" }, children: zt }, f));
1546
1584
  }
1547
1585
  }
1548
- }, At = Ae(() => {
1549
- const g = Xt.current, v = /* @__PURE__ */ new Map(), y = {}, C = Object.keys(Le);
1550
- for (let I = 0; I < C.length; I++) {
1551
- const Y = C[I], N = [], ee = [], ne = [];
1552
- bn(Le[Y], ne, N, ee, /* @__PURE__ */ new Set(), g, v), y[Y] = { cells: ne, rangesH: N, rangesV: ee };
1586
+ }, At = Ve(() => {
1587
+ const g = Gt.current, v = /* @__PURE__ */ new Map(), O = {}, b = Object.keys(Te), y = b.length;
1588
+ for (let V = 0; V < y; V++) {
1589
+ const Q = b[V], oe = [], ce = [], W = [];
1590
+ bn(Te[Q], W, oe, ce, /* @__PURE__ */ new Set(), g, v), O[Q] = { cells: W, rangesH: oe, rangesV: ce };
1553
1591
  }
1554
- return Xt.current = v, y;
1555
- }, [tt, c, a, ze, je, L, fe, $e, W, X, st]), Cn = (g, v, y, C, I) => {
1592
+ return Gt.current = v, O;
1593
+ }, [rt, s, c, De, Xe, z, fe, Ie, J, T, ft]), Cn = (g, v, O, b, y) => {
1556
1594
  if (g) if (v) {
1557
- const Y = `view:${g.getAnchor()}:hl:`, N = g.getVisibleRows();
1558
- if (!N || N.length === 0) return;
1559
- const ee = 0, ne = g.getBounds().width;
1560
- let K = [];
1561
- const De = I.sort($.rowFirstRangeComparator), Qe = g.getVisibleRangeCoords();
1562
- for (let Re = 0; Re < N.length && N[Re] <= Qe.rowEnd; Re++) {
1563
- const Me = N[Re];
1564
- if (Me < Qe.rowStart) continue;
1565
- let nt = !1;
1566
- for (; De.length > 0 && De[0].rowStart <= Me; ) {
1567
- const G = De.shift();
1568
- G.rowEnd > Me && (K.push(G), nt = !0);
1595
+ const V = `view:${g.getAnchor()}:hl:`, Q = g.getVisibleRows();
1596
+ if (!Q || Q.length === 0) return;
1597
+ const oe = 0, ce = g.getBounds().width;
1598
+ let W = [];
1599
+ const ye = y.sort(F.rowFirstRangeComparator), Ge = g.getVisibleRangeCoords();
1600
+ for (let Oe = 0; Oe < Q.length && Q[Oe] <= Ge.rowEnd; Oe++) {
1601
+ const ze = Q[Oe];
1602
+ if (ze < Ge.rowStart) continue;
1603
+ let qe = !1;
1604
+ for (; ye.length > 0 && ye[0].rowStart <= ze; ) {
1605
+ const be = ye.shift();
1606
+ be.rowEnd > ze && (W.push(be), qe = !0);
1569
1607
  }
1570
- nt && (K = K.sort($.columnFirstRangeComparator));
1571
- const Ne = g.getLayout(), St = Ne.getRowOffset(Me + 1);
1572
- let rt = ee;
1573
- for (let G = 0; G < K.length + 1; G++) {
1574
- let ot = rt, Tt = ne;
1575
- const Mt = K[G];
1576
- G < K.length && (Tt = Math.min(ne, Ne.getColOffset(Mt.colStart)), rt = Math.min(ne, Ne.getColOffset(Mt.colEnd + 1))), C.push(wo("path", { d: `M ${Z.boundPixel(ot)} ${Z.boundPixel(St, !1, y)} L ${Z.boundPixel(Tt)} ${Z.boundPixel(St, !1, y)}`, stroke: ce, strokeWidth: 1, vectorEffect: "non-scaling-stroke", ...J, key: Y + Me + ":" + G }));
1608
+ qe && (W = W.sort(F.columnFirstRangeComparator));
1609
+ const Re = g.getLayout(), St = Re.getRowOffset(ze + 1);
1610
+ let it = oe;
1611
+ const Be = W.length;
1612
+ for (let be = 0; be < Be + 1; be++) {
1613
+ let lt = it, Ot = ce;
1614
+ const me = W[be];
1615
+ be < Be && (Ot = Math.min(ce, Re.getColOffset(me.colStart)), it = Math.min(ce, Re.getColOffset(me.colEnd + 1))), b.push(xo("path", { d: `M ${_.boundPixel(lt)} ${_.boundPixel(St, !1, O)} L ${_.boundPixel(Ot)} ${_.boundPixel(St, !1, O)}`, stroke: Y, strokeWidth: 1, vectorEffect: "non-scaling-stroke", ...j, key: V + ze + ":" + be }));
1577
1616
  }
1578
- for (let G = K.length - 1; G >= 0; G--) K[G].rowEnd <= N[Re + 1] && K.splice(G, 1);
1617
+ for (let be = Be - 1; be >= 0; be--) W[be].rowEnd <= Q[Oe + 1] && W.splice(be, 1);
1579
1618
  }
1580
1619
  } else {
1581
- const Y = `view:${g.getAnchor()}:vl:`, N = g.getVisibleColumns();
1582
- if (!N || N.length === 0) return;
1583
- const ee = 0, ne = g.getBounds().height;
1584
- let K = [];
1585
- const De = I.sort($.columnFirstRangeComparator), Qe = g.getVisibleRangeCoords();
1586
- for (let Re = 0; Re < N.length && N[Re] <= Qe.colEnd; Re++) {
1587
- const Me = N[Re];
1588
- if (Me < Qe.colStart) continue;
1589
- let nt = !1;
1590
- for (; De.length > 0 && De[0].colStart <= Me; ) {
1591
- const G = De.shift();
1592
- G.colEnd > Me && (K.push(G), nt = !0);
1620
+ const V = `view:${g.getAnchor()}:vl:`, Q = g.getVisibleColumns();
1621
+ if (!Q || Q.length === 0) return;
1622
+ const oe = 0, ce = g.getBounds().height;
1623
+ let W = [];
1624
+ const ye = y.sort(F.columnFirstRangeComparator), Ge = g.getVisibleRangeCoords(), Oe = Q.length;
1625
+ for (let ze = 0; ze < Oe && Q[ze] <= Ge.colEnd; ze++) {
1626
+ const qe = Q[ze];
1627
+ if (qe < Ge.colStart) continue;
1628
+ let Re = !1;
1629
+ for (; ye.length > 0 && ye[0].colStart <= qe; ) {
1630
+ const lt = ye.shift();
1631
+ lt.colEnd > qe && (W.push(lt), Re = !0);
1593
1632
  }
1594
- nt && (K = K.sort($.rowFirstRangeComparator));
1595
- const Ne = g.getLayout(), St = Ne.getColOffset(Me + 1);
1596
- let rt = ee;
1597
- for (let G = 0; G < K.length + 1; G++) {
1598
- let ot = rt, Tt = ne;
1599
- const Mt = K[G];
1600
- G < K.length && (Tt = Math.min(ne, Ne.getRowOffset(Mt.rowStart)), rt = Math.min(ne, Ne.getRowOffset(Mt.rowEnd + 1)));
1601
- let ke = ce;
1602
- C.push(Ee("path", { d: `M ${Z.boundPixel(St, !1, y)} ${Z.boundPixel(ot)} L ${Z.boundPixel(St, !1, y)} ${Z.boundPixel(Tt)}`, stroke: ke, strokeWidth: 1, vectorEffect: "non-scaling-stroke", ...oe }, Y + Me + ":" + G));
1633
+ Re && (W = W.sort(F.rowFirstRangeComparator));
1634
+ const St = g.getLayout(), it = St.getColOffset(qe + 1);
1635
+ let Be = oe;
1636
+ const be = W.length;
1637
+ for (let lt = 0; lt < be + 1; lt++) {
1638
+ let Ot = Be, me = ce;
1639
+ const Ze = W[lt];
1640
+ lt < be && (me = Math.min(ce, St.getRowOffset(Ze.rowStart)), Be = Math.min(ce, St.getRowOffset(Ze.rowEnd + 1)));
1641
+ let kt = Y;
1642
+ b.push(Ce("path", { d: `M ${_.boundPixel(it, !1, O)} ${_.boundPixel(Ot)} L ${_.boundPixel(it, !1, O)} ${_.boundPixel(me)}`, stroke: kt, strokeWidth: 1, vectorEffect: "non-scaling-stroke", ...ee }, V + qe + ":" + lt));
1603
1643
  }
1604
- for (let G = K.length - 1; G >= 0; G--) K[G].colEnd <= N[Re + 1] && K.splice(G, 1);
1644
+ for (let lt = be - 1; lt >= 0; lt--) W[lt].colEnd <= Q[ze + 1] && W.splice(lt, 1);
1605
1645
  }
1606
1646
  }
1607
1647
  }, xn = (g) => {
1608
1648
  if (!At) return;
1609
- const v = {};
1610
- for (let y = 0; y < _t.length; y++) {
1611
- const C = _t[y], I = Le[C], Y = [];
1612
- Cn(I, g, 0, Y, g ? At[C].rangesH : At[C].rangesV);
1613
- const N = I.getRangeCoordsBounds(), ee = Math.ceil(N.width), ne = Math.ceil(N.height);
1614
- v[C] = Ee("svg", { width: `${ee}`, height: `${ne}`, viewBox: `0 0 ${ee} ${ne}`, preserveAspectRatio: "none", shapeRendering: "crispEdges", style: { position: "absolute" }, children: Y });
1649
+ const v = {}, O = Jt.length;
1650
+ for (let b = 0; b < O; b++) {
1651
+ const y = Jt[b], V = Te[y], Q = [];
1652
+ Cn(V, g, 0, Q, g ? At[y].rangesH : At[y].rangesV);
1653
+ const oe = V.getRangeCoordsBounds(), ce = Math.ceil(oe.width), W = Math.ceil(oe.height);
1654
+ v[y] = Ce("svg", { width: `${ce}`, height: `${W}`, viewBox: `0 0 ${ce} ${W}`, preserveAspectRatio: "none", shapeRendering: "crispEdges", style: { position: "absolute" }, children: Q });
1615
1655
  }
1616
1656
  return v;
1617
- }, In = Ae(() => L === !0 || L?.horizontal === !0 ? xn(!0) : null, [tt, L, ze, Q, k, ce, J, c, a, He, Pt, At]), En = Ae(() => L === !0 || L?.vertical === !0 ? xn(!1) : null, [tt, L, je, Q, k, ce, oe, c, a, Be, Ze, At]), Vn = Ae(() => It.left === 0 ? null : Ee(co, { linePoints: [0, 0, 0, Be + 1], bounds: { x: It.left, y: 0, width: 1, height: Be + 1 }, ...Se }), [tt, It.left, Be, Se]), Wn = Ae(() => It.top === 0 ? null : Ee(co, { linePoints: [0, 0, He + 1, 0], bounds: { x: 0, y: It.top, width: He + 1, height: 1 }, ...A }), [tt, It.top, He, A]), pn = Ae(() => {
1618
- const g = [], v = (y) => {
1619
- if (!y || !Le[y]) return;
1620
- const C = Le[y].getBounds();
1621
- return Zt("div", { style: { position: "absolute", pointerEvents: "none", left: C.x, top: C.y, width: C.width, height: C.height, clip: `rect(0, ${C.width + 1}px, ${C.height + 1}px, 0)` }, className: `view view-${y}`, children: [In?.[y], En?.[y], At?.[y].cells] }, `view:${y}`);
1622
- };
1623
- for (let y = 0; y < _t.length; y++) g.push(v(_t[y]));
1624
- return Ee(_n, { children: g });
1625
- }, [Le, In, En, At]), Un = Ae(() => {
1657
+ }, In = Ve(() => z === !0 || z?.horizontal === !0 ? xn(!0) : null, [rt, z, De, U, R, Y, j, s, c, Ke, Dt, At]), En = Ve(() => z === !0 || z?.vertical === !0 ? xn(!1) : null, [rt, z, Xe, U, R, Y, ee, s, c, Ae, et, At]), Wn = Ve(() => Rt.left === 0 ? null : Ce(ao, { linePoints: [0, 0, 0, Ae + 1], bounds: { x: Rt.left, y: 0, width: 1, height: Ae + 1 }, ...he }), [rt, Rt.left, Ae, he]), Un = Ve(() => Rt.top === 0 ? null : Ce(ao, { linePoints: [0, 0, Ke + 1, 0], bounds: { x: 0, y: Rt.top, width: Ke + 1, height: 1 }, ...M }), [rt, Rt.top, Ke, M]), pn = Ve(() => {
1658
+ const g = [], v = (b) => {
1659
+ if (!b || !Te[b]) return;
1660
+ const y = Te[b].getBounds();
1661
+ return Qt("div", { style: { position: "absolute", pointerEvents: "none", left: y.x, top: y.y, width: y.width, height: y.height, clip: `rect(0, ${y.width + 1}px, ${y.height + 1}px, 0)` }, className: `view view-${b}`, children: [In?.[b], En?.[b], At?.[b].cells] }, `view:${b}`);
1662
+ }, O = Jt.length;
1663
+ for (let b = 0; b < O; b++) g.push(v(Jt[b]));
1664
+ return Ce(Qn, { children: g });
1665
+ }, [Te, In, En, At]), Hn = Ve(() => {
1626
1666
  if (!n) return;
1627
- const g = (N, ee, ne, K) => {
1628
- if (!K || K.length === 0) return;
1629
- const De = [];
1630
- for (let Qe = 0; Qe < K.length; Qe++) {
1631
- const Re = K[Qe];
1632
- let Me = N?.get(Re);
1633
- Me !== qn && (Me = Re(ne) ?? qn), ee.set(Re, Me), Me && Me !== qn && De.push(Me);
1667
+ const g = (oe, ce, W, ye) => {
1668
+ if (!ye || ye.length === 0) return;
1669
+ const Ge = [], Oe = ye.length;
1670
+ for (let ze = 0; ze < Oe; ze++) {
1671
+ const qe = ye[ze];
1672
+ let Re = oe?.get(qe);
1673
+ Re !== Yn && (Re = qe(W) ?? Yn), ce.set(qe, Re), Re && Re !== Yn && Ge.push(Re);
1634
1674
  }
1635
- return De;
1636
- }, v = (N, ee, ne) => {
1637
- if (!ne) return;
1638
- const K = ne.getBounds(), De = ne.getInsets(), Qe = ne.getAnchor();
1639
- return Zt("div", { className: rn("view", `view-${Qe}`, ao.view), style: { position: "absolute", pointerEvents: "none", left: K.x - De.left, top: K.y - De.top, width: K.width - (De.left + De.right), height: K.height - (De.top + De.bottom), clipPath: p ? "inset(-2px)" : "inset(0px)" }, children: [g(N, ee, ne, Ce), Fn?.[Qe].overlays] }, `view:${Qe}`);
1640
- }, y = ut.current, C = {}, I = [], Y = Object.keys(Le);
1641
- for (let N = 0; N < Y.length; N++) {
1642
- const ee = Y[N], ne = y?.[ee], K = C[ee] = /* @__PURE__ */ new Map();
1643
- I.push(v(ne, K, Le[ee]));
1675
+ return Ge;
1676
+ }, v = (oe, ce, W) => {
1677
+ if (!W) return;
1678
+ const ye = W.getBounds(), Ge = W.getInsets(), Oe = W.getAnchor();
1679
+ return Qt("div", { className: rn("view", `view-${Oe}`, uo.view), style: { position: "absolute", pointerEvents: "none", left: ye.x - Ge.left, top: ye.y - Ge.top, width: ye.width - (Ge.left + Ge.right), height: ye.height - (Ge.top + Ge.bottom), clipPath: p ? "inset(-2px)" : "inset(0px)" }, children: [g(oe, ce, W, Se), Vn?.[Oe].overlays] }, `view:${Oe}`);
1680
+ }, O = gt.current, b = {}, y = [], V = Object.keys(Te), Q = V.length;
1681
+ for (let oe = 0; oe < Q; oe++) {
1682
+ const ce = V[oe], W = O?.[ce], ye = b[ce] = /* @__PURE__ */ new Map();
1683
+ y.push(v(W, ye, Te[ce]));
1644
1684
  }
1645
- return ut.current = C, I;
1646
- }, [tt, Le, p, Ce]), Hn = Ae(() => {
1647
- const { style: g, ...v } = Ke ?? {};
1648
- return Ee("div", { style: { width: He, height: Be, ...g }, className: "sheetxl-stage", tabIndex: 0, ref: Ue, ...v, ...en, children: qe ? qe(pn) : pn });
1649
- }, [He, Be, pn, Ke, qe]), Rn = ue(!1);
1650
- return bt(() => {
1685
+ return gt.current = b, y;
1686
+ }, [rt, Te, p, Se]), Nn = Ve(() => {
1687
+ const { style: g, ...v } = je ?? {};
1688
+ return Ce("div", { style: { width: Ke, height: Ae, ...g }, className: "sheetxl-stage", tabIndex: 0, ref: Ne, ...v, ...Wt, children: Ye ? Ye(pn) : pn });
1689
+ }, [Ke, Ae, pn, je, Ye]), Rn = ie(!1);
1690
+ return pt(() => {
1651
1691
  !Rn.current && At && (Rn.current = !0, xe?.(on.current));
1652
- }, [At]), Zt("div", { className: rn("sheetxl-grid", ao["sheetxl-grid"]), style: { overflow: "visible", cursor: te, maxWidth: He, maxHeight: Be, width: He, height: Be, ...fe }, ref: on, children: [Hn, Zt("div", { className: rn("sheetxl-overlays"), ref: et, ...O, children: [Un, Vn, Wn] })] });
1692
+ }, [At]), Qt("div", { className: rn("sheetxl-grid", uo["sheetxl-grid"]), style: { overflow: "visible", cursor: Z, maxWidth: Ke, maxHeight: Ae, width: Ke, height: Ae, ...fe }, ref: on, children: [Nn, Qt("div", { className: rn("sheetxl-overlays"), ref: ot, ...B, children: [Hn, Wn, Un] })] });
1653
1693
  }));
1654
- Eo.displayName = "BaseGrid";
1655
- const Ro = Nt(Jt((t, n) => {
1656
- const { width: o, height: r, style: c = {}, className: a, ...i } = t, [l, { width: h, height: T }] = Co();
1657
- return Ee("div", { className: a, style: { ...c }, children: Ee("div", { style: { position: "relative", top: "0px", left: "0px", width: "100%", height: "100%", maxWidth: "100%", maxHeight: "100%", boxSizing: "content-box" }, ref: l, children: Ee(Eo, { ref: n, width: o ?? h, height: r ?? T, ...i }) }) });
1694
+ Ro.displayName = "BaseGrid";
1695
+ const Mo = Kt(en((t, n) => {
1696
+ const { width: o, height: r, style: s = {}, className: c, ...i } = t, [l, { width: h, height: k }] = yo();
1697
+ return Ce("div", { className: c, style: { ...s }, children: Ce("div", { style: { position: "relative", top: "0px", left: "0px", width: "100%", height: "100%", maxWidth: "100%", maxHeight: "100%", boxSizing: "content-box" }, ref: l, children: Ce(Ro, { ref: n, width: o ?? h, height: r ?? k, ...i }) }) });
1658
1698
  }));
1659
- Ro.displayName = "Grid";
1660
- const tr = Nt(Jt((t, n) => {
1661
- const { showVerticalScrollbar: o, showHorizontalScrollbar: r, createHorizontalScrollbar: c, createVerticalScrollbar: a, createScrollCorner: i, viewport: l, onScrollViewport: h, style: T = {}, className: B, onScroll: R, ...P } = t, [L, ce] = gt(null), J = ue(null), oe = ue(null);
1662
- Tn(!l), Lo(n, () => oe.current && J.current ? Object.assign(oe.current, J.current) : null);
1663
- const $e = z((te) => {
1664
- oe.current?.scrollTo(te), h?.(te);
1699
+ Mo.displayName = "Grid";
1700
+ const cr = Kt(en((t, n) => {
1701
+ const { showVerticalScrollbar: o, showHorizontalScrollbar: r, createHorizontalScrollbar: s, createVerticalScrollbar: c, createScrollCorner: i, viewport: l, onScrollViewport: h, style: k = {}, className: A, onScroll: E, ...P } = t, [z, Y] = dt(null), j = ie(null), ee = ie(null);
1702
+ Tn(!l), $o(n, () => ee.current && j.current ? Object.assign(ee.current, j.current) : null);
1703
+ const Ie = $((Z) => {
1704
+ ee.current?.scrollTo(Z), h?.(Z);
1665
1705
  }, []);
1666
- return Ee(Oo, { className: B, style: T, ref: J, showVerticalScrollbar: o, showHorizontalScrollbar: r, createHorizontalScrollbar: c, createVerticalScrollbar: a, createScrollCorner: i, viewport: L, onScrollViewport: $e, children: Ee(Ro, { style: { width: "100%", height: "100%" }, ...P, onViewportChange: (te) => ce(te), ref: oe }) });
1706
+ return Ce(Lo, { className: A, style: k, ref: j, showVerticalScrollbar: o, showHorizontalScrollbar: r, createHorizontalScrollbar: s, createVerticalScrollbar: c, createScrollCorner: i, viewport: z, onScrollViewport: Ie, children: Ce(Mo, { style: { width: "100%", height: "100%" }, ...P, onViewportChange: (Z) => Y(Z), ref: ee }) });
1667
1707
  }));
1668
- tr.displayName = "ScrollableGrid";
1669
- const ho = () => !1, nr = Nt((t) => {
1670
- const { index: n, value: o, zoom: r, zoomScale: c = 100, headerText: a = (Ce) => `${Ce}`, headerStyle: i, headerStyleSelect: l = i, headerStyleSelectAll: h = l, headerStyleHover: T = h, verticalPadding: B = 0, horizontalPadding: R = 0, isSelected: P = ho, isSelectedAll: L = ho, coords: ce, bounds: J, range: oe, orientation: $e, view: te, style: k, ...Q } = t, Se = c / 100, A = ue(null), [me, Ve] = gt(!1), Te = P?.(n) || !1, We = L?.(n) ? h : Te ? l : i;
1671
- let ge = We;
1672
- if (me) {
1673
- let Ce = T;
1674
- typeof T == "function" && (Ce = T(We)), ge = Ht.mergeContentful(We, Ce);
1708
+ cr.displayName = "ScrollableGrid";
1709
+ const go = () => !1, sr = Kt((t) => {
1710
+ const { index: n, value: o, zoom: r, zoomScale: s = 100, headerText: c = (Se) => `${Se}`, headerStyle: i, headerStyleSelect: l = i, headerStyleSelectAll: h = l, headerStyleHover: k = h, verticalPadding: A = 0, horizontalPadding: E = 0, isSelected: P = go, isSelectedAll: z = go, coords: Y, bounds: j, range: ee, orientation: Ie, view: Z, style: R, ...U } = t, he = s / 100, M = ie(null), [se, Ue] = dt(!1), ke = P?.(n) || !1, He = z?.(n) ? h : ke ? l : i;
1711
+ let ge = He;
1712
+ if (se) {
1713
+ let Se = k;
1714
+ typeof k == "function" && (Se = k(He)), ge = Nt.mergeContentful(He, Se);
1675
1715
  }
1676
- return Ee("div", { ref: A, style: { background: ge.fill, color: ge.text?.fill, fontFamily: ge.text?.fontFamily ?? i.text?.fontFamily, fontSize: 96 * (ge.text?.fontSize ?? 11) / 72 * Se, fontStyle: ge.text?.fontStyle, fontWeight: ge.text?.fontWeight, lineHeight: 1.2, display: "flex", justifyContent: "center", alignItems: "end", pointerEvents: "auto", paddingBottom: `${Se}px`, ...k, left: k.left - ($e === Ut.Column ? 1 : 0), top: k.top - ($e === Ut.Row ? 1 : 0), width: k.width + 1, height: k.height + 1, overflow: "hidden" }, ...Q, onMouseMove: (Ce) => {
1677
- Z.detectIt().primaryInput !== "touch" && Ce.buttons === 0 && Ve(!0);
1678
- }, onMouseOut: (Ce) => {
1679
- Ve(!1);
1680
- }, children: a(n) });
1716
+ return Ce("div", { ref: M, style: { background: ge.fill, color: ge.text?.fill, fontFamily: ge.text?.fontFamily ?? i.text?.fontFamily, fontSize: 96 * (ge.text?.fontSize ?? 11) / 72 * he, fontStyle: ge.text?.fontStyle, fontWeight: ge.text?.fontWeight, lineHeight: 1.2, display: "flex", justifyContent: "center", alignItems: "end", pointerEvents: "auto", paddingBottom: `${he}px`, ...R, left: R.left - (Ie === Ht.Column ? 1 : 0), top: R.top - (Ie === Ht.Row ? 1 : 0), width: R.width + 1, height: R.height + 1, overflow: "hidden" }, ...U, onMouseMove: (Se) => {
1717
+ _.detectIt().primaryInput !== "touch" && Se.buttons === 0 && Ue(!0);
1718
+ }, onMouseOut: (Se) => {
1719
+ Ue(!1);
1720
+ }, children: c(n) });
1681
1721
  });
1682
- nr.displayName = "HeaderRenderer";
1683
- const Mo = "ew-resize", ko = "ns-resize", or = Nt(Jt((t, n) => {
1684
- const { orientation: o, view: r, index: c, className: a, style: i, disabled: l = !1, disabledResize: h = !1, isNextHidden: T, isHidden: B, isSelected: R, isSelectedAll: P, showTouchDivider: L, headerStyle: ce, headerStyleSelect: J, headerStyleSelectAll: oe, headerStyleHover: $e, bounds: te, onPointerDown: k, onAutoFit: Q, ...Se } = t, A = o === Ut.Column;
1685
- let me = ce;
1686
- R && J && (me = J), P && oe && (me = oe);
1687
- const Ve = Z.detectIt().primaryInput === "touch";
1688
- let Te = A ? 14 : 8, We = Te / 2, ge = 0;
1689
- T && (ge = -2), B && (ge = 2), B && (Te = Te / 2 + ge, We = 2 * ge);
1690
- let Ce = me.dividerStrokeFill ?? me.strokeFill;
1691
- return !(R || P) && ge === 0 && (Ce = `linear-gradient(${A ? 180 : 90}deg, ${me.fill}, ${Ce} 55%, ${Ce} 100%)`), Zt("div", { className: rn("header-divider", { disabled: l }, a, `index-${c}`), ref: n, onPointerDown: Ve ? void 0 : k, onDoubleClick: Ve ? void 0 : () => Q?.(), style: { top: (A ? 0 : -Te / 2 + (ge - 1)) + "px", left: (A ? -Te / 2 + (ge - 1) : 0) + "px", width: A ? Te : "calc(100% + 1px)", height: A ? "calc(100% + 1px)" : Te, position: "absolute", overflow: "visible", pointerEvents: "all", cursor: l || h || Ve ? void 0 : A ? Mo : ko, ...i }, ...Se, children: [Ee("div", { style: { position: "relative", top: `${A ? 0 : We}px`, left: `${A ? We : 0}px`, width: A ? 1 : "100%", height: A ? "100%" : 1, background: Ce }, onDoubleClick: () => Q?.() }), L && Ve ? Ee("div", { style: { position: "absolute", cursor: "grab", zIndex: 1, borderRadius: "4px", right: A ? "-6px" : "2px", bottom: A ? "2px" : "-9px", height: "24px", width: A ? "24px" : "18px", maxHeight: A ? "calc(100% - 4px)" : void 0, maxWidth: A ? void 0 : "calc(100% - 4px)", background: me.fill, border: `${oe.edgeStrokeFill} solid 1px`, boxShadow: `0.5px 0.5px 0px 0px ${ce.text.fill}`, display: "flex", alignItems: "center", justifyContent: "center" }, onPointerDown: k, children: Ee("div", { style: { width: "6.4px", height: "12px", backgroundImage: `url("data:image/svg+xml,%3Csvg width='6.4' height='12' viewBox='0 0 9.6 16' version='1.1' fill='${encodeURIComponent(J.text.fill)}' xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg'%3E%3Cpath d='M 9.60008,14.40009 C 9.60008,15.28374 8.88368,16 8.00003,16 7.11639,16 6.40012,15.28374 6.40012,14.40009 c 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40012 c 0,0.88364 -0.7164,1.60004 -1.60005,1.60004 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60004 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40006 c 0,0.88365 -0.7164,1.60005 -1.60005,1.60005 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60005 C 6.40012,0.71626 7.11639,0 8.00003,0 8.88368,0 9.60008,0.71626 9.60008,1.59991 M 3.19996,14.40009 C 3.19996,15.28374 2.48369,16 1.60005,16 0.7164,16 0,15.28374 0,14.40009 c 0,-0.88365 0.7164,-1.60005 1.60005,-1.60005 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40012 c 0,0.88364 -0.71627,1.60004 -1.59991,1.60004 C 0.7164,9.60001 0,8.88361 0,7.99997 0,7.11632 0.7164,6.39992 1.60005,6.39992 c 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40006 c 0,0.88365 -0.71627,1.60005 -1.59991,1.60005 C 0.7164,3.19996 0,2.48356 0,1.59991 0,0.71626 0.7164,0 1.60005,0 2.48369,0 3.19996,0.71626 3.19996,1.59991' /%3E%3C/svg%3E%0A")`, backgroundRepeat: "no-repeat", backgroundPosition: "center", transform: A ? void 0 : "rotate(90deg)" } }) }) : null] });
1692
- })), rr = (t, n) => Ee(or, { ...t, ref: n }), pr = Nt(Jt((t, n) => {
1693
- const { orientation: o, view: r, index: c, disabled: a = !1, disabledResize: i = !1, resizeThreshold: l = 1, dividerRenderer: h = rr, onDividerMouseDown: T, onDividerResizeStart: B, onDividerResize: R, onDividerResizeEnd: P, onDividerMouseUp: L, onDividerAutoFit: ce, onPointerDown: J, ...oe } = t, $e = D(J, [J]), te = D(ce, [ce]), k = o === Ut.Column;
1694
- let Q = k ? r.getVisibleColumns() : r.getVisibleRows(), Se = null;
1695
- Q.length > 0 && (k ? Se = r.getRangeCoordsBounds({ rowStart: 0, rowEnd: 0, colStart: Q[0], colEnd: Q[Q.length - 1] }) : r.getRangeCoordsBounds({ rowStart: Q[0], rowEnd: Q[Q.length - 1], colStart: 0, colEnd: 0 }), Se = r.toClipBounds(Se, Vt));
1696
- const A = ue(null), [me, Ve] = gt(null), Te = (F, re) => k ? F.clientX - re.clientX : F.clientY - re.clientY, We = r.getLayout(), ge = k ? We.getColOffset(c + 1) : We.getRowOffset(c + 1), Ce = un({ processTouch: !0, onPointerDown: (F) => {
1697
- if ($e?.(F), !a && !i) {
1698
- const re = k ? We.getColOffset(c) : We.getRowOffset(c), W = ge - re;
1699
- A.current = { isResizing: !1, startSize: W, index: c, view: r, orientation: o, onDividerMouseDown: T, onDividerResizeStart: B, onDividerResize: R, onDividerResizeEnd: P, onDividerMouseUp: L }, Ve(A.current), T?.(c, W);
1722
+ sr.displayName = "HeaderRenderer";
1723
+ const ko = "ew-resize", Po = "ns-resize", ar = Kt(en((t, n) => {
1724
+ const { orientation: o, view: r, index: s, className: c, style: i, disabled: l = !1, disabledResize: h = !1, isNextHidden: k, isHidden: A, isSelected: E, isSelectedAll: P, showTouchDivider: z, headerStyle: Y, headerStyleSelect: j, headerStyleSelectAll: ee, headerStyleHover: Ie, bounds: Z, onPointerDown: R, onAutoFit: U, ...he } = t, M = o === Ht.Column;
1725
+ let se = Y;
1726
+ E && j && (se = j), P && ee && (se = ee);
1727
+ const Ue = _.detectIt().primaryInput === "touch";
1728
+ let ke = M ? 14 : 8, He = ke / 2, ge = 0;
1729
+ k && (ge = -2), A && (ge = 2), A && (ke = ke / 2 + ge, He = 2 * ge);
1730
+ let Se = se.dividerStrokeFill ?? se.strokeFill;
1731
+ return !(E || P) && ge === 0 && (Se = `linear-gradient(${M ? 180 : 90}deg, ${se.fill}, ${Se} 55%, ${Se} 100%)`), Qt("div", { className: rn("header-divider", { disabled: l }, c, `index-${s}`), ref: n, onPointerDown: Ue ? void 0 : R, onDoubleClick: Ue ? void 0 : () => U?.(), style: { top: (M ? 0 : -ke / 2 + (ge - 1)) + "px", left: (M ? -ke / 2 + (ge - 1) : 0) + "px", width: M ? ke : "calc(100% + 1px)", height: M ? "calc(100% + 1px)" : ke, position: "absolute", overflow: "visible", pointerEvents: "all", cursor: l || h || Ue ? void 0 : M ? ko : Po, ...i }, ...he, children: [Ce("div", { style: { position: "relative", top: `${M ? 0 : He}px`, left: `${M ? He : 0}px`, width: M ? 1 : "100%", height: M ? "100%" : 1, background: Se }, onDoubleClick: () => U?.() }), z && Ue ? Ce("div", { style: { position: "absolute", cursor: "grab", zIndex: 1, borderRadius: "4px", right: M ? "-6px" : "2px", bottom: M ? "2px" : "-9px", height: "24px", width: M ? "24px" : "18px", maxHeight: M ? "calc(100% - 4px)" : void 0, maxWidth: M ? void 0 : "calc(100% - 4px)", background: se.fill, border: `${ee.edgeStrokeFill} solid 1px`, boxShadow: `0.5px 0.5px 0px 0px ${Y.text.fill}`, display: "flex", alignItems: "center", justifyContent: "center" }, onPointerDown: R, children: Ce("div", { style: { width: "6.4px", height: "12px", backgroundImage: `url("data:image/svg+xml,%3Csvg width='6.4' height='12' viewBox='0 0 9.6 16' version='1.1' fill='${encodeURIComponent(j.text.fill)}' xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg'%3E%3Cpath d='M 9.60008,14.40009 C 9.60008,15.28374 8.88368,16 8.00003,16 7.11639,16 6.40012,15.28374 6.40012,14.40009 c 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40012 c 0,0.88364 -0.7164,1.60004 -1.60005,1.60004 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60004 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40006 c 0,0.88365 -0.7164,1.60005 -1.60005,1.60005 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60005 C 6.40012,0.71626 7.11639,0 8.00003,0 8.88368,0 9.60008,0.71626 9.60008,1.59991 M 3.19996,14.40009 C 3.19996,15.28374 2.48369,16 1.60005,16 0.7164,16 0,15.28374 0,14.40009 c 0,-0.88365 0.7164,-1.60005 1.60005,-1.60005 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40012 c 0,0.88364 -0.71627,1.60004 -1.59991,1.60004 C 0.7164,9.60001 0,8.88361 0,7.99997 0,7.11632 0.7164,6.39992 1.60005,6.39992 c 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40006 c 0,0.88365 -0.71627,1.60005 -1.59991,1.60005 C 0.7164,3.19996 0,2.48356 0,1.59991 0,0.71626 0.7164,0 1.60005,0 2.48369,0 3.19996,0.71626 3.19996,1.59991' /%3E%3C/svg%3E%0A")`, backgroundRepeat: "no-repeat", backgroundPosition: "center", transform: M ? void 0 : "rotate(90deg)" } }) }) : null] });
1732
+ })), dr = (t, n) => Ce(ar, { ...t, ref: n }), Cr = Kt(en((t, n) => {
1733
+ const { orientation: o, view: r, index: s, disabled: c = !1, disabledResize: i = !1, resizeThreshold: l = 1, dividerRenderer: h = dr, onDividerMouseDown: k, onDividerResizeStart: A, onDividerResize: E, onDividerResizeEnd: P, onDividerMouseUp: z, onDividerAutoFit: Y, onPointerDown: j, ...ee } = t, Ie = L(j, [j]), Z = L(Y, [Y]), R = o === Ht.Column;
1734
+ let U = R ? r.getVisibleColumns() : r.getVisibleRows(), he = null;
1735
+ U.length > 0 && (R ? he = r.getRangeCoordsBounds({ rowStart: 0, rowEnd: 0, colStart: U[0], colEnd: U[U.length - 1] }) : r.getRangeCoordsBounds({ rowStart: U[0], rowEnd: U[U.length - 1], colStart: 0, colEnd: 0 }), he = r.toClipBounds(he, Vt));
1736
+ const M = ie(null), [se, Ue] = dt(null), ke = (ne, Ee) => R ? ne.clientX - Ee.clientX : ne.clientY - Ee.clientY, He = r.getLayout(), ge = R ? He.getColOffset(s + 1) : He.getRowOffset(s + 1), Se = un({ processTouch: !0, onPointerDown: (ne) => {
1737
+ if (Ie?.(ne), !c && !i) {
1738
+ const Ee = R ? He.getColOffset(s) : He.getRowOffset(s), J = ge - Ee;
1739
+ M.current = { isResizing: !1, startSize: J, index: s, view: r, orientation: o, onDividerMouseDown: k, onDividerResizeStart: A, onDividerResize: E, onDividerResizeEnd: P, onDividerMouseUp: z }, Ue(M.current), k?.(s, J);
1700
1740
  }
1701
- F.stopPropagation(), F.preventDefault();
1702
- }, onPointerUp: (F, re, W) => {
1703
- if (!A.current) return;
1704
- A.current.isResizing && A.current.onDividerResizeEnd?.(A.current.index, Math.max(0, A.current.startSize + Te(F, W)), A.current.startSize);
1705
- const X = A.current;
1706
- A.current = null, Ve(A.current), X.onDividerMouseUp?.(X.index);
1707
- }, onPointerMoveOrWait: (F, re, W) => {
1708
- if (!A.current) return;
1709
- const X = Te(F, W);
1710
- A.current.isResizing ? A.current.onDividerResize?.(A.current.index, Math.max(0, A.current.startSize + X), A.current.startSize) : Math.abs(X) > Math.max(1, l) && (A.current = { ...A.current, isResizing: !0 }, Ve(A.current), A.current.onDividerResizeStart?.(A.current.index, Math.max(0, A.current.startSize + X))), F.stopPropagation(), F.preventDefault();
1711
- } }), O = D(() => {
1712
- te?.(c);
1713
- }, [c]);
1714
- if (!Se) return;
1715
- const p = h({ bounds: Se, orientation: o, view: r, index: c, disabled: a, disabledResize: i, onAutoFit: O, onPointerDown: Ce, ...oe }, n);
1741
+ ne.stopPropagation(), ne.preventDefault();
1742
+ }, onPointerUp: (ne, Ee, J) => {
1743
+ if (!M.current) return;
1744
+ M.current.isResizing && M.current.onDividerResizeEnd?.(M.current.index, Math.max(0, M.current.startSize + ke(ne, J)), M.current.startSize);
1745
+ const T = M.current;
1746
+ M.current = null, Ue(M.current), T.onDividerMouseUp?.(T.index);
1747
+ }, onPointerMoveOrWait: (ne, Ee, J) => {
1748
+ if (!M.current) return;
1749
+ const T = ke(ne, J);
1750
+ M.current.isResizing ? M.current.onDividerResize?.(M.current.index, Math.max(0, M.current.startSize + T), M.current.startSize) : Math.abs(T) > Math.max(1, l) && (M.current = { ...M.current, isResizing: !0 }, Ue(M.current), M.current.onDividerResizeStart?.(M.current.index, Math.max(0, M.current.startSize + T))), ne.stopPropagation(), ne.preventDefault();
1751
+ } }), B = L(() => {
1752
+ Z?.(s);
1753
+ }, [s]);
1754
+ if (!he) return;
1755
+ const p = h({ bounds: he, orientation: o, view: r, index: s, disabled: c, disabledResize: i, onAutoFit: B, onPointerDown: Se, ...ee }, n);
1716
1756
  if (!p) return;
1717
- const { getPortalContainer: Ke } = go();
1718
- let qe = null;
1719
- return me && me.isResizing && me.index === c && (qe = xo(Ee("div", { style: { position: "absolute", cursor: k ? Mo : ko, left: 0, top: 0, width: "100%", height: "100%" } }), Ke(), "divider:" + c)), Zt(_n, { children: [qe, Ee("div", { className: rn("header-divider-anchor"), style: { position: "absolute", pointerEvents: "auto", top: `${k ? Se.y : ge}px`, left: `${k ? ge : Se.x}px`, width: (k ? 0 : Se.width - 1) + "px", height: (k ? Se.height - 1 : 0) + "px", display: "flex" }, tabIndex: -1, children: p })] });
1757
+ const { getPortalContainer: je } = fo();
1758
+ let Ye = null;
1759
+ return se && se.isResizing && se.index === s && (Ye = po(Ce("div", { style: { position: "absolute", cursor: R ? ko : Po, left: 0, top: 0, width: "100%", height: "100%" } }), je(), "divider:" + s)), Qt(Qn, { children: [Ye, Ce("div", { className: rn("header-divider-anchor"), style: { position: "absolute", pointerEvents: "auto", top: `${R ? he.y : ge}px`, left: `${R ? ge : he.x}px`, width: (R ? 0 : he.width - 1) + "px", height: (R ? he.height - 1 : 0) + "px", display: "flex" }, tabIndex: -1, children: p })] });
1720
1760
  }));
1721
- class lr {
1761
+ class ur {
1722
1762
  naturalDimensions(n, o = {}) {
1723
1763
  const r = document.createElement("div");
1724
- let c = o?.lineHeight ?? "1";
1725
- !o?.lineHeight && o.paintableText?.fontSize && (c = Math.ceil(1.2 * o.paintableText.fontSize) + "px");
1726
- const a = document.createElement("div");
1727
- a.style.visibility = "hidden", a.style.position = "absolute", a.style.textRendering = "geometricprecision", a.style.display = "inline-grid", a.style.overflowWrap = "break-word", a.style.maxWidth = o.maxWidth ? o.maxWidth + "px" : "100%", a.style.lineHeight = c, a.style.letterSpacing = (o.paintableText?.letterSpacing ?? 0) + "px", a.style.fontSize = o.paintableText?.fontSize ? o.paintableText.fontSize + "px" : "unset", a.style.fontFamily = o.paintableText?.fontSize ? o.paintableText.fontFamily : "unset", a.style.fontWeight = o.paintableText?.fontWeight ? "" + o.paintableText.fontWeight : "400", a.style.fontStyle = o.paintableText?.fontStyle ? o.paintableText.fontStyle : "normal", a.style.whiteSpace = o.paintableText?.wrap === "wrap" ? "break-spaces" : "pre", r.appendChild(a);
1764
+ let s = o?.lineHeight ?? "1";
1765
+ !o?.lineHeight && o.paintableText?.fontSize && (s = Math.ceil(1.2 * o.paintableText.fontSize) + "px");
1766
+ const c = document.createElement("div");
1767
+ c.style.visibility = "hidden", c.style.position = "absolute", c.style.textRendering = "geometricprecision", c.style.display = "inline-grid", c.style.overflowWrap = "break-word", c.style.maxWidth = o.maxWidth ? o.maxWidth + "px" : "100%", c.style.lineHeight = s, c.style.letterSpacing = (o.paintableText?.letterSpacing ?? 0) + "px", c.style.fontSize = o.paintableText?.fontSize ? o.paintableText.fontSize + "px" : "unset", c.style.fontFamily = o.paintableText?.fontSize ? o.paintableText.fontFamily : "unset", c.style.fontWeight = o.paintableText?.fontWeight ? "" + o.paintableText.fontWeight : "400", c.style.fontStyle = o.paintableText?.fontStyle ? o.paintableText.fontStyle : "normal", c.style.whiteSpace = o.paintableText?.wrap === "wrap" ? "break-spaces" : "pre", r.appendChild(c);
1728
1768
  const i = n.split(`
1729
1769
  `);
1730
1770
  for (let h = 0; h < i.length; h++) {
1731
- let T = document.createElement("span");
1732
- a.appendChild(T), T.textContent = i[h];
1771
+ let k = document.createElement("span");
1772
+ c.appendChild(k), k.textContent = i[h];
1733
1773
  }
1734
- i.length !== 0 && i[i.length - 1].length !== 0 || a.appendChild(document.createElement("br")), document.body.appendChild(a);
1735
- let l = a.getBoundingClientRect();
1736
- return a.remove(), { width: l.width, height: l.height, maxLineHeight: 1.2 * (o.paintableText?.fontSize || 1056 / 72) };
1774
+ i.length !== 0 && i[i.length - 1].length !== 0 || c.appendChild(document.createElement("br")), document.body.appendChild(c);
1775
+ let l = c.getBoundingClientRect();
1776
+ return c.remove(), { width: l.width, height: l.height, maxLineHeight: 1.2 * (o.paintableText?.fontSize || 1056 / 72) };
1737
1777
  }
1738
1778
  }
1739
- const ir = (t = void 0) => Object.freeze({ clean: t, dirty: void 0, editMode: !1 }), cr = ir(), mr = Nt(Jt((t, n) => {
1740
- const { editState: o = cr, defaultTextStyle: r, onStartEdit: c, onChangeEdit: a, onSubmitEdit: i, onCancelEdit: l, onDoneEdit: h, containerBounds: T, setNaturalDimensions: B, onNavigate: R, textProperties: P, style: L, autoFocus: ce, ...J } = t, oe = ue(null), { width: $e = 0 } = T ?? {}, [te, k] = gt(() => o);
1741
- bt(() => {
1742
- k(o);
1779
+ const hr = (t = void 0) => Object.freeze({ clean: t, dirty: void 0, editMode: !1 }), gr = hr(), Ir = Kt(en((t, n) => {
1780
+ const { editState: o = gr, defaultTextStyle: r, onStartEdit: s, onChangeEdit: c, onSubmitEdit: i, onCancelEdit: l, onDoneEdit: h, containerBounds: k, setNaturalDimensions: A, onNavigate: E, textProperties: P, style: z, autoFocus: Y, ...j } = t, ee = ie(null), { width: Ie = 0 } = k ?? {}, [Z, R] = dt(() => o);
1781
+ pt(() => {
1782
+ R(o);
1743
1783
  }, [o]);
1744
- const Q = P?.align || "left", Se = P?.vAlign || "middle", A = P?.fill || "#040404", me = P?.wrap || "wrap", Ve = P?.fontFamily || "Calibri", Te = P?.fontSize || 11, We = P?.fontWeight || 400, ge = P?.fontStyle || "normal", Ce = te.dirty ?? te.clean ?? "";
1745
- let O = 2;
1746
- const p = 96 * Te / 72, Ke = 1.2 * p;
1747
- Se === "right" && (O += 1);
1748
- const qe = Ae(() => new lr().naturalDimensions(Ce, { maxWidth: me === "wrap" ? $e - O : void 0, lineHeight: `${Ke}px`, paintableText: { fontStyle: ge, wrap: me, letterSpacing: -0.25 } }), [Ce, me, O, p, Ve, We, ge, B, $e]), F = z(() => qe.maxLineHeight ? qe.maxLineHeight + "px" : "1.2", [qe]), [re, W] = gt(F);
1749
- Qt(() => {
1750
- W(F());
1751
- }, [T, qe]), Qt(() => {
1752
- B?.({ width: me === "wrap" ? void 0 : qe.width + O, height: qe.height });
1753
- }, [qe, B]);
1754
- const X = D(a, [a]), se = D((S) => {
1755
- if (te.dirty === S) return;
1756
- const Pe = { ...te };
1757
- Pe.dirty = S, oe.current, k(Pe), X?.(Pe);
1758
- }, [te]), Lt = D((S) => {
1759
- if (te.editMode === S) return;
1760
- const Pe = { ...te };
1761
- Pe.editMode = S, k(Pe), X?.(Pe);
1762
- }, [te]), mt = D(() => {
1784
+ const U = P?.align || "left", he = P?.vAlign || "middle", M = P?.fill || "#040404", se = P?.wrap || "wrap", Ue = P?.fontFamily || "Calibri", ke = P?.fontSize || 11, He = P?.fontWeight || 400, ge = P?.fontStyle || "normal", Se = Z.dirty ?? Z.clean ?? "";
1785
+ let B = 2;
1786
+ const p = 96 * ke / 72, je = 1.2 * p;
1787
+ he === "right" && (B += 1);
1788
+ const Ye = Ve(() => new ur().naturalDimensions(Se, { maxWidth: se === "wrap" ? Ie - B : void 0, lineHeight: `${je}px`, paintableText: { fontStyle: ge, wrap: se, letterSpacing: -0.25 } }), [Se, se, B, p, Ue, He, ge, A, Ie]), ne = $(() => Ye.maxLineHeight ? Ye.maxLineHeight + "px" : "1.2", [Ye]), [Ee, J] = dt(ne);
1789
+ _t(() => {
1790
+ J(ne());
1791
+ }, [k, Ye]), _t(() => {
1792
+ A?.({ width: se === "wrap" ? void 0 : Ye.width + B, height: Ye.height });
1793
+ }, [Ye, A]);
1794
+ const T = L(c, [c]), X = L((S) => {
1795
+ if (Z.dirty === S) return;
1796
+ const Me = { ...Z };
1797
+ Me.dirty = S, ee.current, R(Me), T?.(Me);
1798
+ }, [Z]), Mt = L((S) => {
1799
+ if (Z.editMode === S) return;
1800
+ const Me = { ...Z };
1801
+ Me.editMode = S, R(Me), T?.(Me);
1802
+ }, [Z]), Ct = L(() => {
1763
1803
  try {
1764
- return i?.(te), h?.(), !0;
1804
+ return i?.(Z), h?.(), !0;
1765
1805
  } catch {
1766
1806
  return !1;
1767
1807
  }
1768
- }, [i, te]), st = D(() => {
1769
- k(o), l?.(), h?.();
1770
- }, [l, o]), at = D((S) => {
1771
- if (!oe.current) return;
1772
- if (S.isDefaultPrevented(), !(S.isTrusted || S.nativeEvent.ctrlKey || S.nativeEvent.metaKey || S.nativeEvent.altKey || S.nativeEvent.isComposing) && mo.indexOf(S.nativeEvent.key) !== -1) {
1773
- const le = { ...te };
1774
- return le.dirty = S.nativeEvent.key === "Backspace" ? "" : (le.dirty ?? "") + S.key, k(le), X?.(le), void S.preventDefault();
1808
+ }, [i, Z]), ft = L(() => {
1809
+ R(o), l?.(), h?.();
1810
+ }, [l, o]), ut = L((S) => {
1811
+ if (!ee.current) return;
1812
+ if (S.isDefaultPrevented(), !(S.isTrusted || S.nativeEvent.ctrlKey || S.nativeEvent.metaKey || S.nativeEvent.altKey || S.nativeEvent.isComposing) && vo.indexOf(S.nativeEvent.key) !== -1) {
1813
+ const re = { ...Z };
1814
+ return re.dirty = S.nativeEvent.key === "Backspace" ? "" : (re.dirty ?? "") + S.key, R(re), T?.(re), void S.preventDefault();
1775
1815
  }
1776
- const Pe = S.nativeEvent.shiftKey;
1777
- if (S.which === zt.Escape) return S.preventDefault(), void st();
1778
- if (S.which === zt.F2) return Lt(!0), void S.preventDefault();
1779
- if (S.which === zt.Enter && (S.preventDefault(), mt() && R?.(Pe ? f.Up : f.Down)), S.which === zt.Tab) return S.preventDefault(), void (mt() && R?.(Pe ? f.Left : f.Right));
1780
- if (!te.editMode) {
1781
- let le = null;
1816
+ const Me = S.nativeEvent.shiftKey;
1817
+ if (S.which === Lt.Escape) return S.preventDefault(), void ft();
1818
+ if (S.which === Lt.F2) return Mt(!0), void S.preventDefault();
1819
+ if (S.which === Lt.Enter && (S.preventDefault(), Ct() && E?.(Me ? w.Up : w.Down)), S.which === Lt.Tab) return S.preventDefault(), void (Ct() && E?.(Me ? w.Left : w.Right));
1820
+ if (!Z.editMode) {
1821
+ let re = null;
1782
1822
  switch (S.which) {
1783
- case zt.Left:
1784
- le = f.Left;
1823
+ case Lt.Left:
1824
+ re = w.Left;
1785
1825
  break;
1786
- case zt.Right:
1787
- le = f.Right;
1826
+ case Lt.Right:
1827
+ re = w.Right;
1788
1828
  break;
1789
- case zt.Up:
1790
- le = f.Up;
1829
+ case Lt.Up:
1830
+ re = w.Up;
1791
1831
  break;
1792
- case zt.Down:
1793
- le = f.Down;
1832
+ case Lt.Down:
1833
+ re = w.Down;
1794
1834
  }
1795
- if (le) return void mt();
1835
+ if (re) return void Ct();
1796
1836
  }
1797
- }, [te, R]), [fe, en] = gt(!ce);
1798
- bt(() => {
1799
- en(!1);
1837
+ }, [Z, E]), [fe, Wt] = dt(!Y);
1838
+ pt(() => {
1839
+ Wt(!1);
1800
1840
  }, []);
1801
- const M = fo(n, () => ({ startEdit(S) {
1802
- let Pe = S?.initialSelection;
1803
- if (!Pe) {
1804
- const xe = oe.current.value.length ?? 0;
1805
- Pe = { start: xe, end: xe, direction: "forward" };
1841
+ const D = wo(n, () => ({ startEdit(S) {
1842
+ let Me = S?.initialSelection;
1843
+ if (!Me) {
1844
+ const xe = ee.current.value.length ?? 0;
1845
+ Me = { start: xe, end: xe, direction: "forward" };
1806
1846
  }
1807
- oe.current?.setSelectionRange(Pe.start, Pe.end, Pe.direction);
1808
- const le = { ...o, editMode: S?.editMode ?? !1 };
1809
- S?.text !== void 0 && (le.dirty = S.text), le.editMode === o.editMode && le.dirty === o.dirty || (k(le), X?.(le));
1810
- }, submitEdit: () => mt(), cancelEdit() {
1811
- st();
1847
+ ee.current?.setSelectionRange(Me.start, Me.end, Me.direction);
1848
+ const re = { ...o, editMode: S?.editMode ?? !1 };
1849
+ S?.text !== void 0 && (re.dirty = S.text), re.editMode === o.editMode && re.dirty === o.dirty || (R(re), T?.(re));
1850
+ }, submitEdit: () => Ct(), cancelEdit() {
1851
+ ft();
1812
1852
  }, autoFocus() {
1813
- oe.current?.focus();
1814
- }, getLineHeight: () => qe?.maxLineHeight ?? Ke, dispatchEvent: (S) => oe.current.dispatchEvent(S) }), [o, c]);
1815
- return Ee("div", { ref: M, ...J, style: { background: "transparent", display: "flex", flexGrow: 1, alignSelf: "center", height: qe.height, maxWidth: "100%", maxHeight: "100%", ...L }, children: Ee("textarea", { spellCheck: "false", ref: oe, value: Ce, autoFocus: !1, disabled: fe, name: "cell-editor", autoComplete: "off", autoCapitalize: "off", style: { flex: "1 1 100%", position: "relative", fontSize: `${p}px`, fontFamily: `${Ve}`, fontWeight: `${We}`, fontStyle: `${ge}`, padding: "0px", marginRight: Q === "right" ? "3px" : "0px", marginLeft: Q === "left" ? "2px" : "0px", lineHeight: re, height: qe.height, textRendering: "geometricPrecision", letterSpacing: "-0.25px", boxSizing: "border-box", borderWidth: 0, outline: "none", resize: "none", overflow: "hidden", verticalAlign: "baseline", textAlign: Q, background: "transparent", color: A, marginBottom: "0px", userSelect: "text", maxHeight: "100%", whiteSpace: me === "wrap" ? "break-spaces" : "pre", wordWrap: "break-word" }, onChange: (S) => {
1816
- se(S.target.value);
1853
+ ee.current?.focus();
1854
+ }, getLineHeight: () => Ye?.maxLineHeight ?? je, dispatchEvent: (S) => ee.current.dispatchEvent(S) }), [o, s]);
1855
+ return Ce("div", { ref: D, ...j, style: { background: "transparent", display: "flex", flexGrow: 1, alignSelf: "center", height: Ye.height, maxWidth: "100%", maxHeight: "100%", ...z }, children: Ce("textarea", { spellCheck: "false", ref: ee, value: Se, autoFocus: !1, disabled: fe, name: "cell-editor", autoComplete: "off", autoCapitalize: "off", style: { flex: "1 1 100%", position: "relative", fontSize: `${p}px`, fontFamily: `${Ue}`, fontWeight: `${He}`, fontStyle: `${ge}`, padding: "0px", marginRight: U === "right" ? "3px" : "0px", marginLeft: U === "left" ? "2px" : "0px", lineHeight: Ee, height: Ye.height, textRendering: "geometricPrecision", letterSpacing: "-0.25px", boxSizing: "border-box", borderWidth: 0, outline: "none", resize: "none", overflow: "hidden", verticalAlign: "baseline", textAlign: U, background: "transparent", color: M, marginBottom: "0px", userSelect: "text", maxHeight: "100%", whiteSpace: se === "wrap" ? "break-spaces" : "pre", wordWrap: "break-word" }, onChange: (S) => {
1856
+ X(S.target.value);
1817
1857
  }, onDoubleClick: (S) => {
1818
1858
  S.isTrusted;
1819
1859
  }, onMouseDown: (S) => {
1820
- Lt(!0);
1821
- }, onKeyDown: at }) });
1822
- })), vr = Nt((t) => {
1823
- const { value: n, view: o, bounds: r, range: c, zoom: a, children: i, style: l, ...h } = t;
1824
- return Ee("div", { style: { padding: "2px 4px", fontFamily: "Calibri", letterSpacing: -0.25, lineHeight: 1.2, fontSize: l?.fontSize || 1056 / 72, ...l }, ...h, children: n });
1860
+ Mt(!0);
1861
+ }, onKeyDown: ut }) });
1862
+ })), Er = Kt((t) => {
1863
+ const { value: n, view: o, bounds: r, range: s, zoom: c, children: i, style: l, ...h } = t;
1864
+ return Ce("div", { style: { padding: "2px 4px", fontFamily: "Calibri", letterSpacing: -0.25, lineHeight: 1.2, fontSize: l?.fontSize || 1056 / 72, ...l }, ...h, children: n });
1825
1865
  });
1826
1866
  export {
1827
- Eo as BaseGrid,
1828
- mr as DefaultCellEditor,
1829
- vr as DefaultCellRenderer,
1830
- or as DefaultHeaderDivider,
1831
- yo as FillHandle,
1832
- Ro as Grid,
1833
- pr as HeaderDivider,
1834
- nr as HeaderRenderer,
1835
- xr as RESET_SCROLL_EVENTS_DEBOUNCE_INTERVAL,
1867
+ Ro as BaseGrid,
1868
+ Ir as DefaultCellEditor,
1869
+ Er as DefaultCellRenderer,
1870
+ ar as DefaultHeaderDivider,
1871
+ Io as FillHandle,
1872
+ Mo as Grid,
1873
+ Cr as HeaderDivider,
1874
+ sr as HeaderRenderer,
1875
+ br as RESET_SCROLL_EVENTS_DEBOUNCE_INTERVAL,
1836
1876
  Vt as SELECTION_CLIP_INSETS,
1837
- mo as STANDARD_KEY_CHARS,
1838
- co as SVGLine,
1839
- qo as SVGRect,
1840
- tr as ScrollableGrid,
1841
- vo as Selection,
1842
- Xn as TouchSelectHandle,
1843
- jo as defaultSelectionRenderer,
1844
- ir as getDefaultStringEditState,
1877
+ vo as STANDARD_KEY_CHARS,
1878
+ ao as SVGLine,
1879
+ Qo as SVGRect,
1880
+ cr as ScrollableGrid,
1881
+ bo as Selection,
1882
+ Zn as TouchSelectHandle,
1883
+ _o as defaultSelectionRenderer,
1884
+ hr as getDefaultStringEditState,
1845
1885
  $t as safeSelectionCoords,
1846
- Bo as useCellLayout,
1847
- fr as useHeaderSelection,
1848
- gr as useKeyboardEditorOverlay,
1849
- wr as useSelection
1886
+ Yo as useAnimatedMeasure,
1887
+ Ao as useCellLayout,
1888
+ Sr as useHeaderSelection,
1889
+ vr as useKeyboardEditorOverlay,
1890
+ yr as useSelection
1850
1891
  };