@sheetxl/sdk 0.7.28-beta.2 → 0.7.28-beta.4

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.
Files changed (64) hide show
  1. package/browser/cjs/{BREMLtxkQhtNSVra.cjs → BF14ZEAnaqxXroSj.cjs} +1 -1
  2. package/browser/cjs/{BG7YDVxiC4ErxvF1.cjs → BXtvdT1Z-MsB_o5F.cjs} +1 -1
  3. package/browser/cjs/Bc4JjVVZfFo3R4He.cjs +33 -0
  4. package/browser/cjs/{CQf4zxkBmheTVbjX.cjs → CD2RXdnfqSYNc6gX.cjs} +2 -2
  5. package/browser/cjs/DcLpXGexEtOxi-dD.cjs +1 -0
  6. package/browser/cjs/index.cjs +2 -2
  7. package/browser/esm/{DN4d5bDBkti28wuc.mjs → 0Mj5WKM362q6CECb.mjs} +213 -207
  8. package/browser/esm/{BxIOX1TojvA-1ZZP.mjs → CHSahmMFYNB0Ajkf.mjs} +2 -2
  9. package/browser/esm/{CZO1RubmqnJV96rq.mjs → CKk58ZLcrllMzfou.mjs} +2 -2
  10. package/browser/esm/{DRWu3TmcE9JFf78V.mjs → CPTtL2f6_4iblmFM.mjs} +2 -2
  11. package/browser/esm/{DPOelA1J3WHbMXyh.mjs → CoA-sUxjiIUIpTUF.mjs} +2 -2
  12. package/browser/esm/{vHWuKF-ftK7LM1uw.mjs → DBIu6NUHIcxOOBQp.mjs} +1 -1
  13. package/browser/esm/{CB_4gdPPPruwremH.mjs → Dy4Sdpju1T2icURu.mjs} +4748 -3883
  14. package/browser/esm/index.mjs +419 -411
  15. package/node/esm/{XQhP3dYwF_tEuswB.mjs → BtGxbEbBm79YvF_k.mjs} +303 -297
  16. package/node/esm/{B-tgcZihStNV9CbZ.mjs → DUYP6faJJHCaW1Xf.mjs} +1 -1
  17. package/node/esm/{C8tfYGL3wHy9IDDc.mjs → DqgWsVXROpSgKq6c.mjs} +2 -2
  18. package/node/esm/index.mjs +8686 -7802
  19. package/package.json +6 -6
  20. package/resources/locales/de/model.msg.json +12 -0
  21. package/resources/locales/en/model.msg.json +12 -0
  22. package/types/scripting-enums.json +2 -0
  23. package/types/scripting.d.ts +341 -15
  24. package/types/src/anchored/IAnchored.d.ts +27 -0
  25. package/types/src/calculation/Calculation.d.ts +21 -12
  26. package/types/src/calculation/ICalculation.d.ts +183 -0
  27. package/types/src/calculation/compiler/CompilerUtils.d.ts +20 -0
  28. package/types/src/calculation/compiler/FormulaParser.d.ts +32 -6
  29. package/types/src/calculation/executor/CalcExecutor.d.ts +204 -13
  30. package/types/src/calculation/executor/CalcExecutorUtils.d.ts +31 -0
  31. package/types/src/calculation/executor/CircularReference.d.ts +81 -0
  32. package/types/src/calculation/functions/Operators.d.ts +1 -1
  33. package/types/src/calculation/grid/CalcGrid.d.ts +5 -1
  34. package/types/src/calculation/grid/CalcGridUtils.d.ts +3 -2
  35. package/types/src/calculation/grid/ICalcGrid.d.ts +23 -1
  36. package/types/src/calculation/spatial/CircularEntry.d.ts +18 -0
  37. package/types/src/calculation/spatial/index.d.ts +1 -0
  38. package/types/src/calculation/state/CalcNode.d.ts +24 -17
  39. package/types/src/calculation/state/CalcState.d.ts +78 -15
  40. package/types/src/calculation/state/CalculationContext.d.ts +39 -0
  41. package/types/src/calculation/state/_ReadObservedGrid.d.ts +90 -0
  42. package/types/src/cell/ICell.d.ts +16 -0
  43. package/types/src/cellRange/ICellRange.d.ts +72 -6
  44. package/types/src/condition/AnchoredConditional.d.ts +26 -6
  45. package/types/src/conditionalFormat/ConditionalFormat.d.ts +8 -1
  46. package/types/src/conditionalFormat/IConditionalFormat.d.ts +4 -1
  47. package/types/src/conditionalFormat/IConditionalFormatCollection.d.ts +6 -2
  48. package/types/src/dataValidation/IDataValidationCollection.d.ts +6 -2
  49. package/types/src/hyperlink/IHyperlink.d.ts +3 -1
  50. package/types/src/hyperlink/_Hyperlink.d.ts +6 -0
  51. package/types/src/lib/utils/utils.browser.d.ts +5 -0
  52. package/types/src/license/LicenseDetails.d.ts +5 -0
  53. package/types/src/primitives/CalcSignal.d.ts +20 -0
  54. package/types/src/protectedRange/IProtectedRangeCollection.d.ts +7 -2
  55. package/types/src/scripting/_ScriptUtils.d.ts +13 -0
  56. package/types/src/sheet/Sheet.d.ts +33 -2
  57. package/types/src/sheet/SheetCell.d.ts +2 -0
  58. package/types/src/sheet/SheetRange.d.ts +12 -1
  59. package/types/src/sheet/_SheetStateTypes.d.ts +14 -1
  60. package/types/src/style/IStyle.d.ts +5 -0
  61. package/types/src/table/AnchoredTable.d.ts +17 -1
  62. package/types/src/text/TextUtils.d.ts +18 -0
  63. package/browser/cjs/DoemwsUQoGCk0vBK.cjs +0 -33
  64. package/browser/cjs/_c2uwwpr03Y7lzIj.cjs +0 -1
@@ -1,58 +1,58 @@
1
1
  /**
2
- * @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.7.28-beta.2
2
+ * @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.7.28-beta.4
3
3
  *
4
4
  * (C) 2026-present SheetXL Inc. & Michael T. Ford
5
5
  * License: The license can be found at https://www.sheetxl.com/license.
6
6
  */
7
- import { A as e, B as t, C as s, D as i, E as r, F as n, I as o, ICalculation as a, L as h, M as l, N as u, O as c, P as p, R as g, S as O, T as _, V as m, _ as E, a as L, b as A, c as T, d as f, f as U, g as N, h as d, i as C, j as S, k as x, l as I, m as R, n as M, o as P, p as v, r as y, s as b, t as k, u as w, v as B, w as $, x as F, y as G, z as D } from "./index.mjs";
7
+ import { A as e, B as t, C as s, D as i, E as r, F as n, H as o, I as a, ICalculation as h, L as l, M as u, N as c, O as p, P as g, R as O, S as _, T as m, V as E, _ as L, a as A, b as T, c as f, d as U, f as d, g as N, h as C, i as S, j as x, k as I, l as R, m as M, n as P, o as v, p as y, r as b, s as k, t as w, u as B, v as $, w as F, x as G, y as D, z as Y } from "./index.mjs";
8
8
  import { FormulaError as z } from "@sheetxl/primitives";
