@sheetxl/grid-react 0.1.98

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.
@@ -0,0 +1,3311 @@
1
+ /**
2
+ * @license @sheetxl/grid-react - Grid - Advanced data grid component for React - v0.0.0
3
+ *
4
+ * (C) 2025-present SheetXL Inc. & Michael T. Ford
5
+ * License: The license can be found at https://www.sheetxl.com/license.
6
+ */
7
+ import { jsx as e, jsxs as t, Fragment as n } from "react/jsx-runtime";
8
+ import o, { memo as r, useCallback as i, useRef as l, useEffect as s, useImperativeHandle as c, forwardRef as a, useMemo as d, useLayoutEffect as u, useState as h, createElement as f, useReducer as p } from "react";
9
+ import g from "clsx";
10
+ import { useMeasure as w } from "react-use";
11
+ import { mergeRefs as m } from "react-merge-refs";
12
+ import { createRoot as x } from "react-dom/client";
13
+ import { unstable_batchedUpdates as y, createPortal as v } from "react-dom";
14
+ import b from "tiny-invariant";
15
+ /**
16
+ * @license @sheetxl/utils - Utils - Utilities used by most SheetXL components. - v0.1.93
17
+ *
18
+ * (C) 2025-present SheetXL Inc. & Michael T. Ford
19
+ * License: The license can be found at https://www.sheetxl.com/license.
20
+ */
21
+ const S = "up", E = "down", _ = "left", I = "right", C = "tl", M = "t", T = "l", k = "c", R = "text/html", P = "text/plain", O = "image/png", L = Object.freeze({ left: 0, top: 0 }), D = Object.freeze({ left: 0, top: 0, bottom: 0, right: 0 }), z = Object.freeze({ x: 0, y: 0, width: 0, height: 0 });
22
+ Object.freeze(Object.defineProperty({ __proto__: null, EmptyBounds: z, EmptyRect: D, EmptyTopLeft: L }, Symbol.toStringTag, { value: "Module" }));
23
+ const A = "column", $ = "row", B = Object.freeze({ colIndex: 0, rowIndex: 0 }), F = Object.freeze({ colStart: 0, rowStart: 0, colEnd: 0, rowEnd: 0 }), j = (e5, t2) => e5.colStart === t2.colStart ? e5.rowStart - t2.rowStart : e5.colStart - t2.colStart, V = (e5, t2) => e5.rowStart === t2.rowStart ? e5.colStart - t2.colStart : e5.rowStart - t2.rowStart, W = (e5, t2) => e5.rowEnd === t2.rowEnd ? t2.colEnd - e5.colEnd : t2.rowEnd - e5.rowEnd, H = (e5, t2) => e5.colEnd === t2.colEnd ? t2.rowEnd - e5.rowEnd : t2.colEnd - e5.colEnd, N = (e5, t2) => e5.colIndex === t2.colIndex ? e5.rowIndex - t2.rowIndex : e5.colIndex - t2.colIndex, U = (e5, t2) => e5.rowIndex === t2.rowIndex ? e5.colIndex - t2.colIndex : e5.rowIndex - t2.rowIndex, q = (e5 = $, t2 = false) => t2 ? e5 !== A ? W : H : e5 !== A ? V : j, K = (e5, t2) => e5 === t2 || !(!e5 || !t2) && e5.rowIndex === t2.rowIndex && e5.colIndex === t2.colIndex, Y = (e5, t2) => e5 === t2 || !(!e5 || !t2) && e5.rowStart === t2.rowStart && e5.rowEnd === t2.rowEnd && e5.colStart === t2.colStart && e5.colEnd === t2.colEnd, X = (e5, t2) => !(!e5 || !t2 || e5.colStart > t2.colEnd || t2.colStart > e5.colEnd || e5.rowStart > t2.rowEnd || t2.rowStart > e5.rowEnd), G = (e5, t2) => {
24
+ if (e5 === t2) return true;
25
+ if (!e5 || !t2) return false;
26
+ if (e5.length !== t2.length) return false;
27
+ for (let n2 = 0; n2 < e5.length; n2++) if (!Y(e5[n2], t2[n2])) return false;
28
+ return true;
29
+ }, Z = (e5, t2, n2) => {
30
+ if (!e5 && !t2) return null;
31
+ if (!e5) return n2 ? t2 : { ...t2 };
32
+ if (!t2) return n2 ? e5 : { ...e5 };
33
+ const o2 = Math.min(e5.colStart, t2.colStart), r2 = Math.min(e5.rowStart, t2.rowStart), i2 = Math.max(e5.colEnd, t2.colEnd), l2 = Math.max(e5.rowEnd, t2.rowEnd);
34
+ let s2 = n2;
35
+ return s2 ? (s2.colStart = o2, s2.rowStart = r2, s2.colEnd = i2, s2.rowEnd = l2) : s2 = { colStart: o2, rowStart: r2, colEnd: i2, rowEnd: l2 }, s2;
36
+ }, J = (e5, t2) => {
37
+ if (!t2 || 0 === t2.length) return e5;
38
+ const n2 = { ...e5 };
39
+ for (let e6 = 0; e6 < t2.length; e6++) {
40
+ const o2 = t2[e6];
41
+ X(n2, o2) && (n2.rowStart = Math.min(n2.rowStart, o2.rowStart), n2.colStart = Math.min(n2.colStart, o2.colStart), n2.rowEnd = Math.max(n2.rowEnd, o2.rowEnd), n2.colEnd = Math.max(n2.colEnd, o2.colEnd));
42
+ }
43
+ return n2;
44
+ }, Q = [null, null], ee = (e5, t2, n2) => {
45
+ if (e5[0].value === e5[1].value) return t2;
46
+ };
47
+ function te(e5, t2 = 2, n2, o2 = $, r2) {
48
+ let i2 = [...e5];
49
+ if (t2 <= 0 || e5.length <= 1) return i2;
50
+ let l2 = o2 === A, s2 = 0, c2 = false;
51
+ do {
52
+ const e6 = i2.sort(q(l2 ? $ : A));
53
+ i2 = [], i2.push(e6[0]);
54
+ const t3 = e6.length;
55
+ let a2 = 0, d2 = e6[0], u2 = d2.colStart, h2 = d2.rowStart, f2 = d2.colEnd, p2 = d2.rowEnd;
56
+ for (let s3 = 1; s3 < t3; s3++) {
57
+ const t4 = e6[s3];
58
+ let g2 = false;
59
+ if (g2 = l2 ? d2 && h2 === t4.rowStart && p2 === t4.rowEnd && f2 + 1 === t4.colStart : d2 && u2 === t4.colStart && f2 === t4.colEnd && p2 + 1 === t4.rowStart, g2) {
60
+ let e7 = { colStart: u2, rowStart: h2, colEnd: l2 ? t4.colEnd : f2, rowEnd: l2 ? p2 : t4.rowEnd };
61
+ if (void 0 !== d2.value && (e7.value = d2.value), n2) {
62
+ const i3 = r2 ?? [null, null];
63
+ i3[0] = d2, i3[1] = t4, e7 = n2(i3, e7, o2);
64
+ }
65
+ if (e7) {
66
+ i2[a2] = e7, c2 = true, d2 = e7, u2 = d2.colStart, h2 = d2.rowStart, f2 = d2.colEnd, p2 = d2.rowEnd;
67
+ continue;
68
+ }
69
+ }
70
+ i2[++a2] = t4, d2 = t4, u2 = d2.colStart, h2 = d2.rowStart, f2 = d2.colEnd, p2 = d2.rowEnd;
71
+ }
72
+ s2++, l2 = !l2, 1 === s2 && (c2 = true);
73
+ } while (s2 < t2 && c2 && i2.length > 1);
74
+ return i2;
75
+ }
76
+ const ne = Object.freeze(Object.defineProperty({ __proto__: null, EmptyCell: B, EmptyRange: F, cellToRange: (e5, t2) => {
77
+ if (!e5) return null;
78
+ let n2 = t2;
79
+ return n2 || (n2 = { ...e5 }, delete n2.colIndex, delete n2.rowIndex), n2.colStart = e5.colIndex ?? 0, n2.rowStart = e5.rowIndex ?? 0, n2.colEnd = e5.colIndex ?? 0, n2.rowEnd = e5.rowIndex ?? 0, n2;
80
+ }, columnFirstCellComparator: N, columnFirstRangeComparator: j, createCellComparator: (e5 = $, t2 = false) => t2 ? e5 !== A ? (e6, t3) => e6.rowIndex === t3.rowIndex ? t3.colIndex - e6.colIndex : t3.rowIndex - e6.rowIndex : (e6, t3) => e6.colIndex === t3.colIndex ? t3.rowIndex - e6.rowIndex : t3.colIndex - e6.colIndex : e5 !== A ? U : N, createConflatingRanges: (e5, t2 = false) => {
81
+ const n2 = [];
82
+ let o2, r2, i2 = Number.MIN_SAFE_INTEGER, l2 = Number.MIN_SAFE_INTEGER;
83
+ return { append: (s2, c2, a2) => {
84
+ let d2 = true;
85
+ const u2 = void 0 !== a2;
86
+ if (u2) {
87
+ const n3 = e5 ? e5(r2, a2, t2) : r2 === a2 ? a2 : void 0;
88
+ void 0 === n3 ? d2 = false : a2 = n3;
89
+ }
90
+ if (d2 && c2 === l2 + 1 && s2 === i2) return t2 ? o2.rowEnd = c2 : o2.colEnd = c2, l2 = c2, void (r2 = a2);
91
+ o2 && n2.push(o2);
92
+ const h2 = t2 ? s2 : c2, f2 = t2 ? c2 : s2;
93
+ o2 = { colStart: h2, rowStart: f2, colEnd: h2, rowEnd: f2 }, u2 && (o2.value = a2), i2 = s2, l2 = c2, r2 = a2;
94
+ }, done: (e6) => (o2 && (n2.push(o2), o2 = null), e6 ? te(n2, 3, true === e6 ? ee : e6, t2 ? A : $, Q) : n2) };
95
+ }, createRangeComparator: q, defaultRange: (e5, t2, n2) => e5 ? n2 ? (n2.colStart = e5.colStart ?? t2.colStart, n2.rowStart = e5.rowStart ?? t2.rowStart, n2.colEnd = e5.colEnd ?? t2.colEnd, n2.rowEnd = e5.rowEnd ?? t2.rowEnd, n2) : { colStart: e5.colStart ?? t2.colStart, rowStart: e5.rowStart ?? t2.rowStart, colEnd: e5.colEnd ?? t2.colEnd, rowEnd: e5.rowEnd ?? t2.rowEnd } : t2, extendRangeToIntersectingRanges: J, extendRangeToUnionRanges: (e5, t2) => {
96
+ if (!t2 || 0 === t2.length) return e5;
97
+ let n2 = e5, o2 = null;
98
+ for (; !Y(n2, o2); ) o2 = n2, n2 = J(o2, t2);
99
+ return n2;
100
+ }, indexOfCoords: (e5, t2) => {
101
+ const n2 = { colStart: e5.colIndex, rowStart: e5.rowIndex, colEnd: e5.colIndex, rowEnd: e5.rowIndex };
102
+ for (let e6 = t2.length - 1; e6 >= 0; e6--) if (X(n2, t2[e6])) return e6;
103
+ return -1;
104
+ }, intersectRanges: (e5, t2, n2) => {
105
+ if (!e5) return n2 ? t2 : { ...t2 };
106
+ if (!t2) return n2 ? e5 : { ...e5 };
107
+ if (!e5 && !t2) return null;
108
+ if (e5.rowStart > t2.rowEnd || e5.rowEnd < t2.rowStart || e5.colStart > t2.colEnd || e5.colEnd < t2.colStart) return null;
109
+ const o2 = Math.max(e5.colStart, t2.colStart), r2 = Math.max(e5.rowStart, t2.rowStart), i2 = Math.min(e5.colEnd, t2.colEnd), l2 = Math.min(e5.rowEnd, t2.rowEnd);
110
+ let s2 = n2;
111
+ return s2 ? (s2.colStart = o2, s2.rowStart = r2, s2.colEnd = i2, s2.rowEnd = l2) : s2 = { colStart: o2, rowStart: r2, colEnd: i2, rowEnd: l2 }, s2;
112
+ }, isCellWithinRange: (e5, t2) => !(!e5 || !t2 || e5.rowIndex < t2.rowStart || e5.rowIndex > t2.rowEnd || e5.colIndex < t2.colStart || e5.colIndex > t2.colEnd), isEqualCells: K, isEqualRanges: Y, isEqualRangesArrays: G, isEqualSelectionCoords: (e5, t2) => e5 === t2 || !(!e5 || !t2) && e5.rangeIndex === t2.rangeIndex && !!K(e5.cell, t2.cell) && G(e5.ranges, t2.ranges), isRangeWithinRange: (e5, t2) => !(e5.rowStart < t2.rowStart || e5.rowEnd > t2.rowEnd || e5.colStart < t2.colStart || e5.colEnd > t2.colEnd), isRangesIntersect: X, isSingleCell: (e5) => !!e5 && e5.rowEnd === e5.rowStart && e5.colStart === e5.colEnd, isValidRange: (e5) => !(!e5 || "number" != typeof e5.colStart || e5.colStart < 0 || "number" != typeof e5.colEnd || e5.colEnd < e5.colStart || "number" != typeof e5.rowStart || e5.rowStart < 0 || "number" != typeof e5.rowEnd || e5.rowEnd < e5.rowStart), mergeRangedValues: te, rowFirstCellComparator: U, rowFirstRangeComparator: V, sanitizeRange: (e5) => e5 ? { colStart: e5.colIndex ?? e5.colStart ?? 0, rowStart: e5.rowIndex ?? e5.rowStart ?? 0, colEnd: e5.colIndex ?? e5.colEnd ?? 0, rowEnd: e5.rowIndex ?? e5.rowEnd ?? 0 } : null, translateRange: (e5, t2 = -e5.rowStart, n2 = -e5.colStart, o2) => o2 ? (o2.colStart = e5.colStart + n2, o2.rowStart = e5.rowStart + t2, o2.colEnd = e5.colEnd + n2, o2.rowEnd = e5.rowEnd + t2, o2) : { colStart: e5.colStart + n2, rowStart: e5.rowStart + t2, colEnd: e5.colEnd + n2, rowEnd: e5.rowEnd + t2 }, unionRanges: Z, unionRangesArrays: (e5, t2, n2) => {
113
+ if (!e5 || 0 === e5.length) return null;
114
+ if (1 === e5.length && !t2) return e5[0];
115
+ let o2 = e5[0];
116
+ for (let t3 = 1; t3 < e5.length; t3++) o2 = Z(o2, e5[t3], n2);
117
+ return t2 && (o2 = Z(o2, t2, n2)), o2;
118
+ } }, Symbol.toStringTag, { value: "Module" }));
119
+ const oe = "function" == typeof Symbol && Symbol.for ? Symbol.for("react.element") : 60103;
120
+ function re(e5) {
121
+ return /* @__PURE__ */ function(e6) {
122
+ return !!e6 && "object" == typeof e6;
123
+ }(e5) && !function(e6) {
124
+ const t2 = Object.prototype.toString.call(e6);
125
+ return "[object RegExp]" === t2 || "[object Date]" === t2 || e6.$$typeof === oe;
126
+ }(e5);
127
+ }
128
+ function ie(e5, t2) {
129
+ return false !== t2.clone && t2.isMergeableObject(e5) ? ae((n2 = e5, Array.isArray(n2) ? [] : {}), e5, t2) : e5;
130
+ var n2;
131
+ }
132
+ function le(e5, t2, n2) {
133
+ return e5.concat(t2).map(function(e6) {
134
+ return ie(e6, n2);
135
+ });
136
+ }
137
+ function se(e5) {
138
+ return Object.keys(e5).concat((t2 = e5, Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(t2).filter(function(e6) {
139
+ return Object.propertyIsEnumerable.call(t2, e6);
140
+ }) : []));
141
+ var t2;
142
+ }
143
+ function ce(e5, t2) {
144
+ try {
145
+ return t2 in e5;
146
+ } catch (e6) {
147
+ return false;
148
+ }
149
+ }
150
+ function ae(e5, t2, n2) {
151
+ (n2 = n2 || {}).arrayMerge = n2.arrayMerge || le, n2.isMergeableObject = n2.isMergeableObject || re, n2.cloneUnlessOtherwiseSpecified = ie;
152
+ const o2 = Array.isArray(t2);
153
+ return o2 === Array.isArray(e5) ? o2 ? n2.arrayMerge(e5, t2, n2) : function(e6, t3, n3) {
154
+ const o3 = {};
155
+ return n3.isMergeableObject(e6) && se(e6).forEach(function(t4) {
156
+ o3[t4] = ie(e6[t4], n3);
157
+ }), se(t3).forEach(function(r2) {
158
+ var i2, l2;
159
+ ce(i2 = e6, l2 = r2) && (!Object.hasOwnProperty.call(i2, l2) || !Object.propertyIsEnumerable.call(i2, l2)) || (ce(e6, r2) && n3.isMergeableObject(t3[r2]) ? o3[r2] = function(e7, t4) {
160
+ if (!t4.customMerge) return ae;
161
+ const n4 = t4.customMerge(e7);
162
+ return "function" == typeof n4 ? n4 : ae;
163
+ }(r2, n3)(e6[r2], t3[r2], n3) : o3[r2] = ie(t3[r2], n3));
164
+ }), o3;
165
+ }(e5, t2, n2) : ie(t2, n2);
166
+ }
167
+ ae.all = function(e5, t2) {
168
+ if (!Array.isArray(e5)) throw new Error("first argument should be an array");
169
+ return e5.reduce(function(e6, n2) {
170
+ return ae(e6, n2, t2);
171
+ }, {});
172
+ };
173
+ const de = Object.freeze([]), ue = Object.freeze({}), he = (e5) => e5, fe = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e5) {
174
+ let t2 = 16 * Math.random() | 0;
175
+ return ("x" === e5 ? t2 : 3 & t2 | 8).toString(16);
176
+ }), pe = (e5, t2) => e5 === t2 || !(!Array.isArray(e5) || !Array.isArray(t2) || e5.length !== t2.length) && e5.every((e6, n2) => e6 === t2[n2]), ge = (e5) => "object" == typeof e5 && !Array.isArray(e5) && null !== e5, we = (e5) => "object" != typeof e5 || Array.isArray(e5) || null === e5 ? e5 : (Object.keys(e5).forEach(function(t2) {
177
+ e5[t2] && "object" == typeof e5[t2] ? we(e5[t2]) : null !== e5[t2] && void 0 !== e5[t2] || delete e5[t2], "object" == typeof e5[t2] && 0 === Object.keys(e5[t2]).length && delete e5[t2];
178
+ }), 0 === Object.keys(e5).length ? null : e5), me = (e5, t2) => !(e5 !== t2 && !pe(e5, t2) && !e5.isEqual?.(t2)), xe = (e5, t2, n2 = me) => {
179
+ if (null == e5 || e5 === t2) return null;
180
+ if (!e5 || "object" != typeof e5 || Array.isArray(e5) || e5.isImmutable?.()) return n2(e5, t2) ? null : e5;
181
+ const o2 = Object.keys(e5);
182
+ if (0 === o2.length) return null;
183
+ let r2 = false;
184
+ for (let i2 = 0; i2 < o2.length; i2++) {
185
+ const l2 = o2[i2];
186
+ null === xe(e5[l2], t2?.[l2], n2) && (r2 = true, delete e5[l2]);
187
+ }
188
+ return r2 && 0 === Object.keys(e5).length ? null : void 0;
189
+ }, ye = "object" == typeof performance && "function" == typeof performance.now ? () => performance.now() : () => Date.now(), ve = (e5) => null == e5, be = (e5, t2) => !(t2.left > e5.right || t2.right < e5.left || t2.top > e5.bottom || t2.bottom < e5.top), Se = !("undefined" == typeof window || !window.document || !window.document.createElement), Ee = { Windows: "windows", MacOS: "macos", IOS: "ios", Linux: "linux", Android: "android", Safari: "safari", Firefox: "firefox", Node: "node", Unknown: "unknown" }, _e = () => {
190
+ if (Ie()) return Ee.Node;
191
+ const e5 = void 0 !== globalThis.navigator && globalThis.navigator.userAgent ? globalThis.navigator.userAgent.toLowerCase() : "";
192
+ return e5 ? /(win32|win64|windows|wince)/i.test(e5) ? Ee.Windows : /(macintosh|macintel|macppc|mac68k|macos)/i.test(e5) ? Ee.MacOS : /(iphone|ipad|ipod)/i.test(e5) ? Ee.IOS : /android/.test(e5) ? Ee.Android : /linux/.test(e5) ? Ee.Linux : /^((?!chrome|android|).)*safari/i.test(e5) ? Ee.Safari : /^((?!chrome|android|Seamonkey).)*firefox/i.test(e5) ? Ee.Firefox : Ee.Unknown : Ee.Unknown;
193
+ };
194
+ function Ie() {
195
+ return "undefined" != typeof process && "node" === process.release?.name || ("undefined" != typeof process && process.browser, false);
196
+ }
197
+ const Ce = (e5, t2 = false) => (document.hasFocus() || t2) && (e5 === document.activeElement || e5?.contains(document.activeElement)), Me = Object.freeze(Object.defineProperty({ __proto__: null, EmptyArray: de, EmptyObject: ue, OSType: Ee, arrayMove: function(e5, t2, n2) {
198
+ const o2 = e5.slice();
199
+ return o2.splice(n2 < 0 ? o2.length + n2 : n2, 0, o2.splice(t2, 1)[0]), o2;
200
+ }, asNumber: (e5) => {
201
+ const t2 = ((e6) => 1 * e6)(e5);
202
+ return Number.isFinite(t2) ? t2 : 0;
203
+ }, camelToPrettyCase: (e5) => 1 === e5.length ? e5.toUpperCase() : e5.replace(/([A-Z])/g, " $1").replace(/^./, function(e6) {
204
+ return e6.toUpperCase();
205
+ }).trim(), canUseDOM: Se, cancelTimeout: (e5) => {
206
+ cancelAnimationFrame(e5.id);
207
+ }, castToString: (e5) => null == e5 || void 0 === e5 ? "" : "string" != typeof e5 ? "" + e5 : e5, cloneObject: (e5) => ve(e5) ? e5 : JSON.parse(JSON.stringify(e5)), consoleWithNoSource: (...e5) => new Promise((t2) => {
208
+ setTimeout(() => {
209
+ Function("console.log.apply(console, arguments)").apply(null, e5), t2();
210
+ });
211
+ }), debounce: function(e5, t2 = 300, n2 = false) {
212
+ let o2, r2, i2, l2, s2 = 0;
213
+ function c2() {
214
+ let a3 = Date.now() - s2;
215
+ a3 < t2 && a3 >= 0 ? o2 = setTimeout(c2, t2 - a3) : (o2 = null, n2 || (l2 = e5.apply(i2, r2), i2 = r2 = null));
216
+ }
217
+ null == t2 && (t2 = 100);
218
+ const a2 = function() {
219
+ i2 = globalThis, r2 = arguments, s2 = Date.now();
220
+ var a3 = n2 && !o2;
221
+ return o2 || (o2 = setTimeout(c2, t2)), a3 && (l2 = e5.apply(i2, r2), i2 = r2 = null), l2;
222
+ };
223
+ return a2.clear = function() {
224
+ o2 && (clearTimeout(o2), o2 = null);
225
+ }, a2.flush = function() {
226
+ o2 && (l2 = e5.apply(i2, r2), i2 = r2 = null, clearTimeout(o2), o2 = null);
227
+ }, a2;
228
+ }, deepEqual: function e2(t2, n2) {
229
+ if (t2 === n2) return true;
230
+ if (t2 && n2 && "object" == typeof t2 && "object" == typeof n2) {
231
+ if (t2.constructor !== n2.constructor) return false;
232
+ let o2, r2, i2;
233
+ if (Array.isArray(t2)) {
234
+ if (o2 = t2.length, o2 != n2.length) return false;
235
+ for (r2 = o2; 0 !== r2--; ) if (!e2(t2[r2], n2[r2])) return false;
236
+ return true;
237
+ }
238
+ if (t2 instanceof Map && n2 instanceof Map) {
239
+ if (t2.size !== n2.size) return false;
240
+ for (r2 of t2.entries()) if (!n2.has(r2[0])) return false;
241
+ for (r2 of t2.entries()) if (!e2(r2[1], n2.get(r2[0]))) return false;
242
+ return true;
243
+ }
244
+ if (t2 instanceof Set && n2 instanceof Set) {
245
+ if (t2.size !== n2.size) return false;
246
+ for (r2 of t2.entries()) if (!n2.has(r2[0])) return false;
247
+ return true;
248
+ }
249
+ if (ArrayBuffer.isView(t2) && ArrayBuffer.isView(n2)) {
250
+ if (o2 = t2.length, o2 != n2.length) return false;
251
+ for (r2 = o2; 0 !== r2--; ) if (t2[r2] !== n2[r2]) return false;
252
+ return true;
253
+ }
254
+ if (t2.constructor === RegExp) return t2.source === n2.source && t2.flags === n2.flags;
255
+ if (t2.valueOf !== Object.prototype.valueOf) return t2.valueOf() === n2.valueOf();
256
+ if (t2.toString !== Object.prototype.toString) return t2.toString() === n2.toString();
257
+ if (i2 = Object.keys(t2), o2 = i2.length, o2 !== Object.keys(n2).length) return false;
258
+ for (r2 = o2; 0 !== r2--; ) if (!Object.prototype.hasOwnProperty.call(n2, i2[r2])) return false;
259
+ for (r2 = o2; 0 !== r2--; ) {
260
+ let o3 = i2[r2];
261
+ if (!("_owner" === o3 && t2.$$typeof || e2(t2[o3], n2[o3]))) return false;
262
+ }
263
+ return true;
264
+ }
265
+ return t2 != t2 && n2 != n2;
266
+ }, deepFreeze: function e3(t2) {
267
+ return Object.freeze(t2), Object.keys(t2).forEach((n2) => {
268
+ "object" != typeof t2[n2] || null === t2[n2] || Object.isFrozen(t2[n2]) || e3(t2[n2]);
269
+ }), t2;
270
+ }, deepMerge: ae, diffValues: (e5, t2) => {
271
+ const n2 = {}, o2 = Object.keys(t2), r2 = o2.length;
272
+ for (let i2 = 0; i2 < r2; i2++) {
273
+ const r3 = o2[i2];
274
+ e5[r3] !== t2[r3] && (void 0 === e5[r3] ? n2[r3] = t2[r3] : n2[r3] = e5[r3]);
275
+ }
276
+ return 0 === Object.keys(n2).length ? null : n2;
277
+ }, findEqualOrGreater: function(e5, t2, n2 = he) {
278
+ let o2 = 0, r2 = e5.length - 1;
279
+ for (; o2 <= r2; ) {
280
+ let i2 = Math.floor((o2 + r2) / 2), l2 = n2(e5[i2]);
281
+ if (l2 === t2) return i2;
282
+ l2 < t2 ? o2 = i2 + 1 : r2 = i2 - 1;
283
+ }
284
+ return o2;
285
+ }, findEqualOrLesser: function(e5, t2, n2 = he) {
286
+ let o2 = e5.length - 1, r2 = 0;
287
+ for (; o2 >= r2; ) {
288
+ let i2 = Math.floor((o2 + r2) / 2), l2 = n2(e5[i2]);
289
+ if (l2 === t2) return i2;
290
+ l2 > t2 ? o2 = i2 - 1 : r2 = i2 + 1;
291
+ }
292
+ return o2;
293
+ }, findNextStep: (e5, t2 = true, n2 = 15, o2 = 10, r2 = 400) => {
294
+ const i2 = Math.max(e5 - o2, 0) + (t2 ? 1 : -1);
295
+ return Math.min(r2, Math[t2 ? "ceil" : "floor"](i2 / n2) * n2 + o2);
296
+ }, getBuildEnv: () => "node-build", getDPI: () => {
297
+ let e5 = 1;
298
+ return "object" == typeof window && (e5 = window.devicePixelRatio || 1), e5;
299
+ }, getFromPath: (e5, t2) => {
300
+ const n2 = t2.split(".");
301
+ let o2 = e5;
302
+ for (let e6 = 0; e6 < n2.length; e6++) {
303
+ const t3 = n2[e6];
304
+ if (!o2) return null;
305
+ let r2 = o2[t3];
306
+ if ("function" == typeof r2 && (r2 = r2.bind(o2)()), !r2 || !ge(r2)) return r2;
307
+ o2 = r2;
308
+ }
309
+ return o2 ?? null;
310
+ }, getOS: _e, hasFocus: Ce, isDefined: (e5) => !(null == e5), isEmpty: (e5) => null == e5 || "" === e5, isEqualArrays: pe, isEqualBounds: (e5, t2) => e5 === t2 || !(e5 && !t2 || t2 && !e5) && e5.x === t2.x && e5.y === t2.y && e5.width === t2.width && e5.height === t2.height, isEqualObjectKeys: (e5, t2) => {
311
+ if (e5 === t2) return true;
312
+ if (e5 && !t2 || t2 && !e5) return false;
313
+ const n2 = Object.keys(e5);
314
+ if (n2.length !== Object.keys(t2).length) return false;
315
+ for (let o2 = 0; o2 < n2.length; o2++) if (e5[n2[o2]] !== t2[n2[o2]]) return false;
316
+ return true;
317
+ }, isNode: Ie, isNullOrUndefined: ve, isNumeric: (e5) => {
318
+ const t2 = 1 * e5;
319
+ return Number.isFinite(t2) && "number" == typeof t2;
320
+ }, isObject: ge, isPromiseLike: (e5) => !!e5 && "function" == typeof e5.then, isRectInsideRect: (e5, t2) => e5.top >= t2.top && e5.bottom <= t2.bottom && e5.left >= t2.left && e5.right <= t2.right, isRectIntersect: be, mergeContentful: (...e5) => {
321
+ const t2 = e5.length;
322
+ if (t2 > 0 && void 0 !== e5[t2 - 1] && !ge(e5[t2 - 1])) return e5[t2 - 1];
323
+ let n2 = e5[0] || {};
324
+ for (let o2 = 1; o2 < t2; o2++) n2 = ae(n2, e5[o2] || {}, { arrayMerge: (e6, t3) => [...t3] });
325
+ return n2;
326
+ }, nextTick: (e5) => {
327
+ "undefined" != typeof window && "function" == typeof window.requestAnimationFrame ? window.requestAnimationFrame(() => {
328
+ e5();
329
+ }) : ("function" == typeof setImmediate ? setImmediate : setTimeout)(() => {
330
+ e5();
331
+ });
332
+ }, openFileDialog: (e5 = "*.*") => new Promise((t2, n2) => {
333
+ if (!Se) return void n2("Unable to open dialog with no dom.");
334
+ const o2 = document.createElement("input");
335
+ o2.type = "file", o2.accept = e5;
336
+ let r2 = null, i2 = false;
337
+ globalThis.addEventListener?.("focus", () => {
338
+ setTimeout(() => {
339
+ r2 || i2 || (i2 = true, t2(null));
340
+ }, 1e3);
341
+ }, { once: true, passive: true }), o2.onchange = () => {
342
+ if (r2 = o2.files[0], r2) {
343
+ if (i2) return void console.warn("File open detected after faux cancel.", r2);
344
+ t2(r2);
345
+ }
346
+ }, o2.autofocus = true, o2.click();
347
+ }), rafThrottle: (e5) => {
348
+ let t2, n2 = false, o2 = function() {
349
+ n2 = false, e5(t2);
350
+ };
351
+ return function(e6) {
352
+ t2 = e6, t2 && t2.persist && t2.persist(), n2 || (n2 = true, requestAnimationFrame(o2));
353
+ };
354
+ }, removeEmptyProperties: we, removeEqualValues: xe, removeListenerAll: (e5) => {
355
+ if (!e5) return [];
356
+ for (let t2 = 0; t2 < e5.length; t2++) e5[t2] && e5[t2]();
357
+ return [];
358
+ }, requestTimeout: (e5, t2) => {
359
+ const n2 = ye(), o2 = { id: requestAnimationFrame(function r2() {
360
+ ye() - n2 >= t2 ? e5.call(null) : o2.id = requestAnimationFrame(r2);
361
+ }) };
362
+ return o2;
363
+ }, roundAccurately: (e5, t2 = 0) => {
364
+ if (null == e5 || !isFinite(e5)) return null;
365
+ const n2 = 10 ** t2;
366
+ return Number(Math.round(e5 * n2) / n2);
367
+ }, setToPath: (e5, t2, n2) => {
368
+ const o2 = t2.split(".");
369
+ let r2 = e5;
370
+ if (!r2) throw new Error("Can not set path to a null path.");
371
+ for (let e6 = 0; r2 && e6 < o2.length - 1; e6++) {
372
+ const t3 = o2[e6];
373
+ let n3 = r2[t3];
374
+ if (null == n3 && (n3 = {}, r2[t3] = n3), !ge(n3)) throw new Error("Can not set path to a non object path.");
375
+ r2 = n3;
376
+ }
377
+ if ("number" != typeof n2 && "boolean" != typeof n2 && "string" != typeof n2 && !ge(n2)) throw new Error(`Can not set path to ${n2} that is not a a supported primitive.`);
378
+ return r2[o2[o2.length - 1]] = n2, e5;
379
+ }, splitNumber: (e5) => {
380
+ let t2 = Math.abs(e5);
381
+ if (isNaN(t2) || !isFinite(e5)) return null;
382
+ let n2 = 0 | t2, o2 = t2 - n2, r2 = 0, i2 = 0, l2 = 1;
383
+ if (o2 > 5e-8) for (; i2 < 8 && Math.abs(r2 / l2 - o2) > 5e-8; ) i2++, l2 *= 10, r2 = Math.round(o2 * l2);
384
+ return { ip: Math.trunc(e5), fp: r2, ipLength: Math.ceil(Math.log10(n2 + 1)), fpLength: i2 };
385
+ }, subtractRect: (e5, t2, n2 = false) => {
386
+ if (!t2) return [e5];
387
+ if (!be(e5, t2)) return [];
388
+ const o2 = [];
389
+ let r2 = e5;
390
+ const i2 = () => {
391
+ t2.top > r2.top && t2.top < r2.bottom && (o2.push({ ...r2, bottom: t2.top }), r2 = { ...r2, top: t2.top });
392
+ }, l2 = () => {
393
+ t2.bottom > r2.top && t2.bottom < r2.bottom && (o2.push({ ...r2, top: t2.bottom }), r2 = { ...r2, bottom: t2.bottom });
394
+ }, s2 = () => {
395
+ t2.right > r2.left && t2.right < r2.right && (o2.push({ ...r2, left: t2.right }), r2 = { ...r2, right: t2.right });
396
+ }, c2 = () => {
397
+ t2.left > r2.left && t2.left < r2.right && (o2.push({ ...r2, right: t2.left }), r2 = { ...r2, left: t2.left });
398
+ };
399
+ return n2 ? (c2(), s2(), i2(), l2()) : (i2(), l2(), s2(), c2()), o2;
400
+ }, textToKey: (e5) => e5.replace(/[^a-zA-Z0-9]/g, "").toLowerCase(), throttle: function(e5, t2) {
401
+ let n2 = null;
402
+ return (...o2) => {
403
+ const r2 = Date.now();
404
+ (!n2 || r2 - n2 >= t2) && (n2 = r2, e5(...o2));
405
+ };
406
+ }, toSafeJSON: function e4(t2) {
407
+ if (null === t2 || "object" != typeof t2) return t2;
408
+ if ("function" == typeof t2.toJSON) return t2.toJSON();
409
+ if (Array.isArray(t2)) return t2.map((t3) => e4(t3));
410
+ if ("function" == typeof t2.toString && t2.toString !== Object.prototype.toString) return t2.toString();
411
+ const n2 = {};
412
+ for (const o2 in t2) t2.hasOwnProperty(o2) && (n2[o2] = e4(t2[o2]));
413
+ return n2;
414
+ }, transpose: (e5) => {
415
+ if (!e5) return e5;
416
+ const t2 = e5.length, n2 = e5[0].length, o2 = [];
417
+ for (let e6 = 0; e6 < n2; e6++) o2[e6] = Array(t2);
418
+ for (let r2 = 0; r2 < t2; r2++) for (let t3 = 0; t3 < n2; t3++) o2[t3][r2] = e5[r2][t3];
419
+ return o2;
420
+ }, uuidV4: fe, validEnumValue: (e5, t2) => {
421
+ if (!Object.values(e5).includes(t2)) throw new Error(`Invalid type: ${t2 ?? "null"}. Must be one of: ${Object.values(t2).join(", ")}.`);
422
+ }, whenFocus: async (e5, t2 = false) => new Promise((n2) => {
423
+ Ce(e5, t2) ? n2(true) : e5.addEventListener("focusin", () => {
424
+ n2(true);
425
+ }, { once: true }), e5.focus();
426
+ }) }, Symbol.toStringTag, { value: "Module" }));
427
+ Object.freeze(Object.defineProperty({ __proto__: null, MESSAGE_ERROR_INVALID_ARG: (e5) => `Invalid argument: '${e5}'.` }, Symbol.toStringTag, { value: "Module" }));
428
+ const Te = (e5) => {
429
+ const t2 = new Uint8Array(e5), n2 = t2.byteLength;
430
+ let o2 = "";
431
+ for (let e6 = 0; e6 < n2; e6++) o2 += String.fromCharCode(t2[e6]);
432
+ if ("undefined" != typeof window && "function" == typeof globalThis.btoa) return globalThis.btoa(o2);
433
+ if ("undefined" != typeof Buffer) return Buffer.from(o2, "binary").toString("base64");
434
+ throw new Error("Unsupported environment");
435
+ }, ke = (e5) => new Promise((t2, n2) => {
436
+ if (e5) if ("undefined" != typeof FileReader) {
437
+ const o2 = new FileReader();
438
+ o2.onload = () => {
439
+ t2(o2.result);
440
+ }, o2.onerror = () => {
441
+ n2(o2.error);
442
+ }, o2.readAsText(e5);
443
+ } else if ("undefined" != typeof Buffer) {
444
+ const o2 = (e6) => Buffer.from(e6).toString("utf-8");
445
+ e5.arrayBuffer().then((e6) => {
446
+ t2(o2(e6));
447
+ }).catch((e6) => {
448
+ n2(e6);
449
+ });
450
+ } else n2(new Error("Unsupported environment"));
451
+ else t2("");
452
+ });
453
+ Object.freeze(Object.defineProperty({ __proto__: null, DEFAULT_MIME_TYPE: "*/*", arrayBufferToBase64: Te, base64ToArrayBuffer: (e5) => {
454
+ const t2 = "undefined" != typeof window && "function" == typeof globalThis.atob ? globalThis.atob(e5) : Buffer.from(e5, "base64").toString("binary"), n2 = t2.length, o2 = new Uint8Array(n2);
455
+ for (let e6 = 0; e6 < n2; e6++) o2[e6] = t2.charCodeAt(e6);
456
+ return o2.buffer;
457
+ }, blobToString: ke }, Symbol.toStringTag, { value: "Module" }));
458
+ const Re = "data:image/png;base64,", Pe = "Unable to resolve image.", Oe = (e5) => new Promise(async (t2, n2) => {
459
+ let o2 = null;
460
+ try {
461
+ o2 = new Image(), o2.src = e5, o2.addEventListener("load", function() {
462
+ t2({ width: o2.naturalWidth, height: o2.naturalHeight });
463
+ }, { once: true }), o2.addEventListener("error", function() {
464
+ URL.revokeObjectURL(e5), n2("Invalid Image");
465
+ }, { once: true }), await o2.decode("sync");
466
+ } catch (e6) {
467
+ o2?.src && URL.revokeObjectURL(o2.src);
468
+ }
469
+ o2 || n2(Pe);
470
+ }), Le = "image/svg+xml";
471
+ var De, ze;
472
+ Object.freeze(Object.defineProperty({ __proto__: null, DATA_URL_PNG_PREFIX: Re, getImageDataUrl: (e5, t2 = 1) => new Promise(async (n2, o2) => {
473
+ let r2 = null;
474
+ try {
475
+ r2 = new Image(), r2.src = e5, r2.addEventListener("load", function() {
476
+ try {
477
+ const e6 = document.createElement("canvas");
478
+ e6.width = r2.naturalWidth, e6.height = r2.naturalHeight, e6.getContext("2d").drawImage(r2, 0, 0);
479
+ const o3 = e6.toDataURL("image/png", t2);
480
+ n2({ elemImg: r2, dataUrl: o3 });
481
+ } catch (t3) {
482
+ URL.revokeObjectURL(e5), o2(t3);
483
+ }
484
+ }, { once: true }), r2.addEventListener("error", function() {
485
+ URL.revokeObjectURL(e5), o2("Invalid Image");
486
+ }, { once: true }), await r2.decode("sync");
487
+ } catch (e6) {
488
+ r2?.src && URL.revokeObjectURL(r2.src);
489
+ }
490
+ r2 || o2(Pe);
491
+ }), loadImageDetails: async (e5, t2 = null) => {
492
+ let n2 = null;
493
+ const o2 = async () => {
494
+ try {
495
+ const o3 = t2 ?? "image/*", r3 = URL.createObjectURL(new Blob([e5], { type: o3 })), i2 = await Oe(r3);
496
+ n2 = { mimeType: o3, naturalDimensions: i2, asUrl: r3 };
497
+ } catch (e6) {
498
+ }
499
+ }, r2 = async () => {
500
+ try {
501
+ const o3 = new TextDecoder().decode(e5), r3 = URL.createObjectURL(new Blob([o3], { type: Le })), i2 = await Oe(r3);
502
+ n2 = { mimeType: t2 ?? Le, naturalDimensions: i2, asUrl: r3, asSVGText: o3 };
503
+ } catch (e6) {
504
+ }
505
+ };
506
+ if (t2 === Le ? await r2() : t2.startsWith("image/") ? await o2() : (await o2(), n2 || await r2()), !n2) throw new Error("Failed to load image");
507
+ return n2;
508
+ } }, Symbol.toStringTag, { value: "Module" })), (ze = De || (De = {})).resolveTypedUpdates = (e5, t2, n2, o2) => {
509
+ if (null === e5) return e5;
510
+ if (void 0 === e5) return o2;
511
+ let r2 = e5;
512
+ if (t2?.shorthand) {
513
+ const o3 = t2?.shorthand(e5, n2);
514
+ void 0 !== o3 && (r2 = o3);
515
+ }
516
+ if (null !== r2 && t2?.getSubType) {
517
+ const e6 = t2.getSubType(r2);
518
+ e6 && (t2 = e6);
519
+ }
520
+ const i2 = t2?.properties, l2 = t2?.arrayType ?? false;
521
+ let s2 = r2;
522
+ if (t2 && t2.merge && s2 && o2) s2 = t2.merge(s2, o2, n2);
523
+ else if (l2) ;
524
+ else if (i2) {
525
+ const e6 = Object.keys({ ...r2, ...o2 });
526
+ s2 = null;
527
+ for (let t3 = 0; t3 < e6.length; t3++) {
528
+ const l3 = e6[t3];
529
+ let c2, a2 = r2[l3];
530
+ if (void 0 !== a2) {
531
+ const e7 = i2[l3];
532
+ c2 = e7 ? (0, ze.resolveTypedUpdates)(a2, e7, n2, o2?.[l3]) : a2;
533
+ } else c2 = o2?.[l3];
534
+ null != c2 && (s2 = s2 ?? {}, s2[l3] = c2);
535
+ }
536
+ }
537
+ return s2;
538
+ };
539
+ const Ae = "The Safari browser does not support advanced copy and paste.\nCopy and paste will be limited to within the browser tab.\n\nPlease use Chrome or Edge if external copy and paste is required.", $e = "You do not have permissions to access the clipboard.\nAll copy and paste operations will be limited to the browser tab.", Be = { Safari: "The Safari browser does not support advanced copy and paste.\nCopy and paste will be limited to within the browser tab.\n\nPlease use Chrome or Edge if external copy and paste is required.", Perms: $e, PermsWrite: _e() === Ee.Safari ? Ae : $e, PermsRead: _e() === Ee.Safari ? Ae : $e }, Fe = async () => new Promise((e5) => {
540
+ document.hasFocus() ? e5() : globalThis.addEventListener?.("focus", () => {
541
+ e5();
542
+ }, { once: true }), document.activeElement.focus?.();
543
+ }), je = async (e5, t2, n2) => {
544
+ if (_e() === Ee.Safari) return await n2(new Error(Be.Safari));
545
+ try {
546
+ const o2 = async (e6) => {
547
+ try {
548
+ return await e6();
549
+ } catch (e7) {
550
+ if (e7.message?.includes("Document is not focused")) return false;
551
+ throw e7;
552
+ }
553
+ }, r2 = await globalThis?.navigator?.permissions?.query({ name: e5, allowWithoutGesture: true, allowWithoutSanitization: true });
554
+ let i2 = false;
555
+ if ("prompt" === r2.state && (i2 = await o2(t2)), i2 || "granted" !== r2.state || (i2 = await t2()), !i2) return await n2(new Error(r2.state));
556
+ } catch (e6) {
557
+ if ("No valid data on clipboard" === e6.message || "DataError" === e6.name) return;
558
+ return await n2(e6);
559
+ }
560
+ }, Ve = async (e5) => {
561
+ try {
562
+ return await e5.read({ unsanitized: [R] });
563
+ } catch (e6) {
564
+ }
565
+ return await e5.read();
566
+ };
567
+ if (!globalThis.ClipboardItem) {
568
+ const e5 = (e6, t3) => new Blob([t3], { type: e6 });
569
+ class t2 {
570
+ constructor(t3, n2) {
571
+ this._items = {}, this._types = Object.keys(t3);
572
+ const o2 = {}, r2 = Object.keys(t3);
573
+ for (let n3 = 0; n3 < r2.length; n3++) {
574
+ const i2 = r2[n3];
575
+ let l2 = t3[i2];
576
+ o2[i2] = "string" == typeof l2 ? e5(i2, l2) : l2;
577
+ }
578
+ this._items = o2, this._presentationStyle = n2?.presentationStyle ?? "unspecified";
579
+ }
580
+ get types() {
581
+ return this._types;
582
+ }
583
+ getType(e6) {
584
+ return Promise.resolve(this._items[e6]);
585
+ }
586
+ supports(e6) {
587
+ return true;
588
+ }
589
+ }
590
+ globalThis.ClipboardItem = t2;
591
+ }
592
+ const We = async (e5, t2 = R) => new Promise(async (n2, o2) => {
593
+ try {
594
+ const o3 = await (async (e6, t3) => {
595
+ if (!e6) return null;
596
+ const n3 = await Ve(e6);
597
+ let o4 = false;
598
+ for (let e7 = 0; !o4 && n3 && e7 < n3.length; e7++) if (o4 = n3[e7].types.includes(t3), o4) return await n3[e7].getType(t3);
599
+ return o4 ? void 0 : null;
600
+ })(e5, t2);
601
+ if (o3) {
602
+ const e6 = new FileReader();
603
+ e6.onload = () => {
604
+ n2(e6.result);
605
+ }, e6.onerror = () => {
606
+ n2("");
607
+ }, e6.readAsText(o3);
608
+ } else n2("");
609
+ } catch (e6) {
610
+ o2(e6);
611
+ }
612
+ }), He = async (e5, t2 = R) => {
613
+ const n2 = await We(e5, t2);
614
+ if (!n2) return null;
615
+ let o2 = null;
616
+ try {
617
+ o2 = new DOMParser().parseFromString(n2, R);
618
+ } catch (e6) {
619
+ console.warn("Can't parse html from clipboard.");
620
+ }
621
+ return o2;
622
+ }, Ne = "clipboard-uuid", Ue = "web text/uuid", qe = (e5) => `<div style="display:none" ${Ne}="${e5}"/>`, Ke = (e5, t2) => {
623
+ let n2 = null;
624
+ try {
625
+ const o2 = new DOMParser().parseFromString(t2, R);
626
+ o2.body.firstElementChild.setAttribute(Ne, e5), n2 = o2.getElementsByTagName("body")[0].innerHTML;
627
+ } catch (e6) {
628
+ console.warn("Can't embed uuid.", e6);
629
+ }
630
+ return n2;
631
+ }, Ye = (e5, t2) => {
632
+ if (!t2 || !e5) return false;
633
+ try {
634
+ const n2 = t2.querySelectorAll(`[${Ne}="${e5}"]`);
635
+ if (n2 && 1 === n2.length) return true;
636
+ if (t2.querySelector("parsererror")) throw new Error("We are unable to parse node");
637
+ return false;
638
+ } catch (e6) {
639
+ return false;
640
+ }
641
+ };
642
+ class Xe {
643
+ constructor(e5) {
644
+ if (void 0 === e5?.nativeClipboard || true === e5?.nativeClipboard) try {
645
+ this._nativeClipboard = globalThis?.navigator.clipboard;
646
+ } catch (t2) {
647
+ true === e5?.nativeClipboard && console.warn("NativeClipboard option set to true but no native clipboard available.");
648
+ }
649
+ else this._nativeClipboard = false === e5?.nativeClipboard ? null : e5?.nativeClipboard;
650
+ this._disableCheckOnFocus = e5?.disableCheckOnFocus ?? false, this._init();
651
+ }
652
+ async _checkForChanges() {
653
+ this._nativeClipboard && this._state && !this._disableCheckOnFocus && await je("clipboard-read", async () => {
654
+ await Fe();
655
+ const e5 = await We(this._nativeClipboard, Ue);
656
+ if (!this._state) return true;
657
+ if (e5 && e5 === this._state.uuid) return true;
658
+ const t2 = await He(this._nativeClipboard, R);
659
+ return !this._state || (Ye(this._state.uuid, t2) || this.clear(), true);
660
+ }, async (e5) => {
661
+ "denied" === e5?.message || e5.message?.includes("Document is not focused") || _e() === Ee.Safari || console.warn("Unable to detect clipboard changes: ", e5);
662
+ });
663
+ }
664
+ _init() {
665
+ const e5 = this;
666
+ this._listeners = /* @__PURE__ */ new Map(), this._listenersCapture = /* @__PURE__ */ new Map(), this._state = null, this._nativeClipboard && (this._onFocus = () => {
667
+ e5._checkForChanges();
668
+ }, this._onBlur = () => {
669
+ globalThis.addEventListener?.("focus", e5._onFocus, { once: true });
670
+ }, globalThis.addEventListener?.("blur", this._onBlur), this._nativeClipboard.addEventListener("clipboardchange", (t2) => {
671
+ e5._checkForChanges();
672
+ }));
673
+ }
674
+ async read() {
675
+ if (!this._nativeClipboard) return this._state?.items ?? null;
676
+ const e5 = this;
677
+ return await je("clipboard-read", async () => {
678
+ if (await Fe(), this._state?.uuid) {
679
+ const t2 = await We(this._nativeClipboard, Ue);
680
+ if (t2 && t2 === e5._state.uuid) return true;
681
+ const n2 = await He(this._nativeClipboard, R);
682
+ if (Ye(e5._state?.uuid, n2)) return true;
683
+ }
684
+ return e5._state = { items: await Ve(this._nativeClipboard), uuid: null, ref: null }, this.dispatchEvent(new Event("clipboardread")), true;
685
+ }, async (e6) => {
686
+ this.dispatchEvent(new Event("clipboarderrorread"));
687
+ }), this._state?.items ?? [];
688
+ }
689
+ async write(e5) {
690
+ return this._write({ uuid: fe(), items: e5, ref: null });
691
+ }
692
+ async _write(e5) {
693
+ if (!this._nativeClipboard) return this._state = e5, this.dispatchEvent(new Event("clipboardwrite")), this.dispatchEvent(new Event("clipboardchange")), null;
694
+ const t2 = this, n2 = [], o2 = e5.uuid;
695
+ let r2 = e5.items ?? [];
696
+ const i2 = () => {
697
+ t2._state = { uuid: o2, ref: e5.ref, items: n2 }, t2.dispatchEvent(new Event("clipboardwrite")), t2.dispatchEvent(new Event("clipboardchange"));
698
+ };
699
+ await je("clipboard-write", async () => {
700
+ await Fe(), o2 && 0 === r2.length && (r2.push(new ClipboardItem({ [Ue]: new Blob([o2], { type: Ue }) })), r2.push(new ClipboardItem({ [R]: new Blob([qe(o2)], { type: R }) })));
701
+ for (let e6 = 0; e6 < Math.min(1, r2.length); e6++) {
702
+ const t3 = r2[e6];
703
+ let i3 = t3.types.indexOf(R), l2 = null;
704
+ if (-1 !== i3) {
705
+ const e7 = await t3.getType(R);
706
+ l2 = await ke(e7), l2 && (l2 = Ke(o2, l2));
707
+ }
708
+ if (!l2 && t3.types.includes(P)) {
709
+ const e7 = await t3.getType(P);
710
+ if (e7) {
711
+ let t4 = null;
712
+ "string" == typeof e7 ? (console.warn("text as string", e7), t4 = e7) : t4 = await ke(e7), t4 && (l2 = `<div ${Ne}="${o2}">${t4}</div>`);
713
+ }
714
+ }
715
+ if (!l2 && t3.types.includes(O)) {
716
+ const e7 = await t3.getType(O), n3 = Te(await e7.arrayBuffer());
717
+ l2 = `<div ${Ne}="${o2}"><img src="${Re + n3}"/></div>`;
718
+ }
719
+ !l2 && o2 && (l2 = qe(o2));
720
+ const s2 = new Blob([l2 ?? ""], { type: R }), c2 = {};
721
+ for (let e7 = 0; e7 < t3.types.length; e7++) {
722
+ const n3 = t3.types[e7];
723
+ c2[n3] = e7 === i3 ? s2 : t3.getType(n3);
724
+ }
725
+ l2 && -1 === i3 && (c2[R] = s2), o2 && (c2[Ue] = new Blob([o2], { type: Ue })), n2.push(new ClipboardItem(c2));
726
+ }
727
+ try {
728
+ n2 && 0 !== n2.length ? await this._nativeClipboard.write(n2) : await (async (e6) => {
729
+ e6 && await e6.writeText("");
730
+ })(this._nativeClipboard);
731
+ } catch (e6) {
732
+ e6.message?.includes("Document is not focused") || console.warn("Unable to write to native clipboard: ", e6);
733
+ }
734
+ return i2(), true;
735
+ }, async (e6) => {
736
+ this.dispatchEvent(new Event("clipboarderrorwrite")), i2();
737
+ });
738
+ }
739
+ async writeReference(e5) {
740
+ if (!e5) return void this.clear();
741
+ let t2 = null;
742
+ const n2 = {};
743
+ try {
744
+ const t3 = await e5.toText?.() ?? null;
745
+ t3 && (n2[P] = new Blob([t3 ?? ""], { type: P }));
746
+ } catch (e6) {
747
+ t2 = e6;
748
+ }
749
+ try {
750
+ const t3 = await e5.toHtml?.() ?? null;
751
+ t3 && (n2[R] = new Blob([t3], { type: R }));
752
+ } catch (e6) {
753
+ t2 = e6, console.warn("export to html", e6);
754
+ }
755
+ try {
756
+ const t3 = await e5.toImage?.() ?? null;
757
+ t3 && (n2[O] = t3);
758
+ } catch (e6) {
759
+ t2 = e6, console.warn("export to png", e6);
760
+ }
761
+ const o2 = this._write({ uuid: fe(), ref: e5, items: Object.keys(n2).length > 0 ? [new ClipboardItem(n2)] : null });
762
+ if (t2) throw t2;
763
+ return o2;
764
+ }
765
+ clear(e5 = false) {
766
+ this._state && (this._state = null, e5 && this._write({ uuid: null, ref: null, items: null }), this.dispatchEvent(new Event("clipboardwrite")), this.dispatchEvent(new Event("clipboardchange")));
767
+ }
768
+ async readReference() {
769
+ return await this.read(), this._state?.ref ?? null;
770
+ }
771
+ readText() {
772
+ return new Promise(async (e5, t2) => {
773
+ const n2 = await this.read();
774
+ let o2 = null;
775
+ for (let e6 = 0; !o2 && n2 && e6 < n2.length; e6++) n2[e6].types.includes(P) && (o2 = await n2[e6].getType(P));
776
+ if (!o2) return void e5("");
777
+ const r2 = new FileReader();
778
+ r2.onload = () => {
779
+ e5(r2.result);
780
+ }, r2.readAsText(o2), r2.onerror = (e6) => {
781
+ t2(e6);
782
+ };
783
+ });
784
+ }
785
+ async writeText(e5) {
786
+ const t2 = [new ClipboardItem({ [P]: new Blob([e5], { type: P }) })];
787
+ return this._write({ uuid: fe(), items: t2, ref: null });
788
+ }
789
+ addEventListener(e5, t2, n2 = {}) {
790
+ const o2 = n2?.capture ? this._listenersCapture : this._listeners;
791
+ let r2 = o2.get(e5);
792
+ r2 || (r2 = /* @__PURE__ */ new Map(), o2.set(e5, r2)), r2.set(t2, "boolean" == typeof n2 ? {} : n2);
793
+ }
794
+ dispatchEvent(e5) {
795
+ if (!e5) return;
796
+ const t2 = (t3) => {
797
+ const n2 = t3.get(e5.type);
798
+ n2 && n2.forEach((t4, o2) => {
799
+ try {
800
+ "function" == typeof o2 ? o2(e5) : o2.handleEvent && o2.handleEvent(e5), t4.once && n2.delete(o2);
801
+ } catch (e6) {
802
+ console.warn(e6);
803
+ }
804
+ });
805
+ };
806
+ return t2(this._listenersCapture), t2(this._listeners), true;
807
+ }
808
+ removeEventListener(e5, t2, n2) {
809
+ const o2 = n2?.capture ? this._listenersCapture : this._listeners, r2 = o2.get(e5);
810
+ r2 && (r2.delete(t2), 0 === r2.size && o2.delete(e5));
811
+ }
812
+ close() {
813
+ globalThis.removeEventListener?.("focus", this._onFocus), globalThis.removeEventListener?.("blur", this._onBlur);
814
+ }
815
+ }
816
+ var Ge;
817
+ (Ge = Xe || (Xe = {})).ErrorMessages = Be, Ge.Global = new Ge();
818
+ var Ze = "undefined" != typeof window ? window : { screen: {}, navigator: {} }, Je = (Ze.matchMedia || function() {
819
+ return { matches: false };
820
+ }).bind(Ze), Qe = false, et = { get passive() {
821
+ return Qe = true;
822
+ } }, tt = function() {
823
+ };
824
+ Ze.addEventListener && Ze.addEventListener("p", tt, et), Ze.removeEventListener && Ze.removeEventListener("p", tt, false);
825
+ var nt = Qe, ot = "PointerEvent" in Ze, rt = "ontouchstart" in Ze, it = rt || "TouchEvent" in Ze && Je("(any-pointer: coarse)").matches, lt = (Ze.navigator.maxTouchPoints || 0) > 0 || it, st = Ze.navigator.userAgent || "", ct = Je("(pointer: coarse)").matches && /iPad|Macintosh/.test(st) && Math.min(Ze.screen.width || 0, Ze.screen.height || 0) >= 768, at = (Je("(pointer: coarse)").matches || !Je("(pointer: fine)").matches && rt) && !/Windows.*Firefox/.test(st), dt = Je("(any-pointer: fine)").matches || Je("(any-hover: hover)").matches || ct || !rt, ut = !lt || !dt && at ? lt ? "touchOnly" : "mouseOnly" : "hybrid", ht = "mouseOnly" === ut ? "mouse" : "touchOnly" === ut || at ? "touch" : "mouse";
826
+ const ft = Object.freeze(Object.defineProperty({ __proto__: null, deviceType: ut, primaryInput: ht, supportsPassiveEvents: nt, supportsPointerEvents: ot, supportsTouchEvents: it }, Symbol.toStringTag, { value: "Module" })), pt = { Left: "left", Right: "right", Center: "center" }, gt = "shift", wt = "alt", mt = "ctrl", xt = 9, yt = 13, vt = 27, bt = 37, St = 38, Et = 39, _t = 40, It = 113, Ct = 3, Mt = { Horizontal: "horizontal", Vertical: "vertical" }, Tt = (e5, t2) => {
827
+ const n2 = i((...t3) => e5?.(...t3), t2), o2 = l(null);
828
+ o2.current = n2;
829
+ const r2 = i((...e6) => o2.current?.(...e6), []);
830
+ if (o2.current) return r2;
831
+ }, kt = (t2) => {
832
+ const { style: n2, orientation: o2 = Mt.Vertical, ...r2 } = t2, i2 = o2 === Mt.Vertical;
833
+ return e("div", { style: { paddingBottom: "0px", paddingRight: "0px", paddingLeft: i2 ? "0px" : "3px", paddingTop: i2 ? "3px" : "0px", display: "flex", alignItems: "center", justifyContent: "center", ...n2 }, ...r2, children: e("button", { style: { padding: "0", display: "flex", alignItems: "center", justifyContent: "center", border: "none" }, className: `scrollbar-button ${i2 ? "vertical" : "horizontal"} single-button start`, children: e("svg", { width: "9", height: "9", viewBox: "0 0 6 6", style: { opacity: "inherit" }, children: e("path", { d: i2 ? "m 3.7274761,0.68060577 1.11969,1.93863003 1.12075,1.93912 c 0.0895,0.155 0.12152,0.33658 0.0904,0.51283 -0.0311,0.17625 -0.12336,0.33591 -0.26054,0.45091 -0.13715,0.11495 -0.31044,0.17793 -0.4894,0.17781 H 0.83095614 c -0.20186,0 -0.39542,-0.0802 -0.53814,-0.2229 -0.14272,-0.14272 -0.22291,-0.33629 -0.22291,-0.53814 -3e-4,-0.13308 0.0347,-0.26385 0.10147,-0.379 l 1.11872996,-1.94066 1.11921,-1.93864003 c 0.13594,-0.23541 0.38717,-0.38047 0.65905,-0.38047 0.27188,0 0.52311,0.14506 0.65905,0.38047 z" : "m 0.75051,2.3424298 1.93863,-1.11969 1.93912,-1.12075 c 0.155,-0.0895 0.33658,-0.12152 0.51283,-0.0904 0.17625,0.0311 0.33591,0.12336 0.45091,0.26054 0.11495,0.13715 0.17793,0.31044 0.17781,0.4894 v 4.47742 c 0,0.20186 -0.0802,0.39542 -0.2229,0.53814 -0.14272,0.14272 -0.33629,0.22291 -0.53814,0.22291 -0.13308,3e-4 -0.26385,-0.0347 -0.379,-0.10147 L 2.68911,4.7797998 0.75047,3.6605898 C 0.51506,3.5246498 0.37,3.2734198 0.37,3.0015398 c 0,-0.27188 0.14506,-0.52311 0.38047,-0.65905 z" }) }) }) });
834
+ }, Rt = (t2) => {
835
+ const { style: n2, orientation: o2 = Mt.Vertical, ...r2 } = t2, i2 = o2 === Mt.Vertical;
836
+ return e("div", { style: { paddingLeft: "0px", paddingTop: "0px", paddingRight: i2 ? "0px" : "3px", paddingBottom: i2 ? "3px" : "0px", display: "flex", alignItems: "center", justifyContent: "center", ...n2 }, ...r2, children: e("button", { style: { padding: "0", display: "flex", alignItems: "center", justifyContent: "center", border: "none" }, className: `scrollbar-button ${i2 ? "vertical" : "horizontal"} single-button end`, children: e("svg", { width: "9", height: "9", viewBox: "0 0 6 6", style: { opacity: "inherit" }, children: e("path", { d: i2 ? "M 2.412334,5.319396 1.292644,3.3807659 0.17189405,1.4416459 c -0.0895,-0.155 -0.12152,-0.33658 -0.0904,-0.51282998 0.0311,-0.17625 0.12336,-0.33591 0.26054,-0.45091 0.13715,-0.11495 0.31044,-0.17793 0.4894,-0.17781 H 5.308854 c 0.20186,0 0.39542,0.0802 0.53814,0.2229 0.14272,0.14272 0.22291,0.33629 0.22291,0.53813998 3e-4,0.13308 -0.0347,0.26385 -0.10147,0.379 l -1.11873,1.94066 -1.11921,1.9386401 c -0.13594,0.23541 -0.38717,0.38047 -0.65905,0.38047 -0.27188,0 -0.52311,-0.14506 -0.65905,-0.38047 z" : "m 5.3893002,3.6575719 -1.9386301,1.11969 -1.93912,1.12075 c -0.155,0.0895 -0.33658,0.12152 -0.51282997,0.0904 -0.17625,-0.0311 -0.33591,-0.12336 -0.45091,-0.26054 -0.11495,-0.13715 -0.17793,-0.31044 -0.17781,-0.4894 V 0.76105195 c 0,-0.20186 0.0802,-0.39542 0.2229,-0.53814 C 0.73562013,0.08019195 0.92919013,1.9467784e-6 1.1310401,1.9467784e-6 1.2641201,-2.9805322e-4 1.3948901,0.03470195 1.5100401,0.10147195 l 1.94066,1.11872995 1.9386401,1.11921 c 0.23541,0.13594 0.38047,0.38717 0.38047,0.65905 0,0.27188 -0.14506,0.52311 -0.38047,0.65905 z" }) }) }) });
837
+ }, Pt = (e5, t2, n2, o2, r2 = 0) => {
838
+ for (let r3 = 0; r3 < n2.length; r3++) {
839
+ const i2 = n2[r3].getBoundingClientRect();
840
+ let l2 = i2.left - t2, s2 = l2 + i2.width;
841
+ if (o2) {
842
+ if (l2 < e5 && s2 >= e5) return l2;
843
+ } else if (Math.ceil(s2) > Math.ceil(e5) + 2) return s2;
844
+ }
845
+ return r2;
846
+ };
847
+ /**
848
+ * @license @sheetxl/utils-react - Utils React - Utilities for React capabilities needed for all SheetXL components. - v0.1.95
849
+ *
850
+ * (C) 2025-present SheetXL Inc. & Michael T. Ford
851
+ * License: The license can be found at https://www.sheetxl.com/license.
852
+ */
853
+ Object.freeze(Object.defineProperty({ __proto__: null, getScrollTo: Pt }, Symbol.toStringTag, { value: "Module" }));
854
+ const Ot = r(a((n2, o2) => {
855
+ const { offset: r2 = 0, totalSize: c2 = 0, viewportSize: a2 = 0, style: u2, className: f2, orientation: p2 = Mt.Vertical, onScrollOffset: m2, onScroll: x2, showCustomScrollButtons: y2 = false, scrollButtonIncrement: v2 = 200, scrollButtonInitialRepeatDelay: b2 = 260, scrollButtonAdditionalRepeatDelay: S2 = 120, createScrollStartButton: E2 = kt, createScrollEndButton: _2 = Rt, ...I2 } = n2, C2 = Tt(x2, [x2]), M2 = l(null), [T2, { width: k2, height: R2 }] = w(), [P2, { width: O2, height: L2 }] = w(), D2 = p2 === Mt.Vertical, z2 = D2 ? "top" : "left", A2 = D2 ? "scrollTop" : "scrollLeft", $2 = D2 ? R2 : k2, B2 = D2 ? L2 : O2, [F2, j2] = h(null);
856
+ s(() => {
857
+ null !== F2 && M2.current && M2.current.scrollTo({ behavior: "smooth", [z2]: F2 });
858
+ }, [F2, D2]);
859
+ const V2 = i((e5, t2 = false) => {
860
+ if (!M2.current) return 0;
861
+ const n3 = M2.current.querySelector(".scrollbar-viewport"), o3 = n3.getBoundingClientRect(), r3 = n3.children, i2 = t2 ? 0 : Pt(e5, o3[z2], r3, true, Math.max(0, e5 - v2));
862
+ return j2(i2), Math.max(0, i2);
863
+ }, []), W2 = i((e5, t2 = false) => {
864
+ if (!M2.current) return 0;
865
+ const n3 = M2.current.querySelector(".scrollbar-viewport"), o3 = n3.getBoundingClientRect(), r3 = n3.children, i2 = Math.ceil(B2 - $2), l2 = t2 ? i2 : Pt(e5, o3[z2], r3, false, Math.max(0, e5 + v2));
866
+ return j2(l2), Math.min(i2, l2);
867
+ }, [B2, $2]), H2 = l(null), N2 = i((e5) => {
868
+ H2.current = r2;
869
+ const t2 = e5.target[A2];
870
+ m2(t2, a2, c2), C2?.(e5);
871
+ }, [m2, a2, c2, r2]);
872
+ s(() => {
873
+ const e5 = H2.current;
874
+ H2.current = null, r2 !== e5 && (M2.current[A2] = r2);
875
+ }, [r2, A2]);
876
+ const U2 = l(null), q2 = l(null), K2 = i(() => {
877
+ U2.current && (clearTimeout(U2.current), U2.current = null, q2.current = null);
878
+ }, []), Y2 = i((e5, t2, n3, o3 = b2) => {
879
+ q2.current = e5, U2.current = setTimeout(() => {
880
+ const t3 = n3 ? V2(q2.current || e5) : W2(q2.current || e5);
881
+ t3 !== q2.current ? Y2(t3, false, n3, S2) : K2();
882
+ }, t2 ? 0 : o3);
883
+ }, [V2, W2, K2]);
884
+ s(() => () => K2(), [K2]);
885
+ const X2 = r2, G2 = d(() => {
886
+ if (!y2) return null;
887
+ const e5 = { orientation: p2, disabled: Math.floor(X2) <= 0 || 0 === Math.floor(B2 - $2), onMouseUp: K2, onMouseLeave: K2, onMouseDown: () => Y2(X2, true, true) };
888
+ return E2?.(e5);
889
+ }, [y2, p2, X2, F2, B2, $2]), Z2 = d(() => {
890
+ if (!y2) return null;
891
+ const e5 = { orientation: p2, disabled: Math.floor(B2 - $2) <= Math.ceil(X2), onMouseUp: K2, onMouseLeave: K2, onMouseDown: () => Y2(X2, true, false) };
892
+ return _2?.(e5);
893
+ }, [y2, p2, X2, F2, B2, $2]);
894
+ return t("div", { ref: o2, style: { display: "flex", flex: "1", flexDirection: D2 ? "column" : "row", padding: "0", ...u2 }, className: g("_sheetxl-scrollbar_18qzf_11", f2), ...I2, children: [G2, e("div", { className: "pseudo-scrollbar", style: { flex: "1 1 100%", display: "flex", boxSizing: "content-box", flexDirection: D2 ? "column" : "row", justifyContent: "center", alignItems: "center" }, ref: T2, children: e("div", { tabIndex: -1, style: { flex: "1 1 100%", overflowY: D2 ? "scroll" : "hidden", overflowX: D2 ? "hidden" : "scroll", position: "relative", willChange: "transform" }, onScroll: N2, ref: M2, children: e("div", { ref: P2, style: { position: "absolute", height: D2 ? c2 - a2 + (R2 ?? 0) : 1, width: D2 ? 1 : c2 - a2 + (k2 ?? 0) }, className: "scrollbar-viewport" }) }) }), Z2] });
895
+ }));
896
+ Ot.displayName = "Scrollbar";
897
+ let Lt = Date.now, Dt = {}, zt = 1;
898
+ const At = (e5) => {
899
+ let t2 = null !== Dt[e5];
900
+ return t2 && (Dt[e5] = null), t2;
901
+ }, $t = (e5, t2, n2, o2 = 0, r2) => {
902
+ let i2 = Lt(), l2 = i2, s2 = 0, c2 = 0, a2 = zt++;
903
+ if (a2 % 20 == 0) {
904
+ const e6 = {};
905
+ for (let t3 in Dt) e6[t3] = true;
906
+ Dt = e6;
907
+ }
908
+ const d2 = function(u2) {
909
+ const h2 = true !== u2, f2 = Lt();
910
+ if (!Dt[a2] || t2 && !t2(a2)) return Dt[a2] = null, void n2(60 - c2 / ((f2 - i2) / 1e3), a2, false);
911
+ if (h2) {
912
+ const e6 = Math.round((f2 - l2) / 16.666666666666668) - 1;
913
+ for (let t3 = 0; t3 < Math.min(e6, 4); t3++) d2(true), c2++;
914
+ }
915
+ o2 && (s2 = (f2 - i2) / o2, s2 > 1 && (s2 = 1));
916
+ const p2 = r2 ? r2(s2) : s2;
917
+ false !== e5(p2, f2, h2) && 1 !== s2 || !h2 ? h2 && (l2 = f2, requestAnimationFrame(d2)) : (Dt[a2] = null, n2(60 - c2 / ((f2 - i2) / 1e3), a2, 1 === s2 || void 0 === o2));
918
+ };
919
+ return Dt[a2] = true, requestAnimationFrame(d2), a2;
920
+ };
921
+ var Bt = function() {
922
+ }, Ft = function(e5) {
923
+ return Math.pow(e5 - 1, 3) + 1;
924
+ }, jt = function(e5) {
925
+ return (e5 /= 0.5) < 1 ? 0.5 * Math.pow(e5, 3) : 0.5 * (Math.pow(e5 - 2, 3) + 2);
926
+ }, Vt = function(e5, t2) {
927
+ for (var n2 in this.__callback = e5, this.options = { scrollingX: true, scrollingY: true, animating: true, animationDuration: 250, bouncing: true, locking: true, paging: false, snapping: false, zooming: false, minZoom: 0.5, maxZoom: 3, speedMultiplier: 1, scrollingComplete: Bt, penetrationDeceleration: 0.03, penetrationAcceleration: 0.08 }, t2) this.options[n2] = t2[n2];
928
+ };
929
+ Vt.prototype = { __isSingleTouch: false, __isTracking: false, __didDecelerationComplete: false, __isGesturing: false, __isDragging: false, __isDecelerating: false, __isAnimating: false, __clientLeft: 0, __clientTop: 0, __clientWidth: 0, __clientHeight: 0, __contentWidth: 0, __contentHeight: 0, __snapWidth: 100, __snapHeight: 100, __zoomLevel: 1, __scrollLeft: 0, __scrollTop: 0, __maxScrollLeft: 0, __maxScrollTop: 0, __scheduledLeft: 0, __scheduledTop: 0, __scheduledZoom: 0, __lastTouchLeft: null, __lastTouchTop: null, __lastTouchMove: null, __positions: null, __minDecelerationScrollLeft: null, __minDecelerationScrollTop: null, __maxDecelerationScrollLeft: null, __maxDecelerationScrollTop: null, __decelerationVelocityX: null, __decelerationVelocityY: null, setDimensions: function(e5, t2, n2, o2) {
930
+ null !== e5 && (this.__clientWidth = e5), null !== t2 && (this.__clientHeight = t2), null !== n2 && (this.__contentWidth = n2), null !== o2 && (this.__contentHeight = o2), this.__computeScrollMax(), this.scrollTo(this.__scrollLeft, this.__scrollTop, true);
931
+ }, setPosition: function(e5, t2) {
932
+ this.__clientLeft = e5 || 0, this.__clientTop = t2 || 0;
933
+ }, setSnapSize: function(e5, t2) {
934
+ this.__snapWidth = e5, this.__snapHeight = t2;
935
+ }, getValues: function() {
936
+ return { left: this.__scrollLeft, top: this.__scrollTop, right: this.__scrollLeft + this.__clientWidth / this.__zoomLevel, bottom: this.__scrollTop + this.__clientHeight / this.__zoomLevel, zoom: this.__zoomLevel };
937
+ }, getPoint: function(e5, t2) {
938
+ var n2 = this.getValues();
939
+ return { left: e5 / n2.zoom, top: t2 / n2.zoom };
940
+ }, getScrollMax: function() {
941
+ return { left: this.__maxScrollLeft, top: this.__maxScrollTop };
942
+ }, zoomTo: function(e5, t2, n2, o2, r2) {
943
+ if (!this.options.zooming) throw new Error("Zooming is not enabled!");
944
+ r2 && (this.__zoomComplete = r2), this.__isDecelerating && (At(this.__isDecelerating), this.__isDecelerating = false);
945
+ var i2 = this.__zoomLevel;
946
+ void 0 === n2 && (n2 = this.__clientWidth / 2), void 0 === o2 && (o2 = this.__clientHeight / 2), e5 = Math.max(Math.min(e5, this.options.maxZoom), this.options.minZoom), this.__computeScrollMax(e5);
947
+ var l2 = e5 / i2, s2 = l2 * (this.__scrollLeft + n2) - n2, c2 = l2 * (this.__scrollTop + o2) - o2;
948
+ s2 > this.__maxScrollLeft ? s2 = this.__maxScrollLeft : s2 < 0 && (s2 = 0), c2 > this.__maxScrollTop ? c2 = this.__maxScrollTop : c2 < 0 && (c2 = 0), this.__publish(s2, c2, e5, t2);
949
+ }, zoomBy: function(e5, t2, n2, o2, r2) {
950
+ this.zoomTo(this.__zoomLevel * e5, t2, n2, o2, r2);
951
+ }, scrollTo: function(e5, t2, n2, o2) {
952
+ if (this.__isDecelerating && (At(this.__isDecelerating), this.__isDecelerating = false), void 0 !== o2 && o2 !== this.__zoomLevel) {
953
+ if (!this.options.zooming) throw new Error("Zooming is not enabled!");
954
+ e5 *= o2, t2 *= o2, this.__computeScrollMax(o2);
955
+ } else o2 = this.__zoomLevel;
956
+ this.options.scrollingX ? this.options.paging ? e5 = Math.round(e5 / this.__clientWidth) * this.__clientWidth : this.options.snapping && (e5 = Math.round(e5 / this.__snapWidth) * this.__snapWidth) : e5 = this.__scrollLeft, this.options.scrollingY ? this.options.paging ? t2 = Math.round(t2 / this.__clientHeight) * this.__clientHeight : this.options.snapping && (t2 = Math.round(t2 / this.__snapHeight) * this.__snapHeight) : t2 = this.__scrollTop, e5 = Math.max(Math.min(this.__maxScrollLeft, e5), 0), t2 = Math.max(Math.min(this.__maxScrollTop, t2), 0), e5 === this.__scrollLeft && t2 === this.__scrollTop && (n2 = false), this.__publish(e5, t2, o2, n2);
957
+ }, scrollBy: function(e5, t2, n2) {
958
+ var o2 = this.__isAnimating ? this.__scheduledLeft : this.__scrollLeft, r2 = this.__isAnimating ? this.__scheduledTop : this.__scrollTop;
959
+ this.scrollTo(o2 + (e5 || 0), r2 + (t2 || 0), n2);
960
+ }, doMouseZoom: function(e5, t2, n2, o2) {
961
+ var r2 = e5 > 0 ? 0.97 : 1.03;
962
+ return this.zoomTo(this.__zoomLevel * r2, false, n2 - this.__clientLeft, o2 - this.__clientTop);
963
+ }, doTouchStart: function(e5, t2) {
964
+ if (void 0 === e5.length) throw new Error("Invalid touch list: " + e5);
965
+ if (t2 instanceof Date && (t2 = t2.valueOf()), "number" != typeof t2) throw new Error("Invalid timestamp value: " + t2);
966
+ var n2, o2;
967
+ this.__interruptedAnimation = true, this.__isDecelerating && (At(this.__isDecelerating), this.__isDecelerating = false, this.__interruptedAnimation = true), this.__isAnimating && (At(this.__isAnimating), this.__isAnimating = false, this.__interruptedAnimation = true);
968
+ var r2 = 1 === e5.length;
969
+ r2 ? (n2 = e5[0].pageX, o2 = e5[0].pageY) : (n2 = Math.abs(e5[0].pageX + e5[1].pageX) / 2, o2 = Math.abs(e5[0].pageY + e5[1].pageY) / 2), this.__initialTouchLeft = n2, this.__initialTouchTop = o2, this.__zoomLevelStart = this.__zoomLevel, this.__lastTouchLeft = n2, this.__lastTouchTop = o2, this.__lastTouchMove = t2, this.__lastScale = 1, this.__enableScrollX = !r2 && this.options.scrollingX, this.__enableScrollY = !r2 && this.options.scrollingY, this.__isTracking = true, this.__didDecelerationComplete = false, this.__isDragging = !r2, this.__isSingleTouch = r2, this.__positions = [];
970
+ }, doTouchMove: function(e5, t2, n2) {
971
+ if (void 0 === e5.length) throw new Error("Invalid touch list: " + e5);
972
+ if (t2 instanceof Date && (t2 = t2.valueOf()), "number" != typeof t2) throw new Error("Invalid timestamp value: " + t2);
973
+ if (this.__isTracking) {
974
+ var o2, r2;
975
+ 2 === e5.length ? (o2 = Math.abs(e5[0].pageX + e5[1].pageX) / 2, r2 = Math.abs(e5[0].pageY + e5[1].pageY) / 2) : (o2 = e5[0].pageX, r2 = e5[0].pageY);
976
+ var i2 = this.__positions;
977
+ if (this.__isDragging) {
978
+ var l2 = o2 - this.__lastTouchLeft, s2 = r2 - this.__lastTouchTop, c2 = this.__scrollLeft, a2 = this.__scrollTop, d2 = this.__zoomLevel;
979
+ if (void 0 !== n2 && this.options.zooming) {
980
+ var u2 = d2;
981
+ if (d2 = d2 / this.__lastScale * n2, u2 !== (d2 = Math.max(Math.min(d2, this.options.maxZoom), this.options.minZoom))) {
982
+ var h2 = o2 - this.__clientLeft, f2 = r2 - this.__clientTop;
983
+ c2 = (h2 + c2) * d2 / u2 - h2, a2 = (f2 + a2) * d2 / u2 - f2, this.__computeScrollMax(d2);
984
+ }
985
+ }
986
+ if (this.__enableScrollX) {
987
+ c2 -= l2 * this.options.speedMultiplier;
988
+ var p2 = this.__maxScrollLeft;
989
+ (c2 > p2 || c2 < 0) && (this.options.bouncing ? c2 += l2 / 2 * this.options.speedMultiplier : c2 = c2 > p2 ? p2 : 0);
990
+ }
991
+ if (this.__enableScrollY) {
992
+ a2 -= s2 * this.options.speedMultiplier;
993
+ var g2 = this.__maxScrollTop;
994
+ (a2 > g2 || a2 < 0) && (this.options.bouncing ? a2 += s2 / 2 * this.options.speedMultiplier : a2 = a2 > g2 ? g2 : 0);
995
+ }
996
+ i2.length > 60 && i2.splice(0, 30), i2.push(c2, a2, t2), this.__publish(c2, a2, d2);
997
+ } else {
998
+ var w2 = this.options.locking ? 3 : 0, m2 = Math.abs(o2 - this.__initialTouchLeft), x2 = Math.abs(r2 - this.__initialTouchTop);
999
+ this.__enableScrollX = this.options.scrollingX && m2 >= w2, this.__enableScrollY = this.options.scrollingY && x2 >= w2, i2.push(this.__scrollLeft, this.__scrollTop, t2), this.__isDragging = (this.__enableScrollX || this.__enableScrollY) && (m2 >= 5 || x2 >= 5), this.__isDragging && (this.__interruptedAnimation = false);
1000
+ }
1001
+ this.__lastTouchLeft = o2, this.__lastTouchTop = r2, this.__lastTouchMove = t2, this.__lastScale = n2;
1002
+ }
1003
+ }, doTouchEnd: function(e5) {
1004
+ if (e5 instanceof Date && (e5 = e5.valueOf()), "number" != typeof e5) throw new Error("Invalid timestamp value: " + e5);
1005
+ if (this.__isTracking) {
1006
+ if (this.__isTracking = false, this.__isDragging) if (this.__isDragging = false, this.__isSingleTouch && this.options.animating && e5 - this.__lastTouchMove <= 100) {
1007
+ for (var t2 = this.__positions, n2 = t2.length - 1, o2 = n2, r2 = n2; r2 > 0 && t2[r2] > this.__lastTouchMove - 100; r2 -= 3) o2 = r2;
1008
+ if (o2 !== n2) {
1009
+ var i2 = t2[n2] - t2[o2], l2 = this.__scrollLeft - t2[o2 - 2], s2 = this.__scrollTop - t2[o2 - 1];
1010
+ this.__decelerationVelocityX = l2 / i2 * (1e3 / 60), this.__decelerationVelocityY = s2 / i2 * (1e3 / 60);
1011
+ var c2 = this.options.paging || this.options.snapping ? 4 : 1;
1012
+ (Math.abs(this.__decelerationVelocityX) > c2 || Math.abs(this.__decelerationVelocityY) > c2) && this.__startDeceleration(e5);
1013
+ } else this.options.scrollingComplete();
1014
+ } else e5 - this.__lastTouchMove > 100 && this.options.scrollingComplete();
1015
+ this.__isDecelerating || ((this.__interruptedAnimation || this.__isDragging) && this.options.scrollingComplete(), this.scrollTo(this.__scrollLeft, this.__scrollTop, true, this.__zoomLevel)), this.__positions.length = 0;
1016
+ }
1017
+ }, __publish: function(e5, t2, n2, o2) {
1018
+ var r2 = this.__isAnimating;
1019
+ if (r2 && (At(r2), this.__isAnimating = false), o2 && this.options.animating) {
1020
+ this.__scheduledLeft = e5, this.__scheduledTop = t2, this.__scheduledZoom = n2;
1021
+ var i2 = this.__scrollLeft, l2 = this.__scrollTop, s2 = this.__zoomLevel, c2 = e5 - i2, a2 = t2 - l2, d2 = n2 - s2, u2 = function(e6, t3, n3) {
1022
+ n3 && (this.__scrollLeft = i2 + c2 * e6, this.__scrollTop = l2 + a2 * e6, this.__zoomLevel = s2 + d2 * e6, this.__callback && this.__callback(this.__scrollLeft, this.__scrollTop, this.__zoomLevel));
1023
+ }.bind(this), h2 = function(e6) {
1024
+ return this.__isAnimating === e6;
1025
+ }.bind(this), f2 = function(e6, t3, n3) {
1026
+ t3 === this.__isAnimating && (this.__isAnimating = false), (this.__didDecelerationComplete || n3) && this.options.scrollingComplete(), this.options.zooming && (this.__computeScrollMax(), this.__zoomComplete && (this.__zoomComplete(), this.__zoomComplete = null));
1027
+ }.bind(this);
1028
+ this.__isAnimating = $t(u2, h2, f2, this.options.animationDuration, r2 ? Ft : jt);
1029
+ } else this.__scheduledLeft = this.__scrollLeft = e5, this.__scheduledTop = this.__scrollTop = t2, this.__scheduledZoom = this.__zoomLevel = n2, this.__callback && this.__callback(e5, t2, n2), this.options.zooming && (this.__computeScrollMax(), this.__zoomComplete && (this.__zoomComplete(), this.__zoomComplete = null));
1030
+ }, __computeScrollMax: function(e5) {
1031
+ void 0 === e5 && (e5 = this.__zoomLevel), this.__maxScrollLeft = Math.max(this.__contentWidth * e5 - this.__clientWidth, 0), this.__maxScrollTop = Math.max(this.__contentHeight * e5 - this.__clientHeight, 0);
1032
+ }, __startDeceleration: function(e5) {
1033
+ if (this.options.paging) {
1034
+ var t2 = Math.max(Math.min(this.__scrollLeft, this.__maxScrollLeft), 0), n2 = Math.max(Math.min(this.__scrollTop, this.__maxScrollTop), 0), o2 = this.__clientWidth, r2 = this.__clientHeight;
1035
+ this.__minDecelerationScrollLeft = Math.floor(t2 / o2) * o2, this.__minDecelerationScrollTop = Math.floor(n2 / r2) * r2, this.__maxDecelerationScrollLeft = Math.ceil(t2 / o2) * o2, this.__maxDecelerationScrollTop = Math.ceil(n2 / r2) * r2;
1036
+ } else this.__minDecelerationScrollLeft = 0, this.__minDecelerationScrollTop = 0, this.__maxDecelerationScrollLeft = this.__maxScrollLeft, this.__maxDecelerationScrollTop = this.__maxScrollTop;
1037
+ var i2 = function(e6, t3, n3) {
1038
+ this.__stepThroughDeceleration(n3);
1039
+ }.bind(this), l2 = this.options.snapping ? 4 : 0.1, s2 = function() {
1040
+ var e6 = Math.abs(this.__decelerationVelocityX) >= l2 || Math.abs(this.__decelerationVelocityY) >= l2;
1041
+ return e6 || (this.__didDecelerationComplete = true), e6;
1042
+ }.bind(this), c2 = function(e6, t3, n3) {
1043
+ this.__isDecelerating = false, this.__didDecelerationComplete && this.options.scrollingComplete(), this.scrollTo(this.__scrollLeft, this.__scrollTop, this.options.snapping);
1044
+ }.bind(this);
1045
+ this.__isDecelerating = $t(i2, s2, c2);
1046
+ }, __stepThroughDeceleration: function(e5) {
1047
+ var t2 = this.__scrollLeft + this.__decelerationVelocityX, n2 = this.__scrollTop + this.__decelerationVelocityY;
1048
+ if (!this.options.bouncing) {
1049
+ var o2 = Math.max(Math.min(this.__maxDecelerationScrollLeft, t2), this.__minDecelerationScrollLeft);
1050
+ o2 !== t2 && (t2 = o2, this.__decelerationVelocityX = 0);
1051
+ var r2 = Math.max(Math.min(this.__maxDecelerationScrollTop, n2), this.__minDecelerationScrollTop);
1052
+ r2 !== n2 && (n2 = r2, this.__decelerationVelocityY = 0);
1053
+ }
1054
+ if (e5 ? this.__publish(t2, n2, this.__zoomLevel) : (this.__scrollLeft = t2, this.__scrollTop = n2), this.options.paging || (this.__decelerationVelocityX *= 0.95, this.__decelerationVelocityY *= 0.95), this.options.bouncing) {
1055
+ var i2 = 0, l2 = 0, s2 = this.options.penetrationDeceleration, c2 = this.options.penetrationAcceleration;
1056
+ t2 < this.__minDecelerationScrollLeft ? i2 = this.__minDecelerationScrollLeft - t2 : t2 > this.__maxDecelerationScrollLeft && (i2 = this.__maxDecelerationScrollLeft - t2), n2 < this.__minDecelerationScrollTop ? l2 = this.__minDecelerationScrollTop - n2 : n2 > this.__maxDecelerationScrollTop && (l2 = this.__maxDecelerationScrollTop - n2), 0 !== i2 && (i2 * this.__decelerationVelocityX <= 0 ? this.__decelerationVelocityX += i2 * s2 : this.__decelerationVelocityX = i2 * c2), 0 !== l2 && (l2 * this.__decelerationVelocityY <= 0 ? this.__decelerationVelocityY += l2 * s2 : this.__decelerationVelocityY = l2 * c2);
1057
+ }
1058
+ } };
1059
+ const Wt = /* @__PURE__ */ new Set(["INPUT", "TEXTAREA", "SELECT"]), Ht = {};
1060
+ function Nt() {
1061
+ return ft;
1062
+ }
1063
+ const Ut = Object.freeze(Object.defineProperty({ __proto__: null, EmptyCssProperties: Ht, boundPixel: function(e5, t2 = false, n2 = 0) {
1064
+ return e5;
1065
+ }, createSyntheticEvent: (e5) => {
1066
+ let t2 = false, n2 = false;
1067
+ return { nativeEvent: e5, currentTarget: e5.currentTarget, target: e5.target, bubbles: e5.bubbles, cancelable: e5.cancelable, defaultPrevented: e5.defaultPrevented, eventPhase: e5.eventPhase, isTrusted: e5.isTrusted, preventDefault: () => {
1068
+ t2 = true, e5.preventDefault();
1069
+ }, isDefaultPrevented: () => t2, stopPropagation: () => {
1070
+ n2 = true, e5.stopPropagation();
1071
+ }, isPropagationStopped: () => n2, persist: () => {
1072
+ }, timeStamp: e5.timeStamp, type: e5.type };
1073
+ }, detectIt: Nt, focusableNodeNames: Wt, toPrettyKeyCode: (e5) => "BracketLeft" === e5 ? "[" : "BracketRight" === e5 ? "]" : Me.camelToPrettyCase(e5) }, Symbol.toStringTag, { value: "Module" })), qt = [];
1074
+ function Kt(e5, t2, n2 = qt) {
1075
+ const o2 = l(null);
1076
+ return c(e5, () => {
1077
+ if (!o2.current) return;
1078
+ const e6 = o2.current, n3 = t2?.();
1079
+ if (!n3 || "object" != typeof n3) throw new Error("attributes must return a plain object of values");
1080
+ const r2 = Object.keys(n3), i2 = r2.length;
1081
+ for (let t3 = 0; t3 < i2; t3++) {
1082
+ const o3 = r2[t3], i3 = n3[o3];
1083
+ Object.defineProperty(e6, o3, { value: i3, writable: true, configurable: true, enumerable: true });
1084
+ }
1085
+ return e6;
1086
+ }, n2), o2;
1087
+ }
1088
+ const Yt = (t2) => e(Ot, { ...t2 }), Xt = ({ width: t2, height: n2 }) => e("div", { className: "corner", style: { minWidth: `${t2}px`, width: `${t2}px`, minHeight: `${n2}px`, height: `${n2}px` } }), Gt = r(a((o2, r2) => {
1089
+ const { children: c2, viewport: a2, onScrollViewport: u2, showHorizontalScrollbar: h2 = true, showVerticalScrollbar: f2 = true, createScrollCorner: p2 = Xt, createHorizontalScrollbar: g2 = Yt, createVerticalScrollbar: m2 = Yt, style: x2, touchElement: y2, disableTouch: v2, ...b2 } = o2, S2 = Tt(u2, [u2]), E2 = Kt(r2, () => ({ isScrollPane: () => true }), []), _2 = l(null);
1090
+ s(() => {
1091
+ _2.current && (_2.current.__scrollTop === a2?.top && _2.current.__scrollLeft !== !a2?.left || _2.current?.scrollTo(a2?.left, a2?.top, false));
1092
+ }, [a2?.left, a2?.top, y2]);
1093
+ const I2 = i((e5, t2) => {
1094
+ S2?.({ left: e5, top: t2 });
1095
+ }, []), C2 = i((e5) => {
1096
+ _2.current?.doTouchStart(e5.touches, e5.timeStamp);
1097
+ }, []), M2 = i((e5) => {
1098
+ e5.preventDefault(), _2.current?.doTouchMove(e5.touches, e5.timeStamp);
1099
+ }, []), T2 = i((e5) => {
1100
+ _2.current?.doTouchEnd(e5.timeStamp);
1101
+ }, []), k2 = i(({ containerWidth: e5, containerHeight: t2, totalWidth: n2, totalHeight: o3 }) => {
1102
+ _2.current.setDimensions(e5, t2, n2, o3);
1103
+ }, []);
1104
+ s(() => {
1105
+ const e5 = y2 ?? E2.current;
1106
+ if (!v2 && Nt().supportsTouchEvents && e5 && a2) {
1107
+ if (!_2.current) {
1108
+ const e6 = { scrollingX: true, scrollingY: true, decelerationRate: 0.95, penetrationAcceleration: 0.08 };
1109
+ _2.current = new Vt(I2, e6);
1110
+ }
1111
+ Nt().supportsTouchEvents && (e5.addEventListener("touchstart", C2), e5.addEventListener("touchend", T2), e5.addEventListener("touchmove", M2)), k2({ containerWidth: a2?.width, containerHeight: a2?.height, totalWidth: a2?.totalWidth, totalHeight: a2?.totalHeight });
1112
+ }
1113
+ return () => {
1114
+ e5?.removeEventListener("touchstart", C2), e5?.removeEventListener("touchend", T2), e5?.removeEventListener("touchmove", M2);
1115
+ };
1116
+ }, [a2?.width, a2?.height, a2?.totalWidth, a2?.totalHeight, v2, y2]);
1117
+ const [R2, { width: P2 }] = w(), [O2, { height: L2 }] = w(), D2 = d(() => {
1118
+ const t2 = m2({ orientation: Mt.Vertical, offset: a2?.top, viewportSize: a2?.height, totalSize: a2?.totalHeight, onScrollOffset: (e5) => {
1119
+ S2?.({ top: e5 });
1120
+ } });
1121
+ return e("div", { style: { display: "flex", flex: "0" }, ref: R2, children: t2 });
1122
+ }, [m2, a2?.top, a2?.height, a2?.totalHeight]), z2 = d(() => {
1123
+ const o3 = g2({ orientation: Mt.Horizontal, offset: a2?.left, viewportSize: a2?.width, totalSize: a2?.totalWidth, onScrollOffset: (e5) => S2?.({ left: e5 }) });
1124
+ return t("div", { style: { display: "flex", flex: "none", flexDirection: "row", alignItems: "stretch", justifyContent: "center" }, children: [e("div", { style: { display: "flex", flex: "1 1 100%", flexDirection: "column", width: `calc(100% - ${P2}px)` }, children: e("div", { ref: O2, className: "sizer", children: o3 }) }), f2 ? p2({ width: P2, height: L2 }) : e(n, {})] });
1125
+ }, [g2, a2?.left, a2?.width, a2?.totalWidth, f2, p2, P2, L2]);
1126
+ return e("div", { style: { position: "relative", display: "flex", minWidth: f2 ? `${P2}px` : void 0, minHeight: h2 ? `${L2}px` : void 0, ...x2 }, ...b2, ref: E2, children: t("div", { style: { position: "relative", width: "100%", flex: "1 1 100%", display: "flex", flexDirection: "column", boxSizing: "border-box" }, children: [t("div", { style: { display: "flex", flex: "1 1 100%", overflow: "hidden" }, children: [e("div", { style: { display: "flex", flex: "1 1 100%", overflow: "hidden" }, children: c2 }), f2 ? D2 : e(n, {})] }), h2 ? z2 : e(n, {})] }) });
1127
+ }));
1128
+ Gt.displayName = "ScrollPane";
1129
+ const Zt = () => {
1130
+ const e5 = document.fullscreenElement;
1131
+ return e5 ? e5.querySelector(".fullscreen-portal-root") || e5 : document.body;
1132
+ };
1133
+ let Jt = 0;
1134
+ function Qt() {
1135
+ return s(() => {
1136
+ function e5() {
1137
+ const e6 = document.fullscreenElement;
1138
+ if (!e6) return;
1139
+ let t2 = e6.querySelector(".fullscreen-portal-root");
1140
+ t2 || (t2 = document.createElement("div"), t2.className = "fullscreen-portal-root _fullscreen-portal-root_5qk7s_7", e6.appendChild(t2));
1141
+ }
1142
+ return Jt++, e5(), document.addEventListener("fullscreenchange", e5), () => {
1143
+ document.removeEventListener("fullscreenchange", e5), Jt--, Jt <= 0 && (document.querySelectorAll(".fullscreen-portal-root").forEach((e6) => {
1144
+ e6.parentNode && e6.parentNode.removeChild(e6);
1145
+ }), Jt = 0);
1146
+ };
1147
+ }, []), { getPortalContainer: Zt };
1148
+ }
1149
+ const en = 100, tn = 100, nn = 1e6, on = 100, rn = 50;
1150
+ r(a((t2, n2) => {
1151
+ const { offset: o2 = 0, viewportSize: r2 = 0, totalSize: s2 = 0, minSize: c2 = 0, endGap: a2 = en, endScrollIncrement: d2 = tn, style: f2 = Ht, onMouseDown: p2, onScrollOffset: g2, onScroll: w2, scaleLimit: m2 = nn, scaleFactor: x2 = on, precisionFactor: y2 = rn, ...v2 } = t2;
1152
+ w2 && console.warn("onScroll not supported for VirtualScrollbar. Use onScrollOffset instead");
1153
+ const b2 = Tt(p2, [p2]), S2 = () => ({ offset: o2, totalSize: 0 === m2 ? s2 : Math.min(s2 ?? 0, Math.max(c2 ?? 0, (o2 ?? 0) + (r2 ?? 0)) + (a2 ?? 0)) }), [E2, _2] = h(S2), I2 = 0 !== m2 && E2.totalSize > m2 ? x2 : 1, C2 = I2 / y2, M2 = Math.ceil(E2.totalSize / I2), T2 = Math.ceil(E2.offset / I2), k2 = Math.ceil(r2 / I2), R2 = i((e5) => {
1154
+ }, []), [P2, O2] = h(false), L2 = l(null);
1155
+ u(() => {
1156
+ if (!P2) {
1157
+ L2.current = { propTotalSize: s2, propViewportSize: r2, propOffset: o2 };
1158
+ const e5 = S2();
1159
+ _2(e5);
1160
+ }
1161
+ }, [s2, r2, o2, P2, c2, a2, d2]);
1162
+ const D2 = Tt((e5, t3, n3) => {
1163
+ const i2 = L2.current;
1164
+ L2.current = null, i2 && i2.propTotalSize === s2 && i2.propViewportSize === r2 && i2.propOffset === o2 || (Math.abs(e5 - T2) < C2 && (e5 = T2), g2?.(e5 * I2, T2, k2));
1165
+ }, [g2, I2, C2, T2, k2]), z2 = i((e5) => {
1166
+ document.removeEventListener("mousemove", R2), document.removeEventListener("mouseup", z2), O2(false);
1167
+ }, []), A2 = i((e5) => {
1168
+ b2?.(e5), O2(true), document.addEventListener("mousemove", R2, { passive: true }), document.addEventListener("mouseup", z2, { passive: true });
1169
+ }, [R2, z2]);
1170
+ return e(Ot, { ref: n2, style: { ...f2 }, ...v2, offset: T2, totalSize: M2, viewportSize: k2, onMouseDown: A2, onScrollOffset: D2 });
1171
+ })).displayName = "VirtualScrollbar", r(a((t2, n2) => {
1172
+ const { refFocusStart: o2, ...r2 } = t2, s2 = l(null), c2 = i(() => {
1173
+ if (o2) return void o2?.current?.focus();
1174
+ const e5 = s2.current.parentElement.children;
1175
+ let t3 = [];
1176
+ for (let n3 = 0; n3 < e5.length && e5[n3] !== s2.current; n3++) {
1177
+ const o3 = e5[n3].getAttribute("tabindex");
1178
+ if (null == o3 || "-1" === o3) continue;
1179
+ if ("true" === e5[n3].getAttribute("disabled")) continue;
1180
+ const r3 = e5[n3];
1181
+ r3.focus && t3.push({ tabindex: parseInt(o3), child: r3 });
1182
+ }
1183
+ 0 !== t3.length && (t3.sort(function(e6, t4) {
1184
+ return e6.tabindex - t4.tabindex;
1185
+ }), t3[0].child.focus());
1186
+ }, [o2]);
1187
+ return e("div", { tabIndex: 0, ref: m([s2, n2]), onFocus: c2, ...r2 });
1188
+ })), r(a((r2, i2) => {
1189
+ const { className: s2, style: c2, children: a2, radius: u2 = 4, strokeWidth: h2 = 1, strokeColor: f2 = "grey", ...p2 } = r2, [g2, { width: x2, height: y2 }] = w(), v2 = l(null), b2 = (e5, t2 = 0) => {
1190
+ const n2 = e5 / 2, o2 = y2 - n2 + t2;
1191
+ return function(e6, t3, n3 = false) {
1192
+ if (0 === t3) return e6;
1193
+ function o3(e7, t4, n4) {
1194
+ let o4 = t4.x - e7.x, i4 = t4.y - e7.y, l3 = Math.sqrt(o4 * o4 + i4 * i4);
1195
+ return r3(e7, t4, Math.min(1, n4 / l3));
1196
+ }
1197
+ function r3(e7, t4, n4) {
1198
+ return { x: e7.x + (t4.x - e7.x) * n4, y: e7.y + (t4.y - e7.y) * n4 };
1199
+ }
1200
+ function i3(e7, t4) {
1201
+ e7.length > 2 && (e7[e7.length - 2] = t4.x, e7[e7.length - 1] = t4.y);
1202
+ }
1203
+ function l2(e7) {
1204
+ return { x: parseFloat(e7[e7.length - 2]), y: parseFloat(e7[e7.length - 1]) };
1205
+ }
1206
+ let s3 = e6.split(/[,\s]/).reduce(function(e7, t4) {
1207
+ let n4 = t4.match("([a-zA-Z])(.+)");
1208
+ return n4 ? (e7.push(n4[1]), e7.push(n4[2])) : e7.push(t4), e7;
1209
+ }, []).reduce(function(e7, t4) {
1210
+ return parseFloat(t4) == t4 && e7.length ? e7[e7.length - 1].push(t4) : e7.push([t4]), e7;
1211
+ }, []), c3 = [];
1212
+ if (s3.length > 1) {
1213
+ let e7 = l2(s3[0]), a3 = null;
1214
+ "Z" === s3[s3.length - 1][0] && s3[0].length > 2 && (a3 = ["L", e7.x, e7.y], s3[s3.length - 1] = a3), c3.push(s3[0]);
1215
+ for (let e8 = 1; e8 < s3.length; e8++) {
1216
+ let d2 = c3[c3.length - 1], u3 = s3[e8], h3 = u3 === a3 ? s3[1] : s3[e8 + 1];
1217
+ if (h3 && d2 && d2.length > 2 && "L" === u3[0] && h3.length > 2 && "L" === h3[0]) {
1218
+ let e9, s4, a4 = l2(d2), f3 = l2(u3), p3 = l2(h3);
1219
+ n3 ? (e9 = r3(f3, d2.origPoint || a4, t3), s4 = r3(f3, h3.origPoint || p3, t3)) : (e9 = o3(f3, a4, t3), s4 = o3(f3, p3, t3)), i3(u3, e9), u3.origPoint = f3, c3.push(u3);
1220
+ let g3 = r3(e9, f3, 0.5), w2 = r3(f3, s4, 0.5), m2 = ["C", g3.x, g3.y, w2.x, w2.y, s4.x, s4.y];
1221
+ m2.origPoint = f3, c3.push(m2);
1222
+ } else c3.push(u3);
1223
+ }
1224
+ if (a3) {
1225
+ let e8 = l2(c3[c3.length - 1]);
1226
+ c3.push(["Z"]), i3(c3[0], e8);
1227
+ }
1228
+ } else c3 = s3;
1229
+ return c3.reduce(function(e7, t4) {
1230
+ return e7 + t4.join(" ") + " ";
1231
+ }, "");
1232
+ }(`M 0 ${n2} L ${u2 - 0.5} ${n2} L ${u2 - 0.5} ${o2} L ${2 * u2} ${o2} L ${x2 - 2 * u2} ${o2} M ${x2 - 2 * u2} ${o2} L ${x2 - u2} ${o2} L ${x2 - u2} ${n2} L ${x2} ${n2}`, u2);
1233
+ }, S2 = d(() => b2(h2), [x2, y2, u2, h2]), E2 = d(() => {
1234
+ if (0 === u2) return;
1235
+ const e5 = u2 / 2;
1236
+ return b2(u2) + `L ${x2} 0 L 0 0 L 0 ${e5}`;
1237
+ }, [S2, u2, h2]), _2 = d(() => ({ style: { clipPath: `path('${E2}')` } }), [E2]);
1238
+ return t("div", { className: s2, style: { display: "flex", flexDirection: "row", ...c2 }, ...p2, ref: m([v2, g2, i2]), children: [o.isValidElement(a2) ? o.cloneElement(a2, _2) : e(n, {}), e("svg", { style: { position: "absolute", top: 0, left: 0, pointerEvents: "none" }, width: x2, height: y2, viewBox: `0 0 ${x2} ${y2}`, children: e("path", { d: S2, stroke: f2, fill: "none", vectorEffect: "non-scaling-stroke", strokeWidth: h2 }) })] });
1239
+ }));
1240
+ const ln = {}, sn = (t2) => {
1241
+ const { onPointerDown: n2, style: o2, splitDirection: r2, paddingBefore: i2 = 0, paddingAfter: l2 = 0, disabled: s2, key: c2, hitAreaProps: a2 = ln, ...d2 } = t2, u2 = "row" === r2, { style: h2, className: f2, ...p2 } = a2;
1242
+ return e("div", { style: { ...o2, position: "relative" }, ...d2, children: e("div", { className: g("hit-box", f2), style: { left: (u2 ? -i2 : 0) + "px", width: `calc(100% + ${u2 ? i2 + l2 : 0}px)`, top: (u2 ? 0 : -i2) + "px", height: `calc(100% + ${u2 ? 0 : i2 + l2}px)`, position: "absolute", ...h2 }, onPointerDown: s2 ? void 0 : n2, ...p2 }) }, c2);
1243
+ }, cn = {}, an = (e5, t2, n2 = true) => null === e5 ? null : null !== e5.pixels ? n2 ? e5.pixels : t2 - e5.pixels : (n2 ? e5.percent : 100 - e5.percent) / 100 * t2, dn = (e5, t2 = true) => e5?.percent ? `${t2 ? e5.percent : 100 - e5.percent}%` : e5?.pixels ? `${e5.pixels}px` : void 0, un = (e5, t2) => {
1244
+ if (null == e5) return null;
1245
+ const n2 = { percent: null, pixels: null };
1246
+ let o2 = t2;
1247
+ return "string" == typeof e5 && ((e5 = e5.trim().toLowerCase()).endsWith("px") ? (e5 = e5.substring(0, e5.length - 2), o2 = false) : e5.endsWith("%") && (e5 = e5.substring(0, e5.length - 1), o2 = true), e5 = parseFloat(e5)), o2 ? n2.percent = e5 : n2.pixels = e5, Object.freeze(n2);
1248
+ };
1249
+ function hn(e5) {
1250
+ if (!e5) throw new Error("must have a PointerHandlerOptions");
1251
+ const { onPointerDown: t2, onPointerUp: n2, onPointerMoveOrWait: o2, processTouch: r2 = false, consumeTouch: c2 = true } = e5, a2 = Tt(t2, [t2]), d2 = Tt(n2, [n2]), u2 = Tt(o2, [o2]), h2 = l(false), f2 = e5?.timerInitial ?? 230, p2 = e5?.timerContinuous ?? f2 / 2, g2 = l(null), w2 = l(null), m2 = l(null), x2 = l(null), y2 = i(() => {
1252
+ x2.current && (clearTimeout(x2.current), x2.current = null);
1253
+ }, []), v2 = i((e6) => {
1254
+ x2.current = setTimeout(() => {
1255
+ window.requestAnimationFrame(() => {
1256
+ false !== h2.current && u2?.(w2.current, m2.current, g2.current);
1257
+ }), v2(p2);
1258
+ }, e6 ?? f2);
1259
+ }, []);
1260
+ s(() => () => y2(), []);
1261
+ const b2 = r2 ? "pointer" : "mouse", S2 = i((e6) => {
1262
+ e6.stopPropagation(), e6.stopImmediatePropagation(), e6.preventDefault();
1263
+ }, []), E2 = Tt((e6) => {
1264
+ document.removeEventListener(`${b2}move`, C2), document.removeEventListener(`${b2}up`, E2), document.removeEventListener("keydown", M2), document.removeEventListener("keyup", T2), document.removeEventListener("touchstart", S2, { capture: true }), document.removeEventListener("touchmove", S2, { capture: true }), window.removeEventListener("blur", _2), y2(), window.requestAnimationFrame(() => {
1265
+ false !== h2.current && (h2.current = false, d2?.(e6, m2.current, g2.current), m2.current = null);
1266
+ });
1267
+ }, []), _2 = i(() => {
1268
+ false !== h2.current && (h2.current = false, E2(w2.current));
1269
+ }, []), I2 = Tt(() => {
1270
+ y2(), v2(p2), window.requestAnimationFrame(() => {
1271
+ false !== h2.current && u2?.(w2.current, m2.current, g2.current);
1272
+ });
1273
+ }, [p2]), C2 = Tt((e6) => {
1274
+ w2.current = e6, I2();
1275
+ }, []), M2 = Tt((e6) => {
1276
+ m2.current = { ctrlKey: e6.ctrlKey, shiftKey: e6.shiftKey, altKey: e6.altKey, metaKey: e6.metaKey }, I2();
1277
+ }, []), T2 = Tt((e6) => {
1278
+ m2.current = { ctrlKey: e6.ctrlKey, shiftKey: e6.shiftKey, altKey: e6.altKey, metaKey: e6.metaKey }, I2();
1279
+ }, [p2]);
1280
+ return Tt((e6) => {
1281
+ e6.isDefaultPrevented() || (m2.current = { ctrlKey: e6.ctrlKey, shiftKey: e6.shiftKey, altKey: e6.altKey, metaKey: e6.metaKey }, false !== a2(e6, m2.current) && (g2.current = e6, w2.current = e6.nativeEvent, document.addEventListener(`${b2}up`, E2, { passive: false }), document.addEventListener(`${b2}move`, C2, { passive: false }), document.addEventListener("keydown", M2, { passive: false }), document.addEventListener("keyup", T2, { passive: false }), window.addEventListener("blur", _2, { passive: true }), r2 && c2 && (document.addEventListener("touchstart", S2, { passive: false, capture: true }), document.addEventListener("touchmove", S2, { passive: false, capture: true })), h2.current = true, v2(f2)));
1282
+ }, [f2, r2]);
1283
+ }
1284
+ r(a((n2, r2) => {
1285
+ const { elementBefore: i2, elementAfter: c2, splitDirection: a2 = "row", fixedPane: u2 = null, position: f2, onPositionChange: p2, minBefore: x2, maxBefore: y2, minAfter: v2, maxAfter: b2, children: S2, className: E2, style: _2, disabled: I2 = false, onDragStart: C2, onDragResize: M2, onDragFinish: T2, resizerProps: k2 = cn, paneProps: R2 = cn, paneBeforeProps: P2 = cn, paneAfterProps: O2 = cn, createResizer: L2 = sn } = n2;
1286
+ if (S2) throw new Error("Use elementBefore and elementAfter instead of children.");
1287
+ const D2 = d(() => o.isValidElement(c2) && o.isValidElement(i2), [c2, i2]), z2 = d(() => {
1288
+ let e5 = null;
1289
+ u2 && ("before" === u2 ? e5 = 0 : "after" === u2 && (e5 = 1));
1290
+ const t2 = null === e5;
1291
+ return { fixedPaneOffset: e5, isPercent: t2, minBefore: un(x2, t2), maxBefore: un(y2, t2), minAfter: un(v2, t2), maxAfter: un(b2, t2) };
1292
+ }, [x2, y2, v2, b2]), A2 = Tt(p2, [p2]), [$2, B2] = h(() => un(f2, null === u2));
1293
+ s(() => {
1294
+ B2(un(f2, null === u2));
1295
+ }, [f2, u2]);
1296
+ const [F2, { width: j2, height: V2 }] = w(), [W2, { width: H2, height: N2 }] = w(), U2 = "row" === a2 ? H2 : N2, q2 = "row" === a2 ? j2 : V2, K2 = d(() => ((e5, t2, n3, o2) => {
1297
+ const r3 = [null, null], i3 = [null, null];
1298
+ if (e5 || (e5 = { percent: null === o2.fixedPaneOffset ? 50 : null, pixels: null === o2.fixedPaneOffset ? null : 0 }), 0 === t2) return null != e5?.pixels ? 1 !== o2.fixedPaneOffset ? (r3[0] = e5?.pixels, i3[1] = 100) : (r3[1] = e5?.pixels - n3, i3[0] = 100) : null != e5?.percent && (1 !== o2.fixedPaneOffset ? (i3[0] = e5?.percent, i3[1] = 100 - e5?.percent) : (i3[1] = e5?.percent, i3[0] = 100 - e5?.percent)), { percents: i3, pixels: r3, minBefore: dn(o2.minBefore, true), maxBefore: dn(o2.maxBefore, true), minAfter: dn(o2.minAfter), maxAfter: dn(o2.maxAfter) };
1299
+ let l2 = an(e5, t2, 1 !== o2.fixedPaneOffset), s2 = t2 - n3, c3 = an(o2.minBefore, s2, true) ?? 0, a3 = an(o2.maxBefore, s2, true) ?? s2, d2 = 0, u3 = 0, h2 = 0, f3 = s2;
1300
+ d2 = (an(o2.maxAfter, t2, false) ?? n3) - n3, u3 = an(o2.minAfter, t2, false) ?? t2, h2 = Math.max(c3, d2), f3 = Math.min(a3, u3), l2 = Math.max(h2, Math.min(l2, f3)), u3 = Math.min(s2 - l2, an(o2.maxAfter, s2 - l2, true) ?? s2), d2 = Math.min(s2 - l2, an(o2.minAfter, s2 - l2, true) ?? s2), r3[0] = l2, r3[1] = s2 - r3[0];
1301
+ const p3 = Math.max(0, Math.min(100, l2 / s2 * 100));
1302
+ return i3[0] = p3, i3[1] = 100 - i3[0], { percents: i3, pixels: r3, minBefore: `${c3}px`, minAfter: `${d2}px`, maxBefore: `${r3[0]}px`, maxAfter: `${r3[1]}px` };
1303
+ })($2, q2, U2, z2), [z2, $2, q2, U2, a2]), [Y2, X2] = h(false), G2 = Tt(C2, [C2]), Z2 = Tt(M2, [M2]), J2 = Tt(T2, [T2]), Q2 = l(null), ee2 = l(null), te2 = l(null), { style: ne2, className: oe2, ...re2 } = R2, ie2 = { minWidth: 0, minHeight: 0, maxWidth: "100%", maxHeight: "100%", display: "flex", overflow: "hidden", ...ne2 }, { className: le2, style: se2, ...ce2 } = P2, { className: ae2, style: de2, ...ue2 } = O2, he2 = { flex: "1 1 100%", width: "100%", ..._2, flexDirection: a2, display: "flex" }, { className: fe2, style: pe2, onPointerDown: ge2, ...we2 } = k2, me2 = Tt((e5) => {
1304
+ const t2 = un(e5, null === u2);
1305
+ B2(t2);
1306
+ }, [u2]), xe2 = Tt((e5) => {
1307
+ if (I2 || !Y2) return;
1308
+ const t2 = be2.current?.getBoundingClientRect();
1309
+ let n3 = 0;
1310
+ n3 = "row" === a2 ? (e5.clientX ?? e5.touches?.[0]?.clientX) - t2.x : (e5.clientY ?? e5.touches?.[0]?.clientY) - t2.y, n3 = Math.max(0, Math.min(q2, n3)), 1 === z2.fixedPaneOffset && (n3 = q2 - n3), f2 && $2.pixels === n3 || B2({ pixels: n3, percent: null }), Z2?.(n3), e5.stopPropagation(), e5.preventDefault();
1311
+ }, [z2, a2, I2, Y2, $2, q2]), ye2 = Tt((e5) => {
1312
+ if (document.removeEventListener("pointermove", xe2), document.removeEventListener("touchmove", xe2), document.removeEventListener("pointerup", ye2), Y2 && (X2(false), $2)) {
1313
+ if (J2($2.pixels), !un(f2, null === u2) || $2.pixels !== f2) {
1314
+ const e6 = { ...$2 };
1315
+ null === e6.percent && (e6.percent = e6.pixels / q2 * 100), A2(e6);
1316
+ }
1317
+ e5.stopPropagation(), e5.preventDefault();
1318
+ }
1319
+ }, [$2, Y2, f2, u2, q2]), ve2 = Tt((e5) => {
1320
+ ge2?.(e5), e5.defaultPrevented || I2 || Y2 || (X2(true), G2(), document.addEventListener("pointermove", xe2, { passive: false }), document.addEventListener("touchmove", xe2, { passive: false }), document.addEventListener("pointerup", ye2, { passive: false }));
1321
+ }, [ge2]), be2 = Kt(r2, () => ({ setPosition: me2, isSplitPane: () => true }), []), Se2 = d(() => D2 ? L2?.({ key: "resizer", ref: m([W2, ee2]), className: g("resizer", fe2), onPointerDownCapture: ve2, style: { cursor: I2 ? void 0 : "row" === a2 ? "ew-resize" : "ns-resize", minWidth: "row" === a2 ? "2px" : void 0, minHeight: "row" !== a2 ? "2px" : void 0, boxSizing: "border-box", pointerEvents: "all", zIndex: 1, ...pe2 }, splitDirection: a2, disabled: I2, ...we2 }) : null, [D2, fe2, we2, a2, pe2, I2]), Ee2 = "row" === a2 ? "Width" : "Height", _e2 = { ...ie2, ...se2, flex: 0 === z2.fixedPaneOffset && null !== K2?.pixels[0] ? `0 0 ${Math.round(K2?.pixels[0])}px` : `1 1 ${Math.round(K2?.percents[0] ?? 100)}%`, [`min${Ee2}`]: K2?.minBefore, [`max${Ee2}`]: c2 ? K2?.maxBefore : "100%" }, Ie2 = { ...ie2, ...de2, flex: 1 === z2.fixedPaneOffset && null !== K2?.pixels[1] ? `0 0 ${Math.round(K2?.pixels[1])}px` : `1 1 ${Math.round(K2?.percents[1] ?? 100)}%`, [`min${Ee2}`]: K2?.minAfter, [`max${Ee2}`]: i2 ? K2?.maxAfter : "100%" }, Ce2 = d(() => i2 ? e("div", { ref: Q2, className: g("before", oe2, le2), style: _e2, ...re2, ...ce2, children: i2 }, "before") : null, [i2, R2, P2, z2, K2]), Me2 = d(() => c2 ? e("div", { ref: te2, className: g("after", oe2, ae2), style: Ie2, ...re2, ...ue2, children: c2 }, "after") : null, [c2, R2, O2, z2, K2]);
1322
+ return t("div", { ref: m([F2, be2]), className: g("splitPane", "row" === a2 ? "vertical" : "horizontal", { dragging: Y2 }, E2), style: he2, children: [Ce2, Se2, Me2] });
1323
+ }));
1324
+ const fn = ({ initValue: e5, useHookBody: t2, applyStateChange: n2 }) => {
1325
+ const o2 = l(e5);
1326
+ if ("function" != typeof t2) throw new Error("function expected as hook body parameter. got " + typeof t2);
1327
+ const r2 = t2();
1328
+ return u(() => {
1329
+ o2.current !== r2 && (o2.current = r2, n2(r2));
1330
+ }, [n2, r2]), null;
1331
+ }, pn = (e5) => {
1332
+ console && console.warn && console.warn(e5);
1333
+ }, gn = "object" == typeof self && self.self === self && self || "object" == typeof global && global.global === global && global || void 0;
1334
+ let wn = 1, mn = false, xn = false;
1335
+ const yn = [], vn = [], bn = () => {
1336
+ vn.forEach((e5) => e5());
1337
+ }, Sn = ({ automaticContainerInternalUseOnly: t2 }) => {
1338
+ const [o2, r2] = h([]), i2 = l([]);
1339
+ return i2.current = o2, t2 || false !== mn || (xn = true), s(() => {
1340
+ let e5 = true;
1341
+ function n2() {
1342
+ if (e5) return vn[0] !== n2 ? (t2 || true !== mn || pn("SingletonHooksContainer is mounted after some singleton hook has been used.Your SingletonHooksContainer will not be used in favor of internal one."), void r2((e6) => [])) : void r2([...yn]);
1343
+ }
1344
+ return vn.push(n2), bn(), () => {
1345
+ e5 = false, i2.current?.length > 0 && pn("SingletonHooksContainer is unmounted, but it has active singleton hooks. They will be reevaluated once SingletonHooksContainer is mounted again"), vn.splice(vn.indexOf(n2), 1), bn();
1346
+ };
1347
+ }, [t2]), e(n, { children: o2.map(({ hook: e5, key: t3 }) => f(fn, { ...e5, key: t3 })) });
1348
+ }, En = (t2, n2, o2 = {}) => {
1349
+ let r2, i2, l2 = false, c2 = false, a2 = [], { unmountIfNoConsumers: d2 = false } = o2;
1350
+ const u2 = (e5) => {
1351
+ i2 = e5, y(() => a2.forEach((t3) => t3(e5)));
1352
+ }, f2 = () => (c2 || (i2 = "function" == typeof t2 ? t2() : t2, c2 = true), i2);
1353
+ return () => {
1354
+ const [o3, c3] = h(f2);
1355
+ return s(() => (l2 || (l2 = true, r2 = ((t3) => {
1356
+ const n3 = wn++;
1357
+ return yn.push({ hook: t3, key: n3 }), 0 === vn.length && false === xn && (mn = true, ((t4) => {
1358
+ if (gn.document && gn.document.createElement) {
1359
+ const n4 = gn.document.createElement("div");
1360
+ x(n4).render(e(t4, { automaticContainerInternalUseOnly: true }));
1361
+ } else pn("Can not mount SingletonHooksContainer on server side. Did you manage to run useEffect on server? Please mount SingletonHooksContainer into your components tree manually.");
1362
+ })(Sn)), bn(), () => {
1363
+ yn.splice(yn.findIndex((e5) => e5.key === n3), 1), bn();
1364
+ };
1365
+ })({ initValue: t2, useHookBody: n2, applyStateChange: u2 })), a2.push(c3), i2 !== o3 && c3(i2), () => {
1366
+ a2.splice(a2.indexOf(c3), 1), 0 === a2.length && d2 && (r2(), l2 = false);
1367
+ }), []), o3;
1368
+ };
1369
+ };
1370
+ En(null, () => {
1371
+ const [e5, t2] = h(null);
1372
+ return e5;
1373
+ });
1374
+ class _n {
1375
+ constructor(e5, t2, n2, o2) {
1376
+ this._listenersProperties = /* @__PURE__ */ new Set(), this._listenersExecute = /* @__PURE__ */ new Set(), this._key = e5, this._target = t2, this._applyProps(n2 || {}), this._callback = o2, void 0 === o2 && (this._callback = () => {
1377
+ console.log(`implement: ${this.label()} : ${this.description()}`);
1378
+ });
1379
+ }
1380
+ key() {
1381
+ return this._key;
1382
+ }
1383
+ _resolve(e5, t2) {
1384
+ if ("function" == typeof e5) {
1385
+ const n2 = t2 ?? this._context;
1386
+ return e5("function" == typeof n2 ? n2() : n2);
1387
+ }
1388
+ return e5;
1389
+ }
1390
+ target() {
1391
+ return "function" == typeof this._target ? this._target() : this._target;
1392
+ }
1393
+ label(e5, t2) {
1394
+ const n2 = this._scopedLabels?.[e5] || this._label;
1395
+ let o2 = null;
1396
+ if ("function" == typeof n2) {
1397
+ const e6 = t2 ?? this._context;
1398
+ o2 = n2("function" == typeof e6 ? e6() : e6);
1399
+ } else o2 = n2;
1400
+ return o2;
1401
+ }
1402
+ description(e5) {
1403
+ return this._resolve(this._description, e5);
1404
+ }
1405
+ tags(e5) {
1406
+ return this._resolve(this._tags, e5);
1407
+ }
1408
+ icon(e5) {
1409
+ return this._resolve(this._icon, e5);
1410
+ }
1411
+ shortcut() {
1412
+ return this._resolve(this._shortcut);
1413
+ }
1414
+ disabled() {
1415
+ return this._resolve(this._disabled) || !this._callback;
1416
+ }
1417
+ state() {
1418
+ return this._resolve(this._state);
1419
+ }
1420
+ context() {
1421
+ return "function" == typeof this._context ? this._context() : this._context;
1422
+ }
1423
+ async execute(e5, t2) {
1424
+ if (!this.disabled() && this._callback) {
1425
+ try {
1426
+ let n2 = true;
1427
+ if (t2?.beforeExecute && (n2 = t2?.beforeExecute(this, e5)), false === await Promise.resolve(n2)) return false;
1428
+ const o2 = this._callback.bind(this)(e5, this);
1429
+ if (false === await Promise.resolve(o2)) return false;
1430
+ t2?.onExecute?.(this, e5), this._notifyExecute(e5);
1431
+ } catch (n2) {
1432
+ return console.warn(n2), t2?.onError(this, n2, e5), this._notifyError(e5, n2), false;
1433
+ }
1434
+ return true;
1435
+ }
1436
+ }
1437
+ addPropertyListener(e5, t2 = false) {
1438
+ if (!e5) throw new Error("listener must be specified");
1439
+ const n2 = this._listenersProperties;
1440
+ return n2.add(e5), t2 && e5({}, this), () => {
1441
+ n2.delete(e5);
1442
+ };
1443
+ }
1444
+ addExecuteListener(e5) {
1445
+ if (!e5) throw new Error("listener must be specified");
1446
+ const t2 = this._listenersExecute;
1447
+ return t2.add(e5), function() {
1448
+ t2.delete(e5);
1449
+ };
1450
+ }
1451
+ _notifyExecute(e5) {
1452
+ const t2 = this;
1453
+ this._listenersExecute.forEach((n2) => {
1454
+ n2.onExecute(t2, e5);
1455
+ });
1456
+ }
1457
+ _notifyError(e5, t2) {
1458
+ const n2 = this;
1459
+ this._listenersExecute.forEach((o2) => {
1460
+ o2.onError?.(n2, e5, t2);
1461
+ });
1462
+ }
1463
+ updateCallback(e5) {
1464
+ return this._callback = e5 || null, this;
1465
+ }
1466
+ update(e5) {
1467
+ if (!e5) return;
1468
+ const t2 = this._applyProps(e5);
1469
+ return Object.keys(t2).length > 0 && this._notifyPropertyChange(t2), this;
1470
+ }
1471
+ _notifyPropertyChange(e5) {
1472
+ const t2 = this;
1473
+ this._listenersProperties.forEach((n2) => {
1474
+ n2(e5, t2);
1475
+ });
1476
+ }
1477
+ _applyProps(e5) {
1478
+ let t2 = {}, n2 = this;
1479
+ return Object.keys(e5).forEach((o2) => {
1480
+ let r2 = e5[o2];
1481
+ n2["_" + o2] !== r2 && (n2["_" + o2] = t2[o2] = r2);
1482
+ }), t2;
1483
+ }
1484
+ }
1485
+ class In extends _n {
1486
+ }
1487
+ Me.getOS() === Me.OSType.MacOS || (Me.getOS(), Me.OSType.IOS), Me.getOS() === Me.OSType.MacOS || (Me.getOS(), Me.OSType.IOS), En({ setClipboard: (e5) => {
1488
+ throw new Error("This is only available via the useClipboard.");
1489
+ }, getClipboard: () => Xe.Global, refNativeCopy: { current: null }, refNativeLastKey: { current: null } }, () => {
1490
+ const [e5, t2] = h(Xe.Global);
1491
+ return { setClipboard: (e6) => t2(e6), getClipboard: () => e5, refNativeCopy: l(null), refNativeLastKey: l(null) };
1492
+ });
1493
+ let Cn = false, Mn = 0;
1494
+ var Tn = "undefined" != typeof document ? u : s;
1495
+ const kn = () => "sheetxl-ui-" + Mn++, Rn = o["useId".toString()], Pn = null != Rn ? Rn : function() {
1496
+ const [e5, t2] = o.useState(() => Cn ? kn() : void 0);
1497
+ return Tn(() => {
1498
+ null == e5 && t2(kn());
1499
+ }, []), o.useEffect(() => {
1500
+ Cn || (Cn = true);
1501
+ }, []), e5;
1502
+ }, On = ({ itemType: e5, index: t2, itemSize: n2, instanceProps: o2, scale: r2 = 1 }) => {
1503
+ let i2, l2, s2;
1504
+ "column" === e5 ? (i2 = o2.columnMetadataMap, l2 = o2.lastMeasuredColumnIndex, s2 = o2.recalcColumnIndices) : (i2 = o2.rowMetadataMap, l2 = o2.lastMeasuredRowIndex, s2 = o2.recalcRowIndices);
1505
+ const c2 = s2.length > 0;
1506
+ if (t2 > l2) {
1507
+ let a2 = 0;
1508
+ if (l2 >= 0) {
1509
+ const e6 = i2[l2];
1510
+ a2 = e6.offset + e6.size;
1511
+ }
1512
+ for (let e6 = l2 + 1; e6 <= t2; e6++) {
1513
+ let t3 = c2 ? s2.includes(e6) ? n2(e6) * r2 : i2[e6]?.size || n2(e6) * r2 : n2(e6) * r2;
1514
+ i2[e6] = { offset: a2, size: t3 }, a2 += t3;
1515
+ }
1516
+ "column" === e5 ? o2.lastMeasuredColumnIndex = t2 : o2.lastMeasuredRowIndex = t2;
1517
+ }
1518
+ return i2[t2], i2[t2];
1519
+ }, Ln = ({ itemType: e5, itemSize: t2, itemCount: n2, instanceProps: o2, offset: r2, scale: i2 }) => {
1520
+ let l2, s2;
1521
+ "column" === e5 ? (l2 = o2.columnMetadataMap, s2 = o2.lastMeasuredColumnIndex) : (l2 = o2.rowMetadataMap, s2 = o2.lastMeasuredRowIndex);
1522
+ let c2 = 0;
1523
+ return c2 = (s2 > 0 ? l2[s2].offset : 0) >= r2 ? Dn({ itemType: e5, itemSize: t2, instanceProps: o2, high: s2, low: 0, offset: r2, scale: i2 }) : zn({ itemType: e5, itemSize: t2, itemCount: n2, instanceProps: o2, index: Math.max(0, s2), offset: r2, scale: i2 }), c2 = Math.min(c2, n2), c2;
1524
+ }, Dn = ({ itemType: e5, itemSize: t2, instanceProps: n2, high: o2, low: r2, offset: i2, scale: l2 }) => {
1525
+ for (; r2 <= o2; ) {
1526
+ const s2 = r2 + Math.floor((o2 - r2) / 2), c2 = On({ itemType: e5, itemSize: t2, index: s2, instanceProps: n2, scale: l2 }).offset;
1527
+ if (c2 === i2) return s2;
1528
+ c2 < i2 ? r2 = s2 + 1 : c2 > i2 && (o2 = s2 - 1);
1529
+ }
1530
+ return r2 > 0 ? r2 - 1 : 0;
1531
+ }, zn = ({ itemType: e5, itemSize: t2, itemCount: n2, instanceProps: o2, index: r2, offset: i2, scale: l2 }) => {
1532
+ let s2 = 1;
1533
+ for (; r2 < n2 && On({ itemType: e5, itemSize: t2, index: r2, instanceProps: o2, scale: l2 }).offset < i2; ) r2 += s2, s2 *= 2;
1534
+ return Dn({ itemType: e5, itemSize: t2, instanceProps: o2, high: Math.min(r2, n2 - 1), low: Math.floor(r2 / 2), offset: i2, scale: l2 });
1535
+ }, An = (e5) => {
1536
+ const { rowCount: t2, columnCount: n2, defaultRowHeight: o2, getRowHeight: r2, defaultColumnWidth: i2, getColumnWidth: c2 } = e5 || {}, a2 = l({ columnMetadataMap: {}, rowMetadataMap: {}, lastMeasuredColumnIndex: -1, lastMeasuredRowIndex: -1, recalcColumnIndices: [], recalcRowIndices: [] }), d2 = Tt((e6) => Ln({ itemType: "row", itemCount: t2, itemSize: r2 ?? (() => o2 ?? 20), instanceProps: a2.current, offset: e6 }), [t2, r2, o2]), u2 = Tt((e6) => -1 === e6 ? 0 : On({ itemType: "row", index: e6, itemSize: r2 ?? (() => o2 ?? 20), instanceProps: a2.current }).offset, [r2, o2]), f2 = Tt((e6) => On({ itemType: "row", index: e6, itemSize: r2 ?? (() => o2 ?? 20), instanceProps: a2.current }).size, [r2, o2]), g2 = Tt((e6) => Ln({ itemType: "column", itemCount: n2, itemSize: c2 ?? (() => i2 ?? 75), instanceProps: a2.current, offset: e6 }), [n2, c2, i2]), w2 = Tt((e6) => -1 === e6 ? 0 : On({ itemType: "column", index: e6, itemSize: c2 ?? (() => i2 ?? 75), instanceProps: a2.current }).offset, [c2, i2]), m2 = Tt((e6) => On({ itemType: "column", index: e6, itemSize: c2 ?? (() => i2 ?? 75), instanceProps: a2.current }).size, [c2, i2]), [x2, y2] = p((e6) => e6 + 1, 0), v2 = () => ({ getRowOffset: u2, getColOffset: w2, getRowIndex: d2, getColIndex: g2 }), [b2, S2] = h(() => e5 ? v2() : null);
1537
+ return s(() => {
1538
+ S2(e5 ? v2() : null);
1539
+ }, [x2, t2, n2, i2, o2, f2, m2]), b2;
1540
+ }, $n = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ~`!@#$%^&*()-_=+[{]};:'\",<.>/?|\\", Bn = (e5) => {
1541
+ if (!e5) return null;
1542
+ if ("start" === e5.eventType) return { type: e5.eventType };
1543
+ if ("submit" === e5.eventType) return { type: e5.eventType };
1544
+ if ("cancel" === e5.eventType) return { type: e5.eventType };
1545
+ if ("keyboard" === e5.eventType) return { type: e5.eventType, key: e5.event.key };
1546
+ if ("pointer" === e5.eventType) return { type: e5.eventType };
1547
+ if ("coordsChange" === e5.eventType) {
1548
+ const t2 = { type: e5.eventType };
1549
+ return e5.activeCoords && (t2.activeCoords = e5.activeCoords), t2;
1550
+ }
1551
+ return { type: e5.eventType ?? "unknown" };
1552
+ }, Fn = (e5) => true, jn = (e5) => !!e5 && (!(e5.ctrlKey || e5.metaKey || e5.altKey || e5.isComposing) && (!(e5.shiftKey || "F2" !== e5.key && " " !== e5.key && "Backspace" !== e5.key) || (!e5.shiftKey || " " !== e5.key) && -1 !== $n.indexOf(e5.key))), Vn = (e5) => !!e5 && ("dblclick" === e5.type && { editMode: true }), Wn = (t2) => {
1553
+ const { session: n2, refLatestCoords: o2, handleSubmitEdit: r2, handleCancelEdit: c2, cellBounds: a2, isInBounds: d2, getCellEditor: u2, propsEditor: f2, borderStrokeFill: p2 = "rgb(33, 115, 70)", borderStrokeWidth: g2 = 2, alignment: w2 = pt.Left, style: m2, ...x2 } = t2, y2 = l(null), v2 = l(null), [b2, S2] = h(false), E2 = n2.coords, _2 = i(async (e5) => {
1554
+ const t3 = y2.current?.getBoundingClientRect();
1555
+ if (t3) {
1556
+ if ("keyboard" === e5.eventType) {
1557
+ const t4 = e5.event, n3 = new KeyboardEvent(t4.type, { bubbles: true, cancelable: true, view: window, key: t4.key, code: t4.code, location: t4.location, repeat: t4.repeat, isComposing: t4.isComposing, charCode: t4.charCode, keyCode: t4.keyCode, which: t4.which, ctrlKey: t4.ctrlKey, shiftKey: t4.shiftKey, altKey: t4.altKey, metaKey: t4.metaKey });
1558
+ n3.isSynthetic = true, n3.key, v2.current?.dispatchEvent(n3);
1559
+ } else "pointer" === e5.eventType || console.warn("unsupported event type", e5);
1560
+ await new Promise((e6) => requestAnimationFrame(e6));
1561
+ }
1562
+ }, []);
1563
+ s(() => {
1564
+ const e5 = v2.current;
1565
+ S2(true), v2.current.startEdit?.(n2.startEvent);
1566
+ return (async () => {
1567
+ n2.editorRefs.push(e5), n2.editorRefsDispatchEditorEvent.push(_2);
1568
+ const t3 = [...n2.events];
1569
+ for (let e6 = 0; e6 < t3.length; e6++) await _2(t3[e6]);
1570
+ n2.onMount(e5);
1571
+ })(), () => {
1572
+ const t3 = n2.editorRefs.indexOf(e5);
1573
+ -1 !== t3 && n2.editorRefs.splice(t3, 1), n2.onUnmount(e5);
1574
+ };
1575
+ }, []);
1576
+ const I2 = i(() => r2(n2), []), C2 = i(() => {
1577
+ c2(n2);
1578
+ }, []), M2 = o2.current && ne.isEqualCells(o2.current, E2), T2 = d2 && M2 && b2, k2 = u2({ autoFocus: !!n2.startEvent?.autoFocus, ...f2, onSubmitEdit: I2, onCancelEdit: C2, ref: v2 }, E2), R2 = a2.x + Ut.boundPixel(-g2 / 2), P2 = Ut.boundPixel(a2.width + g2 / 2, true);
1579
+ return e("div", { tabIndex: 0, ref: y2, style: { background: void 0, ...m2, opacity: T2 ? m2?.opacity ?? 1 : 0, pointerEvents: "auto", position: "absolute", boxSizing: "border-box", top: `${a2.y + Ut.boundPixel(-g2 / 2)}px`, height: Ut.boundPixel(a2.height + g2 / 2, true), left: `${R2}px`, width: P2 }, ...x2, children: e("div", { className: "editor-container", style: { position: "absolute", boxSizing: "border-box", left: `${Ut.boundPixel(1)}px`, top: `${Ut.boundPixel(1)}px`, width: Ut.boundPixel(a2.width - 2, true), height: Ut.boundPixel(a2.height - 2, true), outline: `${g2}px ${p2} solid`, boxShadow: "rgba(60,64,67,.35) 2px 2px 6px 3px", maxHeight: "100%", overflow: "hidden", display: "flex" }, children: k2 }) });
1580
+ }, Hn = (t2) => {
1581
+ const { view: n2, canEdit: o2 = Fn, getCellEditor: r2, onBeforeStartEdit: c2, onStartEdit: a2, onSubmitEdit: d2, onCancelEdit: f2, onDoneEdit: g2, isEditorStartKeyEvent: w2 = jn, isEditorStartPointerEvent: m2 = Vn, containerProps: x2, borderStrokeFill: y2, borderStrokeWidth: v2 = 2, getRangeCoords: b2 = null, activeCoords: S2, alignment: E2 = pt.Left } = t2, [_2, I2] = h(false), [C2, M2] = h(void 0), T2 = Tt((e5, t3, n3, o3, r3, i2) => {
1582
+ if (!t3) return null;
1583
+ const l2 = r3?.(t3, e5), s2 = e5.getRangeCoordsBounds(l2), c3 = e5.toClipBounds(s2), a3 = s2, d3 = e5.getZoom();
1584
+ if (!c3) return null;
1585
+ n3 && (n3 *= d3), o3 && (o3 *= d3);
1586
+ let u2 = a3, h2 = false;
1587
+ if (void 0 !== n3) {
1588
+ let t4 = { ...l2 }, o4 = 0;
1589
+ for (; !h2 && u2.width <= n3 && o4 < 20; ) {
1590
+ o4++, o4 > 19 && console.warn("max width reached");
1591
+ const r4 = e5.getTotalRangeCoords(), l3 = e5.getLayout();
1592
+ i2 === pt.Left ? t4.colEnd + 1 < r4.colEnd ? t4.colEnd = l3.getColIndex(u2.x + n3) : h2 = true : i2 === pt.Right ? t4.colStart - 1 >= 0 ? t4.colStart = l3.getColIndex(u2.x - (n3 - u2.width)) : h2 = true : i2 === pt.Center && t4.colEnd + 1 < r4.colEnd && t4.colStart - 1 >= 0 ? (t4.colStart = l3.getColIndex(u2.x - (n3 - u2.width) / 2), t4.colEnd = l3.getColIndex(u2.x + u2.width + (n3 - u2.width) / 2)) : h2 = true, h2 || (u2 = e5.getRangeCoordsBounds(t4));
1593
+ }
1594
+ }
1595
+ u2.height = a3.height, void 0 !== o3 && (u2.height = Math.max(o3 + 1, a3.height));
1596
+ const { width: f3, height: p2 } = e5.getViewportSize();
1597
+ return { x: u2.x ?? 0, y: u2.y ?? 0, height: Math.min(p2 - u2.y, u2.height) + 1, width: Math.min(f3 - u2.x, u2.width) + 1 };
1598
+ }, [E2]), k2 = Tt(o2, [o2]), R2 = i(() => {
1599
+ n2?.getStage()?.focus();
1600
+ }, [n2]), P2 = Tt((e5) => {
1601
+ c2?.(e5), W2(), I2(true);
1602
+ }, [c2]), O2 = Tt((e5) => {
1603
+ a2?.(e5.coords);
1604
+ }, [a2]), L2 = Tt((e5) => {
1605
+ e5.isSubmitted || e5.isCancelled || (A2.current.isEditorClosed = true, R2(), e5.isCancelled = true, f2?.(e5.coords), W2());
1606
+ }, [f2]), D2 = Tt((e5) => {
1607
+ if (e5.isSubmitted || e5.isCancelled) return false;
1608
+ try {
1609
+ return e5.isEditorClosing = true, e5.isSubmitted = true, e5.isEditorSubmitted || (e5.isEditorSubmitted = true, e5.editorRefs[0]?.submitEdit?.()), e5.coords, d2?.(e5.coords), e5.isEditorClosed = true, R2(), W2(), true;
1610
+ } catch (t3) {
1611
+ throw e5.isEditorClosing = false, e5.isSubmitted = false, t3;
1612
+ }
1613
+ }, [d2]), z2 = Tt((e5) => {
1614
+ I2(false), g2?.(e5.coords), W2();
1615
+ }, [g2]), A2 = l(null), $2 = l(null), B2 = l(null), F2 = l([]), [j2, V2] = p((e5) => e5 + 1, 0), W2 = i((e5) => {
1616
+ e5 && F2.current.push(e5), V2();
1617
+ }, []), H2 = Tt((e5) => {
1618
+ if (e5.defaultPrevented || e5.isSynthetic) return;
1619
+ if (!n2) return;
1620
+ const t3 = n2?.getCellCoordsFromClient(e5.clientX, e5.clientY);
1621
+ if (!t3) return;
1622
+ W2({ eventType: "pointer", event: e5, coords: t3 });
1623
+ }, [n2]), N2 = Tt((e5) => {
1624
+ const t3 = e5.nativeEvent;
1625
+ H2(t3);
1626
+ }, [n2]), U2 = Tt((e5) => {
1627
+ if (e5.defaultPrevented || e5.isSynthetic) return;
1628
+ if (!n2?.getStage()) return;
1629
+ const t3 = $2.current;
1630
+ w2(e5, t3) && (e5.stopPropagation(), e5.preventDefault()), e5.key;
1631
+ W2({ eventType: "keyboard", event: e5, coords: t3 });
1632
+ }, [n2]);
1633
+ u(() => {
1634
+ const e5 = (e6, t4) => {
1635
+ const o4 = t4?.cell ?? e6;
1636
+ if (!o4) return null;
1637
+ const r3 = o4;
1638
+ if (!k2(o4)) return null;
1639
+ P2?.(o4);
1640
+ const i2 = Me.uuidV4();
1641
+ t4 = Object.freeze({ autoFocus: true, ...t4 }), B2.current = o4;
1642
+ const l2 = { coords: r3, startEvent: t4, uuid: i2, isMounted: false, isStarted: false, isSubmitted: false, isEditorSubmitted: false, isEditorClosing: false, isEditorClosed: false, isCancelled: false, events: [], editorRefsDispatchEditorEvent: [], editorRefs: [], onMount: (e7) => {
1643
+ l2.isMounted || (l2.isMounted = true, W2());
1644
+ }, onUnmount: (e7) => {
1645
+ if (0 === l2.editorRefs.length) {
1646
+ const e8 = () => {
1647
+ l2.isMounted = false, W2();
1648
+ };
1649
+ if (document.activeElement !== document.body) e8();
1650
+ else {
1651
+ const t5 = (e9) => {
1652
+ e9.defaultPrevented || e9.target !== document.body || U2(e9);
1653
+ };
1654
+ window.addEventListener("keydown", t5, true), n2.getStage()?.addEventListener("focusin", () => {
1655
+ window.removeEventListener("keydown", t5), e8();
1656
+ }, { once: true }), R2();
1657
+ }
1658
+ }
1659
+ } };
1660
+ return l2;
1661
+ };
1662
+ if (F2.current.length <= 0 && !A2.current) return;
1663
+ const t3 = F2.current[0];
1664
+ Bn(t3), ((e6) => {
1665
+ const t4 = [], n3 = e6?.length ?? 0;
1666
+ for (let o4 = 0; o4 < n3; o4++) {
1667
+ const n4 = e6[o4];
1668
+ t4.push(Bn(n4));
1669
+ }
1670
+ })(F2.current), A2.current, A2.current;
1671
+ let o3 = A2.current;
1672
+ if (A2.current) {
1673
+ if (A2.current.isDone) A2.current = null;
1674
+ else if (A2.current.isSubmitted || A2.current.isCancelled) {
1675
+ if (A2.current.isMounted) return;
1676
+ A2.current.isDone || (z2(A2.current), A2.current.isDone = true);
1677
+ }
1678
+ }
1679
+ if (t3) {
1680
+ if ("start" === t3.eventType) {
1681
+ const n3 = t3, o4 = n3.startEvent?.cell ?? $2.current;
1682
+ A2.current && ne.isEqualCells(A2.current.coords, o4) || (A2.current = e5(o4, n3.startEvent));
1683
+ } else if ("keyboard" === t3.eventType) {
1684
+ const n3 = t3.event;
1685
+ if (A2.current) {
1686
+ n3.key, A2.current.events, A2.current.events.push(t3);
1687
+ for (let e6 = 0; e6 < A2.current.editorRefsDispatchEditorEvent.length; e6++) A2.current.editorRefsDispatchEditorEvent[e6](t3);
1688
+ } else {
1689
+ if (w2(n3, t3.coords)) {
1690
+ let n4;
1691
+ const o4 = e5(n4?.cell ?? $2.current, n4);
1692
+ o4 && o4.events.push(t3), A2.current = o4;
1693
+ }
1694
+ }
1695
+ } else if ("pointer" === t3.eventType) {
1696
+ const n3 = t3.event;
1697
+ if (A2.current) {
1698
+ A2.current.events.push(t3);
1699
+ for (let e6 = 0; e6 < A2.current.editorRefsDispatchEditorEvent.length; e6++) A2.current.editorRefsDispatchEditorEvent[e6](t3);
1700
+ } else {
1701
+ const o4 = t3?.coords ?? $2.current, r3 = m2(n3, o4);
1702
+ if (r3) {
1703
+ let n4;
1704
+ "boolean" != typeof n4 && (n4 = r3);
1705
+ const i2 = e5(o4, n4);
1706
+ i2 && i2.events.push(t3), A2.current = i2;
1707
+ }
1708
+ }
1709
+ } else if ("submit" === t3.eventType) {
1710
+ if (A2.current && !A2.current.isSubmitted && !A2.current.isCancelled) {
1711
+ if (!A2.current.isMounted) return;
1712
+ D2(A2.current);
1713
+ }
1714
+ } else if ("cancel" === t3.eventType) {
1715
+ if (A2.current && !A2.current.isSubmitted && !A2.current.isCancelled) {
1716
+ if (!A2.current.isMounted) return;
1717
+ L2(A2.current);
1718
+ }
1719
+ } else if ("coordsChange" === t3.eventType) {
1720
+ const e6 = t3;
1721
+ if ($2.current = e6.activeCoords, A2.current, A2.current && !A2.current.isSubmitted && !A2.current.isCancelled) {
1722
+ if (!A2.current.isMounted) return;
1723
+ try {
1724
+ D2(A2.current);
1725
+ } catch (e7) {
1726
+ }
1727
+ }
1728
+ }
1729
+ }
1730
+ F2.current.length > 0 && (F2.current.shift(), W2()), 0 === F2.current.length && (!A2.current || A2.current.isEditorClosing || A2.current.isEditorClosed ? !A2.current && o3 && R2() : A2.current.isMounted && !A2.current.isStarted && (A2.current.isStarted = true, A2.current.startEvent.autoFocus && ("string" == typeof A2.current.startEvent.autoFocus ? A2.current.editorRefs[0]?.autoFocus(A2.current.startEvent.autoFocus) : A2.current.editorRefs[0]?.autoFocus()), O2?.(A2.current), requestAnimationFrame(() => {
1731
+ n2 && A2.current?.coords && n2.scrollCellCoordsIntoView(A2.current.coords);
1732
+ })));
1733
+ }, [j2]), s(() => {
1734
+ B2.current = S2;
1735
+ const e5 = A2.current?.coords;
1736
+ if (!ne.isEqualCells(e5, S2)) {
1737
+ A2.current && (A2.current.isEditorClosing = true);
1738
+ W2({ eventType: "coordsChange", activeCoords: S2 });
1739
+ }
1740
+ }, [S2]);
1741
+ const q2 = i((e5) => {
1742
+ U2(e5.nativeEvent);
1743
+ }, []), { width: K2 = 0, height: Y2 = 0 } = C2 ?? { width: 0, height: 0 }, X2 = Tt(r2, [r2]);
1744
+ return { overlay: Tt((t3) => {
1745
+ if (!A2.current || A2.current.isEditorClosed) return A2.current, null;
1746
+ A2.current.coords;
1747
+ let n3 = T2(t3, A2.current.coords, K2, Y2, b2, E2), o3 = true;
1748
+ n3 && 0 !== n3.width && 0 !== n3.height || (n3 = { x: 0, y: 0, width: K2, height: K2 }, o3 = false);
1749
+ const r3 = t3.getZoom(), i2 = { containerBounds: { x: 0, y: 0, width: n3.width / r3, height: n3.height / r3 }, setNaturalDimensions: M2, zoom: r3 };
1750
+ return e(Wn, { session: A2.current, refLatestCoords: B2, handleSubmitEdit: D2, handleCancelEdit: L2, cellBounds: n3, borderStrokeWidth: v2, borderStrokeFill: y2, isInBounds: o3, getCellEditor: X2, propsEditor: i2, alignment: E2, ...x2 }, "editor:" + A2.current.uuid);
1751
+ }, [r2, b2, j2, K2, Y2, E2, v2, y2]), startEdit: i((e5) => {
1752
+ W2({ eventType: "start", startEvent: e5 });
1753
+ }, []), submitEdit: i(() => {
1754
+ W2({ eventType: "submit" });
1755
+ }, []), cancelEdit: i(() => {
1756
+ W2({ eventType: "cancel" });
1757
+ }, []), onKeyboardEvent: q2, onPointerEvent: N2, onKeyboardEventNative: U2, onPointerEventNative: H2, isEditing: _2 };
1758
+ }, Nn = ({ gridRef: e5, gridMainRef: t2, orientation: n2 = $, headerCount: o2, selectionPolicy: r2 = "multiple", newSelectionMode: s2 = "clear", alwaysScrollToActiveCoords: c2 = true, onDragStart: a2, onDragEnd: u2, pointerDownInterceptor: h2, pointerMoveInterceptor: f2, onPointerUp: p2, newSelection: g2, modifySelection: w2, appendSelection: m2, clearSelections: x2 }) => {
1759
+ const y2 = o2 ?? ((n2 === $ ? e5.current?.rowCount : e5.current?.columnCount) || 0), v2 = l(null), b2 = l(null), S2 = l(false), E2 = l(null), _2 = i((e6) => n2 === A ? { rowIndex: 0, colIndex: e6.colIndex } : { rowIndex: e6.rowIndex, colIndex: 0 }, [n2]), I2 = i((e6) => n2 === A ? { rowIndex: t2.current ? t2.current.rowCount - 1 : 0, colIndex: e6.colIndex } : { rowIndex: e6.rowIndex, colIndex: t2.current ? t2.current.columnCount - 1 : 0 }, [n2]), C2 = (e6) => {
1760
+ b2.current = I2(e6), w2(b2.current, v2.current);
1761
+ }, M2 = i((o3, r3) => {
1762
+ if (!e5.current) return;
1763
+ const i2 = e5.current.getViewFromClient(o3, r3)?.getCellCoordsFromClient(o3, r3);
1764
+ return i2 ? (n2 === A ? i2.rowIndex = t2.current.getViewport().rowStart : i2.colIndex = t2.current.getViewport().colStart, i2) : void 0;
1765
+ }, []), T2 = i((e6, o3 = false) => {
1766
+ let r3 = e6;
1767
+ return o3 || (r3 = { ...e6 }, n2 === $ ? delete r3.colIndex : delete r3.rowIndex), t2.current?.scrollCellCoordsIntoView(r3);
1768
+ }, [n2]), k2 = Tt(u2, [u2]), R2 = Tt(a2, [a2]), P2 = d(() => ({ onPointerDown: (o3) => {
1769
+ if (!e5 || !e5.current) return;
1770
+ if (o3.nativeEvent.defaultPrevented) return;
1771
+ const r3 = M2(o3.nativeEvent.clientX, o3.nativeEvent.clientY);
1772
+ if (!r3) return;
1773
+ o3.nativeEvent.which;
1774
+ const i2 = o3.nativeEvent.shiftKey, l2 = o3.nativeEvent.ctrlKey || o3.nativeEvent.metaKey;
1775
+ if (false === h2?.(o3, r3)) return;
1776
+ R2?.(), S2.current = true;
1777
+ const s3 = t2.current?.getViewFromClient(o3.nativeEvent.clientX, o3.nativeEvent.clientY), a3 = ((e6, t3) => n2 === A ? { ...e6, rowIndex: t3.rowStart } : { ...e6, colIndex: t3.colStart })(r3, s3.getVisibleRangeCoords());
1778
+ if (i2) C2(r3);
1779
+ else {
1780
+ if (l2) return ((e6, t3 = e6, n3) => {
1781
+ v2.current = _2(e6), b2.current = I2(t3), m2(v2.current, b2.current, n3);
1782
+ })(r3, r3, a3), void (c2 && T2(a3, true));
1783
+ ((e6, t3 = e6, n3) => {
1784
+ v2.current = _2(e6), b2.current = I2(t3), g2(v2.current, b2.current, n3);
1785
+ })(r3, r3, a3), C2(r3), c2 && T2(a3, true);
1786
+ }
1787
+ }, onPointerMoveOrWait: Me.throttle((t3) => {
1788
+ if (!S2.current || !e5?.current) return;
1789
+ const n3 = M2(t3.clientX, t3.clientY);
1790
+ if (n3 && false !== f2?.(t3, n3)) {
1791
+ if (ne.isEqualCells(E2.current, n3)) return x2();
1792
+ C2(n3), T2(n3);
1793
+ }
1794
+ }, 60), onPointerUp: (e6) => {
1795
+ S2.current = false, k2?.(), p2?.(e6);
1796
+ }, processTouch: true, consumeTouch: true }), [r2, c2, y2, s2, x2, h2, p2]);
1797
+ return { onPointerDown: Tt(hn(P2), []), getCellCoordsFromClient: M2 };
1798
+ }, Un = (e5, t2, n2) => {
1799
+ if (!e5) return t2;
1800
+ let o2 = t2;
1801
+ const r2 = n2 === I || n2 === E;
1802
+ for (; ; ) {
1803
+ const t3 = e5(o2, !r2);
1804
+ if (0 === t3) return o2;
1805
+ r2 ? o2 += t3 : o2 -= t3;
1806
+ }
1807
+ }, qn = (e5, t2, n2) => {
1808
+ const o2 = [];
1809
+ let r2 = t2;
1810
+ for (; r2 <= n2; ) {
1811
+ const t3 = Math.max(0, e5(r2));
1812
+ 0 === t3 ? (o2.push(r2), r2++) : r2 += t3;
1813
+ }
1814
+ return o2;
1815
+ }, Kn = (e5, t2, n2, o2, r2, i2) => {
1816
+ if (!t2) return i2;
1817
+ let { rowIndex: l2, colIndex: s2 } = e5;
1818
+ switch (o2) {
1819
+ case E: {
1820
+ l2 = Un(n2, Math.min(l2 + 1, i2), o2);
1821
+ let e6 = t2({ rowIndex: l2, colIndex: s2 });
1822
+ for (; !e6 && l2 < i2; ) l2 = Un(n2, Math.min(++l2, i2), o2), e6 = t2({ rowIndex: l2, colIndex: s2 });
1823
+ return l2;
1824
+ }
1825
+ case S: {
1826
+ l2 = Un(n2, Math.max(l2 - 1, i2), o2);
1827
+ let e6 = t2({ rowIndex: l2, colIndex: s2 });
1828
+ for (; !e6 && l2 > i2; ) l2 = Un(n2, Math.max(--l2, i2), o2), e6 = t2({ rowIndex: l2, colIndex: s2 });
1829
+ return l2;
1830
+ }
1831
+ case I: {
1832
+ s2 = Un(n2, Math.min(s2 + 1, i2), o2);
1833
+ let e6 = t2({ rowIndex: l2, colIndex: s2 });
1834
+ for (; !e6 && s2 < i2; ) s2 = Un(n2, Math.min(++s2, i2), o2), e6 = t2({ rowIndex: l2, colIndex: s2 });
1835
+ return s2;
1836
+ }
1837
+ case _: {
1838
+ s2 = Un(n2, Math.max(s2 - 1, i2), o2);
1839
+ let e6 = t2({ rowIndex: l2, colIndex: s2 });
1840
+ for (; !e6 && s2 > i2; ) s2 = Un(n2, Math.max(--s2, i2), o2), e6 = t2({ rowIndex: l2, colIndex: s2 });
1841
+ return s2;
1842
+ }
1843
+ default:
1844
+ return i2;
1845
+ }
1846
+ }, Yn = (e5, t2 = () => true, n2, o2, r2, i2) => {
1847
+ let { rowIndex: l2, colIndex: s2 } = e5;
1848
+ switch (o2) {
1849
+ case E: {
1850
+ l2 = Un(n2, Math.min(l2 + 1, i2), o2);
1851
+ let e6 = t2?.({ rowIndex: l2, colIndex: s2 });
1852
+ for (; e6 && l2 < i2; ) l2 = Un(n2, Math.min(++l2, i2), o2), e6 = t2?.({ rowIndex: l2, colIndex: s2 });
1853
+ return t2?.({ rowIndex: l2, colIndex: s2 }) ? l2 : l2 - 1;
1854
+ }
1855
+ case S: {
1856
+ l2 = Un(n2, Math.max(l2 - 1, i2), o2);
1857
+ let e6 = t2?.({ rowIndex: l2, colIndex: s2 });
1858
+ for (; e6 && l2 > i2; ) l2 = Un(n2, Math.max(--l2, i2), o2), e6 = t2?.({ rowIndex: l2, colIndex: s2 });
1859
+ return t2?.({ rowIndex: l2, colIndex: s2 }) ? l2 : l2 + 1;
1860
+ }
1861
+ case I: {
1862
+ s2 = Un(n2, Math.min(s2 + 1, i2), o2);
1863
+ let e6 = t2?.({ rowIndex: l2, colIndex: s2 });
1864
+ for (; e6 && s2 < i2; ) s2 = Un(n2, Math.min(++s2, i2), o2), e6 = t2?.({ rowIndex: l2, colIndex: s2 });
1865
+ return t2?.({ rowIndex: l2, colIndex: s2 }) ? s2 : s2 - 1;
1866
+ }
1867
+ case _: {
1868
+ s2 = Un(n2, Math.max(s2 - 1, i2), o2);
1869
+ let e6 = t2?.({ rowIndex: l2, colIndex: s2 });
1870
+ for (; e6 && s2 > i2; ) s2 = Un(n2, Math.max(--s2, i2), o2), e6 = t2?.({ rowIndex: l2, colIndex: s2 });
1871
+ return t2?.({ rowIndex: l2, colIndex: s2 }) ? s2 : s2 + 1;
1872
+ }
1873
+ default:
1874
+ return null;
1875
+ }
1876
+ }, Xn = (e5, t2, n2, o2, r2, i2) => {
1877
+ if (!t2) return i2;
1878
+ let l2, { rowIndex: s2, colIndex: c2 } = e5;
1879
+ o2 === E ? l2 = { rowIndex: s2 + 1, colIndex: c2 } : o2 === S ? l2 = { rowIndex: s2 - 1, colIndex: c2 } : o2 === I ? l2 = { rowIndex: s2, colIndex: c2 + 1 } : o2 === _ && (l2 = { rowIndex: s2, colIndex: c2 - 1 });
1880
+ const a2 = t2(e5), d2 = t2(l2);
1881
+ var u2, h2;
1882
+ return (h2 = d2, !(u2 = a2) && !h2 || !u2 && h2 || u2 && !h2 ? Kn : Yn)(e5, t2, n2, o2, false, i2) ?? i2;
1883
+ }, Gn = (e5, t2) => `${e5}:${t2}`, Zn = (e5, t2, n2, o2, r2, i2) => {
1884
+ if (n2 - t2 >= r2 - o2) return o2;
1885
+ let l2 = o2;
1886
+ if ("nearest" === e5 && (o2 - t2 > 0 ? e5 = "start" : n2 - r2 > 0 && (e5 = "end")), "start" === e5) l2 = t2;
1887
+ else if ("end" === e5) l2 = n2 - (r2 - o2);
1888
+ else if ("center" === e5) {
1889
+ l2 = t2 + (n2 - t2) / 2 - (r2 - o2) / 2;
1890
+ }
1891
+ return Math.max(0, Math.min(l2, i2 - (r2 - o2)));
1892
+ }, Jn = (e5, t2, n2, o2) => (console.log("todo: implement convertToVisibleRanges"), e5), Qn = (e5, t2 = I, n2, o2, r2, i2 = null) => {
1893
+ if (i2 && ne.isEqualSelectionCoords(i2, e5)) return e5;
1894
+ const l2 = e5.ranges[e5.rangeIndex];
1895
+ if (!ne.isRangesIntersect({ rowStart: e5.cell.rowIndex, colStart: e5.cell.colIndex, rowEnd: e5.cell.rowIndex, colEnd: e5.cell.colIndex }, l2)) return e5;
1896
+ let s2 = { ...e5.cell }, c2 = e5.rangeIndex;
1897
+ switch (t2) {
1898
+ case I:
1899
+ s2.colIndex = Un(r2, s2.colIndex + 1, t2);
1900
+ break;
1901
+ case _:
1902
+ s2.colIndex = Un(r2, s2.colIndex - 1, t2);
1903
+ break;
1904
+ case E:
1905
+ s2.rowIndex = Un(o2, s2.rowIndex + 1, t2);
1906
+ break;
1907
+ case S:
1908
+ s2.rowIndex = Un(o2, s2.rowIndex - 1, t2);
1909
+ }
1910
+ const a2 = (t3) => {
1911
+ if (t3) {
1912
+ c2 = e5.rangeIndex >= e5.ranges.length - 1 ? 0 : e5.rangeIndex + 1;
1913
+ const t4 = e5.ranges[c2];
1914
+ s2 = { colIndex: t4.colStart, rowIndex: t4.rowStart };
1915
+ } else {
1916
+ c2 = e5.rangeIndex <= 0 ? e5.ranges.length - 1 : e5.rangeIndex - 1;
1917
+ const t4 = e5.ranges[c2];
1918
+ s2 = { colIndex: t4.colEnd, rowIndex: t4.rowEnd };
1919
+ }
1920
+ };
1921
+ if (t2 === I && s2.colIndex > l2.colEnd && s2.rowIndex === l2.rowEnd) a2(true);
1922
+ else if (t2 === _ && s2.colIndex < l2.colStart && s2.rowIndex === l2.rowStart) a2(false);
1923
+ else if (t2 === E && s2.colIndex === l2.colEnd && s2.rowIndex > l2.rowEnd) a2(true);
1924
+ else if (t2 === S && s2.colIndex === l2.colStart && s2.rowIndex < l2.rowStart) a2(false);
1925
+ else {
1926
+ let e6 = s2.rowIndex, n3 = s2.colIndex;
1927
+ switch (t2) {
1928
+ case I:
1929
+ n3 > l2.colEnd && (e6 = Un(o2, e6 + 1, t2), n3 = l2.colStart, e6 > l2.rowEnd && (e6 = l2.rowStart));
1930
+ break;
1931
+ case _:
1932
+ n3 < l2.colStart && (e6 = Un(o2, e6 - 1, t2), n3 = l2.colEnd, e6 < l2.rowStart && (e6 = l2.rowEnd));
1933
+ break;
1934
+ case E:
1935
+ e6 > l2.rowEnd && (n3 = Un(r2, n3 + 1, t2), e6 = l2.rowStart, n3 > l2.colEnd && (n3 = l2.colStart));
1936
+ break;
1937
+ case S:
1938
+ e6 < l2.rowStart && (n3 = Un(r2, n3 - 1, t2), e6 = l2.rowEnd, n3 < l2.colStart && (n3 = l2.colEnd));
1939
+ }
1940
+ s2 = { rowIndex: e6, colIndex: n3 };
1941
+ }
1942
+ let d2 = n2(s2);
1943
+ if (!ne.isRangeWithinRange(d2, l2)) {
1944
+ const e6 = ne.intersectRanges(d2, l2);
1945
+ e6 && (d2 = e6);
1946
+ }
1947
+ let u2 = { rowStart: Un(o2, d2.rowStart, E), colStart: Un(r2, d2.colStart, I), rowEnd: Un(o2, d2.rowEnd, S), colEnd: Un(r2, d2.colEnd, _) };
1948
+ if (u2.rowStart !== s2.rowIndex || u2.colStart !== s2.colIndex) {
1949
+ switch (t2) {
1950
+ case I:
1951
+ e5.ranges[c2].colStart === u2.colStart && e5.ranges[c2].colEnd === u2.colEnd && (s2.rowIndex = u2.rowEnd), s2.colIndex = u2.colEnd;
1952
+ break;
1953
+ case _:
1954
+ e5.ranges[c2].colStart === u2.colStart && e5.ranges[c2].colEnd === u2.colEnd && (s2.rowIndex = u2.rowStart), s2.rowIndex === u2.rowStart ? s2.colIndex = u2.colStart + 1 : s2.colIndex = u2.colStart;
1955
+ break;
1956
+ case E:
1957
+ e5.ranges[c2].rowStart === u2.rowStart && e5.ranges[c2].rowEnd === u2.rowEnd && (s2.colIndex = u2.colEnd), s2.rowIndex = u2.rowEnd;
1958
+ break;
1959
+ case S:
1960
+ e5.ranges[c2].rowStart === u2.rowStart && e5.ranges[c2].rowEnd === u2.rowEnd && (s2.colIndex = u2.colStart), s2.colIndex === u2.colStart ? s2.rowIndex = u2.rowStart + 1 : s2.rowIndex = u2.rowStart;
1961
+ }
1962
+ return Qn({ cell: s2, ranges: e5.ranges, rangeIndex: c2 }, t2, n2, o2, r2, i2 ?? e5);
1963
+ }
1964
+ return { ranges: e5.ranges, cell: s2, rangeIndex: c2 };
1965
+ }, eo = (e5, t2) => {
1966
+ let n2, o2 = 0, r2 = 0;
1967
+ return t2.colStart < e5.colStart ? (n2 = _, o2 = e5.colStart - t2.colStart, r2 = t2.colStart) : t2.colEnd > e5.colEnd ? (n2 = I, o2 = t2.colEnd - e5.colEnd, r2 = t2.colEnd) : t2.rowStart < e5.rowStart ? (n2 = S, o2 = e5.rowStart - t2.rowStart, r2 = t2.rowStart) : t2.rowEnd > e5.rowEnd && (n2 = E, o2 = t2.rowEnd - e5.rowEnd, r2 = t2.rowEnd), { direction: n2, amount: o2, index: r2 };
1968
+ }, to = (e5, t2 = false, n2, o2) => {
1969
+ if (!n2) return 0;
1970
+ const r2 = !t2, i2 = r2 ? 1 : -1;
1971
+ let l2 = n2(r2 ? e5 : e5 + 1), s2 = n2(r2 ? e5 + 1 : e5), c2 = e5 + (r2 ? 2 : -1), a2 = 0;
1972
+ for (; (s2 - l2) * i2 <= 0; ) {
1973
+ if (r2 && c2 - 1 > o2 + 1 || !r2 && c2 + 1 < o2) return a2;
1974
+ l2 = s2, s2 = n2(c2), c2 += i2, a2++;
1975
+ }
1976
+ return a2;
1977
+ }, no = (e5, t2, n2, o2, r2) => {
1978
+ const i2 = {};
1979
+ let l2 = null, s2 = null;
1980
+ for (let c2 = 0; c2 <= n2.length && n2[c2] <= r2; c2++) {
1981
+ const r3 = n2[c2];
1982
+ if (r3 < o2) continue;
1983
+ const a2 = l2 === r3 ? s2 : t2 ? e5.getColOffset(r3) : e5.getRowOffset(r3), d2 = t2 ? e5.getColOffset(r3 + 1) : e5.getRowOffset(r3 + 1);
1984
+ l2 = r3 + 1, s2 = d2, i2[r3] = Object.freeze({ offset: a2, size: d2 - a2, spanIndex: c2 });
1985
+ }
1986
+ return Object.freeze(i2);
1987
+ }, oo = (e5, t2, n2) => {
1988
+ const o2 = e5.getColOffset(t2.colStart) + (n2?.left ?? 0), r2 = e5.getRowOffset(t2.rowStart) + (n2?.top ?? 0);
1989
+ return { x: o2, y: r2, width: e5.getColOffset(t2.colEnd + 1) + (n2?.right ?? 0) - (n2?.left ?? 0) - o2, height: e5.getRowOffset(t2.rowEnd + 1) + (n2?.bottom ?? 0) - (n2?.top ?? 0) - r2 };
1990
+ }, ro = (e5, t2, n2) => !!n2 && (!(e5 < n2.x || e5 > n2.x + n2.width) && !(t2 < n2.y || t2 > n2.y + n2.height)), io = (e5, t2 = true) => `M ${Ut.boundPixel(e5.left)} ${Ut.boundPixel(e5.top)} L ${Ut.boundPixel(e5.right, true)} ${Ut.boundPixel(e5.top)} L ${Ut.boundPixel(e5.right, true)} ${Ut.boundPixel(e5.bottom, true)} L ${Ut.boundPixel(e5.left)} ${Ut.boundPixel(e5.bottom, true)} L ${Ut.boundPixel(e5.left)} ${Ut.boundPixel(e5.top)} ${t2 ? "Z" : ""}`, lo = (t2) => {
1991
+ const { linePoints: n2, bounds: o2, pathProps: r2, style: i2, ...l2 } = t2;
1992
+ return e("svg", { width: `${Ut.boundPixel(o2.width, true)}`, height: `${Ut.boundPixel(o2.height, true)}`, viewBox: `0 0 ${Ut.boundPixel(o2.width, true)} ${Ut.boundPixel(o2.height, true)}`, style: { position: "absolute", left: `${Ut.boundPixel(o2.x)}px`, top: `${Ut.boundPixel(o2.y)}px`, width: `${Ut.boundPixel(o2.width, true)}px`, height: `${Ut.boundPixel(o2.height, true)}px`, pointerEvents: "none", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top, width, height", willChange: "left, top, width, height, stroke-dashoffset", ...i2 }, ...l2, children: e("path", { d: `M ${Ut.boundPixel(n2[0])} ${Ut.boundPixel(n2[1])} L ${Ut.boundPixel(n2[2])} ${Ut.boundPixel(n2[3])}`, fill: "none", vectorEffect: "non-scaling-stroke", stroke: "black", ...r2 }) });
1993
+ }, so = (n2) => {
1994
+ const { x: o2 = 0, y: r2 = 0, width: i2 = 0, height: l2 = 0, fill: s2, stroke: c2, strokeWidth: a2 = 0, strokeDasharray: d2, strokeDashoffset: u2, clipPath: h2, pathBounds: f2, pathProps: p2, style: g2, ...w2 } = n2, m2 = r2, x2 = o2, y2 = i2, v2 = l2;
1995
+ let b2 = null;
1996
+ if (s2) {
1997
+ let t2 = io({ top: 0, left: 0, bottom: v2, right: y2 });
1998
+ f2 && (t2 = t2 + " " + io({ top: f2.y - m2, left: f2.x - x2, bottom: f2.height + f2.y - m2, right: f2.width + f2.x - x2 })), b2 = [e("path", { d: t2, fill: s2, stroke: "none", fillRule: "evenodd" }, "fill")];
1999
+ }
2000
+ return t("svg", { width: `${Ut.boundPixel(i2, true)}`, height: `${Ut.boundPixel(l2, true)}`, viewBox: `0 0 ${Ut.boundPixel(i2, true)} ${Ut.boundPixel(l2, true)}`, preserveAspectRatio: "none", style: { position: "absolute", left: `${Ut.boundPixel(o2)}px`, top: `${Ut.boundPixel(r2)}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", ...g2 }, ...w2, children: [b2, e("path", { d: io({ top: 0, left: 0, right: y2, bottom: v2 }), fill: "none", strokeDasharray: d2, strokeDashoffset: u2, stroke: c2, vectorEffect: "non-scaling-stroke", strokeWidth: a2, ...p2 })] });
2001
+ }, co = (t2) => {
2002
+ const { key: n2, ...o2 } = t2;
2003
+ return e(ao, { ...o2 }, n2);
2004
+ }, ao = r((t2) => {
2005
+ const { stroke: n2, fill: o2, x: r2 = 0, y: i2 = 0, width: l2 = 0, height: c2 = 0, style: a2, isAnimatedStroke: d2, animatedStrokeProps: u2, range: h2, cell: f2, ...p2 } = t2, g2 = d2 || !!u2, w2 = { name: "walking-offset", dashGap: 2, speed: 50, dashLength: 8, ...u2 };
2006
+ let m2 = w2.dashGap + w2.dashLength;
2007
+ const x2 = w2.speed * m2, y2 = Pn().replaceAll(":", ""), v2 = `${w2.name}-${y2}`;
2008
+ let b2;
2009
+ return s(() => {
2010
+ if (!g2) return;
2011
+ const e5 = `@keyframes ${v2} {
2012
+ to {
2013
+ stroke-dashoffset: 0px;
2014
+ }
2015
+ }`, t3 = document.createElement("style");
2016
+ t3.appendChild(document.createTextNode(e5)), document.head.appendChild(t3);
2017
+ return t3.sheet.insertRule(e5, 0), () => {
2018
+ document.head.removeChild(t3);
2019
+ };
2020
+ }, [g2]), g2 && (b2 = { strokeDasharray: `${w2.dashLength}px ${w2.dashGap}px`, strokeDashoffset: `${m2}px`, animation: `${v2} ${x2}ms linear infinite`, willChange: "stroke-dashoffset" }), e(so, { x: r2, y: i2, width: l2, height: c2, stroke: n2, fill: o2, shapeRendering: "crispEdges", style: { ...b2, ...a2 }, ...p2 });
2021
+ });
2022
+ ao.displayName = "Selection";
2023
+ const uo = r(a((t2, n2) => {
2024
+ const { x: o2 = 0, y: r2 = 0, borderWidth: i2 = 1, size: l2 = 6, borderStroke: s2, corner: c2, style: a2, className: d2, background: u2, ...h2 } = t2;
2025
+ if (0 === o2 || 0 === r2) return null;
2026
+ let f2 = true, p2 = true, w2 = true, m2 = true;
2027
+ switch (c2) {
2028
+ case "tl":
2029
+ f2 = false, p2 = false;
2030
+ break;
2031
+ case "bl":
2032
+ f2 = false, m2 = false;
2033
+ break;
2034
+ case "br":
2035
+ w2 = false, m2 = false;
2036
+ break;
2037
+ case "tr":
2038
+ p2 = false, w2 = false;
2039
+ }
2040
+ return e("div", { className: g("fill-handle", d2), style: { position: "absolute", left: o2 - (l2 + (f2 ? i2 : 0)) / 2, top: r2 - (l2 + (p2 ? i2 : 0)) / 2, width: l2, height: l2, borderLeft: f2 ? `${i2}px ${s2}` : void 0, borderTop: p2 ? `${i2}px ${s2}` : void 0, borderRight: w2 ? `${i2}px ${s2}` : void 0, borderBottom: m2 ? `${i2}px ${s2}` : void 0, background: u2, cursor: "crosshair", pointerEvents: "all", transitionDuration: "0ms", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top", willChange: "left, top", ...a2 }, tabIndex: -1, ...h2 });
2041
+ }));
2042
+ uo.displayName = "FillHandle";
2043
+ const ho = r(a((o2, r2) => {
2044
+ const { range: i2, view: c2, anchor: a2, borderStroke: u2 = "rgb(33, 115, 70)", background: f2 = "white", borderWidth: p2 = 1.5, size: x2 = 22, style: y2, className: b2, selectionTouchPointerHandler: S2, onTouchSelectStart: E2, onTouchSelectEnd: _2, currentTouchAnchor: I2, scrollableElement: C2, scrollableRoot: M2 = document.body, ...T2 } = o2, k2 = Tt(E2, [E2]), R2 = Tt(_2, [_2]), { bounds: P2, coordsPivot: O2, key: L2 } = d(() => {
2045
+ if (!i2 || !c2) return null;
2046
+ let e5 = null, t2 = null;
2047
+ switch (a2) {
2048
+ case "tl":
2049
+ e5 = { colIndex: i2.colEnd, rowIndex: i2.rowEnd }, t2 = { colIndex: i2.colStart, rowIndex: i2.rowStart };
2050
+ break;
2051
+ case "br":
2052
+ e5 = { colIndex: i2.colStart, rowIndex: i2.rowStart }, t2 = { colIndex: i2.colEnd, rowIndex: i2.rowEnd };
2053
+ break;
2054
+ case "t":
2055
+ case "l":
2056
+ e5 = { colIndex: i2.colEnd, rowIndex: i2.rowEnd };
2057
+ break;
2058
+ case "b":
2059
+ e5 = { colIndex: i2.colStart, rowIndex: i2.rowStart };
2060
+ break;
2061
+ case "r":
2062
+ e5 = { colIndex: i2.colStart, rowIndex: i2.rowEnd };
2063
+ }
2064
+ let n2 = c2.getRangeCoordsBounds(t2 ? { rowStart: t2.rowIndex, colStart: t2.colIndex, rowEnd: t2.rowIndex, colEnd: t2.colIndex } : i2);
2065
+ const o3 = c2.getBounds(), r3 = c2.getViewportSize(), l2 = o3.x, s2 = o3.y, d2 = r3.width, u3 = r3.height;
2066
+ switch (a2) {
2067
+ case "tl":
2068
+ break;
2069
+ case "br":
2070
+ n2.x = n2.x + n2.width, n2.y = n2.y + n2.height;
2071
+ break;
2072
+ case "t":
2073
+ n2.x = d2 / 2 - l2;
2074
+ break;
2075
+ case "b":
2076
+ n2.x = d2 / 2 - l2, n2.y = n2.y + n2.height;
2077
+ break;
2078
+ case "l":
2079
+ n2.y = u3 / 2 - s2;
2080
+ break;
2081
+ case "r":
2082
+ n2.x = n2.x + n2.width, n2.y = u3 / 2 - s2;
2083
+ }
2084
+ const h2 = c2.toClipBounds(n2, 0);
2085
+ return !h2 || h2.width <= 0 || h2.height <= 0 || n2.x < 0 || n2.y < 0 || n2.x > d2 || n2.y > u3 ? { bounds: null, coordsAnchor: null, coordsPivot: null, key: null } : { bounds: n2, coordsAnchor: null, coordsPivot: e5, key: "touchSelect-" + c2.getAnchor() + "-" + a2 };
2086
+ }, [i2, c2, a2]), D2 = l(null), z2 = hn(d(() => {
2087
+ const e5 = (e6) => "t" === a2 || "b" === a2 ? { ...e6, colIndex: void 0 } : "l" === a2 || "r" === a2 ? { ...e6, rowIndex: void 0 } : e6;
2088
+ return { processTouch: true, consumeTouch: true, onPointerDown: (t2, n2) => {
2089
+ const o3 = e5(c2.getCellCoordsFromClient(t2.clientX, t2.clientY));
2090
+ return D2.current = { coordsPivot: O2 }, k2?.(a2), S2.onSelectionPointerDown(t2, n2, c2, o3, O2, false, true);
2091
+ }, onPointerMoveOrWait: (t2, n2, o3) => {
2092
+ const r3 = e5(c2.getCellCoordsFromClient(t2.clientX, t2.clientY));
2093
+ return S2.onSelectionPointerMoveOrWait(t2, n2, o3, c2, r3, D2.current?.coordsPivot, true, true);
2094
+ }, onPointerUp: (e6, t2, n2) => (D2.current = null, R2?.(a2), S2.onPointerUp(e6, t2, n2)) };
2095
+ }, [S2, i2, c2, a2])), [A2, { y: $2, x: B2 }] = w(), F2 = l(null), { getPortalContainer: j2 } = Qt(), [V2, W2] = h(null);
2096
+ return s(() => {
2097
+ const t2 = F2.current?.getBoundingClientRect();
2098
+ if (!t2 || !P2) return void W2(null);
2099
+ let n2 = 0, o3 = 0, i3 = C2;
2100
+ for (; i3; ) n2 += i3.scrollLeft, o3 += i3.scrollTop, i3 = M2 && i3 === M2.parentElement ? null : i3.parentElement;
2101
+ W2(v(e("div", { className: g("touch-select-handle", b2), ref: r2, style: { position: "absolute", left: n2 + (t2?.x ?? 0) - (x2 + p2) / 2, top: o3 + (t2?.y ?? 0) - (x2 + p2) / 2, width: x2, height: x2, borderWidth: `${p2}px`, border: u2, borderRadius: "50%", background: f2, boxShadow: `0 0 0 1.5px ${f2}`, cursor: "grab", pointerEvents: "all", opacity: I2 ? 0 : 1, transitionDuration: "160ms", transitionProperty: "opacity", ...y2 }, tabIndex: -1, onPointerDown: z2, ...T2 }), M2 ?? j2(), L2));
2102
+ }, [$2, B2, P2?.x, P2?.y, P2?.width, P2?.height, b2, I2, f2, x2, p2, u2, C2]), P2 ? t(n, { children: [e("div", { ref: m([A2, F2]), style: { position: "absolute", left: P2.x, top: P2.y, opacity: 0 } }), V2] }) : null;
2103
+ }));
2104
+ ho.displayName = "TouchSelectHandle";
2105
+ const fo = -10, po = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd: 0 }), go = Object.freeze({ colIndex: 0, rowIndex: 0 }), wo = Object.freeze([]), mo = (e5) => {
2106
+ if (e5 && e5.cell && e5.ranges && e5.rangeIndex > -1 && e5.rangeIndex <= e5.ranges.length) return e5;
2107
+ const t2 = { cell: null, ranges: e5?.ranges ?? wo };
2108
+ return t2.rangeIndex = e5?.rangeIndex ?? t2.ranges.length - 1, t2.cell = e5?.cell, !t2.cell && t2.ranges.length > 0 && (t2.cell = { rowIndex: t2.ranges[t2.rangeIndex].rowStart, colIndex: t2.ranges[t2.rangeIndex].colStart }), t2.cell || (t2.cell = go), ne.isEqualSelectionCoords(t2, e5) ? e5 : t2;
2109
+ }, xo = (e5, t2, n2) => {
2110
+ const o2 = e5.getVisibleRangeCoords(), r2 = e5.getScrollOrientation();
2111
+ !r2.horizontal && (t2.colIndex > o2.colEnd || t2.colIndex < o2.colStart) && (t2 = { ...t2, colIndex: t2.colIndex > o2.colEnd ? o2.colEnd + 1 : o2.colEnd - 1 }, e5 = n2.current.getViewFromLocation(k)), !r2.vertical && (t2.rowIndex > o2.rowEnd || t2.rowIndex < o2.rowStart) && (t2 = { ...t2, rowIndex: t2.rowIndex > o2.rowEnd ? o2.rowEnd + 1 : o2.rowEnd - 1 }, e5 = n2.current.getViewFromLocation(k)), e5.scrollCellCoordsIntoView(t2);
2112
+ }, yo = () => false, vo = ({ gridRef: t2, commands: n2, layout: o2, selection: r2, onSelectionChange: c2, onSelectionDragStart: a2, onSelectionDragEnd: p2, selectionPolicy: g2 = "multiple", newSelectionMode: w2 = "clear", allowDeselectSelection: m2 = true, onFillPreview: x2, onFillCancel: y2, onFillDone: v2, onFill: b2, disableFillDrag: R2 = !b2, fillHandleBorderColor: P2 = "white", hiddenRowsAt: O2, hiddenColumnsAt: L2, isContentfulCell: D2, contentfulCellFinder: z2 = Xn, getDataCoords: A2, alwaysScrollToActiveCoords: $2 = false, selectionBounds: B2, pointerDownInterceptor: F2, pointerMoveInterceptor: j2, mergedRanges: V2, canSelectionSpanMergedCells: W2 = yo, onMoveDragStart: H2, onMoveDragUpdate: N2, onMoveDragEnd: U2, onMoveDragDone: q2, selectionRenderer: K2 = co, disableMoveDrag: Y2 = !U2, getCellCoordsAsRangeCoords: X2 = ne.cellToRange, moveDragHitSize: G2 = 6, moveDragOutlineSize: Z2 = 4, selectionBackgroundColor: J2 = "rgba(16, 124, 65, 0.1)", selectionBorderColor: Q2 = "rgb(33, 115, 70)", selectionRemoveBorderColor: ee2 = "rgb(255, 0, 0)", selectionRemoveBackgroundColor: te2 = "rgba(250, 10, 10, 0.1)", disableTouchSelection: oe2 = false, touchSelectHandleProps: re2 }) => {
2113
+ const ie2 = i(() => ({ top: B2?.top ?? 0, left: B2?.left ?? 0, bottom: t2.current?.rowCount - 1 || 0, right: t2.current?.columnCount - 1 || 0 }), []), le2 = Tt(b2, [b2]), se2 = Tt(x2, [x2]), ce2 = Tt(y2, [y2]), ae2 = Tt(v2, [v2]), de2 = Tt(D2, [D2]), ue2 = Tt(K2, [K2]), he2 = Tt((e5, t3 = false) => to(e5, t3, o2.getRowOffset, t3 ? ie2().bottom : ie2().top), [o2?.getRowOffset]), fe2 = Tt(O2 ?? he2, [O2]), pe2 = Tt((e5, t3 = false) => to(e5, t3, o2.getColOffset, t3 ? ie2().right : ie2().left), [o2?.getColOffset]), ge2 = Tt(L2 ?? pe2, [L2]), [we2, me2] = h(() => mo(r2)), xe2 = d(() => mo(we2), [we2]), ye2 = l(xe2), ve2 = l(true);
2114
+ u(Me.throttle(() => {
2115
+ me2((e5) => {
2116
+ ve2.current = true;
2117
+ const t3 = mo(r2);
2118
+ return ne.isEqualSelectionCoords(t3, e5) ? e5 : t3;
2119
+ });
2120
+ }, 0), [r2]), u(() => {
2121
+ ye2.current = xe2;
2122
+ }, [xe2]), s(() => {
2123
+ ve2.current || !c2 || ne.isEqualSelectionCoords(r2, xe2) || c2(xe2);
2124
+ }, [xe2]);
2125
+ const be2 = i((e5) => {
2126
+ me2((t3) => {
2127
+ ve2.current = false, t3 = mo(t3);
2128
+ let n3 = "function" == typeof e5 ? e5(t3.ranges) : e5 ?? wo;
2129
+ if (ne.isEqualRangesArrays(n3, t3.ranges)) return t3;
2130
+ let o3 = Math.max(n3.length ? 0 : -1, Math.min(t3.rangeIndex, n3.length - 1)), r3 = t3.cell;
2131
+ -1 === o3 || ne.isCellWithinRange(r3, n3[o3]) || (r3 = { rowIndex: n3[o3].rowStart, colIndex: n3[o3].colStart }), 1 === n3.length && ne.isSingleCell(n3[0]) && ne.isCellWithinRange(r3, n3[0]) && (n3 = [], o3 = -1);
2132
+ const i2 = { cell: r3, ranges: n3, rangeIndex: o3 };
2133
+ return ne.isEqualSelectionCoords(i2, t3) ? t3 : i2;
2134
+ });
2135
+ }, []), Se2 = Tt((e5) => {
2136
+ me2((t3) => {
2137
+ ve2.current = false, t3 = mo(t3);
2138
+ const n3 = e5 ?? go, o3 = X2(n3);
2139
+ if (!ne.isSingleCell(o3) && 0 === t3.ranges.length) return { ranges: [o3], rangeIndex: 0, cell: n3 };
2140
+ if (ne.isEqualCells(n3, t3.cell)) return t3;
2141
+ let r3 = t3.ranges, i2 = t3.rangeIndex;
2142
+ 1 === t3.ranges.length && (ne.isSingleCell(t3.ranges[0]) && ne.isCellWithinRange(n3, t3.ranges[0]) || !ne.isCellWithinRange(n3, t3.ranges[0])) && (r3 = [], i2 = -1);
2143
+ const l2 = { ranges: r3, rangeIndex: i2, cell: n3 };
2144
+ return ne.isEqualSelectionCoords(l2, t3) ? t3 : l2;
2145
+ });
2146
+ }, [X2]), [Ee2, _e2] = h(null), [Ie2, Ce2] = h(null), Te2 = l(null), [ke2, Re2] = h(null), Pe2 = l(null), Oe2 = l(null), [Le2, De2] = h(null), ze2 = l(null), Ae2 = l(null), $e2 = l(V2);
2147
+ s(() => {
2148
+ $e2.current = V2;
2149
+ }, [V2]);
2150
+ const Be2 = Tt((e5, n3 = { inline: "nearest", block: "nearest" }) => {
2151
+ let { rowIndex: o3, colIndex: r3 } = e5;
2152
+ void 0 === o3 && xe2?.cell && (o3 = xe2.cell.rowIndex), void 0 === r3 && xe2?.cell && (r3 = xe2.cell.colIndex), void 0 !== o3 && void 0 !== r3 && t2.current?.scrollCellCoordsIntoView({ rowIndex: o3, colIndex: r3 }, n3);
2153
+ }, [xe2]), Fe2 = i((e5) => {
2154
+ const t3 = ie2();
2155
+ return e5.rowIndex < t3.top || e5.colIndex < t3.left || e5.colIndex > t3.right || e5.rowIndex > t3.bottom;
2156
+ }, []), je2 = Tt((e5, n3) => {
2157
+ if (!t2?.current) return null;
2158
+ const o3 = { rowStart: Math.min(e5.rowIndex, n3.rowIndex), colStart: Math.min(e5.colIndex, n3.colIndex), rowEnd: Math.max(e5.rowIndex, n3.rowIndex), colEnd: Math.max(e5.colIndex, n3.colIndex) }, r3 = W2?.(o3);
2159
+ if (r3) return o3;
2160
+ const i2 = X2(e5), l2 = X2(n3), s2 = { rowStart: Math.min(i2.rowStart, l2.rowStart), colStart: Math.min(i2.colStart, l2.colStart), rowEnd: Math.max(i2.rowEnd, l2.rowEnd), colEnd: Math.max(i2.colEnd, l2.colEnd) };
2161
+ let c3;
2162
+ return "function" == typeof $e2.current ? c3 = $e2.current(s2) : V2 && (c3 = V2), c3 ? ne.extendRangeToUnionRanges(s2, c3) : s2;
2163
+ }, [W2, X2]), Ve2 = Tt((e5, t3, n3) => {
2164
+ const o3 = e5.ranges.length > 0 ? e5.ranges[e5.rangeIndex] : { rowStart: e5.cell.rowIndex, colStart: e5.cell.colIndex, rowEnd: e5.cell.rowIndex, colEnd: e5.cell.colIndex }, r3 = { rowStart: Math.min(t3.rowIndex ?? o3.rowStart, n3.rowIndex ?? o3.rowStart), colStart: Math.min(t3.colIndex ?? o3.colStart, n3.colIndex ?? o3.colStart), rowEnd: Math.max(t3.rowIndex ?? o3.rowEnd, n3.rowIndex ?? o3.rowEnd), colEnd: Math.max(t3.colIndex ?? o3.colEnd, n3.colIndex ?? o3.colEnd) }, i2 = { rowIndex: r3.rowStart, colIndex: r3.colStart }, l2 = { rowIndex: r3.rowEnd, colIndex: r3.colEnd };
2165
+ if (Fe2(i2) || Fe2(l2)) return;
2166
+ return je2(i2, l2);
2167
+ }, [je2]), We2 = Tt((e5, t3, n3) => {
2168
+ if ("single" === g2) return;
2169
+ if (!ye2.current) return;
2170
+ const o3 = Ve2(ye2.current, e5, t3 ?? ye2.current.cell);
2171
+ if (!o3) return;
2172
+ const r3 = ye2.current.rangeIndex;
2173
+ be2((e6) => e6.length ? e6.map((e7, t4) => r3 === t4 ? o3 : e7) : [o3]), n3 && o3 && Se2({ colIndex: o3.colStart, rowIndex: o3.rowStart });
2174
+ }, []), He2 = i((e5, t3, n3) => {
2175
+ if (!ye2.current) return;
2176
+ e5 = { ...ye2.current?.cell, ...e5 }, t3 = t3 ?? e5;
2177
+ const o3 = Ve2(ye2.current, e5, t3);
2178
+ if (!o3) return;
2179
+ const r3 = { rowIndex: o3.rowStart, colIndex: o3.colStart }, i2 = { ...r3, ...n3 };
2180
+ "clear" === w2 ? (ze2.current = i2, Ue2()) : "modify" === w2 ? We2(r3) : Ne2(r3), Se2(i2);
2181
+ }, []), Ne2 = i((e5, t3 = e5, n3) => {
2182
+ "multiple" !== g2 || !e5 || Fe2(e5) || Fe2(t3) || me2((o3) => {
2183
+ ve2.current = false, o3 = mo(o3);
2184
+ const r3 = je2(e5, t3);
2185
+ if (!r3) return o3;
2186
+ let i2 = o3.ranges.length > 0 ? [...o3.ranges] : [je2(o3.cell, o3.cell)];
2187
+ i2.push(r3);
2188
+ const l2 = { ranges: i2, cell: { rowIndex: r3.rowStart, colIndex: r3.colStart, ...n3 }, rangeIndex: i2.length - 1 };
2189
+ return ne.isEqualSelectionCoords(l2, o3) ? o3 : l2;
2190
+ });
2191
+ }, []), Ue2 = () => {
2192
+ be2(wo);
2193
+ }, qe2 = "touch" === Ut.detectIt().primaryInput, Ke2 = l(null), Ye2 = l(null), Xe2 = l(null), Ge2 = d(() => ({ onPointerDown: (e5) => {
2194
+ if (!t2 || !t2.current) return false;
2195
+ const n3 = e5.nativeEvent, o3 = t2.current.getViewFromClient(n3.clientX, n3.clientY);
2196
+ if ("touch" === n3.pointerType || "touchstart" === n3.type) return Ye2.current = { topLeft: o3.getScrollTopLeft(), point: { x: n3.clientX, y: n3.clientY } }, true;
2197
+ const r3 = o3.getCellCoordsFromClient(e5.nativeEvent.clientX, e5.nativeEvent.clientY);
2198
+ if (!r3) return false;
2199
+ Ke2.current = { anchor: o3.getAnchor(), coords: r3 }, Ae2.current = null;
2200
+ const i2 = e5.nativeEvent.which === Ct;
2201
+ if (i2) {
2202
+ if (-1 !== ne.indexOfCoords(r3, xe2.ranges)) return false;
2203
+ }
2204
+ const l2 = e5.nativeEvent.shiftKey, s2 = e5.nativeEvent.ctrlKey || e5.nativeEvent.metaKey, c3 = s2, d2 = m2, u2 = xe2.ranges.length > 0, h2 = s2 && d2;
2205
+ if (false === F2?.(e5, r3, xe2)) return false;
2206
+ a2?.(ye2.current, e5.nativeEvent);
2207
+ const f2 = !i2 && "single" !== g2;
2208
+ if (l2) return We2(r3), f2;
2209
+ const p3 = ne.isEqualCells(r3, xe2.cell);
2210
+ if (c3) {
2211
+ if (p3 && (!h2 || !u2)) return f2;
2212
+ if (s2) {
2213
+ if (-1 !== ne.indexOfCoords(r3, xe2.ranges) && d2) {
2214
+ Pe2.current = r3;
2215
+ const e6 = je2(r3, r3);
2216
+ return Oe2.current = e6, Re2(e6), f2;
2217
+ }
2218
+ }
2219
+ return Ne2(r3), f2;
2220
+ }
2221
+ $2 && Be2(r3), p3 && 0 === xe2.ranges.length || He2(r3);
2222
+ }, onPointerMoveOrWait: Me.throttle((e5, n3) => {
2223
+ if (!t2?.current) return;
2224
+ if ("touch" === e5.pointerType || "touchmove" === e5.type) return;
2225
+ if (!Ke2.current) return;
2226
+ const o3 = Ke2.current.anchor;
2227
+ let r3 = t2.current.getViewFromLocation(o3), i2 = r3.getCellCoordsFromClient(e5.clientX, e5.clientY);
2228
+ if (!ne.isEqualCells(i2, Ke2.current?.coords) && (Ke2.current = { anchor: o3, coords: i2 }, i2 && false !== j2?.(e5, i2, ye2.current))) {
2229
+ if (Pe2.current) {
2230
+ const e6 = { rowStart: Math.min(i2.rowIndex, Pe2.current.rowIndex), colStart: Math.min(i2.colIndex, Pe2.current.colIndex), rowEnd: Math.max(i2.rowIndex, Pe2.current.rowIndex), colEnd: Math.max(i2.colIndex, Pe2.current.colIndex) }, t3 = { rowIndex: e6.rowStart, colIndex: e6.colStart }, n4 = { rowIndex: e6.rowEnd, colIndex: e6.colEnd };
2231
+ if (Fe2(t3) || Fe2(n4)) return;
2232
+ const o4 = je2(t3, n4);
2233
+ Oe2.current = o4, Re2(o4);
2234
+ } else We2(i2);
2235
+ Xe2.current = n3, xo(r3, i2, t2);
2236
+ }
2237
+ }, 60), onPointerUp: (e5) => {
2238
+ if (Ke2.current = null, "touch" === e5.pointerType || "touchend" === e5.type) {
2239
+ if (Ye2.current) {
2240
+ const e6 = t2.current.getViewFromClient(Ye2.current.point.x, Ye2.current.point.y), n4 = e6.getScrollTopLeft();
2241
+ if (n4.left === Ye2.current.topLeft.left && n4.top === Ye2.current.topLeft.top) {
2242
+ const t3 = e6.getCellCoordsFromClient(Ye2.current.point.x, Ye2.current.point.y);
2243
+ He2(t3);
2244
+ }
2245
+ }
2246
+ return Ye2.current = null, void (Ke2.current = null);
2247
+ }
2248
+ try {
2249
+ p2?.(ye2.current, e5);
2250
+ } catch (e6) {
2251
+ console.warn(e6);
2252
+ }
2253
+ if (!Pe2.current) return;
2254
+ const n3 = Oe2.current;
2255
+ Pe2.current = null, Oe2.current = null, Re2(null), me2((e6) => {
2256
+ if (ve2.current = false, 0 === (e6 = mo(e6)).ranges.length) return e6;
2257
+ let t3 = [], o3 = -1, r3 = e6.cell;
2258
+ for (let i3 = 0; i3 < e6.ranges.length; i3++) {
2259
+ const l2 = e6.ranges[i3];
2260
+ if (ne.isRangesIntersect(l2, n3)) {
2261
+ const r4 = Me.subtractRect({ top: l2.rowStart, left: l2.colStart, bottom: l2.rowEnd + 1, right: l2.colEnd + 1 }, { top: n3.rowStart, left: n3.colStart, bottom: n3.rowEnd + 1, right: n3.colEnd + 1 });
2262
+ for (let n4 = 0; n4 < r4.length; n4++) {
2263
+ const i4 = { rowStart: r4[n4].top, colStart: r4[n4].left, rowEnd: r4[n4].bottom - 1, colEnd: r4[n4].right - 1 };
2264
+ t3.push(i4), ne.isCellWithinRange(e6.cell, i4) && (o3 = t3.length - 1);
2265
+ }
2266
+ } else t3.push(l2);
2267
+ t3.length > 0 && -1 === o3 && ne.isCellWithinRange(e6.cell, l2) && (o3 = t3.length - 1, r3 = { rowIndex: t3[t3.length - 1].rowStart, colIndex: t3[t3.length - 1].colStart });
2268
+ }
2269
+ const i2 = { cell: r3, rangeIndex: o3, ranges: t3 };
2270
+ return ne.isEqualSelectionCoords(i2, e6) ? e6 : i2;
2271
+ });
2272
+ }, processTouch: true, consumeTouch: false }), [xe2, g2, m2, $2, w2]), Ze2 = Tt(hn(Ge2), []), Je2 = d(() => ({ onSelectionPointerDown: (e5, n3, o3, r3, i2 = xe2.cell, l2 = $2, s2 = e5.nativeEvent.shiftKey, c3 = false) => {
2273
+ if (!t2 || !t2.current) return false;
2274
+ e5.stopPropagation(), e5.preventDefault(), e5.nativeEvent.stopImmediatePropagation();
2275
+ const d2 = o3 ?? t2.current.getViewFromClient(e5.nativeEvent.clientX, e5.nativeEvent.clientY), u2 = r3 ?? d2.getCellCoordsFromClient(e5.nativeEvent.clientX, e5.nativeEvent.clientY);
2276
+ if (!u2) return false;
2277
+ Ke2.current = { anchor: d2.getAnchor(), coords: u2 }, Ae2.current = null;
2278
+ const h2 = e5.nativeEvent.which === Ct;
2279
+ if (h2) {
2280
+ if (-1 !== ne.indexOfCoords(u2, xe2.ranges)) return false;
2281
+ }
2282
+ const f2 = e5.nativeEvent.ctrlKey || e5.nativeEvent.metaKey, p3 = f2, w3 = m2, x3 = xe2.ranges.length > 0, y3 = f2 && w3;
2283
+ if (false === F2?.(e5, u2, xe2)) return false;
2284
+ a2?.(ye2.current, e5.nativeEvent);
2285
+ const v3 = !h2 && "single" !== g2;
2286
+ if (s2) return We2(u2, i2, c3), v3;
2287
+ const b3 = ne.isEqualCells(u2, i2);
2288
+ if (p3) {
2289
+ if (b3 && (!y3 || !x3)) return v3;
2290
+ if (y3) {
2291
+ if (-1 !== ne.indexOfCoords(u2, xe2.ranges) && w3) {
2292
+ Pe2.current = u2;
2293
+ const e6 = je2(u2, u2);
2294
+ return Oe2.current = e6, Re2(e6), v3;
2295
+ }
2296
+ }
2297
+ return Ne2(u2), v3;
2298
+ }
2299
+ l2 && Be2(u2), b3 && 0 === xe2.ranges.length || He2(u2);
2300
+ }, onSelectionPointerMoveOrWait: (e5, n3, o3, r3, i2, l2 = xe2.cell, s2 = true, c3 = false) => {
2301
+ if (!t2?.current) return;
2302
+ if (e5.stopPropagation(), e5.preventDefault(), e5.stopImmediatePropagation(), !Ke2.current) return;
2303
+ const a3 = Ke2.current.anchor;
2304
+ let d2 = r3 ?? t2.current.getViewFromLocation(a3), u2 = i2 ?? d2.getCellCoordsFromClient(e5.clientX, e5.clientY);
2305
+ if (!ne.isEqualCells(u2, Ke2.current?.coords) && (Ke2.current = { anchor: a3, coords: u2 }, u2 && false !== j2?.(e5, u2, ye2.current))) {
2306
+ if (Pe2.current) {
2307
+ const e6 = { rowStart: Math.min(u2.rowIndex, Pe2.current.rowIndex), colStart: Math.min(u2.colIndex, Pe2.current.colIndex), rowEnd: Math.max(u2.rowIndex, Pe2.current.rowIndex), colEnd: Math.max(u2.colIndex, Pe2.current.colIndex) }, t3 = { rowIndex: e6.rowStart, colIndex: e6.colStart }, n4 = { rowIndex: e6.rowEnd, colIndex: e6.colEnd };
2308
+ if (Fe2(t3) || Fe2(n4)) return;
2309
+ const o4 = je2(t3, n4);
2310
+ Oe2.current = o4, Re2(o4);
2311
+ } else We2(u2, l2, c3);
2312
+ s2 && xo(d2, u2, t2);
2313
+ }
2314
+ }, onPointerUp: (e5) => {
2315
+ Ke2.current = null, e5.stopPropagation(), e5.preventDefault(), e5.stopImmediatePropagation();
2316
+ try {
2317
+ p2?.(ye2.current, e5);
2318
+ } catch (e6) {
2319
+ console.warn(e6);
2320
+ }
2321
+ if (!Pe2.current) return;
2322
+ const t3 = Oe2.current;
2323
+ Pe2.current = null, Oe2.current = null, Re2(null), me2((e6) => {
2324
+ if (ve2.current = false, 0 === (e6 = mo(e6)).ranges.length) return e6;
2325
+ let n3 = [], o3 = -1, r3 = e6.cell;
2326
+ for (let i3 = 0; i3 < e6.ranges.length; i3++) {
2327
+ const l2 = e6.ranges[i3];
2328
+ if (ne.isRangesIntersect(l2, t3)) {
2329
+ const r4 = Me.subtractRect({ top: l2.rowStart, left: l2.colStart, bottom: l2.rowEnd + 1, right: l2.colEnd + 1 }, { top: t3.rowStart, left: t3.colStart, bottom: t3.rowEnd + 1, right: t3.colEnd + 1 });
2330
+ for (let t4 = 0; t4 < r4.length; t4++) {
2331
+ const i4 = { rowStart: r4[t4].top, colStart: r4[t4].left, rowEnd: r4[t4].bottom - 1, colEnd: r4[t4].right - 1 };
2332
+ n3.push(i4), ne.isCellWithinRange(e6.cell, i4) && (o3 = n3.length - 1);
2333
+ }
2334
+ } else n3.push(l2);
2335
+ n3.length > 0 && -1 === o3 && ne.isCellWithinRange(e6.cell, l2) && (o3 = n3.length - 1, r3 = { rowIndex: n3[n3.length - 1].rowStart, colIndex: n3[n3.length - 1].colStart });
2336
+ }
2337
+ const i2 = { cell: r3, rangeIndex: o3, ranges: n3 };
2338
+ return ne.isEqualSelectionCoords(i2, e6) ? e6 : i2;
2339
+ });
2340
+ } }), [xe2, g2, m2, $2, w2]), Qe2 = Tt((e5, n3 = false, r3 = false, i2 = 0) => {
2341
+ if (!t2.current || !xe2.cell) return;
2342
+ let l2 = xe2.cell, s2 = xe2.cell;
2343
+ if (n3 && xe2.ranges.length > 0) {
2344
+ const t3 = xe2.ranges[xe2.rangeIndex], n4 = xe2.cell;
2345
+ switch (e5) {
2346
+ case S:
2347
+ s2 = { rowIndex: n4.rowIndex === t3.rowStart ? t3.rowEnd : t3.rowStart, colIndex: t3.colEnd }, l2 = { rowIndex: n4.rowIndex === t3.rowStart ? t3.rowStart : t3.rowEnd, colIndex: t3.colStart };
2348
+ break;
2349
+ case E:
2350
+ s2 = { rowIndex: n4.rowIndex === t3.rowEnd ? t3.rowStart : t3.rowEnd, colIndex: t3.colEnd }, l2 = { rowIndex: n4.rowIndex === t3.rowEnd ? t3.rowEnd : t3.rowStart, colIndex: t3.colStart };
2351
+ break;
2352
+ case _:
2353
+ s2 = { rowIndex: t3.rowEnd, colIndex: n4.colIndex === t3.colStart ? t3.colEnd : t3.colStart }, l2 = { rowIndex: t3.rowStart, colIndex: n4.colIndex === t3.colStart ? t3.colStart : t3.colEnd };
2354
+ break;
2355
+ case I:
2356
+ s2 = { rowIndex: t3.rowEnd, colIndex: n4.colIndex === t3.colEnd ? t3.colStart : t3.colEnd }, l2 = { rowIndex: t3.rowStart, colIndex: n4.colIndex === t3.colEnd ? t3.colEnd : t3.colStart };
2357
+ }
2358
+ }
2359
+ const c3 = X2(s2);
2360
+ let { rowStart: a3, colStart: d2 } = c3;
2361
+ const u2 = ie2();
2362
+ if (Ae2.current) switch (e5) {
2363
+ case S:
2364
+ case E:
2365
+ Ae2.current.colIndex >= c3.colStart && Ae2.current.colIndex <= c3.colEnd && (d2 = Ae2.current.colIndex);
2366
+ break;
2367
+ case _:
2368
+ case I:
2369
+ Ae2.current.rowIndex >= c3.rowStart && Ae2.current.rowIndex <= c3.rowEnd && (a3 = Ae2.current.rowIndex);
2370
+ }
2371
+ if (!i2) {
2372
+ switch (e5) {
2373
+ case S:
2374
+ a3 = Un(fe2, Math.max(c3.rowStart - 1, u2.top), e5);
2375
+ break;
2376
+ case E:
2377
+ a3 = Un(fe2, Math.min(c3.rowEnd + 1, u2.bottom), e5);
2378
+ break;
2379
+ case _:
2380
+ d2 = Un(ge2, Math.max(c3.colStart - 1, u2.left), e5);
2381
+ break;
2382
+ case I:
2383
+ d2 = Un(ge2, Math.min(c3.colEnd + 1, u2.right), e5);
2384
+ }
2385
+ if (r3) switch (e5) {
2386
+ case S:
2387
+ a3 = z2({ ...s2, colIndex: xe2.cell.colIndex }, de2, fe2, e5, false, Math.max(u2.top, fe2(u2.top, false)));
2388
+ break;
2389
+ case E:
2390
+ a3 = z2({ ...s2, colIndex: xe2.cell.colIndex }, de2, fe2, e5, false, Math.min(u2.bottom, u2.bottom - fe2(u2.bottom, true)));
2391
+ break;
2392
+ case _:
2393
+ d2 = z2({ ...s2, rowIndex: xe2.cell.rowIndex }, de2, ge2, e5, false, Math.max(u2.left, ge2(u2.left, false)));
2394
+ break;
2395
+ case I:
2396
+ d2 = z2({ ...s2, rowIndex: xe2.cell.rowIndex }, de2, ge2, e5, false, Math.min(u2.right, u2.right - ge2(u2.right, true)));
2397
+ }
2398
+ }
2399
+ let h2 = null;
2400
+ if (i2) {
2401
+ let n4 = 0;
2402
+ switch (e5) {
2403
+ case S:
2404
+ n4 = o2.getRowOffset(a3 + 1), a3 = Math.max(u2.top, o2.getRowIndex(n4 - i2)), h2 = { top: o2.getRowOffset(a3 + 1) - (n4 - t2.current.getScrollPosition().top) };
2405
+ break;
2406
+ case E:
2407
+ n4 = o2.getRowOffset(a3), a3 = Math.min(u2.bottom, o2.getRowIndex(n4 + i2)), h2 = { top: o2.getRowOffset(a3) - (n4 - t2.current.getScrollPosition().top) };
2408
+ break;
2409
+ case _:
2410
+ n4 = o2.getColOffset(d2 + 1), d2 = Math.max(u2.left, o2.getColIndex(n4 - i2)), h2 = { left: o2.getColOffset(d2 + 1) - (n4 - t2.current.getScrollPosition().left) };
2411
+ break;
2412
+ case I:
2413
+ n4 = o2.getColOffset(d2), d2 = Math.min(u2.right, o2.getColIndex(n4 + i2)), h2 = { left: o2.getColOffset(d2) - (n4 - t2.current.getScrollPosition().left) };
2414
+ }
2415
+ }
2416
+ const f2 = { rowIndex: a3, colIndex: d2 }, p3 = X2(f2), g3 = { rowIndex: p3.rowStart, colIndex: p3.colStart };
2417
+ n3 || (Ae2.current = f2);
2418
+ const w3 = ne.isEqualCells(ze2.current, g3) && ne.isEqualCells(ze2.current, l2);
2419
+ if (n3 && !w3 ? We2(g3, l2) : He2(g3), h2) t2.current.scrollTo(h2);
2420
+ else {
2421
+ if (n3 && ze2.current) {
2422
+ const t3 = ie2();
2423
+ if (e5 === I && ze2.current.colIndex === t3.left || e5 === _ && ze2.current.colIndex === t3.right || e5 === S && ze2.current.rowIndex === t3.bottom || e5 === E && ze2.current.rowIndex === t3.top) return;
2424
+ }
2425
+ e5 === _ || e5 === I ? Be2({ colIndex: f2.colIndex }) : e5 !== S && e5 !== E || Be2({ rowIndex: f2.rowIndex });
2426
+ }
2427
+ }, [xe2, X2]), et2 = Tt((e5) => {
2428
+ if (!t2.current) return;
2429
+ if (0 === xe2.ranges.length) return void Qe2(e5);
2430
+ const n3 = X2(xe2.cell);
2431
+ if (ne.isEqualRangesArrays([n3], xe2.ranges)) return void Qe2(e5);
2432
+ const o3 = Qn(xe2, e5, X2, fe2, ge2);
2433
+ me2((e6) => {
2434
+ ve2.current = false, e6 = mo(e6);
2435
+ const t3 = { ...e6, cell: o3.cell, rangeIndex: o3.rangeIndex };
2436
+ return ne.isEqualSelectionCoords(t3, e6) ? e6 : t3;
2437
+ }), o3.cell && Be2(o3.cell);
2438
+ }, [xe2, X2]), tt2 = i(() => {
2439
+ const e5 = ie2();
2440
+ We2({ rowIndex: e5.top }, { rowIndex: e5.bottom });
2441
+ }, []), nt2 = i(() => {
2442
+ const e5 = ie2();
2443
+ We2({ colIndex: e5.left }, { colIndex: e5.right });
2444
+ }, []), ot2 = Tt(() => {
2445
+ xe2.cell && t2?.current && Be2(xe2.cell);
2446
+ }, [xe2.cell]), rt2 = i((e5 = false) => {
2447
+ const t3 = { rowIndex: ie2().top };
2448
+ e5 ? We2(t3) : He2(t3), Be2(t3);
2449
+ }, []), it2 = i((e5 = false) => {
2450
+ const t3 = { rowIndex: ie2().bottom };
2451
+ e5 ? We2(t3) : He2(t3), Be2(t3);
2452
+ }, []), lt2 = i((e5 = false) => {
2453
+ const t3 = { colIndex: ie2().left };
2454
+ e5 ? We2(t3) : He2(t3), Be2(t3);
2455
+ }, []), st2 = i((e5 = false) => {
2456
+ const t3 = ie2(), n3 = { rowIndex: t3.top, colIndex: t3.left };
2457
+ e5 ? We2(n3) : He2(n3), Be2(n3);
2458
+ }, []), ct2 = i((e5 = false) => {
2459
+ const t3 = ie2(), n3 = { colIndex: A2?.()?.colEnd ?? t3.right };
2460
+ e5 ? We2(n3) : He2(n3), Be2(n3);
2461
+ }, [A2]), at2 = i((e5 = false) => {
2462
+ const t3 = ie2(), n3 = { rowIndex: A2?.()?.rowEnd ?? t3.bottom, colIndex: A2?.()?.colEnd ?? t3.right };
2463
+ e5 ? We2(n3) : He2(n3), Be2(n3);
2464
+ }, [A2]), dt2 = Tt((e5) => {
2465
+ if (!t2.current) return;
2466
+ if (xe2.ranges.length <= 1) return;
2467
+ const n3 = e5 === _ || e5 === S;
2468
+ let o3 = xe2.rangeIndex + (n3 ? -1 : 1);
2469
+ o3 < 0 ? o3 = xe2.ranges.length - 1 : o3 > xe2.ranges.length - 1 && (o3 = 0);
2470
+ const r3 = xe2.ranges[o3], i2 = Qn({ cell: { rowIndex: r3.rowEnd, colIndex: r3.colEnd }, rangeIndex: 0, ranges: [r3] }, I, X2, fe2, ge2);
2471
+ me2((e6) => {
2472
+ ve2.current = false, e6 = mo(e6);
2473
+ const t3 = { ...e6, cell: i2.cell, rangeIndex: o3 };
2474
+ return ne.isEqualSelectionCoords(t3, e6) ? e6 : t3;
2475
+ }), i2.cell && Be2(i2.cell);
2476
+ }, [xe2, X2]), ut2 = Tt(() => {
2477
+ const e5 = Jn(xe2);
2478
+ me2((t3) => {
2479
+ ve2.current = false, t3 = mo(t3);
2480
+ const n3 = { ...t3, visibleSelection: e5 };
2481
+ return ne.isEqualSelectionCoords(n3, t3) ? t3 : n3;
2482
+ }), e5.cell && Be2(e5.cell);
2483
+ }, [xe2, X2]), ht2 = Tt(() => {
2484
+ if (!t2.current) return;
2485
+ if (0 === xe2.ranges.length) return;
2486
+ const e5 = xe2.cell, n3 = xe2.ranges[xe2.rangeIndex], o3 = Jn({ cell: e5, rangeIndex: 0, ranges: [n3] }), r3 = o3.ranges[o3.rangeIndex];
2487
+ let i2;
2488
+ i2 = r3.rowStart === e5.rowIndex && r3.colStart === e5.colIndex ? { rowIndex: r3.rowStart, colIndex: r3.colEnd } : r3.rowStart === e5.rowIndex && r3.colEnd === e5.colIndex ? { rowIndex: r3.rowEnd, colIndex: r3.colStart } : r3.rowEnd === e5.rowIndex && r3.colStart === e5.colIndex ? { rowIndex: r3.rowEnd, colIndex: r3.colEnd } : { rowIndex: r3.rowStart, colIndex: r3.colStart }, me2((e6) => {
2489
+ e6 = mo(e6);
2490
+ const t3 = { ...e6, cell: i2 };
2491
+ return ne.isEqualSelectionCoords(t3, e6) ? e6 : t3;
2492
+ }), i2 && Be2(i2);
2493
+ }, [xe2, X2]), ft2 = i((e5 = false) => {
2494
+ Qe2(E, e5, false, t2.current.getDimensions().containerHeight);
2495
+ }, []), pt2 = i((e5 = false) => {
2496
+ Qe2(S, e5, false, t2.current.getDimensions().containerHeight);
2497
+ }, []), xt2 = i((e5 = false) => {
2498
+ Qe2(I, e5, false, t2.current.getDimensions().containerWidth);
2499
+ }, []), yt2 = i((e5 = false) => {
2500
+ Qe2(_, e5, false, t2.current.getDimensions().containerWidth);
2501
+ }, []), vt2 = i(() => {
2502
+ et2(_);
2503
+ }, []), bt2 = i(() => {
2504
+ et2(I);
2505
+ }, []), St2 = i(() => {
2506
+ et2(S);
2507
+ }, []), Et2 = i(() => {
2508
+ et2(E);
2509
+ }, []), _t2 = i(() => {
2510
+ dt2(_);
2511
+ }, []), It2 = i(() => {
2512
+ dt2(I);
2513
+ }, []), Mt2 = i(() => {
2514
+ ht2();
2515
+ }, []), kt2 = i(() => {
2516
+ Qe2(_, false, false);
2517
+ }, []), Rt2 = i(() => {
2518
+ Qe2(_, true, false);
2519
+ }, []), Pt2 = i(() => {
2520
+ Qe2(_, false, true);
2521
+ }, []), Ot2 = i(() => {
2522
+ Qe2(_, true, true);
2523
+ }, []), Lt2 = i(() => {
2524
+ Qe2(I, false, false);
2525
+ }, []), Dt2 = i(() => {
2526
+ Qe2(I, true, false);
2527
+ }, []), zt2 = i(() => {
2528
+ Qe2(I, false, true);
2529
+ }, []), At2 = i(() => {
2530
+ Qe2(I, true, true);
2531
+ }, []), $t2 = i(() => {
2532
+ Qe2(S, false, false);
2533
+ }, []), Bt2 = i(() => {
2534
+ Qe2(S, true, false);
2535
+ }, []), Ft2 = i(() => {
2536
+ Qe2(S, false, true);
2537
+ }, []), jt2 = i(() => {
2538
+ Qe2(S, true, true);
2539
+ }, []), Vt2 = i(() => {
2540
+ Qe2(E, false, false);
2541
+ }, []), Wt2 = i(() => {
2542
+ Qe2(E, true, false);
2543
+ }, []), Ht2 = i(() => {
2544
+ Qe2(E, false, true);
2545
+ }, []), Nt2 = i(() => {
2546
+ Qe2(E, true, true);
2547
+ }, []), qt2 = i(() => {
2548
+ be2((e5) => e5.slice(0, -1));
2549
+ }, []), Kt2 = d(() => {
2550
+ const e5 = ie2();
2551
+ return ((e6, t3, n3, o3, r3) => {
2552
+ for (let i2 = 0; i2 < e6.length; i2++) {
2553
+ const l2 = e6[i2];
2554
+ if (l2.rowStart === t3 && l2.colStart === n3 && l2.rowEnd === o3 && l2.colEnd === r3) return true;
2555
+ }
2556
+ return false;
2557
+ })(xe2.ranges, e5.top, e5.left, e5.bottom, e5.right);
2558
+ }, [B2, xe2.ranges]), Yt2 = i((e5, n3 = true) => {
2559
+ ze2.current = e5, Se2(e5), n3 && e5 && t2?.current && Be2(e5);
2560
+ }, []), Xt2 = Tt((e5 = true) => {
2561
+ const t3 = Te2.current;
2562
+ if (!ye2.current?.cell) return;
2563
+ const n3 = ye2.current?.ranges, o3 = ye2.current?.cell;
2564
+ if (!o3 || !t3) return;
2565
+ if (!t3) return;
2566
+ let r3 = null;
2567
+ if (r3 = n3.length > 0 ? n3[n3.length - 1] : X2(o3), r3.colEnd >= r3.colStart && r3.rowEnd >= r3.rowStart) {
2568
+ const n4 = eo(r3, t3);
2569
+ let o4 = e5 ? le2 : se2;
2570
+ try {
2571
+ o4?.(r3, t3, n4.direction);
2572
+ } catch (e6) {
2573
+ console.warn(e6);
2574
+ } finally {
2575
+ e5 && ae2?.();
2576
+ }
2577
+ }
2578
+ }, [X2]), Gt2 = l(null), Zt2 = d(() => ({ onPointerDown: (e5, n3) => {
2579
+ if (Xe2.current = n3, !t2 || !t2.current) return false;
2580
+ const o3 = t2.current.getViewFromClient(e5.nativeEvent.clientX, e5.nativeEvent.clientY), r3 = o3?.getCellCoordsFromClient(e5.nativeEvent.clientX, e5.nativeEvent.clientY);
2581
+ r3 && (e5.stopPropagation(), _e2("crosshair"), Gt2.current = { anchor: o3.getAnchor(), coords: r3 });
2582
+ }, onPointerMoveOrWait: (e5, n3) => {
2583
+ if (R2 || !t2?.current || !ye2.current || !Gt2.current) return;
2584
+ const o3 = Gt2.current.anchor;
2585
+ let r3 = t2.current.getViewFromLocation(o3), i2 = r3.getCellCoordsFromClient(e5.clientX, e5.clientY);
2586
+ if (!i2) return;
2587
+ Gt2.current = { anchor: o3, coords: i2 };
2588
+ const l2 = ye2.current.ranges;
2589
+ let s2 = je2(ye2.current.cell, i2);
2590
+ if (!s2) return;
2591
+ const c3 = l2.length > 0, a3 = c3 ? l2[l2.length - 1] : X2(ye2.current.cell);
2592
+ if (!s2) return;
2593
+ const d2 = s2.rowStart < a3.rowStart ? S : s2.rowEnd > a3.rowEnd ? E : s2.colEnd > a3.colEnd ? I : _, u2 = ie2();
2594
+ d2 === _ && (s2 = { ...a3, colStart: Math.max(u2.left, s2.colStart) }), d2 === S && (s2 = { ...a3, rowStart: Math.max(u2.top, s2.rowStart) }), d2 === I && (s2 = { ...a3, colEnd: Math.min(u2.right, s2.colEnd) }), d2 === E && (s2 = { ...a3, rowEnd: Math.min(u2.bottom, s2.rowEnd) });
2595
+ const h2 = eo(a3, s2);
2596
+ if (!W2?.(a3)) {
2597
+ let e6;
2598
+ "function" == typeof $e2.current ? e6 = $e2.current(a3) : V2 && (e6 = V2), s2 = ((e7, t3, n4, o4, r4, i3) => {
2599
+ const l3 = { ...t3 };
2600
+ if (0 === n4.length) return l3;
2601
+ if (r4 === _) {
2602
+ const t4 = e7.colEnd + 1 - e7.colStart;
2603
+ l3.colStart = e7.colStart - Math.ceil(i3 / t4) * t4, l3.colStart < o4.left && (l3.colStart = l3.colStart + Math.ceil((o4.left - l3.colStart) / t4) * t4);
2604
+ } else if (r4 === I) {
2605
+ const t4 = e7.colEnd + 1 - e7.colStart;
2606
+ l3.colEnd = e7.colEnd + Math.ceil(i3 / t4) * t4, l3.colEnd > o4.right && (l3.colEnd = l3.colEnd - Math.ceil((o4.right - l3.colEnd) / t4) * t4);
2607
+ } else if (r4 === S) {
2608
+ const t4 = e7.rowEnd + 1 - e7.rowStart;
2609
+ l3.rowStart = e7.rowStart - Math.ceil(i3 / t4) * t4, l3.rowStart < o4.top && (l3.rowStart = l3.rowStart + Math.ceil((o4.top - l3.rowStart) / t4) * t4);
2610
+ } else if (r4 === E) {
2611
+ const t4 = e7.rowEnd + 1 - e7.rowStart;
2612
+ l3.rowEnd = e7.rowEnd + Math.ceil(i3 / t4) * t4, l3.rowEnd > o4.bottom && (l3.rowEnd = l3.rowEnd - Math.ceil((o4.bottom - l3.rowEnd) / t4) * t4);
2613
+ }
2614
+ return l3;
2615
+ })(a3, s2, e6, u2, h2.direction, h2.amount);
2616
+ }
2617
+ if (c3 && ne.isRangeWithinRange(s2, a3) && (s2 = null), !ne.isEqualRanges(s2, Te2.current)) {
2618
+ if (Ce2(s2), Te2.current = s2, !s2) {
2619
+ try {
2620
+ ce2?.();
2621
+ } catch (e6) {
2622
+ }
2623
+ return void ae2?.();
2624
+ }
2625
+ Xt2(false);
2626
+ }
2627
+ Xe2.current = n3, xo(r3, i2, t2);
2628
+ }, onPointerUp: (e5, n3) => {
2629
+ Xe2.current = n3, Promise.resolve(Xt2(true)).finally(() => {
2630
+ ae2?.(), Ce2(null), Te2.current = null, Gt2.current = null, _e2(null), t2.current?.focus();
2631
+ });
2632
+ } }), [X2]), Jt2 = hn(Zt2), Qt2 = d(() => ({ onPointerDown: Jt2 }), [Jt2]), [en2, tn2] = h(null), nn2 = l(null), on2 = d(() => ({ onPointerDown: (e5, n3) => {
2633
+ if (Xe2.current = n3, !t2 || !t2.current) return false;
2634
+ const o3 = t2.current.getViewFromClient(e5.nativeEvent.clientX, e5.nativeEvent.clientY), r3 = o3?.getCellCoordsFromClient(e5.nativeEvent.clientX, e5.nativeEvent.clientY);
2635
+ if (!r3) return;
2636
+ if (false === F2?.(e5, r3, xe2)) return false;
2637
+ e5.stopPropagation(), _e2("default");
2638
+ const i2 = o3.getRelativePointFromClient(0, 0), l2 = ye2.current?.ranges[ye2.current?.ranges.length - 1] ?? ne.cellToRange(ye2.current?.cell), s2 = o3.toClipBounds(o3.getRangeCoordsBounds(l2)), c3 = { x: 0, y: 0 };
2639
+ s2.x - i2.x > e5.nativeEvent.clientX ? c3.x = e5.nativeEvent.clientX - (s2.x - i2.x) : e5.nativeEvent.clientX >= s2.x - i2.x + s2.width && (c3.x = Math.max(0, e5.nativeEvent.clientX - (s2.x - i2.x + s2.width)) + 1), s2.y - i2.y > e5.nativeEvent.clientY ? c3.y = e5.nativeEvent.clientY - (s2.y - i2.y) : e5.nativeEvent.clientY >= s2.y - i2.y + s2.height && (c3.y = Math.max(0, e5.nativeEvent.clientY - (s2.y - i2.y + s2.height)) + 1), H2?.(l2, e5.nativeEvent, n3), nn2.current = { range: l2, anchor: o3.getAnchor(), cell: r3, isMoving: false, extrusion: c3 };
2640
+ }, onPointerMoveOrWait: (e5, n3, o3) => {
2641
+ if (Y2 || !t2?.current || !ye2.current || !nn2.current) return;
2642
+ const r3 = e5.clientX - o3.clientX, i2 = e5.clientY - o3.clientY;
2643
+ if (nn2.current.isMoving = nn2.current.isMoving || Math.abs(r3) > Math.max(1, 2) || Math.abs(i2) > Math.max(1, 2) || performance.now() - o3.timeStamp > 500, !nn2.current.isMoving) return;
2644
+ const l2 = nn2.current.anchor, s2 = nn2.current.extrusion;
2645
+ let c3 = t2.current.getViewFromLocation(l2), a3 = c3.getCellCoordsFromClient(e5.clientX - s2.x, e5.clientY - s2.y, true);
2646
+ if (!a3) return;
2647
+ const d2 = nn2.current.cell, u2 = nn2.current.range, h2 = ie2(), f2 = u2.colEnd - u2.colStart + 1, p3 = Math.min(Math.max(0, d2.colIndex - u2.colStart), f2 - 1), g3 = Math.min(h2.right - f2 + 1, Math.max(h2.left, a3.colIndex - p3)), w3 = u2.rowEnd - u2.rowStart + 1, m3 = Math.min(Math.max(0, d2.rowIndex - u2.rowStart), w3 - 1), x3 = Math.min(h2.bottom - w3 + 1, Math.max(h2.top, a3.rowIndex - m3)), y3 = { colStart: g3, colEnd: g3 + f2 - 1, rowStart: x3, rowEnd: x3 + w3 - 1 };
2648
+ ne.isEqualRanges(en2, y3) && !((e6) => !e6 || !Xe2.current || Xe2.current.ctrlKey !== e6.ctrlKey || Xe2.current.shiftKey !== e6.shiftKey || Xe2.current.altKey !== e6.altKey || Xe2.current.metaKey !== e6.metaKey)(e5) || (tn2(y3), N2?.(y3, e5, n3)), Xe2.current = n3, xo(c3, a3, t2);
2649
+ }, onPointerUp: (e5, n3) => {
2650
+ Xe2.current = n3;
2651
+ const o3 = () => {
2652
+ tn2(null), nn2.current = null, _e2(null), t2.current?.focus();
2653
+ };
2654
+ if (!nn2.current) return void o3();
2655
+ const r3 = nn2.current.range, i2 = en2;
2656
+ U2?.(r3, e5, n3), Promise.resolve(r3 && i2 && q2?.(r3, i2, e5, n3)).finally(() => {
2657
+ o3();
2658
+ });
2659
+ } }), [en2]), rn2 = hn(on2), ln2 = d(() => ({ onPointerDown: rn2 }), [rn2]), sn2 = l(null), cn2 = d(() => {
2660
+ const e5 = ne.isEqualSelectionCoords(xe2, sn2.current) ? sn2.current : xe2;
2661
+ return sn2.current = e5, e5;
2662
+ }, [xe2]), an2 = i((n3) => {
2663
+ let o3 = null, r3 = "br";
2664
+ const i2 = [], l2 = { stroke: P2, fill: J2, strokeWidth: 0.5 }, s2 = (e5, t3, o4) => {
2665
+ const r4 = n3.toClipBounds(n3.getRangeCoordsBounds(e5), fo);
2666
+ if (!r4) return;
2667
+ r4.x = r4.width > 0 ? r4.x : r4.x - l2.strokeWidth / 2, r4.y = r4.height > 0 ? r4.y : r4.y - l2.strokeWidth / 2, r4.width = Math.max(r4.width, l2.strokeWidth), r4.height = Math.max(r4.height, l2.strokeWidth);
2668
+ const i3 = { key: `selection-fill-${t3}`, range: e5, ...r4, ...l2 };
2669
+ if (o4) {
2670
+ const e6 = n3.getCellCoordsAsRangeCoords(o4);
2671
+ i3.cell = o4, i3.pathBounds = n3.toClipBounds(n3.getRangeCoordsBounds(e6), fo), i3.pathBounds && (i3.pathBounds.width <= 0 || i3.pathBounds.height <= 0) && (delete i3.pathBounds, delete i3.cell);
2672
+ }
2673
+ return ue2(i3);
2674
+ };
2675
+ let c3 = xe2 ? mo(xe2) : null;
2676
+ const a3 = c3?.cell ? n3.getCellCoordsAsRangeCoords(c3?.cell) : po;
2677
+ !c3 || c3.ranges && 0 !== c3.ranges.length || (c3 = { ranges: [a3], rangeIndex: 0, cell: c3.cell });
2678
+ for (let e5 = 0; c3 && e5 < c3.ranges.length; e5++) {
2679
+ const t3 = c3.ranges[e5], l3 = s2(t3, e5, e5 === c3.rangeIndex ? c3.cell : null);
2680
+ l3 && i2.push(l3);
2681
+ const a4 = 2, d3 = 0.5, u3 = n3.toClipBounds(n3.getRangeCoordsBounds(t3, { top: 0, left: 0, right: 0, bottom: 0 }), fo);
2682
+ if (u3) {
2683
+ const n4 = (c3.ranges.length, 4);
2684
+ i2.push(ue2({ range: t3, key: `selection-inside-edge-${e5}`, x: u3.x - 1, y: u3.y - 1, width: Math.max(u3.width + 1, 0), height: Math.max(u3.height + 1, 0), style: { overflow: "hidden" }, stroke: P2, strokeWidth: n4 }));
2685
+ }
2686
+ if (1 === c3.ranges.length) {
2687
+ const o4 = n3.toClipBounds(n3.getRangeCoordsBounds(t3), fo);
2688
+ if (o4) {
2689
+ Y2 || i2.push(ue2({ range: t3, key: `move-selection-hit-box-${e5}`, x: o4.width > 1 ? o4.x : o4.x - (G2 / 2 + 1), y: o4.height > 1 ? o4.y : o4.y - (G2 / 2 + 1), width: Math.max(o4.width + 2, 1), height: Math.max(o4.height + 2, 1), stroke: "transparent", style: { boxShadow: "none" }, pathProps: { cursor: en2 ? void 0 : "move", pointerEvents: "stroke" }, strokeWidth: G2, ...ln2 }));
2690
+ const n4 = a4;
2691
+ i2.push(ue2({ range: t3, key: `selection-single-${e5}`, x: o4.x - n4 / 2, y: o4.y - n4 / 2, width: Math.max(o4.width + n4 / 2, 1), height: Math.max(o4.height + n4 / 2, 1), stroke: Q2, strokeWidth: n4 }));
2692
+ }
2693
+ } else {
2694
+ const o4 = n3.toClipBounds(n3.getRangeCoordsBounds(t3, { top: -1, left: -1, right: -2, bottom: -2 }), fo);
2695
+ o4 && i2.push(ue2({ range: t3, key: `selection-multi-${e5}`, x: o4.width > 1 ? o4.x : o4.x - d3 / 2, y: o4.height > 1 ? o4.y : o4.y - d3 / 2, width: Math.max(o4.width, d3) + 1, height: Math.max(o4.height, d3) + 1, stroke: Q2, style: { overflow: "hidden" }, strokeWidth: 2 }));
2696
+ }
2697
+ if (c3.ranges.length > 1 && e5 === c3.rangeIndex) {
2698
+ const o4 = n3.getCellCoordsAsRangeCoords(c3.cell), r4 = n3.toClipBounds(n3.getRangeCoordsBounds(o4, { top: 1, left: 1, right: -1, bottom: -1 }), fo);
2699
+ r4 && i2.push(ue2({ range: t3, key: `selection-anchor-${e5}`, x: r4.x, y: r4.y, width: Math.max(r4.width, d3), height: Math.max(r4.height, d3), stroke: Q2, style: { overflow: "hidden" }, strokeWidth: 2 }));
2700
+ }
2701
+ if (e5 === c3.ranges.length - 1) {
2702
+ o3 = null, r3 = null;
2703
+ const e6 = t3.rowStart === ie2().top && t3.rowEnd === ie2().bottom, i3 = t3.colStart === ie2().left && t3.colEnd === ie2().right, l4 = n3.getRangeCoordsBounds(t3);
2704
+ let s3 = null;
2705
+ if (e6 || i3) {
2706
+ if (s3 = n3.toClipBounds(l4, fo), Object.keys(n3.allViews()).length > 1) {
2707
+ const o4 = n3.getVisibleRangeCoords(), r4 = n3.allViews()[C], l5 = n3.allViews()[M], c4 = n3.allViews()[T], a5 = n3.getAnchor();
2708
+ (i3 && (a5 === M && r4 || a5 === k && c4 || !ne.isCellWithinRange({ colIndex: t3.colStart, rowIndex: t3.rowEnd }, o4) && !ne.isCellWithinRange({ colIndex: t3.colStart, rowIndex: t3.rowEnd + 1 }, o4)) || e6 && (a5 === T && r4 || a5 === k && l5 || !ne.isCellWithinRange({ colIndex: t3.colEnd, rowIndex: t3.rowStart }, o4) && !ne.isCellWithinRange({ colIndex: t3.colEnd + 1, rowIndex: t3.rowStart }, o4))) && (s3 = null);
2709
+ }
2710
+ } else s3 = n3.toClipBounds(l4, fo);
2711
+ if (!s3 || 0 === s3.width || 0 === s3.height) continue;
2712
+ o3 = { x: s3.x + s3.width + 1, y: s3.y + s3.height + 1 }, 0 === s3.width || 0 === s3.height || t3.rowStart === ie2().top && t3.colStart === ie2().left && t3.rowEnd === ie2().bottom && t3.colEnd === ie2().right || (e6 ? (o3.y = a4, r3 = "tr") : i3 && (o3.x = a4, r3 = "bl"));
2713
+ }
2714
+ }
2715
+ let d2 = null;
2716
+ if (ke2) {
2717
+ const e5 = n3.toClipBounds(n3.getRangeCoordsBounds(ke2, { top: 0, left: 0, right: 0, bottom: 0 }), fo);
2718
+ if (e5) {
2719
+ const t3 = 2;
2720
+ d2 = ue2({ ...l2, range: ke2, key: "remove-selection", x: e5.x, y: e5.y, width: e5.width, height: e5.height, strokeWidth: t3, stroke: ee2, fill: te2 });
2721
+ }
2722
+ }
2723
+ let u2 = null;
2724
+ if (Ie2) {
2725
+ const e5 = n3.toClipBounds(n3.getRangeCoordsBounds(Ie2, { top: 0, left: 0, right: 0, bottom: 0 }), fo);
2726
+ if (e5) {
2727
+ const t3 = 2;
2728
+ u2 = ue2({ range: Ie2, key: "selection-fill-outline", x: e5.x - t3 / 2, y: e5.y - t3 / 2, width: e5.width + t3 / 2, height: e5.height + t3 / 2, strokeWidth: t3, stroke: Q2, strokeDasharray: "3 2" });
2729
+ }
2730
+ }
2731
+ let h2 = null;
2732
+ !R2 && o3 && !en2 && (h2 = f(uo, { ...o3, corner: r3, size: 7.5, borderStroke: `${P2} solid`, style: { borderRadius: 1 }, background: Q2, ...Qt2, key: "fillHandle" }));
2733
+ const p3 = [...i2];
2734
+ if (d2 && p3.push(d2), u2 && p3.push(u2), h2 && p3.push(h2), !oe2 && qe2 && 1 === c3?.ranges.length && c3.ranges[c3.ranges.length - 1]) {
2735
+ const o4 = c3.ranges[c3.ranges.length - 1], r4 = o4.rowStart === ie2().top && o4.rowEnd === ie2().bottom, i3 = o4.colStart === ie2().left && o4.colEnd === ie2().right, l3 = { view: n3, range: o4, borderStroke: `${Q2} solid`, background: P2, selectionTouchPointerHandler: Je2, ...re2, onTouchSelectStart: (e5) => De2(e5), onTouchSelectEnd: () => De2(null), currentTouchAnchor: Le2 };
2736
+ p3.push(e(ho, { anchor: i3 ? "b" : r4 ? "r" : "br", scrollableElement: t2.current, ...l3 }, "touch-select-handle-after")), p3.push(e(ho, { anchor: i3 ? "t" : r4 ? "l" : "tl", scrollableElement: t2.current, ...l3 }, "touch-select-handle-before"));
2737
+ }
2738
+ if (en2) {
2739
+ const e5 = n3.toClipBounds(n3.getRangeCoordsBounds(en2, { top: 1, left: 1, right: 1, bottom: 1 }), fo);
2740
+ e5 && p3.push(ue2({ range: en2, key: "selection-move-outline", x: e5.x - Z2 / 2, y: e5.y - Z2 / 2, width: Math.max(e5.width + Z2 / 2, 1), height: Math.max(e5.height + Z2 / 2, 1), stroke: Q2, style: { boxShadow: "none", transitionDuration: "70ms", transitionTimingFunction: "ease-in", transitionProperty: "left, top, width, height", willChange: "left, top, width, height" }, strokeWidth: Z2 }));
2741
+ }
2742
+ return e("div", { children: p3 }, "selection");
2743
+ }, [cn2, ke2, R2, Ie2, Y2, en2, ie2, P2, Q2, J2, ee2, te2, oe2, re2, Le2]), dn2 = d(() => {
2744
+ const e5 = () => t2.current;
2745
+ return [new In("moveToPageDown", e5, { label: "Page Down", description: "Shift viewport down one page.", shortcut: [{ key: "PageDown" }] }, () => ft2(false)), new In("selectToPageDown", e5, { label: "Select To Page Down", description: "Shift viewport and select down one page.", shortcut: [{ key: "PageDown", modifiers: [gt] }] }, () => ft2(true)), new In("moveToPageRight", e5, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [wt] }] }, () => xt2(false)), new In("selectToPageRight", e5, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [wt, gt] }] }, () => xt2(true)), new In("moveToPageUp", e5, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp" }] }, () => pt2(false)), new In("selectToPageUp", e5, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp", modifiers: [gt] }] }, () => pt2(true)), new In("moveToPageLeft", e5, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [wt] }] }, () => yt2(false)), new In("selectToPageLeft", e5, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [wt, gt] }] }, () => yt2(true)), new In("selectColumn", e5, { label: "Select Column", description: "Select the columns for the selected cells.", shortcut: { key: "Space", modifiers: [mt] } }, tt2), new In("selectRow", e5, { label: "Select Row", description: "Select the rows for the selected cells.", shortcut: { key: "Space", modifiers: [gt] } }, nt2), new In("selectToColumnStart", e5, { label: "Select To Column Start", description: "Select the columns to the beginning of the sheet." }, () => rt2(true)), new In("selectToColumnEnd", e5, { label: "Select To Column End", description: "Select the columns to the end of the sheet." }, () => it2(true)), new In("moveToRowStart", e5, { label: "Move to Row Home", description: "Move to the beginning of the row.", shortcut: [{ key: "Home" }] }, () => lt2(false)), new In("selectToRowStart", e5, { label: "Select to Row Home", description: "Select to the beginning of the row.", shortcut: [{ key: "Home", modifiers: [gt] }] }, () => lt2(true)), new In("moveToSheetStart", e5, { label: "Move to Sheet Home", description: "Move to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [mt] }] }, () => st2(false)), new In("selectToSheetStart", e5, { label: "Select to Sheet Home", description: "Select to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [mt, gt] }] }, () => st2(true)), new In("moveToRowEnd", e5, { label: "Move to Row End", description: "Move to the end of the row.", shortcut: [{ key: "End" }] }, () => ct2(false)), new In("selectToRowEnd", e5, { label: "Select to Row End", description: "Select to the end of the row.", shortcut: [{ key: "End", modifiers: [gt] }] }, () => ct2(true)), new In("moveToSheetEnd", e5, { label: "Move to Sheet End", description: "Move to the end of the sheet.", shortcut: [{ key: "End", modifiers: [mt] }] }, () => at2(false)), new In("selectToSheetEnd", e5, { label: "Select to Sheet End", description: "Select to the end of the sheet.", shortcut: [{ key: "End", modifiers: [mt, gt] }] }, () => at2(true)), new In("scrollToActiveCoords", e5, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell.", shortcut: { key: "Backspace", modifiers: [mt] } }, ot2), new In("scrollToActiveCoordsClearSelection", e5, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell and clear selection.", shortcut: { key: "Backspace", modifiers: [gt] } }, () => {
2746
+ Ue2(), Yt2(xe2.cell, true);
2747
+ }), new In("traverseSelectionRight", e5, { label: "Traverse Right", description: "Traverse the selection moving rightward.", shortcut: { key: "Tab" } }, bt2), new In("traverseSelectionLeft", e5, { label: "Traverse Left", description: "Traverse the selection moving leftward.", shortcut: { key: "Tab", modifiers: [gt] } }, vt2), new In("traverseSelectionDown", e5, { label: "Traverse Down", description: "Traverse the selection moving downward.", shortcut: [{ key: "Enter" }, { key: "NumpadEnter" }] }, Et2), new In("traverseSelectionUp", e5, { label: "Traverse Up", description: "Traverse the selection moving upward.", shortcut: [{ key: "Enter", modifiers: [gt] }, { key: "NumpadEnter", modifiers: [gt] }] }, St2), new In("moveLeft", e5, { label: "Move Left", description: "Move active cell to the left.", shortcut: [{ key: "ArrowLeft" }] }, kt2), new In("selectLeft", e5, { label: "Select Left", description: "Extend selection left.", shortcut: [{ key: "ArrowLeft", modifiers: [gt] }] }, Rt2), new In("moveContentfulLeft", e5, { label: "Move Left Contentful", description: "Move left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [mt] }] }, Pt2), new In("selectContentfulLeft", e5, { label: "Select Left Contentful", description: "Extend selection left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [mt, gt] }] }, Ot2), new In("moveRight", e5, { label: "Move Right", description: "Move active cell to the right.", shortcut: [{ key: "ArrowRight" }] }, Lt2), new In("selectRight", e5, { label: "Select Right", description: "Extend selection right.", shortcut: [{ key: "ArrowRight", modifiers: [gt] }] }, Dt2), new In("moveContentfulRight", e5, { label: "Move Right Contentful", description: "Move right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [mt] }] }, zt2), new In("selectContentfulRight", e5, { label: "Select Right Contentful", description: "Extend selection right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [mt, gt] }] }, At2), new In("moveUp", e5, { label: "Move Up", description: "Move active cell to the up.", shortcut: [{ key: "ArrowUp" }] }, $t2), new In("selectUp", e5, { label: "Select Up", description: "Extend selection up.", shortcut: [{ key: "ArrowUp", modifiers: [gt] }] }, Bt2), new In("moveContentfulUp", e5, { label: "Move Up Contentful", description: "Move up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [mt] }] }, Ft2), new In("selectContentfulUp", e5, { label: "Select Up Contentful", description: "Extend selection up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [mt, gt] }] }, jt2), new In("moveDown", e5, { label: "Move Down", description: "Move active cell to the down.", shortcut: [{ key: "ArrowDown" }] }, Vt2), new In("selectDown", e5, { label: "Select Down", description: "Extend selection down.", shortcut: [{ key: "ArrowDown", modifiers: [gt] }] }, Wt2), new In("moveContentfulDown", e5, { label: "Move Down Contentful", description: "Move down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [mt] }] }, Ht2), new In("selectContentfulDown", e5, { label: "Select Down Contentful", description: "Extend selection down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [mt, gt] }] }, Nt2), new In("selectVisible", e5, { label: "Select Visible", description: "Select visible cells only.", shortcut: { key: ";", modifiers: [wt] } }, ut2), new In("traverseSelectionPreviousRange", e5, { label: "Traverse Previous Range", description: "Traverse the selection to the previous range.", shortcut: { key: "ArrowLeft", modifiers: [mt, wt] } }, _t2), new In("traverseSelectionNextRange", e5, { label: "Traverse Next Range", description: "Traverse the selection to the next range.", shortcut: { key: "ArrowRight", modifiers: [mt, wt] } }, It2), new In("traverseSelectionCorners", e5, { label: "Traverse Corners", description: "Traverse the selection through the corners of the selected range.", shortcut: { key: ".", modifiers: [mt] } }, Mt2)];
2748
+ }, []);
2749
+ return d(() => {
2750
+ n2?.addCommands(dn2, true);
2751
+ }, [n2]), { selection: cn2, setSelectionCell: Yt2, setSelectionRanges: be2, overlay: an2, cursor: Ee2, onPointerDown: Ze2, clearLastSelection: qt2, newSelection: He2, modifySelection: We2, appendSelection: Ne2, clearSelections: Ue2, isEntire: Kt2, navigate: Qe2, navigateSelection: et2 };
2752
+ }, bo = { "sheetxl-grid": "_sheetxl-grid_11irg_13" }, So = Object.freeze({ top: 0, left: 0 }), Eo = Object.freeze({ bottom: -4, right: -4 }), _o = Object.freeze({ horizontal: true, vertical: true }), Io = [C, M, T, k], Co = 150, Mo = 3e3, To = {}, ko = r(a((o2, r2) => {
2753
+ const { width: c2, height: a2, rowCount: w2 = 1, columnCount: m2 = 1, defaultRowHeight: x2, defaultColumnWidth: y2, getRowHeight: v2, getColumnWidth: R2, layout: P2, onViewportScroll: O2, onImmediateScroll: L2, showGridLines: D2 = true, gridLineColor: z2 = "rgb(224, 224, 224)", gridLineRowsProps: A2, gridLineColumnsProps: $2, clipCells: B2 = true, cursor: F2, freezeLeft: j2 = 0, freezeTop: V2 = 0, freezeLeftProps: W2, freezeTopProps: H2, cellRenderer: N2, onViewportChange: U2, onFirstRender: q2, overlayRenderer: K2, overlayProps: Y2, overlays: X2, overlaysProps: G2, allowOverlaysOverflow: Z2 = false, stageProps: J2, stageWrapper: Q2 = null, hiddenRowsAt: ee2, hiddenColumnsAt: te2, hiddenCellAt: oe2, getVisibleCells: re2, zoom: ie2 = 1, enableMouseWheel: le2 = true, onWheelScroll: se2, getCellCoordsAsRangeCoords: ce2 = ne.cellToRange, scrollPoint: ae2 = So, style: de2 = {}, ...ue2 } = o2;
2754
+ b(N2, "No cellRenderer specified. This is probably not what you wanted"), b(!o2?.children, "Grid does not support children elements");
2755
+ const he2 = Tt(L2, [L2]), fe2 = Tt(U2, [U2]), pe2 = Tt(O2, [O2]), ge2 = Tt(se2, [se2]), we2 = Tt(q2, [q2]), me2 = l(null), xe2 = l(null), ye2 = l(null), [ve2, be2] = p((e5) => e5 + 1, 0), [Se2, Ee2] = h({ left: ae2?.left ?? 0, top: ae2?.top ?? 0, horizontalScrollDirection: null, verticalScrollDirection: null }), _e2 = l(null), Ie2 = l(Se2), { top: Ce2, left: Te2, verticalScrollDirection: ke2, horizontalScrollDirection: Re2 } = Se2, Pe2 = l(false), Oe2 = An({ rowCount: w2, columnCount: m2, defaultRowHeight: x2, defaultColumnWidth: y2, getRowHeight: v2, getColumnWidth: R2 }), Le2 = l(null), De2 = d(() => {
2756
+ const e5 = P2 || Oe2;
2757
+ return Le2.current = null, { getColOffset: (t2) => e5.getColOffset(t2) * ie2, getColIndex: (t2) => e5.getColIndex(t2 / ie2), getRowOffset: (t2) => e5.getRowOffset(t2) * ie2, getRowIndex: (t2) => e5.getRowIndex(t2 / ie2) };
2758
+ }, [Oe2, P2, ie2]), ze2 = (e5, t2, n2) => {
2759
+ const o3 = (t2?.left ?? 0) + 0, r3 = (t2?.top ?? 0) + 0;
2760
+ return { getColOffset: (t3) => e5.getColOffset(t3) - o3, getColIndex: (t3) => e5.getColIndex(t3 + o3), getRowOffset: (t3) => e5.getRowOffset(t3) - r3, getRowIndex: (t3) => e5.getRowIndex(t3 + r3) };
2761
+ }, Ae2 = i((e5, t2 = false) => to(e5, t2, De2.getRowOffset, t2 ? 0 : w2), [w2, De2?.getRowOffset]), $e2 = Tt(ee2 ?? Ae2, [ee2]), Be2 = i((e5, t2 = false) => to(e5, t2, De2.getColOffset, t2 ? m2 : 0), [m2, De2?.getColOffset]), Fe2 = Tt(te2 ?? Be2, [te2]), je2 = d(() => Math.min(c2 ?? 800, De2.getColOffset(m2)), [De2.getColOffset, m2, c2]), Ve2 = d(() => Math.min(a2 ?? 600, De2.getRowOffset(w2)), [De2.getRowOffset, w2, a2]), We2 = i((e5) => {
2762
+ Me.canUseDOM && setTimeout(() => {
2763
+ me2.current?.focus({ preventScroll: true, ...e5 });
2764
+ }, 0);
2765
+ }, []), He2 = i((e5) => me2.current?.contains(e5) || xe2.current?.contains(e5), []);
2766
+ s(() => {
2767
+ Pe2.current && (_e2.current && _e2.current.left !== Ie2.current?.left && _e2.current.top !== Ie2.current?.top || (_e2.current = null, pe2?.({ left: Te2, top: Ce2 })));
2768
+ }, [Te2, Ce2]);
2769
+ const Ne2 = Tt(() => ({ top: Ce2, left: Te2 }), [Ce2, Te2]), Ue2 = d(() => {
2770
+ const e5 = [];
2771
+ let t2 = 0, n2 = 0;
2772
+ "number" == typeof V2 ? t2 = V2 : (t2 = V2.index ?? 0, n2 = (V2.scrollOffset ?? 0) * ie2);
2773
+ const o3 = n2, r3 = De2.getRowOffset(t2), i2 = r3 - o3;
2774
+ if (t2 > 0) {
2775
+ const l3 = ze2(De2, { top: n2 + De2.getRowOffset(0) }), s3 = De2.getRowIndex(o3), c4 = De2.getRowIndex(r3 - 1);
2776
+ let a4;
2777
+ e5[1] = { minIndex: s3, maxIndex: c4, minCoord: 0, maxCoord: t2 - 1, minBounds: 0, maxBounds: i2, visibleIndices: () => a4 || (a4 = Object.freeze(qn($e2, s3, c4)), a4), layout: l3, maxVirtualBounds: r3, scrollOffset: n2, freezeOffset: n2 };
2778
+ }
2779
+ const l2 = Math.max(0, Ve2 - i2), s2 = ze2(De2, { top: Ce2 + i2 }), c3 = s2.getRowIndex(0), a3 = s2.getRowIndex(l2);
2780
+ let d2;
2781
+ return e5[0] = { minIndex: c3, maxIndex: a3, minCoord: t2, maxCoord: w2 - 1, minBounds: i2, maxBounds: l2, visibleIndices: () => d2 || (d2 = Object.freeze(qn($e2, c3, a3)), d2), layout: s2, maxVirtualBounds: De2.getRowOffset(w2), scrollOffset: Ce2, freezeOffset: (t2 > 0 ? De2.getRowOffset(t2) : 0) - n2 }, e5;
2782
+ }, [De2.getRowIndex, De2.getRowOffset, $e2, Ve2, w2, V2, Ce2, ie2]), qe2 = d(() => {
2783
+ const e5 = [];
2784
+ let t2 = 0, n2 = 0;
2785
+ "number" == typeof j2 ? t2 = j2 : (t2 = j2.index ?? 0, n2 = (j2.scrollOffset ?? 0) * ie2);
2786
+ const o3 = n2, r3 = De2.getColOffset(t2), i2 = r3 - o3;
2787
+ if (t2 > 0) {
2788
+ const l3 = ze2(De2, { left: n2 + De2.getColOffset(0) }), s3 = De2.getColIndex(o3), c4 = De2.getColIndex(r3 - 1);
2789
+ let a4;
2790
+ e5[1] = { minIndex: s3, maxIndex: c4, minCoord: 0, maxCoord: t2 - 1, minBounds: 0, maxBounds: i2, visibleIndices: () => a4 || (a4 = Object.freeze(qn(Fe2, s3, c4)), a4), layout: l3, maxVirtualBounds: r3, scrollOffset: n2, freezeOffset: n2 };
2791
+ }
2792
+ const l2 = Math.max(0, je2 - i2), s2 = ze2(De2, { left: Te2 + i2 }), c3 = s2.getColIndex(0), a3 = s2.getColIndex(l2);
2793
+ let d2;
2794
+ return e5[0] = { minIndex: c3, maxIndex: a3, minCoord: t2, maxCoord: m2 - 1, minBounds: i2, maxBounds: l2, visibleIndices: () => d2 || (d2 = Object.freeze(qn(Fe2, c3, a3)), d2), layout: s2, maxVirtualBounds: De2.getColOffset(m2), scrollOffset: Te2, freezeOffset: (t2 > 0 ? De2.getColOffset(t2) : 0) - n2 }, e5;
2795
+ }, [De2.getColIndex, De2.getColOffset, Fe2, je2, m2, j2, Te2, ie2]), Ke2 = l({}), Ye2 = l([]), Xe2 = d(() => {
2796
+ let e5 = {};
2797
+ const t2 = (t3, n3, o3, r3, i2) => {
2798
+ const l2 = { vertical: r3?.vertical || false, horizontal: r3?.horizontal || false };
2799
+ if (t3 >= qe2.length || n3 >= Ue2.length) return null;
2800
+ const s2 = { rowStart: Ue2[n3].minIndex, colStart: qe2[t3].minIndex, rowEnd: Ue2[n3].maxIndex, colEnd: qe2[t3].maxIndex };
2801
+ if (s2.rowStart > s2.rowEnd || s2.colStart > s2.colEnd) return null;
2802
+ const c3 = { getColIndex: (e6) => qe2[t3].layout.getColIndex(e6), getColOffset: (e6) => qe2[t3].layout.getColOffset(e6), getRowIndex: (e6) => Ue2[n3].layout.getRowIndex(e6), getRowOffset: (e6) => Ue2[n3].layout.getRowOffset(e6) }, a3 = Object.freeze({ left: i2?.left ?? 0, top: i2?.top ?? 0, right: i2?.right ?? 0, bottom: i2?.bottom ?? 0 }), d2 = Object.freeze({ x: qe2[t3].minBounds, y: Ue2[n3].minBounds, width: qe2[t3].maxBounds, height: Ue2[n3].maxBounds }), u2 = (e6, t4) => oo(c3, e6 ?? s2, t4), h2 = { width: qe2[t3].maxVirtualBounds, height: Ue2[n3].maxVirtualBounds }, f2 = { left: qe2[t3].scrollOffset, top: Ue2[n3].scrollOffset }, p2 = { left: qe2[t3].freezeOffset, top: Ue2[n3].freezeOffset }, g2 = { width: je2, height: Ve2 };
2803
+ let w3 = null, m3 = null;
2804
+ const x3 = (p2.top + (r3.vertical ? f2.top : 0)) / ie2, y3 = (p2.left + (r3.horizontal ? f2.left : 0)) / ie2;
2805
+ return { getStage: () => me2.current ?? null, getVisibleRangeCoords: () => s2, toClipBounds: (e6, t4) => {
2806
+ let n4, o4 = 0;
2807
+ return void 0 === t4 || "number" == typeof t4 ? (n4 = u2(s2), o4 = t4) : n4 = t4, ((e7, t5, n5 = 0) => {
2808
+ if (e7.x > t5.width || e7.y > t5.height) return null;
2809
+ const o5 = { left: e7.x, top: e7.y, bottom: e7.height + e7.y, right: e7.width + e7.x }, r4 = { left: t5.x + n5, top: t5.y + n5, bottom: t5.height - 2 * n5 + t5.y, right: t5.width - 2 * n5 + t5.x }, i3 = { left: Math.max(o5.left, r4.left), top: Math.max(o5.top, r4.top), bottom: Math.min(o5.bottom, r4.bottom), right: Math.min(o5.right, r4.right) }, l3 = { x: i3.left, y: i3.top, width: i3.right - i3.left, height: i3.bottom - i3.top };
2810
+ return l3.height < 0 || l3.width < 0 ? null : l3;
2811
+ })(e6 ?? { x: 0, y: 0, width: d2.width, height: d2.height }, n4, o4);
2812
+ }, toViewBounds: (e6) => 0 === y3 && 0 === x3 && 1 === ie2 ? e6 : { x: (e6.x - y3) * ie2, y: (e6.y - x3) * ie2, width: e6.width * ie2, height: e6.height * ie2 }, toAbsoluteBounds: (e6) => 0 === y3 && 0 === x3 && 1 === ie2 ? e6 : { x: e6.x / ie2 + y3, y: e6.y / ie2 + x3, width: e6.width / ie2, height: e6.height / ie2 }, getRelativePointFromClient: (e6, t4) => {
2813
+ const n4 = tt2(e6, t4);
2814
+ return { x: n4.x - d2.x, y: n4.y - d2.y };
2815
+ }, getLayout: () => c3, getCellCoordsAsRangeCoords: ce2, getVisibleColumns: () => qe2[t3].visibleIndices(), getVisibleRows: () => Ue2[n3].visibleIndices(), getVisibleColumnOffsets: () => (w3 || (w3 = no(qe2[t3].layout, true, qe2[t3].visibleIndices(), s2.colStart, s2.colEnd)), w3), getVisibleRowOffsets: () => (m3 || (m3 = no(Ue2[n3].layout, false, Ue2[n3].visibleIndices(), s2.rowStart, s2.rowEnd)), m3), getTotalRangeCoords: () => ({ colStart: qe2[t3].minCoord, colEnd: qe2[t3].maxCoord, rowStart: Ue2[n3].minCoord, rowEnd: Ue2[n3].maxCoord }), getRangeCoordsBounds: u2, scrollCellCoordsIntoView: (e6, t4) => ut2(e6, t4, o3), getCellCoordsFromClient: (e6, t4, n4 = false) => {
2816
+ const o4 = tt2(e6, t4);
2817
+ if (!o4) return null;
2818
+ const r4 = c3.getColIndex(o4.x - d2.x), i3 = { rowIndex: c3.getRowIndex(o4.y - d2.y), colIndex: r4 };
2819
+ if (n4) return i3;
2820
+ const l3 = ce2(i3);
2821
+ return { rowIndex: l3.rowStart, colIndex: l3.colStart };
2822
+ }, getZoom: () => ie2, getAnchor: () => o3, getBounds: () => d2, getInsets: () => a3, getTotalSize: () => h2, getViewportSize: () => g2, getScrollTopLeft: () => f2, getFreezeTopLeft: () => p2, getScrollOrientation: () => l2, allViews: () => e5 };
2823
+ };
2824
+ let n2 = e5[k] = t2(0, 0, k, _o, Eo);
2825
+ return n2 && (e5[k] = n2), n2 = t2(0, 1, M, { horizontal: true }), n2 && (e5[M] = n2), n2 = t2(1, 0, T, { vertical: true }), n2 && (e5[T] = n2), n2 = t2(1, 1, C, {}), n2 && (e5[C] = n2), Ke2.current = null, e5 = Object.freeze(e5);
2826
+ }, [Ue2, qe2, ce2]), Ge2 = Object.keys(Xe2), Ze2 = qe2[0]?.maxVirtualBounds ?? 0, Je2 = Ue2[0]?.maxVirtualBounds ?? 0, Qe2 = d(() => ({ left: qe2[1] ? qe2[1].layout.getColOffset(qe2[1].maxIndex + 1) : 0, top: Ue2[1] ? Ue2[1].layout.getRowOffset(Ue2[1].maxIndex + 1) : 0 }), [Xe2]);
2827
+ s(() => {
2828
+ if (Ye2.current.length > 0) {
2829
+ for (let e5 = 0; e5 < Ye2.current.length; e5++) Ye2.current[e5]();
2830
+ Ye2.current = [];
2831
+ }
2832
+ }, [Xe2]);
2833
+ const et2 = Tt(() => ({ containerWidth: je2, containerHeight: Ve2, totalWidth: Ze2, totalHeight: Je2 }), [je2, Ve2, De2]);
2834
+ s(() => {
2835
+ !_e2.current && Pe2.current && fe2({ top: Ce2, left: Te2, width: je2, height: Ve2, totalWidth: Ze2, totalHeight: Je2 });
2836
+ }, [Ce2, Te2, Ze2, Je2]), s(() => {
2837
+ Pe2.current && fe2({ top: Ce2, left: Te2, width: je2, height: Ve2, totalWidth: Ze2, totalHeight: Je2 });
2838
+ }, [je2, Ve2]);
2839
+ const tt2 = i((e5, t2) => {
2840
+ b("number" == typeof e5 && "number" == typeof t2, "Top and left should be a number.");
2841
+ const n2 = me2.current?.getBoundingClientRect();
2842
+ return n2 ? { x: e5 - n2.x, y: t2 - n2.y } : { x: e5, y: t2 };
2843
+ }, []), nt2 = Tt((e5) => Xe2[e5] || null, [Xe2]), ot2 = Tt((e5, t2) => {
2844
+ if (1 === Object.keys(Xe2).length) return Xe2[k];
2845
+ const n2 = tt2(e5, t2);
2846
+ if (!n2) return null;
2847
+ const { x: o3, y: r3 } = n2;
2848
+ let i2 = null;
2849
+ const l2 = Io;
2850
+ for (let e6 = 0; !i2 && e6 < l2.length; e6++) {
2851
+ const t3 = Xe2[l2[e6]];
2852
+ t3 && ro(o3, r3, t3.getBounds()) && (i2 = t3);
2853
+ }
2854
+ return i2 || (i2 = Xe2[k]), i2;
2855
+ }, [Xe2, ce2]), rt2 = Tt(() => Xe2[k].getVisibleRangeCoords(), [Xe2[k]]), it2 = l(null), lt2 = i(() => {
2856
+ null !== it2.current && Me.cancelTimeout(it2.current), it2.current = Me.requestTimeout(st2, 150);
2857
+ }, []), st2 = i(() => {
2858
+ it2.current = null, Ee2((e5) => {
2859
+ const t2 = { ...e5, verticalScrollDirection: null, horizontalScrollDirection: null };
2860
+ return Ie2.current = t2, t2;
2861
+ });
2862
+ }, []), ct2 = Tt((e5) => {
2863
+ const t2 = e5?.left ?? e5?.[0], n2 = e5?.top ?? e5?.[1], o3 = void 0 !== t2 ? Math.min(Ze2 - je2, Math.max(qe2?.[1]?.scrollOffset ?? 0, t2)) : Ie2.current.left, r3 = void 0 !== n2 ? Math.min(Je2 - Ve2, Math.max(Ue2?.[1]?.scrollOffset ?? 0, n2)) : Ie2.current.top;
2864
+ if (Ie2.current.left === o3 && Ie2.current.top === r3) return;
2865
+ let i2 = null, l2 = null;
2866
+ Ie2.current.left > o3 ? i2 = _ : Ie2.current.left < o3 && (i2 = I), Ie2.current.top > r3 ? l2 = S : Ie2.current.top < r3 && (l2 = E), Me.throttle(() => {
2867
+ Ee2((e6) => {
2868
+ const t3 = { ...e6, left: o3, top: r3, horizontalScrollDirection: i2, verticalScrollDirection: l2 };
2869
+ return Ie2.current = t3, t3;
2870
+ });
2871
+ }, 17)(), _e2.current?.top === r3 && _e2.current?.left === o3 || (_e2.current = { left: o3, top: r3 }, he2({ left: o3, top: r3 }), fe2({ left: o3, top: r3, width: je2, height: Ve2, totalWidth: Ze2, totalHeight: Je2 })), lt2();
2872
+ }, [Ze2, Je2, Ue2, qe2]);
2873
+ s(() => {
2874
+ _e2.current || ct2({ left: Te2, top: Ce2 });
2875
+ }, [Ze2, je2, Je2, Ve2]), u(() => {
2876
+ _e2.current = { left: ae2?.left, top: ae2?.top }, ct2(_e2.current);
2877
+ }, [ae2?.left, ae2?.top]);
2878
+ const at2 = Tt((e5) => {
2879
+ const t2 = e5?.left ?? e5?.[0], n2 = e5?.top ?? e5?.[1], o3 = e5?.behavior ?? "auto", r3 = { left: Ie2.current.left + (t2 ?? 0), top: Ie2.current.top + (n2 ?? 0) };
2880
+ o3 && (r3.behavior = o3), ct2(r3);
2881
+ }, [Ze2, je2, Je2, Ve2]), dt2 = i((e5) => {
2882
+ let t2 = null;
2883
+ if (Object.keys(Xe2).length > 1) {
2884
+ const n2 = Io;
2885
+ for (let o3 = 0; !t2 && o3 < n2.length; o3++) {
2886
+ const r3 = Xe2[n2[o3]];
2887
+ r3 && ne.isCellWithinRange(e5, r3.getVisibleRangeCoords()) && (t2 = r3);
2888
+ }
2889
+ }
2890
+ return t2 || (t2 = Xe2[k]), t2;
2891
+ }, [Xe2]), ut2 = Tt((e5, t2 = { inline: "nearest", block: "nearest" }, n2 = null) => {
2892
+ const o3 = { rowIndex: 0, colIndex: 0, ...e5 };
2893
+ let r3 = null;
2894
+ if (null !== n2) {
2895
+ if (r3 = Xe2[n2], null === r3) return new Promise((e6, t3) => {
2896
+ t3("Invalid view");
2897
+ });
2898
+ } else r3 = dt2(o3);
2899
+ const i2 = ce2(o3), l2 = r3.getLayout(), s2 = l2.getColOffset(i2.colStart), c3 = l2.getRowOffset(i2.rowStart), a3 = l2.getColOffset(i2.colEnd + 1), d2 = l2.getRowOffset(i2.rowEnd + 1), u2 = r3.getBounds(), h2 = r3.getTotalSize(), f2 = r3.getScrollTopLeft(), p2 = ((e6, t3, n3 = true) => (n3 = true === n3 ? { block: "start", inline: "end" } : false === n3 ? { block: "end", inline: "end" } : { block: "end", inline: "end", ...n3 }, { left: Zn(n3.inline, e6.x, e6.x + e6.width, t3.left, t3.left + t3.width, t3.totalWidth), top: Zn(n3.block, e6.y, e6.y + e6.height, t3.top, t3.top + t3.height, t3.totalHeight) }))({ x: s2 + f2.left, y: c3 + f2.top, width: a3 - s2, height: d2 - c3 }, { left: f2.left, top: f2.top, width: u2.width, height: u2.height, totalWidth: h2.width, totalHeight: h2.height }, t2), g2 = { ...p2 };
2900
+ g2.left > Te2 ? g2.left += 20 : g2.left < Te2 && (g2.left -= 0), g2.top > Ce2 ? g2.top += 20 : g2.top < Ce2 && (g2.top -= 0);
2901
+ const w3 = r3.getScrollOrientation();
2902
+ return w3.horizontal && void 0 !== e5.colIndex || delete g2.left, w3.vertical && void 0 !== e5.rowIndex || delete g2.top, new Promise((e6, t3) => {
2903
+ try {
2904
+ ct2(g2), e6(g2);
2905
+ } catch (e7) {
2906
+ t3(e7);
2907
+ }
2908
+ });
2909
+ }, [Ze2, Je2, Xe2, ce2]), ht2 = Tt((e5) => {
2910
+ const t2 = e5.shiftKey;
2911
+ e5.preventDefault();
2912
+ const { deltaX: n2, deltaY: o3, deltaMode: r3 } = e5;
2913
+ if (ye2.current) return;
2914
+ let i2 = ge2?.(e5);
2915
+ if (false === i2) return;
2916
+ let l2 = t2 ? o3 : n2, s2 = o3;
2917
+ const c3 = t2 || Math.abs(l2) > Math.abs(s2);
2918
+ 1 === r3 && (s2 *= 0), ye2.current = window.requestAnimationFrame(() => {
2919
+ ye2.current = null, at2(c3 ? { left: l2 } : { top: s2 });
2920
+ });
2921
+ }, [Ze2, je2, Je2, Ve2, ge2]), ft2 = i((e5 = null) => {
2922
+ Le2.current = null, Ke2.current = null, be2();
2923
+ }, []);
2924
+ u(() => {
2925
+ ft2();
2926
+ }, [N2]);
2927
+ const pt2 = Kt(r2, () => ({ stage: me2.current, focus: We2, contains: He2, invalidate: ft2, scrollTo: ct2, scrollBy: at2, scrollCellCoordsIntoView: ut2, getScrollPosition: Ne2, getDimensions: et2, getViewport: rt2, handleWheel: ht2, rowCount: w2, columnCount: m2, getLayout: () => De2, getRelativePointFromClient: tt2, getViewFromClient: ot2, getViewFromCellCoords: dt2, getViewFromLocation: nt2, onViewChangeOnce: (e5) => {
2928
+ Ye2.current.push(e5);
2929
+ } }), [w2, m2, Xe2]);
2930
+ s(() => (le2 && pt2.current?.addEventListener("wheel", ht2, { passive: false }), Pe2.current = true, _e2.current = null, () => {
2931
+ pt2.current?.removeEventListener("wheel", ht2);
2932
+ }), [le2]);
2933
+ const gt2 = l([]), wt2 = (t2, n2) => {
2934
+ if (!t2 || !K2) return;
2935
+ gt2.current = [];
2936
+ n2.push(((t3, o3) => {
2937
+ const r3 = `view:${t3.getAnchor()}:overlay:${n2.length}`, i2 = K2?.({ key: r3, view: t3 }, (e5) => gt2.current[o3] = e5);
2938
+ if (!i2) return null;
2939
+ const l2 = t3.getBounds();
2940
+ return e("div", { style: { position: "absolute", left: "0px", top: "0px", width: `${l2.width}px`, height: `${l2.height}px`, overflow: "hidden" }, children: i2 }, `overlay-${t3.getAnchor()}-${o3}`);
2941
+ })(t2, 0));
2942
+ }, mt2 = d(() => {
2943
+ const e5 = {}, t2 = Object.keys(Xe2);
2944
+ for (let n2 = 0; n2 < t2.length; n2++) {
2945
+ const o3 = t2[n2], r3 = [];
2946
+ wt2(Xe2[o3], r3), e5[o3] = { overlays: r3 };
2947
+ }
2948
+ return e5;
2949
+ }, [ve2, K2, w2, m2, Ue2, qe2]), xt2 = (t2, n2, o3, r3, i2, l2, s2) => {
2950
+ if (!t2) return;
2951
+ const c3 = t2.getVisibleColumns(), a3 = t2.getVisibleRows();
2952
+ if (0 === c3.length || 0 === a3.length) return;
2953
+ let d2 = null;
2954
+ if (re2) d2 = re2(t2);
2955
+ else {
2956
+ d2 = [];
2957
+ for (let e5 = 0; e5 < a3.length; e5++) for (let t3 = 0; t3 < c3.length; t3++) {
2958
+ const n3 = { rowIndex: a3[e5], colIndex: c3[t3] };
2959
+ if (oe2?.(n3)) continue;
2960
+ const o4 = { coords: n3, range: ce2(n3) };
2961
+ d2.push(o4);
2962
+ }
2963
+ }
2964
+ const u2 = t2.getVisibleColumnOffsets(), h2 = t2.getVisibleRowOffsets(), f2 = t2.getScrollTopLeft(), p2 = t2.getFreezeTopLeft(), g2 = f2.left + p2.left, w3 = f2.top + p2.top, m3 = Math.trunc(g2 / Mo), x3 = Math.trunc(w3 / Mo), y3 = {}, v3 = (e5, t3, n3, o4, r4) => {
2965
+ const i3 = `view:${e5.getAnchor()}:cell:${Gn(t3.rowIndex, t3.colIndex)}`, c4 = o4.x, a4 = o4.y, d3 = Math.trunc((g2 + c4) / Mo) - m3, u3 = Math.trunc((w3 + a4) / Mo) - x3;
2966
+ y3[u3] || (y3[u3] = {});
2967
+ let h3 = y3[u3][d3];
2968
+ h3 || (h3 = y3[u3][d3] = []);
2969
+ let f3 = l2?.get(i3);
2970
+ if (!f3) {
2971
+ const l3 = (g2 + c4) % Mo, s3 = (w3 + a4) % Mo;
2972
+ f3 = N2({ key: i3, coords: t3, bounds: o4, zoom: ie2, range: n3, view: e5, value: r4, style: { left: Ut.boundPixel(l3), top: Ut.boundPixel(s3), width: Ut.boundPixel(o4.width, true), height: Ut.boundPixel(o4.height, true) } });
2973
+ }
2974
+ s2?.set(i3, f3), h3.push(f3);
2975
+ };
2976
+ for (let e5 = 0; d2 && e5 < d2.length; e5++) {
2977
+ const n3 = d2[e5], l3 = n3?.coords ?? n3;
2978
+ if (!l3) continue;
2979
+ const s3 = n3?.range ?? { rowStart: l3.rowIndex, colStart: l3.colIndex, rowEnd: l3.rowIndex, colEnd: l3.colIndex }, c4 = t2.getVisibleRangeCoords();
2980
+ if (!ne.isRangesIntersect(s3, c4) && !ne.isRangeWithinRange(s3, c4)) continue;
2981
+ const a4 = s3 && !ne.isSingleCell(s3);
2982
+ if (!a4 && oe2?.(l3)) continue;
2983
+ const f3 = l3.rowIndex, p3 = l3.colIndex, g3 = h2[f3], w4 = u2[p3];
2984
+ let m4 = null;
2985
+ g3 && w4 && (m4 = { x: w4.offset, y: g3.offset, width: w4.size, height: g3.size });
2986
+ const x4 = Gn(s3.rowStart, s3.colStart);
2987
+ if (a4) {
2988
+ if (i2.has(x4)) continue;
2989
+ i2.add(x4), s3.rowEnd - s3.rowStart > 0 && o3.push(s3), s3.colEnd - s3.colStart > 0 && r3.push(s3);
2990
+ }
2991
+ if (a4 && (m4 = oo(t2.getLayout(), s3)), !m4) {
2992
+ console.warn("no bounds for cell", x4);
2993
+ continue;
2994
+ }
2995
+ const y4 = n3?.value;
2996
+ v3(t2, l3, s3, m4, y4);
2997
+ }
2998
+ const b2 = g2 % Mo, S2 = w3 % Mo, E2 = Object.keys(y3);
2999
+ for (let o4 = 0; o4 < E2.length; o4++) {
3000
+ const r4 = y3[E2[o4]];
3001
+ if (!r4) continue;
3002
+ const i3 = Object.keys(r4);
3003
+ for (let l3 = 0; l3 < i3.length; l3++) {
3004
+ const s3 = r4[i3[l3]];
3005
+ if (!s3) continue;
3006
+ const c4 = parseInt(E2[o4]), a4 = parseInt(i3[l3]), d3 = c4 + x3, u3 = a4 + m3, h3 = `view:${t2.getAnchor()}:segment:${u3}:${d3}`;
3007
+ n2.push(e("div", { className: "cell-container", style: { transform: `translate(${Ut.boundPixel(a4 * Mo - b2, true)}px, ${Ut.boundPixel(c4 * Mo - S2, true)}px)`, willChange: "transform" }, children: s3 }, h3));
3008
+ }
3009
+ }
3010
+ }, yt2 = d(() => {
3011
+ const e5 = Le2.current, t2 = /* @__PURE__ */ new Map(), n2 = {}, o3 = Object.keys(Xe2);
3012
+ for (let r3 = 0; r3 < o3.length; r3++) {
3013
+ const i2 = o3[r3], l2 = [], s2 = [], c3 = [];
3014
+ xt2(Xe2[i2], c3, l2, s2, /* @__PURE__ */ new Set(), e5, t2), n2[i2] = { cells: c3, rangesH: l2, rangesV: s2 };
3015
+ }
3016
+ return Le2.current = t2, n2;
3017
+ }, [ve2, w2, m2, Ue2, qe2, D2, de2, B2, oe2, re2, ce2]), vt2 = (t2, n2, o3, r3, i2) => {
3018
+ if (t2) if (n2) {
3019
+ const e5 = `view:${t2.getAnchor()}:hl:`, n3 = t2.getVisibleRows();
3020
+ if (!n3 || 0 === n3.length) return;
3021
+ const l2 = 0, s2 = t2.getBounds().width;
3022
+ let c3 = [];
3023
+ const a3 = i2.sort(ne.rowFirstRangeComparator), d2 = t2.getVisibleRangeCoords();
3024
+ for (let i3 = 0; i3 < n3.length && n3[i3] <= d2.rowEnd; i3++) {
3025
+ const u2 = n3[i3];
3026
+ if (u2 < d2.rowStart) continue;
3027
+ let h2 = false;
3028
+ for (; a3.length > 0 && a3[0].rowStart <= u2; ) {
3029
+ const e6 = a3.shift();
3030
+ e6.rowEnd > u2 && (c3.push(e6), h2 = true);
3031
+ }
3032
+ h2 && (c3 = c3.sort(ne.columnFirstRangeComparator));
3033
+ const p2 = t2.getLayout(), g2 = p2.getRowOffset(u2 + 1);
3034
+ let w3 = l2;
3035
+ for (let t3 = 0; t3 < c3.length + 1; t3++) {
3036
+ let n4 = w3, i4 = s2;
3037
+ const l3 = c3[t3];
3038
+ t3 < c3.length && (i4 = Math.min(s2, p2.getColOffset(l3.colStart)), w3 = Math.min(s2, p2.getColOffset(l3.colEnd + 1))), r3.push(f("path", { d: `M ${Ut.boundPixel(n4)} ${Ut.boundPixel(g2, false, o3)} L ${Ut.boundPixel(i4)} ${Ut.boundPixel(g2, false, o3)}`, stroke: z2, strokeWidth: 1, vectorEffect: "non-scaling-stroke", ...A2, key: e5 + u2 + ":" + t3 }));
3039
+ }
3040
+ for (let e6 = c3.length - 1; e6 >= 0; e6--) c3[e6].rowEnd <= n3[i3 + 1] && c3.splice(e6, 1);
3041
+ }
3042
+ } else {
3043
+ const n3 = `view:${t2.getAnchor()}:vl:`, l2 = t2.getVisibleColumns();
3044
+ if (!l2 || 0 === l2.length) return;
3045
+ const s2 = 0, c3 = t2.getBounds().height;
3046
+ let a3 = [];
3047
+ const d2 = i2.sort(ne.columnFirstRangeComparator), u2 = t2.getVisibleRangeCoords();
3048
+ for (let i3 = 0; i3 < l2.length && l2[i3] <= u2.colEnd; i3++) {
3049
+ const h2 = l2[i3];
3050
+ if (h2 < u2.colStart) continue;
3051
+ let f2 = false;
3052
+ for (; d2.length > 0 && d2[0].colStart <= h2; ) {
3053
+ const e5 = d2.shift();
3054
+ e5.colEnd > h2 && (a3.push(e5), f2 = true);
3055
+ }
3056
+ f2 && (a3 = a3.sort(ne.rowFirstRangeComparator));
3057
+ const p2 = t2.getLayout(), g2 = p2.getColOffset(h2 + 1);
3058
+ let w3 = s2;
3059
+ for (let t3 = 0; t3 < a3.length + 1; t3++) {
3060
+ let i4 = w3, l3 = c3;
3061
+ const s3 = a3[t3];
3062
+ t3 < a3.length && (l3 = Math.min(c3, p2.getRowOffset(s3.rowStart)), w3 = Math.min(c3, p2.getRowOffset(s3.rowEnd + 1)));
3063
+ let d3 = z2;
3064
+ r3.push(e("path", { d: `M ${Ut.boundPixel(g2, false, o3)} ${Ut.boundPixel(i4)} L ${Ut.boundPixel(g2, false, o3)} ${Ut.boundPixel(l3)}`, stroke: d3, strokeWidth: 1, vectorEffect: "non-scaling-stroke", ...$2 }, n3 + h2 + ":" + t3));
3065
+ }
3066
+ for (let e5 = a3.length - 1; e5 >= 0; e5--) a3[e5].colEnd <= l2[i3 + 1] && a3.splice(e5, 1);
3067
+ }
3068
+ }
3069
+ }, bt2 = (t2) => {
3070
+ if (!yt2) return;
3071
+ const n2 = {};
3072
+ for (let o3 = 0; o3 < Ge2.length; o3++) {
3073
+ const r3 = Ge2[o3], i2 = Xe2[r3], l2 = [];
3074
+ vt2(i2, t2, 0, l2, t2 ? yt2[r3].rangesH : yt2[r3].rangesV);
3075
+ const s2 = i2.getRangeCoordsBounds(), c3 = Math.ceil(s2.width), a3 = Math.ceil(s2.height);
3076
+ n2[r3] = e("svg", { width: `${c3}`, height: `${a3}`, viewBox: `0 0 ${c3} ${a3}`, preserveAspectRatio: "none", shapeRendering: "crispEdges", style: { position: "absolute" }, children: l2 });
3077
+ }
3078
+ return n2;
3079
+ }, St2 = d(() => true === D2 || true === D2?.horizontal ? bt2(true) : null, [ve2, D2, Ue2, V2, j2, z2, A2, w2, m2, je2, Ze2, yt2]), Et2 = d(() => true === D2 || true === D2?.vertical ? bt2(false) : null, [ve2, D2, qe2, V2, j2, z2, $2, w2, m2, Ve2, Je2, yt2]), _t2 = d(() => 0 === Qe2.left ? null : e(lo, { linePoints: [0, 0, 0, Ve2 + 1], bounds: { x: Qe2.left, y: 0, width: 1, height: Ve2 + 1 }, ...W2 }), [ve2, Qe2.left, Ve2, W2]), It2 = d(() => 0 === Qe2.top ? null : e(lo, { linePoints: [0, 0, je2 + 1, 0], bounds: { x: 0, y: Qe2.top, width: je2 + 1, height: 1 }, ...H2 }), [ve2, Qe2.top, je2, H2]), Ct2 = d(() => {
3080
+ const o3 = [], r3 = (e5) => {
3081
+ if (!e5 || !Xe2[e5]) return;
3082
+ const n2 = Xe2[e5].getBounds();
3083
+ return t("div", { style: { position: "absolute", pointerEvents: "none", left: n2.x, top: n2.y, width: n2.width, height: n2.height, clip: `rect(0, ${n2.width + 1}px, ${n2.height + 1}px, 0)` }, className: `view view-${e5}`, children: [St2?.[e5], Et2?.[e5], yt2?.[e5].cells] }, `view:${e5}`);
3084
+ };
3085
+ for (let e5 = 0; e5 < Ge2.length; e5++) o3.push(r3(Ge2[e5]));
3086
+ return e(n, { children: o3 });
3087
+ }, [Xe2, St2, Et2, yt2]), Mt2 = d(() => {
3088
+ if (!r2) return;
3089
+ const e5 = (e6, t2, n3, o4) => {
3090
+ if (!o4 || 0 === o4.length) return;
3091
+ const r3 = [];
3092
+ for (let i3 = 0; i3 < o4.length; i3++) {
3093
+ const l3 = o4[i3];
3094
+ let s3 = e6?.get(l3);
3095
+ s3 !== To && (s3 = l3(n3) ?? To), t2.set(l3, s3), s3 && s3 !== To && r3.push(s3);
3096
+ }
3097
+ return r3;
3098
+ }, n2 = (n3, o4, r3) => {
3099
+ if (!r3) return;
3100
+ const i3 = r3.getBounds(), l3 = r3.getInsets(), s3 = r3.getAnchor();
3101
+ return t("div", { className: g("view", `view-${s3}`, bo.view), style: { position: "absolute", pointerEvents: "none", left: i3.x - l3.left, top: i3.y - l3.top, width: i3.width - (l3.left + l3.right), height: i3.height - (l3.top + l3.bottom), clipPath: Z2 ? "inset(-2px)" : "inset(0px)" }, children: [e5(n3, o4, r3, X2), mt2?.[s3].overlays] }, `view:${s3}`);
3102
+ }, o3 = Ke2.current, i2 = {}, l2 = [], s2 = Object.keys(Xe2);
3103
+ for (let e6 = 0; e6 < s2.length; e6++) {
3104
+ const t2 = s2[e6], r3 = o3?.[t2], c3 = i2[t2] = /* @__PURE__ */ new Map();
3105
+ l2.push(n2(r3, c3, Xe2[t2]));
3106
+ }
3107
+ return Ke2.current = i2, l2;
3108
+ }, [ve2, Xe2, Z2, X2]), kt2 = d(() => {
3109
+ const { style: t2, ...n2 } = J2 ?? {};
3110
+ return e("div", { style: { width: je2, height: Ve2, ...t2 }, className: "sheetxl-stage", tabIndex: 0, ref: me2, ...n2, ...ue2, children: Q2 ? Q2(Ct2) : Ct2 });
3111
+ }, [je2, Ve2, Ct2, J2, Q2]), Rt2 = l(false);
3112
+ return s(() => {
3113
+ !Rt2.current && yt2 && (Rt2.current = true, we2?.(pt2.current));
3114
+ }, [yt2]), t("div", { className: g("sheetxl-grid", bo["sheetxl-grid"]), style: { overflow: "visible", cursor: F2, maxWidth: je2, maxHeight: Ve2, width: je2, height: Ve2, ...de2 }, ref: pt2, children: [kt2, t("div", { className: g("sheetxl-overlays"), ref: xe2, ...G2, children: [Mt2, _t2, It2] })] });
3115
+ }));
3116
+ ko.displayName = "BaseGrid";
3117
+ const Ro = r(a((t2, n2) => {
3118
+ const { width: o2, height: r2, style: i2 = {}, className: l2, ...s2 } = t2, [c2, { width: a2, height: d2 }] = w();
3119
+ return e("div", { className: l2, style: { ...i2 }, children: e("div", { style: { position: "relative", top: "0px", left: "0px", width: "100%", height: "100%", maxWidth: "100%", maxHeight: "100%", boxSizing: "content-box" }, ref: c2, children: e(ko, { ref: n2, width: o2 ?? a2, height: r2 ?? d2, ...s2 }) }) });
3120
+ }));
3121
+ Ro.displayName = "Grid";
3122
+ const Po = r(a((t2, n2) => {
3123
+ const { showVerticalScrollbar: o2, showHorizontalScrollbar: r2, createHorizontalScrollbar: s2, createVerticalScrollbar: a2, createScrollCorner: d2, viewport: u2, onScrollViewport: f2, style: p2 = {}, className: g2, onScroll: w2, ...m2 } = t2, [x2, y2] = h(null), v2 = l(null), S2 = l(null);
3124
+ b(!u2, "Viewport can not be specified"), c(n2, () => S2.current && v2.current ? Object.assign(S2.current, v2.current) : null);
3125
+ const E2 = i((e5) => {
3126
+ S2.current?.scrollTo(e5), f2?.(e5);
3127
+ }, []);
3128
+ return e(Gt, { className: g2, style: p2, ref: v2, showVerticalScrollbar: o2, showHorizontalScrollbar: r2, createHorizontalScrollbar: s2, createVerticalScrollbar: a2, createScrollCorner: d2, viewport: x2, onScrollViewport: E2, children: e(Ro, { style: { width: "100%", height: "100%" }, ...m2, onViewportChange: (e5) => y2(e5), ref: S2 }) });
3129
+ }));
3130
+ Po.displayName = "ScrollableGrid";
3131
+ const Oo = () => false, Lo = r((t2) => {
3132
+ const { index: n2, value: o2, zoom: r2, zoomScale: i2 = 100, headerText: s2 = (e5) => `${e5}`, headerStyle: c2, headerStyleSelect: a2 = c2, headerStyleSelectAll: d2 = a2, headerStyleHover: u2 = d2, verticalPadding: f2 = 0, horizontalPadding: p2 = 0, isSelected: g2 = Oo, isSelectedAll: w2 = Oo, coords: m2, bounds: x2, range: y2, orientation: v2, view: b2, style: S2, ...E2 } = t2, _2 = i2 / 100, I2 = l(null), [C2, M2] = h(false), T2 = g2?.(n2) || false, k2 = w2?.(n2) || false ? d2 : T2 ? a2 : c2;
3133
+ let R2 = k2;
3134
+ if (C2) {
3135
+ let e5 = u2;
3136
+ "function" == typeof u2 && (e5 = u2(k2)), R2 = Me.mergeContentful(k2, e5);
3137
+ }
3138
+ return e("div", { ref: I2, style: { background: R2.fill, color: R2.text?.fill, fontFamily: R2.text?.fontFamily ?? c2.text?.fontFamily, fontSize: 96 * (R2.text?.fontSize ?? 11) / 72 * _2, fontStyle: R2.text?.fontStyle, fontWeight: R2.text?.fontWeight, lineHeight: 1.2, display: "flex", justifyContent: "center", alignItems: "end", pointerEvents: "auto", paddingBottom: `${_2}px`, ...S2, left: S2.left - (v2 === A ? 1 : 0), top: S2.top - (v2 === $ ? 1 : 0), width: S2.width + 1, height: S2.height + 1, overflow: "hidden" }, ...E2, onMouseMove: (e5) => {
3139
+ "touch" !== Ut.detectIt().primaryInput && 0 === e5.buttons && M2(true);
3140
+ }, onMouseOut: (e5) => {
3141
+ M2(false);
3142
+ }, children: s2(n2) });
3143
+ });
3144
+ Lo.displayName = "HeaderRenderer";
3145
+ const Do = "ew-resize", zo = "ns-resize", Ao = r(a((n2, o2) => {
3146
+ const { orientation: r2, view: i2, index: l2, className: s2, style: c2, disabled: a2 = false, disabledResize: d2 = false, isNextHidden: u2, isHidden: h2, isSelected: f2, isSelectedAll: p2, showTouchDivider: w2, headerStyle: m2, headerStyleSelect: x2, headerStyleSelectAll: y2, headerStyleHover: v2, bounds: b2, onPointerDown: S2, onAutoFit: E2, ..._2 } = n2, I2 = r2 === A;
3147
+ let C2 = m2;
3148
+ f2 && x2 && (C2 = x2), p2 && y2 && (C2 = y2);
3149
+ const M2 = "touch" === Ut.detectIt().primaryInput;
3150
+ let T2 = I2 ? 14 : 8, k2 = T2 / 2, R2 = 0;
3151
+ u2 && (R2 = -2), h2 && (R2 = 2), h2 && (T2 = T2 / 2 + R2, k2 = 2 * R2);
3152
+ let P2 = C2.dividerStrokeFill ?? C2.strokeFill;
3153
+ return !(f2 || p2) && 0 === R2 && (P2 = `linear-gradient(${I2 ? 180 : 90}deg, ${C2.fill}, ${P2} 55%, ${P2} 100%)`), t("div", { className: g("header-divider", { disabled: a2 }, s2, `index-${l2}`), ref: o2, onPointerDown: M2 ? void 0 : S2, onDoubleClick: M2 ? void 0 : () => E2?.(), style: { top: (I2 ? 0 : -T2 / 2 + (R2 - 1)) + "px", left: (I2 ? -T2 / 2 + (R2 - 1) : 0) + "px", width: I2 ? T2 : "calc(100% + 1px)", height: I2 ? "calc(100% + 1px)" : T2, position: "absolute", overflow: "visible", pointerEvents: "all", cursor: a2 || d2 || M2 ? void 0 : I2 ? Do : zo, ...c2 }, ..._2, children: [e("div", { style: { position: "relative", top: `${I2 ? 0 : k2}px`, left: `${I2 ? k2 : 0}px`, width: I2 ? 1 : "100%", height: I2 ? "100%" : 1, background: P2 }, onDoubleClick: () => E2?.() }), w2 && M2 ? e("div", { style: { position: "absolute", cursor: "grab", zIndex: 1, borderRadius: "4px", right: I2 ? "-6px" : "2px", bottom: I2 ? "2px" : "-9px", height: "24px", width: I2 ? "24px" : "18px", maxHeight: I2 ? "calc(100% - 4px)" : void 0, maxWidth: I2 ? void 0 : "calc(100% - 4px)", background: C2.fill, border: `${y2.edgeStrokeFill} solid 1px`, boxShadow: `0.5px 0.5px 0px 0px ${m2.text.fill}`, display: "flex", alignItems: "center", justifyContent: "center" }, onPointerDown: S2, children: e("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(x2.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: I2 ? void 0 : "rotate(90deg)" } }) }) : null] });
3154
+ })), $o = (t2, n2) => e(Ao, { ...t2, ref: n2 }), Bo = r(a((o2, r2) => {
3155
+ const { orientation: i2, view: s2, index: c2, disabled: a2 = false, disabledResize: d2 = false, resizeThreshold: u2 = 1, dividerRenderer: f2 = $o, onDividerMouseDown: p2, onDividerResizeStart: w2, onDividerResize: m2, onDividerResizeEnd: x2, onDividerMouseUp: y2, onDividerAutoFit: b2, onPointerDown: S2, ...E2 } = o2, _2 = Tt(S2, [S2]), I2 = Tt(b2, [b2]), C2 = i2 === A;
3156
+ let M2 = C2 ? s2.getVisibleColumns() : s2.getVisibleRows(), T2 = null;
3157
+ M2.length > 0 && (C2 ? T2 = s2.getRangeCoordsBounds({ rowStart: 0, rowEnd: 0, colStart: M2[0], colEnd: M2[M2.length - 1] }) : s2.getRangeCoordsBounds({ rowStart: M2[0], rowEnd: M2[M2.length - 1], colStart: 0, colEnd: 0 }), T2 = s2.toClipBounds(T2, fo));
3158
+ const k2 = l(null), [R2, P2] = h(null), O2 = (e5, t2) => C2 ? e5.clientX - t2.clientX : e5.clientY - t2.clientY, L2 = s2.getLayout(), D2 = C2 ? L2.getColOffset(c2 + 1) : L2.getRowOffset(c2 + 1), z2 = hn({ processTouch: true, onPointerDown: (e5) => {
3159
+ if (_2?.(e5), !a2 && !d2) {
3160
+ const e6 = C2 ? L2.getColOffset(c2) : L2.getRowOffset(c2), t2 = D2 - e6;
3161
+ k2.current = { isResizing: false, startSize: t2, index: c2, view: s2, orientation: i2, onDividerMouseDown: p2, onDividerResizeStart: w2, onDividerResize: m2, onDividerResizeEnd: x2, onDividerMouseUp: y2 }, P2(k2.current), p2?.(c2, t2);
3162
+ }
3163
+ e5.stopPropagation(), e5.preventDefault();
3164
+ }, onPointerUp: (e5, t2, n2) => {
3165
+ if (!k2.current) return;
3166
+ k2.current.isResizing && k2.current.onDividerResizeEnd?.(k2.current.index, Math.max(0, k2.current.startSize + O2(e5, n2)), k2.current.startSize);
3167
+ const o3 = k2.current;
3168
+ k2.current = null, P2(k2.current), o3.onDividerMouseUp?.(o3.index);
3169
+ }, onPointerMoveOrWait: (e5, t2, n2) => {
3170
+ if (!k2.current) return;
3171
+ const o3 = O2(e5, n2);
3172
+ k2.current.isResizing ? k2.current.onDividerResize?.(k2.current.index, Math.max(0, k2.current.startSize + o3), k2.current.startSize) : Math.abs(o3) > Math.max(1, u2) && (k2.current = { ...k2.current, isResizing: true }, P2(k2.current), k2.current.onDividerResizeStart?.(k2.current.index, Math.max(0, k2.current.startSize + o3))), e5.stopPropagation(), e5.preventDefault();
3173
+ } }), $2 = Tt(() => {
3174
+ I2?.(c2);
3175
+ }, [c2]);
3176
+ if (!T2) return;
3177
+ const B2 = f2({ bounds: T2, orientation: i2, view: s2, index: c2, disabled: a2, disabledResize: d2, onAutoFit: $2, onPointerDown: z2, ...E2 }, r2);
3178
+ if (!B2) return;
3179
+ const { getPortalContainer: F2 } = Qt();
3180
+ let j2 = null;
3181
+ return R2 && R2.isResizing && R2.index === c2 && (j2 = v(e("div", { style: { position: "absolute", cursor: C2 ? Do : zo, left: 0, top: 0, width: "100%", height: "100%" } }), F2(), "divider:" + c2)), t(n, { children: [j2, e("div", { className: g("header-divider-anchor"), style: { position: "absolute", pointerEvents: "auto", top: `${C2 ? T2.y : D2}px`, left: `${C2 ? D2 : T2.x}px`, width: (C2 ? 0 : T2.width - 1) + "px", height: (C2 ? T2.height - 1 : 0) + "px", display: "flex" }, tabIndex: -1, children: B2 })] });
3182
+ }));
3183
+ class Fo {
3184
+ naturalDimensions(e5, t2 = {}) {
3185
+ const n2 = document.createElement("div");
3186
+ let o2 = t2?.lineHeight ?? "1";
3187
+ !t2?.lineHeight && t2.paintableText?.fontSize && (o2 = Math.ceil(1.2 * t2.paintableText.fontSize) + "px");
3188
+ const r2 = document.createElement("div");
3189
+ r2.style.visibility = "hidden", r2.style.position = "absolute", r2.style.textRendering = "geometricprecision", r2.style.display = "inline-grid", r2.style.overflowWrap = "break-word", r2.style.maxWidth = t2.maxWidth ? t2.maxWidth + "px" : "100%", r2.style.lineHeight = o2, r2.style.letterSpacing = (t2.paintableText?.letterSpacing ?? 0) + "px", r2.style.fontSize = t2.paintableText?.fontSize ? t2.paintableText.fontSize + "px" : "unset", r2.style.fontFamily = t2.paintableText?.fontSize ? t2.paintableText.fontFamily : "unset", r2.style.fontWeight = t2.paintableText?.fontWeight ? "" + t2.paintableText.fontWeight : "400", r2.style.fontStyle = t2.paintableText?.fontStyle ? t2.paintableText.fontStyle : "normal", r2.style.whiteSpace = "wrap" === t2.paintableText?.wrap ? "break-spaces" : "pre", n2.appendChild(r2);
3190
+ const i2 = e5.split("\n");
3191
+ for (let e6 = 0; e6 < i2.length; e6++) {
3192
+ let t3 = document.createElement("span");
3193
+ r2.appendChild(t3), t3.textContent = i2[e6];
3194
+ }
3195
+ 0 !== i2.length && 0 !== i2[i2.length - 1].length || r2.appendChild(document.createElement("br")), document.body.appendChild(r2);
3196
+ let l2 = r2.getBoundingClientRect();
3197
+ return r2.remove(), { width: l2.width, height: l2.height, maxLineHeight: 1.2 * (t2.paintableText?.fontSize || 1056 / 72) };
3198
+ }
3199
+ }
3200
+ const jo = (e5 = void 0) => Object.freeze({ clean: e5, dirty: void 0, editMode: false }), Vo = jo(), Wo = r(a((t2, n2) => {
3201
+ const { editState: o2 = Vo, defaultTextStyle: r2, onStartEdit: c2, onChangeEdit: a2, onSubmitEdit: f2, onCancelEdit: p2, onDoneEdit: g2, containerBounds: w2, setNaturalDimensions: m2, onNavigate: x2, textProperties: y2, style: v2, autoFocus: b2, ...C2 } = t2, M2 = l(null), { width: T2 = 0 } = w2 ?? {}, [k2, R2] = h(() => o2);
3202
+ s(() => {
3203
+ R2(o2);
3204
+ }, [o2]);
3205
+ const P2 = y2?.align || "left", O2 = y2?.vAlign || "middle", L2 = y2?.fill || "#040404", D2 = y2?.wrap || "wrap", z2 = y2?.fontFamily || "Calibri", A2 = y2?.fontSize || 11, $2 = y2?.fontWeight || 400, B2 = y2?.fontStyle || "normal", F2 = k2.dirty ?? k2.clean ?? "";
3206
+ let j2 = 2;
3207
+ const V2 = 96 * A2 / 72, W2 = 1.2 * V2;
3208
+ "right" === O2 && (j2 += 1);
3209
+ const H2 = d(() => new Fo().naturalDimensions(F2, { maxWidth: "wrap" === D2 ? T2 - j2 : void 0, lineHeight: `${W2}px`, paintableText: { fontStyle: B2, wrap: D2, letterSpacing: -0.25 } }), [F2, D2, j2, V2, z2, $2, B2, m2, T2]), N2 = i(() => H2.maxLineHeight ? H2.maxLineHeight + "px" : "1.2", [H2]), [U2, q2] = h(N2);
3210
+ u(() => {
3211
+ q2(N2());
3212
+ }, [w2, H2]), u(() => {
3213
+ m2?.({ width: "wrap" === D2 ? void 0 : H2.width + j2, height: H2.height });
3214
+ }, [H2, m2]);
3215
+ const K2 = Tt(a2, [a2]), Y2 = Tt((e5) => {
3216
+ if (k2.dirty === e5) return;
3217
+ const t3 = { ...k2 };
3218
+ t3.dirty = e5, M2.current, R2(t3), K2?.(t3);
3219
+ }, [k2]), X2 = Tt((e5) => {
3220
+ if (k2.editMode === e5) return;
3221
+ const t3 = { ...k2 };
3222
+ t3.editMode = e5, R2(t3), K2?.(t3);
3223
+ }, [k2]), G2 = Tt(() => {
3224
+ try {
3225
+ return f2?.(k2), g2?.(), true;
3226
+ } catch (e5) {
3227
+ return false;
3228
+ }
3229
+ }, [f2, k2]), Z2 = Tt(() => {
3230
+ R2(o2), p2?.(), g2?.();
3231
+ }, [p2, o2]), J2 = Tt((e5) => {
3232
+ if (!M2.current) return;
3233
+ if (e5.isDefaultPrevented(), !(e5.isTrusted || e5.nativeEvent.ctrlKey || e5.nativeEvent.metaKey || e5.nativeEvent.altKey || e5.nativeEvent.isComposing) && -1 !== $n.indexOf(e5.nativeEvent.key)) {
3234
+ const t4 = { ...k2 };
3235
+ return t4.dirty = "Backspace" === e5.nativeEvent.key ? "" : (t4.dirty ?? "") + e5.key, R2(t4), K2?.(t4), void e5.preventDefault();
3236
+ }
3237
+ const t3 = e5.nativeEvent.shiftKey;
3238
+ if (e5.which === vt) return e5.preventDefault(), void Z2();
3239
+ if (e5.which === It) return X2(true), void e5.preventDefault();
3240
+ if (e5.which === yt && (e5.preventDefault(), G2() && x2?.(t3 ? S : E)), e5.which === xt) return e5.preventDefault(), void (G2() && x2?.(t3 ? _ : I));
3241
+ if (!k2.editMode) {
3242
+ let t4 = null;
3243
+ switch (e5.which) {
3244
+ case bt:
3245
+ t4 = _;
3246
+ break;
3247
+ case Et:
3248
+ t4 = I;
3249
+ break;
3250
+ case St:
3251
+ t4 = S;
3252
+ break;
3253
+ case _t:
3254
+ t4 = E;
3255
+ }
3256
+ if (t4) return void G2();
3257
+ }
3258
+ }, [k2, x2]), [Q2, ee2] = h(!b2);
3259
+ s(() => {
3260
+ ee2(false);
3261
+ }, []);
3262
+ const te2 = Kt(n2, () => ({ startEdit(e5) {
3263
+ let t3 = e5?.initialSelection;
3264
+ if (!t3) {
3265
+ const e6 = M2.current.value.length ?? 0;
3266
+ t3 = { start: e6, end: e6, direction: "forward" };
3267
+ }
3268
+ M2.current?.setSelectionRange(t3.start, t3.end, t3.direction);
3269
+ const n3 = { ...o2, editMode: e5?.editMode ?? false };
3270
+ void 0 !== e5?.text && (n3.dirty = e5.text), n3.editMode === o2.editMode && n3.dirty === o2.dirty || (R2(n3), K2?.(n3));
3271
+ }, submitEdit: () => G2(), cancelEdit() {
3272
+ Z2();
3273
+ }, autoFocus() {
3274
+ M2.current?.focus();
3275
+ }, getLineHeight: () => H2?.maxLineHeight ?? W2, dispatchEvent: (e5) => M2.current.dispatchEvent(e5) }), [o2, c2]);
3276
+ return e("div", { ref: te2, ...C2, style: { background: "transparent", display: "flex", flexGrow: 1, alignSelf: "center", height: H2.height, maxWidth: "100%", maxHeight: "100%", ...v2 }, children: e("textarea", { spellCheck: "false", ref: M2, value: F2, autoFocus: false, disabled: Q2, name: "cell-editor", autoComplete: "off", autoCapitalize: "off", style: { flex: "1 1 100%", position: "relative", fontSize: `${V2}px`, fontFamily: `${z2}`, fontWeight: `${$2}`, fontStyle: `${B2}`, padding: "0px", marginRight: "right" === P2 ? "3px" : "0px", marginLeft: "left" === P2 ? "2px" : "0px", lineHeight: U2, height: H2.height, textRendering: "geometricPrecision", letterSpacing: "-0.25px", boxSizing: "border-box", borderWidth: 0, outline: "none", resize: "none", overflow: "hidden", verticalAlign: "baseline", textAlign: P2, background: "transparent", color: L2, marginBottom: "0px", userSelect: "text", maxHeight: "100%", whiteSpace: "wrap" === D2 ? "break-spaces" : "pre", wordWrap: "break-word" }, onChange: (e5) => {
3277
+ Y2(e5.target.value);
3278
+ }, onDoubleClick: (e5) => {
3279
+ e5.isTrusted;
3280
+ }, onMouseDown: (e5) => {
3281
+ X2(true);
3282
+ }, onKeyDown: J2 }) });
3283
+ })), Ho = r((t2) => {
3284
+ const { value: n2, view: o2, bounds: r2, range: i2, zoom: l2, children: s2, style: c2, ...a2 } = t2;
3285
+ return e("div", { style: { padding: "2px 4px", fontFamily: "Calibri", letterSpacing: -0.25, lineHeight: 1.2, fontSize: c2?.fontSize || 1056 / 72, ...c2 }, ...a2, children: n2 });
3286
+ });
3287
+ export {
3288
+ ko as BaseGrid,
3289
+ Wo as DefaultCellEditor,
3290
+ Ho as DefaultCellRenderer,
3291
+ Ao as DefaultHeaderDivider,
3292
+ uo as FillHandle,
3293
+ Ro as Grid,
3294
+ Bo as HeaderDivider,
3295
+ Lo as HeaderRenderer,
3296
+ Co as RESET_SCROLL_EVENTS_DEBOUNCE_INTERVAL,
3297
+ fo as SELECTION_CLIP_INSETS,
3298
+ $n as STANDARD_KEY_CHARS,
3299
+ lo as SVGLine,
3300
+ so as SVGRect,
3301
+ Po as ScrollableGrid,
3302
+ ao as Selection,
3303
+ ho as TouchSelectHandle,
3304
+ co as defaultSelectionRenderer,
3305
+ jo as getDefaultStringEditState,
3306
+ mo as safeSelectionCoords,
3307
+ An as useCellLayout,
3308
+ Nn as useHeaderSelection,
3309
+ Hn as useKeyboardEditorOverlay,
3310
+ vo as useSelection
3311
+ };