@origints/xlsx 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,112 +1,116 @@
1
- import $ from "exceljs";
2
- function l(s, t) {
3
- return { ok: !0, value: s, path: t };
1
+ import { TYPE_LABEL as N, registerSpecExecutor as we, globalRegistry as me } from "@origints/core";
2
+ import re from "exceljs";
3
+ function f(r, e) {
4
+ return { ok: !0, value: r, path: e };
4
5
  }
5
- function h(s, t, e, r) {
6
+ function w(r, e, t, n) {
6
7
  return {
7
8
  ok: !1,
8
- failure: { kind: s, message: t, path: e, sourceLocation: r }
9
+ failure: { kind: r, message: e, path: t, sourceLocation: n }
9
10
  };
10
11
  }
11
- function F(s) {
12
- const t = [];
13
- return s.file && t.push(s.file), s.sheet && t.push(`[${s.sheet}]`), s.range ? t.push(`!${s.range}`) : s.cell && t.push(`!${s.cell}`), t.join("") || "workbook";
12
+ function Je(r) {
13
+ const e = [];
14
+ return r.file && e.push(r.file), r.sheet && e.push(`[${r.sheet}]`), r.range ? e.push(`!${r.range}`) : r.cell && e.push(`!${r.cell}`), e.join("") || "workbook";
14
15
  }
15
- function U(s) {
16
- if (s.sheet)
16
+ function je(r) {
17
+ if (r.sheet)
17
18
  return {
18
19
  kind: "excel",
19
- file: s.file ?? "",
20
- sheet: s.sheet,
21
- range: s.range ?? s.cell ?? ""
20
+ file: r.file ?? "",
21
+ sheet: r.sheet,
22
+ range: r.range ?? r.cell ?? ""
22
23
  };
23
24
  }
24
- function b(s) {
25
- return typeof s == "object" && s !== null && !(s instanceof Date) && "formula" in s;
25
+ function P(r) {
26
+ return typeof r == "object" && r !== null && !(r instanceof Date) && "formula" in r;
26
27
  }
27
- function S(s) {
28
- return typeof s == "object" && s !== null && !(s instanceof Date) && "error" in s;
28
+ function Q(r) {
29
+ return typeof r == "object" && r !== null && !(r instanceof Date) && "error" in r;
29
30
  }
30
- async function M(s) {
31
- const t = s.getReader(), e = [];
31
+ async function ge(r) {
32
+ const e = r.getReader(), t = [];
32
33
  try {
33
34
  for (; ; ) {
34
- const { done: r, value: n } = await t.read();
35
- if (r) break;
36
- e.push(n);
35
+ const { done: n, value: s } = await e.read();
36
+ if (n) break;
37
+ t.push(s);
37
38
  }
38
- return Buffer.concat(e);
39
+ return Buffer.concat(t);
39
40
  } finally {
40
- t.releaseLock();
41
+ e.releaseLock();
41
42
  }
42
43
  }
43
- function T(s) {
44
- let t = 0;
45
- for (let e = 0; e < s.length; e++)
46
- t = t * 26 + (s.charCodeAt(e) - 64);
47
- return t;
44
+ function ne(r) {
45
+ let e = 0;
46
+ for (let t = 0; t < r.length; t++)
47
+ e = e * 26 + (r.charCodeAt(t) - 64);
48
+ return e;
48
49
  }
49
- function N(s) {
50
- let t = "";
51
- for (; s > 0; ) {
52
- const e = (s - 1) % 26;
53
- t = String.fromCharCode(65 + e) + t, s = Math.floor((s - 1) / 26);
50
+ function fe(r) {
51
+ let e = "";
52
+ for (; r > 0; ) {
53
+ const t = (r - 1) % 26;
54
+ e = String.fromCharCode(65 + t) + e, r = Math.floor((r - 1) / 26);
54
55
  }
55
- return t;
56
+ return e;
56
57
  }
57
- function p(s) {
58
- const t = s.match(/^([A-Z]+)(\d+)$/i);
59
- if (!t)
60
- throw new Error(`Invalid cell address: ${s}`);
61
- const e = t[1].toUpperCase();
58
+ function V(r) {
59
+ const e = r.match(/^([A-Z]+)(\d+)$/i);
60
+ if (!e)
61
+ throw new Error(`Invalid cell address: ${r}`);
62
+ const t = e[1].toUpperCase();
62
63
  return {
63
- row: parseInt(t[2], 10),
64
- col: T(e),
65
- colLetter: e
64
+ row: parseInt(e[2], 10),
65
+ col: ne(t),
66
+ colLetter: t
66
67
  };
67
68
  }
68
- function R(s, t) {
69
- return `${N(t)}${s}`;
69
+ function Y(r, e) {
70
+ return `${fe(e)}${r}`;
70
71
  }
71
- function y(s) {
72
- const t = s.split(":");
73
- if (t.length === 1) {
74
- const n = p(t[0]);
72
+ function H(r) {
73
+ const e = r.split(":");
74
+ if (e.length === 1) {
75
+ const s = V(e[0]);
75
76
  return {
76
- start: { row: n.row, col: n.col },
77
- end: { row: n.row, col: n.col }
77
+ start: { row: s.row, col: s.col },
78
+ end: { row: s.row, col: s.col }
78
79
  };
79
80
  }
80
- if (t.length !== 2)
81
- throw new Error(`Invalid range: ${s}`);
82
- const e = p(t[0]), r = p(t[1]);
81
+ if (e.length !== 2)
82
+ throw new Error(`Invalid range: ${r}`);
83
+ const t = V(e[0]), n = V(e[1]);
83
84
  return {
84
- start: { row: e.row, col: e.col },
85
- end: { row: r.row, col: r.col }
85
+ start: { row: t.row, col: t.col },
86
+ end: { row: n.row, col: n.col }
86
87
  };
87
88
  }
88
- function A(s, t, e, r) {
89
- const n = R(s, t), o = R(e, r);
90
- return n === o ? n : `${n}:${o}`;
89
+ function le(r, e, t, n) {
90
+ const s = Y(r, e), l = Y(t, n);
91
+ return s === l ? s : `${s}:${l}`;
91
92
  }
92
- function O(s, t, e) {
93
- return s >= e.start.row && s <= e.end.row && t >= e.start.col && t <= e.end.col;
93
+ function Le(r, e, t) {
94
+ return r >= t.start.row && r <= t.end.row && e >= t.start.col && e <= t.end.col;
94
95
  }
95
- class w {
96
- constructor(t, e, r) {
97
- this.cell = t, this._path = e, this._sheetName = r;
96
+ class W {
97
+ constructor(e, t, n) {
98
+ this.cell = e, this._path = t, this._sheetName = n;
99
+ }
100
+ get [N]() {
101
+ return `XlsxCell(${this.address})`;
98
102
  }
99
103
  /**
100
104
  * Creates an XlsxCell from an ExcelJS cell.
101
105
  * @internal
102
106
  */
103
- static fromExcelJS(t, e, r) {
104
- const n = {
105
- file: r,
106
- sheet: e,
107
- cell: t.address
107
+ static fromExcelJS(e, t, n) {
108
+ const s = {
109
+ file: n,
110
+ sheet: t,
111
+ cell: e.address
108
112
  };
109
- return new w(t, n, e);
113
+ return new W(e, s, t);
110
114
  }
111
115
  // ---------------------------------------------------------------------------
112
116
  // IDENTITY & LOCATION
@@ -154,67 +158,67 @@ class w {
154
158
  * Returns the raw cell value.
155
159
  */
156
160
  value() {
157
- const t = this.getRawValue();
158
- return b(t) ? l(t.result ?? null, this._path) : S(t) ? h("formula", `Cell contains error: ${t.error}`, this._path) : l(t, this._path);
161
+ const e = this.getRawValue();
162
+ return P(e) ? f(e.result ?? null, this._path) : Q(e) ? w("formula", `Cell contains error: ${e.error}`, this._path) : f(e, this._path);
159
163
  }
160
164
  /**
161
165
  * Returns the extended cell value (including formula info).
162
166
  */
163
167
  extendedValue() {
164
- return l(this.getRawValue(), this._path);
168
+ return f(this.getRawValue(), this._path);
165
169
  }
166
170
  /**
167
171
  * Extract value as a string.
168
172
  */
169
173
  string() {
170
- const t = this.getResolvedValue();
171
- return t == null ? h("type", "Expected string, got null", this._path) : typeof t == "string" ? l(t, this._path) : typeof t == "number" || typeof t == "boolean" ? l(String(t), this._path) : t instanceof Date ? l(t.toISOString(), this._path) : h("type", `Expected string, got ${typeof t}`, this._path);
174
+ const e = this.getResolvedValue();
175
+ return e == null ? w("type", "Expected string, got null", this._path) : typeof e == "string" ? f(e, this._path) : typeof e == "number" || typeof e == "boolean" ? f(String(e), this._path) : e instanceof Date ? f(e.toISOString(), this._path) : w("type", `Expected string, got ${typeof e}`, this._path);
172
176
  }
173
177
  /**
174
178
  * Extract value as a number.
175
179
  */
176
180
  number() {
177
- const t = this.getResolvedValue();
178
- if (typeof t == "number")
179
- return l(t, this._path);
180
- if (typeof t == "string") {
181
- const e = parseFloat(t);
182
- if (!isNaN(e))
183
- return l(e, this._path);
181
+ const e = this.getResolvedValue();
182
+ if (typeof e == "number")
183
+ return f(e, this._path);
184
+ if (typeof e == "string") {
185
+ const t = parseFloat(e);
186
+ if (!isNaN(t))
187
+ return f(t, this._path);
184
188
  }
185
- return h("type", `Expected number, got ${E(t)}`, this._path);
189
+ return w("type", `Expected number, got ${ee(e)}`, this._path);
186
190
  }
187
191
  /**
188
192
  * Extract value as a boolean.
189
193
  */
190
194
  boolean() {
191
- const t = this.getResolvedValue();
192
- return typeof t == "boolean" ? l(t, this._path) : h("type", `Expected boolean, got ${E(t)}`, this._path);
195
+ const e = this.getResolvedValue();
196
+ return typeof e == "boolean" ? f(e, this._path) : w("type", `Expected boolean, got ${ee(e)}`, this._path);
193
197
  }
194
198
  /**
195
199
  * Extract value as a Date.
196
200
  */
197
201
  date() {
198
- const t = this.getResolvedValue();
199
- if (t instanceof Date)
200
- return l(t, this._path);
201
- if (typeof t == "number") {
202
- const e = this.excelDateToJS(t);
203
- return l(e, this._path);
202
+ const e = this.getResolvedValue();
203
+ if (e instanceof Date)
204
+ return f(e, this._path);
205
+ if (typeof e == "number") {
206
+ const t = this.excelDateToJS(e);
207
+ return f(t, this._path);
204
208
  }
205
- if (typeof t == "string") {
206
- const e = new Date(t);
207
- if (!isNaN(e.getTime()))
208
- return l(e, this._path);
209
+ if (typeof e == "string") {
210
+ const t = new Date(e);
211
+ if (!isNaN(t.getTime()))
212
+ return f(t, this._path);
209
213
  }
210
- return h("type", `Expected date, got ${E(t)}`, this._path);
214
+ return w("type", `Expected date, got ${ee(e)}`, this._path);
211
215
  }
212
216
  /**
213
217
  * Get the formula if this cell contains one.
214
218
  */
215
219
  formula() {
216
- const t = this.getRawValue();
217
- return b(t) ? l(t.formula, this._path) : h("type", "Cell does not contain a formula", this._path);
220
+ const e = this.getRawValue();
221
+ return P(e) ? f(e.formula, this._path) : w("type", "Cell does not contain a formula", this._path);
218
222
  }
219
223
  // ---------------------------------------------------------------------------
220
224
  // RICH TEXT & MARKDOWN
@@ -224,50 +228,50 @@ class w {
224
228
  * Returns segments with their individual formatting properties.
225
229
  */
226
230
  richText() {
227
- const t = this.cell.value, e = this.cell.hyperlink;
228
- if (t && typeof t == "object" && "richText" in t) {
229
- const u = t.richText.map((c) => ({
230
- text: c.text,
231
- bold: c.font?.bold,
232
- italic: c.font?.italic,
233
- underline: c.font?.underline === !0 || c.font?.underline === "single",
234
- strikethrough: c.font?.strike,
235
- color: c.font?.color?.argb,
236
- size: c.font?.size,
237
- font: c.font?.name
231
+ const e = this.cell.value, t = this.cell.hyperlink;
232
+ if (e && typeof e == "object" && "richText" in e) {
233
+ const a = e.richText.map((i) => ({
234
+ text: i.text,
235
+ bold: i.font?.bold,
236
+ italic: i.font?.italic,
237
+ underline: i.font?.underline === !0 || i.font?.underline === "single",
238
+ strikethrough: i.font?.strike,
239
+ color: i.font?.color?.argb,
240
+ size: i.font?.size,
241
+ font: i.font?.name
238
242
  }));
239
- return l({ segments: u, hyperlink: e }, this._path);
243
+ return f({ segments: a, hyperlink: t }, this._path);
240
244
  }
241
- if (t && typeof t == "object" && "text" in t && "hyperlink" in t) {
242
- const a = t, u = this.style(), c = {
243
- text: a.text,
244
- bold: u.font?.bold,
245
- italic: u.font?.italic,
246
- underline: u.font?.underline,
247
- strikethrough: u.font?.strikethrough,
248
- color: u.font?.color,
249
- size: u.font?.size,
250
- font: u.font?.name
245
+ if (e && typeof e == "object" && "text" in e && "hyperlink" in e) {
246
+ const o = e, a = this.style(), i = {
247
+ text: o.text,
248
+ bold: a.font?.bold,
249
+ italic: a.font?.italic,
250
+ underline: a.font?.underline,
251
+ strikethrough: a.font?.strikethrough,
252
+ color: a.font?.color,
253
+ size: a.font?.size,
254
+ font: a.font?.name
251
255
  };
252
- return l(
256
+ return f(
253
257
  {
254
- segments: [c],
255
- hyperlink: a.hyperlink
258
+ segments: [i],
259
+ hyperlink: o.hyperlink
256
260
  },
257
261
  this._path
258
262
  );
259
263
  }
260
- const r = this.getResolvedValue(), n = r !== null ? String(r) : "", o = this.style(), i = {
261
- text: n,
262
- bold: o.font?.bold,
263
- italic: o.font?.italic,
264
- underline: o.font?.underline,
265
- strikethrough: o.font?.strikethrough,
266
- color: o.font?.color,
267
- size: o.font?.size,
268
- font: o.font?.name
264
+ const n = this.getResolvedValue(), s = n !== null ? String(n) : "", l = this.style(), u = {
265
+ text: s,
266
+ bold: l.font?.bold,
267
+ italic: l.font?.italic,
268
+ underline: l.font?.underline,
269
+ strikethrough: l.font?.strikethrough,
270
+ color: l.font?.color,
271
+ size: l.font?.size,
272
+ font: l.font?.name
269
273
  };
270
- return l({ segments: [i], hyperlink: e }, this._path);
274
+ return f({ segments: [u], hyperlink: t }, this._path);
271
275
  }
272
276
  /**
273
277
  * Get the cell content as Markdown.
@@ -280,23 +284,23 @@ class w {
280
284
  * - Rich text segments with mixed formatting
281
285
  */
282
286
  markdown() {
283
- const t = this.richText();
284
- if (!t.ok)
285
- return t;
286
- const { segments: e, hyperlink: r } = t.value;
287
- let n = "";
288
- for (const o of e) {
289
- let i = o.text;
290
- o.strikethrough && (i = `~~${i}~~`), o.bold && (i = `**${i}**`), o.italic && (i = `*${i}*`), n += i;
287
+ const e = this.richText();
288
+ if (!e.ok)
289
+ return e;
290
+ const { segments: t, hyperlink: n } = e.value;
291
+ let s = "";
292
+ for (const l of t) {
293
+ let u = l.text;
294
+ l.strikethrough && (u = `~~${u}~~`), l.bold && (u = `**${u}**`), l.italic && (u = `*${u}*`), s += u;
291
295
  }
292
- return r && (n = `[${n}](${r})`), l(n, this._path);
296
+ return n && (s = `[${s}](${n})`), f(s, this._path);
293
297
  }
294
298
  /**
295
299
  * Check if the cell contains rich text (multiple formatted segments).
296
300
  */
297
301
  isRichText() {
298
- const t = this.cell.value;
299
- return t !== null && typeof t == "object" && "richText" in t;
302
+ const e = this.cell.value;
303
+ return e !== null && typeof e == "object" && "richText" in e;
300
304
  }
301
305
  // ---------------------------------------------------------------------------
302
306
  // TYPE CHECKING
@@ -305,14 +309,14 @@ class w {
305
309
  * Check if the cell is empty.
306
310
  */
307
311
  isEmpty() {
308
- const t = this.cell.value;
309
- return t == null || t === "";
312
+ const e = this.cell.value;
313
+ return e == null || e === "";
310
314
  }
311
315
  /**
312
316
  * Check if the cell contains a formula.
313
317
  */
314
318
  isFormula() {
315
- return b(this.getRawValue());
319
+ return P(this.getRawValue());
316
320
  }
317
321
  /**
318
322
  * Check if the cell is part of a merged range.
@@ -354,7 +358,7 @@ class w {
354
358
  * Check if the cell contains an error.
355
359
  */
356
360
  isError() {
357
- return S(this.getRawValue());
361
+ return Q(this.getRawValue());
358
362
  }
359
363
  // ---------------------------------------------------------------------------
360
364
  // METADATA
@@ -363,31 +367,31 @@ class w {
363
367
  * Get the cell's style information.
364
368
  */
365
369
  style() {
366
- const t = this.cell.font, e = this.cell.fill, r = this.cell.border, n = this.cell.alignment;
370
+ const e = this.cell.font, t = this.cell.fill, n = this.cell.border, s = this.cell.alignment;
367
371
  return {
368
- font: t ? {
369
- name: t.name,
370
- size: t.size,
371
- bold: t.bold,
372
- italic: t.italic,
373
- underline: t.underline === !0 || t.underline === "single",
374
- strikethrough: t.strike,
375
- color: t.color?.argb ?? (t.color?.theme !== void 0 ? `theme:${t.color.theme}` : void 0)
372
+ font: e ? {
373
+ name: e.name,
374
+ size: e.size,
375
+ bold: e.bold,
376
+ italic: e.italic,
377
+ underline: e.underline === !0 || e.underline === "single",
378
+ strikethrough: e.strike,
379
+ color: e.color?.argb ?? (e.color?.theme !== void 0 ? `theme:${e.color.theme}` : void 0)
376
380
  } : void 0,
377
- fill: e && e.type === "pattern" ? {
378
- type: e.pattern,
379
- color: e.fgColor?.argb
381
+ fill: t && t.type === "pattern" ? {
382
+ type: t.pattern,
383
+ color: t.fgColor?.argb
380
384
  } : void 0,
381
- border: r ? {
382
- top: !!r.top,
383
- bottom: !!r.bottom,
384
- left: !!r.left,
385
- right: !!r.right
385
+ border: n ? {
386
+ top: !!n.top,
387
+ bottom: !!n.bottom,
388
+ left: !!n.left,
389
+ right: !!n.right
386
390
  } : void 0,
387
- alignment: n ? {
388
- horizontal: n.horizontal,
389
- vertical: n.vertical,
390
- wrapText: n.wrapText
391
+ alignment: s ? {
392
+ horizontal: s.horizontal,
393
+ vertical: s.vertical,
394
+ wrapText: s.wrapText
391
395
  } : void 0,
392
396
  numFmt: this.cell.numFmt
393
397
  };
@@ -396,18 +400,18 @@ class w {
396
400
  * Get the hyperlink URL if the cell contains one.
397
401
  */
398
402
  hyperlink() {
399
- const t = this.cell.hyperlink;
400
- return t ? l(t, this._path) : h("missing", "Cell does not contain a hyperlink", this._path);
403
+ const e = this.cell.hyperlink;
404
+ return e ? f(e, this._path) : w("missing", "Cell does not contain a hyperlink", this._path);
401
405
  }
402
406
  /**
403
407
  * Get the comment/note if the cell has one.
404
408
  */
405
409
  comment() {
406
- const t = this.cell.note;
407
- return t ? typeof t == "string" ? l(t, this._path) : t.texts ? l(
408
- t.texts.map((e) => e.text).join(""),
410
+ const e = this.cell.note;
411
+ return e ? typeof e == "string" ? f(e, this._path) : e.texts ? f(
412
+ e.texts.map((t) => t.text).join(""),
409
413
  this._path
410
- ) : h("format", "Unable to extract comment text", this._path) : h("missing", "Cell does not contain a comment", this._path);
414
+ ) : w("format", "Unable to extract comment text", this._path) : w("missing", "Cell does not contain a comment", this._path);
411
415
  }
412
416
  // ---------------------------------------------------------------------------
413
417
  // NAVIGATION FROM CELL
@@ -416,18 +420,18 @@ class w {
416
420
  * Get a cell offset from this one.
417
421
  * @internal Used by navigation methods
418
422
  */
419
- getOffsetCell(t, e, r) {
420
- const n = this.row + t, o = this.col + e;
421
- if (n < 1 || o < 1)
422
- return h(
423
+ getOffsetCell(e, t, n) {
424
+ const s = this.row + e, l = this.col + t;
425
+ if (s < 1 || l < 1)
426
+ return w(
423
427
  "bounds",
424
- `Cell offset (${t}, ${e}) from ${this.address} is out of bounds`,
428
+ `Cell offset (${e}, ${t}) from ${this.address} is out of bounds`,
425
429
  this._path
426
430
  );
427
- const i = r(n, o);
428
- return i ? l(i, i.path) : h(
431
+ const u = n(s, l);
432
+ return u ? f(u, u.path) : w(
429
433
  "missing",
430
- `Cell at ${R(n, o)} not found`,
434
+ `Cell at ${Y(s, l)} not found`,
431
435
  this._path
432
436
  );
433
437
  }
@@ -438,108 +442,110 @@ class w {
438
442
  * Get the raw value, handling ExcelJS value types.
439
443
  */
440
444
  getRawValue() {
441
- const t = this.cell.value;
442
- if (t == null)
445
+ const e = this.cell.value;
446
+ if (e == null)
443
447
  return null;
444
- if (typeof t == "object") {
445
- if ("error" in t)
446
- return { error: String(t.error) };
447
- if ("formula" in t) {
448
- const e = t;
448
+ if (typeof e == "object") {
449
+ if ("error" in e)
450
+ return { error: String(e.error) };
451
+ if ("formula" in e) {
452
+ const t = e;
449
453
  return {
450
- formula: e.formula,
451
- result: this.normalizeResult(e.result)
454
+ formula: t.formula,
455
+ result: this.normalizeResult(t.result)
452
456
  };
453
457
  }
454
- if ("sharedFormula" in t) {
455
- const e = t;
458
+ if ("sharedFormula" in e) {
459
+ const t = e;
456
460
  return {
457
- formula: e.sharedFormula,
458
- result: this.normalizeResult(e.result)
461
+ formula: t.sharedFormula,
462
+ result: this.normalizeResult(t.result)
459
463
  };
460
464
  }
461
- if ("richText" in t)
462
- return t.richText.map((r) => r.text).join("");
463
- if (t instanceof Date)
464
- return t;
465
+ if ("richText" in e)
466
+ return e.richText.map((n) => n.text).join("");
467
+ if (e instanceof Date)
468
+ return e;
465
469
  }
466
- return typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? t : null;
470
+ return typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? e : null;
467
471
  }
468
472
  /**
469
473
  * Get the resolved value (formula result or plain value).
470
474
  */
471
475
  getResolvedValue() {
472
- const t = this.getRawValue();
473
- return b(t) ? t.result ?? null : S(t) ? null : t;
476
+ const e = this.getRawValue();
477
+ return P(e) ? e.result ?? null : Q(e) ? null : e;
474
478
  }
475
479
  /**
476
480
  * Normalize a formula result value.
477
481
  */
478
- normalizeResult(t) {
479
- return t == null ? null : typeof t == "string" || typeof t == "number" || typeof t == "boolean" || t instanceof Date ? t : null;
482
+ normalizeResult(e) {
483
+ return e == null ? null : typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e instanceof Date ? e : null;
480
484
  }
481
485
  /**
482
486
  * Convert Excel date number to JavaScript Date.
483
487
  * Excel dates are days since 1900-01-01 (with a leap year bug).
484
488
  */
485
- excelDateToJS(t) {
486
- const e = t > 60 ? -1 : 0, r = t + e - 1, n = new Date(1900, 0, 1);
487
- return new Date(n.getTime() + r * 24 * 60 * 60 * 1e3);
489
+ excelDateToJS(e) {
490
+ const t = e > 60 ? -1 : 0, n = e + t - 1, s = new Date(1900, 0, 1);
491
+ return new Date(s.getTime() + n * 24 * 60 * 60 * 1e3);
488
492
  }
489
493
  }
490
- function E(s) {
491
- return s === null ? "null" : s === void 0 ? "undefined" : s instanceof Date ? "date" : Array.isArray(s) ? "array" : typeof s;
494
+ function ee(r) {
495
+ return r === null ? "null" : r === void 0 ? "undefined" : r instanceof Date ? "date" : Array.isArray(r) ? "array" : typeof r;
492
496
  }
493
- class m {
494
- constructor(t, e, r, n, o, i, a, u) {
495
- this.worksheet = t, this._startRow = e, this._startCol = r, this._endRow = n, this._endCol = o, this._path = i, this._sheetName = a, this._file = u;
497
+ class y {
498
+ constructor(e, t, n, s, l, u, o, a) {
499
+ this.worksheet = e, this._startRow = t, this._startCol = n, this._endRow = s, this._endCol = l, this._path = u, this._sheetName = o, this._file = a;
500
+ }
501
+ get [N]() {
502
+ return `XlsxRange(${this.address})`;
496
503
  }
497
504
  /**
498
505
  * Creates an XlsxRange from coordinates.
499
506
  * @internal
500
507
  */
501
- static fromCoords(t, e, r, n, o, i, a) {
502
- const u = A(e, r, n, o), c = {
503
- file: a,
504
- sheet: i,
505
- range: u
508
+ static fromCoords(e, t, n, s, l, u, o) {
509
+ const a = le(t, n, s, l), i = {
510
+ file: o,
511
+ sheet: u,
512
+ range: a
506
513
  };
507
- return new m(
508
- t,
514
+ return new y(
509
515
  e,
510
- r,
516
+ t,
511
517
  n,
512
- o,
513
- c,
518
+ s,
519
+ l,
514
520
  i,
515
- a
521
+ u,
522
+ o
516
523
  );
517
524
  }
518
525
  /**
519
526
  * Creates an XlsxRange from an address string.
520
527
  * @internal
521
528
  */
522
- static fromAddress(t, e, r, n) {
529
+ static fromAddress(e, t, n, s) {
523
530
  try {
524
- const { start: o, end: i } = y(e);
525
- return l(
526
- m.fromCoords(
527
- t,
528
- o.row,
529
- o.col,
530
- i.row,
531
- i.col,
532
- r,
533
- n
531
+ const { start: l, end: u } = H(t);
532
+ return f(
533
+ y.fromCoords(
534
+ e,
535
+ l.row,
536
+ l.col,
537
+ u.row,
538
+ u.col,
539
+ n,
540
+ s
534
541
  ),
535
- { file: n, sheet: r, range: e }
542
+ { file: s, sheet: n, range: t }
536
543
  );
537
544
  } catch {
538
- return h(
539
- "range",
540
- `Invalid range address: ${e}`,
541
- { file: n, sheet: r }
542
- );
545
+ return w("range", `Invalid range address: ${t}`, {
546
+ file: s,
547
+ sheet: n
548
+ });
543
549
  }
544
550
  }
545
551
  // ---------------------------------------------------------------------------
@@ -549,7 +555,7 @@ class m {
549
555
  * Returns the range address (e.g., "A1:C10").
550
556
  */
551
557
  get address() {
552
- return A(
558
+ return le(
553
559
  this._startRow,
554
560
  this._startCol,
555
561
  this._endRow,
@@ -611,41 +617,41 @@ class m {
611
617
  * Get a cell at specific row and column within this range.
612
618
  * Coordinates are relative to the range start (0-indexed).
613
619
  */
614
- cellAt(t, e) {
615
- const r = this._startRow + t, n = this._startCol + e;
616
- if (r < this._startRow || r > this._endRow || n < this._startCol || n > this._endCol)
617
- return h(
620
+ cellAt(e, t) {
621
+ const n = this._startRow + e, s = this._startCol + t;
622
+ if (n < this._startRow || n > this._endRow || s < this._startCol || s > this._endCol)
623
+ return w(
618
624
  "bounds",
619
- `Offset (${t}, ${e}) is outside range ${this.address}`,
625
+ `Offset (${e}, ${t}) is outside range ${this.address}`,
620
626
  this._path
621
627
  );
622
- const o = this.worksheet.getCell(r, n);
623
- return l(w.fromExcelJS(o, this._sheetName, this._file), {
628
+ const l = this.worksheet.getCell(n, s);
629
+ return f(W.fromExcelJS(l, this._sheetName, this._file), {
624
630
  ...this._path,
625
- cell: o.address,
631
+ cell: l.address,
626
632
  range: void 0
627
633
  });
628
634
  }
629
635
  /**
630
636
  * Get a cell by its address within this range.
631
637
  */
632
- cell(t) {
638
+ cell(e) {
633
639
  try {
634
- const { start: e } = y(t);
635
- if (e.row < this._startRow || e.row > this._endRow || e.col < this._startCol || e.col > this._endCol)
636
- return h(
640
+ const { start: t } = H(e);
641
+ if (t.row < this._startRow || t.row > this._endRow || t.col < this._startCol || t.col > this._endCol)
642
+ return w(
637
643
  "bounds",
638
- `Cell ${t} is outside range ${this.address}`,
644
+ `Cell ${e} is outside range ${this.address}`,
639
645
  this._path
640
646
  );
641
- const r = this.worksheet.getCell(t);
642
- return l(w.fromExcelJS(r, this._sheetName, this._file), {
647
+ const n = this.worksheet.getCell(e);
648
+ return f(W.fromExcelJS(n, this._sheetName, this._file), {
643
649
  ...this._path,
644
- cell: t,
650
+ cell: e,
645
651
  range: void 0
646
652
  });
647
653
  } catch {
648
- return h("range", `Invalid cell address: ${t}`, this._path);
654
+ return w("range", `Invalid cell address: ${e}`, this._path);
649
655
  }
650
656
  }
651
657
  // ---------------------------------------------------------------------------
@@ -655,52 +661,52 @@ class m {
655
661
  * Iterate over all cells in the range (row by row).
656
662
  */
657
663
  *cells() {
658
- for (let t = this._startRow; t <= this._endRow; t++)
659
- for (let e = this._startCol; e <= this._endCol; e++) {
660
- const r = this.worksheet.getCell(t, e);
661
- yield w.fromExcelJS(r, this._sheetName, this._file);
664
+ for (let e = this._startRow; e <= this._endRow; e++)
665
+ for (let t = this._startCol; t <= this._endCol; t++) {
666
+ const n = this.worksheet.getCell(e, t);
667
+ yield W.fromExcelJS(n, this._sheetName, this._file);
662
668
  }
663
669
  }
664
670
  /**
665
671
  * Iterate over rows, returning arrays of cells.
666
672
  */
667
673
  *rows() {
668
- for (let t = this._startRow; t <= this._endRow; t++) {
669
- const e = [];
670
- for (let r = this._startCol; r <= this._endCol; r++) {
671
- const n = this.worksheet.getCell(t, r);
672
- e.push(w.fromExcelJS(n, this._sheetName, this._file));
674
+ for (let e = this._startRow; e <= this._endRow; e++) {
675
+ const t = [];
676
+ for (let n = this._startCol; n <= this._endCol; n++) {
677
+ const s = this.worksheet.getCell(e, n);
678
+ t.push(W.fromExcelJS(s, this._sheetName, this._file));
673
679
  }
674
- yield e;
680
+ yield t;
675
681
  }
676
682
  }
677
683
  /**
678
684
  * Iterate over columns, returning arrays of cells.
679
685
  */
680
686
  *cols() {
681
- for (let t = this._startCol; t <= this._endCol; t++) {
682
- const e = [];
683
- for (let r = this._startRow; r <= this._endRow; r++) {
684
- const n = this.worksheet.getCell(r, t);
685
- e.push(w.fromExcelJS(n, this._sheetName, this._file));
687
+ for (let e = this._startCol; e <= this._endCol; e++) {
688
+ const t = [];
689
+ for (let n = this._startRow; n <= this._endRow; n++) {
690
+ const s = this.worksheet.getCell(n, e);
691
+ t.push(W.fromExcelJS(s, this._sheetName, this._file));
686
692
  }
687
- yield e;
693
+ yield t;
688
694
  }
689
695
  }
690
696
  /**
691
697
  * Get all values in the range as a 2D array.
692
698
  */
693
699
  values() {
694
- const t = [];
695
- for (const e of this.rows()) {
696
- const r = [];
697
- for (const n of e) {
698
- const o = n.value();
699
- r.push(o.ok ? o.value : null);
700
+ const e = [];
701
+ for (const t of this.rows()) {
702
+ const n = [];
703
+ for (const s of t) {
704
+ const l = s.value();
705
+ n.push(l.ok ? l.value : null);
700
706
  }
701
- t.push(r);
707
+ e.push(n);
702
708
  }
703
- return t;
709
+ return e;
704
710
  }
705
711
  /**
706
712
  * Get all cells as a flat array.
@@ -714,34 +720,34 @@ class m {
714
720
  /**
715
721
  * Get a subrange within this range.
716
722
  */
717
- subRange(t) {
723
+ subRange(e) {
718
724
  try {
719
- const { start: e, end: r } = y(t);
720
- return e.row < this._startRow || r.row > this._endRow || e.col < this._startCol || r.col > this._endCol ? h(
725
+ const { start: t, end: n } = H(e);
726
+ return t.row < this._startRow || n.row > this._endRow || t.col < this._startCol || n.col > this._endCol ? w(
721
727
  "bounds",
722
- `Subrange ${t} extends outside range ${this.address}`,
728
+ `Subrange ${e} extends outside range ${this.address}`,
723
729
  this._path
724
- ) : l(
725
- m.fromCoords(
730
+ ) : f(
731
+ y.fromCoords(
726
732
  this.worksheet,
727
- e.row,
728
- e.col,
729
- r.row,
730
- r.col,
733
+ t.row,
734
+ t.col,
735
+ n.row,
736
+ n.col,
731
737
  this._sheetName,
732
738
  this._file
733
739
  ),
734
- { ...this._path, range: t }
740
+ { ...this._path, range: e }
735
741
  );
736
742
  } catch {
737
- return h("range", `Invalid range address: ${t}`, this._path);
743
+ return w("range", `Invalid range address: ${e}`, this._path);
738
744
  }
739
745
  }
740
746
  /**
741
747
  * Get the first row as a range.
742
748
  */
743
749
  firstRow() {
744
- return m.fromCoords(
750
+ return y.fromCoords(
745
751
  this.worksheet,
746
752
  this._startRow,
747
753
  this._startCol,
@@ -755,7 +761,7 @@ class m {
755
761
  * Get the last row as a range.
756
762
  */
757
763
  lastRow() {
758
- return m.fromCoords(
764
+ return y.fromCoords(
759
765
  this.worksheet,
760
766
  this._endRow,
761
767
  this._startCol,
@@ -769,7 +775,7 @@ class m {
769
775
  * Get the first column as a range.
770
776
  */
771
777
  firstCol() {
772
- return m.fromCoords(
778
+ return y.fromCoords(
773
779
  this.worksheet,
774
780
  this._startRow,
775
781
  this._startCol,
@@ -783,7 +789,7 @@ class m {
783
789
  * Get the last column as a range.
784
790
  */
785
791
  lastCol() {
786
- return m.fromCoords(
792
+ return y.fromCoords(
787
793
  this.worksheet,
788
794
  this._startRow,
789
795
  this._endCol,
@@ -796,18 +802,18 @@ class m {
796
802
  /**
797
803
  * Get a specific row as a range (0-indexed offset from start).
798
804
  */
799
- rowAt(t) {
800
- const e = this._startRow + t;
801
- return e < this._startRow || e > this._endRow ? h(
805
+ rowAt(e) {
806
+ const t = this._startRow + e;
807
+ return t < this._startRow || t > this._endRow ? w(
802
808
  "bounds",
803
- `Row offset ${t} is outside range ${this.address}`,
809
+ `Row offset ${e} is outside range ${this.address}`,
804
810
  this._path
805
- ) : l(
806
- m.fromCoords(
811
+ ) : f(
812
+ y.fromCoords(
807
813
  this.worksheet,
808
- e,
814
+ t,
809
815
  this._startCol,
810
- e,
816
+ t,
811
817
  this._endCol,
812
818
  this._sheetName,
813
819
  this._file
@@ -818,19 +824,19 @@ class m {
818
824
  /**
819
825
  * Get a specific column as a range (0-indexed offset from start).
820
826
  */
821
- colAt(t) {
822
- const e = this._startCol + t;
823
- return e < this._startCol || e > this._endCol ? h(
827
+ colAt(e) {
828
+ const t = this._startCol + e;
829
+ return t < this._startCol || t > this._endCol ? w(
824
830
  "bounds",
825
- `Column offset ${t} is outside range ${this.address}`,
831
+ `Column offset ${e} is outside range ${this.address}`,
826
832
  this._path
827
- ) : l(
828
- m.fromCoords(
833
+ ) : f(
834
+ y.fromCoords(
829
835
  this.worksheet,
830
836
  this._startRow,
831
- e,
837
+ t,
832
838
  this._endRow,
833
- e,
839
+ t,
834
840
  this._sheetName,
835
841
  this._file
836
842
  ),
@@ -843,11 +849,11 @@ class m {
843
849
  /**
844
850
  * Find the first cell matching the predicate.
845
851
  */
846
- find(t) {
847
- for (const e of this.cells())
848
- if (t(e))
849
- return l(e, e.path);
850
- return h(
852
+ find(e) {
853
+ for (const t of this.cells())
854
+ if (e(t))
855
+ return f(t, t.path);
856
+ return w(
851
857
  "missing",
852
858
  `No cell matching predicate found in range ${this.address}`,
853
859
  this._path
@@ -856,53 +862,53 @@ class m {
856
862
  /**
857
863
  * Find all cells matching the predicate.
858
864
  */
859
- findAll(t) {
860
- const e = [];
861
- for (const r of this.cells())
862
- t(r) && e.push(r);
863
- return e;
865
+ findAll(e) {
866
+ const t = [];
867
+ for (const n of this.cells())
868
+ e(n) && t.push(n);
869
+ return t;
864
870
  }
865
871
  /**
866
872
  * Find the first cell with the specified value.
867
873
  */
868
- findValue(t) {
869
- for (const e of this.cells()) {
870
- const r = e.value();
871
- if (r.ok && r.value === t)
872
- return l(e, e.path);
874
+ findValue(e) {
875
+ for (const t of this.cells()) {
876
+ const n = t.value();
877
+ if (n.ok && n.value === e)
878
+ return f(t, t.path);
873
879
  }
874
- return h(
880
+ return w(
875
881
  "missing",
876
- `Value "${t}" not found in range ${this.address}`,
882
+ `Value "${e}" not found in range ${this.address}`,
877
883
  this._path
878
884
  );
879
885
  }
880
886
  /**
881
887
  * Check if any cell matches the predicate.
882
888
  */
883
- some(t) {
884
- for (const e of this.cells())
885
- if (t(e))
889
+ some(e) {
890
+ for (const t of this.cells())
891
+ if (e(t))
886
892
  return !0;
887
893
  return !1;
888
894
  }
889
895
  /**
890
896
  * Check if all cells match the predicate.
891
897
  */
892
- every(t) {
893
- for (const e of this.cells())
894
- if (!t(e))
898
+ every(e) {
899
+ for (const t of this.cells())
900
+ if (!e(t))
895
901
  return !1;
896
902
  return !0;
897
903
  }
898
904
  /**
899
905
  * Count cells matching the predicate.
900
906
  */
901
- count(t) {
902
- let e = 0;
903
- for (const r of this.cells())
904
- t(r) && e++;
905
- return e;
907
+ count(e) {
908
+ let t = 0;
909
+ for (const n of this.cells())
910
+ e(n) && t++;
911
+ return t;
906
912
  }
907
913
  // ---------------------------------------------------------------------------
908
914
  // CONVERSION
@@ -918,27 +924,27 @@ class m {
918
924
  * @param headerRowOffset - Row offset for headers (default: 0, first row)
919
925
  * @param dataStartOffset - Row offset where data starts (default: 1, second row)
920
926
  */
921
- toObjects(t = 0, e = 1) {
922
- const r = [...this.rows()];
923
- if (r.length === 0) return [];
924
- const n = r[t];
925
- if (!n) return [];
926
- const o = n.map((a) => {
927
- const u = a.value();
928
- return u.ok && u.value !== null ? String(u.value) : "";
929
- }), i = [];
930
- for (let a = e; a < r.length; a++) {
931
- const u = r[a], c = {};
932
- for (let f = 0; f < o.length; f++) {
933
- const g = o[f];
934
- if (g) {
935
- const _ = u[f]?.value();
936
- c[g] = _?.ok ? _.value : null;
927
+ toObjects(e = 0, t = 1) {
928
+ const n = [...this.rows()];
929
+ if (n.length === 0) return [];
930
+ const s = n[e];
931
+ if (!s) return [];
932
+ const l = s.map((o) => {
933
+ const a = o.value();
934
+ return a.ok && a.value !== null ? String(a.value) : "";
935
+ }), u = [];
936
+ for (let o = t; o < n.length; o++) {
937
+ const a = n[o], i = {};
938
+ for (let c = 0; c < l.length; c++) {
939
+ const h = l[c];
940
+ if (h) {
941
+ const k = a[c]?.value();
942
+ i[h] = k?.ok ? k.value : null;
937
943
  }
938
944
  }
939
- i.push(c);
945
+ u.push(i);
940
946
  }
941
- return i;
947
+ return u;
942
948
  }
943
949
  /**
944
950
  * Convert range to JSON-compatible structure.
@@ -950,24 +956,27 @@ class m {
950
956
  };
951
957
  }
952
958
  }
953
- class d {
954
- constructor(t, e, r, n = "right") {
955
- this.sheet = t, this._row = e, this._col = r, this._direction = n;
959
+ class $ {
960
+ constructor(e, t, n, s = "right") {
961
+ this.sheet = e, this._row = t, this._col = n, this._direction = s;
962
+ }
963
+ get [N]() {
964
+ return `XlsxCursor(${this.address} ${this._direction})`;
956
965
  }
957
966
  /**
958
967
  * Create a cursor from an address string.
959
968
  * @internal
960
969
  */
961
- static create(t, e) {
962
- const { row: r, col: n } = p(e);
963
- return new d(t, r, n);
970
+ static create(e, t) {
971
+ const { row: n, col: s } = V(t);
972
+ return new $(e, n, s);
964
973
  }
965
974
  /**
966
975
  * Create a cursor from row and column coordinates.
967
976
  * @internal
968
977
  */
969
- static createAt(t, e, r) {
970
- return new d(t, Math.max(1, e), Math.max(1, r));
978
+ static createAt(e, t, n) {
979
+ return new $(e, Math.max(1, t), Math.max(1, n));
971
980
  }
972
981
  // ---------------------------------------------------------------------------
973
982
  // POSITION
@@ -988,13 +997,13 @@ class d {
988
997
  * Get the current address.
989
998
  */
990
999
  get address() {
991
- return R(this._row, this._col);
1000
+ return Y(this._row, this._col);
992
1001
  }
993
1002
  /**
994
1003
  * Get the current column letter.
995
1004
  */
996
1005
  get colLetter() {
997
- return N(this._col);
1006
+ return fe(this._col);
998
1007
  }
999
1008
  /**
1000
1009
  * Get the current direction.
@@ -1017,58 +1026,68 @@ class d {
1017
1026
  /**
1018
1027
  * Move by a delta (returns new cursor).
1019
1028
  */
1020
- move(t, e) {
1021
- return new d(
1029
+ move(e, t) {
1030
+ return new $(
1022
1031
  this.sheet,
1023
- Math.max(1, this._row + t),
1024
- Math.max(1, this._col + e),
1032
+ Math.max(1, this._row + e),
1033
+ Math.max(1, this._col + t),
1025
1034
  this._direction
1026
1035
  );
1027
1036
  }
1028
1037
  /**
1029
1038
  * Move to a specific address.
1030
1039
  */
1031
- moveTo(t) {
1032
- const { row: e, col: r } = p(t);
1033
- return new d(this.sheet, e, r, this._direction);
1040
+ moveTo(e) {
1041
+ const { row: t, col: n } = V(e);
1042
+ return new $(this.sheet, t, n, this._direction);
1034
1043
  }
1035
1044
  /**
1036
1045
  * Move to a specific row.
1037
1046
  */
1038
- moveToRow(t) {
1039
- return new d(this.sheet, Math.max(1, t), this._col, this._direction);
1047
+ moveToRow(e) {
1048
+ return new $(
1049
+ this.sheet,
1050
+ Math.max(1, e),
1051
+ this._col,
1052
+ this._direction
1053
+ );
1040
1054
  }
1041
1055
  /**
1042
1056
  * Move to a specific column.
1043
1057
  */
1044
- moveToCol(t) {
1045
- const e = typeof t == "string" ? T(t.toUpperCase()) : t;
1046
- return new d(this.sheet, this._row, Math.max(1, e), this._direction);
1058
+ moveToCol(e) {
1059
+ const t = typeof e == "string" ? ne(e.toUpperCase()) : e;
1060
+ return new $(
1061
+ this.sheet,
1062
+ this._row,
1063
+ Math.max(1, t),
1064
+ this._direction
1065
+ );
1047
1066
  }
1048
1067
  /**
1049
1068
  * Move left by count cells.
1050
1069
  */
1051
- left(t = 1) {
1052
- return new d(
1070
+ left(e = 1) {
1071
+ return new $(
1053
1072
  this.sheet,
1054
1073
  this._row,
1055
- Math.max(1, this._col - t),
1074
+ Math.max(1, this._col - e),
1056
1075
  "left"
1057
1076
  );
1058
1077
  }
1059
1078
  /**
1060
1079
  * Move right by count cells.
1061
1080
  */
1062
- right(t = 1) {
1063
- return new d(this.sheet, this._row, this._col + t, "right");
1081
+ right(e = 1) {
1082
+ return new $(this.sheet, this._row, this._col + e, "right");
1064
1083
  }
1065
1084
  /**
1066
1085
  * Move up by count cells.
1067
1086
  */
1068
- up(t = 1) {
1069
- return new d(
1087
+ up(e = 1) {
1088
+ return new $(
1070
1089
  this.sheet,
1071
- Math.max(1, this._row - t),
1090
+ Math.max(1, this._row - e),
1072
1091
  this._col,
1073
1092
  "up"
1074
1093
  );
@@ -1076,41 +1095,41 @@ class d {
1076
1095
  /**
1077
1096
  * Move down by count cells.
1078
1097
  */
1079
- down(t = 1) {
1080
- return new d(this.sheet, this._row + t, this._col, "down");
1098
+ down(e = 1) {
1099
+ return new $(this.sheet, this._row + e, this._col, "down");
1081
1100
  }
1082
1101
  /**
1083
1102
  * Set the current direction.
1084
1103
  */
1085
- setDirection(t) {
1086
- return new d(this.sheet, this._row, this._col, t);
1104
+ setDirection(e) {
1105
+ return new $(this.sheet, this._row, this._col, e);
1087
1106
  }
1088
1107
  /**
1089
1108
  * Move forward in the current direction.
1090
1109
  */
1091
- forward(t = 1) {
1110
+ forward(e = 1) {
1092
1111
  switch (this._direction) {
1093
1112
  case "right":
1094
- return this.right(t);
1113
+ return this.right(e);
1095
1114
  case "left":
1096
- return this.left(t);
1115
+ return this.left(e);
1097
1116
  case "down":
1098
- return this.down(t);
1117
+ return this.down(e);
1099
1118
  case "up":
1100
- return this.up(t);
1119
+ return this.up(e);
1101
1120
  }
1102
1121
  }
1103
1122
  /**
1104
1123
  * Move to the start of the current row.
1105
1124
  */
1106
1125
  startOfRow() {
1107
- return new d(this.sheet, this._row, 1, this._direction);
1126
+ return new $(this.sheet, this._row, 1, this._direction);
1108
1127
  }
1109
1128
  /**
1110
1129
  * Move to the start of the current column.
1111
1130
  */
1112
1131
  startOfCol() {
1113
- return new d(this.sheet, 1, this._col, this._direction);
1132
+ return new $(this.sheet, 1, this._col, this._direction);
1114
1133
  }
1115
1134
  // ---------------------------------------------------------------------------
1116
1135
  // SKIP OPERATIONS
@@ -1119,41 +1138,41 @@ class d {
1119
1138
  * Skip empty cells in the current direction.
1120
1139
  */
1121
1140
  skipEmpty() {
1122
- return this.skipWhile((t) => t.isEmpty());
1141
+ return this.skipWhile((e) => e.isEmpty());
1123
1142
  }
1124
1143
  /**
1125
1144
  * Skip cells while the predicate is true.
1126
1145
  */
1127
- skipWhile(t) {
1128
- let e = this;
1129
- const r = this.sheet.dimensions(), n = Math.max(r.rowCount, r.colCount) * 2;
1130
- for (let o = 0; o < n; o++) {
1131
- const i = e.cell();
1132
- if (!i.ok || !t(i.value)) break;
1133
- e = e.forward();
1146
+ skipWhile(e) {
1147
+ let t = this;
1148
+ const n = this.sheet.dimensions(), s = Math.max(n.rowCount, n.colCount) * 2;
1149
+ for (let l = 0; l < s; l++) {
1150
+ const u = t.cell();
1151
+ if (!u.ok || !e(u.value)) break;
1152
+ t = t.forward();
1134
1153
  }
1135
- return e;
1154
+ return t;
1136
1155
  }
1137
1156
  /**
1138
1157
  * Skip cells until the predicate is true.
1139
1158
  */
1140
- skipUntil(t) {
1141
- return this.skipWhile((e) => !t(e));
1159
+ skipUntil(e) {
1160
+ return this.skipWhile((t) => !e(t));
1142
1161
  }
1143
1162
  /**
1144
1163
  * Skip cells until a specific value is found.
1145
1164
  */
1146
- skipToValue(t) {
1147
- return this.skipUntil((e) => {
1148
- const r = e.value();
1149
- return r.ok && r.value === t;
1165
+ skipToValue(e) {
1166
+ return this.skipUntil((t) => {
1167
+ const n = t.value();
1168
+ return n.ok && n.value === e;
1150
1169
  });
1151
1170
  }
1152
1171
  /**
1153
1172
  * Skip a specific number of cells.
1154
1173
  */
1155
- skip(t) {
1156
- return this.forward(t);
1174
+ skip(e) {
1175
+ return this.forward(e);
1157
1176
  }
1158
1177
  // ---------------------------------------------------------------------------
1159
1178
  // GRAB OPERATIONS
@@ -1162,80 +1181,80 @@ class d {
1162
1181
  * Grab the current cell and move forward.
1163
1182
  */
1164
1183
  grab() {
1165
- const t = this.cell();
1166
- return t.ok ? l(
1184
+ const e = this.cell();
1185
+ return e.ok ? f(
1167
1186
  {
1168
- cell: t.value,
1187
+ cell: e.value,
1169
1188
  cursor: this.forward()
1170
1189
  },
1171
1190
  this.path
1172
- ) : t;
1191
+ ) : e;
1173
1192
  }
1174
1193
  /**
1175
1194
  * Grab n cells in the current direction.
1176
1195
  */
1177
- grabN(t) {
1178
- const e = [];
1179
- let r = this;
1180
- for (let n = 0; n < t; n++) {
1181
- const o = r.cell();
1182
- if (!o.ok)
1196
+ grabN(e) {
1197
+ const t = [];
1198
+ let n = this;
1199
+ for (let s = 0; s < e; s++) {
1200
+ const l = n.cell();
1201
+ if (!l.ok)
1183
1202
  break;
1184
- e.push(o.value), r = r.forward();
1203
+ t.push(l.value), n = n.forward();
1185
1204
  }
1186
- return e.length === 0 ? h("bounds", "No cells to grab", this.path) : l({ cells: e, cursor: r }, this.path);
1205
+ return t.length === 0 ? w("bounds", "No cells to grab", this.path) : f({ cells: t, cursor: n }, this.path);
1187
1206
  }
1188
1207
  /**
1189
1208
  * Grab cells while the predicate is true.
1190
1209
  */
1191
- grabWhile(t) {
1192
- const e = [];
1193
- let r = this;
1194
- const n = this.sheet.dimensions(), o = Math.max(n.rowCount, n.colCount) * 2;
1195
- for (let i = 0; i < o; i++) {
1196
- const a = r.cell();
1197
- if (!a.ok || !t(a.value)) break;
1198
- e.push(a.value), r = r.forward();
1210
+ grabWhile(e) {
1211
+ const t = [];
1212
+ let n = this;
1213
+ const s = this.sheet.dimensions(), l = Math.max(s.rowCount, s.colCount) * 2;
1214
+ for (let u = 0; u < l; u++) {
1215
+ const o = n.cell();
1216
+ if (!o.ok || !e(o.value)) break;
1217
+ t.push(o.value), n = n.forward();
1199
1218
  }
1200
- return l({ cells: e, cursor: r }, this.path);
1219
+ return f({ cells: t, cursor: n }, this.path);
1201
1220
  }
1202
1221
  /**
1203
1222
  * Grab cells until the predicate is true (not including the matching cell).
1204
1223
  */
1205
- grabUntil(t) {
1206
- return this.grabWhile((e) => !t(e));
1224
+ grabUntil(e) {
1225
+ return this.grabWhile((t) => !e(t));
1207
1226
  }
1208
1227
  /**
1209
1228
  * Grab the rest of the current row.
1210
1229
  */
1211
1230
  grabRow() {
1212
- const t = [], e = this.sheet.dimensions();
1213
- let r = this.setDirection("right");
1214
- for (let n = this._col; n <= e.endCol; n++) {
1215
- const o = r.cell();
1216
- if (!o.ok) break;
1217
- t.push(o.value), r = r.forward();
1231
+ const e = [], t = this.sheet.dimensions();
1232
+ let n = this.setDirection("right");
1233
+ for (let s = this._col; s <= t.endCol; s++) {
1234
+ const l = n.cell();
1235
+ if (!l.ok) break;
1236
+ e.push(l.value), n = n.forward();
1218
1237
  }
1219
- return l({ cells: t, cursor: r }, this.path);
1238
+ return f({ cells: e, cursor: n }, this.path);
1220
1239
  }
1221
1240
  /**
1222
1241
  * Grab the rest of the current column.
1223
1242
  */
1224
1243
  grabCol() {
1225
- const t = [], e = this.sheet.dimensions();
1226
- let r = this.setDirection("down");
1227
- for (let n = this._row; n <= e.endRow; n++) {
1228
- const o = r.cell();
1229
- if (!o.ok) break;
1230
- t.push(o.value), r = r.forward();
1244
+ const e = [], t = this.sheet.dimensions();
1245
+ let n = this.setDirection("down");
1246
+ for (let s = this._row; s <= t.endRow; s++) {
1247
+ const l = n.cell();
1248
+ if (!l.ok) break;
1249
+ e.push(l.value), n = n.forward();
1231
1250
  }
1232
- return l({ cells: t, cursor: r }, this.path);
1251
+ return f({ cells: e, cursor: n }, this.path);
1233
1252
  }
1234
1253
  /**
1235
1254
  * Grab non-empty cells in the current direction.
1236
1255
  */
1237
1256
  grabNonEmpty() {
1238
- return this.grabWhile((t) => !t.isEmpty());
1257
+ return this.grabWhile((e) => !e.isEmpty());
1239
1258
  }
1240
1259
  // ---------------------------------------------------------------------------
1241
1260
  // PEEK OPERATIONS
@@ -1249,21 +1268,21 @@ class d {
1249
1268
  /**
1250
1269
  * Peek at cells ahead without moving.
1251
1270
  */
1252
- peekAhead(t) {
1253
- const e = [];
1254
- let r = this;
1255
- for (let n = 0; n < t; n++) {
1256
- const o = r.cell();
1257
- if (!o.ok) break;
1258
- e.push(o.value), r = r.forward();
1271
+ peekAhead(e) {
1272
+ const t = [];
1273
+ let n = this;
1274
+ for (let s = 0; s < e; s++) {
1275
+ const l = n.cell();
1276
+ if (!l.ok) break;
1277
+ t.push(l.value), n = n.forward();
1259
1278
  }
1260
- return l(e, this.path);
1279
+ return f(t, this.path);
1261
1280
  }
1262
1281
  /**
1263
1282
  * Peek at a cell at an offset without moving.
1264
1283
  */
1265
- peekAt(t, e) {
1266
- return this.move(t, e).cell();
1284
+ peekAt(e, t) {
1285
+ return this.move(e, t).cell();
1267
1286
  }
1268
1287
  // ---------------------------------------------------------------------------
1269
1288
  // CURRENT CELL
@@ -1278,8 +1297,8 @@ class d {
1278
1297
  * Get the value of the current cell.
1279
1298
  */
1280
1299
  value() {
1281
- const t = this.cell();
1282
- return t.ok ? t.value.value() : t;
1300
+ const e = this.cell();
1301
+ return e.ok ? e.value.value() : e;
1283
1302
  }
1284
1303
  // ---------------------------------------------------------------------------
1285
1304
  // UTILITIES
@@ -1294,37 +1313,40 @@ class d {
1294
1313
  * Check if the current cell is empty.
1295
1314
  */
1296
1315
  isEmpty() {
1297
- const t = this.cell();
1298
- return t.ok && t.value.isEmpty();
1316
+ const e = this.cell();
1317
+ return e.ok && e.value.isEmpty();
1299
1318
  }
1300
1319
  /**
1301
1320
  * Check if the current cell is non-empty.
1302
1321
  */
1303
1322
  isNotEmpty() {
1304
- const t = this.cell();
1305
- return t.ok && !t.value.isEmpty();
1323
+ const e = this.cell();
1324
+ return e.ok && !e.value.isEmpty();
1306
1325
  }
1307
1326
  /**
1308
1327
  * Create a new cursor at the same position.
1309
1328
  */
1310
1329
  clone() {
1311
- return new d(this.sheet, this._row, this._col, this._direction);
1330
+ return new $(this.sheet, this._row, this._col, this._direction);
1312
1331
  }
1313
1332
  }
1314
- class k {
1315
- constructor(t, e, r) {
1316
- this.worksheet = t, this._path = e, this._file = r;
1333
+ class O {
1334
+ constructor(e, t, n) {
1335
+ this.worksheet = e, this._path = t, this._file = n;
1336
+ }
1337
+ get [N]() {
1338
+ return `XlsxSheet(${this.name})`;
1317
1339
  }
1318
1340
  /**
1319
1341
  * Creates an XlsxSheet from an ExcelJS worksheet.
1320
1342
  * @internal
1321
1343
  */
1322
- static fromExcelJS(t, e) {
1323
- const r = {
1324
- file: e,
1325
- sheet: t.name
1344
+ static fromExcelJS(e, t) {
1345
+ const n = {
1346
+ file: t,
1347
+ sheet: e.name
1326
1348
  };
1327
- return new k(t, r, e);
1349
+ return new O(e, n, t);
1328
1350
  }
1329
1351
  // ---------------------------------------------------------------------------
1330
1352
  // IDENTITY
@@ -1353,40 +1375,40 @@ class k {
1353
1375
  /**
1354
1376
  * Get a cell by its address (e.g., "A1", "B2").
1355
1377
  */
1356
- cell(t) {
1378
+ cell(e) {
1357
1379
  try {
1358
- p(t);
1359
- const e = this.worksheet.getCell(t);
1360
- return l(w.fromExcelJS(e, this.name, this._file), {
1380
+ V(e);
1381
+ const t = this.worksheet.getCell(e);
1382
+ return f(W.fromExcelJS(t, this.name, this._file), {
1361
1383
  ...this._path,
1362
- cell: t
1384
+ cell: e
1363
1385
  });
1364
1386
  } catch {
1365
- return h("range", `Invalid cell address: ${t}`, this._path);
1387
+ return w("range", `Invalid cell address: ${e}`, this._path);
1366
1388
  }
1367
1389
  }
1368
1390
  /**
1369
1391
  * Get a cell by row and column numbers (1-based).
1370
1392
  */
1371
- cellAt(t, e) {
1372
- if (t < 1 || e < 1)
1373
- return h(
1393
+ cellAt(e, t) {
1394
+ if (e < 1 || t < 1)
1395
+ return w(
1374
1396
  "bounds",
1375
- `Invalid cell coordinates: row=${t}, col=${e}`,
1397
+ `Invalid cell coordinates: row=${e}, col=${t}`,
1376
1398
  this._path
1377
1399
  );
1378
- const r = this.worksheet.getCell(t, e);
1379
- return l(w.fromExcelJS(r, this.name, this._file), {
1400
+ const n = this.worksheet.getCell(e, t);
1401
+ return f(W.fromExcelJS(n, this.name, this._file), {
1380
1402
  ...this._path,
1381
- cell: r.address
1403
+ cell: n.address
1382
1404
  });
1383
1405
  }
1384
1406
  /**
1385
1407
  * Get the value of a cell directly.
1386
1408
  */
1387
- getValue(t) {
1388
- const e = this.cell(t);
1389
- return e.ok ? e.value.value() : e;
1409
+ getValue(e) {
1410
+ const t = this.cell(e);
1411
+ return t.ok ? t.value.value() : t;
1390
1412
  }
1391
1413
  // ---------------------------------------------------------------------------
1392
1414
  // RANGE OPERATIONS
@@ -1394,26 +1416,26 @@ class k {
1394
1416
  /**
1395
1417
  * Get a range by its address (e.g., "A1:C10").
1396
1418
  */
1397
- range(t) {
1398
- return m.fromAddress(this.worksheet, t, this.name, this._file);
1419
+ range(e) {
1420
+ return y.fromAddress(this.worksheet, e, this.name, this._file);
1399
1421
  }
1400
1422
  /**
1401
1423
  * Get a range from start to end addresses.
1402
1424
  */
1403
- rangeFrom(t, e) {
1404
- return this.range(`${t}:${e}`);
1425
+ rangeFrom(e, t) {
1426
+ return this.range(`${e}:${t}`);
1405
1427
  }
1406
1428
  /**
1407
1429
  * Get a range by coordinates (1-based).
1408
1430
  */
1409
- rangeAt(t, e, r, n) {
1410
- return t < 1 || e < 1 || r < 1 || n < 1 ? h("bounds", "Invalid range coordinates", this._path) : l(
1411
- m.fromCoords(
1431
+ rangeAt(e, t, n, s) {
1432
+ return e < 1 || t < 1 || n < 1 || s < 1 ? w("bounds", "Invalid range coordinates", this._path) : f(
1433
+ y.fromCoords(
1412
1434
  this.worksheet,
1413
- t,
1414
1435
  e,
1415
- r,
1436
+ t,
1416
1437
  n,
1438
+ s,
1417
1439
  this.name,
1418
1440
  this._file
1419
1441
  ),
@@ -1424,14 +1446,14 @@ class k {
1424
1446
  * Get the used range of the sheet (cells with data).
1425
1447
  */
1426
1448
  usedRange() {
1427
- const t = this.dimensions();
1428
- return t.rowCount === 0 || t.colCount === 0 ? h("missing", "Sheet has no used cells", this._path) : l(
1429
- m.fromCoords(
1449
+ const e = this.dimensions();
1450
+ return e.rowCount === 0 || e.colCount === 0 ? w("missing", "Sheet has no used cells", this._path) : f(
1451
+ y.fromCoords(
1430
1452
  this.worksheet,
1431
- t.startRow,
1432
- t.startCol,
1433
- t.endRow,
1434
- t.endCol,
1453
+ e.startRow,
1454
+ e.startCol,
1455
+ e.endRow,
1456
+ e.endCol,
1435
1457
  this.name,
1436
1458
  this._file
1437
1459
  ),
@@ -1444,18 +1466,18 @@ class k {
1444
1466
  /**
1445
1467
  * Get a row as a range.
1446
1468
  */
1447
- row(t) {
1448
- const e = this.dimensions();
1449
- if (t < 1)
1450
- return h("bounds", `Invalid row number: ${t}`, this._path);
1451
- const r = Math.max(e.endCol, 1);
1452
- return l(
1453
- m.fromCoords(
1469
+ row(e) {
1470
+ const t = this.dimensions();
1471
+ if (e < 1)
1472
+ return w("bounds", `Invalid row number: ${e}`, this._path);
1473
+ const n = Math.max(t.endCol, 1);
1474
+ return f(
1475
+ y.fromCoords(
1454
1476
  this.worksheet,
1455
- t,
1477
+ e,
1456
1478
  1,
1457
- t,
1458
- r,
1479
+ e,
1480
+ n,
1459
1481
  this.name,
1460
1482
  this._file
1461
1483
  ),
@@ -1465,18 +1487,18 @@ class k {
1465
1487
  /**
1466
1488
  * Get a column as a range.
1467
1489
  */
1468
- col(t) {
1469
- const e = typeof t == "string" ? T(t.toUpperCase()) : t;
1470
- if (e < 1)
1471
- return h("bounds", `Invalid column: ${t}`, this._path);
1472
- const r = this.dimensions(), n = Math.max(r.endRow, 1);
1473
- return l(
1474
- m.fromCoords(
1490
+ col(e) {
1491
+ const t = typeof e == "string" ? ne(e.toUpperCase()) : e;
1492
+ if (t < 1)
1493
+ return w("bounds", `Invalid column: ${e}`, this._path);
1494
+ const n = this.dimensions(), s = Math.max(n.endRow, 1);
1495
+ return f(
1496
+ y.fromCoords(
1475
1497
  this.worksheet,
1476
1498
  1,
1477
- e,
1478
- n,
1479
- e,
1499
+ t,
1500
+ s,
1501
+ t,
1480
1502
  this.name,
1481
1503
  this._file
1482
1504
  ),
@@ -1487,14 +1509,14 @@ class k {
1487
1509
  * Iterate over all rows with data.
1488
1510
  */
1489
1511
  *rows() {
1490
- const t = this.dimensions();
1491
- for (let e = t.startRow; e <= t.endRow; e++)
1492
- yield m.fromCoords(
1512
+ const e = this.dimensions();
1513
+ for (let t = e.startRow; t <= e.endRow; t++)
1514
+ yield y.fromCoords(
1493
1515
  this.worksheet,
1494
- e,
1495
- t.startCol,
1496
- e,
1497
- t.endCol,
1516
+ t,
1517
+ e.startCol,
1518
+ t,
1519
+ e.endCol,
1498
1520
  this.name,
1499
1521
  this._file
1500
1522
  );
@@ -1503,14 +1525,14 @@ class k {
1503
1525
  * Iterate over all columns with data.
1504
1526
  */
1505
1527
  *cols() {
1506
- const t = this.dimensions();
1507
- for (let e = t.startCol; e <= t.endCol; e++)
1508
- yield m.fromCoords(
1528
+ const e = this.dimensions();
1529
+ for (let t = e.startCol; t <= e.endCol; t++)
1530
+ yield y.fromCoords(
1509
1531
  this.worksheet,
1510
- t.startRow,
1511
- e,
1512
- t.endRow,
1513
- e,
1532
+ e.startRow,
1533
+ t,
1534
+ e.endRow,
1535
+ t,
1514
1536
  this.name,
1515
1537
  this._file
1516
1538
  );
@@ -1521,15 +1543,15 @@ class k {
1521
1543
  /**
1522
1544
  * Create a cursor starting at the specified address.
1523
1545
  */
1524
- cursor(t) {
1525
- const e = t ?? "A1";
1526
- return d.create(this, e);
1546
+ cursor(e) {
1547
+ const t = e ?? "A1";
1548
+ return $.create(this, t);
1527
1549
  }
1528
1550
  /**
1529
1551
  * Create a cursor starting at the specified coordinates (1-based).
1530
1552
  */
1531
- cursorAt(t, e) {
1532
- return d.createAt(this, t, e);
1553
+ cursorAt(e, t) {
1554
+ return $.createAt(this, e, t);
1533
1555
  }
1534
1556
  // ---------------------------------------------------------------------------
1535
1557
  // QUERY METHODS
@@ -1537,37 +1559,37 @@ class k {
1537
1559
  /**
1538
1560
  * Find the first cell matching the predicate.
1539
1561
  */
1540
- find(t) {
1541
- const e = this.usedRange();
1542
- return e.ok ? e.value.find(t) : e;
1562
+ find(e) {
1563
+ const t = this.usedRange();
1564
+ return t.ok ? t.value.find(e) : t;
1543
1565
  }
1544
1566
  /**
1545
1567
  * Find all cells matching the predicate.
1546
1568
  */
1547
- findAll(t) {
1548
- const e = this.usedRange();
1549
- return e.ok ? e.value.findAll(t) : [];
1569
+ findAll(e) {
1570
+ const t = this.usedRange();
1571
+ return t.ok ? t.value.findAll(e) : [];
1550
1572
  }
1551
1573
  /**
1552
1574
  * Find the first cell with the specified value.
1553
1575
  */
1554
- findValue(t) {
1555
- const e = this.usedRange();
1556
- return e.ok ? e.value.findValue(t) : e;
1576
+ findValue(e) {
1577
+ const t = this.usedRange();
1578
+ return t.ok ? t.value.findValue(e) : t;
1557
1579
  }
1558
1580
  /**
1559
1581
  * Find cells within a specific range matching the predicate.
1560
1582
  */
1561
- findInRange(t, e) {
1562
- const r = this.range(t);
1563
- return r.ok ? r.value.find(e) : r;
1583
+ findInRange(e, t) {
1584
+ const n = this.range(e);
1585
+ return n.ok ? n.value.find(t) : n;
1564
1586
  }
1565
1587
  /**
1566
1588
  * Find all cells within a specific range matching the predicate.
1567
1589
  */
1568
- findAllInRange(t, e) {
1569
- const r = this.range(t);
1570
- return r.ok ? r.value.findAll(e) : [];
1590
+ findAllInRange(e, t) {
1591
+ const n = this.range(e);
1592
+ return n.ok ? n.value.findAll(t) : [];
1571
1593
  }
1572
1594
  // ---------------------------------------------------------------------------
1573
1595
  // DIMENSIONS
@@ -1576,24 +1598,24 @@ class k {
1576
1598
  * Get the dimensions of the used area.
1577
1599
  */
1578
1600
  dimensions() {
1579
- const t = this.worksheet.rowCount, e = this.worksheet.columnCount;
1580
- let r = 1, n = t, o = 1, i = e;
1601
+ const e = this.worksheet.rowCount, t = this.worksheet.columnCount;
1602
+ let n = 1, s = e, l = 1, u = t;
1581
1603
  if (this.worksheet.dimensions) {
1582
- const a = this.worksheet.dimensions;
1583
- if (typeof a == "string")
1604
+ const o = this.worksheet.dimensions;
1605
+ if (typeof o == "string")
1584
1606
  try {
1585
- const u = y(a);
1586
- r = u.start.row, o = u.start.col, n = u.end.row, i = u.end.col;
1607
+ const a = H(o);
1608
+ n = a.start.row, l = a.start.col, s = a.end.row, u = a.end.col;
1587
1609
  } catch {
1588
1610
  }
1589
1611
  }
1590
1612
  return {
1591
- startRow: r,
1592
- endRow: n,
1593
- startCol: o,
1594
- endCol: i,
1595
- rowCount: n - r + 1,
1596
- colCount: i - o + 1
1613
+ startRow: n,
1614
+ endRow: s,
1615
+ startCol: l,
1616
+ endCol: u,
1617
+ rowCount: s - n + 1,
1618
+ colCount: u - l + 1
1597
1619
  };
1598
1620
  }
1599
1621
  /**
@@ -1615,15 +1637,15 @@ class k {
1615
1637
  * Get all merged cell ranges.
1616
1638
  */
1617
1639
  mergedRanges() {
1618
- const t = this.worksheet._merges;
1619
- return t ? Object.keys(t) : [];
1640
+ const e = this.worksheet._merges;
1641
+ return e ? Object.keys(e) : [];
1620
1642
  }
1621
1643
  /**
1622
1644
  * Check if a cell is part of a merged range.
1623
1645
  */
1624
- isMerged(t) {
1625
- const e = this.cell(t);
1626
- return e.ok ? e.value.isMerged() : !1;
1646
+ isMerged(e) {
1647
+ const t = this.cell(e);
1648
+ return t.ok ? t.value.isMerged() : !1;
1627
1649
  }
1628
1650
  // ---------------------------------------------------------------------------
1629
1651
  // INTERNAL HELPERS
@@ -1639,23 +1661,26 @@ class k {
1639
1661
  * Get a cell by coordinates for internal use.
1640
1662
  * @internal
1641
1663
  */
1642
- getCellInternal(t, e) {
1643
- if (t < 1 || e < 1) return;
1644
- const r = this.worksheet.getCell(t, e);
1645
- return w.fromExcelJS(r, this.name, this._file);
1664
+ getCellInternal(e, t) {
1665
+ if (e < 1 || t < 1) return;
1666
+ const n = this.worksheet.getCell(e, t);
1667
+ return W.fromExcelJS(n, this.name, this._file);
1646
1668
  }
1647
1669
  }
1648
- class v {
1649
- constructor(t, e) {
1650
- this.workbook = t, this._path = e, this.sheetsCache = /* @__PURE__ */ new Map();
1670
+ class z {
1671
+ constructor(e, t) {
1672
+ this.workbook = e, this._path = t, this.sheetsCache = /* @__PURE__ */ new Map();
1673
+ }
1674
+ get [N]() {
1675
+ return `XlsxWorkbook(${this.sheetCount()} sheets)`;
1651
1676
  }
1652
1677
  /**
1653
1678
  * Creates an XlsxWorkbook from an ExcelJS workbook.
1654
1679
  * @internal
1655
1680
  */
1656
- static fromExcelJS(t, e) {
1657
- const r = { file: e };
1658
- return new v(t, r);
1681
+ static fromExcelJS(e, t) {
1682
+ const n = { file: t };
1683
+ return new z(e, n);
1659
1684
  }
1660
1685
  // ---------------------------------------------------------------------------
1661
1686
  // IDENTITY
@@ -1678,66 +1703,58 @@ class v {
1678
1703
  /**
1679
1704
  * Get a sheet by name.
1680
1705
  */
1681
- sheet(t) {
1682
- const e = this.sheetsCache.get(t);
1683
- if (e)
1684
- return l(e, { ...this._path, sheet: t });
1685
- const r = this.workbook.getWorksheet(t);
1686
- if (!r)
1687
- return h(
1688
- "missing",
1689
- `Sheet "${t}" not found`,
1690
- this._path
1691
- );
1692
- const n = k.fromExcelJS(r, this._path.file);
1693
- return this.sheetsCache.set(t, n), l(n, n.path);
1706
+ sheet(e) {
1707
+ const t = this.sheetsCache.get(e);
1708
+ if (t)
1709
+ return f(t, { ...this._path, sheet: e });
1710
+ const n = this.workbook.getWorksheet(e);
1711
+ if (!n)
1712
+ return w("missing", `Sheet "${e}" not found`, this._path);
1713
+ const s = O.fromExcelJS(n, this._path.file);
1714
+ return this.sheetsCache.set(e, s), f(s, s.path);
1694
1715
  }
1695
1716
  /**
1696
1717
  * Get a sheet by index (1-based, as per Excel convention).
1697
1718
  */
1698
- sheetAt(t) {
1699
- if (t < 1)
1700
- return h(
1719
+ sheetAt(e) {
1720
+ if (e < 1)
1721
+ return w(
1701
1722
  "bounds",
1702
- `Sheet index must be >= 1, got ${t}`,
1703
- this._path
1704
- );
1705
- const e = this.workbook.getWorksheet(t);
1706
- if (!e)
1707
- return h(
1708
- "missing",
1709
- `Sheet at index ${t} not found`,
1723
+ `Sheet index must be >= 1, got ${e}`,
1710
1724
  this._path
1711
1725
  );
1712
- const r = this.sheetsCache.get(e.name);
1713
- if (r)
1714
- return l(r, r.path);
1715
- const n = k.fromExcelJS(e, this._path.file);
1716
- return this.sheetsCache.set(e.name, n), l(n, n.path);
1726
+ const t = this.workbook.getWorksheet(e);
1727
+ if (!t)
1728
+ return w("missing", `Sheet at index ${e} not found`, this._path);
1729
+ const n = this.sheetsCache.get(t.name);
1730
+ if (n)
1731
+ return f(n, n.path);
1732
+ const s = O.fromExcelJS(t, this._path.file);
1733
+ return this.sheetsCache.set(t.name, s), f(s, s.path);
1717
1734
  }
1718
1735
  /**
1719
1736
  * Get all sheets.
1720
1737
  */
1721
1738
  sheets() {
1722
- const t = [];
1723
- return this.workbook.eachSheet((e) => {
1724
- const r = this.sheetsCache.get(e.name);
1725
- if (r)
1726
- t.push(r);
1739
+ const e = [];
1740
+ return this.workbook.eachSheet((t) => {
1741
+ const n = this.sheetsCache.get(t.name);
1742
+ if (n)
1743
+ e.push(n);
1727
1744
  else {
1728
- const n = k.fromExcelJS(e, this._path.file);
1729
- this.sheetsCache.set(e.name, n), t.push(n);
1745
+ const s = O.fromExcelJS(t, this._path.file);
1746
+ this.sheetsCache.set(t.name, s), e.push(s);
1730
1747
  }
1731
- }), t;
1748
+ }), e;
1732
1749
  }
1733
1750
  /**
1734
1751
  * Get all sheet names.
1735
1752
  */
1736
1753
  sheetNames() {
1737
- const t = [];
1738
- return this.workbook.eachSheet((e) => {
1739
- t.push(e.name);
1740
- }), t;
1754
+ const e = [];
1755
+ return this.workbook.eachSheet((t) => {
1756
+ e.push(t.name);
1757
+ }), e;
1741
1758
  }
1742
1759
  /**
1743
1760
  * Get the number of sheets.
@@ -1755,8 +1772,8 @@ class v {
1755
1772
  * Get the last sheet.
1756
1773
  */
1757
1774
  lastSheet() {
1758
- const t = this.sheetCount();
1759
- return t === 0 ? h("missing", "Workbook has no sheets", this._path) : this.sheetAt(t);
1775
+ const e = this.sheetCount();
1776
+ return e === 0 ? w("missing", "Workbook has no sheets", this._path) : this.sheetAt(e);
1760
1777
  }
1761
1778
  // ---------------------------------------------------------------------------
1762
1779
  // PREDICATES
@@ -1764,39 +1781,35 @@ class v {
1764
1781
  /**
1765
1782
  * Check if a sheet with the given name exists.
1766
1783
  */
1767
- hasSheet(t) {
1768
- return this.workbook.getWorksheet(t) !== void 0;
1784
+ hasSheet(e) {
1785
+ return this.workbook.getWorksheet(e) !== void 0;
1769
1786
  }
1770
1787
  /**
1771
1788
  * Find the first sheet matching the predicate.
1772
1789
  */
1773
- findSheet(t) {
1774
- for (const e of this.sheets())
1775
- if (t(e))
1776
- return l(e, e.path);
1777
- return h(
1778
- "missing",
1779
- "No sheet matching predicate found",
1780
- this._path
1781
- );
1790
+ findSheet(e) {
1791
+ for (const t of this.sheets())
1792
+ if (e(t))
1793
+ return f(t, t.path);
1794
+ return w("missing", "No sheet matching predicate found", this._path);
1782
1795
  }
1783
1796
  /**
1784
1797
  * Find all sheets matching the predicate.
1785
1798
  */
1786
- filterSheets(t) {
1787
- return this.sheets().filter(t);
1799
+ filterSheets(e) {
1800
+ return this.sheets().filter(e);
1788
1801
  }
1789
1802
  /**
1790
1803
  * Find a sheet by name pattern (regex).
1791
1804
  */
1792
- findSheetByPattern(t) {
1793
- return this.findSheet((e) => t.test(e.name));
1805
+ findSheetByPattern(e) {
1806
+ return this.findSheet((t) => e.test(t.name));
1794
1807
  }
1795
1808
  /**
1796
1809
  * Find all sheets by name pattern (regex).
1797
1810
  */
1798
- filterSheetsByPattern(t) {
1799
- return this.filterSheets((e) => t.test(e.name));
1811
+ filterSheetsByPattern(e) {
1812
+ return this.filterSheets((t) => e.test(t.name));
1800
1813
  }
1801
1814
  // ---------------------------------------------------------------------------
1802
1815
  // WORKBOOK PROPERTIES
@@ -1848,20 +1861,20 @@ class v {
1848
1861
  * Iterate over all sheets.
1849
1862
  */
1850
1863
  *[Symbol.iterator]() {
1851
- for (const t of this.sheets())
1852
- yield t;
1864
+ for (const e of this.sheets())
1865
+ yield e;
1853
1866
  }
1854
1867
  /**
1855
1868
  * Execute a function for each sheet.
1856
1869
  */
1857
- forEach(t) {
1858
- this.sheets().forEach(t);
1870
+ forEach(e) {
1871
+ this.sheets().forEach(e);
1859
1872
  }
1860
1873
  /**
1861
1874
  * Map over all sheets.
1862
1875
  */
1863
- map(t) {
1864
- return this.sheets().map(t);
1876
+ map(e) {
1877
+ return this.sheets().map(e);
1865
1878
  }
1866
1879
  // ---------------------------------------------------------------------------
1867
1880
  // INTERNAL
@@ -1874,44 +1887,44 @@ class v {
1874
1887
  return this.workbook;
1875
1888
  }
1876
1889
  }
1877
- const q = {
1890
+ const Oe = {
1878
1891
  // ---------------------------------------------------------------------------
1879
1892
  // VALUE PREDICATES
1880
1893
  // ---------------------------------------------------------------------------
1881
1894
  /**
1882
1895
  * Match cells with the exact value.
1883
1896
  */
1884
- equals: (s) => (t) => {
1885
- const e = t.value();
1886
- return e.ok ? s === null ? e.value === null : e.value === null ? !1 : s instanceof Date && e.value instanceof Date ? s.getTime() === e.value.getTime() : e.value === s : !1;
1897
+ equals: (r) => (e) => {
1898
+ const t = e.value();
1899
+ return t.ok ? r === null ? t.value === null : t.value === null ? !1 : r instanceof Date && t.value instanceof Date ? r.getTime() === t.value.getTime() : t.value === r : !1;
1887
1900
  },
1888
1901
  /**
1889
1902
  * Match cells containing the specified text (case-insensitive by default).
1890
1903
  */
1891
- contains: (s, t = !1) => (e) => {
1892
- const r = e.string();
1893
- return r.ok ? t ? r.value.includes(s) : r.value.toLowerCase().includes(s.toLowerCase()) : !1;
1904
+ contains: (r, e = !1) => (t) => {
1905
+ const n = t.string();
1906
+ return n.ok ? e ? n.value.includes(r) : n.value.toLowerCase().includes(r.toLowerCase()) : !1;
1894
1907
  },
1895
1908
  /**
1896
1909
  * Match cells whose value matches the regex pattern.
1897
1910
  */
1898
- matches: (s) => (t) => {
1899
- const e = t.string();
1900
- return e.ok ? s.test(e.value) : !1;
1911
+ matches: (r) => (e) => {
1912
+ const t = e.string();
1913
+ return t.ok ? r.test(t.value) : !1;
1901
1914
  },
1902
1915
  /**
1903
1916
  * Match cells whose string value starts with the prefix.
1904
1917
  */
1905
- startsWith: (s, t = !1) => (e) => {
1906
- const r = e.string();
1907
- return r.ok ? t ? r.value.startsWith(s) : r.value.toLowerCase().startsWith(s.toLowerCase()) : !1;
1918
+ startsWith: (r, e = !1) => (t) => {
1919
+ const n = t.string();
1920
+ return n.ok ? e ? n.value.startsWith(r) : n.value.toLowerCase().startsWith(r.toLowerCase()) : !1;
1908
1921
  },
1909
1922
  /**
1910
1923
  * Match cells whose string value ends with the suffix.
1911
1924
  */
1912
- endsWith: (s, t = !1) => (e) => {
1913
- const r = e.string();
1914
- return r.ok ? t ? r.value.endsWith(s) : r.value.toLowerCase().endsWith(s.toLowerCase()) : !1;
1925
+ endsWith: (r, e = !1) => (t) => {
1926
+ const n = t.string();
1927
+ return n.ok ? e ? n.value.endsWith(r) : n.value.toLowerCase().endsWith(r.toLowerCase()) : !1;
1915
1928
  },
1916
1929
  // ---------------------------------------------------------------------------
1917
1930
  // TYPE PREDICATES
@@ -1919,76 +1932,76 @@ const q = {
1919
1932
  /**
1920
1933
  * Match cells containing a string value.
1921
1934
  */
1922
- isString: () => (s) => s.isString(),
1935
+ isString: () => (r) => r.isString(),
1923
1936
  /**
1924
1937
  * Match cells containing a numeric value.
1925
1938
  */
1926
- isNumber: () => (s) => s.isNumber(),
1939
+ isNumber: () => (r) => r.isNumber(),
1927
1940
  /**
1928
1941
  * Match cells containing a boolean value.
1929
1942
  */
1930
- isBoolean: () => (s) => s.isBoolean(),
1943
+ isBoolean: () => (r) => r.isBoolean(),
1931
1944
  /**
1932
1945
  * Match cells containing a date value.
1933
1946
  */
1934
- isDate: () => (s) => s.isDate(),
1947
+ isDate: () => (r) => r.isDate(),
1935
1948
  /**
1936
1949
  * Match empty cells.
1937
1950
  */
1938
- isEmpty: () => (s) => s.isEmpty(),
1951
+ isEmpty: () => (r) => r.isEmpty(),
1939
1952
  /**
1940
1953
  * Match non-empty cells.
1941
1954
  */
1942
- isNotEmpty: () => (s) => !s.isEmpty(),
1955
+ isNotEmpty: () => (r) => !r.isEmpty(),
1943
1956
  /**
1944
1957
  * Match cells containing a formula.
1945
1958
  */
1946
- isFormula: () => (s) => s.isFormula(),
1959
+ isFormula: () => (r) => r.isFormula(),
1947
1960
  /**
1948
1961
  * Match cells containing an error.
1949
1962
  */
1950
- isError: () => (s) => s.isError(),
1963
+ isError: () => (r) => r.isError(),
1951
1964
  /**
1952
1965
  * Match merged cells.
1953
1966
  */
1954
- isMerged: () => (s) => s.isMerged(),
1967
+ isMerged: () => (r) => r.isMerged(),
1955
1968
  // ---------------------------------------------------------------------------
1956
1969
  // NUMERIC PREDICATES
1957
1970
  // ---------------------------------------------------------------------------
1958
1971
  /**
1959
1972
  * Match cells with numeric value greater than n.
1960
1973
  */
1961
- greaterThan: (s) => (t) => {
1962
- const e = t.number();
1963
- return e.ok && e.value > s;
1974
+ greaterThan: (r) => (e) => {
1975
+ const t = e.number();
1976
+ return t.ok && t.value > r;
1964
1977
  },
1965
1978
  /**
1966
1979
  * Match cells with numeric value greater than or equal to n.
1967
1980
  */
1968
- greaterThanOrEqual: (s) => (t) => {
1969
- const e = t.number();
1970
- return e.ok && e.value >= s;
1981
+ greaterThanOrEqual: (r) => (e) => {
1982
+ const t = e.number();
1983
+ return t.ok && t.value >= r;
1971
1984
  },
1972
1985
  /**
1973
1986
  * Match cells with numeric value less than n.
1974
1987
  */
1975
- lessThan: (s) => (t) => {
1976
- const e = t.number();
1977
- return e.ok && e.value < s;
1988
+ lessThan: (r) => (e) => {
1989
+ const t = e.number();
1990
+ return t.ok && t.value < r;
1978
1991
  },
1979
1992
  /**
1980
1993
  * Match cells with numeric value less than or equal to n.
1981
1994
  */
1982
- lessThanOrEqual: (s) => (t) => {
1983
- const e = t.number();
1984
- return e.ok && e.value <= s;
1995
+ lessThanOrEqual: (r) => (e) => {
1996
+ const t = e.number();
1997
+ return t.ok && t.value <= r;
1985
1998
  },
1986
1999
  /**
1987
2000
  * Match cells with numeric value between min and max (inclusive).
1988
2001
  */
1989
- between: (s, t) => (e) => {
1990
- const r = e.number();
1991
- return r.ok && r.value >= s && r.value <= t;
2002
+ between: (r, e) => (t) => {
2003
+ const n = t.number();
2004
+ return n.ok && n.value >= r && n.value <= e;
1992
2005
  },
1993
2006
  // ---------------------------------------------------------------------------
1994
2007
  // DATE PREDICATES
@@ -1996,25 +2009,25 @@ const q = {
1996
2009
  /**
1997
2010
  * Match cells with date before the specified date.
1998
2011
  */
1999
- dateBefore: (s) => (t) => {
2000
- const e = t.date();
2001
- return e.ok && e.value.getTime() < s.getTime();
2012
+ dateBefore: (r) => (e) => {
2013
+ const t = e.date();
2014
+ return t.ok && t.value.getTime() < r.getTime();
2002
2015
  },
2003
2016
  /**
2004
2017
  * Match cells with date after the specified date.
2005
2018
  */
2006
- dateAfter: (s) => (t) => {
2007
- const e = t.date();
2008
- return e.ok && e.value.getTime() > s.getTime();
2019
+ dateAfter: (r) => (e) => {
2020
+ const t = e.date();
2021
+ return t.ok && t.value.getTime() > r.getTime();
2009
2022
  },
2010
2023
  /**
2011
2024
  * Match cells with date between start and end (inclusive).
2012
2025
  */
2013
- dateBetween: (s, t) => (e) => {
2014
- const r = e.date();
2015
- if (!r.ok) return !1;
2016
- const n = r.value.getTime();
2017
- return n >= s.getTime() && n <= t.getTime();
2026
+ dateBetween: (r, e) => (t) => {
2027
+ const n = t.date();
2028
+ if (!n.ok) return !1;
2029
+ const s = n.value.getTime();
2030
+ return s >= r.getTime() && s <= e.getTime();
2018
2031
  },
2019
2032
  // ---------------------------------------------------------------------------
2020
2033
  // LOCATION PREDICATES
@@ -2022,49 +2035,49 @@ const q = {
2022
2035
  /**
2023
2036
  * Match cells in the specified row.
2024
2037
  */
2025
- inRow: (s) => (t) => t.row === s,
2038
+ inRow: (r) => (e) => e.row === r,
2026
2039
  /**
2027
2040
  * Match cells in the specified column.
2028
2041
  */
2029
- inCol: (s) => (t) => t.col === s,
2042
+ inCol: (r) => (e) => e.col === r,
2030
2043
  /**
2031
2044
  * Match cells in the specified column (by letter).
2032
2045
  */
2033
- inColLetter: (s) => (t) => t.colLetter.toUpperCase() === s.toUpperCase(),
2046
+ inColLetter: (r) => (e) => e.colLetter.toUpperCase() === r.toUpperCase(),
2034
2047
  // ---------------------------------------------------------------------------
2035
2048
  // COMPOSITION
2036
2049
  // ---------------------------------------------------------------------------
2037
2050
  /**
2038
2051
  * Match cells that satisfy all predicates.
2039
2052
  */
2040
- and: (...s) => (t) => s.every((e) => e(t)),
2053
+ and: (...r) => (e) => r.every((t) => t(e)),
2041
2054
  /**
2042
2055
  * Match cells that satisfy at least one predicate.
2043
2056
  */
2044
- or: (...s) => (t) => s.some((e) => e(t)),
2057
+ or: (...r) => (e) => r.some((t) => t(e)),
2045
2058
  /**
2046
2059
  * Match cells that do not satisfy the predicate.
2047
2060
  */
2048
- not: (s) => (t) => !s(t),
2061
+ not: (r) => (e) => !r(e),
2049
2062
  // ---------------------------------------------------------------------------
2050
2063
  // STYLE PREDICATES
2051
2064
  // ---------------------------------------------------------------------------
2052
2065
  /**
2053
2066
  * Match cells with bold font.
2054
2067
  */
2055
- isBold: () => (s) => s.style().font?.bold === !0,
2068
+ isBold: () => (r) => r.style().font?.bold === !0,
2056
2069
  /**
2057
2070
  * Match cells with italic font.
2058
2071
  */
2059
- isItalic: () => (s) => s.style().font?.italic === !0,
2072
+ isItalic: () => (r) => r.style().font?.italic === !0,
2060
2073
  /**
2061
2074
  * Match cells with a hyperlink.
2062
2075
  */
2063
- hasHyperlink: () => (s) => s.hyperlink().ok,
2076
+ hasHyperlink: () => (r) => r.hyperlink().ok,
2064
2077
  /**
2065
2078
  * Match cells with a comment.
2066
2079
  */
2067
- hasComment: () => (s) => s.comment().ok,
2080
+ hasComment: () => (r) => r.comment().ok,
2068
2081
  // ---------------------------------------------------------------------------
2069
2082
  // UTILITY
2070
2083
  // ---------------------------------------------------------------------------
@@ -2079,179 +2092,1659 @@ const q = {
2079
2092
  /**
2080
2093
  * Create a custom predicate from a function.
2081
2094
  */
2082
- custom: (s) => s
2095
+ custom: (r) => r
2083
2096
  };
2084
- function H(s) {
2097
+ function x(r, e) {
2098
+ return { kind: "extract", format: "xlsx", steps: r, extract: e };
2099
+ }
2100
+ class g {
2101
+ /** @internal */
2102
+ constructor(e) {
2103
+ this.steps = e;
2104
+ }
2105
+ /** @internal Expose steps for colWhere/rowWhere headerRef */
2106
+ get _steps() {
2107
+ return this.steps;
2108
+ }
2109
+ // ---------------------------------------------------------------------------
2110
+ // Terminal extraction
2111
+ // ---------------------------------------------------------------------------
2112
+ /** Extract cell value as string */
2113
+ string() {
2114
+ return x(this.steps, "string");
2115
+ }
2116
+ /** Extract cell value as number */
2117
+ number() {
2118
+ return x(this.steps, "number");
2119
+ }
2120
+ /** Extract cell value as boolean */
2121
+ boolean() {
2122
+ return x(this.steps, "boolean");
2123
+ }
2124
+ /** Extract cell value as Date */
2125
+ date() {
2126
+ return x(this.steps, "date");
2127
+ }
2128
+ /** Extract raw cell value */
2129
+ value() {
2130
+ return x(this.steps, "value");
2131
+ }
2132
+ /** Extract cell formula */
2133
+ formula() {
2134
+ return x(this.steps, "formula");
2135
+ }
2136
+ // ---------------------------------------------------------------------------
2137
+ // Relative movement (cell → cell)
2138
+ // ---------------------------------------------------------------------------
2139
+ /** Move right by count cells (default 1) */
2140
+ right(e = 1) {
2141
+ return new g([...this.steps, { kind: "right", count: e }]);
2142
+ }
2143
+ /** Move left by count cells (default 1) */
2144
+ left(e = 1) {
2145
+ return new g([...this.steps, { kind: "left", count: e }]);
2146
+ }
2147
+ /** Move up by count cells (default 1) */
2148
+ up(e = 1) {
2149
+ return new g([...this.steps, { kind: "up", count: e }]);
2150
+ }
2151
+ /** Move down by count cells (default 1) */
2152
+ down(e = 1) {
2153
+ return new g([...this.steps, { kind: "down", count: e }]);
2154
+ }
2155
+ /** Move by row and column deltas */
2156
+ offset(e, t) {
2157
+ return new g([
2158
+ ...this.steps,
2159
+ { kind: "offset", rowDelta: e, colDelta: t }
2160
+ ]);
2161
+ }
2162
+ /** Scan in direction until predicate matches */
2163
+ scanTo(e, t) {
2164
+ return new g([
2165
+ ...this.steps,
2166
+ { kind: "scanTo", direction: e, predicate: t._spec }
2167
+ ]);
2168
+ }
2169
+ /** Skip cells in direction while predicate matches, land on first non-matching */
2170
+ skipWhile(e, t) {
2171
+ return new g([
2172
+ ...this.steps,
2173
+ { kind: "skipWhile", direction: e, predicate: t._spec }
2174
+ ]);
2175
+ }
2176
+ // ---------------------------------------------------------------------------
2177
+ // Collection (cell → array via collect)
2178
+ // ---------------------------------------------------------------------------
2179
+ /**
2180
+ * Iterate over cells from this position in a direction while the predicate matches.
2181
+ * Returns an ArraySpec whose items are produced by the itemMapper.
2182
+ */
2183
+ eachCell(e, t, n) {
2184
+ const s = n(new g([])), l = {
2185
+ kind: "eachCell",
2186
+ direction: e,
2187
+ while: t._spec
2188
+ };
2189
+ return {
2190
+ kind: "array",
2191
+ source: x(this.steps, l),
2192
+ items: s
2193
+ };
2194
+ }
2195
+ /**
2196
+ * Iterate over slices (rows or columns) from this cell position.
2197
+ * Each slice is passed as an XlsxSliceSB to the mapper, providing
2198
+ * header-relative column/row access via colWhere/rowWhere.
2199
+ */
2200
+ eachSlice(e, t, n) {
2201
+ const s = n(new pe([])), l = {
2202
+ kind: "eachSlice",
2203
+ direction: e,
2204
+ while: t._spec
2205
+ };
2206
+ return {
2207
+ kind: "array",
2208
+ source: x(this.steps, l),
2209
+ items: s
2210
+ };
2211
+ }
2212
+ }
2213
+ class pe {
2214
+ /** @internal */
2215
+ constructor(e) {
2216
+ this.steps = e;
2217
+ }
2218
+ /** Access a column by matching its header cell against a predicate (header-relative) */
2219
+ colWhere(e, t) {
2220
+ const n = x(e._steps, "value");
2221
+ return new g([
2222
+ ...this.steps,
2223
+ { kind: "colWhere", headerRef: n, predicate: t._spec }
2224
+ ]);
2225
+ }
2226
+ /** Access a row by matching its header cell against a predicate (header-relative, for rotated tables) */
2227
+ rowWhere(e, t) {
2228
+ const n = x(e._steps, "value");
2229
+ return new g([
2230
+ ...this.steps,
2231
+ { kind: "rowWhere", headerRef: n, predicate: t._spec }
2232
+ ]);
2233
+ }
2234
+ /** Access a column by 0-based offset from the anchor */
2235
+ col(e) {
2236
+ return new g([
2237
+ ...this.steps,
2238
+ { kind: "offset", rowDelta: 0, colDelta: e }
2239
+ ]);
2240
+ }
2241
+ /** Access a row by 0-based offset from the anchor (for rotated tables) */
2242
+ row(e) {
2243
+ return new g([
2244
+ ...this.steps,
2245
+ { kind: "offset", rowDelta: e, colDelta: 0 }
2246
+ ]);
2247
+ }
2248
+ }
2249
+ class ve {
2250
+ /** @internal */
2251
+ constructor(e) {
2252
+ this.steps = e;
2253
+ }
2254
+ /** Access a column by 1-based index within the row */
2255
+ col(e) {
2256
+ return new g([...this.steps, { kind: "col", index: e }]);
2257
+ }
2258
+ /** Navigate to a cell by address within the row */
2259
+ cell(e) {
2260
+ return new g([...this.steps, { kind: "cell", ref: e }]);
2261
+ }
2262
+ }
2263
+ class te {
2264
+ /** @internal */
2265
+ constructor(e) {
2266
+ this.steps = e;
2267
+ }
2268
+ /** Navigate to a cell by address within the range */
2269
+ cell(e) {
2270
+ return new g([...this.steps, { kind: "cell", ref: e }]);
2271
+ }
2272
+ /** Navigate to a cell by coordinates within the range */
2273
+ cellAt(e, t) {
2274
+ return new g([...this.steps, { kind: "cellAt", row: e, col: t }]);
2275
+ }
2276
+ /**
2277
+ * Iterate over rows in the range.
2278
+ * Each row is provided as an XlsxRowItemSB to the mapper.
2279
+ * Returns an ArraySpec.
2280
+ */
2281
+ rows(e) {
2282
+ const t = e(new ve([]));
2283
+ return {
2284
+ kind: "array",
2285
+ source: x(this.steps, "rows"),
2286
+ items: t
2287
+ };
2288
+ }
2289
+ /**
2290
+ * Iterate over all cells in the range as a flat list.
2291
+ * Each cell is provided as an XlsxCellSB to the mapper.
2292
+ * Returns an ArraySpec.
2293
+ */
2294
+ cells(e) {
2295
+ const t = e(new g([]));
2296
+ return {
2297
+ kind: "array",
2298
+ source: x(this.steps, "cells"),
2299
+ items: t
2300
+ };
2301
+ }
2302
+ }
2303
+ class be {
2304
+ /** @internal */
2305
+ constructor(e) {
2306
+ this.steps = e;
2307
+ }
2308
+ /** Navigate to a cell by address within this row */
2309
+ cell(e) {
2310
+ return new g([...this.steps, { kind: "cell", ref: e }]);
2311
+ }
2312
+ /** Navigate to a cell by column within this row */
2313
+ cellAt(e, t) {
2314
+ return new g([...this.steps, { kind: "cellAt", row: e, col: t }]);
2315
+ }
2316
+ }
2317
+ class _e {
2318
+ /** @internal */
2319
+ constructor(e) {
2320
+ this.steps = e;
2321
+ }
2322
+ /** Navigate to a cell by address within this column */
2323
+ cell(e) {
2324
+ return new g([...this.steps, { kind: "cell", ref: e }]);
2325
+ }
2326
+ /** Navigate to a cell by coordinates within this column */
2327
+ cellAt(e, t) {
2328
+ return new g([...this.steps, { kind: "cellAt", row: e, col: t }]);
2329
+ }
2330
+ }
2331
+ class U {
2332
+ /** @internal */
2333
+ constructor(e) {
2334
+ this.steps = e;
2335
+ }
2336
+ // ---------------------------------------------------------------------------
2337
+ // Direct cell navigation
2338
+ // ---------------------------------------------------------------------------
2339
+ /** Navigate to a cell by address (e.g., "A1", "B2") */
2340
+ cell(e) {
2341
+ return new g([...this.steps, { kind: "cell", ref: e }]);
2342
+ }
2343
+ /** Navigate to a cell by 1-based row and column coordinates */
2344
+ cellAt(e, t) {
2345
+ return new g([...this.steps, { kind: "cellAt", row: e, col: t }]);
2346
+ }
2347
+ // ---------------------------------------------------------------------------
2348
+ // Cell search (sheet → cell)
2349
+ // ---------------------------------------------------------------------------
2350
+ /** Find the first cell matching the predicate */
2351
+ find(e) {
2352
+ return new g([
2353
+ ...this.steps,
2354
+ { kind: "find", predicate: e._spec }
2355
+ ]);
2356
+ }
2357
+ /** Find the first cell matching the predicate in the specified row */
2358
+ findInRow(e, t) {
2359
+ return new g([
2360
+ ...this.steps,
2361
+ { kind: "findInRow", rowIndex: e, predicate: t._spec }
2362
+ ]);
2363
+ }
2364
+ /** Find the first cell matching the predicate in the specified column */
2365
+ findInCol(e, t) {
2366
+ return new g([
2367
+ ...this.steps,
2368
+ { kind: "findInCol", colIndex: e, predicate: t._spec }
2369
+ ]);
2370
+ }
2371
+ /** Find the first cell matching the predicate in the specified range */
2372
+ findInRange(e, t) {
2373
+ return new g([
2374
+ ...this.steps,
2375
+ { kind: "findInRange", rangeRef: e, predicate: t._spec }
2376
+ ]);
2377
+ }
2378
+ range(e, t) {
2379
+ if (t === void 0)
2380
+ return new te([
2381
+ ...this.steps,
2382
+ { kind: "range", ref: e }
2383
+ ]);
2384
+ if (typeof e == "string" && typeof t == "string")
2385
+ return new te([
2386
+ ...this.steps,
2387
+ { kind: "range", ref: `${e}:${t}` }
2388
+ ]);
2389
+ const n = x(e._steps, "value"), s = x(t._steps, "value");
2390
+ return new te([
2391
+ ...this.steps,
2392
+ { kind: "rangeFromCells", from: n, to: s }
2393
+ ]);
2394
+ }
2395
+ /** Navigate to a row by 1-based index */
2396
+ row(e) {
2397
+ return new be([...this.steps, { kind: "row", index: e }]);
2398
+ }
2399
+ /** Navigate to a column by 1-based index */
2400
+ col(e) {
2401
+ return new _e([...this.steps, { kind: "col", index: e }]);
2402
+ }
2403
+ }
2404
+ class se {
2405
+ constructor(e) {
2406
+ this.steps = e;
2407
+ }
2408
+ /** Create a root spec builder */
2409
+ static root() {
2410
+ return new se([]);
2411
+ }
2412
+ /** Navigate to a sheet by name */
2413
+ sheet(e) {
2414
+ return new U([...this.steps, { kind: "sheet", name: e }]);
2415
+ }
2416
+ /** Navigate to a sheet by 1-based index */
2417
+ sheetAt(e) {
2418
+ return new U([...this.steps, { kind: "sheetAt", index: e }]);
2419
+ }
2420
+ /** Navigate to the first sheet */
2421
+ firstSheet() {
2422
+ return new U([...this.steps, { kind: "firstSheet" }]);
2423
+ }
2424
+ /** Find a sheet matching the predicate */
2425
+ findSheet(e) {
2426
+ return new U([
2427
+ ...this.steps,
2428
+ { kind: "findSheet", predicate: e._spec }
2429
+ ]);
2430
+ }
2431
+ }
2432
+ function ze(r) {
2085
2433
  return {
2086
2434
  kind: "transform",
2087
2435
  namespace: "@origints/xlsx",
2088
2436
  name: "parseXlsx",
2089
- args: s
2437
+ args: r,
2438
+ specBuilderFactory: () => se.root()
2090
2439
  };
2091
2440
  }
2092
- const P = {
2441
+ const Pe = {
2093
2442
  namespace: "@origints/xlsx",
2094
2443
  name: "parseXlsx",
2095
2444
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2096
- execute(s, t) {
2445
+ execute(r, e) {
2097
2446
  throw new Error(
2098
2447
  "parseXlsx requires async execution. Use parseXlsxAsyncImpl instead."
2099
2448
  );
2100
2449
  }
2101
2450
  };
2102
- function C(s) {
2103
- return new Uint8Array(s).buffer;
2451
+ function X(r) {
2452
+ return new Uint8Array(r).buffer;
2104
2453
  }
2105
- const I = {
2454
+ const Ce = {
2106
2455
  namespace: "@origints/xlsx",
2107
2456
  name: "parseXlsx",
2108
- async execute(s, t) {
2109
- const e = t ?? {};
2110
- let r;
2111
- if (s instanceof ReadableStream) {
2112
- const o = await M(s);
2113
- r = C(o);
2114
- } else if (Buffer.isBuffer(s))
2115
- r = C(s);
2116
- else if (s instanceof ArrayBuffer)
2117
- r = s;
2118
- else if (s instanceof Uint8Array)
2119
- r = C(s);
2457
+ async execute(r, e) {
2458
+ const t = e ?? {};
2459
+ let n;
2460
+ if (r instanceof ReadableStream) {
2461
+ const l = await ge(r);
2462
+ n = X(l);
2463
+ } else if (Buffer.isBuffer(r))
2464
+ n = X(r);
2465
+ else if (r instanceof ArrayBuffer)
2466
+ n = r;
2467
+ else if (r instanceof Uint8Array)
2468
+ n = X(r);
2120
2469
  else
2121
2470
  throw new Error(
2122
- `parseXlsx expects stream or buffer input, got ${typeof s}`
2471
+ `parseXlsx expects stream or buffer input, got ${typeof r}`
2123
2472
  );
2124
- const n = new $.Workbook();
2125
- return await n.xlsx.load(r), v.fromExcelJS(n, e.fileName);
2473
+ const s = new re.Workbook();
2474
+ return await s.xlsx.load(n), z.fromExcelJS(s, t.fileName);
2126
2475
  }
2127
2476
  };
2128
- async function Z(s, t) {
2129
- const e = new $.Workbook();
2130
- let r;
2131
- return s instanceof ArrayBuffer ? r = s : r = C(s), await e.xlsx.load(r), v.fromExcelJS(e, t?.fileName);
2477
+ async function Ue(r, e) {
2478
+ const t = new re.Workbook();
2479
+ let n;
2480
+ return r instanceof ArrayBuffer ? n = r : n = X(r), await t.xlsx.load(n), z.fromExcelJS(t, e?.fileName);
2132
2481
  }
2133
- async function G(s, t) {
2134
- const e = new $.Workbook();
2135
- return await e.xlsx.readFile(s), v.fromExcelJS(e, t?.fileName ?? s);
2482
+ async function He(r, e) {
2483
+ const t = new re.Workbook();
2484
+ return await t.xlsx.readFile(r), z.fromExcelJS(t, e?.fileName ?? r);
2136
2485
  }
2137
- function D(s, t) {
2138
- return s == null ? null : s instanceof Date ? t?.dateAsIsoString !== !1 ? s.toISOString() : s.getTime() : typeof s == "string" || typeof s == "number" || typeof s == "boolean" ? s : null;
2486
+ function E(r) {
2487
+ switch (r.kind) {
2488
+ // Value predicates
2489
+ case "equals":
2490
+ return (e) => {
2491
+ const t = e.value();
2492
+ return t.ok ? r.value === null ? t.value === null : t.value === null ? !1 : r.value instanceof Date && t.value instanceof Date ? r.value.getTime() === t.value.getTime() : t.value === r.value : !1;
2493
+ };
2494
+ case "contains":
2495
+ return (e) => {
2496
+ const t = e.string();
2497
+ return t.ok ? r.caseSensitive ? t.value.includes(r.text) : t.value.toLowerCase().includes(r.text.toLowerCase()) : !1;
2498
+ };
2499
+ case "matches":
2500
+ return (e) => {
2501
+ const t = e.string();
2502
+ return t.ok ? new RegExp(r.pattern, r.flags).test(t.value) : !1;
2503
+ };
2504
+ case "startsWith":
2505
+ return (e) => {
2506
+ const t = e.string();
2507
+ return t.ok ? r.caseSensitive ? t.value.startsWith(r.prefix) : t.value.toLowerCase().startsWith(r.prefix.toLowerCase()) : !1;
2508
+ };
2509
+ case "endsWith":
2510
+ return (e) => {
2511
+ const t = e.string();
2512
+ return t.ok ? r.caseSensitive ? t.value.endsWith(r.suffix) : t.value.toLowerCase().endsWith(r.suffix.toLowerCase()) : !1;
2513
+ };
2514
+ // Type predicates
2515
+ case "isString":
2516
+ return (e) => e.isString();
2517
+ case "isNumber":
2518
+ return (e) => e.isNumber();
2519
+ case "isBoolean":
2520
+ return (e) => e.isBoolean();
2521
+ case "isDate":
2522
+ return (e) => e.isDate();
2523
+ case "isEmpty":
2524
+ return (e) => e.isEmpty();
2525
+ case "isNotEmpty":
2526
+ return (e) => !e.isEmpty();
2527
+ case "isFormula":
2528
+ return (e) => e.isFormula();
2529
+ case "isError":
2530
+ return (e) => e.isError();
2531
+ case "isMerged":
2532
+ return (e) => e.isMerged();
2533
+ // Numeric predicates
2534
+ case "gt":
2535
+ return (e) => {
2536
+ const t = e.number();
2537
+ return t.ok && t.value > r.value;
2538
+ };
2539
+ case "gte":
2540
+ return (e) => {
2541
+ const t = e.number();
2542
+ return t.ok && t.value >= r.value;
2543
+ };
2544
+ case "lt":
2545
+ return (e) => {
2546
+ const t = e.number();
2547
+ return t.ok && t.value < r.value;
2548
+ };
2549
+ case "lte":
2550
+ return (e) => {
2551
+ const t = e.number();
2552
+ return t.ok && t.value <= r.value;
2553
+ };
2554
+ case "between":
2555
+ return (e) => {
2556
+ const t = e.number();
2557
+ return t.ok && t.value >= r.min && t.value <= r.max;
2558
+ };
2559
+ // Style predicates
2560
+ case "isBold":
2561
+ return (e) => e.style().font?.bold === !0;
2562
+ case "isItalic":
2563
+ return (e) => e.style().font?.italic === !0;
2564
+ case "hasHyperlink":
2565
+ return (e) => e.hyperlink().ok;
2566
+ case "hasComment":
2567
+ return (e) => e.comment().ok;
2568
+ // Composition
2569
+ case "and": {
2570
+ const e = E(r.left), t = E(r.right);
2571
+ return (n) => e(n) && t(n);
2572
+ }
2573
+ case "or": {
2574
+ const e = E(r.left), t = E(r.right);
2575
+ return (n) => e(n) || t(n);
2576
+ }
2577
+ case "not": {
2578
+ const e = E(r.operand);
2579
+ return (t) => !e(t);
2580
+ }
2581
+ }
2139
2582
  }
2140
- function J(s, t) {
2141
- const e = s.value(), r = e.ok ? D(e.value, t) : null;
2142
- return t?.includeCellAddresses ? {
2143
- address: s.address,
2144
- value: r
2145
- } : r;
2583
+ function M(r) {
2584
+ switch (r.kind) {
2585
+ case "nameEquals":
2586
+ return (e) => e.name === r.name;
2587
+ case "nameContains":
2588
+ return (e) => e.name.includes(r.text);
2589
+ case "nameStartsWith":
2590
+ return (e) => e.name.startsWith(r.prefix);
2591
+ case "nameEndsWith":
2592
+ return (e) => e.name.endsWith(r.suffix);
2593
+ case "nameMatches": {
2594
+ const e = new RegExp(r.pattern, r.flags);
2595
+ return (t) => e.test(t.name);
2596
+ }
2597
+ case "and": {
2598
+ const e = M(r.left), t = M(r.right);
2599
+ return (n) => e(n) && t(n);
2600
+ }
2601
+ case "or": {
2602
+ const e = M(r.left), t = M(r.right);
2603
+ return (n) => e(n) || t(n);
2604
+ }
2605
+ case "not": {
2606
+ const e = M(r.operand);
2607
+ return (t) => !e(t);
2608
+ }
2609
+ }
2610
+ }
2611
+ function F(r) {
2612
+ switch (r.kind) {
2613
+ case "rowCol": {
2614
+ const e = E(r.predicate);
2615
+ return (t, n, s) => {
2616
+ const l = s + r.offset;
2617
+ if (l < 1) return !1;
2618
+ const u = t.cellAt(n, l);
2619
+ return u.ok ? e(u.value) : !1;
2620
+ };
2621
+ }
2622
+ case "and": {
2623
+ const e = F(r.left), t = F(r.right);
2624
+ return (n, s, l) => e(n, s, l) && t(n, s, l);
2625
+ }
2626
+ case "or": {
2627
+ const e = F(r.left), t = F(r.right);
2628
+ return (n, s, l) => e(n, s, l) || t(n, s, l);
2629
+ }
2630
+ case "not": {
2631
+ const e = F(r.operand);
2632
+ return (t, n, s) => !e(t, n, s);
2633
+ }
2634
+ }
2146
2635
  }
2147
- function j(s, t) {
2148
- return t?.firstRowAsHeaders ? B(s, t) : W(s, t);
2636
+ function v(r) {
2637
+ return {
2638
+ _spec: r,
2639
+ and(e) {
2640
+ return v({ kind: "and", left: r, right: e._spec });
2641
+ },
2642
+ or(e) {
2643
+ return v({ kind: "or", left: r, right: e._spec });
2644
+ },
2645
+ not() {
2646
+ return v({ kind: "not", operand: r });
2647
+ },
2648
+ describe() {
2649
+ return C(r);
2650
+ }
2651
+ };
2149
2652
  }
2150
- function W(s, t) {
2151
- const e = [];
2152
- for (const r of s.rows()) {
2153
- const n = [];
2154
- for (const o of r) {
2155
- const i = J(o, t);
2156
- i !== null || t?.includeEmpty ? n.push(i) : (n.length > 0 || t?.includeEmpty) && n.push(null);
2653
+ function T(r) {
2654
+ return {
2655
+ _spec: r,
2656
+ and(e) {
2657
+ return T({ kind: "and", left: r, right: e._spec });
2658
+ },
2659
+ or(e) {
2660
+ return T({ kind: "or", left: r, right: e._spec });
2661
+ },
2662
+ not() {
2663
+ return T({ kind: "not", operand: r });
2664
+ },
2665
+ describe() {
2666
+ return I(r);
2157
2667
  }
2158
- (n.length > 0 || t?.includeEmpty) && e.push(n);
2668
+ };
2669
+ }
2670
+ function ye(r) {
2671
+ return r === null ? "null" : r instanceof Date ? `Date(${r.toISOString()})` : typeof r == "string" ? `'${r}'` : String(r);
2672
+ }
2673
+ const Xe = Object.freeze({
2674
+ // Value predicates
2675
+ equals: (r) => v({ kind: "equals", value: r }),
2676
+ contains: (r, e = !1) => v({ kind: "contains", text: r, caseSensitive: e }),
2677
+ matches: (r) => v({
2678
+ kind: "matches",
2679
+ pattern: r.source,
2680
+ flags: r.flags
2681
+ }),
2682
+ startsWith: (r, e = !1) => v({ kind: "startsWith", prefix: r, caseSensitive: e }),
2683
+ endsWith: (r, e = !1) => v({ kind: "endsWith", suffix: r, caseSensitive: e }),
2684
+ // Type predicates
2685
+ isString: () => v({ kind: "isString" }),
2686
+ isNumber: () => v({ kind: "isNumber" }),
2687
+ isBoolean: () => v({ kind: "isBoolean" }),
2688
+ isDate: () => v({ kind: "isDate" }),
2689
+ isEmpty: () => v({ kind: "isEmpty" }),
2690
+ isNotEmpty: () => v({ kind: "isNotEmpty" }),
2691
+ isFormula: () => v({ kind: "isFormula" }),
2692
+ isError: () => v({ kind: "isError" }),
2693
+ isMerged: () => v({ kind: "isMerged" }),
2694
+ // Numeric predicates
2695
+ gt: (r) => v({ kind: "gt", value: r }),
2696
+ gte: (r) => v({ kind: "gte", value: r }),
2697
+ lt: (r) => v({ kind: "lt", value: r }),
2698
+ lte: (r) => v({ kind: "lte", value: r }),
2699
+ between: (r, e) => v({ kind: "between", min: r, max: e }),
2700
+ // Style predicates
2701
+ isBold: () => v({ kind: "isBold" }),
2702
+ isItalic: () => v({ kind: "isItalic" }),
2703
+ hasHyperlink: () => v({ kind: "hasHyperlink" }),
2704
+ hasComment: () => v({ kind: "hasComment" })
2705
+ }), Ke = Object.freeze({
2706
+ nameEquals: (r) => T({ kind: "nameEquals", name: r }),
2707
+ nameContains: (r) => T({ kind: "nameContains", text: r }),
2708
+ nameStartsWith: (r) => T({ kind: "nameStartsWith", prefix: r }),
2709
+ nameEndsWith: (r) => T({ kind: "nameEndsWith", suffix: r }),
2710
+ nameMatches: (r) => T({
2711
+ kind: "nameMatches",
2712
+ pattern: r.source,
2713
+ flags: r.flags
2714
+ })
2715
+ });
2716
+ function C(r) {
2717
+ switch (r.kind) {
2718
+ case "equals":
2719
+ return `equals(${ye(r.value)})`;
2720
+ case "contains":
2721
+ return `contains('${r.text}')`;
2722
+ case "matches":
2723
+ return `matches(/${r.pattern}/${r.flags})`;
2724
+ case "startsWith":
2725
+ return `startsWith('${r.prefix}')`;
2726
+ case "endsWith":
2727
+ return `endsWith('${r.suffix}')`;
2728
+ case "isString":
2729
+ return "isString()";
2730
+ case "isNumber":
2731
+ return "isNumber()";
2732
+ case "isBoolean":
2733
+ return "isBoolean()";
2734
+ case "isDate":
2735
+ return "isDate()";
2736
+ case "isEmpty":
2737
+ return "isEmpty()";
2738
+ case "isNotEmpty":
2739
+ return "isNotEmpty()";
2740
+ case "isFormula":
2741
+ return "isFormula()";
2742
+ case "isError":
2743
+ return "isError()";
2744
+ case "isMerged":
2745
+ return "isMerged()";
2746
+ case "gt":
2747
+ return `gt(${r.value})`;
2748
+ case "gte":
2749
+ return `gte(${r.value})`;
2750
+ case "lt":
2751
+ return `lt(${r.value})`;
2752
+ case "lte":
2753
+ return `lte(${r.value})`;
2754
+ case "between":
2755
+ return `between(${r.min}, ${r.max})`;
2756
+ case "isBold":
2757
+ return "isBold()";
2758
+ case "isItalic":
2759
+ return "isItalic()";
2760
+ case "hasHyperlink":
2761
+ return "hasHyperlink()";
2762
+ case "hasComment":
2763
+ return "hasComment()";
2764
+ case "and":
2765
+ return `${C(r.left)} AND ${C(r.right)}`;
2766
+ case "or":
2767
+ return `${C(r.left)} OR ${C(r.right)}`;
2768
+ case "not":
2769
+ return `NOT(${C(r.operand)})`;
2770
+ }
2771
+ }
2772
+ function K(r) {
2773
+ return {
2774
+ _spec: r,
2775
+ and(e) {
2776
+ return K({ kind: "and", left: r, right: e._spec });
2777
+ },
2778
+ or(e) {
2779
+ return K({ kind: "or", left: r, right: e._spec });
2780
+ },
2781
+ not() {
2782
+ return K({ kind: "not", operand: r });
2783
+ },
2784
+ describe() {
2785
+ return q(r);
2786
+ }
2787
+ };
2788
+ }
2789
+ function Ye(r, e) {
2790
+ return K({ kind: "rowCol", offset: r, predicate: e._spec });
2791
+ }
2792
+ function q(r) {
2793
+ switch (r.kind) {
2794
+ case "rowCol":
2795
+ return `rowCol(${r.offset}, ${C(r.predicate)})`;
2796
+ case "and":
2797
+ return `${q(r.left)} AND ${q(r.right)}`;
2798
+ case "or":
2799
+ return `${q(r.left)} OR ${q(r.right)}`;
2800
+ case "not":
2801
+ return `NOT(${q(r.operand)})`;
2802
+ }
2803
+ }
2804
+ function I(r) {
2805
+ switch (r.kind) {
2806
+ case "nameEquals":
2807
+ return `nameEquals('${r.name}')`;
2808
+ case "nameContains":
2809
+ return `nameContains('${r.text}')`;
2810
+ case "nameStartsWith":
2811
+ return `nameStartsWith('${r.prefix}')`;
2812
+ case "nameEndsWith":
2813
+ return `nameEndsWith('${r.suffix}')`;
2814
+ case "nameMatches":
2815
+ return `nameMatches(/${r.pattern}/${r.flags})`;
2816
+ case "and":
2817
+ return `${I(r.left)} AND ${I(r.right)}`;
2818
+ case "or":
2819
+ return `${I(r.left)} OR ${I(r.right)}`;
2820
+ case "not":
2821
+ return `NOT(${I(r.operand)})`;
2822
+ }
2823
+ }
2824
+ const ie = /* @__PURE__ */ new WeakMap(), ae = /* @__PURE__ */ new WeakMap();
2825
+ function D(r) {
2826
+ return { ok: !0, value: r, path: [] };
2827
+ }
2828
+ function S(r) {
2829
+ return { ok: !1, kind: "format", message: r, path: [] };
2830
+ }
2831
+ function j(r, e) {
2832
+ return { ok: !1, kind: "format", message: r, path: [...e] };
2833
+ }
2834
+ function _(r, e) {
2835
+ return r.ok ? r.value : S(
2836
+ `XLSX navigation failed at ${e}: ${r.failure.message}`
2837
+ );
2838
+ }
2839
+ function ce(r) {
2840
+ switch (r.kind) {
2841
+ case "sheet":
2842
+ return `sheet("${r.name}")`;
2843
+ case "sheetAt":
2844
+ return `sheetAt(${r.index})`;
2845
+ case "firstSheet":
2846
+ return "firstSheet()";
2847
+ case "findSheet":
2848
+ return `findSheet(${I(r.predicate)})`;
2849
+ case "cell":
2850
+ return `cell("${r.ref}")`;
2851
+ case "cellAt":
2852
+ return `cellAt(${r.row}, ${r.col})`;
2853
+ case "find":
2854
+ return `find(${C(r.predicate)})`;
2855
+ case "findInRow":
2856
+ return `findInRow(${r.rowIndex}, ${C(r.predicate)})`;
2857
+ case "findInCol":
2858
+ return `findInCol(${r.colIndex}, ${C(r.predicate)})`;
2859
+ case "findInRange":
2860
+ return `findInRange("${r.rangeRef}", ${C(r.predicate)})`;
2861
+ case "right":
2862
+ return `right(${r.count})`;
2863
+ case "left":
2864
+ return `left(${r.count})`;
2865
+ case "up":
2866
+ return `up(${r.count})`;
2867
+ case "down":
2868
+ return `down(${r.count})`;
2869
+ case "offset":
2870
+ return `offset(${r.rowDelta}, ${r.colDelta})`;
2871
+ case "scanTo":
2872
+ return `scanTo(${r.direction}, ${C(r.predicate)})`;
2873
+ case "skipWhile":
2874
+ return `skipWhile(${r.direction}, ${C(r.predicate)})`;
2875
+ case "colWhere":
2876
+ return `colWhere(${C(r.predicate)})`;
2877
+ case "rowWhere":
2878
+ return `rowWhere(${C(r.predicate)})`;
2879
+ case "range":
2880
+ return `range("${r.ref}")`;
2881
+ case "rangeFromCells":
2882
+ return "rangeFromCells()";
2883
+ case "row":
2884
+ return `row(${r.index})`;
2885
+ case "col":
2886
+ return `col(${r.index})`;
2887
+ }
2888
+ }
2889
+ function m(r) {
2890
+ return typeof r == "object" && r !== null && "ok" in r && !r.ok;
2891
+ }
2892
+ class $e {
2893
+ constructor(e, t, n) {
2894
+ this.workbook = e, this.sheet = t, this.anchorCell = n;
2895
+ }
2896
+ get [N]() {
2897
+ return "XlsxSliceContext";
2159
2898
  }
2160
- return e;
2161
2899
  }
2162
- function B(s, t) {
2163
- const e = [...s.rows()];
2164
- if (e.length === 0) return [];
2165
- const n = e[0].map((i) => {
2166
- const a = i.value();
2167
- return a.ok && a.value !== null ? String(a.value) : `col_${i.col}`;
2168
- }), o = [];
2169
- for (let i = 1; i < e.length; i++) {
2170
- const a = e[i], u = {};
2171
- let c = !1;
2172
- for (let f = 0; f < n.length; f++) {
2173
- const g = n[f], x = a[f];
2174
- if (x) {
2175
- const _ = J(x, t);
2176
- _ !== null && (c = !0), u[g] = _;
2900
+ function Re(r) {
2901
+ if (r == null || typeof r != "object") return null;
2902
+ const e = r[N];
2903
+ if (typeof e == "string") {
2904
+ if (e === "XlsxSliceContext") return "sliceContext";
2905
+ if (e.startsWith("XlsxWorkbook")) return "workbook";
2906
+ if (e.startsWith("XlsxRange")) return "range";
2907
+ if (e.startsWith("XlsxCell")) return "cell";
2908
+ }
2909
+ return r instanceof y ? "range" : r instanceof W ? "cell" : "workbook";
2910
+ }
2911
+ function oe(r) {
2912
+ switch (r) {
2913
+ case "right":
2914
+ return { rowDelta: 0, colDelta: 1 };
2915
+ case "left":
2916
+ return { rowDelta: 0, colDelta: -1 };
2917
+ case "down":
2918
+ return { rowDelta: 1, colDelta: 0 };
2919
+ case "up":
2920
+ return { rowDelta: -1, colDelta: 0 };
2921
+ }
2922
+ }
2923
+ function ue(r, e, t, n, s, l) {
2924
+ const u = E(s), { rowDelta: o, colDelta: a } = oe(n), i = r.dimensions(), c = Math.max(i.rowCount, i.colCount) * 2;
2925
+ let h = e + o, d = t + a;
2926
+ for (let b = 0; b < c && !(h < 1 || d < 1 || h > i.endRow + 1 || d > i.endCol + 1); b++) {
2927
+ const p = r.cellAt(h, d);
2928
+ if (!p.ok) break;
2929
+ const R = p.value;
2930
+ if (l === "scanTo") {
2931
+ if (u(R)) return R;
2932
+ } else if (!u(R)) return R;
2933
+ h += o, d += a;
2934
+ }
2935
+ const k = C(s);
2936
+ return S(l === "scanTo" ? `scanTo(${n}): no cell matching ${k} found` : `skipWhile(${n}): predicate ${k} never stopped matching`);
2937
+ }
2938
+ function xe(r, e, t, n, s) {
2939
+ const l = E(s), { rowDelta: u, colDelta: o } = oe(n), a = r.dimensions(), i = Math.max(a.rowCount, a.colCount) * 2, c = [];
2940
+ let h = e, d = t;
2941
+ for (let k = 0; k < i && !(h < 1 || d < 1 || h > a.endRow + 1 || d > a.endCol + 1); k++) {
2942
+ const b = r.cellAt(h, d);
2943
+ if (!b.ok) break;
2944
+ const p = b.value;
2945
+ if (!l(p)) break;
2946
+ c.push(p), h += u, d += o;
2947
+ }
2948
+ return c;
2949
+ }
2950
+ function Se(r, e, t, n, s, l) {
2951
+ const u = F(l), { rowDelta: o, colDelta: a } = oe(s), i = e.dimensions(), c = Math.max(i.rowCount, i.colCount) * 2, h = [];
2952
+ let d = t, k = n;
2953
+ for (let b = 0; b < c && !(d < 1 || k < 1 || d > i.endRow + 1 || k > i.endCol + 1 || !u(e, d, k)); b++) {
2954
+ const p = e.cellAt(d, k);
2955
+ if (!p.ok) break;
2956
+ h.push(new $e(r, e, p.value)), d += o, k += a;
2957
+ }
2958
+ return h;
2959
+ }
2960
+ function L(r, e) {
2961
+ let t = r;
2962
+ const n = [];
2963
+ function s(o, a) {
2964
+ a.level === "cell" ? n.push(`${o}@${a.cell.address}`) : n.push(o);
2965
+ }
2966
+ function l(o, a) {
2967
+ const i = [...n];
2968
+ return a && i.push(ce(a)), j(o, i);
2969
+ }
2970
+ function u(o) {
2971
+ return o.message;
2972
+ }
2973
+ for (const o of e) {
2974
+ const a = ce(o);
2975
+ switch (o.kind) {
2976
+ // ----- Workbook → Sheet -----
2977
+ case "sheet": {
2978
+ const i = _(t.workbook.sheet(o.name), a);
2979
+ if (m(i)) return l(u(i), o);
2980
+ t = {
2981
+ level: "sheet",
2982
+ workbook: t.workbook,
2983
+ sheet: i
2984
+ }, s(a, t);
2985
+ break;
2986
+ }
2987
+ case "sheetAt": {
2988
+ const i = _(t.workbook.sheetAt(o.index), a);
2989
+ if (m(i)) return l(u(i), o);
2990
+ t = {
2991
+ level: "sheet",
2992
+ workbook: t.workbook,
2993
+ sheet: i
2994
+ }, s(a, t);
2995
+ break;
2996
+ }
2997
+ case "firstSheet": {
2998
+ const i = _(t.workbook.firstSheet(), a);
2999
+ if (m(i)) return l(u(i), o);
3000
+ t = {
3001
+ level: "sheet",
3002
+ workbook: t.workbook,
3003
+ sheet: i
3004
+ }, s(a, t);
3005
+ break;
3006
+ }
3007
+ case "findSheet": {
3008
+ const i = M(o.predicate), c = _(t.workbook.findSheet(i), a);
3009
+ if (m(c)) return l(u(c), o);
3010
+ t = {
3011
+ level: "sheet",
3012
+ workbook: t.workbook,
3013
+ sheet: c
3014
+ }, s(a, t);
3015
+ break;
3016
+ }
3017
+ // ----- Sheet → Cell (direct) -----
3018
+ case "cell": {
3019
+ if (t.level === "workbook")
3020
+ return l("cell() called without a sheet navigation step", o);
3021
+ if (t.level === "range") {
3022
+ const h = _(t.range.cell(o.ref), a);
3023
+ if (m(h)) return l(u(h), o);
3024
+ t = {
3025
+ level: "cell",
3026
+ workbook: t.workbook,
3027
+ sheet: t.sheet,
3028
+ cell: h
3029
+ }, s(a, t);
3030
+ break;
3031
+ }
3032
+ const i = t.sheet, c = _(i.cell(o.ref), a);
3033
+ if (m(c)) return l(u(c), o);
3034
+ t = {
3035
+ level: "cell",
3036
+ workbook: t.workbook,
3037
+ sheet: i,
3038
+ cell: c
3039
+ }, s(a, t);
3040
+ break;
3041
+ }
3042
+ case "cellAt": {
3043
+ if (t.level === "workbook")
3044
+ return l(
3045
+ "cellAt() called without a sheet navigation step",
3046
+ o
3047
+ );
3048
+ if (t.level === "range") {
3049
+ const h = _(t.range.cellAt(o.row, o.col), a);
3050
+ if (m(h)) return l(u(h), o);
3051
+ t = {
3052
+ level: "cell",
3053
+ workbook: t.workbook,
3054
+ sheet: t.sheet,
3055
+ cell: h
3056
+ }, s(a, t);
3057
+ break;
3058
+ }
3059
+ const i = t.sheet, c = _(i.cellAt(o.row, o.col), a);
3060
+ if (m(c)) return l(u(c), o);
3061
+ t = {
3062
+ level: "cell",
3063
+ workbook: t.workbook,
3064
+ sheet: i,
3065
+ cell: c
3066
+ }, s(a, t);
3067
+ break;
3068
+ }
3069
+ // ----- Sheet → Cell (search) -----
3070
+ case "find": {
3071
+ if (t.level !== "sheet")
3072
+ return l("find() requires sheet-level navigation state", o);
3073
+ const i = t.sheet, c = E(o.predicate), h = _(i.find(c), a);
3074
+ if (m(h))
3075
+ return l(u(h), o);
3076
+ t = { level: "cell", workbook: t.workbook, sheet: i, cell: h }, s(a, t);
3077
+ break;
3078
+ }
3079
+ case "findInRow": {
3080
+ if (t.level !== "sheet")
3081
+ return l(
3082
+ "findInRow() requires sheet-level navigation state",
3083
+ o
3084
+ );
3085
+ const i = t.sheet, c = E(o.predicate), h = i.dimensions(), d = Math.max(h.endCol, 1);
3086
+ let k = null;
3087
+ for (let b = 1; b <= d; b++) {
3088
+ const p = i.cellAt(o.rowIndex, b);
3089
+ if (p.ok && c(p.value)) {
3090
+ k = p.value;
3091
+ break;
3092
+ }
3093
+ }
3094
+ if (!k)
3095
+ return l(
3096
+ `findInRow(${o.rowIndex}): no cell matching ${C(o.predicate)} found`,
3097
+ o
3098
+ );
3099
+ t = {
3100
+ level: "cell",
3101
+ workbook: t.workbook,
3102
+ sheet: i,
3103
+ cell: k
3104
+ }, s(a, t);
3105
+ break;
3106
+ }
3107
+ case "findInCol": {
3108
+ if (t.level !== "sheet")
3109
+ return l(
3110
+ "findInCol() requires sheet-level navigation state",
3111
+ o
3112
+ );
3113
+ const i = t.sheet, c = E(o.predicate), h = i.dimensions(), d = Math.max(h.endRow, 1);
3114
+ let k = null;
3115
+ for (let b = 1; b <= d; b++) {
3116
+ const p = i.cellAt(b, o.colIndex);
3117
+ if (p.ok && c(p.value)) {
3118
+ k = p.value;
3119
+ break;
3120
+ }
3121
+ }
3122
+ if (!k)
3123
+ return l(
3124
+ `findInCol(${o.colIndex}): no cell matching ${C(o.predicate)} found`,
3125
+ o
3126
+ );
3127
+ t = {
3128
+ level: "cell",
3129
+ workbook: t.workbook,
3130
+ sheet: i,
3131
+ cell: k
3132
+ }, s(a, t);
3133
+ break;
3134
+ }
3135
+ case "findInRange": {
3136
+ if (t.level !== "sheet")
3137
+ return l(
3138
+ "findInRange() requires sheet-level navigation state",
3139
+ o
3140
+ );
3141
+ const i = t.sheet, c = E(o.predicate), h = _(
3142
+ i.findInRange(o.rangeRef, c),
3143
+ a
3144
+ );
3145
+ if (m(h))
3146
+ return l(u(h), o);
3147
+ t = { level: "cell", workbook: t.workbook, sheet: i, cell: h }, s(a, t);
3148
+ break;
3149
+ }
3150
+ // ----- Cell → Cell (relative movement) -----
3151
+ case "right": {
3152
+ if (t.level !== "cell")
3153
+ return l("right() requires cell-level navigation state", o);
3154
+ const i = t.sheet, c = _(
3155
+ i.cellAt(t.cell.row, t.cell.col + o.count),
3156
+ a
3157
+ );
3158
+ if (m(c))
3159
+ return l(u(c), o);
3160
+ t = { level: "cell", workbook: t.workbook, sheet: i, cell: c }, s(a, t);
3161
+ break;
3162
+ }
3163
+ case "left": {
3164
+ if (t.level !== "cell")
3165
+ return l("left() requires cell-level navigation state", o);
3166
+ const i = t.sheet, c = t.cell.col - o.count;
3167
+ if (c < 1)
3168
+ return l(
3169
+ `left(${o.count}) from column ${t.cell.col} goes out of bounds`,
3170
+ o
3171
+ );
3172
+ const h = _(
3173
+ i.cellAt(t.cell.row, c),
3174
+ a
3175
+ );
3176
+ if (m(h))
3177
+ return l(u(h), o);
3178
+ t = { level: "cell", workbook: t.workbook, sheet: i, cell: h }, s(a, t);
3179
+ break;
3180
+ }
3181
+ case "up": {
3182
+ if (t.level !== "cell")
3183
+ return l("up() requires cell-level navigation state", o);
3184
+ const i = t.sheet, c = t.cell.row - o.count;
3185
+ if (c < 1)
3186
+ return l(
3187
+ `up(${o.count}) from row ${t.cell.row} goes out of bounds`,
3188
+ o
3189
+ );
3190
+ const h = _(
3191
+ i.cellAt(c, t.cell.col),
3192
+ a
3193
+ );
3194
+ if (m(h))
3195
+ return l(u(h), o);
3196
+ t = { level: "cell", workbook: t.workbook, sheet: i, cell: h }, s(a, t);
3197
+ break;
3198
+ }
3199
+ case "down": {
3200
+ if (t.level !== "cell")
3201
+ return l("down() requires cell-level navigation state", o);
3202
+ const i = t.sheet, c = _(
3203
+ i.cellAt(t.cell.row + o.count, t.cell.col),
3204
+ a
3205
+ );
3206
+ if (m(c))
3207
+ return l(u(c), o);
3208
+ t = { level: "cell", workbook: t.workbook, sheet: i, cell: c }, s(a, t);
3209
+ break;
3210
+ }
3211
+ case "offset": {
3212
+ if (t.level !== "cell")
3213
+ return l("offset() requires cell-level navigation state", o);
3214
+ const i = t.sheet, c = t.cell.row + o.rowDelta, h = t.cell.col + o.colDelta;
3215
+ if (c < 1 || h < 1)
3216
+ return l(
3217
+ `offset(${o.rowDelta}, ${o.colDelta}) from ${t.cell.address} goes out of bounds`,
3218
+ o
3219
+ );
3220
+ const d = _(
3221
+ i.cellAt(c, h),
3222
+ a
3223
+ );
3224
+ if (m(d))
3225
+ return l(u(d), o);
3226
+ t = { level: "cell", workbook: t.workbook, sheet: i, cell: d }, s(a, t);
3227
+ break;
3228
+ }
3229
+ // ----- Cell → Cell (scan) -----
3230
+ case "scanTo": {
3231
+ if (t.level !== "cell")
3232
+ return l("scanTo() requires cell-level navigation state", o);
3233
+ const i = t.sheet, c = ue(
3234
+ i,
3235
+ t.cell.row,
3236
+ t.cell.col,
3237
+ o.direction,
3238
+ o.predicate,
3239
+ "scanTo"
3240
+ );
3241
+ if (m(c))
3242
+ return l(
3243
+ u(c),
3244
+ o
3245
+ );
3246
+ t = {
3247
+ level: "cell",
3248
+ workbook: t.workbook,
3249
+ sheet: i,
3250
+ cell: c
3251
+ }, s(a, t);
3252
+ break;
3253
+ }
3254
+ case "skipWhile": {
3255
+ if (t.level !== "cell")
3256
+ return l(
3257
+ "skipWhile() requires cell-level navigation state",
3258
+ o
3259
+ );
3260
+ const i = t.sheet, c = ue(
3261
+ i,
3262
+ t.cell.row,
3263
+ t.cell.col,
3264
+ o.direction,
3265
+ o.predicate,
3266
+ "skipWhile"
3267
+ );
3268
+ if (m(c))
3269
+ return l(
3270
+ u(c),
3271
+ o
3272
+ );
3273
+ t = {
3274
+ level: "cell",
3275
+ workbook: t.workbook,
3276
+ sheet: i,
3277
+ cell: c
3278
+ }, s(a, t);
3279
+ break;
3280
+ }
3281
+ // ----- Sheet → Range -----
3282
+ case "range": {
3283
+ if (t.level !== "sheet")
3284
+ return l("range() requires sheet-level navigation state", o);
3285
+ const i = t.sheet, c = _(i.range(o.ref), a);
3286
+ if (m(c)) return l(u(c), o);
3287
+ t = {
3288
+ level: "range",
3289
+ workbook: t.workbook,
3290
+ sheet: i,
3291
+ range: c
3292
+ }, s(a, t);
3293
+ break;
3294
+ }
3295
+ case "rangeFromCells": {
3296
+ if (t.level !== "sheet")
3297
+ return l(
3298
+ "rangeFromCells requires sheet-level navigation state",
3299
+ o
3300
+ );
3301
+ const i = t.sheet, c = L(
3302
+ { level: "workbook", workbook: t.workbook },
3303
+ o.from.steps
3304
+ );
3305
+ if (m(c))
3306
+ return l(u(c), o);
3307
+ const h = c;
3308
+ if (h.state.level !== "cell")
3309
+ return l(
3310
+ 'rangeFromCells: "from" did not resolve to a cell',
3311
+ o
3312
+ );
3313
+ const d = h.state.cell, k = L(
3314
+ { level: "workbook", workbook: t.workbook },
3315
+ o.to.steps
3316
+ );
3317
+ if (m(k))
3318
+ return l(u(k), o);
3319
+ const b = k;
3320
+ if (b.state.level !== "cell")
3321
+ return l('rangeFromCells: "to" did not resolve to a cell', o);
3322
+ const p = b.state.cell, R = _(
3323
+ i.rangeAt(d.row, d.col, p.row, p.col),
3324
+ a
3325
+ );
3326
+ if (m(R)) return l(u(R), o);
3327
+ t = {
3328
+ level: "range",
3329
+ workbook: t.workbook,
3330
+ sheet: i,
3331
+ range: R
3332
+ }, s(a, t);
3333
+ break;
3334
+ }
3335
+ case "row": {
3336
+ if (t.level !== "sheet")
3337
+ return l("row() requires sheet-level navigation state", o);
3338
+ const i = t.sheet, c = _(i.row(o.index), a);
3339
+ if (m(c)) return l(u(c), o);
3340
+ t = {
3341
+ level: "range",
3342
+ workbook: t.workbook,
3343
+ sheet: i,
3344
+ range: c
3345
+ }, s(a, t);
3346
+ break;
3347
+ }
3348
+ case "col": {
3349
+ if (t.level === "range") {
3350
+ const h = _(t.range.cellAt(0, o.index - 1), a);
3351
+ if (m(h)) return l(u(h), o);
3352
+ t = {
3353
+ level: "cell",
3354
+ workbook: t.workbook,
3355
+ sheet: t.sheet,
3356
+ cell: h
3357
+ }, s(a, t);
3358
+ break;
3359
+ }
3360
+ if (t.level !== "sheet")
3361
+ return l(
3362
+ "col() requires sheet-level or range-level navigation state",
3363
+ o
3364
+ );
3365
+ const i = t.sheet, c = _(i.col(o.index), a);
3366
+ if (m(c)) return l(u(c), o);
3367
+ t = {
3368
+ level: "range",
3369
+ workbook: t.workbook,
3370
+ sheet: i,
3371
+ range: c
3372
+ }, s(a, t);
3373
+ break;
3374
+ }
3375
+ // ----- Header-relative navigation -----
3376
+ case "colWhere": {
3377
+ if (t.level !== "cell")
3378
+ return l(
3379
+ "colWhere() requires cell-level navigation state",
3380
+ o
3381
+ );
3382
+ const i = t.sheet, c = JSON.stringify(o);
3383
+ let h = ie.get(i), d = h?.get(c) ?? null;
3384
+ if (d === null) {
3385
+ const b = o.headerRef, p = L(
3386
+ { level: "workbook", workbook: t.workbook },
3387
+ b.steps
3388
+ );
3389
+ if (m(p))
3390
+ return l(u(p), o);
3391
+ const R = p;
3392
+ if (R.state.level !== "cell")
3393
+ return l(
3394
+ "colWhere: headerRef did not resolve to a cell",
3395
+ o
3396
+ );
3397
+ const B = R.state.cell.row, Z = i.dimensions(), G = E(o.predicate);
3398
+ for (let A = 1; A <= Z.endCol; A++) {
3399
+ const J = i.cellAt(B, A);
3400
+ if (J.ok && G(J.value)) {
3401
+ d = A;
3402
+ break;
3403
+ }
3404
+ }
3405
+ if (d === null) {
3406
+ const A = C(o.predicate);
3407
+ return l(
3408
+ `colWhere: no column matching ${A} found in header row ${B}`,
3409
+ o
3410
+ );
3411
+ }
3412
+ h || (h = /* @__PURE__ */ new Map(), ie.set(i, h)), h.set(c, d);
3413
+ }
3414
+ const k = _(i.cellAt(t.cell.row, d), a);
3415
+ if (m(k)) return l(u(k), o);
3416
+ t = {
3417
+ level: "cell",
3418
+ workbook: t.workbook,
3419
+ sheet: i,
3420
+ cell: k
3421
+ }, s(a, t);
3422
+ break;
3423
+ }
3424
+ case "rowWhere": {
3425
+ if (t.level !== "cell")
3426
+ return l(
3427
+ "rowWhere() requires cell-level navigation state",
3428
+ o
3429
+ );
3430
+ const i = t.sheet, c = JSON.stringify(o);
3431
+ let h = ae.get(i), d = h?.get(c) ?? null;
3432
+ if (d === null) {
3433
+ const b = o.headerRef, p = L(
3434
+ { level: "workbook", workbook: t.workbook },
3435
+ b.steps
3436
+ );
3437
+ if (m(p))
3438
+ return l(u(p), o);
3439
+ const R = p;
3440
+ if (R.state.level !== "cell")
3441
+ return l(
3442
+ "rowWhere: headerRef did not resolve to a cell",
3443
+ o
3444
+ );
3445
+ const B = R.state.cell.col, Z = i.dimensions(), G = E(o.predicate);
3446
+ for (let A = 1; A <= Z.endRow; A++) {
3447
+ const J = i.cellAt(A, B);
3448
+ if (J.ok && G(J.value)) {
3449
+ d = A;
3450
+ break;
3451
+ }
3452
+ }
3453
+ if (d === null) {
3454
+ const A = C(o.predicate);
3455
+ return l(
3456
+ `rowWhere: no row matching ${A} found in header column ${B}`,
3457
+ o
3458
+ );
3459
+ }
3460
+ h || (h = /* @__PURE__ */ new Map(), ae.set(i, h)), h.set(c, d);
3461
+ }
3462
+ const k = _(i.cellAt(d, t.cell.col), a);
3463
+ if (m(k)) return l(u(k), o);
3464
+ t = {
3465
+ level: "cell",
3466
+ workbook: t.workbook,
3467
+ sheet: i,
3468
+ cell: k
3469
+ }, s(a, t);
3470
+ break;
3471
+ }
3472
+ }
3473
+ }
3474
+ return { state: t, breadcrumbs: n };
3475
+ }
3476
+ function Ee(r, e) {
3477
+ if (typeof e != "string")
3478
+ return S(
3479
+ `Unexpected extract type on cell: ${JSON.stringify(e)}`
3480
+ );
3481
+ switch (e) {
3482
+ case "string": {
3483
+ const t = r.string();
3484
+ return t.ok ? D(t.value) : S(`Failed to extract string: ${t.failure.message}`);
3485
+ }
3486
+ case "number": {
3487
+ const t = r.number();
3488
+ return t.ok ? D(t.value) : S(`Failed to extract number: ${t.failure.message}`);
3489
+ }
3490
+ case "boolean": {
3491
+ const t = r.boolean();
3492
+ return t.ok ? D(t.value) : S(`Failed to extract boolean: ${t.failure.message}`);
3493
+ }
3494
+ case "date": {
3495
+ const t = r.date();
3496
+ return t.ok ? D(t.value) : S(`Failed to extract date: ${t.failure.message}`);
3497
+ }
3498
+ case "value": {
3499
+ const t = r.value();
3500
+ return t.ok ? D(t.value) : S(`Failed to extract value: ${t.failure.message}`);
3501
+ }
3502
+ case "formula": {
3503
+ const t = r.formula();
3504
+ return t.ok ? D(t.value) : S(`Failed to extract formula: ${t.failure.message}`);
3505
+ }
3506
+ default:
3507
+ return S(`Unknown cell extract type: ${e}`);
3508
+ }
3509
+ }
3510
+ function Ae(r, e) {
3511
+ if (e === "rows") {
3512
+ const t = [];
3513
+ for (let n = 0; n < r.rowCount; n++) {
3514
+ const s = r.rowAt(n);
3515
+ if (!s.ok)
3516
+ return S(
3517
+ `Failed to get row at offset ${n}: ${s.failure.message}`
3518
+ );
3519
+ t.push(s.value);
3520
+ }
3521
+ return D(t);
3522
+ }
3523
+ return e === "cells" ? D(r.cellsArray()) : S(
3524
+ `Extract type "${typeof e == "string" ? e : JSON.stringify(e)}" is not valid at range level`
3525
+ );
3526
+ }
3527
+ function We(r, e, t) {
3528
+ const n = xe(
3529
+ r,
3530
+ e.row,
3531
+ e.col,
3532
+ t.direction,
3533
+ t.while
3534
+ );
3535
+ return D(n);
3536
+ }
3537
+ function De(r, e) {
3538
+ if (r.kind !== "extract" || r.format !== "xlsx")
3539
+ return S(
3540
+ `Expected extract spec with format "xlsx", got kind="${r.kind}" format="${r.format}"`
3541
+ );
3542
+ const t = Re(e);
3543
+ let n;
3544
+ switch (t) {
3545
+ case "range": {
3546
+ n = {
3547
+ level: "range",
3548
+ workbook: null,
3549
+ sheet: null,
3550
+ range: e
3551
+ };
3552
+ break;
3553
+ }
3554
+ case "cell": {
3555
+ n = {
3556
+ level: "cell",
3557
+ workbook: null,
3558
+ sheet: null,
3559
+ cell: e
3560
+ };
3561
+ break;
3562
+ }
3563
+ case "sliceContext": {
3564
+ const i = e;
3565
+ n = {
3566
+ level: "cell",
3567
+ workbook: i.workbook,
3568
+ sheet: i.sheet,
3569
+ cell: i.anchorCell
3570
+ };
3571
+ break;
3572
+ }
3573
+ default: {
3574
+ n = { level: "workbook", workbook: e };
3575
+ break;
3576
+ }
3577
+ }
3578
+ const s = L(n, r.steps);
3579
+ if (m(s))
3580
+ return s;
3581
+ const { state: l, breadcrumbs: u } = s, o = r.extract;
3582
+ function a(i) {
3583
+ return i.ok ? { ...i, path: [...u] } : { ...i, path: [...u, ...i.path] };
3584
+ }
3585
+ return typeof o == "object" && o.kind === "eachCell" ? l.level !== "cell" ? j(
3586
+ "eachCell extract requires cell-level navigation state",
3587
+ u
3588
+ ) : a(We(l.sheet, l.cell, o)) : typeof o == "object" && o.kind === "eachSlice" ? l.level !== "cell" ? j(
3589
+ "eachSlice extract requires cell-level navigation state",
3590
+ u
3591
+ ) : { ok: !0, value: Se(
3592
+ l.workbook,
3593
+ l.sheet,
3594
+ l.cell.row,
3595
+ l.cell.col,
3596
+ o.direction,
3597
+ o.while
3598
+ ), path: [...u] } : o === "rows" || o === "cells" ? l.level !== "range" ? j(
3599
+ `"${o}" extract requires range-level navigation state`,
3600
+ u
3601
+ ) : a(Ae(l.range, o)) : l.level !== "cell" ? j(
3602
+ "XLSX spec navigation did not reach a cell",
3603
+ u
3604
+ ) : a(Ee(l.cell, o));
3605
+ }
3606
+ function Te(r, e) {
3607
+ return r == null ? null : r instanceof Date ? e?.dateAsIsoString !== !1 ? r.toISOString() : r.getTime() : typeof r == "string" || typeof r == "number" || typeof r == "boolean" ? r : null;
3608
+ }
3609
+ function de(r, e) {
3610
+ const t = r.value(), n = t.ok ? Te(t.value, e) : null;
3611
+ return e?.includeCellAddresses ? {
3612
+ address: r.address,
3613
+ value: n
3614
+ } : n;
3615
+ }
3616
+ function Ie(r, e) {
3617
+ return e?.firstRowAsHeaders ? Me(r, e) : Ne(r, e);
3618
+ }
3619
+ function Ne(r, e) {
3620
+ const t = [];
3621
+ for (const n of r.rows()) {
3622
+ const s = [];
3623
+ for (const l of n) {
3624
+ const u = de(l, e);
3625
+ u !== null || e?.includeEmpty ? s.push(u) : (s.length > 0 || e?.includeEmpty) && s.push(null);
3626
+ }
3627
+ (s.length > 0 || e?.includeEmpty) && t.push(s);
3628
+ }
3629
+ return t;
3630
+ }
3631
+ function Me(r, e) {
3632
+ const t = [...r.rows()];
3633
+ if (t.length === 0) return [];
3634
+ const s = t[0].map((u) => {
3635
+ const o = u.value();
3636
+ return o.ok && o.value !== null ? String(o.value) : `col_${u.col}`;
3637
+ }), l = [];
3638
+ for (let u = 1; u < t.length; u++) {
3639
+ const o = t[u], a = {};
3640
+ let i = !1;
3641
+ for (let c = 0; c < s.length; c++) {
3642
+ const h = s[c], d = o[c];
3643
+ if (d) {
3644
+ const k = de(d, e);
3645
+ k !== null && (i = !0), a[h] = k;
2177
3646
  } else
2178
- u[g] = null;
3647
+ a[h] = null;
2179
3648
  }
2180
- (c || t?.includeEmpty) && o.push(u);
2181
- }
2182
- return o;
2183
- }
2184
- function V(s, t) {
2185
- const e = s.usedRange();
2186
- return e.ok ? j(e.value, t) : t?.firstRowAsHeaders ? [] : [[]];
2187
- }
2188
- function K(s, t) {
2189
- const e = s.sheets();
2190
- if (t?.includeSheetNames !== !1) {
2191
- const r = {};
2192
- for (const n of e)
2193
- r[n.name] = V(n, t);
2194
- return r;
2195
- }
2196
- return e.map((r) => V(r, t));
2197
- }
2198
- function L(s, t) {
2199
- const e = t?.delimiter ?? ",", r = t?.lineEnding ?? `
2200
- `, n = t?.quoteStrings ?? !0, o = [];
2201
- for (const i of s.rows()) {
2202
- const a = [];
2203
- for (const u of i) {
2204
- const c = u.value();
2205
- let f;
2206
- !c.ok || c.value === null ? f = "" : c.value instanceof Date ? f = c.value.toISOString() : f = String(c.value), n && (f.includes(e) || f.includes(`
2207
- `) || f.includes("\r") || f.includes('"')) && (f = '"' + f.replace(/"/g, '""') + '"'), a.push(f);
3649
+ (i || e?.includeEmpty) && l.push(a);
3650
+ }
3651
+ return l;
3652
+ }
3653
+ function he(r, e) {
3654
+ const t = r.usedRange();
3655
+ return t.ok ? Ie(t.value, e) : e?.firstRowAsHeaders ? [] : [[]];
3656
+ }
3657
+ function Ze(r, e) {
3658
+ const t = r.sheets();
3659
+ if (e?.includeSheetNames !== !1) {
3660
+ const n = {};
3661
+ for (const s of t)
3662
+ n[s.name] = he(s, e);
3663
+ return n;
3664
+ }
3665
+ return t.map((n) => he(n, e));
3666
+ }
3667
+ function Fe(r, e) {
3668
+ const t = e?.delimiter ?? ",", n = e?.lineEnding ?? `
3669
+ `, s = e?.quoteStrings ?? !0, l = [];
3670
+ for (const u of r.rows()) {
3671
+ const o = [];
3672
+ for (const a of u) {
3673
+ const i = a.value();
3674
+ let c;
3675
+ !i.ok || i.value === null ? c = "" : i.value instanceof Date ? c = i.value.toISOString() : c = String(i.value), s && (c.includes(t) || c.includes(`
3676
+ `) || c.includes("\r") || c.includes('"')) && (c = '"' + c.replace(/"/g, '""') + '"'), o.push(c);
2208
3677
  }
2209
- o.push(a.join(e));
3678
+ l.push(o.join(t));
2210
3679
  }
2211
- return o.join(r);
3680
+ return l.join(n);
2212
3681
  }
2213
- function Q(s, t) {
2214
- const e = s.usedRange();
2215
- return e.ok ? L(e.value, t) : "";
3682
+ function Ge(r, e) {
3683
+ const t = r.usedRange();
3684
+ return t.ok ? Fe(t.value, e) : "";
2216
3685
  }
2217
- function Y(s) {
2218
- s.register(I);
3686
+ function qe(r) {
3687
+ r.register(Ce);
2219
3688
  }
3689
+ qe(me);
3690
+ we(
3691
+ "xlsx",
3692
+ (r, e) => De(r, e)
3693
+ );
2220
3694
  export {
2221
- w as XlsxCell,
2222
- d as XlsxCursor,
2223
- m as XlsxRange,
2224
- k as XlsxSheet,
2225
- v as XlsxWorkbook,
2226
- J as cellToJson,
2227
- D as cellValueToJson,
2228
- T as columnLetterToNumber,
2229
- N as columnNumberToLetter,
2230
- h as fail,
2231
- R as formatAddress,
2232
- A as formatRange,
2233
- F as formatXlsxPath,
2234
- S as isError,
2235
- b as isFormula,
2236
- O as isInRange,
2237
- l as ok,
2238
- p as parseAddress,
2239
- y as parseRange,
2240
- H as parseXlsx,
2241
- I as parseXlsxAsyncImpl,
2242
- Z as parseXlsxBuffer,
2243
- G as parseXlsxFile,
2244
- P as parseXlsxImpl,
2245
- q as predicates,
2246
- W as rangeToArray,
2247
- L as rangeToCsv,
2248
- j as rangeToJson,
2249
- B as rangeToObjects,
2250
- Y as registerXlsxTransforms,
2251
- Q as sheetToCsv,
2252
- V as sheetToJson,
2253
- M as streamToBuffer,
2254
- U as toExcelLocation,
2255
- K as workbookToJson
3695
+ W as XlsxCell,
3696
+ g as XlsxCellSB,
3697
+ _e as XlsxColSB,
3698
+ $ as XlsxCursor,
3699
+ y as XlsxRange,
3700
+ te as XlsxRangeSB,
3701
+ ve as XlsxRowItemSB,
3702
+ be as XlsxRowSB,
3703
+ O as XlsxSheet,
3704
+ U as XlsxSheetSB,
3705
+ $e as XlsxSliceContext,
3706
+ pe as XlsxSliceSB,
3707
+ se as XlsxSpecBuilder,
3708
+ z as XlsxWorkbook,
3709
+ Xe as cell,
3710
+ de as cellToJson,
3711
+ Te as cellValueToJson,
3712
+ ne as columnLetterToNumber,
3713
+ fe as columnNumberToLetter,
3714
+ E as compileCellPredicate,
3715
+ F as compileRowPredicate,
3716
+ M as compileSheetPredicate,
3717
+ C as describeCellPredicate,
3718
+ q as describeRowPredicate,
3719
+ I as describeSheetPredicate,
3720
+ De as executeXlsxSpec,
3721
+ w as fail,
3722
+ Y as formatAddress,
3723
+ le as formatRange,
3724
+ Je as formatXlsxPath,
3725
+ Q as isError,
3726
+ P as isFormula,
3727
+ Le as isInRange,
3728
+ f as ok,
3729
+ V as parseAddress,
3730
+ H as parseRange,
3731
+ ze as parseXlsx,
3732
+ Ce as parseXlsxAsyncImpl,
3733
+ Ue as parseXlsxBuffer,
3734
+ He as parseXlsxFile,
3735
+ Pe as parseXlsxImpl,
3736
+ Oe as predicates,
3737
+ Ne as rangeToArray,
3738
+ Fe as rangeToCsv,
3739
+ Ie as rangeToJson,
3740
+ Me as rangeToObjects,
3741
+ qe as registerXlsxTransforms,
3742
+ Ye as rowCol,
3743
+ Ke as sheet,
3744
+ Ge as sheetToCsv,
3745
+ he as sheetToJson,
3746
+ ge as streamToBuffer,
3747
+ je as toExcelLocation,
3748
+ Ze as workbookToJson
2256
3749
  };
2257
3750
  //# sourceMappingURL=index.es.js.map