9
- import { CommonUtils as Y } from "@sheetxl/utils";
10
- import { EOF as V, EmbeddedActionsParser as W, Lexer as j, createToken as X, defaultParserErrorProvider as q } from "chevrotain";
11
- var H = [
9
+ import { CommonUtils as V } from "@sheetxl/utils";
10
+ import { EOF as W, EmbeddedActionsParser as j, Lexer as q, createToken as H, defaultParserErrorProvider as X } from "chevrotain";
11
+ var Q = [
12
12
  "All",
13
13
  "Data",
14
14
  "Headers",
15
15
  "Totals",
16
16
  "This Row"
17
17
  ];
18
- var Q = class {
19
- constructor(e = m) {
18
+ var Z = class {
19
+ constructor(e = o) {
20
20
  const t = function(e) {
21
- const t = [...H];
21
+ const t = [...Q];
22
22
  if (e) for (const s of Object.values(e)) {
23
23
  const e = s?.trim();
24
24
  e && !t.some((t) => t.toLowerCase() === e.toLowerCase()) && t.push(e);
25
25
  }
26
26
  return t.sort((e, t) => t.length - e.length), t.map((e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
27
- }(e.specifiers), s = X({
27
+ }(e.specifiers), s = H({
28
28
  name: "WhiteSpace",
29
29
  pattern: /\s+/,
30
- group: j.SKIPPED
31
- }), i = X({
30
+ group: q.SKIPPED
31
+ }), i = H({
32
32
  name: "TableSpecifier",
33
33
  pattern: new RegExp(`\\[#(?:${t})\\]`, "i")
34
34
  }), r = [
35
35
  s,
36
36
  i,
37
- X({
37
+ H({
38
38
  name: "BracketedColumn",
39
39
  pattern: /\[([^[\]]*)\]/,
40
40
  longer_alt: [i]
41
41
  }),
42
- X({
42
+ H({
43
43
  name: "BareSpecifier",
44
44
  pattern: new RegExp(`#(?:${t})`, "i")
45
45
  }),
46
- X({
46
+ H({
47
47
  name: "ColumnSep",
48
48
  pattern: /:/
49
49
  }),
50
- X({
50
+ H({
51
51
  name: "ListSep",
52
52
  pattern: new RegExp(e.separators.separatorFunction.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))
53
53
  })
54
54
  ];
55
- this._lexer = new j(r, { ensureOptimizations: !0 });
55
+ this._lexer = new q(r, { ensureOptimizations: !0 });
56
56
  const n = {};
57
57
  r.forEach((e) => {
58
58
  n[e.name] = e;
@@ -64,116 +64,116 @@ var Q = class {
64
64
  tokenize(e) {
65
65
  return this._lexer.tokenize(e);
66
66
  }
67
- }, Z = class extends W {
68
- constructor(e = m) {
69
- const t = new Q(e), s = t.getVocabulary();
70
- super(s, {
67
+ }, K = class extends j {
68
+ constructor(e = o) {
69
+ const t = new Z(e), i = t.getVocabulary();
70
+ super(i, {
71
71
  nodeLocationTracking: "none",
72
72
  maxLookahead: 2,
73
73
  skipValidations: !0,
74
74
  recoveryEnabled: !1
75
75
  }), this._lexer = t;
76
- const { TableSpecifier: i, BracketedColumn: r, BareSpecifier: n, ColumnSep: a, ListSep: h } = s, l = this;
77
- l.RULE("ruleContent", () => {
78
- const e = [], t = l.SUBRULE(l.ruleItem);
79
- return l.ACTION(() => {
76
+ const { TableSpecifier: r, BracketedColumn: a, BareSpecifier: h, ColumnSep: u, ListSep: c } = i, p = this;
77
+ p.RULE("ruleContent", () => {
78
+ const e = [], t = p.SUBRULE(p.ruleItem);
79
+ return p.ACTION(() => {
80
80
  t && e.push(t);
81
- }), l.MANY(() => {
82
- l.CONSUME(h), l.OPTION(() => {
83
- const t = l.SUBRULE2(l.ruleItem);
84
- l.ACTION(() => {
81
+ }), p.MANY(() => {
82
+ p.CONSUME(c), p.OPTION(() => {
83
+ const t = p.SUBRULE2(p.ruleItem);
84
+ p.ACTION(() => {
85
85
  t && e.push(t);
86
86
  });
87
87
  });
88
88
  }), e;
89
- }), l.RULE("ruleItem", () => l.OR([{ ALT: () => l.SUBRULE(l.ruleSpecifier) }, { ALT: () => l.SUBRULE(l.ruleColumnOrRange) }])), l.RULE("ruleSpecifier", () => l.OR([{ ALT: () => {
90
- const t = l.CONSUME(i);
91
- return l.ACTION(() => {
92
- const s = o(t.image, e);
89
+ }), p.RULE("ruleItem", () => p.OR([{ ALT: () => p.SUBRULE(p.ruleSpecifier) }, { ALT: () => p.SUBRULE(p.ruleColumnOrRange) }])), p.RULE("ruleSpecifier", () => p.OR([{ ALT: () => {
90
+ const t = p.CONSUME(r);
91
+ return p.ACTION(() => {
92
+ const s = l(t.image, e);
93
93
  return s.image = t.image, s;
94
94
  });
95
95
  } }, { ALT: () => {
96
- const t = l.CONSUME(n);
97
- return l.ACTION(() => {
98
- const s = o(t.image, e);
96
+ const t = p.CONSUME(h);
97
+ return p.ACTION(() => {
98
+ const s = l(t.image, e);
99
99
  return s.image = t.image, s;
100
100
  });
101
- } }])), l.RULE("ruleColumnOrRange", () => {
102
- const e = l.CONSUME(r);
103
- let t, s;
104
- return l.OPTION(() => {
105
- t = l.CONSUME(a), s = l.CONSUME2(r);
106
- }), l.ACTION(() => {
107
- const i = p(e.image);
108
- if (i.image = e.image, !s) return i;
109
- const r = p(s.image);
110
- r.image = s.image;
111
- const n = O(":", i, r, !0);
112
- return n.image = t?.image ?? ":", n;
101
+ } }])), p.RULE("ruleColumnOrRange", () => {
102
+ const e = p.CONSUME(a);
103
+ let t, i;
104
+ return p.OPTION(() => {
105
+ t = p.CONSUME(u), i = p.CONSUME2(a);
106
+ }), p.ACTION(() => {
107
+ const r = n(e.image);
108
+ if (r.image = e.image, !i) return r;
109
+ const o = n(i.image);
110
+ o.image = i.image;
111
+ const a = s(":", r, o, !0);
112
+ return a.image = t?.image ?? ":", a;
113
113
  });
114
- }), l.performSelfAnalysis();
114
+ }), p.performSelfAnalysis();
115
115
  }
116
116
  _parseInner(e) {
117
117
  const t = this._lexer.tokenize(e);
118
118
  return t.errors.length > 0 || 0 === t.tokens.length ? [] : (this.input = t.tokens, this.reset(), this.ruleContent() ?? []);
119
119
  }
120
- _parseContent(e) {
121
- if (!e) return [];
122
- const t = e.trim();
120
+ _parseContent(t) {
123
121
  if (!t) return [];
124
- const s = t[0];
125
- if ("@" === s) {
126
- const e = t.slice(1).trim();
127
- if (!e) {
128
- const e = x("@", null, !0);
129
- return e.image = "@", [e];
122
+ const s = t.trim();
123
+ if (!s) return [];
124
+ const i = s[0];
125
+ if ("@" === i) {
126
+ const t = s.slice(1).trim();
127
+ if (!t) {
128
+ const t = e("@", null, !0);
129
+ return t.image = "@", [t];
130
130
  }
131
- const s = p(e);
132
- s.image = e;
133
- const i = x("@", s, !0);
134
- return i.image = "@", [i];
131
+ const i = n(t);
132
+ i.image = t;
133
+ const r = e("@", i, !0);
134
+ return r.image = "@", [r];
135
135
  }
136
- if ("[" !== s && "#" !== s) {
137
- const t = p(e);
138
- return t.image = e, [t];
136
+ if ("[" !== i && "#" !== i) {
137
+ const e = n(t);
138
+ return e.image = t, [e];
139
139
  }
140
- return this._parseInner(t);
140
+ return this._parseInner(s);
141
141
  }
142
142
  parse(e, t, s) {
143
143
  const i = () => ({
144
- root: n("", []),
144
+ root: a("", []),
145
145
  errors: []
146
146
  });
147
147
  if (!s) return i();
148
148
  const r = s.indexOf("[");
149
149
  if (-1 === r) return i();
150
- const o = s.slice(0, r), a = s.slice(r + 1, -1);
150
+ const n = s.slice(0, r), o = s.slice(r + 1, -1);
151
151
  return {
152
- root: n(o, this._parseContent(a)),
152
+ root: a(n, this._parseContent(o)),
153
153
  errors: this.errors.length > 0 ? [...this.errors] : []
154
154
  };
155
155
  }
156
- }, K = /* @__PURE__ */ new Set([
156
+ }, J = /* @__PURE__ */ new Set([
157
157
  ":",
158
158
  ".:.",
159
159
  ".:",
160
160
  ":."
161
- ]), J = /* @__PURE__ */ new Set([
161
+ ]), ee = /* @__PURE__ */ new Set([
162
162
  ".:.",
163
163
  ".:",
164
164
  ":."
165
- ]), ee = (e) => {
165
+ ]), te = (e) => {
166
166
  if (!e) return null;
167
- if (e.type === D.Cell) {
167
+ if (e.type === t.Cell) {
168
168
  const t = e.value;
169
169
  return t.rowIndex === Number.MIN_SAFE_INTEGER ? "col" : t.colIndex === Number.MIN_SAFE_INTEGER ? "row" : null;
170
170
  }
171
171
  return Number.isInteger(e.value) ? "row" : null;
172
- }, te = (e, t) => {
172
+ }, se = (e, t) => {
173
173
  const s = parseInt(36 === e.charCodeAt(0) ? e.substring(1) : e, 10);
174
174
  return s >= 1 && s <= t;
175
- }, se = "A formula must not be empty";
176
- function ie(e, t) {
175
+ }, ie = "A formula must not be empty";
176
+ function re(e, t) {
177
177
  const s = e?.[0]?.image;
178
178
  if (!s) {
179
179
  const e = t?.image;
@@ -181,48 +181,48 @@ function ie(e, t) {
181
181
  }
182
182
  return `Unexpected '${s}'`;
183
183
  }
184
- var re = {
185
- ...q,
186
- buildNoViableAltMessage: (e) => ie(e.actual, e.previous),
187
- buildEarlyExitMessage: (e) => ie(e.actual, e.previous),
184
+ var ne = {
185
+ ...X,
186
+ buildNoViableAltMessage: (e) => re(e.actual, e.previous),
187
+ buildEarlyExitMessage: (e) => re(e.actual, e.previous),
188
188
  buildNotAllInputParsedMessage: (e) => {
189
189
  const t = e.firstRedundant?.image;
190
- return t ? `Unexpected '${t}'` : q.buildNotAllInputParsedMessage(e);
190
+ return t ? `Unexpected '${t}'` : X.buildNotAllInputParsedMessage(e);
191
191
  },
192
192
  buildMismatchTokenMessage: (e) => {
193
193
  const t = e.actual?.image;
194
- return e.expected === V && t ? `Unexpected '${t}'` : q.buildMismatchTokenMessage(e);
194
+ return e.expected === W && t ? `Unexpected '${t}'` : X.buildMismatchTokenMessage(e);
195
195
  }
196
- }, ne = class extends W {
196
+ }, oe = class extends j {
197
197
  constructor(n) {
198
- const o = n?.lexer ?? t.shared(n?.lexerOptions), a = o.getVocabulary();
198
+ const o = n?.lexer ?? E.shared(n?.lexerOptions), a = o.getVocabulary();
199
199
  super(a, {
200
200
  skipValidations: !0,
201
201
  recoveryEnabled: !0,
202
202
  ...n,
203
203
  nodeLocationTracking: "full",
204
- errorMessageProvider: re,
204
+ errorMessageProvider: ne,
205
205
  maxLookahead: 1
206
206
  }), this._ruleInfixOp = this.RULE("ruleInfixOp", () => {
207
- const { PlusOp: e, MinOp: t, MulOp: s, DivOp: i, ExOp: r, ConcatOp: n, GtOp: o, EqOp: a, LtOp: l, NeqOp: u, GteOp: c, LteOp: p } = this._vocab, g = [];
207
+ const { PlusOp: e, MinOp: t, MulOp: i, DivOp: r, ExOp: n, ConcatOp: o, GtOp: a, EqOp: h, LtOp: l, NeqOp: u, GteOp: c, LteOp: p } = this._vocab, g = [];
208
208
  return g.push({ node: this.SUBRULE(this._rulePostfixOp) }), this.MANY(() => {
209
- const O = this.OR(this._c1 || (this._c1 = [
209
+ const s = this.OR(this._c1 || (this._c1 = [
210
210
  { ALT: () => this.CONSUME(e).image },
211
211
  { ALT: () => this.CONSUME(t).image },
212
- { ALT: () => this.CONSUME(s).image },
213
212
  { ALT: () => this.CONSUME(i).image },
214
213
  { ALT: () => this.CONSUME(r).image },
215
214
  { ALT: () => this.CONSUME(n).image },
216
215
  { ALT: () => this.CONSUME(o).image },
217
216
  { ALT: () => this.CONSUME(a).image },
217
+ { ALT: () => this.CONSUME(h).image },
218
218
  { ALT: () => this.CONSUME(l).image },
219
219
  { ALT: () => this.CONSUME(u).image },
220
220
  { ALT: () => this.CONSUME(c).image },
221
221
  { ALT: () => this.CONSUME(p).image }
222
222
  ])), _ = {
223
- value: O,
223
+ value: s,
224
224
  index: this.getLexerPosition(),
225
- isRange: h.includes(O)
225
+ isRange: O.includes(s)
226
226
  }, m = this.SUBRULE2(this._rulePostfixOp);
227
227
  g.push({
228
228
  op: _,
@@ -230,17 +230,17 @@ var re = {
230
230
  });
231
231
  }), this.ACTION(() => {
232
232
  let e = g.length - 1;
233
- const t = R.length;
234
- for (let s = 0; e > 0 && s < t; s++) {
235
- const t = R[s];
236
- let i = 1;
237
- for (; i < g.length;) {
238
- const s = g[i].op;
239
- if (t.includes(s.value)) {
240
- const t = g[i - 1].node, r = g[i].node;
241
- let n = O(s.value, t, r, s.isRange);
242
- n = this._tag(n, s.index), g[i - 1].node = n, g.splice(i, 1), e--;
243
- } else i++;
233
+ const t = C.length;
234
+ for (let i = 0; e > 0 && i < t; i++) {
235
+ const t = C[i];
236
+ let r = 1;
237
+ for (; r < g.length;) {
238
+ const i = g[r].op;
239
+ if (t.includes(i.value)) {
240
+ const t = g[r - 1].node, n = g[r].node;
241
+ let o = s(i.value, t, n, i.isRange);
242
+ o = this._tag(o, i.index), g[r - 1].node = o, g.splice(r, 1), e--;
243
+ } else r++;
244
244
  }
245
245
  }
246
246
  }), g[0].node;
@@ -248,64 +248,73 @@ var re = {
248
248
  const { PlusOp: e, MinOp: t } = this._vocab;
249
249
  return this.OR([{ ALT: () => this.CONSUME(e) }, { ALT: () => this.CONSUME(t) }]);
250
250
  }), this._rulePostfixOp = this.RULE("rulePostfixOp", () => {
251
- const { PercentOp: e, ArrayAnchorOp: t } = this._vocab;
252
- let s = this.SUBRULE(this._rulePrefixOp);
253
- const i = [];
251
+ const { PercentOp: e } = this._vocab;
252
+ let t = this.SUBRULE(this._rulePrefixOp);
253
+ const s = [];
254
254
  return this.MANY(() => {
255
- const s = this.OR([{ ALT: () => this.CONSUME(e).image }, { ALT: () => this.CONSUME(t).image }]);
255
+ const t = this.CONSUME(e).image;
256
256
  this.ACTION(() => {
257
- i.push([s, this.getLexerPosition()]);
257
+ s.push([t, this.getLexerPosition()]);
258
258
  });
259
259
  }), this.ACTION(() => {
260
- const e = i.length;
261
- if (0 !== e) for (let t = 0; t < e; t++) {
262
- const e = i[t], r = e[0], n = e[1], o = h.includes(r);
263
- s = c(r, s, o), s = this._tag(s, n);
260
+ const e = s.length;
261
+ if (0 !== e) for (let i = 0; i < e; i++) {
262
+ const e = s[i], r = e[0], n = e[1], o = O.includes(r);
263
+ t = I(r, t, o), t = this._tag(t, n);
264
264
  }
265
- }), s;
265
+ }), t;
266
266
  }), this._rulePrefixOp = this.RULE("rulePrefixOp", () => {
267
- const { PlusOp: e, MinOp: t, ImplicitIntersectOp: s } = this._vocab, i = [];
267
+ const { PlusOp: t, MinOp: s, ImplicitIntersectOp: i } = this._vocab, r = [];
268
268
  this.MANY(() => {
269
- const r = this.OR([
270
- { ALT: () => this.CONSUME(e).image },
269
+ const e = this.OR([
271
270
  { ALT: () => this.CONSUME(t).image },
272
- { ALT: () => this.CONSUME(s).image }
271
+ { ALT: () => this.CONSUME(s).image },
272
+ { ALT: () => this.CONSUME(i).image }
273
273
  ]);
274
274
  this.ACTION(() => {
275
- i.push([r, this.getLexerPosition()]);
275
+ r.push([e, this.getLexerPosition()]);
276
276
  });
277
277
  });
278
- let r = this.SUBRULE(this._ruleRangeOp);
278
+ let n = this.SUBRULE(this._ruleRangeOp);
279
279
  return this.ACTION(() => {
280
- const e = i.length;
281
- if (0 !== e) for (let t = e - 1; t >= 0; t--) {
282
- const e = i[t], s = e[0], n = e[1], o = h.includes(s);
283
- r = x(s, r, o), r = this._tag(r, n);
280
+ const t = r.length;
281
+ if (0 !== t) for (let s = t - 1; s >= 0; s--) {
282
+ const t = r[s], i = t[0], o = t[1], a = O.includes(i);
283
+ n = e(i, n, a), n = this._tag(n, o);
284
284
  }
285
- }), r;
285
+ }), n;
286
286
  }), this._ruleRangeOp = this.RULE("ruleRangeOp", () => {
287
- const { RangeOp: e, RangeTrimFullOp: t, RangeTrimLeadingOp: s, RangeTrimTrailingOp: i } = this._vocab, r = [];
288
- return r.push({ node: this.SUBRULE(this._ruleCallOp) }), this.MANY(() => {
289
- const n = {
287
+ const { RangeOp: e, RangeTrimFullOp: t, RangeTrimLeadingOp: i, RangeTrimTrailingOp: r, ArrayAnchorOp: n } = this._vocab, o = [];
288
+ return o.push({ node: this.SUBRULE(this._ruleCallOp) }), this.MANY2(() => {
289
+ this.CONSUME(n), o.push({ anchor: this.getLexerPosition() });
290
+ }), this.MANY(() => {
291
+ const s = {
290
292
  value: this.OR(this._c2 || (this._c2 = [
291
293
  { ALT: () => this.CONSUME(e).image },
292
294
  { ALT: () => this.CONSUME(t).image },
293
- { ALT: () => this.CONSUME(s).image },
294
- { ALT: () => this.CONSUME(i).image }
295
+ { ALT: () => this.CONSUME(i).image },
296
+ { ALT: () => this.CONSUME(r).image }
295
297
  ])),
296
298
  index: this.getLexerPosition()
297
- }, o = this.SUBRULE2(this._ruleCallOp);
298
- r.push({
299
- op: n,
300
- node: o
299
+ }, a = this.SUBRULE2(this._ruleCallOp);
300
+ o.push({
301
+ op: s,
302
+ node: a
303
+ }), this.MANY3(() => {
304
+ this.CONSUME2(n), o.push({ anchor: this.getLexerPosition() });
301
305
  });
302
306
  }), this.ACTION(() => {
303
- for (let e = 1; e < r.length; e++) {
304
- const t = r[e].op;
305
- let s = O(t.value, r[0].node, r[e].node, !0);
306
- s = this._tag(s, t.index), r[0].node = s;
307
+ for (let e = 1; e < o.length; e++) {
308
+ const t = o[e];
309
+ if (void 0 !== t.anchor) {
310
+ o[0].node = this._tag(I("#", o[0].node, !0), t.anchor);
311
+ continue;
312
+ }
313
+ const i = t.op;
314
+ let r = s(i.value, o[0].node, t.node, !0);
315
+ r = this._tag(r, i.index), o[0].node = r;
307
316
  }
308
- }), r[0].node;
317
+ }), o[0].node;
309
318
  }), this._ruleCallOp = this.RULE("ruleCallOp", () => {
310
319
  const { OpenParen: e, CloseParen: t } = this._vocab;
311
320
  let s = this.SUBRULE(this._ruleFormula);
@@ -316,7 +325,7 @@ var re = {
316
325
  },
317
326
  DEF: () => {
318
327
  this.CONSUME(e);
319
- const i = this.getLexerPosition(), r = this.SUBRULE(this._ruleFunctionArguments), n = s, o = this.ACTION(() => this._tag(E(n, r), i)), a = this.OPTION(() => this.CONSUME(t));
328
+ const i = this.getLexerPosition(), r = this.SUBRULE(this._ruleFunctionArguments), n = s, o = this.ACTION(() => this._tag($(n, r), i)), a = this.OPTION(() => this.CONSUME(t));
320
329
  this.ACTION(() => {
321
330
  a || this._reportError(o, "Missing closing parenthesis ')'", i), this._tagClose(o, this.getLexerPosition()), s = o;
322
331
  });
@@ -337,15 +346,15 @@ var re = {
337
346
  }), this.ACTION(() => {
338
347
  for (; e.length > 1;) {
339
348
  let t = e.length - 1;
340
- for (let s = 0; s < t; s++) {
341
- const i = e[s], r = e[s + 1], n = O(" ", i, r, !0), o = this._tokenMap.get(i);
342
- o && delete o.tokenIndexClose;
343
- const a = this._tokenMap.get(r), h = a?.tokenIndex;
344
- if (void 0 !== h) {
345
- const e = this.input[h], t = this.input[h - 1]?.endOffset ?? -1, s = this._inputText.slice(t + 1, e.startOffset).slice(0, -1);
346
- s.length > 0 && (n.wsBefore = s);
349
+ for (let i = 0; i < t; i++) {
350
+ const r = e[i], n = e[i + 1], o = s(" ", r, n, !0), a = this._tokenMap.get(r);
351
+ a && delete a.tokenIndexClose;
352
+ const h = this._tokenMap.get(n), l = h?.tokenIndex;
353
+ if (void 0 !== l) {
354
+ const e = this.input[l], t = this.input[l - 1]?.endOffset ?? -1, s = this._inputText.slice(t + 1, e.startOffset).slice(0, -1);
355
+ s.length > 0 && (o.wsBefore = s);
347
356
  }
348
- a && delete a.tokenIndex, s + 1 < t && a && delete a.tokenIndexClose, e.splice(s, 2, n), s--, t--;
357
+ h && delete h.tokenIndex, i + 1 < t && h && delete h.tokenIndexClose, e.splice(i, 2, o), i--, t--;
349
358
  }
350
359
  }
351
360
  }), e[0];
@@ -367,82 +376,82 @@ var re = {
367
376
  });
368
377
  }), t;
369
378
  }), this._ruleParen = this.RULE("ruleParen", () => {
370
- const { OpenParen: e, CloseParen: t } = this._vocab;
371
- return this._processParen(D.Paren, e, t);
379
+ const { OpenParen: e, CloseParen: s } = this._vocab;
380
+ return this._processParen(t.Paren, e, s);
372
381
  }), this._ruleLiteralArray = this.RULE("ruleLiteralArray", () => {
373
- const { OpenCurlyParen: e, CloseCurlyParen: t, ColSeparator: i, RowSeparator: r } = this._vocab;
374
- let n = _();
382
+ const { OpenCurlyParen: e, CloseCurlyParen: t, ColSeparator: s, RowSeparator: i } = this._vocab;
383
+ let n = r();
375
384
  this.CONSUME(e);
376
385
  const o = this.getLexerPosition();
377
- let a = this.ACTION(() => this._tag(s(n), o));
386
+ let a = this.ACTION(() => this._tag(F(n), o));
378
387
  const h = this.SUBRULE(this._ruleLiteralForArray);
379
388
  this.ACTION(() => {
380
389
  n.value.push(h);
381
390
  }), this.MANY(() => {
382
391
  let e = !1;
383
392
  this.OR([{ ALT: () => {
384
- this.CONSUME(i), e = !0;
385
- } }, { ALT: () => this.CONSUME(r) }]);
393
+ this.CONSUME(s), e = !0;
394
+ } }, { ALT: () => this.CONSUME(i) }]);
386
395
  const t = this.SUBRULE2(this._ruleLiteralForArray);
387
396
  this.ACTION(() => {
388
- e || (n = _(), a.value.push(n)), n.value.push(t);
397
+ e || (n = r(), a.value.push(n)), n.value.push(t);
389
398
  });
390
399
  });
391
400
  const l = this.OPTION(() => this.CONSUME(t));
392
401
  return a = this.ACTION(() => (l || this._reportError(a, "Missing closing parenthesis '}'", o), this._tagClose(a, this.getLexerPosition()))), a;
393
402
  }), this._ruleLiteralForArray = this.RULE("ruleLiteralForArray", () => {
394
- const { StringToken: t, BooleanToken: s, LiteralError: r, RefError: n } = this._vocab;
403
+ const { StringToken: e, BooleanToken: t, LiteralError: s, RefError: i } = this._vocab;
395
404
  return this.OR([
396
405
  { ALT: () => {
397
- const t = this.OPTION(() => this.SUBRULE(this._rulePlusMinusOp)), s = this.SUBRULE(this._ruleNumber), r = this.ACTION(() => this._tag(i(s.image, this._locale), this.getLexerPosition()));
398
- return this.ACTION(() => t ? e(t.image, r) : r);
406
+ const e = this.OPTION(() => this.SUBRULE(this._rulePlusMinusOp)), t = this.SUBRULE(this._ruleNumber), s = this.ACTION(() => this._tag(p(t.image, this._locale), this.getLexerPosition()));
407
+ return this.ACTION(() => e ? x(e.image, s) : s);
399
408
  } },
400
409
  { ALT: () => {
401
- const e = this.CONSUME(t);
402
- return this.ACTION(() => this._tag(u(e.image), this.getLexerPosition()));
410
+ const t = this.CONSUME(e);
411
+ return this.ACTION(() => this._tag(g(t.image), this.getLexerPosition()));
403
412
  } },
404
413
  { ALT: () => {
405
- const e = this.CONSUME(s);
406
- return this.ACTION(() => this._tag(N(e.image, this._locale), this.getLexerPosition()));
414
+ const e = this.CONSUME(t);
415
+ return this.ACTION(() => this._tag(L(e.image, this._locale), this.getLexerPosition()));
407
416
  } },
408
417
  { ALT: () => {
409
- const e = this.CONSUME(r);
410
- return this.ACTION(() => this._tag($(e.image, this._locale), this.getLexerPosition()));
418
+ const e = this.CONSUME(s);
419
+ return this.ACTION(() => this._tag(m(e.image, this._locale), this.getLexerPosition()));
411
420
  } },
412
421
  { ALT: () => {
413
- const e = this.CONSUME(n);
414
- return this.ACTION(() => this._tag(S(e.image, this._locale), this.getLexerPosition()));
422
+ const e = this.CONSUME(i);
423
+ return this.ACTION(() => this._tag(u(e.image, this._locale), this.getLexerPosition()));
415
424
  } }
416
425
  ]);
417
426
  }), this._ruleLiteral = this.RULE("ruleLiteral", () => {
418
- const { StringToken: e, BooleanToken: t, LiteralError: s, RefError: r } = this._vocab;
427
+ const { StringToken: e, BooleanToken: t, LiteralError: s, RefError: i } = this._vocab;
419
428
  return this.OR([
420
429
  { ALT: () => {
421
430
  const e = this.SUBRULE(this._ruleNumber);
422
- return this.ACTION(() => this._tag(i(e.image, this._locale), this.getLexerPosition()));
431
+ return this.ACTION(() => this._tag(p(e.image, this._locale), this.getLexerPosition()));
423
432
  } },
424
433
  { ALT: () => {
425
434
  const t = this.CONSUME(e);
426
- return this.ACTION(() => this._tag(u(t.image), this.getLexerPosition()));
435
+ return this.ACTION(() => this._tag(g(t.image), this.getLexerPosition()));
427
436
  } },
428
437
  { ALT: () => {
429
438
  const e = this.CONSUME(t);
430
- return this.ACTION(() => this._tag(N(e.image, this._locale), this.getLexerPosition()));
439
+ return this.ACTION(() => this._tag(L(e.image, this._locale), this.getLexerPosition()));
431
440
  } },
432
441
  { ALT: () => {
433
442
  const e = this.CONSUME(s);
434
- return this.ACTION(() => this._tag($(e.image, this._locale), this.getLexerPosition()));
443
+ return this.ACTION(() => this._tag(m(e.image, this._locale), this.getLexerPosition()));
435
444
  } },
436
445
  { ALT: () => {
437
- const e = this.CONSUME(r);
438
- return this.ACTION(() => this._tag(S(e.image, this._locale), this.getLexerPosition()));
446
+ const e = this.CONSUME(i);
447
+ return this.ACTION(() => this._tag(u(e.image, this._locale), this.getLexerPosition()));
439
448
  } }
440
449
  ]);
441
450
  }), this._ruleFunction = this.RULE("ruleFunction", () => {
442
451
  const { FunctionToken: e, OpenParen: t, CloseParen: s } = this._vocab, i = this.CONSUME(e).image, r = this.getLexerPosition();
443
452
  this.CONSUME(t);
444
453
  const n = this.SUBRULE(this._ruleFunctionArguments);
445
- let o = this.ACTION(() => this._tag(F(i, n), r));
454
+ let o = this.ACTION(() => this._tag(_(i, n), r));
446
455
  const a = this.OPTION(() => this.CONSUME(s));
447
456
  return o = this.ACTION(() => (a || this._reportError(o, "Missing closing parenthesis ')'", r), this._tagClose(o, this.getLexerPosition()))), o;
448
457
  }), this._ruleFunctionArguments = this.RULE("ruleFunctionArguments", () => {
@@ -453,11 +462,11 @@ var re = {
453
462
  let t;
454
463
  this.OPTION2(() => {
455
464
  t = this.SUBRULE(this._ruleIntersectOp);
456
- }), t = this.ACTION(() => t ?? this._tagClose(A(), this.getLexerPosition())), s.push(t), this.MANY(() => {
465
+ }), t = this.ACTION(() => t ?? this._tagClose(G(), this.getLexerPosition())), s.push(t), this.MANY(() => {
457
466
  let t;
458
467
  this.CONSUME(e), this.OPTION3(() => {
459
468
  t = this.SUBRULE2(this._ruleIntersectOp);
460
- }), t = this.ACTION(() => t ?? this._tagClose(A(), this.getLexerPosition())), s.push(t);
469
+ }), t = this.ACTION(() => t ?? this._tagClose(G(), this.getLexerPosition())), s.push(t);
461
470
  });
462
471
  }
463
472
  }), s;
@@ -476,14 +485,14 @@ var re = {
476
485
  return this._tag(e.root, s);
477
486
  });
478
487
  }), this._ruleReference = this.RULE("ruleReference", () => {
479
- const { Sheet: e, SheetQuoted: t, DivOp: s, MulOp: i, PlusOp: n, MinOp: o, ArgSeparator: a, Cell: h, ArrayAnchorOp: u, NamedToken: p, SingleQuotedString: g, Column: O, AbsRow: _, DigitToken: m, RefError: E } = this._vocab;
488
+ const { Sheet: e, SheetQuoted: s, DivOp: r, MulOp: n, PlusOp: o, MinOp: a, ArgSeparator: h, Cell: l, NamedToken: p, SingleQuotedString: g, Column: O, AbsRow: _, DigitToken: m, RefError: E } = this._vocab;
480
489
  let L;
481
490
  this.OPTION2({
482
491
  GATE: () => {
483
- for (let r = 1; r < 6; r++) {
484
- const h = this.LA(r);
485
- if (h.tokenType === e || h.tokenType === t) return !0;
486
- if ("" === h.image || ")" === h.image || h.tokenType === s || h.tokenType === i || h.tokenType === n || h.tokenType === o || h.tokenType === a) break;
492
+ for (let t = 1; t < 6; t++) {
493
+ const i = this.LA(t);
494
+ if (i.tokenType === e || i.tokenType === s) return !0;
495
+ if ("" === i.image || ")" === i.image || i.tokenType === r || i.tokenType === n || i.tokenType === o || i.tokenType === a || i.tokenType === h) break;
487
496
  }
488
497
  return !1;
489
498
  },
@@ -493,40 +502,37 @@ var re = {
493
502
  });
494
503
  let A = this.OR([
495
504
  { ALT: () => {
496
- const e = this.CONSUME(h), t = this.getLexerPosition(), s = this.OPTION(() => this.CONSUME(u));
497
- return this.ACTION(() => {
498
- const i = this._tag(B(e.image, this.rowIndex, this.colIndex), t);
499
- return s ? this._tag(c("#", i, !0), t) : i;
500
- });
505
+ const e = this.CONSUME(l), t = this.getLexerPosition();
506
+ return this.ACTION(() => this._tag(D(e.image, this.rowIndex, this.colIndex), t));
501
507
  } },
502
508
  { ALT: () => {
503
509
  const e = this.OR2([{ ALT: () => this.CONSUME(p) }, { ALT: () => this.CONSUME(g) }]);
504
- return this.ACTION(() => this._tag(r(e.image), this.getLexerPosition()));
510
+ return this.ACTION(() => this._tag(i(e.image), this.getLexerPosition()));
505
511
  } },
506
512
  { ALT: () => this.SUBRULE(this._ruleBracketedString) },
507
513
  { ALT: () => this.SUBRULE(this._ruleFunction) },
508
514
  { ALT: () => {
509
515
  const e = this.CONSUME(O);
510
- return this.ACTION(() => this._tag(G(e.image, this.colIndex), this.getLexerPosition()));
516
+ return this.ACTION(() => this._tag(T(e.image, this.colIndex), this.getLexerPosition()));
511
517
  } },
512
518
  { ALT: () => {
513
519
  const e = this.CONSUME(_);
514
- return this.ACTION(() => this._tag(l(e.image, this.rowIndex), this.getLexerPosition()));
520
+ return this.ACTION(() => this._tag(c(e.image, this.rowIndex), this.getLexerPosition()));
515
521
  } },
516
522
  { ALT: () => {
517
523
  const e = this.CONSUME(m);
518
- return this.ACTION(() => this._tag(l(e.image, this.rowIndex), this.getLexerPosition()));
524
+ return this.ACTION(() => this._tag(c(e.image, this.rowIndex), this.getLexerPosition()));
519
525
  } },
520
526
  { ALT: () => {
521
527
  const e = this.CONSUME(E);
522
- return this.ACTION(() => this._tag(S(e.image, this._locale), this.getLexerPosition()));
528
+ return this.ACTION(() => this._tag(u(e.image, this._locale), this.getLexerPosition()));
523
529
  } }
524
530
  ]);
525
531
  return this.ACTION(() => {
526
532
  if (L && A) {
527
533
  if ("" === L.name) return void this._reportError(A, `'${L.image}' is not a valid sheet reference — a '!' needs a sheet name before it`);
528
534
  let e = A;
529
- A.type === D.Postfix && A.inputs?.[0] && (e = A.inputs[0]), e.type !== D.Cell && e.type !== D.Named && e.type !== D.Row && e.type !== D.TableColumn && e.type !== D.Error || (e.value.scope = L.name, e.value.scopeImage = L.image);
535
+ A.type === t.Postfix && A.inputs?.[0] && (e = A.inputs[0]), e.type !== t.Cell && e.type !== t.Named && e.type !== t.Row && e.type !== t.TableColumn && e.type !== t.Error || (e.value.scope = L.name, e.value.scopeImage = L.image);
530
536
  }
531
537
  }), A;
532
538
  }), this._rulePrefixSheetName = this.RULE("rulePrefixSheetName", () => {
@@ -561,52 +567,52 @@ var re = {
561
567
  { ALT: () => this.CONSUME(s) }
562
568
  ]);
563
569
  }), this._ruleRoot = this.RULE("ruleRoot", () => {
564
- const { ArgSeparator: e } = this._vocab, t = this.SUBRULE(this._ruleIntersectOp), s = [];
570
+ const { ArgSeparator: e } = this._vocab, s = this.SUBRULE(this._ruleIntersectOp), i = [];
565
571
  return this.MANY(() => {
566
- this.CONSUME(e), s.push(this.SUBRULE2(this._ruleIntersectOp));
567
- }), this.ACTION(() => 0 === s.length ? t : {
568
- type: D.List,
572
+ this.CONSUME(e), i.push(this.SUBRULE2(this._ruleIntersectOp));
573
+ }), this.ACTION(() => 0 === i.length ? s : {
574
+ type: t.List,
569
575
  value: ",",
570
- inputs: [t, ...s],
576
+ inputs: [s, ...i],
571
577
  isReference: !0
572
578
  });
573
- }), this._lexer = o, this._locale = o.getLocale(), this._vocab = a, this._srParser = n?.srParser ?? new Z(this._locale), this.performSelfAnalysis();
579
+ }), this._lexer = o, this._locale = o.getLocale(), this._vocab = a, this._srParser = n?.srParser ?? new K(this._locale), this.performSelfAnalysis();
574
580
  }
575
581
  getLexer() {
576
582
  return this._lexer;
577
583
  }
578
- parse(e, t, s, i) {
579
- const n = this._lexer.tokenize(s);
580
- let o;
581
- if (!n) return {
584
+ parse(e, s, r, n) {
585
+ const o = this._lexer.tokenize(r);
586
+ let a;
587
+ if (!o) return {
582
588
  root: {
583
- type: D.Unparsed,
584
- value: s
589
+ type: t.Unparsed,
590
+ value: r
585
591
  },
586
592
  errors: []
587
593
  };
588
- const a = n.tokens;
589
- if (0 === a.length) throw new z.Parse(se);
590
- return this.input = a, this._inputText = s, this._inputTextLength = s.length, this.rowIndex = e, this.colIndex = t, this._astErrors = [], this._tokenMap = /* @__PURE__ */ new Map(), this.reset(), o = this._ruleRoot(), o && this._bindAllWhitespace(o), o = g(o, (t, s) => {
591
- const i = t.type, n = s?.isReference ? s.value : void 0, o = "string" == typeof n && K.has(n), a = "string" == typeof n && J.has(n), h = o ? s.inputs : void 0, u = h ? h[0] === t ? h[1] : h[0] : void 0, c = this._lexer.getMaxRow();
592
- if (o && i !== D.Cell && Number.isInteger(t.value)) {
593
- const s = l(t.image, e);
594
- return d(s, t), "row" !== ee(u) ? this._reportError(s, `'${t.image}' is not a valid reference — a whole row can only pair with another row (as in ${t.image}:${t.image})`) : te(t.image, c) || this._reportError(s, `'${t.image}' is not a valid row — rows run from 1 to ${c}`), s;
594
+ const h = o.tokens;
595
+ if (0 === h.length) throw new z.Parse(ie);
596
+ return this.input = h, this._inputText = r, this._inputTextLength = r.length, this.rowIndex = e, this.colIndex = s, this._astErrors = [], this._tokenMap = /* @__PURE__ */ new Map(), this.reset(), a = this._ruleRoot(), a && this._bindAllWhitespace(a), a = Y(a, (s, r) => {
597
+ const n = s.type, o = r?.isReference ? r.value : void 0, a = "string" == typeof o && J.has(o), h = "string" == typeof o && ee.has(o), l = a ? r.inputs : void 0, u = l ? l[0] === s ? l[1] : l[0] : void 0, p = this._lexer.getMaxRow();
598
+ if (a && n !== t.Cell && Number.isInteger(s.value)) {
599
+ const t = c(s.image, e);
600
+ return N(t, s), "row" !== te(u) ? this._reportError(t, `'${s.image}' is not a valid reference — a whole row can only pair with another row (as in ${s.image}:${s.image})`) : se(s.image, p) || this._reportError(t, `'${s.image}' is not a valid row — rows run from 1 to ${p}`), t;
595
601
  }
596
- if (a && i === D.Named) return this._reportError(t, `'${t.image ?? t.value?.nameId}' is a name — '${n}' needs a cell or range on both sides`), t;
597
- if (i === D.Cell) {
598
- const e = t.value, s = e.colIndex === Number.MIN_SAFE_INTEGER, i = e.rowIndex === Number.MIN_SAFE_INTEGER;
599
- if ((s || i) && ee(u) === (s ? "row" : "col")) return s && !te(t.image, c) && this._reportError(t, `'${t.image}' is not a valid row — rows run from 1 to ${c}`), t;
600
- if (s || i || e.colIndex >= 16384) {
601
- const o = r(t.image);
602
- d(o, t);
603
- const h = e.scope;
604
- return h && (o.value.scope = h, o.value.scopeImage = e.scopeImage), s ? this._reportError(o, `'${t.image}' is not a valid reference — a row needs a column (use ${t.image}:${t.image} for the whole row)`) : i && t.image.includes("$") ? this._reportError(o, `'${t.image}' is not a valid reference — a whole column can only pair with another column (as in ${t.image}:${t.image})`) : a && this._reportError(o, `'${t.image}' is a name — '${n}' needs a cell or range on both sides`), o;
602
+ if (h && n === t.Named) return this._reportError(s, `'${s.image ?? s.value?.nameId}' is a name — '${o}' needs a cell or range on both sides`), s;
603
+ if (n === t.Cell) {
604
+ const e = s.value, t = e.colIndex === Number.MIN_SAFE_INTEGER, r = e.rowIndex === Number.MIN_SAFE_INTEGER;
605
+ if ((t || r) && te(u) === (t ? "row" : "col")) return t && !se(s.image, p) && this._reportError(s, `'${s.image}' is not a valid row — rows run from 1 to ${p}`), s;
606
+ if (t || r || e.colIndex >= 16384) {
607
+ const n = i(s.image);
608
+ N(n, s);
609
+ const a = e.scope;
610
+ return a && (n.value.scope = a, n.value.scopeImage = e.scopeImage), t ? this._reportError(n, `'${s.image}' is not a valid reference — a row needs a column (use ${s.image}:${s.image} for the whole row)`) : r && s.image.includes("$") ? this._reportError(n, `'${s.image}' is not a valid reference — a whole column can only pair with another column (as in ${s.image}:${s.image})`) : h && this._reportError(n, `'${s.image}' is a name — '${o}' needs a cell or range on both sides`), n;
605
611
  }
606
612
  }
607
- return t;
608
- }), i && o && (o = k(o, i, null)), {
609
- root: o,
613
+ return s;
614
+ }), n && a && (a = w(a, n, null)), {
615
+ root: a,
610
616
  errors: [...this.errors, ...this._astErrors]
611
617
  };
612
618
  }
@@ -662,26 +668,26 @@ var re = {
662
668
  _bindAllWhitespace(e) {
663
669
  if (e) {
664
670
  if (this._bindNodeWhitespace(e), e.inputs) for (const t of e.inputs) t && this._bindAllWhitespace(t);
665
- if (e.type === D.Array && Array.isArray(e.value)) {
671
+ if (e.type === t.Array && Array.isArray(e.value)) {
666
672
  for (const t of e.value) if (t && Array.isArray(t.value)) for (const e of t.value) e && this._bindAllWhitespace(e);
667
673
  }
668
674
  }
669
675
  }
670
- }, oe = class {
676
+ }, ae = class {
671
677
  constructor(e) {
672
- e = { ...e }, this._editing = "editing" === e.profile, this._parser = new ne(e);
678
+ e = { ...e }, this._editing = "editing" === e.profile, this._parser = new oe(e);
673
679
  }
674
- compile(e, t, s, i, r, n, o, h) {
680
+ compile(e, t, s, i, r, n, o, a) {
675
681
  if (0 === i.length) {
676
- const t = new z.Parse(se);
682
+ const t = new z.Parse(ie);
677
683
  return this._compileUnparsed(e, r, i, {
678
684
  input: i,
679
685
  cause: t,
680
686
  causes: [t]
681
687
  });
682
688
  }
683
- if (i.length > a.MAX_EXPRESSION_LENGTH) {
684
- const t = new z.Parse((l = i.length, `A formula must not be longer than ${a.MAX_EXPRESSION_LENGTH} characters (this one is ${l})`));
689
+ if (i.length > h.MAX_EXPRESSION_LENGTH) {
690
+ const t = new z.Parse((l = i.length, `A formula must not be longer than ${h.MAX_EXPRESSION_LENGTH} characters (this one is ${l})`));
685
691
  return this._compileUnparsed(e, r, i, {
686
692
  input: i,
687
693
  cause: t,
@@ -691,22 +697,22 @@ var re = {
691
697
  var l;
692
698
  let u, c, p = [];
693
699
  try {
694
- const e = this._parser.parse(t, s, i, h);
700
+ const e = this._parser.parse(t, s, i, a);
695
701
  u = e.root, p = e.errors;
696
702
  } catch (e) {
697
703
  c = z.isError(e, z.Code.Parse) ? e : new z.Parse(e.message, e);
698
704
  }
699
705
  const g = [];
700
- for (const e of p) g.push(w(e));
706
+ for (const e of p) g.push(U(e));
701
707
  if (u) {
702
- T(u, n ?? null) && g.push(new z.Parse("The implicit intersection operator ' ' requires a cell or range on both sides")), I(u, n ?? null) && g.push(new z.Parse("Expected a reference; a value cannot be converted to one."));
703
- const e = C(u, n ?? null);
708
+ R(u, n ?? null) && g.push(new z.Parse("The implicit intersection operator ' ' requires a cell or range on both sides")), f(u, n ?? null) && g.push(new z.Parse("The spill anchor operator '#' requires a cell or range")), B(u, n ?? null) && g.push(new z.Parse("Expected a reference; a value cannot be converted to one."));
709
+ const e = S(u, n ?? null);
704
710
  e && g.push(new z.Parse(e));
705
- const t = L(u, n ?? null);
711
+ const t = A(u, n ?? null);
706
712
  t && g.push(new z.Parse(t));
707
- const s = P(u, n ?? null);
713
+ const s = v(u, n ?? null);
708
714
  s && g.push(new z.Parse(s));
709
- const i = b(u);
715
+ const i = k(u);
710
716
  i && g.push(new z.Parse(i));
711
717
  }
712
718
  g.length > 0 && !c && (c = g[0]);
@@ -722,9 +728,9 @@ var re = {
722
728
  }
723
729
  return this._compileUnparsed(e, r, i, O);
724
730
  }
725
- u = U(u, n ?? null), u = M(u, n ?? null), r && (u = f(u, r, o));
726
- const _ = y(e, r, u, this._editing, O, n ?? null);
727
- if (this._editing && O && v(_.getTokens(), r) !== i) return this._recoverCompiled(e, t, s, i, r, O, o) || this._compileUnparsed(e, r, i, O);
731
+ u = y(u, n ?? null), u = P(u, n ?? null), r && (u = d(u, r, o));
732
+ const _ = b(e, r, u, this._editing, O, n ?? null);
733
+ if (this._editing && O && M(_.getTokens(), r) !== i) return this._recoverCompiled(e, t, s, i, r, O, o) || this._compileUnparsed(e, r, i, O);
728
734
  return _;
729
735
  }
730
736
  autoCorrect(e) {
@@ -745,93 +751,93 @@ var re = {
745
751
  }
746
752
  return 0 === s.length ? null : e + s.reverse().join("");
747
753
  }
748
- _compileUnparsed(e, t, s, i) {
749
- const r = {
754
+ _compileUnparsed(e, s, i, r) {
755
+ const n = {
750
756
  runtime: e,
751
- symbols: t,
757
+ symbols: s,
752
758
  getFunction: null,
753
759
  ast: null,
754
- evaluations: Y.EmptyArray,
755
- executions: Y.EmptyArray,
756
- bindings: Y.EmptyArray,
757
- referencesAbsolute: Y.EmptyArray,
758
- referencesExecute: Y.EmptyArray,
759
- referencesRelative: Y.EmptyArray,
760
- referencesRoot: Y.EmptyArray,
761
- referenceIndices: Y.EmptyArray,
760
+ evaluations: V.EmptyArray,
761
+ executions: V.EmptyArray,
762
+ bindings: V.EmptyArray,
763
+ referencesAbsolute: V.EmptyArray,
764
+ referencesExecute: V.EmptyArray,
765
+ referencesRelative: V.EmptyArray,
766
+ referencesRoot: V.EmptyArray,
767
+ referenceIndices: V.EmptyArray,
762
768
  getTokens: () => [{
763
- type: D.Unparsed,
764
- value: s,
765
- text: s
769
+ type: t.Unparsed,
770
+ value: i,
771
+ text: i
766
772
  }],
767
- namedIds: Y.EmptyArray,
768
- symbolIds: Y.EmptyArray,
773
+ namedIds: V.EmptyArray,
774
+ symbolIds: V.EmptyArray,
769
775
  hasTotals: !1,
770
776
  isReferenceOnly: !1,
771
- error: i,
772
- transform: () => r
777
+ error: r,
778
+ transform: () => n
773
779
  };
774
- return r;
780
+ return n;
775
781
  }
776
- _recoverCompiled(e, t, s, i, r, n, o) {
777
- let a, h = i.length;
782
+ _recoverCompiled(e, s, i, r, n, o, a) {
783
+ let h, l = r.length;
778
784
  try {
779
- const e = this._parser.getLexer().tokenize(i, !1);
780
- a = e.tokens, e.errors.length > 0 && (h = Math.min(h, e.errors[0].offset));
785
+ const e = this._parser.getLexer().tokenize(r, !1);
786
+ h = e.tokens, e.errors.length > 0 && (l = Math.min(l, e.errors[0].offset));
781
787
  } catch {
782
788
  return null;
783
789
  }
784
- const l = [];
785
- for (let e = a.length - 1; e >= 0 && l.length < 24; e--) {
786
- const t = (a[e].endOffset ?? -1) + 1;
787
- t > 0 && t < i.length && t <= h && l.push(t);
790
+ const u = [];
791
+ for (let e = h.length - 1; e >= 0 && u.length < 24; e--) {
792
+ const t = (h[e].endOffset ?? -1) + 1;
793
+ t > 0 && t < r.length && t <= l && u.push(t);
788
794
  }
789
- for (const a of l) {
790
- const h = i.slice(0, a);
791
- let l, u;
795
+ for (const h of u) {
796
+ const l = r.slice(0, h);
797
+ let u, c;
792
798
  try {
793
- l = this._parser.parse(t, s, h).root;
799
+ u = this._parser.parse(s, i, l).root;
794
800
  } catch {
795
801
  continue;
796
802
  }
797
- if (!l || l.type === D.Unparsed) continue;
803
+ if (!u || u.type === t.Unparsed) continue;
798
804
  try {
799
- const t = M(l, null);
800
- u = y(e, r, r ? f(t, r, o) : t, !0, n);
805
+ const t = P(u, null);
806
+ c = b(e, n, n ? d(t, n, a) : t, !0, o);
801
807
  } catch {
802
808
  continue;
803
809
  }
804
- if (v(u.getTokens(), r) !== h) continue;
805
- const c = i.slice(a);
806
- if (0 === c.length) return u;
807
- let p;
808
- const g = {
809
- ...u,
810
- getTokens: () => (p || (p = [...u.getTokens()], this._appendUnparsedTail(p, c)), p),
811
- transform: () => g
810
+ if (M(c.getTokens(), n) !== l) continue;
811
+ const p = r.slice(h);
812
+ if (0 === p.length) return c;
813
+ let g;
814
+ const O = {
815
+ ...c,
816
+ getTokens: () => (g || (g = [...c.getTokens()], this._appendUnparsedTail(g, p)), g),
817
+ transform: () => O
812
818
  };
813
- return g;
819
+ return O;
814
820
  }
815
821
  return null;
816
822
  }
817
- _appendUnparsedTail(e, t) {
818
- const s = [];
819
- for (const t of e) t.type === D.Paren && "(" === t.text ? s.push({
820
- ctx: t.context,
823
+ _appendUnparsedTail(e, s) {
824
+ const i = [];
825
+ for (const s of e) s.type === t.Paren && "(" === s.text ? i.push({
826
+ ctx: s.context,
821
827
  argIndex: 0
822
- }) : t.type === D.Paren && ")" === t.text ? s.pop() : t.type === D.Separator && s.length > 0 && s[s.length - 1].argIndex++;
823
- const i = s.length > 0 ? s[s.length - 1] : void 0, r = i?.ctx ? {
824
- ...i.ctx,
825
- argIndex: -1 === i.ctx.argIndex ? i.argIndex : i.ctx.argIndex
826
- } : void 0, n = (t, s) => {
827
- const i = {
828
- type: D.Unparsed,
829
- value: t,
830
- text: t
828
+ }) : s.type === t.Paren && ")" === s.text ? i.pop() : s.type === t.Separator && i.length > 0 && i[i.length - 1].argIndex++;
829
+ const r = i.length > 0 ? i[i.length - 1] : void 0, n = r?.ctx ? {
830
+ ...r.ctx,
831
+ argIndex: -1 === r.ctx.argIndex ? r.argIndex : r.ctx.argIndex
832
+ } : void 0, o = (s, i) => {
833
+ const r = {
834
+ type: t.Unparsed,
835
+ value: s,
836
+ text: s
831
837
  };
832
- r && (i.context = r), s && (i.isLookup = !0), e.push(i);
833
- }, o = /[A-Za-z_][A-Za-z0-9_]*$/.exec(t), a = o ? o.index : -1;
834
- a >= 0 && (0 === a || !/[A-Za-z0-9_.]/.test(t[a - 1])) ? (a > 0 && n(t.slice(0, a)), n(t.slice(a), !0)) : n(t);
838
+ n && (r.context = n), i && (r.isLookup = !0), e.push(r);
839
+ }, a = /[A-Za-z_][A-Za-z0-9_]*$/.exec(s), h = a ? a.index : -1;
840
+ h >= 0 && (0 === h || !/[A-Za-z0-9_.]/.test(s[h - 1])) ? (h > 0 && o(s.slice(0, h)), o(s.slice(h), !0)) : o(s);
835
841
  }
836
842
  };
837
- export { oe as FormulaCompiler };
843
+ export { ae as FormulaCompiler };