@silurus/ooxml 0.69.0 → 0.70.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4274 @@
1
+ import { B as e, C as t, G as n, H as r, I as i, J as a, K as o, L as s, M as c, O as l, R as u, S as d, U as f, V as p, W as m, X as h, Y as g, Z as _, _ as v, a as y, b, c as x, d as S, f as C, g as w, h as T, i as E, k as D, m as O, n as k, p as A, r as j, s as M, u as N, v as P, w as F, x as I, z as L } from "./line-metrics-DG9p1RvA.js";
2
+ import { i as R, n as ee, r as z, t as B } from "./visible-index-B4ljB_dg.js";
3
+ import { t as V } from "./mathjax-BRfWlbSJ.js";
4
+ import { t as H } from "./segments-BTivjRMw.js";
5
+ //#region packages/core/src/sparkline/renderer.ts
6
+ function U(t, n, r) {
7
+ let { values: i } = r;
8
+ if (i.length === 0 || n.w <= 0 || n.h <= 0) return;
9
+ let a = r.colorSeries ?? "#5B9BD5", o = Math.min(2, n.w * .08), s = Math.max(2, n.h * .2), c = n.x + o, l = n.y + s, u = Math.max(1, n.w - o * 2), d = Math.max(1, n.h - s * 2), f = i.filter((e) => typeof e == "number");
10
+ if (f.length === 0) return;
11
+ let p = Math.min(...f), m = Math.max(...f), h = r.min ?? p, g = r.max ?? m;
12
+ h === g && (g = h + 1, --h);
13
+ let _ = g - h, v = (e) => l + d - (e - h) / _ * d;
14
+ if (r.kind === "stem") {
15
+ ne(t, r, c, l, u, d);
16
+ return;
17
+ }
18
+ if (r.kind === "column") {
19
+ te(t, r, i, c, l, u, d, h, g);
20
+ return;
21
+ }
22
+ if (r.displayXAxis && h < 0 && g > 0) {
23
+ t.save(), t.strokeStyle = r.colorAxis ?? "#000000", t.lineWidth = 1, t.beginPath();
24
+ let e = v(0);
25
+ t.moveTo(c, e), t.lineTo(c + u, e), t.stroke(), t.restore();
26
+ }
27
+ let y = i.length, b = (e) => y === 1 ? c + u / 2 : c + e / (y - 1) * u;
28
+ t.save(), t.strokeStyle = a, t.lineCap = "round", t.lineJoin = "round", t.lineWidth = (r.lineWeight ?? .75) * e, t.beginPath();
29
+ let x = !1, S = r.displayEmptyCellsAs ?? "gap";
30
+ for (let e = 0; e < y; e++) {
31
+ let n = i[e];
32
+ if (n == null) {
33
+ if (S === "zero") {
34
+ let n = b(e), r = v(0);
35
+ x ? t.lineTo(n, r) : (t.moveTo(n, r), x = !0);
36
+ } else S === "gap" && (x = !1);
37
+ continue;
38
+ }
39
+ let r = b(e), a = v(n);
40
+ x ? t.lineTo(r, a) : (t.moveTo(r, a), x = !0);
41
+ }
42
+ t.stroke(), t.restore();
43
+ let C = Math.max(1, Math.min(2.5, d * .12)), w = W(i, r);
44
+ for (let e = 0; e < y; e++) {
45
+ let n = i[e];
46
+ if (n == null) continue;
47
+ let o = w[e];
48
+ (r.markers || o != null) && (t.save(), t.fillStyle = o ?? r.colorMarkers ?? a, t.beginPath(), t.arc(b(e), v(n), C, 0, Math.PI * 2), t.fill(), t.restore());
49
+ }
50
+ }
51
+ function W(e, t) {
52
+ let n = e.map(() => null), r = e.map((e) => typeof e == "number" ? e : null), i = r.findIndex((e) => e != null), a = -1;
53
+ for (let e = r.length - 1; e >= 0; e--) if (r[e] != null) {
54
+ a = e;
55
+ break;
56
+ }
57
+ let o = r.filter((e) => e != null), s = NaN, c = NaN;
58
+ if (o.length > 0 && (s = Math.max(...o), c = Math.min(...o)), t.negative && t.colorNegative) for (let e = 0; e < r.length; e++) {
59
+ let i = r[e];
60
+ i != null && i < 0 && (n[e] = t.colorNegative);
61
+ }
62
+ if (t.first && t.colorFirst && i >= 0 && (n[i] = t.colorFirst), t.last && t.colorLast && a >= 0 && (n[a] = t.colorLast), t.high && t.colorHigh && !Number.isNaN(s)) for (let e = 0; e < r.length; e++) r[e] === s && (n[e] = t.colorHigh);
63
+ if (t.low && t.colorLow && !Number.isNaN(c)) for (let e = 0; e < r.length; e++) r[e] === c && (n[e] = t.colorLow);
64
+ return n;
65
+ }
66
+ function te(e, t, n, r, i, a, o, s, c) {
67
+ let l = n.length;
68
+ if (l === 0) return;
69
+ let u = s < 0 && c > 0 ? 0 : s, d = c - s, f = (e) => i + o - (e - s) / d * o, p = f(u), m = a / l, h = Math.min(1.5, m * .15), g = W(n, t);
70
+ for (let i = 0; i < l; i++) {
71
+ let a = n[i];
72
+ if (a == null) continue;
73
+ let o = g[i] ?? (a < 0 && t.colorNegative ? t.colorNegative : t.colorSeries ?? "#5B9BD5"), s = f(a), c = r + m * i + h / 2, l = Math.max(1, m - h);
74
+ e.save(), e.fillStyle = o, e.fillRect(c, Math.min(p, s), l, Math.abs(p - s)), e.restore();
75
+ }
76
+ }
77
+ function ne(e, t, n, r, i, a) {
78
+ let o = t.values.length;
79
+ if (o === 0) return;
80
+ let s = r + a / 2, c = a / 2, l = i / o, u = Math.min(1.5, l * .15), d = W(t.values, t);
81
+ for (let r = 0; r < o; r++) {
82
+ let i = t.values[r];
83
+ if (i == null || i === 0) continue;
84
+ let a = i < 0, o = d[r] ?? (a && t.colorNegative ? t.colorNegative : t.colorSeries ?? "#5B9BD5"), f = n + l * r + u / 2, p = Math.max(1, l - u);
85
+ e.save(), e.fillStyle = o, a ? e.fillRect(f, s, p, c) : e.fillRect(f, s - c, p, c), e.restore();
86
+ }
87
+ }
88
+ //#endregion
89
+ //#region packages/xlsx/src/worker.ts?worker&inline
90
+ var re = "var e=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,n.unregister(this),e}free(){let e=this.__destroy_into_raw();y.__wbg_xlsxarchive_free(e,0)}extract_image(e){let t=f(e,y.__wbindgen_malloc,y.__wbindgen_realloc),n=v,r=y.xlsxarchive_extract_image(this.__wbg_ptr,t,n);if(r[3])throw p(r[2]);var a=i(r[0],r[1]).slice();return y.__wbindgen_free(r[0],r[1]*1,1),a}constructor(e,t){let r=d(e,y.__wbindgen_malloc),i=v,a=y.xlsxarchive_new(r,i,!u(t),u(t)?BigInt(0):t);if(a[2])throw p(a[1]);return this.__wbg_ptr=a[0]>>>0,n.register(this,this.__wbg_ptr,this),this}parse(){let e=y.xlsxarchive_parse(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return y.__wbindgen_free(e[0],e[1]*1,1),t}parse_sheet(e,t){let n=f(t,y.__wbindgen_malloc,y.__wbindgen_realloc),r=v,a=y.xlsxarchive_parse_sheet(this.__wbg_ptr,e,n,r);if(a[3])throw p(a[2]);var o=i(a[0],a[1]).slice();return y.__wbindgen_free(a[0],a[1]*1,1),o}to_markdown(){let e,t;try{let i=y.xlsxarchive_to_markdown(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,p(i[2]);return e=n,t=r,s(n,r)}finally{y.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(e.prototype[Symbol.dispose]=e.prototype.free);function t(){return{__proto__:null,\"./xlsx_parser_bg.js\":{__proto__:null,__wbg___wbindgen_debug_string_ab4b34d23d6778bd:function(e,t){let n=f(r(t),y.__wbindgen_malloc,y.__wbindgen_realloc),i=v;o().setInt32(e+4,i,!0),o().setInt32(e+0,n,!0)},__wbg___wbindgen_string_get_7ed5322991caaec5:function(e,t){let n=t,r=typeof n==`string`?n:void 0;var i=u(r)?0:f(r,y.__wbindgen_malloc,y.__wbindgen_realloc),a=v;o().setInt32(e+4,a,!0),o().setInt32(e+0,i,!0)},__wbg___wbindgen_throw_6b64449b9b9ed33c:function(e,t){throw Error(s(e,t))},__wbg_error_a6fa202b58aa1cd3:function(e,t){let n,r;try{n=e,r=t,console.error(s(e,t))}finally{y.__wbindgen_free(n,r,1)}},__wbg_new_227d7c05414eb861:function(){return Error()},__wbg_stack_3b0d974bbf31e44f:function(e,t){let n=t.stack,r=f(n,y.__wbindgen_malloc,y.__wbindgen_realloc),i=v;o().setInt32(e+4,i,!0),o().setInt32(e+0,r,!0)},__wbindgen_cast_0000000000000001:function(e,t){return s(e,t)},__wbindgen_init_externref_table:function(){let e=y.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}const n=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>y.__wbg_xlsxarchive_free(e>>>0,1));function r(e){let t=typeof e;if(t==`number`||t==`boolean`||e==null)return`${e}`;if(t==`string`)return`\"${e}\"`;if(t==`symbol`){let t=e.description;return t==null?`Symbol`:`Symbol(${t})`}if(t==`function`){let t=e.name;return typeof t==`string`&&t.length>0?`Function(${t})`:`Function`}if(Array.isArray(e)){let t=e.length,n=`[`;t>0&&(n+=r(e[0]));for(let i=1;i<t;i++)n+=`, `+r(e[i]);return n+=`]`,n}let n=/\\[object ([^\\]]+)\\]/.exec(toString.call(e)),i;if(n&&n.length>1)i=n[1];else return toString.call(e);if(i==`Object`)try{return`Object(`+JSON.stringify(e)+`)`}catch{return`Object`}return e instanceof Error?`${e.name}: ${e.message}\\n${e.stack}`:i}function i(e,t){return e>>>=0,l().subarray(e/1,e/1+t)}let a=null;function o(){return(a===null||a.buffer.detached===!0||a.buffer.detached===void 0&&a.buffer!==y.memory.buffer)&&(a=new DataView(y.memory.buffer)),a}function s(e,t){return e>>>=0,g(e,t)}let c=null;function l(){return(c===null||c.byteLength===0)&&(c=new Uint8Array(y.memory.buffer)),c}function u(e){return e==null}function d(e,t){let n=t(e.length*1,1)>>>0;return l().set(e,n/1),v=e.length,n}function f(e,t,n){if(n===void 0){let n=_.encode(e),r=t(n.length,1)>>>0;return l().subarray(r,r+n.length).set(n),v=n.length,r}let r=e.length,i=t(r,1)>>>0,a=l(),o=0;for(;o<r;o++){let t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==r){o!==0&&(e=e.slice(o)),i=n(i,r,r=o+e.length*3,1)>>>0;let t=l().subarray(i+o,i+r),a=_.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return v=o,i}function p(e){let t=y.__wbindgen_externrefs.get(e);return y.__externref_table_dealloc(e),t}let m=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});m.decode();let h=0;function g(e,t){return h+=t,h>=2146435072&&(m=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),m.decode(),h=t),m.decode(l().subarray(e,e+t))}const _=new TextEncoder;`encodeInto`in _||(_.encodeInto=function(e,t){let n=_.encode(e);return t.set(n),{read:e.length,written:n.length}});let v=0,y;function b(e,t){return y=e.exports,a=null,c=null,y.__wbindgen_start(),y}async function x(e,t){if(typeof Response==`function`&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming==`function`)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if(e.ok&&n(e.type)&&e.headers.get(`Content-Type`)!==`application/wasm`)console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\",t);else throw t}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}function n(e){switch(e){case`basic`:case`cors`:case`default`:return!0}return!1}}async function S(e){if(y!==void 0)return y;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn(`using deprecated parameters for the initialization function; pass a single object instead`));let n=t();(typeof e==`string`||typeof Request==`function`&&e instanceof Request||typeof URL==`function`&&e instanceof URL)&&(e=fetch(e));let{instance:r,module:i}=await x(await e,n);return b(r,i)}function C(e){if(!e.startsWith(`data:`))return null;let t=e.indexOf(`,`);if(t===-1)return null;let n=atob(e.slice(t+1)),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r.buffer}let w=null,T=null;function E(){T&&=(T.free(),null)}self.onmessage=async t=>{let n=t.data;if(n.type===`init`){w=S(C(n.wasmUrl)??n.wasmUrl);return}let r=n.id;try{if(await w,n.type===`parse`){let t=typeof n.maxZipEntryBytes==`number`&&n.maxZipEntryBytes>0?BigInt(n.maxZipEntryBytes):void 0;E(),T=new e(new Uint8Array(n.data),t);let i=T.parse().buffer,a={type:`parsed`,id:r,workbookJson:i};self.postMessage(a,[i])}else if(n.type===`parseSheet`){if(!T)throw Error(`parseSheet before parse: no archive retained`);let e=T.parse_sheet(n.sheetIndex,n.sheetName).buffer,t={type:`parsedSheet`,id:r,worksheetJson:e};self.postMessage(t,[e])}else if(n.type===`extractImage`){if(!T)throw Error(`No xlsx loaded`);let e=T.extract_image(n.path),t=new Uint8Array(e).slice().buffer,i={type:`imageExtracted`,id:r,bytes:t};self.postMessage(i,[t])}}catch(e){let t={type:`error`,id:r,message:String(e)};self.postMessage(t)}};", ie = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", re], { type: "text/javascript;charset=utf-8" });
91
+ function ae(e) {
92
+ let t;
93
+ try {
94
+ if (t = ie && (self.URL || self.webkitURL).createObjectURL(ie), !t) throw "";
95
+ let n = new Worker(t, {
96
+ type: "module",
97
+ name: e?.name
98
+ });
99
+ return n.addEventListener("error", () => {
100
+ (self.URL || self.webkitURL).revokeObjectURL(t);
101
+ }), n;
102
+ } catch {
103
+ return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(re), {
104
+ type: "module",
105
+ name: e?.name
106
+ });
107
+ }
108
+ }
109
+ //#endregion
110
+ //#region packages/xlsx/src/wasm/xlsx_parser_bg.wasm?url
111
+ var oe = new URL(new URL("xlsx_parser_bg.wasm", import.meta.url).href, import.meta.url).href;
112
+ //#endregion
113
+ //#region packages/xlsx/src/sheet-visibility.ts
114
+ function se(e, t) {
115
+ return !Number.isInteger(t) || t < 0 || t >= e.length ? "visible" : e[t].visibility ?? "visible";
116
+ }
117
+ //#endregion
118
+ //#region packages/xlsx/src/formula.ts
119
+ function G(e) {
120
+ return Array.isArray(e) ? e : [e];
121
+ }
122
+ function K(e) {
123
+ return Array.isArray(e) ? e[0] ?? 0 : e;
124
+ }
125
+ var ce = 8;
126
+ function q(e, t) {
127
+ try {
128
+ return le(me(e, t));
129
+ } catch {
130
+ return !1;
131
+ }
132
+ }
133
+ function le(e) {
134
+ let t = K(e);
135
+ return typeof t == "boolean" ? t : typeof t == "number" ? t !== 0 : typeof t == "string" ? t.length > 0 && t.toUpperCase() !== "FALSE" : !1;
136
+ }
137
+ function J(e) {
138
+ let t = K(e);
139
+ if (typeof t == "number") return t;
140
+ if (typeof t == "boolean") return +!!t;
141
+ if (t == null) return 0;
142
+ let n = parseFloat(String(t));
143
+ return isNaN(n) ? 0 : n;
144
+ }
145
+ function Y(e) {
146
+ let t = K(e);
147
+ return t == null ? "" : typeof t == "boolean" ? t ? "TRUE" : "FALSE" : String(t);
148
+ }
149
+ var ue = new Set([
150
+ "<",
151
+ ">",
152
+ "=",
153
+ "+",
154
+ "-",
155
+ "*",
156
+ "/",
157
+ "&",
158
+ "^",
159
+ "%"
160
+ ]);
161
+ function de(e) {
162
+ let t = [], n = 0, r = e;
163
+ for (; n < r.length;) {
164
+ let e = r[n];
165
+ if (e === " " || e === " " || e === "\n" || e === "\r") {
166
+ n++;
167
+ continue;
168
+ }
169
+ if (e === "(") {
170
+ t.push({
171
+ kind: "lparen",
172
+ text: e
173
+ }), n++;
174
+ continue;
175
+ }
176
+ if (e === ")") {
177
+ t.push({
178
+ kind: "rparen",
179
+ text: e
180
+ }), n++;
181
+ continue;
182
+ }
183
+ if (e === ",") {
184
+ t.push({
185
+ kind: "comma",
186
+ text: e
187
+ }), n++;
188
+ continue;
189
+ }
190
+ if (e === ":") {
191
+ t.push({
192
+ kind: "colon",
193
+ text: e
194
+ }), n++;
195
+ continue;
196
+ }
197
+ if (e === "\"") {
198
+ let e = n + 1, i = "";
199
+ for (; e < r.length;) {
200
+ if (r[e] === "\"" && r[e + 1] === "\"") {
201
+ i += "\"", e += 2;
202
+ continue;
203
+ }
204
+ if (r[e] === "\"") break;
205
+ i += r[e], e++;
206
+ }
207
+ t.push({
208
+ kind: "str",
209
+ text: i
210
+ }), n = e + 1;
211
+ continue;
212
+ }
213
+ if (e >= "0" && e <= "9") {
214
+ let e = n;
215
+ for (; e < r.length && (r[e] >= "0" && r[e] <= "9" || r[e] === ".");) e++;
216
+ t.push({
217
+ kind: "num",
218
+ text: r.slice(n, e)
219
+ }), n = e;
220
+ continue;
221
+ }
222
+ if (ue.has(e)) {
223
+ (e === "<" || e === ">") && (r[n + 1] === "=" || e === "<" && r[n + 1] === ">") ? (t.push({
224
+ kind: "op",
225
+ text: r.slice(n, n + 2)
226
+ }), n += 2) : (t.push({
227
+ kind: "op",
228
+ text: e
229
+ }), n++);
230
+ continue;
231
+ }
232
+ if (e === "$" || X(e)) {
233
+ let e = n;
234
+ for (; e < r.length && (r[e] === "$" || fe(r[e]));) e++;
235
+ let i = r.slice(n, e);
236
+ n = e;
237
+ let a = pe(i);
238
+ if (a) t.push({
239
+ kind: "ref",
240
+ text: i,
241
+ ref: a
242
+ });
243
+ else {
244
+ let e = i.toUpperCase();
245
+ e === "TRUE" || e === "FALSE" ? t.push({
246
+ kind: "bool",
247
+ text: e
248
+ }) : t.push({
249
+ kind: "name",
250
+ text: i
251
+ });
252
+ }
253
+ continue;
254
+ }
255
+ n++;
256
+ }
257
+ return t;
258
+ }
259
+ function X(e) {
260
+ return e >= "A" && e <= "Z" || e >= "a" && e <= "z" || e === "_";
261
+ }
262
+ function fe(e) {
263
+ return X(e) || e >= "0" && e <= "9" || e === ".";
264
+ }
265
+ function pe(e) {
266
+ let t = 0, n = !1, r = !1;
267
+ e[t] === "$" && (n = !0, t++);
268
+ let i = t;
269
+ for (; t < e.length && e[t] >= "A" && e[t].toUpperCase() <= "Z" && !(!(e[t] >= "A" && e[t] <= "Z") && !(e[t] >= "a" && e[t] <= "z"));) t++;
270
+ if (t === i) return null;
271
+ let a = e.slice(i, t).toUpperCase();
272
+ e[t] === "$" && (r = !0, t++);
273
+ let o = t;
274
+ for (; t < e.length && e[t] >= "0" && e[t] <= "9";) t++;
275
+ if (t === o || t !== e.length) return null;
276
+ let s = parseInt(e.slice(o, t), 10), c = 0;
277
+ for (let e = 0; e < a.length; e++) c = c * 26 + (a.charCodeAt(e) - 64);
278
+ return {
279
+ colAbs: n,
280
+ col: c,
281
+ rowAbs: r,
282
+ row: s
283
+ };
284
+ }
285
+ function me(e, t) {
286
+ return _e({
287
+ toks: de(e),
288
+ pos: 0
289
+ }, t);
290
+ }
291
+ function he(e) {
292
+ return e.toks[e.pos];
293
+ }
294
+ function ge(e) {
295
+ return e.toks[e.pos++];
296
+ }
297
+ function _e(e, t) {
298
+ return ve(e, t);
299
+ }
300
+ function ve(e, t) {
301
+ let n = ye(e, t), r = he(e);
302
+ if (r && r.kind === "op" && (r.text === "<" || r.text === ">" || r.text === "<=" || r.text === ">=" || r.text === "=" || r.text === "<>")) {
303
+ ge(e);
304
+ let i = ye(e, t);
305
+ return be(r.text, n, i);
306
+ }
307
+ return n;
308
+ }
309
+ function ye(e, t) {
310
+ let n = xe(e, t);
311
+ for (;;) {
312
+ let r = he(e);
313
+ if (!r || r.kind !== "op" || r.text !== "&") break;
314
+ ge(e);
315
+ let i = xe(e, t);
316
+ n = Y(n) + Y(i);
317
+ }
318
+ return n;
319
+ }
320
+ function be(e, t, n) {
321
+ let r = typeof t == "string" && isNaN(parseFloat(t)) ? null : J(t), i = typeof n == "string" && isNaN(parseFloat(n)) ? null : J(n);
322
+ if (r !== null && i !== null) switch (e) {
323
+ case "<": return r < i;
324
+ case ">": return r > i;
325
+ case "<=": return r <= i;
326
+ case ">=": return r >= i;
327
+ case "=": return r === i;
328
+ case "<>": return r !== i;
329
+ }
330
+ let a = String(t ?? ""), o = String(n ?? "");
331
+ switch (e) {
332
+ case "<": return a < o;
333
+ case ">": return a > o;
334
+ case "<=": return a <= o;
335
+ case ">=": return a >= o;
336
+ case "=": return a === o;
337
+ case "<>": return a !== o;
338
+ }
339
+ return !1;
340
+ }
341
+ function xe(e, t) {
342
+ let n = Se(e, t);
343
+ for (;;) {
344
+ let r = he(e);
345
+ if (!r || r.kind !== "op" || r.text !== "+" && r.text !== "-") break;
346
+ ge(e);
347
+ let i = Se(e, t);
348
+ n = r.text === "+" ? J(n) + J(i) : J(n) - J(i);
349
+ }
350
+ return n;
351
+ }
352
+ function Se(e, t) {
353
+ let n = Ce(e, t);
354
+ for (;;) {
355
+ let r = he(e);
356
+ if (!r || r.kind !== "op" || r.text !== "*" && r.text !== "/") break;
357
+ ge(e);
358
+ let i = Ce(e, t);
359
+ if (r.text === "*") n = J(n) * J(i);
360
+ else {
361
+ let e = J(i);
362
+ n = e === 0 ? 0 : J(n) / e;
363
+ }
364
+ }
365
+ return n;
366
+ }
367
+ function Ce(e, t) {
368
+ let n = he(e);
369
+ return n && n.kind === "op" && n.text === "-" ? (ge(e), -J(Ce(e, t))) : n && n.kind === "op" && n.text === "+" ? (ge(e), J(Ce(e, t))) : we(e, t);
370
+ }
371
+ function we(e, t) {
372
+ let n = ge(e);
373
+ if (!n) return 0;
374
+ if (n.kind === "num") return parseFloat(n.text);
375
+ if (n.kind === "str") return n.text;
376
+ if (n.kind === "bool") return n.text === "TRUE";
377
+ if (n.kind === "lparen") {
378
+ let n = _e(e, t), r = ge(e);
379
+ if (!r || r.kind !== "rparen") throw Error("missing )");
380
+ return n;
381
+ }
382
+ if (n.kind === "ref") {
383
+ if (he(e)?.kind === "colon") {
384
+ ge(e);
385
+ let r = ge(e);
386
+ if (r?.kind !== "ref" || !r.ref) throw Error("range: expected ref after :");
387
+ return De(n.ref, r.ref, t);
388
+ }
389
+ return Ee(n.ref, t);
390
+ }
391
+ if (n.kind === "name") {
392
+ if (he(e)?.kind === "lparen") {
393
+ ge(e);
394
+ let r = [];
395
+ if (he(e)?.kind !== "rparen") for (r.push(_e(e, t)); he(e)?.kind === "comma";) ge(e), r.push(_e(e, t));
396
+ let i = ge(e);
397
+ if (!i || i.kind !== "rparen") throw Error("missing )");
398
+ return ke(n.text, r, t);
399
+ }
400
+ let r = t.definedNames.get(n.text);
401
+ return r && t.depth < ce ? me(Te(r.formula), {
402
+ ...t,
403
+ anchorRow: 1,
404
+ anchorCol: 1,
405
+ depth: t.depth + 1
406
+ }) : 0;
407
+ }
408
+ return 0;
409
+ }
410
+ function Te(e) {
411
+ let t = e.match(/^(?:'[^']*'|[A-Za-z_][A-Za-z0-9_.]*)!(.*)$/);
412
+ return t ? t[1] : e;
413
+ }
414
+ function Ee(e, t) {
415
+ let n = e.colAbs ? e.col : e.col + (t.col - t.anchorCol), r = e.rowAbs ? e.row : e.row + (t.row - t.anchorRow);
416
+ return Oe(t.cellIndex.get(`${r}:${n}`));
417
+ }
418
+ function De(e, t, n) {
419
+ let r = e.colAbs ? e.col : e.col + (n.col - n.anchorCol), i = e.rowAbs ? e.row : e.row + (n.row - n.anchorRow), a = t.colAbs ? t.col : t.col + (n.col - n.anchorCol), o = t.rowAbs ? t.row : t.row + (n.row - n.anchorRow), s = Math.min(r, a), c = Math.max(r, a), l = Math.min(i, o), u = Math.max(i, o), d = [], f = 4096;
420
+ for (let e = l; e <= u && d.length < f; e++) for (let t = s; t <= c && d.length < f; t++) d.push(Oe(n.cellIndex.get(`${e}:${t}`)));
421
+ return d;
422
+ }
423
+ function Oe(e) {
424
+ if (!e) return null;
425
+ switch (e.value.type) {
426
+ case "number": return e.value.number;
427
+ case "bool": return e.value.bool;
428
+ case "text": return e.value.text;
429
+ case "error": return null;
430
+ default: return null;
431
+ }
432
+ }
433
+ function ke(e, t, n) {
434
+ switch (e.toUpperCase()) {
435
+ case "AND": return t.flatMap(G).every((e) => le(e));
436
+ case "OR": return t.flatMap(G).some((e) => le(e));
437
+ case "NOT": return !le(t[0]);
438
+ case "IF": return le(t[0]) ? t[1] ?? !0 : t[2] ?? !1;
439
+ case "IFERROR": return t[0] == null ? t[1] ?? 0 : t[0];
440
+ case "IFS":
441
+ for (let e = 0; e + 1 < t.length; e += 2) if (le(t[e])) return t[e + 1];
442
+ return null;
443
+ case "TRUE": return !0;
444
+ case "FALSE": return !1;
445
+ case "ISBLANK": {
446
+ let e = K(t[0]);
447
+ return e == null || e === "";
448
+ }
449
+ case "ISNUMBER": return typeof K(t[0]) == "number";
450
+ case "ISTEXT": return typeof K(t[0]) == "string";
451
+ case "ISNONTEXT": return typeof K(t[0]) != "string";
452
+ case "ISERROR":
453
+ case "ISERR":
454
+ case "ISNA": return K(t[0]) == null;
455
+ case "ISLOGICAL": return typeof K(t[0]) == "boolean";
456
+ case "ROUNDDOWN": {
457
+ let e = J(t[0]), n = 10 ** J(t[1]);
458
+ return (e >= 0 ? Math.floor(e * n) : Math.ceil(e * n)) / n;
459
+ }
460
+ case "ROUNDUP": {
461
+ let e = J(t[0]), n = 10 ** J(t[1]);
462
+ return (e >= 0 ? Math.ceil(e * n) : Math.floor(e * n)) / n;
463
+ }
464
+ case "ROUND": {
465
+ let e = J(t[0]), n = 10 ** J(t[1]);
466
+ return Math.round(e * n) / n;
467
+ }
468
+ case "INT": return Math.floor(J(t[0]));
469
+ case "TRUNC": {
470
+ let e = J(t[0]), n = 10 ** J(t[1] ?? 0);
471
+ return (e >= 0 ? Math.floor(e * n) : Math.ceil(e * n)) / n;
472
+ }
473
+ case "CEILING": {
474
+ let e = J(t[0]), n = J(t[1] ?? 1);
475
+ return n === 0 ? 0 : Math.ceil(e / n) * n;
476
+ }
477
+ case "FLOOR": {
478
+ let e = J(t[0]), n = J(t[1] ?? 1);
479
+ return n === 0 ? 0 : Math.floor(e / n) * n;
480
+ }
481
+ case "MOD": {
482
+ let e = J(t[0]), n = J(t[1]);
483
+ return n === 0 ? null : e - Math.floor(e / n) * n;
484
+ }
485
+ case "POWER": return J(t[0]) ** +J(t[1]);
486
+ case "SQRT": {
487
+ let e = J(t[0]);
488
+ return e < 0 ? null : Math.sqrt(e);
489
+ }
490
+ case "ABS": return Math.abs(J(t[0]));
491
+ case "SIGN": {
492
+ let e = J(t[0]);
493
+ return e > 0 ? 1 : e < 0 ? -1 : 0;
494
+ }
495
+ case "EXP": return Math.exp(J(t[0]));
496
+ case "LN": {
497
+ let e = J(t[0]);
498
+ return e <= 0 ? null : Math.log(e);
499
+ }
500
+ case "LOG10": {
501
+ let e = J(t[0]);
502
+ return e <= 0 ? null : Math.log10(e);
503
+ }
504
+ case "MIN": {
505
+ let e = t.flatMap(G).filter((e) => typeof e == "number");
506
+ return e.length ? Math.min(...e) : 0;
507
+ }
508
+ case "MAX": {
509
+ let e = t.flatMap(G).filter((e) => typeof e == "number");
510
+ return e.length ? Math.max(...e) : 0;
511
+ }
512
+ case "SUM": return t.flatMap(G).reduce((e, t) => e + (typeof t == "number" ? t : 0), 0);
513
+ case "AVERAGE": {
514
+ let e = t.flatMap(G).filter((e) => typeof e == "number");
515
+ return e.length ? e.reduce((e, t) => e + t, 0) / e.length : null;
516
+ }
517
+ case "COUNT": return t.flatMap(G).filter((e) => typeof e == "number").length;
518
+ case "COUNTA": return t.flatMap(G).filter((e) => e != null && e !== "").length;
519
+ case "COUNTBLANK": return t.flatMap(G).filter((e) => e == null || e === "").length;
520
+ case "COUNTIF": return Ae(G(t[0]), t[1]);
521
+ case "SUMIF": return je(G(t[0]), t[1], t[2] === void 0 ? null : G(t[2]));
522
+ case "AVERAGEIF": {
523
+ let e = G(t[0]), n = je(e, t[1], t[2] === void 0 ? null : G(t[2])), r = Ae(e, t[1]);
524
+ return r === 0 ? null : J(n) / r;
525
+ }
526
+ case "LEN": return Y(t[0]).length;
527
+ case "LEFT": return Y(t[0]).slice(0, Math.max(0, J(t[1] ?? 1)));
528
+ case "RIGHT": {
529
+ let e = Y(t[0]), n = Math.max(0, J(t[1] ?? 1));
530
+ return n >= e.length ? e : e.slice(e.length - n);
531
+ }
532
+ case "MID": {
533
+ let e = Y(t[0]), n = Math.max(1, J(t[1])) - 1, r = Math.max(0, J(t[2]));
534
+ return e.slice(n, n + r);
535
+ }
536
+ case "UPPER": return Y(t[0]).toUpperCase();
537
+ case "LOWER": return Y(t[0]).toLowerCase();
538
+ case "TRIM": return Y(t[0]).replace(/\s+/g, " ").trim();
539
+ case "EXACT": return Y(t[0]) === Y(t[1]);
540
+ case "FIND": {
541
+ let e = Y(t[0]), n = Y(t[1]), r = Math.max(1, J(t[2] ?? 1)) - 1, i = n.indexOf(e, r);
542
+ return i < 0 ? null : i + 1;
543
+ }
544
+ case "SEARCH": {
545
+ let e = Y(t[0]).toLowerCase(), n = Y(t[1]).toLowerCase(), r = Math.max(1, J(t[2] ?? 1)) - 1, i = n.indexOf(e, r);
546
+ return i < 0 ? null : i + 1;
547
+ }
548
+ case "CONCATENATE":
549
+ case "CONCAT": return t.flatMap(G).map((e) => e == null ? "" : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : String(e)).join("");
550
+ case "T": {
551
+ let e = K(t[0]);
552
+ return typeof e == "string" ? e : "";
553
+ }
554
+ case "N": {
555
+ let e = K(t[0]);
556
+ return typeof e == "number" ? e : typeof e == "boolean" ? +!!e : 0;
557
+ }
558
+ case "VALUE": return J(t[0]);
559
+ case "ROW": return n.row;
560
+ case "COLUMN": return n.col;
561
+ case "TODAY": return Fe();
562
+ case "NOW": return Ie();
563
+ case "DATE": return Le(J(t[0]), J(t[1]), J(t[2]));
564
+ case "YEAR": return ze(J(t[0])).y;
565
+ case "MONTH": return ze(J(t[0])).m;
566
+ case "DAY": return ze(J(t[0])).d;
567
+ case "WEEKDAY": {
568
+ let e = Re(J(t[0])).getUTCDay(), n = J(t[1] ?? 1);
569
+ return n === 2 ? e === 0 ? 7 : e : n === 3 ? e === 0 ? 6 : e - 1 : e + 1;
570
+ }
571
+ default: return 0;
572
+ }
573
+ }
574
+ function Ae(e, t) {
575
+ let n = Me(t), r = 0;
576
+ for (let t of e) n(t) && r++;
577
+ return r;
578
+ }
579
+ function je(e, t, n) {
580
+ let r = Me(t), i = n ?? e, a = 0;
581
+ for (let t = 0; t < e.length; t++) if (r(e[t])) {
582
+ let e = i[t];
583
+ typeof e == "number" && (a += e);
584
+ }
585
+ return a;
586
+ }
587
+ function Me(e) {
588
+ let t = K(e);
589
+ if (typeof t != "string") {
590
+ let e = typeof t == "number" ? t : null;
591
+ return (n) => e !== null && typeof n == "number" ? n === e : n === t;
592
+ }
593
+ let n = t.match(/^(<=|>=|<>|<|>|=)(.*)$/), r = n ? n[1] : "=", i = n ? n[2] : t, a = i.trim() === "" ? NaN : parseFloat(i), o = !isNaN(a) && /^-?\d+(\.\d+)?$/.test(i.trim());
594
+ return (e) => {
595
+ if (o && typeof e == "number") switch (r) {
596
+ case "<": return e < a;
597
+ case ">": return e > a;
598
+ case "<=": return e <= a;
599
+ case ">=": return e >= a;
600
+ case "<>": return e !== a;
601
+ default: return e === a;
602
+ }
603
+ let t = e == null ? "" : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : String(e);
604
+ switch (r) {
605
+ case "<>": return t !== i;
606
+ case "<": return t < i;
607
+ case ">": return t > i;
608
+ case "<=": return t <= i;
609
+ case ">=": return t >= i;
610
+ default: return t === i;
611
+ }
612
+ };
613
+ }
614
+ var Ne = 25569, Pe = 864e5;
615
+ function Fe() {
616
+ let e = /* @__PURE__ */ new Date(), t = Date.UTC(e.getFullYear(), e.getMonth(), e.getDate());
617
+ return Math.floor(t / Pe) + Ne;
618
+ }
619
+ function Ie() {
620
+ return Date.now() / Pe + Ne;
621
+ }
622
+ function Le(e, t, n) {
623
+ let r = Date.UTC(e, t - 1, n);
624
+ return Math.floor(r / Pe) + Ne;
625
+ }
626
+ function Re(e) {
627
+ let t = (Math.floor(e) - Ne) * Pe;
628
+ return new Date(t);
629
+ }
630
+ function ze(e) {
631
+ let t = Re(e);
632
+ return {
633
+ y: t.getUTCFullYear(),
634
+ m: t.getUTCMonth() + 1,
635
+ d: t.getUTCDate()
636
+ };
637
+ }
638
+ //#endregion
639
+ //#region packages/xlsx/src/number-format.ts
640
+ function Be(e) {
641
+ switch (e.type) {
642
+ case "empty": return "";
643
+ case "text": return e.text;
644
+ case "number": return String(e.number);
645
+ case "bool": return e.bool ? "TRUE" : "FALSE";
646
+ case "error": return e.error;
647
+ }
648
+ }
649
+ function Ve(e, t, n) {
650
+ let r = t.cellXfs[e.styleIndex ?? 0]?.numFmtId ?? 0, i = t.numFmts?.find((e) => e.numFmtId === r)?.formatCode ?? null, a = n?.numFmtId ?? r, o = n?.formatCode ?? i;
651
+ if (e.value.type !== "number") {
652
+ let t = Be(e.value);
653
+ return o ? He(t, o) : t;
654
+ }
655
+ return et(Ue(e.formula) ?? e.value.number, a, o);
656
+ }
657
+ function He(e, t) {
658
+ let n = t.split(";");
659
+ if (n.length < 4) return e;
660
+ let r = n[3];
661
+ if (r === "") return "";
662
+ let i = "", a = 0;
663
+ for (; a < r.length;) {
664
+ let t = r[a];
665
+ if (t === "\"") {
666
+ for (a++; a < r.length && r[a] !== "\"";) i += r[a++];
667
+ a < r.length && a++;
668
+ } else if (t === "\\") a + 1 < r.length && (i += r[a + 1]), a += 2;
669
+ else if (t === "[") {
670
+ for (; a < r.length && r[a] !== "]";) a++;
671
+ a < r.length && a++;
672
+ } else t === "@" ? (i += e, a++) : t === "_" || t === "*" ? a += 2 : (i += t, a++);
673
+ }
674
+ return i;
675
+ }
676
+ function Ue(e) {
677
+ if (!e) return null;
678
+ let t = e.trim().replace(/^=/, "").toUpperCase().replace(/\s+/g, "");
679
+ return t === "TODAY()" ? Fe() : t === "NOW()" ? Ie() : null;
680
+ }
681
+ var We = {
682
+ 14: "m/d/yyyy",
683
+ 15: "d-mmm-yy",
684
+ 16: "d-mmm",
685
+ 17: "mmm-yy",
686
+ 18: "h:mm AM/PM",
687
+ 19: "h:mm:ss AM/PM",
688
+ 20: "h:mm",
689
+ 21: "h:mm:ss",
690
+ 22: "m/d/yyyy h:mm",
691
+ 27: "[$-411]ge.m.d",
692
+ 28: "[$-411]ggge\"年\"m\"月\"d\"日\"",
693
+ 29: "[$-411]ggge\"年\"m\"月\"d\"日\"",
694
+ 30: "m/d/yy",
695
+ 31: "yyyy\"年\"m\"月\"d\"日\"",
696
+ 50: "[$-411]ge.m.d",
697
+ 51: "[$-411]ggge\"年\"m\"月\"d\"日\"",
698
+ 52: "yyyy\"年\"m\"月\"",
699
+ 53: "m\"月\"d\"日\"",
700
+ 54: "[$-411]ggge\"年\"m\"月\"d\"日\"",
701
+ 55: "yyyy\"年\"m\"月\"",
702
+ 56: "m\"月\"d\"日\"",
703
+ 57: "[$-411]ge.m.d",
704
+ 58: "[$-411]ggge\"年\"m\"月\"d\"日\""
705
+ }, Ge = [
706
+ "January",
707
+ "February",
708
+ "March",
709
+ "April",
710
+ "May",
711
+ "June",
712
+ "July",
713
+ "August",
714
+ "September",
715
+ "October",
716
+ "November",
717
+ "December"
718
+ ], Ke = [
719
+ "Sunday",
720
+ "Monday",
721
+ "Tuesday",
722
+ "Wednesday",
723
+ "Thursday",
724
+ "Friday",
725
+ "Saturday"
726
+ ], qe = [
727
+ "日",
728
+ "月",
729
+ "火",
730
+ "水",
731
+ "木",
732
+ "金",
733
+ "土"
734
+ ], Je = [
735
+ "日曜日",
736
+ "月曜日",
737
+ "火曜日",
738
+ "水曜日",
739
+ "木曜日",
740
+ "金曜日",
741
+ "土曜日"
742
+ ], Ye = [
743
+ {
744
+ start: new Date(Date.UTC(2019, 4, 1)),
745
+ abbr: "R",
746
+ short: "令",
747
+ long: "令和"
748
+ },
749
+ {
750
+ start: new Date(Date.UTC(1989, 0, 8)),
751
+ abbr: "H",
752
+ short: "平",
753
+ long: "平成"
754
+ },
755
+ {
756
+ start: new Date(Date.UTC(1926, 11, 25)),
757
+ abbr: "S",
758
+ short: "昭",
759
+ long: "昭和"
760
+ },
761
+ {
762
+ start: new Date(Date.UTC(1912, 6, 30)),
763
+ abbr: "T",
764
+ short: "大",
765
+ long: "大正"
766
+ },
767
+ {
768
+ start: new Date(Date.UTC(1868, 0, 25)),
769
+ abbr: "M",
770
+ short: "明",
771
+ long: "明治"
772
+ }
773
+ ];
774
+ function Xe(e) {
775
+ for (let t of Ye) if (e.getTime() >= t.start.getTime()) return {
776
+ abbr: t.abbr,
777
+ short: t.short,
778
+ long: t.long,
779
+ year: e.getUTCFullYear() - t.start.getUTCFullYear() + 1
780
+ };
781
+ let t = Ye[Ye.length - 1];
782
+ return {
783
+ abbr: t.abbr,
784
+ short: t.short,
785
+ long: t.long,
786
+ year: e.getUTCFullYear()
787
+ };
788
+ }
789
+ function Ze(e) {
790
+ return /* @__PURE__ */ new Date((e - 25569) * 86400 * 1e3);
791
+ }
792
+ function Qe(e, t) {
793
+ let n = Ze(e), r = n.getUTCFullYear(), i = n.getUTCMonth() + 1, a = n.getUTCDate(), o = n.getUTCDay(), s = n.getUTCHours(), c = n.getUTCMinutes(), l = n.getUTCSeconds(), u = t.split(";")[0], d = /am\/pm|a\/p/i.test(u), f = null, p = () => f ??= Xe(n), m = "", h = 0, g = !1;
794
+ for (; h < u.length;) {
795
+ let t = u[h];
796
+ if (t === "\"") {
797
+ for (h++; h < u.length && u[h] !== "\"";) m += u[h++];
798
+ h < u.length && h++, g = !1;
799
+ } else if (t === "[") {
800
+ let t = u.indexOf("]", h), n = t > h ? u.slice(h + 1, t) : "", r = n.match(/^([hms])\1*$/i);
801
+ if (r) {
802
+ let i = r[1].toLowerCase(), a = e < 0 ? "-" : "", o = Math.floor(Math.abs(e) * 86400), s;
803
+ s = i === "h" ? Math.floor(o / 3600) : i === "m" ? Math.floor(o / 60) : o;
804
+ let c = n.length >= 2 ? String(s).padStart(n.length, "0") : String(s);
805
+ m += a + c, h = t + 1, g = i === "h";
806
+ } else {
807
+ for (; h < u.length && u[h] !== "]";) h++;
808
+ h < u.length && h++;
809
+ }
810
+ } else if (t === "_") h += 2;
811
+ else if (t === "*") h += 2;
812
+ else if (t === "\\") h + 1 < u.length && (m += u[h + 1]), h += 2, g = !1;
813
+ else if (t === "y" || t === "Y") {
814
+ let e = 0;
815
+ for (; h < u.length && u[h].toLowerCase() === "y";) e++, h++;
816
+ m += e <= 2 ? String(r).slice(-2) : String(r).padStart(4, "0"), g = !1;
817
+ } else if (t === "m" || t === "M") {
818
+ let e = 0;
819
+ for (; h < u.length && u[h].toLowerCase() === "m";) e++, h++;
820
+ let t = u.slice(h).replace(/\[[^\]]*\]/g, "");
821
+ g || /^:s/i.test(t) ? m += e >= 2 ? String(c).padStart(2, "0") : String(c) : e === 1 ? m += String(i) : e === 2 ? m += String(i).padStart(2, "0") : e === 3 ? m += Ge[i - 1].slice(0, 3) : e === 4 ? m += Ge[i - 1] : m += Ge[i - 1][0], g = !1;
822
+ } else if (t === "d" || t === "D") {
823
+ let e = 0;
824
+ for (; h < u.length && u[h].toLowerCase() === "d";) e++, h++;
825
+ e === 1 ? m += String(a) : e === 2 ? m += String(a).padStart(2, "0") : e === 3 ? m += Ke[o].slice(0, 3) : m += Ke[o], g = !1;
826
+ } else if (t === "h" || t === "H") {
827
+ let e = 0;
828
+ for (; h < u.length && u[h].toLowerCase() === "h";) e++, h++;
829
+ let t = d ? s % 12 || 12 : s;
830
+ m += e >= 2 ? String(t).padStart(2, "0") : String(t), g = !0;
831
+ } else if (t === "s" || t === "S") {
832
+ let e = 0;
833
+ for (; h < u.length && u[h].toLowerCase() === "s";) e++, h++;
834
+ m += e >= 2 ? String(l).padStart(2, "0") : String(l), g = !1;
835
+ } else if (t === "g" || t === "G") {
836
+ let e = 0;
837
+ for (; h < u.length && u[h].toLowerCase() === "g";) e++, h++;
838
+ let t = p();
839
+ e === 1 ? m += t.abbr : e === 2 ? m += t.short : m += t.long, g = !1;
840
+ } else if (t === "e" || t === "E") {
841
+ let e = 0;
842
+ for (; h < u.length && u[h].toLowerCase() === "e";) e++, h++;
843
+ let t = p().year;
844
+ m += e >= 2 ? String(t).padStart(2, "0") : String(t), g = !1;
845
+ } else if (t === "r" || t === "R") {
846
+ let e = 0;
847
+ for (; h < u.length && u[h].toLowerCase() === "r";) e++, h++;
848
+ let t = p().year;
849
+ m += e >= 2 ? String(t).padStart(2, "0") : String(t), g = !1;
850
+ } else if (t === "A" || t === "a") {
851
+ let e = u.slice(h).toUpperCase();
852
+ e.startsWith("AAAA") ? (m += Je[o], h += 4) : e.startsWith("AAA") ? (m += qe[o], h += 3) : e.startsWith("AM/PM") ? (m += s < 12 ? "AM" : "PM", h += 5) : e.startsWith("A/P") ? (m += s < 12 ? "A" : "P", h += 3) : (m += t, h++), g = !1;
853
+ } else m += t, h++, t !== ":" && t !== "/" && t !== "-" && t !== "." && t !== " " && (g = !1);
854
+ }
855
+ return m;
856
+ }
857
+ function $e(e) {
858
+ if (/\[[hms]+\]/i.test(e)) return !0;
859
+ let t = e.replace(/"[^"]*"/g, "").replace(/\[[^\]]*\]/g, "");
860
+ return /[yd]/i.test(t) || /a{3,}/i.test(t);
861
+ }
862
+ function et(e, t, n) {
863
+ let r = We[t];
864
+ if (r) return Qe(e, r);
865
+ if (n && n.trim().toLowerCase() === "general") return String(e);
866
+ if (n) return $e(n) ? Qe(e, n) : at(e, n);
867
+ switch (t) {
868
+ case 0: return String(e);
869
+ case 1: return Math.round(e).toString();
870
+ case 2: return e.toFixed(2);
871
+ case 3: return tt(e, 0);
872
+ case 4: return tt(e, 2);
873
+ case 9: return Math.round(e * 100) + "%";
874
+ case 10: return (e * 100).toFixed(2) + "%";
875
+ case 11: return e.toExponential(2);
876
+ case 37:
877
+ case 38: return tt(e, 0);
878
+ case 39:
879
+ case 40: return tt(e, 2);
880
+ case 49: return String(e);
881
+ default: return String(e);
882
+ }
883
+ }
884
+ function tt(e, t) {
885
+ return e.toLocaleString("en-US", {
886
+ minimumFractionDigits: t,
887
+ maximumFractionDigits: t
888
+ });
889
+ }
890
+ function nt(e) {
891
+ let t = e.match(/\.([0#]+)/);
892
+ return t ? t[1].length : 0;
893
+ }
894
+ function rt(e) {
895
+ let t = [], n = "", r = !1, i = !1, a = (e) => {
896
+ if (!e) return;
897
+ let n = t[t.length - 1];
898
+ n && n.kind === "lit" ? n.text += e : t.push({
899
+ kind: "lit",
900
+ text: e
901
+ });
902
+ }, o = () => {
903
+ r ||= (t.push({ kind: "num" }), !0);
904
+ }, s = 0;
905
+ for (; s < e.length;) {
906
+ let r = e[s];
907
+ if (r === "\"") {
908
+ s++;
909
+ let t = "";
910
+ for (; s < e.length && e[s] !== "\"";) t += e[s++];
911
+ s < e.length && s++, a(t);
912
+ } else if (r === "\\") s + 1 < e.length && a(e[s + 1]), s += 2;
913
+ else if (r === "[") {
914
+ for (; s < e.length && e[s] !== "]";) s++;
915
+ s < e.length && s++;
916
+ } else if (r === "_") s += 2;
917
+ else if (r === "*") s += 2;
918
+ else if (r === "#" || r === "0" || r === "?" || r === "." || r === ",") o(), n += r, s++;
919
+ else if (r === "%") t.push({ kind: "percent" }), s++;
920
+ else if ((r === "E" || r === "e") && (e[s + 1] === "+" || e[s + 1] === "-")) for (i ||= (t.push({
921
+ kind: "sci",
922
+ expSign: e[s + 1] === "+"
923
+ }), !0), s += 2; s < e.length && e[s] === "0";) s++;
924
+ else a(r), s++;
925
+ }
926
+ return {
927
+ tokens: t,
928
+ numSpec: n
929
+ };
930
+ }
931
+ function it(e, t) {
932
+ let n = t.includes(",") && /[#0]/.test(t), r = nt(t);
933
+ return n ? tt(e, r) : t.includes(".") ? e.toFixed(r) : /[#0?]/.test(t) ? Math.round(e).toString() : String(e);
934
+ }
935
+ function at(e, t) {
936
+ let n = t.split(";"), r, i = !1;
937
+ e > 0 ? r = n[0] : e < 0 ? n.length > 1 ? (r = n[1], i = !0) : r = n[0] : r = n.length > 2 ? n[2] : n[0];
938
+ let { tokens: a, numSpec: o } = rt(r), s = a.some((e) => e.kind === "percent"), c = a.find((e) => e.kind === "sci"), l = i ? Math.abs(e) : e;
939
+ s && (l *= 100);
940
+ let u, d = "";
941
+ if (c) {
942
+ let e = nt(o), [t, n] = l.toExponential(e).split("e");
943
+ u = t;
944
+ let r = parseInt(n, 10);
945
+ d = (r < 0 ? "-" : c.expSign ? "+" : "") + String(Math.abs(r)).padStart(2, "0");
946
+ } else u = it(l, o);
947
+ let f = "", p = !1;
948
+ for (let e of a) e.kind === "lit" ? f += e.text : e.kind === "percent" ? f += "%" : e.kind === "num" ? (f += u, p = !0) : e.kind === "sci" && (f += "E" + d);
949
+ return !p && (o.length > 0 || c) && (f += u), f;
950
+ }
951
+ //#endregion
952
+ //#region packages/xlsx/src/conditional-format.ts
953
+ function ot(e, t, n) {
954
+ for (let r of e) if (t >= r.top && t <= r.bottom && n >= r.left && n <= r.right) return !0;
955
+ return !1;
956
+ }
957
+ function st(e) {
958
+ return e && e.value.type === "number" ? e.value.number : null;
959
+ }
960
+ function ct(e) {
961
+ return e && e.value.type === "text" ? e.value.text : null;
962
+ }
963
+ function lt(e, t) {
964
+ let n = [];
965
+ for (let r of e.rows) for (let e of r.cells) e.value.type === "number" && ot(t, e.row, e.col) && n.push(e.value.number);
966
+ return n;
967
+ }
968
+ function ut(e, t) {
969
+ let n = t.length ? Math.min(...t) : 0, r = t.length ? Math.max(...t) : 0, i = e.value == null ? NaN : parseFloat(e.value);
970
+ switch (e.kind) {
971
+ case "min": return n;
972
+ case "max": return r;
973
+ case "num": return isNaN(i) ? 0 : i;
974
+ case "percent": {
975
+ let e = isNaN(i) ? 50 : i;
976
+ return n + (r - n) * (e / 100);
977
+ }
978
+ case "percentile": {
979
+ if (!t.length) return 0;
980
+ let e = [...t].sort((e, t) => e - t), n = (isNaN(i) ? 50 : i) / 100;
981
+ return e[Math.max(0, Math.min(e.length - 1, Math.round(n * (e.length - 1))))];
982
+ }
983
+ default: return isNaN(i) ? 0 : i;
984
+ }
985
+ }
986
+ function dt(e) {
987
+ let t = [], n = /* @__PURE__ */ new Map();
988
+ for (let t of e.rows) for (let e of t.cells) n.set(`${e.row}:${e.col}`, e);
989
+ let r = /* @__PURE__ */ new Map();
990
+ for (let t of e.definedNames ?? []) r.set(t.name, t);
991
+ for (let n of e.conditionalFormats ?? []) {
992
+ let r = lt(e, n.sqref);
993
+ for (let e of n.rules) {
994
+ let i = {
995
+ rule: e,
996
+ sqref: n.sqref
997
+ };
998
+ if (e.type === "colorScale") i.scaleStops = e.stops.map((e) => ut(e, r));
999
+ else if (e.type === "dataBar") i.barMin = ut(e.min, r), i.barMax = ut(e.max, r);
1000
+ else if (e.type === "top10") {
1001
+ let t = [...r].sort((e, t) => e - t), n = t.length;
1002
+ if (n > 0) {
1003
+ let r = Math.min(e.rank, n);
1004
+ if (e.percent) {
1005
+ let a = e.top ? 1 - r / 100 : r / 100;
1006
+ i.top10Threshold = t[Math.max(0, Math.min(n - 1, Math.round(a * (n - 1))))];
1007
+ } else i.top10Threshold = e.top ? t[Math.max(0, n - r)] : t[Math.min(n - 1, r - 1)];
1008
+ i.top10IsTop = e.top;
1009
+ }
1010
+ } else if (e.type === "aboveAverage") {
1011
+ if (r.length > 0) {
1012
+ let t = r.reduce((e, t) => e + t, 0) / r.length;
1013
+ if (i.avgValue = t, i.avgIsAbove = e.aboveAverage, e.stdDev && e.stdDev > 0) {
1014
+ let e = r.reduce((e, n) => e + (n - t) * (n - t), 0) / r.length;
1015
+ i.avgStdDev = Math.sqrt(e);
1016
+ }
1017
+ }
1018
+ } else e.type === "iconSet" && (i.iconThresholds = e.cfvos.map((e) => ut(e, r)));
1019
+ t.push(i);
1020
+ }
1021
+ }
1022
+ return t.sort((e, t) => (e.rule.priority ?? 0) - (t.rule.priority ?? 0)), {
1023
+ compiled: t,
1024
+ worksheet: e,
1025
+ cellIndex: n,
1026
+ definedNames: r
1027
+ };
1028
+ }
1029
+ function ft(e, t, n) {
1030
+ switch (t) {
1031
+ case "greaterThan": return e > (n[0] ?? 0);
1032
+ case "greaterThanOrEqual": return e >= (n[0] ?? 0);
1033
+ case "lessThan": return e < (n[0] ?? 0);
1034
+ case "lessThanOrEqual": return e <= (n[0] ?? 0);
1035
+ case "equal": return e === (n[0] ?? 0);
1036
+ case "notEqual": return e !== (n[0] ?? 0);
1037
+ case "between": return e >= (n[0] ?? 0) && e <= (n[1] ?? 0);
1038
+ case "notBetween": return e < (n[0] ?? 0) || e > (n[1] ?? 0);
1039
+ default: return !1;
1040
+ }
1041
+ }
1042
+ function pt(e) {
1043
+ let t = e.trim();
1044
+ if (t.length >= 2 && t.startsWith("\"") && t.endsWith("\"")) return { text: t.slice(1, -1).replace(/""/g, "\"") };
1045
+ let n = parseFloat(t);
1046
+ return isNaN(n) ? { text: t } : { num: n };
1047
+ }
1048
+ function mt(e, t, n) {
1049
+ let r = n[0] ?? "", i = n[1] ?? "", a = (e) => e.toLowerCase();
1050
+ switch (t) {
1051
+ case "equal": return a(e) === a(r);
1052
+ case "notEqual": return a(e) !== a(r);
1053
+ case "containsText": return a(e).includes(a(r));
1054
+ case "notContains": return !a(e).includes(a(r));
1055
+ case "beginsWith": return a(e).startsWith(a(r));
1056
+ case "endsWith": return a(e).endsWith(a(r));
1057
+ case "between": return a(e) >= a(r) && a(e) <= a(i);
1058
+ case "notBetween": return a(e) < a(r) || a(e) > a(i);
1059
+ default: return !1;
1060
+ }
1061
+ }
1062
+ function ht(e, t, n) {
1063
+ let r = e.replace("#", ""), i = t.replace("#", ""), a = parseInt(r.slice(0, 2), 16), o = parseInt(r.slice(2, 4), 16), s = parseInt(r.slice(4, 6), 16), c = parseInt(i.slice(0, 2), 16), l = parseInt(i.slice(2, 4), 16), u = parseInt(i.slice(4, 6), 16), d = Math.round(a + (c - a) * n), f = Math.round(o + (l - o) * n), p = Math.round(s + (u - s) * n);
1064
+ return `#${d.toString(16).padStart(2, "0").toUpperCase()}${f.toString(16).padStart(2, "0").toUpperCase()}${p.toString(16).padStart(2, "0").toUpperCase()}`;
1065
+ }
1066
+ function gt(e, t, n) {
1067
+ if (!t.length) return "#FFFFFF";
1068
+ if (e <= n[0]) return t[0].color;
1069
+ if (e >= n[n.length - 1]) return t[t.length - 1].color;
1070
+ for (let r = 1; r < n.length; r++) if (e <= n[r]) {
1071
+ let i = n[r - 1], a = n[r], o = a === i ? 0 : (e - i) / (a - i);
1072
+ return ht(t[r - 1].color, t[r].color, o);
1073
+ }
1074
+ return t[t.length - 1].color;
1075
+ }
1076
+ function _t(e, t) {
1077
+ if (t && (t.fill && !e.fill && (e.fill = t.fill), t.font?.color && e.fontColor == null && (e.fontColor = t.font.color), t.font?.bold && e.fontBold == null && (e.fontBold = !0), t.font?.italic && e.fontItalic == null && (e.fontItalic = !0), t.font?.underline && e.fontUnderline == null && (e.fontUnderline = !0), t.font?.strike && e.fontStrike == null && (e.fontStrike = !0), t.numFmt && e.numFmt == null && (e.numFmt = {
1078
+ numFmtId: t.numFmt.numFmtId,
1079
+ formatCode: t.numFmt.formatCode || null
1080
+ }), t.border)) {
1081
+ let n = e.border ?? {};
1082
+ e.border = {
1083
+ left: n.left ?? t.border.left,
1084
+ right: n.right ?? t.border.right,
1085
+ top: n.top ?? t.border.top,
1086
+ bottom: n.bottom ?? t.border.bottom,
1087
+ diagonalUp: n.diagonalUp ?? t.border.diagonalUp,
1088
+ diagonalDown: n.diagonalDown ?? t.border.diagonalDown
1089
+ };
1090
+ }
1091
+ }
1092
+ function vt(e, t, n, r, i) {
1093
+ let a = {};
1094
+ if (!r.compiled.length) return a;
1095
+ for (let o of r.compiled) {
1096
+ if (!ot(o.sqref, t, n)) continue;
1097
+ let s = o.rule, c = st(e);
1098
+ if (s.type === "expression") {
1099
+ let e = o.sqref[0];
1100
+ if (!e) continue;
1101
+ if (q(s.formula, {
1102
+ row: t,
1103
+ col: n,
1104
+ anchorRow: e.top,
1105
+ anchorCol: e.left,
1106
+ cellIndex: r.cellIndex,
1107
+ definedNames: r.definedNames,
1108
+ depth: 0
1109
+ }) && (_t(a, s.dxfId == null ? null : i[s.dxfId]), s.stopIfTrue)) break;
1110
+ continue;
1111
+ }
1112
+ if (s.type === "cellIs") {
1113
+ let t = s.formulas.map(pt), n = ct(e), r = !1;
1114
+ c != null && t.every((e) => e.num != null) ? r = ft(c, s.operator, t.map((e) => e.num)) : n != null && t.every((e) => e.text != null) && (r = mt(n, s.operator, t.map((e) => e.text))), r && _t(a, s.dxfId == null ? null : i[s.dxfId]);
1115
+ } else if (s.type === "top10") {
1116
+ if (c == null || o.top10Threshold == null) continue;
1117
+ (o.top10IsTop ? c >= o.top10Threshold : c <= o.top10Threshold) && _t(a, s.dxfId == null ? null : i[s.dxfId]);
1118
+ } else if (s.type === "aboveAverage") {
1119
+ if (c == null || o.avgValue == null) continue;
1120
+ let e = o.avgStdDev == null ? 0 : o.avgStdDev * (s.stdDev ?? 1), t = o.avgIsAbove ? o.avgValue + e : o.avgValue - e, n = s.equalAverage === !0;
1121
+ (o.avgIsAbove ? n ? c >= t : c > t : n ? c <= t : c < t) && _t(a, s.dxfId == null ? null : i[s.dxfId]);
1122
+ } else if (s.type === "iconSet") {
1123
+ if (c == null || !o.iconThresholds?.length) continue;
1124
+ let e = o.iconThresholds, t = e.length, n = 0;
1125
+ for (let r = 1; r < t; r++) c >= e[r] && (n = r);
1126
+ if (s.reverse && (n = t - 1 - n), s.customIcons && s.customIcons[n]) {
1127
+ let e = s.customIcons[n];
1128
+ e.iconSet !== "NoIcons" && (a.iconSet = {
1129
+ name: e.iconSet,
1130
+ index: e.iconId
1131
+ });
1132
+ } else a.iconSet = {
1133
+ name: s.iconSet,
1134
+ index: n
1135
+ };
1136
+ } else if (s.type === "colorScale") {
1137
+ if (c == null || !o.scaleStops || a.fill) continue;
1138
+ let e = gt(c, s.stops, o.scaleStops);
1139
+ a.fill = {
1140
+ patternType: "solid",
1141
+ fgColor: e,
1142
+ bgColor: e
1143
+ };
1144
+ } else if (s.type === "dataBar") {
1145
+ if (c == null || o.barMin == null || o.barMax == null || a.dataBar) continue;
1146
+ let e = o.barMax - o.barMin, t = e === 0 ? 0 : Math.max(0, Math.min(1, (c - o.barMin) / e));
1147
+ a.dataBar = {
1148
+ color: s.color,
1149
+ ratio: t,
1150
+ gradient: s.gradient
1151
+ };
1152
+ }
1153
+ }
1154
+ return a;
1155
+ }
1156
+ //#endregion
1157
+ //#region packages/xlsx/src/bidi-line.ts
1158
+ function yt(e, t) {
1159
+ return e === 2 ? !0 : e === 1 ? !1 : H(void 0, t) === "rtl";
1160
+ }
1161
+ var bt = (e) => {
1162
+ let t = e.text;
1163
+ return typeof t == "string" ? t : void 0;
1164
+ };
1165
+ function xt(e, t) {
1166
+ let n = e === 2 || S(t);
1167
+ return {
1168
+ needBidi: n,
1169
+ baseRtl: n && yt(e, t)
1170
+ };
1171
+ }
1172
+ function St(e, t) {
1173
+ let n = e.length;
1174
+ if (n === 0) return {
1175
+ order: [],
1176
+ rtl: []
1177
+ };
1178
+ let r = "", i = Array(n);
1179
+ for (let t = 0; t < n; t++) {
1180
+ i[t] = r.length;
1181
+ let n = bt(e[t]) ?? "";
1182
+ r += n.length > 0 ? n : "";
1183
+ }
1184
+ let { levels: a, paragraphLevel: o } = C().computeLevels(r, t ? "rtl" : "ltr"), { order: s, segLevels: c } = N(a, o, i), l = Array(n);
1185
+ for (let e = 0; e < n; e++) l[e] = (c[e] & 1) == 1;
1186
+ return {
1187
+ order: s,
1188
+ rtl: l
1189
+ };
1190
+ }
1191
+ //#endregion
1192
+ //#region packages/xlsx/src/a1.ts
1193
+ function Ct(e) {
1194
+ let t = /^\$?([A-Z]+)\$?(\d+)$/.exec(e.trim());
1195
+ if (!t) return null;
1196
+ let n = t[1], r = 0;
1197
+ for (let e = 0; e < n.length; e++) r = r * 26 + (n.charCodeAt(e) - 64);
1198
+ return {
1199
+ row: parseInt(t[2], 10),
1200
+ col: r
1201
+ };
1202
+ }
1203
+ //#endregion
1204
+ //#region packages/xlsx/src/renderer.ts
1205
+ var wt = p.map((e) => `"${e}"`).join(", "), Tt = r.map((e) => `"${e}"`).join(", "), Et = `"Calibri", "Carlito", "Cambria", "Caladea", Arial, "Noto Naskh Arabic", "Noto Sans Arabic", ${wt}, sans-serif`, Dt = `"Cambria", "Caladea", "Times New Roman", "Liberation Serif", "Noto Naskh Arabic", "Noto Sans Arabic", ${Tt}, serif`, Ot = "\"Courier New\", \"Liberation Mono\", monospace";
1206
+ function kt(e) {
1207
+ let t = e ? n(e) : null, r = o(e);
1208
+ if (!t) return r === "serif" ? Dt : r === "mono" ? Ot : Et;
1209
+ let i = r === "serif";
1210
+ return `${m(t, i ? "serif" : "sans").map((e) => `"${e}"`).join(", ")}, "Calibri", "Carlito", "Cambria", "Caladea", Arial, "Noto Naskh Arabic", "Noto Sans Arabic", ${i ? Tt : wt}, ${i ? "serif" : "sans-serif"}`;
1211
+ }
1212
+ function At(e) {
1213
+ return e ? `"${e}", ${kt(e)}` : Et;
1214
+ }
1215
+ var jt = 11, Mt = 8;
1216
+ function Nt(e, t, n) {
1217
+ return n - e - t;
1218
+ }
1219
+ var Pt = "#7a7a7a", Ft = /* @__PURE__ */ new Map(), It = {
1220
+ "meiryo ui": {
1221
+ 10: 8,
1222
+ 11: 8
1223
+ },
1224
+ meiryo: {
1225
+ 10: 8,
1226
+ 11: 8
1227
+ }
1228
+ };
1229
+ function Lt(t, n) {
1230
+ let r = `${t}:${n}`, i = Ft.get(r);
1231
+ if (i !== void 0) return i;
1232
+ let a = It[t.toLowerCase()]?.[Math.round(n)];
1233
+ if (a !== void 0) return Ft.set(r, a), a;
1234
+ let o = n * e, s = typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1) : typeof document < "u" ? document.createElement("canvas") : null;
1235
+ if (!s) return Mt;
1236
+ let c = s.getContext("2d");
1237
+ if (!c) return Mt;
1238
+ c.font = `${o}px ${At(t)}`;
1239
+ let l = 0;
1240
+ for (let e of "0123456789") {
1241
+ let t = c.measureText(e).width;
1242
+ t > l && (l = t);
1243
+ }
1244
+ let u = Math.round(l) || Mt;
1245
+ return Ft.set(r, u), u;
1246
+ }
1247
+ function Z(e) {
1248
+ return !e.defaultFontFamily || !e.defaultFontSize ? Mt : Lt(e.defaultFontFamily, e.defaultFontSize);
1249
+ }
1250
+ function Q(e, t = Mt) {
1251
+ return Math.trunc((256 * e + Math.trunc(128 / t)) / 256 * t);
1252
+ }
1253
+ function Rt(e, t = Mt) {
1254
+ return e / t;
1255
+ }
1256
+ function $(t) {
1257
+ return Math.round(t * e);
1258
+ }
1259
+ function zt(t) {
1260
+ return t / e;
1261
+ }
1262
+ function Bt(e, t, n, r, i, a, o) {
1263
+ if (!(i <= 0 || a <= 0)) {
1264
+ if (o) {
1265
+ let a = e.createLinearGradient(n, r, n + i, r);
1266
+ a.addColorStop(0, c(t, .85)), a.addColorStop(1, c(t, .15)), e.fillStyle = a;
1267
+ } else e.fillStyle = c(t);
1268
+ e.fillRect(n, r, i, a);
1269
+ }
1270
+ }
1271
+ function Vt(e) {
1272
+ switch (e) {
1273
+ case "solid": return 1;
1274
+ case "darkGray": return .75;
1275
+ case "mediumGray": return .5;
1276
+ case "lightGray": return .25;
1277
+ case "gray125": return .125;
1278
+ case "gray0625": return .0625;
1279
+ case "darkHorizontal":
1280
+ case "darkVertical":
1281
+ case "darkDown":
1282
+ case "darkUp":
1283
+ case "darkGrid":
1284
+ case "darkTrellis": return .5;
1285
+ case "lightHorizontal":
1286
+ case "lightVertical":
1287
+ case "lightDown":
1288
+ case "lightUp":
1289
+ case "lightGrid":
1290
+ case "lightTrellis": return .25;
1291
+ default: return 1;
1292
+ }
1293
+ }
1294
+ var Ht = /* @__PURE__ */ new Map(), Ut = {
1295
+ gray0625: [
1296
+ 128,
1297
+ 0,
1298
+ 8,
1299
+ 0,
1300
+ 128,
1301
+ 0,
1302
+ 8,
1303
+ 0
1304
+ ],
1305
+ gray125: [
1306
+ 136,
1307
+ 0,
1308
+ 34,
1309
+ 0,
1310
+ 136,
1311
+ 0,
1312
+ 34,
1313
+ 0
1314
+ ],
1315
+ lightGray: [
1316
+ 170,
1317
+ 0,
1318
+ 85,
1319
+ 0,
1320
+ 170,
1321
+ 0,
1322
+ 85,
1323
+ 0
1324
+ ],
1325
+ mediumGray: [
1326
+ 170,
1327
+ 85,
1328
+ 170,
1329
+ 85,
1330
+ 170,
1331
+ 85,
1332
+ 170,
1333
+ 85
1334
+ ],
1335
+ darkGray: [
1336
+ 119,
1337
+ 221,
1338
+ 119,
1339
+ 221,
1340
+ 119,
1341
+ 221,
1342
+ 119,
1343
+ 221
1344
+ ],
1345
+ darkHorizontal: [
1346
+ 4095,
1347
+ 4095,
1348
+ 0,
1349
+ 4095,
1350
+ 4095,
1351
+ 0,
1352
+ 4095,
1353
+ 4095,
1354
+ 0,
1355
+ 4095,
1356
+ 4095,
1357
+ 0
1358
+ ],
1359
+ lightHorizontal: [
1360
+ 4095,
1361
+ 0,
1362
+ 0,
1363
+ 4095,
1364
+ 0,
1365
+ 0,
1366
+ 4095,
1367
+ 0,
1368
+ 0,
1369
+ 4095,
1370
+ 0,
1371
+ 0
1372
+ ],
1373
+ darkVertical: Array(12).fill(3510),
1374
+ lightVertical: Array(12).fill(2340),
1375
+ darkGrid: [
1376
+ 204,
1377
+ 204,
1378
+ 51,
1379
+ 51,
1380
+ 204,
1381
+ 204,
1382
+ 51,
1383
+ 51
1384
+ ],
1385
+ lightGrid: [
1386
+ 255,
1387
+ 136,
1388
+ 136,
1389
+ 136,
1390
+ 255,
1391
+ 136,
1392
+ 136,
1393
+ 136
1394
+ ],
1395
+ darkDown: [
1396
+ 204,
1397
+ 102,
1398
+ 51,
1399
+ 153,
1400
+ 204,
1401
+ 102,
1402
+ 51,
1403
+ 153
1404
+ ],
1405
+ lightDown: [
1406
+ 136,
1407
+ 68,
1408
+ 34,
1409
+ 17,
1410
+ 136,
1411
+ 68,
1412
+ 34,
1413
+ 17
1414
+ ],
1415
+ darkUp: [
1416
+ 51,
1417
+ 102,
1418
+ 204,
1419
+ 153,
1420
+ 51,
1421
+ 102,
1422
+ 204,
1423
+ 153
1424
+ ],
1425
+ lightUp: [
1426
+ 17,
1427
+ 34,
1428
+ 68,
1429
+ 136,
1430
+ 17,
1431
+ 34,
1432
+ 68,
1433
+ 136
1434
+ ],
1435
+ darkTrellis: [
1436
+ 255,
1437
+ 102,
1438
+ 255,
1439
+ 153,
1440
+ 255,
1441
+ 102,
1442
+ 255,
1443
+ 153
1444
+ ],
1445
+ lightTrellis: [
1446
+ 153,
1447
+ 102,
1448
+ 102,
1449
+ 153,
1450
+ 153,
1451
+ 102,
1452
+ 102,
1453
+ 153
1454
+ ]
1455
+ };
1456
+ function Wt(e, t, n, r) {
1457
+ let i = e.getTransform(), a = Math.max(1, Math.round(Math.hypot(i.a, i.b))), o = Math.max(1, Math.round(Math.hypot(i.c, i.d))), l = `${t}|${n}|${r}|${a}|${o}`;
1458
+ if (Ht.has(l)) return Ht.get(l);
1459
+ let u = Ut[t];
1460
+ if (!u) return Ht.set(l, null), null;
1461
+ let d = u.length, f = s(d, d);
1462
+ if (!f) return Ht.set(l, null), null;
1463
+ let p = f.getContext("2d");
1464
+ if (!p) return Ht.set(l, null), null;
1465
+ p.fillStyle = c(r), p.fillRect(0, 0, d, d), p.fillStyle = c(n);
1466
+ for (let e = 0; e < d; e++) {
1467
+ let t = u[e];
1468
+ for (let n = 0; n < d; n++) t & 1 << d - 1 - n && p.fillRect(n, e, 1, 1);
1469
+ }
1470
+ let m = e.createPattern(f, "repeat");
1471
+ if (m && typeof DOMMatrix < "u" && (a >= 2 || o >= 2)) {
1472
+ let e = new DOMMatrix();
1473
+ e.scaleSelf(1 / a, 1 / o), m.setTransform(e);
1474
+ }
1475
+ return Ht.set(l, m), m;
1476
+ }
1477
+ function Gt(e, t, n, r, i, a) {
1478
+ if (t.gradient && t.gradient.stops.length > 0) return e.fillStyle = Kt(e, t.gradient, n, r, i, a), e.fillRect(n, r, i, a), !0;
1479
+ let o = t.patternType;
1480
+ if (!o || o === "none") return !1;
1481
+ let s = t.fgColor ?? "000000", l = t.bgColor ?? "FFFFFF";
1482
+ if (o === "solid") return e.fillStyle = c(s), e.fillRect(n, r, i, a), !0;
1483
+ let u = Wt(e, o, s, l);
1484
+ if (u) e.fillStyle = u;
1485
+ else {
1486
+ let t = Vt(o);
1487
+ e.fillStyle = t >= 1 ? c(s) : Yt(s, l, t);
1488
+ }
1489
+ return e.fillRect(n, r, i, a), !0;
1490
+ }
1491
+ function Kt(e, t, n, r, i, a) {
1492
+ let o;
1493
+ if (t.gradientType === "path") {
1494
+ let s = n + i * (t.left + (1 - t.right - t.left) / 2), c = r + a * (t.top + (1 - t.bottom - t.top) / 2), l = Math.hypot(Math.max(s - n, n + i - s), Math.max(c - r, r + a - c));
1495
+ o = e.createRadialGradient(s, c, 0, s, c, l);
1496
+ } else {
1497
+ let s = t.degree * Math.PI / 180, c = n + i / 2, l = r + a / 2, u = (Math.abs(Math.cos(s)) * i + Math.abs(Math.sin(s)) * a) / 2;
1498
+ o = e.createLinearGradient(c - Math.cos(s) * u, l - Math.sin(s) * u, c + Math.cos(s) * u, l + Math.sin(s) * u);
1499
+ }
1500
+ for (let e of t.stops) {
1501
+ let t = Math.min(1, Math.max(0, e.position));
1502
+ o.addColorStop(t, c(e.color));
1503
+ }
1504
+ return o;
1505
+ }
1506
+ var qt = Ct;
1507
+ function Jt(e, t, n, r, i) {
1508
+ let a = Math.max(4, Math.min(8, Math.min(r, i) * .18));
1509
+ e.save(), e.fillStyle = "#D40000", e.beginPath(), e.moveTo(t + r - a, n), e.lineTo(t + r, n), e.lineTo(t + r, n + a), e.closePath(), e.fill(), e.restore();
1510
+ }
1511
+ function Yt(e, t, n) {
1512
+ let r = e.replace("#", ""), i = t.replace("#", ""), a = parseInt(r.slice(0, 2), 16), o = parseInt(r.slice(2, 4), 16), s = parseInt(r.slice(4, 6), 16), c = parseInt(i.slice(0, 2), 16), l = parseInt(i.slice(2, 4), 16), u = parseInt(i.slice(4, 6), 16), d = Math.min(1, Math.max(0, n));
1513
+ return `rgb(${Math.round(a * d + c * (1 - d))},${Math.round(o * d + l * (1 - d))},${Math.round(s * d + u * (1 - d))})`;
1514
+ }
1515
+ function Xt(t, n, r = 1, i) {
1516
+ let a = Math.round(t * e * r * n);
1517
+ return i ? Math.max(a, Math.round(k(i, t * e * n))) : a;
1518
+ }
1519
+ function Zt(t, n = 1) {
1520
+ return `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${Math.max(1, Math.round(t.size * e * n))}px ${At(t.name)}`;
1521
+ }
1522
+ function Qt(e, t, n, r, i, a, o = 1) {
1523
+ if (e.save(), e.strokeStyle = i, e.lineWidth = .5, e.beginPath(), a) {
1524
+ let i = r - 1, a = r + 1, s = i + O(i, .5, o), c = a + O(a, .5, o);
1525
+ e.moveTo(t, s), e.lineTo(n, s), e.moveTo(t, c), e.lineTo(n, c);
1526
+ } else {
1527
+ let i = r + O(r, .5, o);
1528
+ e.moveTo(t, i), e.lineTo(n, i);
1529
+ }
1530
+ e.stroke(), e.restore();
1531
+ }
1532
+ function $t(e, t) {
1533
+ let n = t.font;
1534
+ return n ? {
1535
+ bold: n.bold,
1536
+ italic: n.italic,
1537
+ underline: n.underline,
1538
+ underlineStyle: n.underlineStyle,
1539
+ strike: n.strike,
1540
+ size: n.size ?? e.size,
1541
+ color: n.color ?? e.color,
1542
+ name: n.name ?? e.name,
1543
+ vertAlign: n.vertAlign
1544
+ } : e;
1545
+ }
1546
+ function en(e, t) {
1547
+ let n = e.cellXfs[t] ?? e.cellXfs[0] ?? {
1548
+ fontId: 0,
1549
+ fillId: 0,
1550
+ borderId: 0,
1551
+ numFmtId: 0,
1552
+ alignH: null,
1553
+ alignV: null,
1554
+ wrapText: !1
1555
+ };
1556
+ return {
1557
+ font: e.fonts[n.fontId] ?? {
1558
+ bold: !1,
1559
+ italic: !1,
1560
+ underline: !1,
1561
+ strike: !1,
1562
+ size: jt,
1563
+ color: null,
1564
+ name: null
1565
+ },
1566
+ fill: e.fills[n.fillId] ?? {
1567
+ patternType: "none",
1568
+ fgColor: null,
1569
+ bgColor: null
1570
+ },
1571
+ border: e.borders[n.borderId] ?? {
1572
+ left: null,
1573
+ right: null,
1574
+ top: null,
1575
+ bottom: null
1576
+ },
1577
+ xf: n
1578
+ };
1579
+ }
1580
+ function tn(e, t, n) {
1581
+ let r = [];
1582
+ for (let i of t.split("\n")) r.push(...an(e, i, n));
1583
+ return r;
1584
+ }
1585
+ function nn(e, t) {
1586
+ if (e.length === 0 || t.length === 0) return 0;
1587
+ let n = [...e, ...t], r = e.length;
1588
+ return r - M(n, r, x, 1);
1589
+ }
1590
+ function rn(e, t) {
1591
+ let n = t;
1592
+ for (; n < e.length;) {
1593
+ let t = e[e.length - n - 1], r = e[e.length - n], i = t?.codePointAt(0), a = r?.codePointAt(0);
1594
+ if (i !== void 0 && a !== void 0 && y(i) && y(a)) n++;
1595
+ else break;
1596
+ }
1597
+ return n >= e.length ? t : n;
1598
+ }
1599
+ function an(e, t, n) {
1600
+ let r = [], i = [], a = 0;
1601
+ for (; a < t.length;) {
1602
+ let e = t[a], n = e.codePointAt(0) ?? 0;
1603
+ if (E(n)) i.push(e), a += n > 65535 ? 2 : 1;
1604
+ else if (e === " ") {
1605
+ let e = a;
1606
+ for (; e < t.length && t[e] === " ";) e++;
1607
+ i.push(t.slice(a, e)), a = e;
1608
+ } else {
1609
+ let e = a;
1610
+ for (; e < t.length;) {
1611
+ let n = t[e], r = n.codePointAt(0) ?? 0;
1612
+ if (n === " " || E(r)) break;
1613
+ e += r > 65535 ? 2 : 1;
1614
+ }
1615
+ i.push(t.slice(a, e)), a = e;
1616
+ }
1617
+ }
1618
+ let o = "";
1619
+ for (let t of i) {
1620
+ if (o === "") {
1621
+ o = t;
1622
+ continue;
1623
+ }
1624
+ let i = o + t;
1625
+ if (e.measureText(i).width <= n) o = i;
1626
+ else {
1627
+ let e = t.replace(/^ +/, "");
1628
+ e === "" && (e = t);
1629
+ let n = [...o], i = nn(n, [...e]);
1630
+ if (i > 0) {
1631
+ let t = n.length - i;
1632
+ r.push(n.slice(0, t).join("")), o = n.slice(t).join("") + e;
1633
+ } else r.push(o), o = e;
1634
+ }
1635
+ }
1636
+ return r.push(o), r;
1637
+ }
1638
+ function on(e, t, n, r, i) {
1639
+ let a = [], o = [], s = 0, c = 0, l = null, u = n.size, d = n.name, f = 0, p = () => {
1640
+ o.length !== 0 && (a.push({
1641
+ segments: o,
1642
+ maxFontSize: c,
1643
+ maxFontFamily: l,
1644
+ para: f
1645
+ }), o = [], s = 0, c = 0, l = null);
1646
+ }, m = () => {
1647
+ if (o.length === 0) {
1648
+ a.push({
1649
+ segments: [],
1650
+ maxFontSize: u || jt,
1651
+ maxFontFamily: d,
1652
+ para: f
1653
+ });
1654
+ return;
1655
+ }
1656
+ p();
1657
+ }, h = (t, n) => {
1658
+ if (!t) return;
1659
+ u = n.size, d = n.name, e.font = Zt(cn(n), r);
1660
+ let a = e.measureText(t).width;
1661
+ if (o.length > 0 && s + a > i) {
1662
+ let i = o.flatMap((e) => [...e.text]), a = nn(i, [...t]);
1663
+ a > 0 && (a = rn(i, a));
1664
+ let u = o[o.length - 1], d = [...u.text];
1665
+ a > d.length && (a = d.length);
1666
+ let f = null;
1667
+ if (a > 0) {
1668
+ let t = d.slice(0, d.length - a), n = d.slice(d.length - a);
1669
+ if (e.font = Zt(cn(u.font), r), t.length === 0) o.pop();
1670
+ else {
1671
+ let n = t.join("");
1672
+ u.text = n, u.width = e.measureText(n).width;
1673
+ }
1674
+ let i = n.join("");
1675
+ f = {
1676
+ text: i,
1677
+ font: u.font,
1678
+ width: e.measureText(i).width
1679
+ };
1680
+ }
1681
+ p(), f && (o.push(f), s += f.width, f.font.size > c && (c = f.font.size, l = f.font.name)), e.font = Zt(cn(n), r);
1682
+ }
1683
+ o.push({
1684
+ text: t,
1685
+ font: n,
1686
+ width: a
1687
+ }), s += a, n.size > c && (c = n.size, l = n.name);
1688
+ };
1689
+ for (let e of t) {
1690
+ let t = $t(n, e), r = [], i = 0;
1691
+ for (; i < e.text.length;) {
1692
+ let t = e.text[i], n = t.codePointAt(0) ?? 0;
1693
+ if (n === 10) r.push("\n"), i += 1;
1694
+ else if (E(n)) r.push(t), i += n > 65535 ? 2 : 1;
1695
+ else if (t === " ") {
1696
+ let t = i;
1697
+ for (; t < e.text.length && e.text[t] === " ";) t++;
1698
+ r.push(e.text.slice(i, t)), i = t;
1699
+ } else {
1700
+ let t = i;
1701
+ for (; t < e.text.length;) {
1702
+ let n = e.text[t], r = n.codePointAt(0) ?? 0;
1703
+ if (n === " " || n === "\n" || E(r)) break;
1704
+ t += r > 65535 ? 2 : 1;
1705
+ }
1706
+ r.push(e.text.slice(i, t)), i = t;
1707
+ }
1708
+ }
1709
+ for (let e of r) e === "\n" ? (m(), f++) : h(e, t);
1710
+ }
1711
+ return (o.length > 0 || a.length > 0) && m(), a;
1712
+ }
1713
+ function sn(e, t, n) {
1714
+ return e === "middle" ? {
1715
+ underline: t + Math.round(n * .55),
1716
+ strike: t
1717
+ } : e === "bottom" ? {
1718
+ underline: t + 1,
1719
+ strike: t - Math.round(n * .35)
1720
+ } : {
1721
+ underline: t + n + 1,
1722
+ strike: t + Math.round(n * .5)
1723
+ };
1724
+ }
1725
+ function cn(e) {
1726
+ return e.vertAlign === "superscript" || e.vertAlign === "subscript" ? {
1727
+ ...e,
1728
+ size: e.size * .65
1729
+ } : e;
1730
+ }
1731
+ function ln(e, t, n, r, i, a, o, s) {
1732
+ e.textAlign = "left", e.textBaseline = i;
1733
+ let l = s.needBidi ? St(t, s.baseRtl ?? !1) : null, u = e, d = n;
1734
+ for (let n = 0; n < t.length; n++) {
1735
+ let f = l ? l.order[n] : n;
1736
+ if (l) try {
1737
+ u.direction = l.rtl[f] ? "rtl" : "ltr";
1738
+ } catch {}
1739
+ let p = t[f], m = cn(p.font);
1740
+ e.font = Zt(m, a);
1741
+ let h = s.fontColor ?? p.font.color;
1742
+ e.fillStyle = h ? c(h) : "#000000";
1743
+ let g = Xt(p.font.size, a), _ = 0;
1744
+ p.font.vertAlign === "superscript" ? _ = -Math.round(g * .35) : p.font.vertAlign === "subscript" && (_ = Math.round(g * .1)), e.fillText(p.text, d, r + _);
1745
+ let v = Xt(m.size, a);
1746
+ if (p.font.underline || p.font.strike) {
1747
+ let t = sn(i, r, v);
1748
+ if (p.font.underline) {
1749
+ let n = h ? c(h) : "#000000", r = p.font.underlineStyle === "double" || p.font.underlineStyle === "doubleAccounting";
1750
+ Qt(e, d, d + p.width, t.underline + _, n, r, o);
1751
+ }
1752
+ if (p.font.strike) {
1753
+ let n = t.strike + _, r = n + O(n, .5, o);
1754
+ e.save(), e.strokeStyle = h ? c(h) : "#000000", e.lineWidth = .5, e.beginPath(), e.moveTo(d, r), e.lineTo(d + p.width, r), e.stroke(), e.restore();
1755
+ }
1756
+ }
1757
+ d += p.width;
1758
+ }
1759
+ if (l) try {
1760
+ u.direction = "ltr";
1761
+ } catch {}
1762
+ }
1763
+ function un(e, t, n, r, i, a, o, s, c) {
1764
+ let { alignH: l, cx: u, cellW: d, leftPad: f, paddingX: p } = r, m = t.map((t) => {
1765
+ let r = $t(n, t);
1766
+ return e.font = Zt(cn(r), i), {
1767
+ text: t.text,
1768
+ font: r,
1769
+ width: e.measureText(t.text).width
1770
+ };
1771
+ }), h = m.reduce((e, t) => e + t.width, 0), g;
1772
+ g = l === "right" ? u + d - p - h : l === "center" ? u + d / 2 - h / 2 : u + f;
1773
+ let { needBidi: _, baseRtl: v } = xt(o.readingOrder, m.map((e) => e.text).join(""));
1774
+ ln(e, m, g, s, c, i, a, {
1775
+ fontColor: o.fontColor,
1776
+ needBidi: _,
1777
+ baseRtl: v
1778
+ });
1779
+ }
1780
+ function dn(e, t, n, r, i, a, o = {}) {
1781
+ let { alignV: s, cy: c, cellH: l, paddingY: u } = r, d, f;
1782
+ s === "top" ? (f = "top", d = c + u) : s === "center" ? (f = "middle", d = c + l / 2) : (f = "bottom", d = c + l - u), un(e, t, n, r, i, a, o, d, f);
1783
+ }
1784
+ function fn(e, t, n, r, i, a, o = {}) {
1785
+ let { alignV: s, cy: c, cellH: l, paddingY: u } = r, d = [[]];
1786
+ for (let e of t) {
1787
+ let t = e.text.split("\n");
1788
+ for (let n = 0; n < t.length; n++) n > 0 && d.push([]), t[n] !== "" && d[d.length - 1].push({
1789
+ ...e,
1790
+ text: t[n]
1791
+ });
1792
+ }
1793
+ let f = n.size, p = n.name, m = d.map((e) => {
1794
+ if (e.length === 0) return {
1795
+ pt: f || jt,
1796
+ family: p
1797
+ };
1798
+ let t = 0, r = null;
1799
+ for (let i of e) {
1800
+ let e = $t(n, i);
1801
+ e.size > t && (t = e.size, r = e.name), f = e.size, p = e.name;
1802
+ }
1803
+ return {
1804
+ pt: t,
1805
+ family: r
1806
+ };
1807
+ }).map((e) => Xt(e.pt, i, 1.2, e.family ?? void 0)), h = m.reduce((e, t) => e + t, 0), g;
1808
+ g = s === "top" ? c + u : s === "center" ? c + (l - h) / 2 : c + l - h - u;
1809
+ for (let t = 0; t < d.length; t++) {
1810
+ let s = d[t];
1811
+ s.length > 0 && un(e, s, n, r, i, a, o, g, "top"), g += m[t];
1812
+ }
1813
+ }
1814
+ function pn(e, t, n, r, i, a, o = {}) {
1815
+ t.some((e) => e.text.includes("\n")) ? fn(e, t, n, r, i, a, o) : dn(e, t, n, r, i, a, o);
1816
+ }
1817
+ function mn(e, t, n, r, i, a, o = {}) {
1818
+ let { alignH: s, alignV: c, cx: l, cy: u, cellW: d, cellH: f, leftPad: p, paddingX: m, paddingY: h } = r, g = on(e, t, n, i, d - p - m), _ = g.reduce((e, t) => e + Xt(t.maxFontSize, i, 1.2, t.maxFontFamily ?? void 0), 0), v;
1819
+ v = c === "top" ? u + h : c === "center" ? u + (f - _) / 2 : u + f - _ - h;
1820
+ let y = t.map((e) => e.text).join("").split("\n").map((e) => xt(o.readingOrder, e));
1821
+ for (let t of g) {
1822
+ let n = t.segments.reduce((e, t) => e + t.width, 0), r;
1823
+ r = s === "right" ? l + d - m - n : s === "center" ? l + d / 2 - n / 2 : l + p;
1824
+ let { needBidi: c, baseRtl: u } = y[t.para];
1825
+ ln(e, t.segments, r, v, "top", i, a, {
1826
+ fontColor: o.fontColor,
1827
+ needBidi: c,
1828
+ baseRtl: u
1829
+ }), v += Xt(t.maxFontSize, i, 1.2, t.maxFontFamily ?? void 0);
1830
+ }
1831
+ }
1832
+ function hn(e) {
1833
+ let t = "";
1834
+ for (; e > 0;) {
1835
+ let n = (e - 1) % 26;
1836
+ t = String.fromCharCode(65 + n) + t, e = Math.floor((e - 1) / 26);
1837
+ }
1838
+ return t;
1839
+ }
1840
+ var gn = [
1841
+ "#FF0000",
1842
+ "#FFFF00",
1843
+ "#00B050"
1844
+ ], _n = [
1845
+ "#FF0000",
1846
+ "#FF6600",
1847
+ "#FFFF00",
1848
+ "#00B050"
1849
+ ], vn = [
1850
+ "#FF0000",
1851
+ "#FF6600",
1852
+ "#FFFF00",
1853
+ "#92D050",
1854
+ "#00B050"
1855
+ ];
1856
+ function yn(e, t, n, r, i, a) {
1857
+ if (t === "NoIcons") return;
1858
+ let o = t || "3TrafficLights1", s = parseInt(o[0]) || 3, c = s === 5 ? vn : s === 4 ? _n : gn, l = c[Math.max(0, Math.min(n, c.length - 1))];
1859
+ if (e.save(), e.fillStyle = l, o.includes("Arrow")) {
1860
+ let t = a / 2;
1861
+ e.beginPath(), n === s - 1 ? (e.moveTo(r + t, i), e.lineTo(r + a, i + a), e.lineTo(r, i + a)) : n === 0 ? (e.moveTo(r, i), e.lineTo(r + a, i), e.lineTo(r + t, i + a)) : (e.moveTo(r, i + a * .3), e.lineTo(r + a, i + t), e.lineTo(r, i + a * .7)), e.closePath(), e.fill();
1862
+ } else o.includes("Flag") ? (e.beginPath(), e.moveTo(r, i), e.lineTo(r + a, i), e.lineTo(r, i + a), e.closePath(), e.fill()) : (e.beginPath(), e.arc(r + a / 2, i + a / 2, a / 2, 0, Math.PI * 2), e.fill());
1863
+ e.restore();
1864
+ }
1865
+ function bn(e, t, n, r, i) {
1866
+ let a = Math.max(6, Math.round(Math.min(r, i) * .45)), o = t + r - a - 1, s = n + i - a - 1;
1867
+ e.save(), e.fillStyle = "#D0D0D0", e.fillRect(o, s, a, a), e.fillStyle = "#444444";
1868
+ let c = a * .55, l = o + (a - c) / 2, u = s + (a - c * .5) / 2;
1869
+ e.beginPath(), e.moveTo(l, u), e.lineTo(l + c, u), e.lineTo(l + c / 2, u + c * .5), e.closePath(), e.fill(), e.restore();
1870
+ }
1871
+ function xn(e) {
1872
+ let t = /* @__PURE__ */ new Map();
1873
+ for (let n of e.tables ?? []) {
1874
+ if (!n.styleName) continue;
1875
+ let { top: e, bottom: r, left: i, right: a } = n.range, o = n.accentColor || "#808080", s = !!n.isCustom, c = Math.max(0, n.headerRowCount ?? 1), l = Math.max(0, n.totalsRowCount ?? 0), u = e + c - 1, d = r - l + 1;
1876
+ for (let f = e; f <= r; f++) {
1877
+ let p = c > 0 && f <= u, m = l > 0 && f >= d, h = !p && !m ? f - u - 1 : -1, g = n.showRowStripes && h >= 0 ? h % 2 == 1 ? n.band1HorizontalDxf : n.band2HorizontalDxf : void 0;
1878
+ for (let c = i; c <= a; c++) t.set(`${f}:${c}`, {
1879
+ accent: o,
1880
+ isCustom: s,
1881
+ isHeader: p,
1882
+ isTotals: m,
1883
+ isBanded: n.showRowStripes && h >= 0 && h % 2 == 1,
1884
+ isFirstCol: n.showFirstColumn && c === i,
1885
+ isLastCol: n.showLastColumn && c === a,
1886
+ isTopEdge: f === e,
1887
+ isBottomEdge: f === r,
1888
+ wholeTableDxf: n.wholeTableDxf,
1889
+ headerRowDxf: n.headerRowDxf,
1890
+ totalRowDxf: n.totalRowDxf,
1891
+ firstColumnDxf: n.firstColumnDxf,
1892
+ lastColumnDxf: n.lastColumnDxf,
1893
+ stripeDxf: g
1894
+ });
1895
+ }
1896
+ }
1897
+ return t;
1898
+ }
1899
+ function Sn(e, t, n, r) {
1900
+ let i = t?.border?.horizontal, a = t?.border?.top, o = t?.border?.bottom, s = t?.border?.left, c = t?.border?.right, l = n?.border?.bottom, u = n?.border?.top;
1901
+ if (i || a || o || s || c || l || u) {
1902
+ let t = {
1903
+ left: null,
1904
+ right: null,
1905
+ top: null,
1906
+ bottom: null
1907
+ };
1908
+ return e.isTopEdge ? t.top = a ?? null : i && (t.top = i), e.isHeader && l ? t.bottom = l : e.isBottomEdge ? t.bottom = o ?? null : i && (t.bottom = i), (e.isFirstCol || r === 0) && (t.left = s ?? null), e.isLastCol && (t.right = c ?? null), {
1909
+ kind: "dxf",
1910
+ border: t
1911
+ };
1912
+ }
1913
+ return e.isCustom ? { kind: "none" } : {
1914
+ kind: "accent",
1915
+ color: e.accent,
1916
+ lineWidth: e.isHeader ? 1.5 : 1,
1917
+ topEdge: e.isTopEdge
1918
+ };
1919
+ }
1920
+ function Cn(e) {
1921
+ let t = /* @__PURE__ */ new Map();
1922
+ for (let n of e.sparklineGroups ?? []) {
1923
+ let e = Infinity, r = -Infinity;
1924
+ if (n.minAxisType === "group" || n.maxAxisType === "group") {
1925
+ for (let t of n.sparklines) for (let n of t.values) typeof n == "number" && (n < e && (e = n), n > r && (r = n));
1926
+ (!isFinite(e) || !isFinite(r)) && (e = 0, r = 1);
1927
+ }
1928
+ for (let i of n.sparklines) {
1929
+ let a = i.values.filter((e) => typeof e == "number"), o = a.length ? Math.min(...a) : 0, s = a.length ? Math.max(...a) : 1, c = n.minAxisType === "custom" && typeof n.manualMin == "number" ? n.manualMin : n.minAxisType === "group" ? e : o, l = n.maxAxisType === "custom" && typeof n.manualMax == "number" ? n.manualMax : n.maxAxisType === "group" ? r : s;
1930
+ t.set(`${i.row}:${i.col}`, {
1931
+ kind: n.kind,
1932
+ values: i.values,
1933
+ min: c,
1934
+ max: l,
1935
+ displayEmptyCellsAs: n.displayEmptyCellsAs === "zero" || n.displayEmptyCellsAs === "span" ? n.displayEmptyCellsAs : "gap",
1936
+ displayXAxis: n.displayXAxis,
1937
+ lineWeight: n.lineWeight,
1938
+ markers: n.markers,
1939
+ high: n.high,
1940
+ low: n.low,
1941
+ first: n.first,
1942
+ last: n.last,
1943
+ negative: n.negative,
1944
+ colorSeries: n.colorSeries,
1945
+ colorNegative: n.colorNegative,
1946
+ colorAxis: n.colorAxis,
1947
+ colorMarkers: n.colorMarkers,
1948
+ colorFirst: n.colorFirst,
1949
+ colorLast: n.colorLast,
1950
+ colorHigh: n.colorHigh,
1951
+ colorLow: n.colorLow
1952
+ });
1953
+ }
1954
+ }
1955
+ return t;
1956
+ }
1957
+ function wn(e) {
1958
+ let t = e.replace("#", "");
1959
+ if (t.length < 6) return "#F2F2F2";
1960
+ let n = parseInt(t.slice(0, 2), 16), r = parseInt(t.slice(2, 4), 16), i = parseInt(t.slice(4, 6), 16), a = (e) => Math.round(e * .2 + 255 * .8), o = (e) => e.toString(16).padStart(2, "0").toUpperCase();
1961
+ return `#${o(a(n))}${o(a(r))}${o(a(i))}`;
1962
+ }
1963
+ function Tn(e, t, n, r, i, a, o, s, l, u, d, f, p, m) {
1964
+ if (p <= 0 || m <= 0) return;
1965
+ let { styles: h, cellMap: g, mergeAnchorMap: _, mergeSkipSet: v, cfContext: y, cs: b, dpr: x } = t, S = i.length, C = a.length, w = (e, n) => t.rtl ? Nt(e, n, t.canvasW) : e, T = [], E = -o;
1966
+ for (let e = 0; e < S; e++) T.push(E), E += i[e];
1967
+ let D = [], k = -s;
1968
+ for (let e = 0; e < C; e++) D.push(k), k += a[e];
1969
+ e.save(), e.beginPath(), e.rect(w(d, p), f, p, m), e.clip();
1970
+ let A = [], j = [], M = [];
1971
+ for (let i of t.worksheet.mergeCells ?? []) {
1972
+ let a = i.top, d = i.left;
1973
+ if (a >= n && a < n + C && d >= r && d < r + S || i.bottom < n || i.top >= n + C || i.right < r || i.left >= r + S) continue;
1974
+ let f = t.mergeAnchorMap.get(`${a}:${d}`);
1975
+ if (!f) continue;
1976
+ let p;
1977
+ if (d >= r) p = l + T[d - r];
1978
+ else {
1979
+ let e = 0;
1980
+ for (let n = d; n < r; n++) e += Math.round(Q(t.worksheet.colWidths[n] ?? t.worksheet.defaultColWidth, t.mdw) * b);
1981
+ p = l - o - e;
1982
+ }
1983
+ let m;
1984
+ if (a >= n) m = u + D[a - n];
1985
+ else {
1986
+ let e = 0;
1987
+ for (let r = a; r < n; r++) e += Math.round($(t.worksheet.rowHeights[r] ?? t.worksheet.defaultRowHeight) * b);
1988
+ m = u - s - e;
1989
+ }
1990
+ let g = f.totalW, _ = f.totalH;
1991
+ p = w(p, g);
1992
+ let v = `${a}:${d}`, E = t.cellMap.get(v), { font: O, fill: k, border: A, xf: M } = en(h, E?.styleIndex ?? 0), N = vt(E, a, d, y, h.dxfs ?? []);
1993
+ if (Gt(e, N.fill ?? k, p, m, g, _), N.dataBar && N.dataBar.ratio > 0) {
1994
+ let t = Math.max(0, (g - 4) * N.dataBar.ratio);
1995
+ Bt(e, N.dataBar.color, p + 2, m + 2, t, _ - 4, N.dataBar.gradient);
1996
+ }
1997
+ let P = Kn(Gn(A, a, d, f.right, f.bottom, t.cellMap, h), N.border);
1998
+ if (j.push(() => qn(e, P, p, m, g, _, x)), !E) continue;
1999
+ let F = Ve(E, h, N.numFmt);
2000
+ if (!F || F === "0" && t.worksheet.showZeros === !1) continue;
2001
+ let I = O.bold || !!N.fontBold, L = O.italic || !!N.fontItalic, R = O.underline || !!N.fontUnderline, ee = O.strike || !!N.fontStrike, z = I !== O.bold || L !== O.italic || R !== O.underline || ee !== O.strike ? {
2002
+ ...O,
2003
+ bold: I,
2004
+ italic: L,
2005
+ underline: R,
2006
+ strike: ee
2007
+ } : O;
2008
+ e.font = Zt(z, b);
2009
+ let B = t.hyperlinkMap.get(v) ? "#0563C1" : N.fontColor ?? O.color;
2010
+ e.fillStyle = B ? c(B) : "#000000";
2011
+ let V = E.value.type === "number", H = M.alignH ?? (V ? "right" : "left"), U = M.alignV ?? "bottom", W = M.indent ? Math.round(M.indent * 3 * t.mdw) : 0, te = 3 + (H === "left" || !M.alignH ? W : 0);
2012
+ e.save(), e.beginPath(), e.rect(p, m, g, _), e.clip();
2013
+ let ne;
2014
+ H === "right" ? (ne = p + g - 3, e.textAlign = "right") : H === "center" ? (ne = p + g / 2, e.textAlign = "center") : (ne = p + te, e.textAlign = "left");
2015
+ let re = E.value.type === "text" ? E.value.runs : void 0, ie = re && re.length > 0;
2016
+ if (M.wrapText && ie) mn(e, re, z, {
2017
+ alignH: H,
2018
+ alignV: U,
2019
+ cx: p,
2020
+ cy: m,
2021
+ cellW: g,
2022
+ cellH: _,
2023
+ leftPad: te,
2024
+ paddingX: 3,
2025
+ paddingY: 2
2026
+ }, b, x, {
2027
+ fontColor: N.fontColor,
2028
+ readingOrder: M.readingOrder
2029
+ });
2030
+ else if (M.wrapText) {
2031
+ let t = tn(e, F, g - te - 3), n = Xt(O.size, b, 1.2, O.name ?? void 0), r = t.length * n, i;
2032
+ i = U === "top" ? m + 2 : U === "center" ? m + (_ - r) / 2 : m + _ - r - 2, e.textBaseline = "top";
2033
+ for (let r = 0; r < t.length; r++) e.fillText(t[r], ne, i + r * n);
2034
+ } else if (ie) pn(e, re, z, {
2035
+ alignH: H,
2036
+ alignV: U,
2037
+ cx: p,
2038
+ cy: m,
2039
+ cellW: g,
2040
+ cellH: _,
2041
+ leftPad: te,
2042
+ paddingX: 3,
2043
+ paddingY: 2
2044
+ }, b, x, {
2045
+ fontColor: N.fontColor,
2046
+ readingOrder: M.readingOrder
2047
+ });
2048
+ else {
2049
+ let t;
2050
+ U === "top" ? (e.textBaseline = "top", t = m + 2) : U === "center" ? (e.textBaseline = "middle", t = m + _ / 2) : (e.textBaseline = "bottom", t = m + _ - 2), e.fillText(F, ne, t);
2051
+ }
2052
+ e.restore();
2053
+ }
2054
+ for (let o = 0; o < C; o++) {
2055
+ let s = n + o, C = u + D[o], E = a[o];
2056
+ if (C + E <= f || C >= f + m) continue;
2057
+ let k = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Set(), P = -1, F = (e) => {
2058
+ if (P >= 0 && e - P >= 2) {
2059
+ for (let t = P; t < e - 1; t++) k.add(t);
2060
+ for (let t = P + 1; t < e; t++) N.add(t);
2061
+ }
2062
+ P = -1;
2063
+ };
2064
+ for (let e = 0; e <= S; e++) {
2065
+ let t = !1, n = !1;
2066
+ if (e < S) {
2067
+ let i = `${s}:${r + e}`;
2068
+ if (!v.has(i) && !_.has(i)) {
2069
+ let e = g.get(i);
2070
+ t = en(h, e?.styleIndex ?? 0).xf.alignH === "centerContinuous", n = !!(e && e.value && e.value.type !== "empty");
2071
+ }
2072
+ }
2073
+ t ? n && P >= 0 && e > P ? (F(e), P = e) : P < 0 && (P = e) : F(e);
2074
+ }
2075
+ for (let n = 0; n < S; n++) {
2076
+ let a = r + n, u = l + T[n], f = i[n];
2077
+ if (u + f <= d || u >= d + p) continue;
2078
+ let m = `${s}:${a}`;
2079
+ if (v.has(m)) continue;
2080
+ let D = _.get(m), P = D ? D.totalW : f, F = D ? D.totalH : E, I = w(u, P), L = g.get(m), { font: R, fill: ee, border: z, xf: B } = en(h, L?.styleIndex ?? 0), V = vt(L, s, a, y, h.dxfs ?? []), H = V.fill ?? ee, W = t.tableStyleMap.get(m), te = h.dxfs ?? [], ne = (e) => e == null ? void 0 : te[e], re = ne(W?.wholeTableDxf), ie = ne(W?.headerRowDxf), ae = ne(W?.totalRowDxf), oe = ne(W?.firstColumnDxf), se = ne(W?.lastColumnDxf), G = ne(W?.stripeDxf), K = W?.isHeader && ie?.fill?.fgColor ? ie : W?.isTotals && ae?.fill?.fgColor ? ae : W?.isLastCol && se?.fill?.fgColor ? se : W?.isFirstCol && oe?.fill?.fgColor ? oe : G?.fill?.fgColor ? G : !W?.isHeader && !W?.isTotals && re?.fill?.fgColor ? re : void 0;
2081
+ if (Gt(e, H, I, C, P, F) || (W && K?.fill?.fgColor ? (e.fillStyle = c(K.fill.fgColor), e.fillRect(I, C, P, F)) : W && !W.isCustom && W.isBanded && (e.fillStyle = wn(W.accent), e.fillRect(I, C, P, F))), t.commentCells.has(m) && Jt(e, I, C, P, F), V.dataBar && V.dataBar.ratio > 0) {
2082
+ let t = Math.max(0, (P - 4) * V.dataBar.ratio);
2083
+ Bt(e, V.dataBar.color, I + 2, C + 2, t, F - 4, V.dataBar.gradient);
2084
+ }
2085
+ let ce = t.sparklineMap.get(m);
2086
+ if (ce && U(e, {
2087
+ x: I,
2088
+ y: C,
2089
+ w: P,
2090
+ h: F
2091
+ }, ce), t.worksheet.showGridlines !== !1) {
2092
+ if (e.strokeStyle = "#d0d0d0", e.lineWidth = .5, e.beginPath(), !k.has(n)) {
2093
+ let t = I + P + O(I + P, .5, x);
2094
+ e.moveTo(t, C), e.lineTo(t, C + F);
2095
+ }
2096
+ let t = C + F + O(C + F, .5, x);
2097
+ if (e.moveTo(I, t), e.lineTo(I + P, t), o === 0) {
2098
+ let t = C + O(C, .5, x);
2099
+ e.moveTo(I, t), e.lineTo(I + P, t);
2100
+ }
2101
+ if (n === 0) {
2102
+ let t = I + O(I, .5, x);
2103
+ e.moveTo(t, C), e.lineTo(t, C + F);
2104
+ }
2105
+ e.stroke();
2106
+ }
2107
+ let q = Kn(D ? Gn(z, s, a, D.right, D.bottom, g, h) : z, V.border);
2108
+ (k.has(n) || N.has(n)) && (q = {
2109
+ ...q,
2110
+ left: N.has(n) ? null : q.left,
2111
+ right: k.has(n) ? null : q.right
2112
+ });
2113
+ let le = g.get(`${s - 1}:${a}`), J = le ? en(h, le.styleIndex).border.bottom : null;
2114
+ if (J?.style && (o === 0 || q.top?.style) && (q = {
2115
+ ...q,
2116
+ top: Zn(q.top, J)
2117
+ }), !N.has(n)) {
2118
+ let e = g.get(`${s}:${a - 1}`), t = e ? en(h, e.styleIndex).border.right : null;
2119
+ t?.style && (n === 0 || q.left?.style) && (q = {
2120
+ ...q,
2121
+ left: Zn(q.left, t)
2122
+ });
2123
+ }
2124
+ let Y = W ? Sn(W, re, ie, a) : null, ue = t.autoFilterCells.has(m), de = () => {
2125
+ if (Y) {
2126
+ if (Y.kind === "dxf") qn(e, Y.border, I, C, P, F, x);
2127
+ else if (Y.kind === "accent") {
2128
+ let t = .5 / x;
2129
+ if (e.strokeStyle = Y.color, e.lineWidth = Y.lineWidth, e.beginPath(), e.moveTo(I, C + F - t), e.lineTo(I + P, C + F - t), Y.topEdge) {
2130
+ let t = C + O(C, Y.lineWidth, x);
2131
+ e.moveTo(I, t), e.lineTo(I + P, t);
2132
+ }
2133
+ e.stroke();
2134
+ }
2135
+ }
2136
+ ue && bn(e, I, C, f, F);
2137
+ };
2138
+ if (D) {
2139
+ let t = q;
2140
+ j.push(() => qn(e, t, I, C, P, F, x)), de();
2141
+ } else {
2142
+ let t = q;
2143
+ M.push(() => {
2144
+ qn(e, t, I, C, P, F, x), de();
2145
+ });
2146
+ }
2147
+ if (!L) continue;
2148
+ let X = Ve(L, h, V.numFmt);
2149
+ !X || X === "0" && t.worksheet.showZeros === !1 || A.push(() => {
2150
+ let o = W?.isHeader ? ie : W?.isTotals ? ae : W?.isLastCol && se ? se : W?.isFirstCol && oe ? oe : G || (W ? re : void 0), l = W ? W.isCustom ? !!o?.font?.bold : W.isHeader || W.isTotals : !1, u = R.bold || !!V.fontBold || l, d = R.italic || !!V.fontItalic, f = R.underline || !!V.fontUnderline, p = R.strike || !!V.fontStrike, y = u !== R.bold || d !== R.italic || f !== R.underline || p !== R.strike ? {
2151
+ ...R,
2152
+ bold: u,
2153
+ italic: d,
2154
+ underline: f,
2155
+ strike: p
2156
+ } : R;
2157
+ e.font = Zt(y, b);
2158
+ let w = t.hyperlinkMap.get(m), T = o?.font?.color ?? null, E = w ? "#0563C1" : V.fontColor ?? T ?? R.color;
2159
+ e.fillStyle = E ? c(E) : "#000000";
2160
+ let k = L.value.type === "number", A = B.alignH ?? (k ? "right" : "left"), j = B.alignV ?? "bottom", M = B.indent ? Math.round(B.indent * 3 * t.mdw) : 0, N = V.iconSet ? Math.max(8, Math.round(Math.min(P, F) * .55)) : 0, ee = N > 0 ? N + 4 : 0, z = 3 + (A === "left" || !B.alignH ? M : 0) + ee, H = P, U = I, te = n;
2161
+ if (A === "centerContinuous" && !D) for (let e = n + 1; e < S; e++) {
2162
+ let t = `${s}:${r + e}`;
2163
+ if (v.has(t) || _.has(t)) break;
2164
+ let n = g.get(t);
2165
+ if (n && n.value.type !== "empty" || en(h, n?.styleIndex ?? 0).xf.alignH !== "centerContinuous") break;
2166
+ H += i[e], te = e;
2167
+ }
2168
+ let ne = A === "centerContinuous" ? U : I, K = A === "centerContinuous" ? H : P, ce = X.includes("\n");
2169
+ if (!D && !B.wrapText && !B.textRotation && !k && !ce) {
2170
+ let t = e.measureText(X).width, a = A === "centerContinuous", o = a ? t + 6 : t + z + 3, c = a ? H : P;
2171
+ if (o > c) {
2172
+ let e = o - c, t = 0, l = 0;
2173
+ if (A === "right" ? l = e : A === "center" || a ? (l = e / 2, t = e / 2) : t = e, t > 0) {
2174
+ let e = t, o = a ? te + 1 : n + 1;
2175
+ for (let t = o; t < S && e > 0; t++) {
2176
+ let n = `${s}:${r + t}`;
2177
+ if (v.has(n) || _.has(n)) break;
2178
+ let a = g.get(n);
2179
+ if (a && a.value.type !== "empty") break;
2180
+ K += i[t], e -= i[t];
2181
+ }
2182
+ }
2183
+ if (l > 0) {
2184
+ let e = l;
2185
+ for (let t = n - 1; t >= 0 && e > 0; t--) {
2186
+ let n = `${s}:${r + t}`;
2187
+ if (v.has(n) || _.has(n)) break;
2188
+ let a = g.get(n);
2189
+ if (a && a.value.type !== "empty") break;
2190
+ ne -= i[t], K += i[t], e -= i[t];
2191
+ }
2192
+ }
2193
+ }
2194
+ }
2195
+ let q = X, le = 0;
2196
+ if (A === "fill" && !k && X.length > 0) {
2197
+ let t = Math.max(1, P - 6), n = e.measureText(X).width;
2198
+ if (n > 0 && n < t) {
2199
+ let e = Math.max(1, Math.floor(t / n));
2200
+ q = X.repeat(e);
2201
+ }
2202
+ }
2203
+ if (A === "distributed" || A === "justify" && !B.wrapText && !ce) {
2204
+ let t = Math.max(1, P - 6), n = e.measureText(q).width, r = Math.max(1, [...q].length - 1);
2205
+ n < t && (le = Math.max(0, (t - n) / r));
2206
+ }
2207
+ let J, Y;
2208
+ A === "right" ? (J = I + P - 3, Y = "right") : A === "center" ? (J = I + P / 2, Y = "center") : A === "centerContinuous" ? (J = U + H / 2, Y = "center") : A === "distributed" || A === "justify" && !B.wrapText && !ce ? (J = I + 3, Y = "left") : (J = I + z, Y = "left");
2209
+ let ue = B.textRotation ?? 0, de = ue === 255, fe = ue > 0 && ue !== 255;
2210
+ if (V.iconSet && N > 0 && (e.save(), e.beginPath(), e.rect(I, C, P, F), e.clip(), yn(e, V.iconSet.name, V.iconSet.index, I + 2, C + (F - N) / 2, N), e.restore()), e.save(), e.beginPath(), e.rect(ne, C, K, F), e.clip(), de) {
2211
+ let t = Xt(R.size, b, 1.1), n = X.length * t, r = j === "top" ? C + 2 : j === "center" ? C + (F - n) / 2 : C + F - n - 2;
2212
+ e.textAlign = "center", e.textBaseline = "top";
2213
+ for (let n of X) e.fillText(n, I + P / 2, r), r += t;
2214
+ e.restore();
2215
+ return;
2216
+ }
2217
+ if (fe) {
2218
+ let t = ue <= 90 ? -(ue * Math.PI / 180) : (ue - 90) * Math.PI / 180;
2219
+ e.translate(I + P / 2, C + F / 2), e.rotate(t), e.textAlign = "center", e.textBaseline = "middle", e.fillText(X, 0, 0), e.restore();
2220
+ return;
2221
+ }
2222
+ if (B.shrinkToFit) {
2223
+ let t = e.measureText(X).width, n = P - z - 3;
2224
+ if (t > n && t > 0) {
2225
+ let r = n / t, i = A === "right" ? I + P - 3 : A === "center" ? I + P / 2 : I + z;
2226
+ e.transform(r, 0, 0, 1, i * (1 - r), 0);
2227
+ }
2228
+ }
2229
+ if (e.textAlign = Y, le > 0) try {
2230
+ e.letterSpacing = `${le}px`;
2231
+ } catch {}
2232
+ try {
2233
+ e.direction = yt(B.readingOrder, X) ? "rtl" : "ltr";
2234
+ } catch {}
2235
+ let pe = L.value.type === "text" ? L.value.runs : void 0, me = pe && pe.length > 0;
2236
+ if (B.wrapText && me) mn(e, pe, y, {
2237
+ alignH: A,
2238
+ alignV: j,
2239
+ cx: I,
2240
+ cy: C,
2241
+ cellW: P,
2242
+ cellH: F,
2243
+ leftPad: z,
2244
+ paddingX: 3,
2245
+ paddingY: 2
2246
+ }, b, x, {
2247
+ fontColor: V.fontColor,
2248
+ readingOrder: B.readingOrder
2249
+ });
2250
+ else if (B.wrapText) {
2251
+ let t = tn(e, X, P - z - 3), n = Xt(R.size, b, 1.2, R.name ?? void 0), r = t.length * n, i;
2252
+ j === "top" ? (i = C + 2, e.textBaseline = "top") : j === "center" ? (i = C + (F - r) / 2, e.textBaseline = "top") : (i = C + F - r - 2, e.textBaseline = "top");
2253
+ for (let r = 0; r < t.length; r++) e.fillText(t[r], J, i + r * n);
2254
+ } else if (me) pn(e, pe, y, {
2255
+ alignH: A,
2256
+ alignV: j,
2257
+ cx: I,
2258
+ cy: C,
2259
+ cellW: P,
2260
+ cellH: F,
2261
+ leftPad: z,
2262
+ paddingX: 3,
2263
+ paddingY: 2
2264
+ }, b, x, {
2265
+ fontColor: V.fontColor,
2266
+ readingOrder: B.readingOrder
2267
+ });
2268
+ else {
2269
+ let t = y.vertAlign, n = Xt(R.size, b), r = 0;
2270
+ t === "superscript" ? r = -Math.round(n * .35) : t === "subscript" && (r = Math.round(n * .1));
2271
+ let i = t ? {
2272
+ ...y,
2273
+ size: y.size * .65
2274
+ } : y;
2275
+ t && (e.font = Zt(i, b));
2276
+ let a = null, o = () => a ??= e.measureText(X), s = () => {
2277
+ let e = Math.min(o().width, K - z - 3);
2278
+ return {
2279
+ x: A === "right" ? I + P - 3 - e : A === "center" ? I + P / 2 - e / 2 : I + z,
2280
+ width: e
2281
+ };
2282
+ }, l = Xt(i.size, b);
2283
+ if (y.underline || w) {
2284
+ let { x: t, width: n } = s(), i = (j === "top" ? C + 2 + l + 1 : j === "center" ? C + F / 2 + Math.round(l * .55) : C + F - 2 + 1) + r, a = w ? "#0563C1" : E ? c(E) : "#000000", o = y.underlineStyle === "double" || y.underlineStyle === "doubleAccounting";
2285
+ Qt(e, t, t + n, i, a, o, x);
2286
+ }
2287
+ if (y.strike) {
2288
+ let { x: t, width: n } = s(), i = (j === "top" ? C + 2 + Math.round(l * .5) : j === "center" ? C + F / 2 : C + F - 2 - Math.round(l * .35)) + r, a = i + O(i, .5, x);
2289
+ e.save(), e.strokeStyle = E ? c(E) : "#000000", e.lineWidth = .5, e.beginPath(), e.moveTo(t, a), e.lineTo(t + n, a), e.stroke(), e.restore();
2290
+ }
2291
+ if (X.includes("\n")) {
2292
+ let t = X.split("\n"), n = Xt(R.size, b, 1.2, R.name ?? void 0), i = t.length * n, a;
2293
+ j === "top" ? (a = C + 2, e.textBaseline = "top") : j === "center" ? (a = C + (F - i) / 2, e.textBaseline = "top") : (a = C + F - i - 2, e.textBaseline = "top");
2294
+ for (let i = 0; i < t.length; i++) e.fillText(t[i], J, a + i * n + r);
2295
+ } else {
2296
+ let t;
2297
+ j === "top" ? (e.textBaseline = "top", t = C + 2) : j === "center" ? (e.textBaseline = "middle", t = C + F / 2) : (e.textBaseline = "bottom", t = C + F - 2), e.fillText(q, J, t + r);
2298
+ }
2299
+ }
2300
+ e.restore(), X && t.onTextRun && t.onTextRun({
2301
+ text: X,
2302
+ x: I,
2303
+ y: C,
2304
+ width: P,
2305
+ height: F,
2306
+ row: s,
2307
+ col: a
2308
+ });
2309
+ });
2310
+ }
2311
+ }
2312
+ for (let e of M) e();
2313
+ for (let e of j) e();
2314
+ for (let e of A) e();
2315
+ e.restore();
2316
+ }
2317
+ var En = /* @__PURE__ */ new WeakMap();
2318
+ function Dn(e) {
2319
+ let t = En.get(e);
2320
+ if (t) return t;
2321
+ let n = /* @__PURE__ */ new Map();
2322
+ for (let t of e.rows) for (let e of t.cells) n.set(`${e.row}:${e.col}`, e);
2323
+ let r = /* @__PURE__ */ new Set();
2324
+ for (let t of e.mergeCells ?? []) for (let e = t.top; e <= t.bottom; e++) for (let n = t.left; n <= t.right; n++) e === t.top && n === t.left || r.add(`${e}:${n}`);
2325
+ let i = /* @__PURE__ */ new Set();
2326
+ if (e.autoFilter) {
2327
+ let t = e.autoFilter;
2328
+ for (let e = t.left; e <= t.right; e++) i.add(`${t.top}:${e}`);
2329
+ }
2330
+ let a = /* @__PURE__ */ new Map();
2331
+ for (let t of e.hyperlinks ?? []) t.url && a.set(`${t.row}:${t.col}`, t.url);
2332
+ let o = /* @__PURE__ */ new Set();
2333
+ for (let t of e.commentRefs ?? []) {
2334
+ let e = qt(t);
2335
+ e && o.add(`${e.row}:${e.col}`);
2336
+ }
2337
+ let s = {
2338
+ cellMap: n,
2339
+ cfContext: dt(e),
2340
+ mergeSkipSet: r,
2341
+ autoFilterCells: i,
2342
+ hyperlinkMap: a,
2343
+ commentCells: o,
2344
+ tableStyleMap: xn(e),
2345
+ sparklineMap: Cn(e)
2346
+ };
2347
+ return En.set(e, s), s;
2348
+ }
2349
+ function On(e, t, n, r, i = {}) {
2350
+ let a = i.dpr ?? 1, o = i.cellScale ?? 1, s = Z(t), c = e.canvas.width / a, l = e.canvas.height / a;
2351
+ e.clearRect(0, 0, c, l), e.fillStyle = "#ffffff", e.fillRect(0, 0, c, l);
2352
+ let u = (e) => Math.round(e * o), d = u(50), f = u(22), { row: p, col: m, rows: h, cols: g } = r, _ = (i.scrollOffsetX ?? 0) * o, v = (i.scrollOffsetY ?? 0) * o, y = i.freezeRows ?? 0, b = i.freezeCols ?? 0, x = [];
2353
+ for (let e = 1; e <= b; e++) x.push(u(Q(t.colWidths[e] ?? t.defaultColWidth, s)));
2354
+ let S = [];
2355
+ for (let e = 1; e <= y; e++) S.push(u($(t.rowHeights[e] ?? t.defaultRowHeight)));
2356
+ let C = x.reduce((e, t) => e + t, 0), w = S.reduce((e, t) => e + t, 0), T = [];
2357
+ for (let e = m; e < m + g; e++) T.push(u(Q(t.colWidths[e] ?? t.defaultColWidth, s)));
2358
+ let E = [];
2359
+ for (let e = p; e < p + h; e++) E.push(u($(t.rowHeights[e] ?? t.defaultRowHeight)));
2360
+ let { cellMap: D, cfContext: k, mergeSkipSet: A, autoFilterCells: j, hyperlinkMap: M, commentCells: N, tableStyleMap: P, sparklineMap: F } = Dn(t), I = /* @__PURE__ */ new Map();
2361
+ for (let e of t.mergeCells ?? []) {
2362
+ let n = 0;
2363
+ for (let r = e.left; r <= e.right; r++) n += u(Q(t.colWidths[r] ?? t.defaultColWidth, s));
2364
+ let r = 0;
2365
+ for (let n = e.top; n <= e.bottom; n++) r += u($(t.rowHeights[n] ?? t.defaultRowHeight));
2366
+ I.set(`${e.top}:${e.left}`, {
2367
+ totalW: n,
2368
+ totalH: r,
2369
+ right: e.right,
2370
+ bottom: e.bottom
2371
+ });
2372
+ }
2373
+ let L = {
2374
+ worksheet: t,
2375
+ styles: n,
2376
+ cellMap: D,
2377
+ mergeAnchorMap: I,
2378
+ mergeSkipSet: A,
2379
+ cfContext: k,
2380
+ colWidths: T,
2381
+ rowHeights: E,
2382
+ frozenColWidths: x,
2383
+ frozenRowHeights: S,
2384
+ frozenW: C,
2385
+ frozenH: w,
2386
+ startRow: p,
2387
+ startCol: m,
2388
+ cs: o,
2389
+ dpr: a,
2390
+ autoFilterCells: j,
2391
+ hyperlinkMap: M,
2392
+ commentCells: N,
2393
+ tableStyleMap: P,
2394
+ sparklineMap: F,
2395
+ mdw: s,
2396
+ onTextRun: i.onTextRun,
2397
+ rtl: t.rightToLeft === !0,
2398
+ canvasW: c
2399
+ }, R = d, ee = f, z = R + C, B = ee + w, V = Math.max(0, c - z), H = Math.max(0, l - B);
2400
+ y > 0 && b > 0 && Tn(e, L, 1, 1, x, S, 0, 0, R, ee, R, ee, C, w), y > 0 && Tn(e, L, 1, m, T, S, _, 0, z, ee, z, ee, V, w), b > 0 && Tn(e, L, p, 1, x, E, 0, v, R, B, R, B, C, H), Tn(e, L, p, m, T, E, _, v, z, B, z, B, V, H), t.images && t.images.length > 0 && i.loadedImages && Mn(e, t, i.loadedImages, o, p, m, _, v, z, B, V, H), t.shapeGroups && t.shapeGroups.length > 0 && Nn(e, t, o, p, m, _, v, z, B, V, H, i.loadedImages), t.charts && t.charts.length > 0 && Qn(e, t, o, p, m, _, v, z, B, V, H), t.slicers && t.slicers.length > 0 && dr(e, t, o, p, m, _, v, z, B, V, H), kn(e, c, l, p, m, h, g, T, E, _, v, x, S, C, w, d, f, o, a, i.selectedRowRange ?? null, i.selectedColRange ?? null, t.rightToLeft === !0);
2401
+ let U = t.rightToLeft === !0;
2402
+ if (y > 0) {
2403
+ e.save(), e.strokeStyle = Pt, e.lineWidth = .5, e.beginPath();
2404
+ let t = B + O(B, .5, a);
2405
+ U ? (e.moveTo(0, t), e.lineTo(c - d, t)) : (e.moveTo(d, t), e.lineTo(c, t)), e.stroke(), e.restore();
2406
+ }
2407
+ if (b > 0) {
2408
+ e.save(), e.strokeStyle = Pt, e.lineWidth = .5, e.beginPath();
2409
+ let t = U ? c - z : z, n = t + O(t, .5, a);
2410
+ e.moveTo(n, f), e.lineTo(n, l), e.stroke(), e.restore();
2411
+ }
2412
+ }
2413
+ function kn(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g, _, v, y, b, x) {
2414
+ let S = "#f8f9fa", C = "#e8eaed", w = "#caddf6", T = "#c8ccd0", E = "#5b9bd5", D = "#444", k = (e) => !b || e < b.start || e > b.end ? S : b.strong ? w : C, A = (e) => !b || e < b.start || e > b.end ? T : b.strong ? E : T, j = (e) => !y || e < y.start || e > y.end ? S : y.strong ? w : C, M = (e) => !y || e < y.start || e > y.end ? T : y.strong ? E : T, N = `${Math.max(1, Math.round(11 * _))}px ${Et}`, P = h + p, F = g + m, I = .5 / v, L = (e, n) => x ? Nt(e, n, t) : e, R = x ? t - h : 0;
2415
+ e.fillStyle = S, e.fillRect(R, 0, h, g), e.strokeStyle = T, e.lineWidth = .5, e.beginPath();
2416
+ let ee = R + O(R, .5, v), z = O(0, .5, v);
2417
+ e.moveTo(ee, 0), e.lineTo(ee, g), e.moveTo(R, z), e.lineTo(R + h, z), e.moveTo(R + h - I, 0), e.lineTo(R + h - I, g), e.moveTo(R, g - I), e.lineTo(R + h, g - I), e.stroke(), e.font = N, e.fillStyle = D;
2418
+ let B = (t, n, r) => {
2419
+ let i = L(n, r);
2420
+ e.fillStyle = k(t), e.fillRect(i, 0, r, g), e.strokeStyle = A(t), e.lineWidth = .5, e.beginPath();
2421
+ let a = i + O(i, .5, v), o = O(0, .5, v);
2422
+ e.moveTo(a, 0), e.lineTo(a, g), e.moveTo(i, g - I), e.lineTo(i + r, g - I), e.moveTo(i, o), e.lineTo(i + r, o), e.stroke(), e.fillStyle = D, e.textAlign = "center", e.textBaseline = "middle", e.fillText(hn(t), i + r / 2, g / 2);
2423
+ }, V = (t, n, r) => {
2424
+ let i = R;
2425
+ e.fillStyle = j(t), e.fillRect(i, n, h, r), e.strokeStyle = M(t), e.lineWidth = .5, e.beginPath();
2426
+ let a = n + O(n, .5, v), o = i + O(i, .5, v);
2427
+ e.moveTo(i + h - I, n), e.lineTo(i + h - I, n + r), e.moveTo(i, a), e.lineTo(i + h, a), e.moveTo(o, n), e.lineTo(o, n + r), e.stroke(), e.fillStyle = D, e.textBaseline = "middle";
2428
+ let s = Math.max(2, Math.round(4 * _));
2429
+ x ? (e.textAlign = "left", e.fillText(String(t), i + s, n + r / 2)) : (e.textAlign = "right", e.fillText(String(t), i + h - s, n + r / 2));
2430
+ };
2431
+ if (d.length > 0) {
2432
+ e.save(), e.beginPath(), e.rect(L(h, p), 0, p, g), e.clip();
2433
+ let t = h;
2434
+ for (let e = 0; e < d.length; e++) B(e + 1, t, d[e]), t += d[e];
2435
+ e.restore();
2436
+ }
2437
+ e.save(), e.beginPath(), e.rect(L(P, t - P), 0, t - P, g), e.clip();
2438
+ let H = P - l;
2439
+ for (let e = 0; e < s.length; e++) {
2440
+ let n = s[e];
2441
+ H + n > P && H < t && B(i + e, H, n), H += n;
2442
+ }
2443
+ if (e.restore(), f.length > 0) {
2444
+ e.save(), e.beginPath(), e.rect(R, g, h, m), e.clip();
2445
+ let t = g;
2446
+ for (let e = 0; e < f.length; e++) V(e + 1, t, f[e]), t += f[e];
2447
+ e.restore();
2448
+ }
2449
+ e.save(), e.beginPath(), e.rect(R, F, h, n - F), e.clip();
2450
+ let U = F - u;
2451
+ for (let e = 0; e < c.length; e++) {
2452
+ let t = c[e];
2453
+ U + t > F && U < n && V(r + e, U, t), U += t;
2454
+ }
2455
+ e.restore();
2456
+ }
2457
+ function An(e, t, n) {
2458
+ let r = Z(e), i = 0;
2459
+ for (let a = 1; a < t; a++) i += Math.round(Q(e.colWidths[a] ?? e.defaultColWidth, r) * n);
2460
+ return i;
2461
+ }
2462
+ function jn(e, t, n) {
2463
+ let r = 0;
2464
+ for (let i = 1; i < t; i++) r += Math.round($(e.rowHeights[i] ?? e.defaultRowHeight) * n);
2465
+ return r;
2466
+ }
2467
+ function Mn(e, t, n, r, i, a, o, s, c, l, u, d) {
2468
+ if (u <= 0 || d <= 0) return;
2469
+ let f = An(t, a, r), p = jn(t, i, r);
2470
+ e.save(), e.beginPath(), e.rect(c, l, u, d), e.clip();
2471
+ for (let i of t.images) {
2472
+ let a = n.get(i.imagePath);
2473
+ if (!a) continue;
2474
+ let m = i.fromCol + 1, h = i.fromRow + 1, g = An(t, m, r) + i.fromColOff * r / L, _ = jn(t, h, r) + i.fromRowOff * r / L, v, y;
2475
+ if (i.editAs === "oneCell" && i.nativeExtCx > 0 && i.nativeExtCy > 0) v = i.nativeExtCx * r / L, y = i.nativeExtCy * r / L;
2476
+ else {
2477
+ let e = i.toCol + 1, n = i.toRow + 1, a = An(t, e, r) + i.toColOff * r / L, o = jn(t, n, r) + i.toRowOff * r / L;
2478
+ v = a - g, y = o - _;
2479
+ }
2480
+ if (v <= 0 || y <= 0) continue;
2481
+ let x = c + (g - f) - o, S = l + (_ - p) - s;
2482
+ x + v < c || x > c + u || S + y < l || S > l + d || b(e, a, i.srcRect, x, S, v, y);
2483
+ }
2484
+ e.restore();
2485
+ }
2486
+ function Nn(e, t, n, r, i, a, o, s, c, l, u, d) {
2487
+ if (l <= 0 || u <= 0) return;
2488
+ let f = t.shapeGroups;
2489
+ if (!f || f.length === 0) return;
2490
+ let p = An(t, i, n), m = jn(t, r, n);
2491
+ e.save(), e.beginPath(), e.rect(s, c, l, u), e.clip();
2492
+ for (let r of f) {
2493
+ let i = r.fromCol + 1, f = r.fromRow + 1, h = An(t, i, n) + r.fromColOff * n / L, g = jn(t, f, n) + r.fromRowOff * n / L, _, v;
2494
+ if (r.editAs === "oneCell" && r.nativeExtCx > 0 && r.nativeExtCy > 0) _ = r.nativeExtCx * n / L, v = r.nativeExtCy * n / L;
2495
+ else {
2496
+ let e = r.toCol + 1, i = r.toRow + 1, a = An(t, e, n) + r.toColOff * n / L, o = jn(t, i, n) + r.toRowOff * n / L;
2497
+ _ = a - h, v = o - g;
2498
+ }
2499
+ if (_ <= 0 || v <= 0) continue;
2500
+ let y = s + (h - p) - a, b = c + (g - m) - o;
2501
+ if (!(y + _ < s || y > s + l) && !(b + v < c || b > c + u)) for (let t of r.shapes) {
2502
+ let r = y + t.x * _, i = b + t.y * v, a = t.w * _, o = t.h * v;
2503
+ a <= 0 || o <= 0 || Pn(e, t, r, i, a, o, n, d);
2504
+ }
2505
+ }
2506
+ e.restore();
2507
+ }
2508
+ function Pn(e, t, n, r, i, a, o, s) {
2509
+ if (e.save(), t.rot === 0 ? e.translate(n, r) : (e.translate(n + i / 2, r + a / 2), e.rotate(t.rot * Math.PI / 180), e.translate(-i / 2, -a / 2)), t.geom.type === "custom") for (let n of t.geom.paths) {
2510
+ if (n.w <= 0 || n.h <= 0) continue;
2511
+ let r = i / n.w, o = a / n.h;
2512
+ e.beginPath();
2513
+ let s = 0, c = 0, l = 0, u = 0;
2514
+ for (let t of n.commands) switch (t.op) {
2515
+ case "moveTo": {
2516
+ let n = t.x * r, i = t.y * o;
2517
+ e.moveTo(n, i), s = l = n, c = u = i;
2518
+ break;
2519
+ }
2520
+ case "lineTo": {
2521
+ let n = t.x * r, i = t.y * o;
2522
+ e.lineTo(n, i), s = n, c = i;
2523
+ break;
2524
+ }
2525
+ case "cubicBezTo": {
2526
+ let n = t.x3 * r, i = t.y3 * o;
2527
+ e.bezierCurveTo(t.x1 * r, t.y1 * o, t.x2 * r, t.y2 * o, n, i), s = n, c = i;
2528
+ break;
2529
+ }
2530
+ case "quadBezTo": {
2531
+ let n = t.x2 * r, i = t.y2 * o;
2532
+ e.quadraticCurveTo(t.x1 * r, t.y1 * o, n, i), s = n, c = i;
2533
+ break;
2534
+ }
2535
+ case "arcTo": {
2536
+ let n = t.wr * r, i = t.hr * o;
2537
+ if (n <= 0 || i <= 0) break;
2538
+ let a = t.stAng / 6e4 * (Math.PI / 180), l = t.swAng / 6e4 * (Math.PI / 180), u = s - Math.cos(a) * n, d = c - Math.sin(a) * i, f = a + l;
2539
+ e.ellipse(u, d, n, i, 0, a, f, l < 0), s = u + Math.cos(f) * n, c = d + Math.sin(f) * i;
2540
+ break;
2541
+ }
2542
+ case "close":
2543
+ e.closePath(), s = l, c = u;
2544
+ break;
2545
+ }
2546
+ Wn(e, t);
2547
+ }
2548
+ else if (t.geom.type === "preset") {
2549
+ let n = t.fillColor ?? null, r = t.strokeColor && t.strokeWidth > 0 ? () => {
2550
+ e.strokeStyle = t.strokeColor, e.lineWidth = Math.max(.5, t.strokeWidth / L), e.stroke();
2551
+ } : null;
2552
+ l(e, t.geom.name, 0, 0, i, a, t.geom.adj ?? [], n, r, () => {}) || (e.beginPath(), e.rect(0, 0, i, a), Wn(e, t));
2553
+ } else if (t.geom.type === "image") {
2554
+ let n = s?.get(t.geom.imagePath);
2555
+ n && b(e, n, t.geom.srcRect, 0, 0, i, a);
2556
+ }
2557
+ t.text && Un(e, t.text, i, a, o), e.restore();
2558
+ }
2559
+ var Fn = /* @__PURE__ */ new WeakMap();
2560
+ function In(e, t) {
2561
+ let n = e.tinted.get(t);
2562
+ if (n) return n;
2563
+ let r = e.img.naturalWidth || 1, i = e.img.naturalHeight || 1, a = document.createElement("canvas");
2564
+ a.width = r, a.height = i;
2565
+ let o = a.getContext("2d");
2566
+ return o ? (o.drawImage(e.img, 0, 0, r, i), o.globalCompositeOperation = "source-in", o.fillStyle = t, o.fillRect(0, 0, r, i), e.tinted.set(t, a), a) : e.img;
2567
+ }
2568
+ function Ln(e) {
2569
+ let t = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`, n = new Image();
2570
+ return new Promise((e, r) => {
2571
+ n.onload = () => e(n), n.onerror = r, n.src = t;
2572
+ });
2573
+ }
2574
+ var Rn = 256;
2575
+ function zn(e, t, n) {
2576
+ let r = Math.max(1, Math.round(t * Rn)), i = Math.max(1, Math.round(n * Rn));
2577
+ return e.replace(/<svg([^>]*?)>/, (e, t) => `<svg${t.replace(/\s(?:width|height)="[^"]*"/g, "")} width="${r}" height="${i}">`);
2578
+ }
2579
+ function Bn(e) {
2580
+ let t = [];
2581
+ for (let n of e.shapeGroups ?? []) for (let e of n.shapes) for (let n of e.text?.paragraphs ?? []) for (let e of n.runs) e.type === "math" && t.push({
2582
+ nodes: e.nodes,
2583
+ display: e.display
2584
+ });
2585
+ return t;
2586
+ }
2587
+ function Vn(e) {
2588
+ for (let t of e.shapeGroups ?? []) for (let e of t.shapes) for (let t of e.text?.paragraphs ?? []) for (let e of t.runs) if (e.type === "math" && !Fn.has(e.nodes)) return !0;
2589
+ return !1;
2590
+ }
2591
+ async function Hn(e, t) {
2592
+ let n = Bn(e).filter((e) => !Fn.has(e.nodes));
2593
+ if (n.length !== 0) {
2594
+ await t.loadMathJax();
2595
+ for (let e of n) if (!Fn.has(e.nodes)) try {
2596
+ let n = await t.mathMLToSvg(v(e.nodes, e.display)), r = await Ln(zn(V(n.svg, "#000000"), n.widthEm, n.ascentEm + n.descentEm));
2597
+ Fn.set(e.nodes, {
2598
+ img: r,
2599
+ widthEm: n.widthEm,
2600
+ ascentEm: n.ascentEm,
2601
+ descentEm: n.descentEm,
2602
+ tinted: /* @__PURE__ */ new Map()
2603
+ });
2604
+ } catch {}
2605
+ }
2606
+ }
2607
+ function Un(t, n, r, i, a) {
2608
+ if (r <= 0 || i <= 0 || n.paragraphs.length === 0) return;
2609
+ let o = n.lIns / L * a, s = n.rIns / L * a, c = n.tIns / L * a, l = n.bIns / L * a, u = Math.max(0, r - o - s), d = Math.max(0, i - c - l);
2610
+ if (u <= 0 || d <= 0) return;
2611
+ let f = (t) => {
2612
+ let n = (t.size > 0 ? t.size : jt) * e * a, r = At(t.fontFace);
2613
+ return {
2614
+ font: `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${n}px ${r}`,
2615
+ px: n
2616
+ };
2617
+ }, p = (e, n) => {
2618
+ let r = t.font;
2619
+ t.font = e;
2620
+ let i = t.measureText("M").actualBoundingBoxAscent;
2621
+ return t.font = r, i > 0 ? i : n * .85;
2622
+ }, m = n.wrap !== "none", h = [];
2623
+ for (let r of n.paragraphs) {
2624
+ let i = r.align || "l", o = (r.marL ?? 0) / L * a, s = (r.marR ?? 0) / L * a, c = (r.indent ?? 0) / L * a, l = Math.max(0, c), d = Math.max(0, u - o - s), g = !1, _ = () => g ? o : o + l, v = () => g ? d : d - l, y = [], b = 0, x = 0, S = 0, C = !1, w = (t) => {
2625
+ let i = t;
2626
+ return r.spaceLine && (r.spaceLine.type === "pct" ? i *= r.spaceLine.val / 1e5 : i = r.spaceLine.val * e * a), n.autoFit === "norm" && n.lnSpcReduction != null && r.spaceLine?.type !== "pts" && (i *= 1 - n.lnSpcReduction), i;
2627
+ }, T = () => {
2628
+ if (x === 0) {
2629
+ let t = (E || jt) * e * a, n = Math.max(k(D, t), k(O, t));
2630
+ x = Math.max(t * 1.2, n), S = p(`${t}px ${At(D)}`, t);
2631
+ }
2632
+ x = w(x), h.push({
2633
+ segs: y,
2634
+ align: i,
2635
+ height: x,
2636
+ ascent: S,
2637
+ hasMath: C,
2638
+ leftInset: _(),
2639
+ availW: v()
2640
+ }), g = !0, y = [], b = 0, x = 0, S = 0, C = !1;
2641
+ }, E = 0, D, O;
2642
+ for (let n of r.runs) {
2643
+ if (n.type === "break") {
2644
+ T();
2645
+ continue;
2646
+ }
2647
+ if (n.type === "math") {
2648
+ let t = Fn.get(n.nodes);
2649
+ if (!t) continue;
2650
+ let r = (n.fontSize ?? (E || jt)) * e * a, s = t.widthEm * r, c = t.ascentEm * r, l = t.descentEm * r, u = n.color ?? "#000000";
2651
+ if (n.display) {
2652
+ T(), h.push({
2653
+ segs: [{
2654
+ kind: "math",
2655
+ render: t,
2656
+ color: u,
2657
+ w: s,
2658
+ ascent: c,
2659
+ descent: l
2660
+ }],
2661
+ align: i,
2662
+ height: w(c + l),
2663
+ ascent: c,
2664
+ hasMath: !0,
2665
+ leftInset: o,
2666
+ availW: d
2667
+ }), g = !0;
2668
+ continue;
2669
+ }
2670
+ m && b + s > v() && y.length > 0 && T(), y.push({
2671
+ kind: "math",
2672
+ render: t,
2673
+ color: u,
2674
+ w: s,
2675
+ ascent: c,
2676
+ descent: l
2677
+ }), b += s, x = Math.max(x, c + l), S = Math.max(S, c), C = !0;
2678
+ continue;
2679
+ }
2680
+ E = n.size > 0 ? n.size : jt, D = n.fontFace, O = n.fontFaceEa;
2681
+ let { font: r, px: s } = f(n), c = n.color ?? "#000000", l = Math.max(k(n.fontFace, s), k(n.fontFaceEa, s)), u = Math.max(s * 1.2, l);
2682
+ x = Math.max(x, u), S = Math.max(S, p(r, s)), t.font = r;
2683
+ let _ = n.text.split("\n");
2684
+ for (let e = 0; e < _.length; e++) {
2685
+ e > 0 && T();
2686
+ let n = _[e];
2687
+ if (!n) continue;
2688
+ if (!m) {
2689
+ let e = t.measureText(n).width;
2690
+ y.push({
2691
+ kind: "text",
2692
+ text: n,
2693
+ font: r,
2694
+ color: c,
2695
+ w: e
2696
+ }), b += e;
2697
+ continue;
2698
+ }
2699
+ let i = "";
2700
+ for (let e of n) {
2701
+ let n = i + e, a = t.measureText(n).width;
2702
+ if (b + a > v() && (i.length > 0 || y.length > 0)) {
2703
+ if (i) {
2704
+ let e = t.measureText(i).width;
2705
+ y.push({
2706
+ kind: "text",
2707
+ text: i,
2708
+ font: r,
2709
+ color: c,
2710
+ w: e
2711
+ }), b += e;
2712
+ }
2713
+ T(), i = e, t.font = r, x = Math.max(x, u), S = Math.max(S, p(r, s));
2714
+ } else i = n;
2715
+ }
2716
+ if (i) {
2717
+ let e = t.measureText(i).width;
2718
+ y.push({
2719
+ kind: "text",
2720
+ text: i,
2721
+ font: r,
2722
+ color: c,
2723
+ w: e
2724
+ }), b += e;
2725
+ }
2726
+ }
2727
+ }
2728
+ T();
2729
+ }
2730
+ let g = h.reduce((e, t) => e + t.height, 0), _ = c;
2731
+ n.anchor === "ctr" ? _ = c + (d - g) / 2 : n.anchor === "b" && (_ = c + Math.max(0, d - g));
2732
+ let v = _;
2733
+ for (let e of h) {
2734
+ let n = e.segs.reduce((e, t) => e + t.w, 0), r = o + e.leftInset, i = r;
2735
+ if (e.align === "ctr" ? i = r + Math.max(0, (e.availW - n) / 2) : e.align === "r" && (i = r + Math.max(0, e.availW - n)), e.hasMath) {
2736
+ t.textBaseline = "alphabetic";
2737
+ let n = v + e.ascent;
2738
+ for (let r of e.segs) {
2739
+ if (r.kind === "text") t.font = r.font, t.fillStyle = r.color, t.fillText(r.text, i, n);
2740
+ else {
2741
+ let e = In(r.render, r.color);
2742
+ t.drawImage(e, i, n - r.ascent, r.w, r.ascent + r.descent);
2743
+ }
2744
+ i += r.w;
2745
+ }
2746
+ } else {
2747
+ t.textBaseline = "middle";
2748
+ let n = v + e.height / 2;
2749
+ for (let r of e.segs) r.kind === "text" && (t.font = r.font, t.fillStyle = r.color, t.fillText(r.text, i, n)), i += r.w;
2750
+ }
2751
+ v += e.height;
2752
+ }
2753
+ }
2754
+ function Wn(e, t) {
2755
+ t.fillColor && (e.fillStyle = t.fillColor, e.fill()), t.strokeColor && t.strokeWidth > 0 && (e.strokeStyle = t.strokeColor, e.lineWidth = Math.max(.5, t.strokeWidth / L), e.stroke());
2756
+ }
2757
+ function Gn(e, t, n, r, i, a, o) {
2758
+ if (r === n && i === t) return e;
2759
+ let s = (e, r) => {
2760
+ if (e === t && r === n) return null;
2761
+ let i = a.get(`${e}:${r}`);
2762
+ return i ? en(o, i.styleIndex).border : null;
2763
+ }, c = s(t, r), l = s(i, n), u = s(i, r), d = (e, ...t) => {
2764
+ if (e?.style) return e;
2765
+ for (let e of t) if (e?.style) return e;
2766
+ return e ?? null;
2767
+ };
2768
+ return {
2769
+ left: e.left,
2770
+ top: e.top,
2771
+ right: d(c?.right, u?.right, e.right),
2772
+ bottom: d(l?.bottom, u?.bottom, e.bottom),
2773
+ diagonalUp: e.diagonalUp ?? null,
2774
+ diagonalDown: e.diagonalDown ?? null
2775
+ };
2776
+ }
2777
+ function Kn(e, t) {
2778
+ if (!t) return e;
2779
+ let n = (e, t) => t && t.style ? t : e ?? null;
2780
+ return {
2781
+ left: n(e.left, t.left),
2782
+ right: n(e.right, t.right),
2783
+ top: n(e.top, t.top),
2784
+ bottom: n(e.bottom, t.bottom),
2785
+ diagonalUp: n(e.diagonalUp, t.diagonalUp),
2786
+ diagonalDown: n(e.diagonalDown, t.diagonalDown)
2787
+ };
2788
+ }
2789
+ function qn(e, t, n, r, i, a, o = 1) {
2790
+ let s = [
2791
+ {
2792
+ edge: t.top,
2793
+ x1: n,
2794
+ y1: r,
2795
+ x2: n + i,
2796
+ y2: r,
2797
+ kind: "h"
2798
+ },
2799
+ {
2800
+ edge: t.bottom,
2801
+ x1: n,
2802
+ y1: r + a,
2803
+ x2: n + i,
2804
+ y2: r + a,
2805
+ kind: "h"
2806
+ },
2807
+ {
2808
+ edge: t.left,
2809
+ x1: n,
2810
+ y1: r,
2811
+ x2: n,
2812
+ y2: r + a,
2813
+ kind: "v"
2814
+ },
2815
+ {
2816
+ edge: t.right,
2817
+ x1: n + i,
2818
+ y1: r,
2819
+ x2: n + i,
2820
+ y2: r + a,
2821
+ kind: "v"
2822
+ },
2823
+ {
2824
+ edge: t.diagonalUp,
2825
+ x1: n,
2826
+ y1: r + a,
2827
+ x2: n + i,
2828
+ y2: r,
2829
+ kind: "d"
2830
+ },
2831
+ {
2832
+ edge: t.diagonalDown,
2833
+ x1: n,
2834
+ y1: r,
2835
+ x2: n + i,
2836
+ y2: r + a,
2837
+ kind: "d"
2838
+ }
2839
+ ];
2840
+ for (let { edge: t, x1: l, y1: u, x2: d, y2: f, kind: p } of s) {
2841
+ if (!t || !t.style || t.style === "none") continue;
2842
+ let s = t.color ? c(t.color) : "#000000";
2843
+ if (t.style === "double" && p === "d") {
2844
+ e.strokeStyle = s, e.lineWidth = 1, e.setLineDash([]);
2845
+ let t = d - l, n = f - u, r = Math.hypot(t, n), i = -n / r * 1, a = t / r * 1;
2846
+ e.beginPath(), e.moveTo(l + i, u + a), e.lineTo(d + i, f + a), e.moveTo(l - i, u - a), e.lineTo(d - i, f - a), e.stroke();
2847
+ continue;
2848
+ }
2849
+ if (t.style === "double" && p !== "d") {
2850
+ if (e.strokeStyle = s, e.lineWidth = 1, e.setLineDash([]), e.beginPath(), p === "h") {
2851
+ let t = u === r, o = t ? r - 1 : r + a + 1, s = t ? r + 1 : r + a - 1;
2852
+ e.moveTo(n - 1, o), e.lineTo(n + i + 1, o), e.moveTo(n + 1, s), e.lineTo(n + i - 1, s);
2853
+ } else {
2854
+ let t = l === n, o = t ? n - 1 : n + i + 1, s = t ? n + 1 : n + i - 1;
2855
+ e.moveTo(o, r - 1), e.lineTo(o, r + a + 1), e.moveTo(s, r + 1), e.lineTo(s, r + a - 1);
2856
+ }
2857
+ e.stroke();
2858
+ continue;
2859
+ }
2860
+ e.beginPath(), e.strokeStyle = s;
2861
+ let m = Jn(t.style);
2862
+ e.lineWidth = m;
2863
+ let h = Yn(t.style);
2864
+ e.setLineDash(h);
2865
+ let g = p === "v" ? O(l, m, o) : 0, _ = p === "h" ? O(u, m, o) : 0;
2866
+ e.moveTo(l + g, u + _), e.lineTo(d + g, f + _), e.stroke(), e.setLineDash([]);
2867
+ }
2868
+ }
2869
+ function Jn(e) {
2870
+ switch (e) {
2871
+ case "thick": return 3;
2872
+ case "medium":
2873
+ case "mediumDashed":
2874
+ case "mediumDashDot":
2875
+ case "mediumDashDotDot":
2876
+ case "slantDashDot": return 2;
2877
+ case "hair": return .5;
2878
+ default: return 1;
2879
+ }
2880
+ }
2881
+ function Yn(e) {
2882
+ return i(e);
2883
+ }
2884
+ function Xn(e) {
2885
+ switch (e) {
2886
+ case "double": return 13;
2887
+ case "thick": return 12;
2888
+ case "medium": return 11;
2889
+ case "mediumDashed": return 10;
2890
+ case "mediumDashDot": return 9;
2891
+ case "slantDashDot": return 8;
2892
+ case "mediumDashDotDot": return 7;
2893
+ case "thin": return 6;
2894
+ case "dashed": return 5;
2895
+ case "dashDot": return 4;
2896
+ case "dashDotDot": return 3;
2897
+ case "dotted": return 2;
2898
+ case "hair": return 1;
2899
+ default: return 0;
2900
+ }
2901
+ }
2902
+ function Zn(e, t) {
2903
+ let n = Xn(e?.style), r = Xn(t?.style);
2904
+ return n === 0 && r === 0 ? null : n >= r ? e ?? null : t ?? null;
2905
+ }
2906
+ function Qn(t, n, r, i, a, o, s, c, l, u, d) {
2907
+ if (u <= 0 || d <= 0) return;
2908
+ let f = An(n, a, r), p = jn(n, i, r);
2909
+ for (let i of n.charts) {
2910
+ let a = i.fromCol + 1, m = i.fromRow + 1, h = i.toCol + 1, g = i.toRow + 1, _ = An(n, a, r) + i.fromColOff * r / L, v = jn(n, m, r) + i.fromRowOff * r / L, y = An(n, h, r) + i.toColOff * r / L, b = jn(n, g, r) + i.toRowOff * r / L, x = y - _, S = b - v;
2911
+ if (x <= 0 || S <= 0) continue;
2912
+ let C = c + (_ - f) - o, w = l + (v - p) - s;
2913
+ if (C + x < c || C > c + u || w + S < l || w > l + d) continue;
2914
+ t.save(), t.beginPath(), t.rect(c, l, u, d), t.clip();
2915
+ let T = e * r;
2916
+ R(t, i.chart, {
2917
+ x: C,
2918
+ y: w,
2919
+ w: x,
2920
+ h: S
2921
+ }, T), t.restore();
2922
+ }
2923
+ }
2924
+ var $n = "600 12px \"Meiryo UI\", \"Segoe UI\", sans-serif", er = "11px \"Meiryo UI\", \"Segoe UI\", sans-serif", tr = "#FFFFFF", nr = "#BFBFBF", rr = "#F2F2F2", ir = "#404040", ar = "#FFFFFF", or = "#000000", sr = "#A5A5A5", cr = "#E7E6E6", lr = "#A6A6A6", ur = "#C6C6C6";
2925
+ function dr(e, t, n, r, i, a, o, s, c, l, u) {
2926
+ if (l <= 0 || u <= 0) return;
2927
+ let d = t.slicers;
2928
+ if (!d) return;
2929
+ let f = An(t, i, n), p = jn(t, r, n);
2930
+ for (let r of d) {
2931
+ let i = r.fromCol + 1, d = r.fromRow + 1, m = r.toCol + 1, h = r.toRow + 1, g = An(t, i, n) + r.fromColOff * n / L, _ = jn(t, d, n) + r.fromRowOff * n / L, v = An(t, m, n) + r.toColOff * n / L, y = jn(t, h, n) + r.toRowOff * n / L, b = v - g, x = y - _;
2932
+ if (b <= 0 || x <= 0) continue;
2933
+ let S = s + (g - f) - a, C = c + (_ - p) - o;
2934
+ S + b < s || S > s + l || C + x < c || C > c + u || (e.save(), e.beginPath(), e.rect(s, c, l, u), e.clip(), fr(e, r.caption, r.items, S, C, b, x, n), e.restore());
2935
+ }
2936
+ }
2937
+ function fr(e, t, n, r, i, a, o, s) {
2938
+ e.fillStyle = tr, e.fillRect(r, i, a, o), e.strokeStyle = nr, e.lineWidth = 1, e.strokeRect(r + .5, i + .5, a - 1, o - 1);
2939
+ let c = Math.max(20 * s, 14);
2940
+ e.fillStyle = rr, e.fillRect(r + 1, i + 1, a - 2, c), e.fillStyle = ir, e.font = pr($n, s), e.textBaseline = "middle", e.textAlign = "left";
2941
+ let l = 6 * s;
2942
+ if (mr(e, t, r + l, i + c / 2 + 1, a - 2 * l), n.length === 0) return;
2943
+ let u = Math.max(1, Math.round(2 * s)), d = 4 * s, f = r + d, p = i + c + d, m = a - 2 * d, h = o - c - 2 * d;
2944
+ if (m <= 0 || h <= 0) return;
2945
+ let g = Math.max(18 * s, 16), _ = Math.max(1, Math.floor((h + u) / (g + u))), v = Math.min(n.length, _), y = Math.min(g, (h - u * (v - 1)) / v);
2946
+ if (y <= 0) return;
2947
+ e.font = pr(er, s);
2948
+ let b = 8 * s;
2949
+ for (let t = 0; t < v; t++) {
2950
+ let r = n[t], i = p + t * (y + u), a = r.selected;
2951
+ e.fillStyle = a ? ar : cr, e.fillRect(f, i, m, y), e.strokeStyle = a ? sr : ur, e.lineWidth = 1, e.strokeRect(f + .5, i + .5, m - 1, y - 1), e.fillStyle = a ? or : lr, mr(e, r.name, f + b, i + y / 2 + 1, m - 2 * b);
2952
+ }
2953
+ }
2954
+ function pr(e, t) {
2955
+ return e.replace(/(\d+(?:\.\d+)?)px/, (e, n) => `${Math.round(Number(n) * t)}px`);
2956
+ }
2957
+ function mr(e, t, n, r, i) {
2958
+ if (i <= 0) return;
2959
+ let a = t;
2960
+ if (e.measureText(a).width > i) {
2961
+ for (; a.length > 0 && e.measureText(a + "…").width > i;) a = a.slice(0, -1);
2962
+ a = a.length > 0 ? a + "…" : "";
2963
+ }
2964
+ e.fillText(a, n, r);
2965
+ }
2966
+ //#endregion
2967
+ //#region packages/xlsx/src/render-orchestrator.ts
2968
+ async function hr(e, t, n, r, i = 0, a = 0, o = null) {
2969
+ let s = async (e, t) => {
2970
+ let n = I(t, o, i, a);
2971
+ return d(await r(e, t), {
2972
+ widthPt: n.widthPt,
2973
+ heightPt: n.heightPt
2974
+ });
2975
+ }, c = t === "image/svg+xml", l = {
2976
+ svgImagePath: n,
2977
+ srcRect: o
2978
+ };
2979
+ if (P(l)) try {
2980
+ return await F(l.svgImagePath, r);
2981
+ } catch {
2982
+ return c ? F(e, r) : s(e, t);
2983
+ }
2984
+ return c ? F(e, r) : s(e, t);
2985
+ }
2986
+ async function gr(e, t, n) {
2987
+ if (!n) return;
2988
+ let r = n, i = /* @__PURE__ */ new Map();
2989
+ if (e.images) for (let n of e.images) t.has(n.imagePath) || i.set(n.imagePath, {
2990
+ imagePath: n.imagePath,
2991
+ mimeType: n.mimeType,
2992
+ svgImagePath: n.svgImagePath,
2993
+ widthPt: n.nativeExtCx > 0 ? n.nativeExtCx / u : 0,
2994
+ heightPt: n.nativeExtCy > 0 ? n.nativeExtCy / u : 0,
2995
+ srcRect: n.srcRect ?? null
2996
+ });
2997
+ if (e.shapeGroups) for (let n of e.shapeGroups) for (let e of n.shapes) e.geom.type === "image" && !t.has(e.geom.imagePath) && i.set(e.geom.imagePath, {
2998
+ imagePath: e.geom.imagePath,
2999
+ mimeType: e.geom.mimeType,
3000
+ svgImagePath: e.geom.svgImagePath,
3001
+ widthPt: n.nativeExtCx > 0 ? n.nativeExtCx * e.w / u : 0,
3002
+ heightPt: n.nativeExtCy > 0 ? n.nativeExtCy * e.h / u : 0,
3003
+ srcRect: e.geom.srcRect ?? null
3004
+ });
3005
+ i.size !== 0 && await Promise.all([...i.values()].map(async (e) => {
3006
+ try {
3007
+ let n = await hr(e.imagePath, e.mimeType, e.svgImagePath, r, e.widthPt, e.heightPt, e.srcRect);
3008
+ t.set(e.imagePath, n);
3009
+ } catch {}
3010
+ }));
3011
+ }
3012
+ async function _r(e, t, n, r = {}) {
3013
+ let { ws: i, styles: a, imageCache: o } = e;
3014
+ await gr(i, o, r.fetchImage), e.math && Vn(i) && await Hn(i, e.math);
3015
+ let s = r.dpr ?? T(), c = w(t) ? t.clientWidth || 800 : t.width, l = w(t) ? t.clientHeight || 600 : t.height, u = r.width ?? c, d = r.height ?? l, f = Math.round(u * s), p = Math.round(d * s);
3016
+ if (t.width !== f && (t.width = f), t.height !== p && (t.height = p), w(t)) {
3017
+ let e = `${u}px`, n = `${d}px`;
3018
+ t.style.width !== e && (t.style.width = e), t.style.height !== n && (t.style.height = n);
3019
+ }
3020
+ let m = t.getContext("2d");
3021
+ m.setTransform(s, 0, 0, s, 0, 0), On(m, i, a, n, {
3022
+ ...r,
3023
+ dpr: s,
3024
+ loadedImages: o
3025
+ });
3026
+ }
3027
+ //#endregion
3028
+ //#region packages/xlsx/src/google-fonts.ts
3029
+ var vr = {
3030
+ ...g,
3031
+ ...f
3032
+ };
3033
+ function* yr(e) {
3034
+ for (let t of e?.sharedStrings ?? []) if (t.runs && t.runs.length > 0) for (let e of t.runs) yield e.text;
3035
+ else yield t.text;
3036
+ }
3037
+ function br(e) {
3038
+ let t = /* @__PURE__ */ new Set(), r = null;
3039
+ for (let i of e?.styles?.fonts ?? []) i.name && (t.add(i.name), r ??= n(i.name));
3040
+ for (let n of a(yr(e), r)) t.add(n);
3041
+ return t;
3042
+ }
3043
+ function xr(e) {
3044
+ let t = (e ?? "").trim();
3045
+ if (!t) return {
3046
+ kind: "unresolved",
3047
+ formula: ""
3048
+ };
3049
+ if (t.length >= 2 && t.startsWith("\"") && t.endsWith("\"")) return {
3050
+ kind: "inline",
3051
+ values: t.slice(1, -1).split(",").map((e) => e.trim()).filter((e) => e.length > 0)
3052
+ };
3053
+ let n, r = t, i = t.indexOf("!");
3054
+ if (i >= 0) {
3055
+ let e = t.slice(0, i);
3056
+ e.startsWith("'") && e.endsWith("'") && e.length >= 2 && (e = e.slice(1, -1).replace(/''/g, "'")), n = e, r = t.slice(i + 1);
3057
+ }
3058
+ let [a, o] = r.split(":"), s = Ct(a ?? "");
3059
+ if (s) {
3060
+ let e = o ? Ct(o) : s;
3061
+ if (e) {
3062
+ let t = {
3063
+ row: Math.min(s.row, e.row),
3064
+ col: Math.min(s.col, e.col)
3065
+ }, r = {
3066
+ row: Math.max(s.row, e.row),
3067
+ col: Math.max(s.col, e.col)
3068
+ };
3069
+ return {
3070
+ kind: "range",
3071
+ sheet: n,
3072
+ start: t,
3073
+ end: r
3074
+ };
3075
+ }
3076
+ }
3077
+ return {
3078
+ kind: "unresolved",
3079
+ formula: t
3080
+ };
3081
+ }
3082
+ function Sr(e, t) {
3083
+ if (e.kind === "inline") return {
3084
+ kind: "values",
3085
+ values: e.values
3086
+ };
3087
+ if (e.kind === "unresolved") return {
3088
+ kind: "formula",
3089
+ formula: e.formula
3090
+ };
3091
+ let n = [];
3092
+ for (let r = e.start.row; r <= e.end.row; r++) for (let i = e.start.col; i <= e.end.col; i++) {
3093
+ let e = t(r, i);
3094
+ e != null && e !== "" && n.push(e);
3095
+ }
3096
+ return {
3097
+ kind: "values",
3098
+ values: n
3099
+ };
3100
+ }
3101
+ function Cr(e) {
3102
+ let { cell: t, panel: n, viewport: r, rtl: i } = e, a = t.y + t.h + 2, o = t.y - 2 - n.h, s;
3103
+ s = a + n.h <= r.h ? a : o >= 0 ? o : a, s = Math.max(0, Math.min(s, r.h - n.h));
3104
+ let c = i ? t.x + t.w - n.w : t.x;
3105
+ return c = Math.max(0, Math.min(c, r.w - n.w)), {
3106
+ left: c,
3107
+ top: s
3108
+ };
3109
+ }
3110
+ //#endregion
3111
+ //#region packages/xlsx/src/workbook.ts
3112
+ var wr = class e {
3113
+ worker;
3114
+ bridge;
3115
+ parsedWorkbook = null;
3116
+ sheetCache = /* @__PURE__ */ new Map();
3117
+ imageCache = /* @__PURE__ */ new Map();
3118
+ imageBlobCache = /* @__PURE__ */ new Map();
3119
+ _fetchImage = (e, t) => this.getImage(e, t);
3120
+ rawData = null;
3121
+ maxZipEntryBytes;
3122
+ math;
3123
+ _mode = "main";
3124
+ constructor(e, t, n) {
3125
+ this.worker = e, this._mode = t, this.bridge = new A(this.worker, {
3126
+ correlate: (e) => e.id,
3127
+ toError: (e) => e.type === "error" ? e.message : void 0
3128
+ });
3129
+ let r = new URL(n ?? oe, location.href).href;
3130
+ this.bridge.post({
3131
+ type: "init",
3132
+ wasmUrl: r
3133
+ });
3134
+ }
3135
+ static async load(t, n = {}) {
3136
+ let r = n.mode ?? "main";
3137
+ if (r === "worker" && (typeof Worker > "u" || typeof OffscreenCanvas > "u")) throw Error("mode: 'worker' requires Worker and OffscreenCanvas support");
3138
+ let i = new e(r === "worker" ? (await import("./render-worker-host-2V2UCnvB.js")).createRenderWorker() : new ae(), r, n.wasmUrl);
3139
+ return await i._load(t, n), i;
3140
+ }
3141
+ async _load(e, t = {}) {
3142
+ let n;
3143
+ if (typeof e == "string") {
3144
+ let t = await fetch(e);
3145
+ if (!t.ok) throw Error(`Failed to fetch: ${t.status} ${t.statusText}`);
3146
+ n = await t.arrayBuffer();
3147
+ } else n = e;
3148
+ this.rawData = n, this.maxZipEntryBytes = t.maxZipEntryBytes, this.math = t.math, t.math && this._mode === "worker" && console.warn("[ooxml] the math engine is unavailable in mode: 'worker'; equations will be skipped. Use mode: 'main' for workbooks with equations.");
3149
+ let r = await this.bridge.request((e) => this._mode === "worker" ? {
3150
+ type: "parse",
3151
+ id: e,
3152
+ data: n.slice(0),
3153
+ maxZipEntryBytes: this.maxZipEntryBytes,
3154
+ useGoogleFonts: !!t.useGoogleFonts
3155
+ } : {
3156
+ type: "parse",
3157
+ id: e,
3158
+ data: n.slice(0),
3159
+ maxZipEntryBytes: this.maxZipEntryBytes
3160
+ }, void 0, { timeoutMs: t.workerTimeoutMs });
3161
+ if (this._mode === "worker") this.parsedWorkbook = r.workbook;
3162
+ else {
3163
+ let { workbookJson: e } = r;
3164
+ this.parsedWorkbook = JSON.parse(new TextDecoder().decode(new Uint8Array(e)));
3165
+ }
3166
+ this._mode === "main" && t.useGoogleFonts && await h(br(this.parsedWorkbook), vr);
3167
+ }
3168
+ get sheetNames() {
3169
+ return this.parsedWorkbook?.workbook.sheets.map((e) => e.name) ?? [];
3170
+ }
3171
+ get sheetCount() {
3172
+ return this.parsedWorkbook?.workbook.sheets.length ?? 0;
3173
+ }
3174
+ get tabColors() {
3175
+ return this.parsedWorkbook?.workbook.sheets.map((e) => e.tabColor ?? null) ?? [];
3176
+ }
3177
+ sheetVisibility(e) {
3178
+ return se(this.parsedWorkbook?.workbook.sheets ?? [], e);
3179
+ }
3180
+ isHidden(e) {
3181
+ return this.sheetVisibility(e) !== "visible";
3182
+ }
3183
+ async getWorksheet(e) {
3184
+ let t = this.sheetCache.get(e);
3185
+ if (t) return t;
3186
+ if (!this.parsedWorkbook || !this.rawData) throw Error("Workbook not loaded");
3187
+ let n = this.parsedWorkbook.workbook.sheets[e];
3188
+ if (!n) throw Error(`Sheet index ${e} out of range`);
3189
+ let r = await this.bridge.request((t) => ({
3190
+ type: "parseSheet",
3191
+ id: t,
3192
+ sheetIndex: e,
3193
+ sheetName: n.name,
3194
+ maxZipEntryBytes: this.maxZipEntryBytes
3195
+ })), i;
3196
+ if (this._mode === "worker") i = r.worksheet;
3197
+ else {
3198
+ let { worksheetJson: e } = r;
3199
+ i = JSON.parse(new TextDecoder().decode(new Uint8Array(e)));
3200
+ }
3201
+ return this.sheetCache.set(e, i), i;
3202
+ }
3203
+ async getImage(e, t) {
3204
+ let n = this.imageBlobCache.get(e);
3205
+ if (n) return n;
3206
+ let r = this.bridge.request((t) => ({
3207
+ type: "extractImage",
3208
+ id: t,
3209
+ path: e
3210
+ })).then((e) => {
3211
+ let n = e.bytes;
3212
+ return new Blob([n], { type: t });
3213
+ });
3214
+ return this.imageBlobCache.set(e, r), r;
3215
+ }
3216
+ async resolveValidationList(e, t) {
3217
+ if (!this.parsedWorkbook) throw Error("Workbook not loaded");
3218
+ let n = xr(t);
3219
+ if (n.kind !== "range") return Sr(n, () => null);
3220
+ let r = e;
3221
+ if (n.sheet) {
3222
+ let e = this.sheetNames.findIndex((e) => e.toLowerCase() === n.sheet?.toLowerCase());
3223
+ if (e < 0) return {
3224
+ kind: "formula",
3225
+ formula: t ?? ""
3226
+ };
3227
+ r = e;
3228
+ }
3229
+ let i = await this.getWorksheet(r), a = this.parsedWorkbook.styles, o = /* @__PURE__ */ new Map();
3230
+ for (let e of i.rows) for (let t of e.cells) o.set(`${t.row}:${t.col}`, t);
3231
+ return Sr(n, (e, t) => {
3232
+ let n = o.get(`${e}:${t}`);
3233
+ return n ? Ve(n, a) : null;
3234
+ });
3235
+ }
3236
+ async renderViewport(e, t, n, r = {}) {
3237
+ if (this._mode === "worker") throw Error("renderViewport(canvas) is unavailable in mode: 'worker'; use renderViewportToBitmap() and paint it via an ImageBitmapRenderingContext");
3238
+ if (!this.parsedWorkbook) throw Error("Workbook not loaded");
3239
+ return _r({
3240
+ ws: this.sheetCache.get(t) ?? await this.getWorksheet(t),
3241
+ styles: this.parsedWorkbook.styles,
3242
+ imageCache: this.imageCache,
3243
+ math: this.math
3244
+ }, e, n, {
3245
+ fetchImage: this._fetchImage,
3246
+ ...r
3247
+ });
3248
+ }
3249
+ async renderViewportToBitmap(e, t, n) {
3250
+ let r = {
3251
+ ...n,
3252
+ dpr: n.dpr ?? T()
3253
+ };
3254
+ if (this._mode === "worker") {
3255
+ if (!Number.isInteger(e) || e < 0 || e >= this.sheetCount) throw Error(`Sheet index ${e} out of range (count: ${this.sheetCount})`);
3256
+ return (await this.bridge.request((n) => ({
3257
+ type: "renderViewport",
3258
+ id: n,
3259
+ sheetIndex: e,
3260
+ viewport: t,
3261
+ opts: r
3262
+ }))).bitmap;
3263
+ }
3264
+ let i = new OffscreenCanvas(1, 1);
3265
+ return await this.renderViewport(i, e, t, r), i.transferToImageBitmap();
3266
+ }
3267
+ destroy() {
3268
+ this.bridge.terminate(), this.parsedWorkbook = null, this.sheetCache.clear(), this.imageCache.clear(), this.imageBlobCache.clear(), t(this._fetchImage), this.rawData = null;
3269
+ }
3270
+ };
3271
+ //#endregion
3272
+ //#region packages/xlsx/src/data-validation.ts
3273
+ function Tr(e, t, n) {
3274
+ if (!e) return !1;
3275
+ for (let r of e.split(/\s+/)) {
3276
+ if (!r) continue;
3277
+ let [e, i] = r.split(":"), a = Ct(e);
3278
+ if (!a) continue;
3279
+ if (!i) {
3280
+ if (a.row === t && a.col === n) return !0;
3281
+ continue;
3282
+ }
3283
+ let o = Ct(i);
3284
+ if (!o) continue;
3285
+ let s = Math.min(a.row, o.row), c = Math.max(a.row, o.row), l = Math.min(a.col, o.col), u = Math.max(a.col, o.col);
3286
+ if (t >= s && t <= c && n >= l && n <= u) return !0;
3287
+ }
3288
+ return !1;
3289
+ }
3290
+ function Er(e, t, n) {
3291
+ if (!e) return null;
3292
+ for (let r of e) if (r.validationType === "list" && Tr(r.sqref, t, n)) return r;
3293
+ return null;
3294
+ }
3295
+ function Dr(e) {
3296
+ let { cell: t, popup: n, viewport: r, rtl: i } = e, a = t.x + t.w + 8, o = t.x - 8 - n.w, s = a + n.w <= r.w, c = o >= 0, l;
3297
+ l = i ? c ? o : s ? a : o : s ? a : c ? o : a, l = Math.max(0, Math.min(l, r.w - n.w));
3298
+ let u = t.y;
3299
+ return u = Math.max(0, Math.min(u, r.h - n.h)), {
3300
+ left: l,
3301
+ top: u
3302
+ };
3303
+ }
3304
+ //#endregion
3305
+ //#region packages/xlsx/src/viewer.ts
3306
+ var Or = 150, kr = 280, Ar = 200, jr = 240, Mr = 200, Nr = 30, Pr = 1, Fr = .45, Ir = "data-xlsx-viewer-styles", Lr = ".xlsx-tab-strip::-webkit-scrollbar{display:none}.xlsx-tab-nav{background:transparent;transition:background 0.1s;}.xlsx-tab-nav:hover{background:rgba(0,0,0,0.08);}.xlsx-zoom-slider{-webkit-appearance:none;appearance:none;background:transparent;height:15px;margin:0;}.xlsx-zoom-slider::-webkit-slider-runnable-track{height:4px;background:#c4c4c4;border-radius:2px;}.xlsx-zoom-slider::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:12px;height:12px;margin-top:-4px;border-radius:50%;background:#808080;cursor:pointer;}.xlsx-zoom-slider:hover::-webkit-slider-thumb{background:#5f5f5f;}.xlsx-zoom-slider::-moz-range-track{height:4px;background:#c4c4c4;border-radius:2px;}.xlsx-zoom-slider::-moz-range-thumb{width:12px;height:12px;border:none;border-radius:50%;background:#808080;cursor:pointer;}";
3307
+ function Rr() {
3308
+ if (typeof document > "u" || !document.head || document.head.querySelector(`style[${Ir}]`)) return;
3309
+ let e = document.createElement("style");
3310
+ e.setAttribute(Ir, ""), e.textContent = Lr, document.head.appendChild(e);
3311
+ }
3312
+ var zr = class {
3313
+ idxs;
3314
+ cumDelta;
3315
+ constructor(e, t, n, r) {
3316
+ this.defaultPx = t, this.maxIndex = r, this.idxs = Object.keys(e).map(Number).filter((e) => e >= 1 && e <= r).sort((e, t) => e - t), this.cumDelta = Array(this.idxs.length);
3317
+ let i = 0;
3318
+ for (let r = 0; r < this.idxs.length; r++) i += n(e[this.idxs[r]]) - t, this.cumDelta[r] = i;
3319
+ }
3320
+ deltaBefore(e) {
3321
+ let t = 0, n = this.idxs.length;
3322
+ for (; t < n;) {
3323
+ let r = t + n >> 1;
3324
+ this.idxs[r] < e ? t = r + 1 : n = r;
3325
+ }
3326
+ return t === 0 ? 0 : this.cumDelta[t - 1];
3327
+ }
3328
+ offsetOf(e) {
3329
+ return (e - 1) * this.defaultPx + this.deltaBefore(e);
3330
+ }
3331
+ indexAt(e) {
3332
+ if (e <= 0) return {
3333
+ index: 1,
3334
+ partial: 0
3335
+ };
3336
+ let t = 1, n = this.maxIndex;
3337
+ for (; t < n;) {
3338
+ let r = t + n + 1 >> 1;
3339
+ this.offsetOf(r) <= e ? t = r : n = r - 1;
3340
+ }
3341
+ return {
3342
+ index: t,
3343
+ partial: e - this.offsetOf(t)
3344
+ };
3345
+ }
3346
+ scrollableIndexAt(e, t) {
3347
+ let n = e + this.offsetOf(t);
3348
+ return n >= this.offsetOf(this.maxIndex) + this.sizeOf(this.maxIndex) ? null : this.indexAt(n).index;
3349
+ }
3350
+ sizeOf(e) {
3351
+ return this.offsetOf(e + 1) - this.offsetOf(e);
3352
+ }
3353
+ }, Br = "#1a73e8", Vr = 4, Hr = 5;
3354
+ function Ur(e, t, n, r) {
3355
+ for (let { index: i, edge: a } of t) if (!(a <= r) && Math.abs(e - a) <= n) return i;
3356
+ return null;
3357
+ }
3358
+ function Wr(e) {
3359
+ return {
3360
+ border: `2px solid ${e}`,
3361
+ background: `color-mix(in srgb, ${e} 8%, transparent)`
3362
+ };
3363
+ }
3364
+ var Gr = /* @__PURE__ */ new WeakMap();
3365
+ function Kr(e, t) {
3366
+ let n = Gr.get(e);
3367
+ if (n) return n;
3368
+ let r = {
3369
+ col: new zr(e.colWidths, Q(e.defaultColWidth, t), (e) => Q(e, t), 16384),
3370
+ row: new zr(e.rowHeights, $(e.defaultRowHeight), (e) => $(e), 1048576)
3371
+ };
3372
+ return Gr.set(e, r), r;
3373
+ }
3374
+ var qr = class {
3375
+ wb = null;
3376
+ wrapper;
3377
+ canvas;
3378
+ canvasArea;
3379
+ scrollHost;
3380
+ spacer;
3381
+ tabBar;
3382
+ tabStrip;
3383
+ navPrev;
3384
+ navNext;
3385
+ navGroup;
3386
+ tabs = [];
3387
+ tabColors = [];
3388
+ zoomSlider = null;
3389
+ zoomLabel = null;
3390
+ currentSheet = 0;
3391
+ _hiddenSheetMode;
3392
+ currentWorksheet = null;
3393
+ opts;
3394
+ _mode;
3395
+ _bitmapCtx = null;
3396
+ resizeObserver = null;
3397
+ _rafId = null;
3398
+ _renderSeq = 0;
3399
+ effectiveH = 0;
3400
+ anchorCell = null;
3401
+ activeCell = null;
3402
+ selectionMode = "cells";
3403
+ isSelecting = !1;
3404
+ selectionOverlay;
3405
+ keydownHandler = null;
3406
+ pendingTap = null;
3407
+ resizeDrag = null;
3408
+ commentPopup;
3409
+ commentMap = /* @__PURE__ */ new Map();
3410
+ commentPopupKey = null;
3411
+ commentPopupTimer = null;
3412
+ validationPanel;
3413
+ validationPanelKey = null;
3414
+ validationArrowRect = null;
3415
+ validationOutsideHandler = null;
3416
+ constructor(e, t = {}) {
3417
+ this.opts = t, this._mode = t.mode ?? "main", this._hiddenSheetMode = t.hiddenSheetMode ?? "show", this.wrapper = document.createElement("div"), this.wrapper.style.cssText = "position:relative;width:100%;height:100%;border:1px solid #c8ccd0;background:#fff;box-sizing:border-box;font-family:sans-serif;display:flex;flex-direction:column;", this.canvasArea = document.createElement("div"), this.canvasArea.style.cssText = "position:relative;flex:1;min-height:0;overflow:hidden;", this.canvas = document.createElement("canvas"), this.canvas.style.cssText = "position:absolute;top:0;left:0;z-index:0;display:block;", this._mode === "worker" && (this._bitmapCtx = this.canvas.getContext("bitmaprenderer")), this.selectionOverlay = document.createElement("div"), this.selectionOverlay.style.cssText = "position:absolute;top:0;left:0;z-index:1;pointer-events:none;overflow:hidden;width:100%;height:100%;", this.scrollHost = document.createElement("div"), this.scrollHost.style.cssText = "position:absolute;inset:0;overflow:auto;z-index:2;background:transparent;", this.spacer = document.createElement("div"), this.spacer.style.cssText = "position:absolute;top:0;left:0;pointer-events:none;", this.scrollHost.appendChild(this.spacer), this.commentPopup = document.createElement("div"), this.commentPopup.style.cssText = `position:absolute;z-index:3;pointer-events:none;display:none;max-width:${kr}px;max-height:${Ar}px;overflow:hidden;box-sizing:border-box;padding:6px 8px;background:#fffbcc;border:1px solid #b8b8a0;box-shadow:1px 2px 5px rgba(0,0,0,0.25);font:12px/1.4 sans-serif;color:#222;white-space:pre-wrap;word-break:break-word;`, this.validationPanel = document.createElement("div"), this.validationPanel.setAttribute("data-xlsx-validation-panel", ""), this.validationPanel.style.cssText = `position:absolute;z-index:4;pointer-events:auto;display:none;min-width:80px;max-width:${jr}px;max-height:${Mr}px;overflow-y:auto;box-sizing:border-box;background:#fff;border:1px solid #7f7f7f;box-shadow:1px 2px 5px rgba(0,0,0,0.25);font:12px/1.4 sans-serif;color:#222;`, this.validationPanel.addEventListener("wheel", (e) => e.stopPropagation()), this.canvasArea.appendChild(this.canvas), this.canvasArea.appendChild(this.selectionOverlay), this.canvasArea.appendChild(this.scrollHost), this.canvasArea.appendChild(this.commentPopup), this.canvasArea.appendChild(this.validationPanel);
3418
+ let n = Math.round(50 * (this.opts.cellScale ?? 1));
3419
+ this.tabBar = document.createElement("div"), this.tabBar.style.cssText = `display:flex;align-items:flex-end;height:${Nr}px;flex-shrink:0;background:#f0f0f0;border-top:1px solid #c8ccd0;`, this.navPrev = this.makeNavButton("◀", "Scroll tabs left", () => this.scrollTabs(-1)), this.navNext = this.makeNavButton("▶", "Scroll tabs right", () => this.scrollTabs(1)), this.navPrev.dataset.xlsxTabNav = "prev", this.navNext.dataset.xlsxTabNav = "next";
3420
+ let r = document.createElement("div");
3421
+ r.style.cssText = `display:flex;flex-shrink:0;width:${n}px;height:100%;`, r.appendChild(this.navPrev), r.appendChild(this.navNext), this.navGroup = r, this.tabStrip = document.createElement("div"), this.tabStrip.style.cssText = `position:relative;display:flex;align-items:flex-end;flex:1;min-width:0;height:100%;margin-left:${Pr}px;overflow-x:auto;overflow-y:hidden;gap:${Pr}px;scrollbar-width:none;`, this.tabStrip.classList.add("xlsx-tab-strip"), Rr(), this.tabStrip.addEventListener("scroll", () => this.updateNavButtons()), this.tabBar.appendChild(r), this.tabBar.appendChild(this.tabStrip), this.opts.showZoomSlider !== !1 && this.tabBar.appendChild(this.buildZoomControl()), this.wrapper.appendChild(this.canvasArea), this.wrapper.appendChild(this.tabBar), e.appendChild(this.wrapper), this.scrollHost.addEventListener("scroll", () => {
3422
+ this.pendingTap = null, this.hideCommentPopup(), this.hideValidationPanel(), this.scrollHost.clientWidth > 0 && (this.effectiveH = this.effectiveScrollLeft), this.scheduleRender(), this.updateSelectionOverlay();
3423
+ }), this.resizeObserver = new ResizeObserver(() => {
3424
+ this.reanchorHorizontalScroll(), this.scheduleRender(), this.updateSelectionOverlay(), this.updateNavButtons();
3425
+ }), this.resizeObserver.observe(this.canvasArea), this.setupSelectionEvents();
3426
+ }
3427
+ async load(e) {
3428
+ try {
3429
+ this.wb = await wr.load(e, {
3430
+ useGoogleFonts: this.opts.useGoogleFonts,
3431
+ maxZipEntryBytes: this.opts.maxZipEntryBytes,
3432
+ workerTimeoutMs: this.opts.workerTimeoutMs,
3433
+ wasmUrl: this.opts.wasmUrl,
3434
+ math: this.opts.math,
3435
+ mode: this._mode
3436
+ }), this.buildTabs(), this.opts.onReady?.(this.wb.sheetNames), await this.showSheet(this._initialSheet());
3437
+ } catch (e) {
3438
+ let t = e instanceof Error ? e : Error(String(e));
3439
+ if (this.opts.onError) {
3440
+ this.opts.onError(t);
3441
+ return;
3442
+ }
3443
+ throw t;
3444
+ }
3445
+ }
3446
+ get workbook() {
3447
+ if (!this.wb) throw Error("Workbook not loaded");
3448
+ return this.wb;
3449
+ }
3450
+ async showSheet(e) {
3451
+ this.currentSheet = e, this.scrollHost.scrollTop = 0, this.anchorCell = null, this.activeCell = null, this.selectionMode = "cells", this.hideCommentPopup(), this.hideValidationPanel(), this.updateSelectionOverlay(), this.updateTabActive(e), this.currentWorksheet = await this.workbook.getWorksheet(e), this.buildCommentMap(this.currentWorksheet), this.updateSpacerSize(this.currentWorksheet), this.resetHorizontalScroll(), await this.renderCurrentSheet(), this.opts.onSheetChange?.(e, this.workbook.sheetNames.length);
3452
+ }
3453
+ get isRtl() {
3454
+ return this.currentWorksheet?.rightToLeft === !0;
3455
+ }
3456
+ get maxScrollLeft() {
3457
+ return Math.max(0, this.scrollHost.scrollWidth - this.scrollHost.clientWidth);
3458
+ }
3459
+ get effectiveScrollLeft() {
3460
+ let e = this.scrollHost.scrollLeft;
3461
+ return this.isRtl ? this.maxScrollLeft - e : e;
3462
+ }
3463
+ screenX(e, t) {
3464
+ return this.isRtl ? Nt(e, t, this.canvasArea.clientWidth) : e;
3465
+ }
3466
+ resetHorizontalScroll() {
3467
+ this.effectiveH = 0, this.scrollHost.scrollLeft = this.isRtl ? this.maxScrollLeft : 0;
3468
+ }
3469
+ reanchorHorizontalScroll() {
3470
+ if (!this.isRtl || this.scrollHost.clientWidth === 0) return;
3471
+ let e = Math.max(0, this.maxScrollLeft - this.effectiveH);
3472
+ Math.abs(this.scrollHost.scrollLeft - e) > 1 && (this.scrollHost.scrollLeft = e);
3473
+ }
3474
+ get sheetIndex() {
3475
+ return this.currentSheet;
3476
+ }
3477
+ get sheetCount() {
3478
+ return this.wb?.sheetCount ?? 0;
3479
+ }
3480
+ async goToSheet(e) {
3481
+ this.sheetCount !== 0 && await this.showSheet(Math.max(0, Math.min(e, this.sheetCount - 1)));
3482
+ }
3483
+ async nextSheet() {
3484
+ await this.goToSheet(this._stepSheet(1));
3485
+ }
3486
+ async prevSheet() {
3487
+ await this.goToSheet(this._stepSheet(-1));
3488
+ }
3489
+ _stepSheet(e) {
3490
+ return this._hiddenSheetMode === "skip" && this.wb ? ee(this.currentSheet, e, (e) => this.wb.isHidden(e), this.sheetCount) : this.currentSheet + e;
3491
+ }
3492
+ _initialSheet() {
3493
+ return this._hiddenSheetMode === "skip" && this.wb ? z(0, (e) => this.wb.isHidden(e), this.sheetCount) : 0;
3494
+ }
3495
+ getCellAt(e, t) {
3496
+ let n = this.currentWorksheet;
3497
+ if (!n) return null;
3498
+ let r = this.opts.cellScale ?? 1, i = this.canvasArea.getBoundingClientRect(), a = this.screenX(e - i.left, 0) / r, o = (t - i.top) / r;
3499
+ if (a < 50 || o < 22) return null;
3500
+ let s = a - 50, c = o - 22, l = n.freezeRows ?? 0, u = n.freezeCols ?? 0, d = 0, f = [];
3501
+ for (let e = 1; e <= l; e++) {
3502
+ let t = $(n.rowHeights[e] ?? n.defaultRowHeight);
3503
+ f.push(t), d += t;
3504
+ }
3505
+ let p = 0, m = [];
3506
+ for (let e = 1; e <= u; e++) {
3507
+ let t = Q(n.colWidths[e] ?? n.defaultColWidth, Z(n));
3508
+ m.push(t), p += t;
3509
+ }
3510
+ let h;
3511
+ if (c < d) {
3512
+ h = -1;
3513
+ let e = 0;
3514
+ for (let t = 0; t < l; t++) if (e += f[t], c < e) {
3515
+ h = t + 1;
3516
+ break;
3517
+ }
3518
+ if (h === -1) return null;
3519
+ } else {
3520
+ let e = c - d + this.scrollHost.scrollTop / r, t = Kr(n, Z(n)).row.scrollableIndexAt(e, l + 1);
3521
+ if (t === null) return null;
3522
+ h = t;
3523
+ }
3524
+ let g;
3525
+ if (s < p) {
3526
+ g = -1;
3527
+ let e = 0;
3528
+ for (let t = 0; t < u; t++) if (e += m[t], s < e) {
3529
+ g = t + 1;
3530
+ break;
3531
+ }
3532
+ if (g === -1) return null;
3533
+ } else {
3534
+ let e = s - p + this.effectiveScrollLeft / r, t = Kr(n, Z(n)).col.scrollableIndexAt(e, u + 1);
3535
+ if (t === null) return null;
3536
+ g = t;
3537
+ }
3538
+ return {
3539
+ row: h,
3540
+ col: g
3541
+ };
3542
+ }
3543
+ getCellRect(e, t) {
3544
+ let n = this.currentWorksheet;
3545
+ if (!n) return null;
3546
+ let r = this.opts.cellScale ?? 1, i = Z(n), a = (e) => Math.round(e * r), o = (e) => a(Q(n.colWidths[e] ?? n.defaultColWidth, i)), s = (e) => a($(n.rowHeights[e] ?? n.defaultRowHeight)), c = n.freezeRows ?? 0, l = n.freezeCols ?? 0, u;
3547
+ if (t <= l) {
3548
+ let e = a(50);
3549
+ for (let n = 1; n < t; n++) e += o(n);
3550
+ u = e;
3551
+ } else {
3552
+ let e = 0;
3553
+ for (let t = 1; t <= l; t++) e += o(t);
3554
+ let s = a(50) + e, c = this.effectiveScrollLeft / r, d = Kr(n, i).col, { index: f, partial: p } = d.indexAt(c + d.offsetOf(l + 1)), m = s - p * r;
3555
+ if (t >= f) for (let e = f; e < t; e++) m += o(e);
3556
+ else for (let e = t; e < f; e++) m -= o(e);
3557
+ u = m;
3558
+ }
3559
+ let d;
3560
+ if (e <= c) {
3561
+ let t = a(22);
3562
+ for (let n = 1; n < e; n++) t += s(n);
3563
+ d = t;
3564
+ } else {
3565
+ let t = 0;
3566
+ for (let e = 1; e <= c; e++) t += s(e);
3567
+ let o = a(22) + t, l = this.scrollHost.scrollTop / r, u = Kr(n, i).row, { index: f, partial: p } = u.indexAt(l + u.offsetOf(c + 1)), m = o - p * r;
3568
+ if (e >= f) for (let t = f; t < e; t++) m += s(t);
3569
+ else for (let t = e; t < f; t++) m -= s(t);
3570
+ d = m;
3571
+ }
3572
+ return {
3573
+ x: u,
3574
+ y: d,
3575
+ w: o(t),
3576
+ h: s(e)
3577
+ };
3578
+ }
3579
+ get selection() {
3580
+ return !this.anchorCell || !this.activeCell ? null : {
3581
+ anchor: this.anchorCell,
3582
+ active: this.activeCell,
3583
+ mode: this.selectionMode
3584
+ };
3585
+ }
3586
+ select(e) {
3587
+ let t = Ct(e);
3588
+ t && (this.hideValidationPanel(), this.selectionMode = "cells", this.anchorCell = {
3589
+ row: t.row,
3590
+ col: t.col
3591
+ }, this.activeCell = {
3592
+ row: t.row,
3593
+ col: t.col
3594
+ }, this.updateSelectionOverlay(), this.renderCurrentSheet(), this.opts.onSelectionChange?.(this.selection));
3595
+ }
3596
+ getHeaderHit(e, t) {
3597
+ let n = this.currentWorksheet;
3598
+ if (!n) return null;
3599
+ let r = this.opts.cellScale ?? 1, i = this.canvasArea.getBoundingClientRect(), a = this.screenX(e - i.left, 0) / r, o = (t - i.top) / r, s = a < 50, c = o < 22;
3600
+ if (!s && !c) return null;
3601
+ if (s && c) return { kind: "corner" };
3602
+ let l = n.freezeRows ?? 0, u = n.freezeCols ?? 0;
3603
+ if (s) {
3604
+ let e = o - 22;
3605
+ if (e < 0) return { kind: "corner" };
3606
+ let t = 0, i = [];
3607
+ for (let e = 1; e <= l; e++) {
3608
+ let r = $(n.rowHeights[e] ?? n.defaultRowHeight);
3609
+ i.push(r), t += r;
3610
+ }
3611
+ if (e < t) {
3612
+ let t = 0;
3613
+ for (let n = 0; n < l; n++) if (t += i[n], e < t) return {
3614
+ kind: "row",
3615
+ row: n + 1
3616
+ };
3617
+ return null;
3618
+ }
3619
+ let a = e - t + this.scrollHost.scrollTop / r, s = Kr(n, Z(n)).row.scrollableIndexAt(a, l + 1);
3620
+ return s === null ? null : {
3621
+ kind: "row",
3622
+ row: s
3623
+ };
3624
+ }
3625
+ let d = a - 50;
3626
+ if (d < 0) return { kind: "corner" };
3627
+ let f = 0, p = [];
3628
+ for (let e = 1; e <= u; e++) {
3629
+ let t = Q(n.colWidths[e] ?? n.defaultColWidth, Z(n));
3630
+ p.push(t), f += t;
3631
+ }
3632
+ if (d < f) {
3633
+ let e = 0;
3634
+ for (let t = 0; t < u; t++) if (e += p[t], d < e) return {
3635
+ kind: "col",
3636
+ col: t + 1
3637
+ };
3638
+ return null;
3639
+ }
3640
+ let m = d - f + this.effectiveScrollLeft / r, h = Kr(n, Z(n)).col.scrollableIndexAt(m, u + 1);
3641
+ return h === null ? null : {
3642
+ kind: "col",
3643
+ col: h
3644
+ };
3645
+ }
3646
+ getResizeTarget(e, t) {
3647
+ let n = this.currentWorksheet;
3648
+ if (!n) return null;
3649
+ let r = this.opts.cellScale ?? 1, i = this.canvasArea.getBoundingClientRect(), a = this.screenX(e - i.left, 0), o = t - i.top, s = Math.round(50 * r), c = Math.round(22 * r), l = Z(n);
3650
+ if (o <= c && a > s) {
3651
+ let n = this.getHeaderHit(e, t);
3652
+ if (n?.kind !== "col") return null;
3653
+ let r = /* @__PURE__ */ new Map(), i = [];
3654
+ for (let e of [n.col - 1, n.col]) {
3655
+ if (e < 1) continue;
3656
+ let t = this.getCellRect(1, e);
3657
+ t && (r.set(e, t.x), i.push({
3658
+ index: e,
3659
+ edge: t.x + t.w
3660
+ }));
3661
+ }
3662
+ let o = Ur(a, i, Vr, s);
3663
+ return o === null ? null : {
3664
+ kind: "col",
3665
+ index: o,
3666
+ originScaled: r.get(o),
3667
+ mdw: l
3668
+ };
3669
+ }
3670
+ if (a <= s && o > c) {
3671
+ let n = this.getHeaderHit(e, t);
3672
+ if (n?.kind !== "row") return null;
3673
+ let r = /* @__PURE__ */ new Map(), i = [];
3674
+ for (let e of [n.row - 1, n.row]) {
3675
+ if (e < 1) continue;
3676
+ let t = this.getCellRect(e, 1);
3677
+ t && (r.set(e, t.y), i.push({
3678
+ index: e,
3679
+ edge: t.y + t.h
3680
+ }));
3681
+ }
3682
+ let a = Ur(o, i, Vr, c);
3683
+ return a === null ? null : {
3684
+ kind: "row",
3685
+ index: a,
3686
+ originScaled: r.get(a),
3687
+ mdw: l
3688
+ };
3689
+ }
3690
+ return null;
3691
+ }
3692
+ applyResize(e, t) {
3693
+ let n = this.resizeDrag, r = this.currentWorksheet;
3694
+ if (!n || !r) return;
3695
+ let i = this.opts.cellScale ?? 1, a = this.canvasArea.getBoundingClientRect();
3696
+ if (n.kind === "col") {
3697
+ let t = this.screenX(e - a.left, 0), o = Math.max(Hr, Math.round((t - n.originScaled) / i));
3698
+ r.colWidths[n.index] = Rt(o, n.mdw);
3699
+ } else {
3700
+ let e = t - a.top, o = Math.max(Hr, Math.round((e - n.originScaled) / i));
3701
+ r.rowHeights[n.index] = zt(o);
3702
+ }
3703
+ Gr.delete(r), this.updateSpacerSize(r), this.updateSelectionOverlay(), this.scheduleRender();
3704
+ }
3705
+ setSelectionColor(e) {
3706
+ this.opts.selectionColor = e, this.updateSelectionOverlay();
3707
+ }
3708
+ async setHiddenSheetMode(e) {
3709
+ this._hiddenSheetMode = e, this.buildTabs(), e === "skip" && this.wb && this.wb.isHidden(this.currentSheet) ? await this.showSheet(z(this.currentSheet, (e) => this.wb.isHidden(e), this.sheetCount)) : this.updateTabActive(this.currentSheet);
3710
+ }
3711
+ get hiddenSheetMode() {
3712
+ return this._hiddenSheetMode;
3713
+ }
3714
+ get visibleSheetCount() {
3715
+ if (!this.wb) return 0;
3716
+ let e = this.wb;
3717
+ return B((t) => e.isHidden(t), this.sheetCount);
3718
+ }
3719
+ copySelection() {
3720
+ let e = this.currentWorksheet;
3721
+ if (!e || !this.anchorCell || !this.activeCell) return;
3722
+ let t = 1, n = 1;
3723
+ for (let r of e.rows) {
3724
+ r.index > t && (t = r.index);
3725
+ for (let e of r.cells) e.col > n && (n = e.col);
3726
+ }
3727
+ let r, i, a, o;
3728
+ this.selectionMode === "all" ? (r = 1, i = t, a = 1, o = n) : this.selectionMode === "rows" ? (r = Math.min(this.anchorCell.row, this.activeCell.row), i = Math.max(this.anchorCell.row, this.activeCell.row), a = 1, o = n) : this.selectionMode === "cols" ? (a = Math.min(this.anchorCell.col, this.activeCell.col), o = Math.max(this.anchorCell.col, this.activeCell.col), r = 1, i = t) : (r = Math.min(this.anchorCell.row, this.activeCell.row), i = Math.max(this.anchorCell.row, this.activeCell.row), a = Math.min(this.anchorCell.col, this.activeCell.col), o = Math.max(this.anchorCell.col, this.activeCell.col));
3729
+ let s = /* @__PURE__ */ new Map();
3730
+ for (let t of e.rows) if (!(t.index < r || t.index > i)) for (let e of t.cells) {
3731
+ if (e.col < a || e.col > o) continue;
3732
+ let n = e.value, r = "";
3733
+ n.type === "text" ? r = n.runs ? n.runs.map((e) => e.text).join("") : n.text : n.type === "number" ? r = String(n.number) : n.type === "bool" ? r = n.bool ? "TRUE" : "FALSE" : n.type === "error" && (r = n.error), r && s.set(`${t.index}:${e.col}`, r);
3734
+ }
3735
+ let c = [];
3736
+ for (let e = r; e <= i; e++) {
3737
+ let t = [];
3738
+ for (let n = a; n <= o; n++) t.push(s.get(`${e}:${n}`) ?? "");
3739
+ c.push(t.join(" "));
3740
+ }
3741
+ navigator.clipboard.writeText(c.join("\n")).catch(() => void 0);
3742
+ }
3743
+ updateSelectionOverlay() {
3744
+ if (this.selectionOverlay.innerHTML = "", !this.anchorCell || !this.activeCell) return;
3745
+ let e = this.opts.cellScale ?? 1, t = this.currentWorksheet, n = t?.freezeRows ?? 0, r = t?.freezeCols ?? 0, i = (t) => Math.round(t * e), a = i(50), o = i(22), s = 0;
3746
+ if (t) for (let e = 1; e <= n; e++) s += i($(t.rowHeights[e] ?? t.defaultRowHeight));
3747
+ let c = 0;
3748
+ if (t) for (let e = 1; e <= r; e++) c += i(Q(t.colWidths[e] ?? t.defaultColWidth, Z(t)));
3749
+ let l, u, d, f, p = 1, m = 1;
3750
+ if (this.selectionMode === "all") l = a, u = o, d = this.canvasArea.clientWidth - a, f = this.canvasArea.clientHeight - o;
3751
+ else if (this.selectionMode === "rows") {
3752
+ p = Math.min(this.anchorCell.row, this.activeCell.row);
3753
+ let e = Math.max(this.anchorCell.row, this.activeCell.row), t = this.getCellRect(p, 1), n = this.getCellRect(e, 1);
3754
+ if (!t || !n) return;
3755
+ l = a, u = t.y, d = this.canvasArea.clientWidth - a, f = n.y + n.h - t.y;
3756
+ } else if (this.selectionMode === "cols") {
3757
+ m = Math.min(this.anchorCell.col, this.activeCell.col);
3758
+ let e = Math.max(this.anchorCell.col, this.activeCell.col), t = this.getCellRect(1, m), n = this.getCellRect(1, e);
3759
+ if (!t || !n) return;
3760
+ l = t.x, u = o, d = n.x + n.w - t.x, f = this.canvasArea.clientHeight - o;
3761
+ } else {
3762
+ p = Math.min(this.anchorCell.row, this.activeCell.row);
3763
+ let e = Math.max(this.anchorCell.row, this.activeCell.row);
3764
+ m = Math.min(this.anchorCell.col, this.activeCell.col);
3765
+ let t = Math.max(this.anchorCell.col, this.activeCell.col), n = this.getCellRect(p, m), r = this.getCellRect(e, t);
3766
+ if (!n || !r) return;
3767
+ l = n.x, u = n.y, d = r.x + r.w - n.x, f = r.y + r.h - n.y;
3768
+ }
3769
+ l < a && (d -= a - l, l = a), u < o && (f -= o - u, u = o);
3770
+ let h = a + c, g = o + s;
3771
+ if (m > r && l < h && (d -= h - l, l = h), p > n && u < g && (f -= g - u, u = g), d <= 0 || f <= 0) return;
3772
+ let _ = this.screenX(l, d), { border: v, background: y } = Wr(this.opts.selectionColor ?? Br), b = document.createElement("div");
3773
+ b.style.cssText = `position:absolute;left:${_}px;top:${u}px;width:${d}px;height:${f}px;box-sizing:border-box;border:${v};background:${y};pointer-events:none;`, this.selectionOverlay.appendChild(b), this.maybeDrawValidationDropdown();
3774
+ }
3775
+ maybeDrawValidationDropdown() {
3776
+ if (this.validationArrowRect = null, this.selectionMode !== "cells") return;
3777
+ let e = this.currentWorksheet, t = this.activeCell;
3778
+ if (!e || !t || !Er(e.dataValidations, t.row, t.col)) return;
3779
+ let n = this.getCellRect(t.row, t.col);
3780
+ if (!n) return;
3781
+ let r = this.opts.cellScale ?? 1, i = Math.round(50 * r), a = Math.round(22 * r), o = Math.max(14, Math.min(n.h, 22 * r)), s = n.x + n.w, c = n.y;
3782
+ if (s + o <= i || c + o <= a) return;
3783
+ let l = this.screenX(s, o), u = document.createElement("div");
3784
+ u.setAttribute("data-xlsx-validation-dropdown", ""), u.style.cssText = `position:absolute;left:${l}px;top:${c}px;width:${o}px;height:${o}px;box-sizing:border-box;display:flex;align-items:center;justify-content:center;background:#f0f0f0;border:1px solid #7f7f7f;pointer-events:none;`;
3785
+ let d = Math.max(4, Math.round(o * .42));
3786
+ u.innerHTML = `<svg width="${d}" height="${d}" viewBox="0 0 10 6" aria-hidden="true"><path d="M0 0 L10 0 L5 6 Z" fill="#333"/></svg>`, this.selectionOverlay.appendChild(u), this.validationArrowRect = {
3787
+ x: l,
3788
+ y: c,
3789
+ w: o,
3790
+ h: o
3791
+ }, this.validationPanel.style.display !== "none" && (this.validationPanelKey === `${t.row}:${t.col}` ? this.positionValidationPanel() : this.hideValidationPanel());
3792
+ }
3793
+ toggleValidationPanel() {
3794
+ let e = this.currentWorksheet, t = this.activeCell;
3795
+ if (!e || !t) return;
3796
+ let n = `${t.row}:${t.col}`;
3797
+ if (this.validationPanelKey === n && this.validationPanel.style.display !== "none") {
3798
+ this.hideValidationPanel();
3799
+ return;
3800
+ }
3801
+ let r = Er(e.dataValidations, t.row, t.col);
3802
+ r && this.openValidationPanel(t, r.formula1);
3803
+ }
3804
+ async openValidationPanel(e, t) {
3805
+ let n;
3806
+ try {
3807
+ n = await this.workbook.resolveValidationList(this.currentSheet, t);
3808
+ } catch {
3809
+ n = {
3810
+ kind: "formula",
3811
+ formula: t ?? ""
3812
+ };
3813
+ }
3814
+ let r = this.activeCell;
3815
+ !r || r.row !== e.row || r.col !== e.col || (this.validationPanelKey = `${e.row}:${e.col}`, this.renderValidationPanel(n), this.positionValidationPanel(), this.installValidationOutsideHandler());
3816
+ }
3817
+ renderValidationPanel(e) {
3818
+ let t = this.validationPanel;
3819
+ if (t.textContent = "", e.kind === "formula" || e.values.length === 0) {
3820
+ let n = document.createElement("div");
3821
+ n.style.cssText = "padding:4px 8px;color:#666;font-style:italic;white-space:pre-wrap;word-break:break-word;", n.textContent = e.kind === "formula" ? e.formula ? `= ${e.formula}` : "(no list)" : "(empty list)", t.appendChild(n);
3822
+ return;
3823
+ }
3824
+ for (let n of e.values) {
3825
+ let e = document.createElement("div");
3826
+ e.setAttribute("data-xlsx-validation-item", ""), e.style.cssText = "padding:3px 8px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:default;", e.textContent = n, e.addEventListener("pointerenter", () => {
3827
+ e.style.background = "#cfe3ff";
3828
+ }), e.addEventListener("pointerleave", () => {
3829
+ e.style.background = "";
3830
+ }), t.appendChild(e);
3831
+ }
3832
+ }
3833
+ positionValidationPanel() {
3834
+ let e = this.activeCell;
3835
+ if (!e) return;
3836
+ let t = this.getCellRect(e.row, e.col);
3837
+ if (!t) return;
3838
+ let n = this.screenX(t.x, t.w);
3839
+ this.validationPanel.style.left = "-9999px", this.validationPanel.style.top = "-9999px", this.validationPanel.style.display = "block";
3840
+ let r = Cr({
3841
+ cell: {
3842
+ x: n,
3843
+ y: t.y,
3844
+ w: t.w,
3845
+ h: t.h
3846
+ },
3847
+ panel: {
3848
+ w: this.validationPanel.offsetWidth,
3849
+ h: this.validationPanel.offsetHeight
3850
+ },
3851
+ viewport: {
3852
+ w: this.canvasArea.clientWidth,
3853
+ h: this.canvasArea.clientHeight
3854
+ },
3855
+ rtl: this.isRtl
3856
+ });
3857
+ this.validationPanel.style.left = `${r.left}px`, this.validationPanel.style.top = `${r.top}px`;
3858
+ }
3859
+ installValidationOutsideHandler() {
3860
+ this.validationOutsideHandler || (this.validationOutsideHandler = (e) => {
3861
+ let t = e.target;
3862
+ if (t && this.validationPanel.contains(t)) return;
3863
+ let n = this.canvasArea.getBoundingClientRect(), r = e.clientX - n.left, i = e.clientY - n.top, a = this.validationArrowRect;
3864
+ a && r >= a.x && r <= a.x + a.w && i >= a.y && i <= a.y + a.h || this.hideValidationPanel();
3865
+ }, document.addEventListener("pointerdown", this.validationOutsideHandler, !0));
3866
+ }
3867
+ hideValidationPanel() {
3868
+ this.validationPanel.style.display = "none", this.validationPanelKey = null, this.validationOutsideHandler &&= (document.removeEventListener("pointerdown", this.validationOutsideHandler, !0), null);
3869
+ }
3870
+ buildCommentMap(e) {
3871
+ this.commentMap = /* @__PURE__ */ new Map();
3872
+ for (let t of e.comments ?? []) {
3873
+ let e = Ct(t.cellRef);
3874
+ e && this.commentMap.set(`${e.row}:${e.col}`, t);
3875
+ }
3876
+ }
3877
+ scheduleCommentPopup(e) {
3878
+ let t = `${e.row}:${e.col}`, n = this.commentMap.get(t);
3879
+ if (!n) {
3880
+ this.hideCommentPopup();
3881
+ return;
3882
+ }
3883
+ this.commentPopupKey !== t && (this.hideCommentPopup(), this.commentPopupKey = t, this.commentPopupTimer = setTimeout(() => {
3884
+ this.commentPopupTimer = null, this.renderCommentPopup(e, n);
3885
+ }, Or));
3886
+ }
3887
+ renderCommentPopup(e, t) {
3888
+ let n = this.getCellRect(e.row, e.col);
3889
+ if (!n) return;
3890
+ if (this.commentPopup.textContent = "", t.author) {
3891
+ let e = document.createElement("div");
3892
+ e.style.cssText = "font-weight:bold;margin-bottom:2px;", e.textContent = t.author, this.commentPopup.appendChild(e);
3893
+ }
3894
+ let r = document.createElement("div");
3895
+ r.textContent = t.text, this.commentPopup.appendChild(r);
3896
+ let i = this.screenX(n.x, n.w);
3897
+ this.commentPopup.style.left = "-9999px", this.commentPopup.style.top = "-9999px", this.commentPopup.style.display = "block";
3898
+ let a = Dr({
3899
+ cell: {
3900
+ x: i,
3901
+ y: n.y,
3902
+ w: n.w,
3903
+ h: n.h
3904
+ },
3905
+ popup: {
3906
+ w: this.commentPopup.offsetWidth,
3907
+ h: this.commentPopup.offsetHeight
3908
+ },
3909
+ viewport: {
3910
+ w: this.canvasArea.clientWidth,
3911
+ h: this.canvasArea.clientHeight
3912
+ },
3913
+ rtl: this.isRtl
3914
+ });
3915
+ this.commentPopup.style.left = `${a.left}px`, this.commentPopup.style.top = `${a.top}px`;
3916
+ }
3917
+ hideCommentPopup() {
3918
+ this.commentPopupTimer !== null && (clearTimeout(this.commentPopupTimer), this.commentPopupTimer = null), this.commentPopupKey = null, this.commentPopup.style.display = "none";
3919
+ }
3920
+ applyPointerSelection(e, t, n, r, i) {
3921
+ let a = this.getHeaderHit(e, t);
3922
+ if (a) {
3923
+ a.kind === "corner" ? (this.selectionMode = "all", this.anchorCell = {
3924
+ row: 1,
3925
+ col: 1
3926
+ }, this.activeCell = {
3927
+ row: 1,
3928
+ col: 1
3929
+ }, this.isSelecting = !1) : a.kind === "row" ? n && this.anchorCell && this.selectionMode === "rows" ? this.activeCell = {
3930
+ row: a.row,
3931
+ col: 1
3932
+ } : (this.selectionMode = "rows", this.anchorCell = {
3933
+ row: a.row,
3934
+ col: 1
3935
+ }, this.activeCell = {
3936
+ row: a.row,
3937
+ col: 1
3938
+ }, i && (this.isSelecting = !0, this.scrollHost.setPointerCapture(r))) : n && this.anchorCell && this.selectionMode === "cols" ? this.activeCell = {
3939
+ row: 1,
3940
+ col: a.col
3941
+ } : (this.selectionMode = "cols", this.anchorCell = {
3942
+ row: 1,
3943
+ col: a.col
3944
+ }, this.activeCell = {
3945
+ row: 1,
3946
+ col: a.col
3947
+ }, i && (this.isSelecting = !0, this.scrollHost.setPointerCapture(r))), this.updateSelectionOverlay(), this.renderCurrentSheet(), this.opts.onSelectionChange?.(this.selection);
3948
+ return;
3949
+ }
3950
+ let o = this.getCellAt(e, t);
3951
+ o && (n && this.anchorCell && this.selectionMode === "cells" ? this.activeCell = o : (this.selectionMode = "cells", this.anchorCell = o, this.activeCell = o), i && (this.isSelecting = !0, this.scrollHost.setPointerCapture(r)), this.updateSelectionOverlay(), this.renderCurrentSheet(), this.opts.onSelectionChange?.(this.selection));
3952
+ }
3953
+ setupSelectionEvents() {
3954
+ this.scrollHost.addEventListener("pointerdown", (e) => {
3955
+ if (e.button !== 0) return;
3956
+ let t = this.opts.resizable ?? !0 ? this.getResizeTarget(e.clientX, e.clientY) : null;
3957
+ if (t) {
3958
+ e.preventDefault(), this.resizeDrag = {
3959
+ ...t,
3960
+ pointerId: e.pointerId
3961
+ }, this.scrollHost.setPointerCapture(e.pointerId), this.hideCommentPopup();
3962
+ return;
3963
+ }
3964
+ let n = this.validationArrowRect;
3965
+ if (n) {
3966
+ let t = this.canvasArea.getBoundingClientRect(), r = e.clientX - t.left, i = e.clientY - t.top;
3967
+ if (r >= n.x && r <= n.x + n.w && i >= n.y && i <= n.y + n.h) {
3968
+ e.preventDefault(), this.toggleValidationPanel();
3969
+ return;
3970
+ }
3971
+ }
3972
+ let r = this.scrollHost.getBoundingClientRect(), i = e.clientX - r.left - this.scrollHost.clientLeft, a = e.clientY - r.top - this.scrollHost.clientTop;
3973
+ if (i >= this.scrollHost.clientWidth || a >= this.scrollHost.clientHeight) return;
3974
+ let o = this.scrollHost.scrollWidth > this.scrollHost.clientWidth && this.scrollHost.clientHeight - a <= 16 || this.scrollHost.scrollHeight > this.scrollHost.clientHeight && this.scrollHost.clientWidth - i <= 16;
3975
+ if (e.pointerType !== "mouse" || o) {
3976
+ this.pendingTap = {
3977
+ x: e.clientX,
3978
+ y: e.clientY,
3979
+ shiftKey: e.shiftKey,
3980
+ pointerId: e.pointerId
3981
+ };
3982
+ return;
3983
+ }
3984
+ this.applyPointerSelection(e.clientX, e.clientY, e.shiftKey, e.pointerId, !0);
3985
+ }), this.scrollHost.addEventListener("pointermove", (e) => {
3986
+ if (this.resizeDrag && this.resizeDrag.pointerId === e.pointerId) {
3987
+ e.preventDefault(), this.applyResize(e.clientX, e.clientY);
3988
+ return;
3989
+ }
3990
+ if (e.pointerType === "mouse" && !this.isSelecting && (this.opts.resizable ?? !0)) {
3991
+ let t = this.getResizeTarget(e.clientX, e.clientY);
3992
+ if (this.scrollHost.style.cursor = t ? t.kind === "col" ? "col-resize" : "row-resize" : "", t) {
3993
+ this.hideCommentPopup();
3994
+ return;
3995
+ }
3996
+ }
3997
+ if (this.pendingTap && this.pendingTap.pointerId === e.pointerId) {
3998
+ let t = e.clientX - this.pendingTap.x, n = e.clientY - this.pendingTap.y;
3999
+ t * t + n * n > 64 && (this.pendingTap = null);
4000
+ }
4001
+ if (e.pointerType === "mouse" && !this.isSelecting) {
4002
+ let t = this.getCellAt(e.clientX, e.clientY);
4003
+ t ? this.scheduleCommentPopup(t) : this.hideCommentPopup();
4004
+ }
4005
+ if (this.isSelecting) {
4006
+ if (this.selectionMode === "rows") {
4007
+ let t = this.getHeaderHit(e.clientX, e.clientY), n = t?.kind === "row" ? t.row : this.getCellAt(e.clientX, e.clientY)?.row;
4008
+ if (!n || n === this.activeCell?.row) return;
4009
+ this.activeCell = {
4010
+ row: n,
4011
+ col: 1
4012
+ };
4013
+ } else if (this.selectionMode === "cols") {
4014
+ let t = this.getHeaderHit(e.clientX, e.clientY), n = t?.kind === "col" ? t.col : this.getCellAt(e.clientX, e.clientY)?.col;
4015
+ if (!n || n === this.activeCell?.col) return;
4016
+ this.activeCell = {
4017
+ row: 1,
4018
+ col: n
4019
+ };
4020
+ } else {
4021
+ let t = this.getCellAt(e.clientX, e.clientY);
4022
+ if (!t || t.row === this.activeCell?.row && t.col === this.activeCell?.col) return;
4023
+ this.activeCell = t;
4024
+ }
4025
+ this.updateSelectionOverlay(), this.scheduleRender(), this.opts.onSelectionChange?.(this.selection);
4026
+ }
4027
+ }), this.scrollHost.addEventListener("pointerup", (e) => {
4028
+ if (this.resizeDrag && this.resizeDrag.pointerId === e.pointerId) {
4029
+ this.scrollHost.releasePointerCapture(e.pointerId), this.resizeDrag = null;
4030
+ return;
4031
+ }
4032
+ if (this.pendingTap && this.pendingTap.pointerId === e.pointerId) {
4033
+ let t = e.clientX - this.pendingTap.x, n = e.clientY - this.pendingTap.y;
4034
+ if (t * t + n * n <= 64 && (this.applyPointerSelection(e.clientX, e.clientY, this.pendingTap.shiftKey, e.pointerId, !1), e.pointerType !== "mouse" && this.activeCell)) {
4035
+ let e = `${this.activeCell.row}:${this.activeCell.col}`, t = this.commentMap.get(e);
4036
+ t ? (this.hideCommentPopup(), this.renderCommentPopup(this.activeCell, t)) : this.hideCommentPopup();
4037
+ }
4038
+ this.pendingTap = null;
4039
+ }
4040
+ this.isSelecting = !1;
4041
+ }), this.scrollHost.addEventListener("pointercancel", (e) => {
4042
+ this.resizeDrag && this.resizeDrag.pointerId === e.pointerId && (this.resizeDrag = null), this.pendingTap && this.pendingTap.pointerId === e.pointerId && (this.pendingTap = null), this.isSelecting = !1;
4043
+ }), this.scrollHost.addEventListener("wheel", (e) => {
4044
+ (e.ctrlKey || e.metaKey) && (e.preventDefault(), e.deltaY !== 0 && this.setScale(j(this.opts.cellScale ?? 1, e.deltaY)));
4045
+ }, { passive: !1 }), this.scrollHost.addEventListener("pointerleave", () => this.hideCommentPopup()), this.keydownHandler = (e) => {
4046
+ (e.ctrlKey || e.metaKey) && e.key === "c" ? this.copySelection() : e.key === "Escape" && this.validationPanel.style.display !== "none" && this.hideValidationPanel();
4047
+ }, document.addEventListener("keydown", this.keydownHandler);
4048
+ }
4049
+ buildTabs() {
4050
+ this.tabStrip.innerHTML = "", this.tabs = [], this.tabColors = this.workbook.tabColors, this.workbook.sheetNames.forEach((e, t) => {
4051
+ let n = document.createElement("button");
4052
+ n.textContent = e, n.title = e, n.style.cssText = this.tabCss(t, !1), n.addEventListener("click", () => this.showSheet(t)), this.tabStrip.appendChild(n), this.tabs.push(n);
4053
+ }), this.updateNavButtons();
4054
+ }
4055
+ makeNavButton(e, t, n) {
4056
+ let r = document.createElement("button");
4057
+ return r.textContent = e, r.setAttribute("aria-label", t), r.title = t, r.classList.add("xlsx-tab-nav"), r.style.cssText = this.navButtonStyle(!1), r.addEventListener("click", n), r;
4058
+ }
4059
+ navButtonStyle(e) {
4060
+ return e ? "flex:1;height:100%;padding:0;display:flex;align-items:center;justify-content:center;border:none;color:#666;font-size:9px;line-height:1;box-sizing:border-box;outline:none;opacity:0.3;cursor:default;pointer-events:none;" : "flex:1;height:100%;padding:0;display:flex;align-items:center;justify-content:center;border:none;color:#666;font-size:9px;line-height:1;box-sizing:border-box;outline:none;cursor:pointer;";
4061
+ }
4062
+ scrollTabs(e) {
4063
+ let t = this.tabStrip, n = t.scrollLeft, r = n + t.clientWidth, i = null;
4064
+ if (e === 1) for (let e of this.tabs) {
4065
+ let n = e.offsetLeft + e.offsetWidth;
4066
+ if (n > r + 1) {
4067
+ i = n - t.clientWidth;
4068
+ break;
4069
+ }
4070
+ }
4071
+ else for (let e = this.tabs.length - 1; e >= 0; e--) {
4072
+ let t = this.tabs[e].offsetLeft;
4073
+ if (t < n - 1) {
4074
+ i = t;
4075
+ break;
4076
+ }
4077
+ }
4078
+ i !== null && (t.scrollLeft = Math.max(0, i)), this.updateNavButtons();
4079
+ }
4080
+ updateNavButtons() {
4081
+ let e = this.tabStrip, t = e.scrollLeft <= 0, n = e.scrollLeft + e.clientWidth >= e.scrollWidth - 1;
4082
+ this.navPrev.style.cssText = this.navButtonStyle(t), this.navNext.style.cssText = this.navButtonStyle(n);
4083
+ }
4084
+ updateTabActive(e) {
4085
+ this.tabs.forEach((t, n) => {
4086
+ t.style.cssText = this.tabCss(n, n === e);
4087
+ });
4088
+ let t = this.tabs[e];
4089
+ if (t && t.offsetParent !== null) {
4090
+ let e = this.tabStrip, n = t.getBoundingClientRect(), r = e.getBoundingClientRect();
4091
+ n.left < r.left ? e.scrollLeft -= r.left - n.left : n.right > r.right && (e.scrollLeft += n.right - r.right);
4092
+ }
4093
+ }
4094
+ tabStyle(e, t) {
4095
+ let n = Nr - 2, r = Nr - 5, i = t ? `box-shadow:inset 0 -${e ? 2 : 3}px 0 0 ${t};` : "";
4096
+ return e ? `display:inline-block;flex:none;padding:0 14px;position:relative;border:1px solid #c8ccd0;border-bottom:none;border-radius:3px 3px 0 0;cursor:pointer;white-space:nowrap;max-width:160px;overflow:hidden;text-overflow:ellipsis;outline:none;box-sizing:border-box;height:${n}px;font-size:13px;background:#fff;color:#000;border-bottom:1px solid #fff;font-weight:600;top:1px;` + i : `display:inline-block;flex:none;padding:0 14px;position:relative;border:1px solid #c8ccd0;border-bottom:none;border-radius:3px 3px 0 0;cursor:pointer;white-space:nowrap;max-width:160px;overflow:hidden;text-overflow:ellipsis;outline:none;box-sizing:border-box;height:${r}px;font-size:11px;background:#e0e0e0;color:#555;` + i;
4097
+ }
4098
+ tabCss(e, t) {
4099
+ let n = this.tabStyle(t, this.tabColors[e]);
4100
+ return this._hiddenSheetMode !== "show" && this.wb?.isHidden(e) && (n += this._hiddenSheetMode === "skip" ? "display:none;" : `opacity:${Fr};`), n;
4101
+ }
4102
+ buildZoomControl() {
4103
+ let e = this.opts.zoomMin ?? .1, t = this.opts.zoomMax ?? 4, n = this.opts.cellScale ?? 1, r = document.createElement("div");
4104
+ r.style.cssText = "display:flex;align-items:center;flex-shrink:0;gap:2px;padding:0 10px;height:100%;color:#555;font-size:12px;user-select:none;";
4105
+ let i = (e, t, n) => {
4106
+ let r = document.createElement("button");
4107
+ return r.textContent = e, r.setAttribute("aria-label", t), r.title = t, r.style.cssText = "width:18px;height:18px;padding:0;border:none;background:transparent;color:#555;font-size:14px;line-height:1;cursor:pointer;border-radius:3px;", r.addEventListener("click", () => this.setScale((this.opts.cellScale ?? 1) + n)), r;
4108
+ }, a = document.createElement("input");
4109
+ a.type = "range", a.min = "0", a.max = "100", a.step = "any", a.value = String(this.zoomScaleToPos(n, e, t)), a.setAttribute("aria-label", "Zoom"), a.title = "Zoom", a.classList.add("xlsx-zoom-slider"), a.style.cssText = "width:90px;cursor:pointer;", a.addEventListener("input", () => this.setScale(this.zoomPosToScale(Number(a.value), e, t)));
4110
+ let o = document.createElement("span");
4111
+ return o.textContent = `${Math.round(n * 100)}%`, o.style.cssText = "min-width:42px;margin-left:6px;text-align:right;font-variant-numeric:tabular-nums;", r.appendChild(i("−", "Zoom out", -.1)), r.appendChild(a), r.appendChild(i("+", "Zoom in", .1)), r.appendChild(o), this.zoomSlider = a, this.zoomLabel = o, r;
4112
+ }
4113
+ zoomPosToScale(e, t, n) {
4114
+ return e <= 50 ? t + e / 50 * (1 - t) : 1 + (e - 50) / 50 * (n - 1);
4115
+ }
4116
+ zoomScaleToPos(e, t, n) {
4117
+ let r = Math.min(n, Math.max(t, e));
4118
+ return r <= 1 ? (r - t) / (1 - t) * 50 : 50 + (r - 1) / (n - 1) * 50;
4119
+ }
4120
+ setScale(e) {
4121
+ let t = this.opts.zoomMin ?? .1, n = this.opts.zoomMax ?? 4, r = Math.min(Math.round(n * 100), Math.max(Math.round(t * 100), Math.round(e * 100))), i = r / 100;
4122
+ if (i !== (this.opts.cellScale ?? 1)) {
4123
+ if (this.opts.cellScale = i, this.zoomSlider && (this.zoomSlider.value = String(this.zoomScaleToPos(i, t, n))), this.zoomLabel && (this.zoomLabel.textContent = `${r}%`), this.navGroup.style.width = `${Math.round(50 * i)}px`, this.currentWorksheet) {
4124
+ let e = this.effectiveScrollLeft;
4125
+ this.updateSpacerSize(this.currentWorksheet), this.effectiveH = e, this.isRtl && (this.scrollHost.scrollLeft = Math.max(0, this.maxScrollLeft - e));
4126
+ }
4127
+ this.renderCurrentSheet(), this.updateSelectionOverlay(), this.updateNavButtons();
4128
+ }
4129
+ }
4130
+ updateSpacerSize(e) {
4131
+ let t = this.opts.cellScale ?? 1, n = Z(e), r = (e) => Math.round(e * t), i = e.freezeRows ?? 0, a = e.freezeCols ?? 0, o = Math.max(50, i), s = Math.max(26, a);
4132
+ for (let t of e.rows) {
4133
+ t.index > o && (o = t.index);
4134
+ for (let e of t.cells) e.col > s && (s = e.col);
4135
+ }
4136
+ o += 30, s += 10;
4137
+ let c = r(50);
4138
+ for (let t = 1; t <= s; t++) c += r(Q(e.colWidths[t] ?? e.defaultColWidth, n));
4139
+ let l = r(22);
4140
+ for (let t = 1; t <= o; t++) l += r($(e.rowHeights[t] ?? e.defaultRowHeight));
4141
+ this.spacer.style.width = `${c}px`, this.spacer.style.height = `${l}px`;
4142
+ }
4143
+ scheduleRender() {
4144
+ if (this._rafId === null) {
4145
+ if (typeof requestAnimationFrame != "function") {
4146
+ this.renderCurrentSheet();
4147
+ return;
4148
+ }
4149
+ this._rafId = requestAnimationFrame(() => {
4150
+ this._rafId = null, this.renderCurrentSheet();
4151
+ });
4152
+ }
4153
+ }
4154
+ async renderCurrentSheet() {
4155
+ if (!this.currentWorksheet) return;
4156
+ let e = this.currentWorksheet, t = this.canvasArea.clientWidth, n = this.canvasArea.clientHeight;
4157
+ if (t <= 0 || n <= 0) return;
4158
+ let r = ++this._renderSeq, i = this.opts.cellScale ?? 1, a = window.devicePixelRatio ?? 1, o = e.freezeRows ?? 0, s = e.freezeCols ?? 0, c = 0;
4159
+ for (let t = 1; t <= s; t++) c += Q(e.colWidths[t] ?? e.defaultColWidth, Z(e));
4160
+ let l = 0;
4161
+ for (let t = 1; t <= o; t++) l += $(e.rowHeights[t] ?? e.defaultRowHeight);
4162
+ let u = this.effectiveScrollLeft / i, d = this.scrollHost.scrollTop / i, f = Kr(e, Z(e)), { index: p, partial: m } = f.col.indexAt(u + f.col.offsetOf(s + 1)), { index: h, partial: g } = f.row.indexAt(d + f.row.offsetOf(o + 1)), _ = t / i - 50 - c, v = n / i - 22 - l, y = 0;
4163
+ {
4164
+ let t = -m, n = p;
4165
+ for (; t < _ + m && n <= 16384;) t += Q(e.colWidths[n] ?? e.defaultColWidth, Z(e)), y++, n++;
4166
+ y += 2;
4167
+ }
4168
+ let b = 0;
4169
+ {
4170
+ let t = -g, n = h;
4171
+ for (; t < v + g && n <= 1048576;) t += $(e.rowHeights[n] ?? e.defaultRowHeight), b++, n++;
4172
+ b += 2;
4173
+ }
4174
+ let x = {
4175
+ row: h,
4176
+ col: p,
4177
+ rows: b,
4178
+ cols: y
4179
+ }, { selectedRowRange: S, selectedColRange: C } = this.computeHeaderHighlight(), w = {
4180
+ width: t,
4181
+ height: n,
4182
+ dpr: a,
4183
+ cellScale: i,
4184
+ scrollOffsetX: m,
4185
+ scrollOffsetY: g,
4186
+ freezeRows: o,
4187
+ freezeCols: s,
4188
+ selectedRowRange: S,
4189
+ selectedColRange: C
4190
+ };
4191
+ if (this._mode === "worker") {
4192
+ let e = await this.workbook.renderViewportToBitmap(this.currentSheet, x, w);
4193
+ if (r !== this._renderSeq) {
4194
+ e.close();
4195
+ return;
4196
+ }
4197
+ this.canvas.width !== e.width && (this.canvas.width = e.width), this.canvas.height !== e.height && (this.canvas.height = e.height);
4198
+ let i = `${t}px`, a = `${n}px`;
4199
+ this.canvas.style.width !== i && (this.canvas.style.width = i), this.canvas.style.height !== a && (this.canvas.style.height = a), this._bitmapCtx?.transferFromImageBitmap(e);
4200
+ } else await this.workbook.renderViewport(this.canvas, this.currentSheet, x, w);
4201
+ }
4202
+ computeHeaderHighlight() {
4203
+ if (!this.anchorCell || !this.activeCell) return {
4204
+ selectedRowRange: null,
4205
+ selectedColRange: null
4206
+ };
4207
+ let e = 2 ** 53 - 1, t = Math.min(this.anchorCell.row, this.activeCell.row), n = Math.max(this.anchorCell.row, this.activeCell.row), r = Math.min(this.anchorCell.col, this.activeCell.col), i = Math.max(this.anchorCell.col, this.activeCell.col);
4208
+ switch (this.selectionMode) {
4209
+ case "cells": return {
4210
+ selectedRowRange: {
4211
+ start: t,
4212
+ end: n,
4213
+ strong: !1
4214
+ },
4215
+ selectedColRange: {
4216
+ start: r,
4217
+ end: i,
4218
+ strong: !1
4219
+ }
4220
+ };
4221
+ case "rows": return {
4222
+ selectedRowRange: {
4223
+ start: t,
4224
+ end: n,
4225
+ strong: !0
4226
+ },
4227
+ selectedColRange: {
4228
+ start: 1,
4229
+ end: e,
4230
+ strong: !1
4231
+ }
4232
+ };
4233
+ case "cols": return {
4234
+ selectedRowRange: {
4235
+ start: 1,
4236
+ end: e,
4237
+ strong: !1
4238
+ },
4239
+ selectedColRange: {
4240
+ start: r,
4241
+ end: i,
4242
+ strong: !0
4243
+ }
4244
+ };
4245
+ case "all": return {
4246
+ selectedRowRange: {
4247
+ start: 1,
4248
+ end: e,
4249
+ strong: !0
4250
+ },
4251
+ selectedColRange: {
4252
+ start: 1,
4253
+ end: e,
4254
+ strong: !0
4255
+ }
4256
+ };
4257
+ }
4258
+ }
4259
+ get sheetNames() {
4260
+ return this.wb?.sheetNames ?? [];
4261
+ }
4262
+ get canvasElement() {
4263
+ return this.canvas;
4264
+ }
4265
+ destroy() {
4266
+ this.resizeObserver?.disconnect(), this._rafId !== null && typeof cancelAnimationFrame == "function" && (cancelAnimationFrame(this._rafId), this._rafId = null), this._renderSeq++, this.hideCommentPopup(), this.hideValidationPanel(), this.keydownHandler && document.removeEventListener("keydown", this.keydownHandler), this.wb?.destroy(), this.wrapper.remove();
4267
+ }
4268
+ }, Jr = /* @__PURE__ */ _({
4269
+ XlsxViewer: () => qr,
4270
+ XlsxWorkbook: () => wr,
4271
+ autoResize: () => D
4272
+ });
4273
+ //#endregion
4274
+ export { qr as n, wr as r, Jr as t };