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

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 (32) hide show
  1. package/browser/cjs/1mH2uhx_Dmceu88H.cjs +33 -0
  2. package/browser/cjs/B4PKKgaDTG9aSO-f.cjs +1 -0
  3. package/browser/cjs/{CQf4zxkBmheTVbjX.cjs → BX6A6xGDOr_td9mw.cjs} +2 -2
  4. package/browser/cjs/{BG7YDVxiC4ErxvF1.cjs → CWCKcp58KidyndaL.cjs} +1 -1
  5. package/browser/cjs/{BREMLtxkQhtNSVra.cjs → D6cjnwWR_iUSe1f6.cjs} +1 -1
  6. package/browser/cjs/index.cjs +2 -2
  7. package/browser/esm/{CZO1RubmqnJV96rq.mjs → B1gpnr-7kLU7jTy-.mjs} +2 -2
  8. package/browser/esm/{CB_4gdPPPruwremH.mjs → C78IaCXqwCcraBPe.mjs} +5055 -4959
  9. package/browser/esm/{DRWu3TmcE9JFf78V.mjs → CPgz9_iM7xyAcytg.mjs} +2 -2
  10. package/browser/esm/{DN4d5bDBkti28wuc.mjs → CX1NO_a1QPjXDvTU.mjs} +213 -207
  11. package/browser/esm/{vHWuKF-ftK7LM1uw.mjs → DZfds6s3ayTZrozO.mjs} +1 -1
  12. package/browser/esm/{DPOelA1J3WHbMXyh.mjs → Dv8FyXyeygJPXoHo.mjs} +2 -2
  13. package/browser/esm/{BxIOX1TojvA-1ZZP.mjs → Rj8e7SashcMlcdZJ.mjs} +2 -2
  14. package/browser/esm/index.mjs +419 -414
  15. package/node/esm/{C8tfYGL3wHy9IDDc.mjs → 8VtzCFSmLPKxJjOa.mjs} +2 -2
  16. package/node/esm/{XQhP3dYwF_tEuswB.mjs → BkY99r-c3BhlT_Kv.mjs} +303 -297
  17. package/node/esm/{B-tgcZihStNV9CbZ.mjs → DE3eIaqkk5xzmV1c.mjs} +1 -1
  18. package/node/esm/index.mjs +5312 -5213
  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.d.ts +76 -7
  23. package/types/src/calculation/ICalculation.d.ts +5 -0
  24. package/types/src/calculation/compiler/CompilerUtils.d.ts +20 -0
  25. package/types/src/calculation/compiler/FormulaParser.d.ts +32 -6
  26. package/types/src/calculation/functions/Operators.d.ts +1 -1
  27. package/types/src/calculation/grid/CalcGrid.d.ts +2 -0
  28. package/types/src/calculation/grid/ICalcGrid.d.ts +11 -0
  29. package/types/src/cellRange/ICellRange.d.ts +60 -3
  30. package/types/src/sheet/SheetRange.d.ts +12 -1
  31. package/browser/cjs/DoemwsUQoGCk0vBK.cjs +0 -33
  32. package/browser/cjs/_c2uwwpr03Y7lzIj.cjs +0 -1
@@ -1,12 +1,12 @@
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.3
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 { n as e } from "./vHWuKF-ftK7LM1uw.mjs";
8
- import { $t as t, At as n, Bt as r, Cn as i, Ct as a, Dn as o, Dt as s, En as c, Et as l, Ft as u, H as d, Ht as f, It as p, J as m, Jt as h, Kt as g, Lt as _, Mt as v, Nt as y, Ot as ee, Pt as b, Qt as te, Rt as ne, Sn as x, St as re, Tn as ie, Tt as ae, Ut as S, Vt as oe, Wt as se, Xt as ce, Yt as C, Zt as le, _n as ue, _t as de, a as w, an as fe, at as pe, bn as T, bt as me, c as he, cn as ge, ct as _e, d as ve, dn as ye, dt as be, en as E, f as xe, fn as Se, ft as Ce, gn as we, gt as Te, h as Ee, hn as De, ht as Oe, i as ke, in as Ae, it as je, j as Me, jt as D, kt as Ne, l as O, ln as Pe, lt as Fe, m as Ie, mn as Le, mt as Re, n as ze, nn as Be, nt as Ve, o as k, on as He, ot as Ue, p as We, pn as Ge, pt as Ke, qt as qe, r as Je, rn as A, rt as Ye, s as Xe, sn as Ze, st as Qe, t as $e, tn as et, u as tt, un as nt, ut as rt, vn as it, vt as at, wn as j, wt as ot, xn as M, xt as st, yn as ct, yt as lt, z as ut, zt as N } from "./CB_4gdPPPruwremH.mjs";
9
- import { t as dt } from "./DRWu3TmcE9JFf78V.mjs";
7
+ import { n as e } from "./DZfds6s3ayTZrozO.mjs";
8
+ import { $t as t, At as n, B as r, Bt as i, Cn as a, Ct as o, Dn as s, Dt as c, En as l, Et as u, Ft as d, Gt as f, Ht as p, It as m, Jt as h, Lt as g, M as _, Mt as v, Nt as y, On as ee, Ot as b, Pt as te, Qt as ne, Rt as re, Sn as x, St as ie, Tn as S, Tt as ae, U as oe, Ut as C, Vt as w, Wt as T, Xt as E, Y as se, Yt as ce, Zt as le, _n as ue, _t as de, a as D, an as fe, at as pe, bn as me, bt as he, c as ge, cn as _e, ct as ve, d as ye, dn as be, dt as xe, en as O, f as Se, fn as Ce, ft as we, gn as Te, gt as Ee, h as De, hn as Oe, ht as ke, i as Ae, in as k, it as je, jt as Me, kt as Ne, l as A, ln as Pe, lt as Fe, m as Ie, mn as Le, mt as Re, n as ze, nn as Be, o as j, on as Ve, ot as He, p as Ue, pn as We, pt as Ge, qt as Ke, r as qe, rn as Je, rt as Ye, s as Xe, sn as Ze, st as Qe, t as $e, tn as M, u as et, un as tt, ut as nt, vn as rt, vt as it, wn as at, wt as ot, xn as N, xt as st, yn as ct, yt as lt, zt as ut } from "./C78IaCXqwCcraBPe.mjs";
9
+ import { t as dt } from "./CPgz9_iM7xyAcytg.mjs";
10
10
  import { FormulaError as P, ScalarType as F } from "@sheetxl/primitives";
11
11
  import { BufferUtils as ft, CommonUtils as I, CoordUtils as L, DOMUtils as pt, DefaultLanguagePackService as mt, ExpectedError as R, InvalidPasswordError as ht, MimeType as gt, Notifier as z, NullNotAllowedError as _t, OutOfBoundsError as B, PasswordRequiredError as vt, UndoManager as yt, messageKey as V, t as H } from "@sheetxl/utils";
12
12
  export * from "@sheetxl/primitives";
@@ -108,7 +108,7 @@ var xt = class extends yt {
108
108
  }
109
109
  }, St = class {
110
110
  constructor(e, t) {
111
- this._dirty = !1, this._store = e, this._savedCommitId = e.getCurrentCommit()?.getId() ?? null, this._emitter = new j(this);
111
+ this._dirty = !1, this._store = e, this._savedCommitId = e.getCurrentCommit()?.getId() ?? null, this._emitter = new S(this);
112
112
  let n = this;
113
113
  this._removeStoreListener = e.addListener({
114
114
  onCommitEnd() {
@@ -145,7 +145,7 @@ var xt = class extends yt {
145
145
  }
146
146
  }, U = class e {
147
147
  constructor(t, n = {}) {
148
- this._password = null, this._emitter = new j(this), this._path = t ?? null, this._name = n.name ?? null, this._format = n.format ?? null, this._size = n.size ?? null, this._canWrite = n.canWrite ?? e._defaultCanWrite(this._path), this._encryption = n.encryption ?? null;
148
+ this._password = null, this._emitter = new S(this), this._path = t ?? null, this._name = n.name ?? null, this._format = n.format ?? null, this._size = n.size ?? null, this._canWrite = n.canWrite ?? e._defaultCanWrite(this._path), this._encryption = n.encryption ?? null;
149
149
  }
150
150
  static _defaultCanWrite(e) {
151
151
  return !!e && !/^(https?:|data:|blob:)/i.test(e);
@@ -156,7 +156,7 @@ var xt = class extends yt {
156
156
  getName() {
157
157
  if (this._name !== null && this._name !== void 0) return this._name;
158
158
  let e = this._cleanPath();
159
- return e && T(e) || null;
159
+ return e && N(e) || null;
160
160
  }
161
161
  getPath() {
162
162
  return this._path;
@@ -167,7 +167,7 @@ var xt = class extends yt {
167
167
  getExtension() {
168
168
  let e = this._cleanPath();
169
169
  if (!e) return null;
170
- let t = M(e);
170
+ let t = x(e);
171
171
  return t ? t.toLowerCase() : null;
172
172
  }
173
173
  getEncryption() {
@@ -230,10 +230,10 @@ var xt = class extends yt {
230
230
  }
231
231
  switch (i) {
232
232
  case "file": {
233
- let e = n, t = e?.name, i = t ? `${T(t)}` : "";
233
+ let e = n, t = e?.name, i = t ? `${N(t)}` : "";
234
234
  a = await e.arrayBuffer(), o = {
235
235
  format: r,
236
- ext: M(t),
236
+ ext: x(t),
237
237
  name: i,
238
238
  absolutePath: t,
239
239
  size: e.size,
@@ -272,7 +272,7 @@ var xt = class extends yt {
272
272
  e = r.input, t = r.init, i = r.timeout;
273
273
  }
274
274
  }
275
- let s = i || 3e4, c = new AbortController(), l = setTimeout(() => c.abort(), s), u = typeof e == "string" ? e : e.toString(), d = M(u);
275
+ let s = i || 3e4, c = new AbortController(), l = setTimeout(() => c.abort(), s), u = typeof e == "string" ? e : e.toString(), d = x(u);
276
276
  try {
277
277
  let n = await fetch(e, {
278
278
  ...t,
@@ -284,7 +284,7 @@ var xt = class extends yt {
284
284
  a = i, o = {
285
285
  format: r,
286
286
  ext: d,
287
- name: T(u, !0),
287
+ name: N(u, !0),
288
288
  absolutePath: u
289
289
  };
290
290
  } catch (e) {
@@ -498,7 +498,7 @@ var Ot = class {
498
498
  "Trebuchet MS",
499
499
  "Verdana"
500
500
  ], W = /* @__PURE__ */ new Map();
501
- W.set(A.GenericName.Serif, ["Tahoma"]), W.set(A.GenericName.SanSerif, ["Calibri"]), W.set(A.GenericName.MonoSpace, ["Courier New"]), W.set(A.GenericName.Cursive, ["Comic Sans MS"]), W.set(A.GenericName.Fantasy, ["Luminari"]), W.set(A.GenericName.UISystem, ["Arial"]), W.set(A.GenericName.UISerif, ["Tahoma"]), W.set(A.GenericName.UISanSerif, ["Arial"]), W.set(A.GenericName.UIMonoSpace, ["Courier New"]), W.set(A.GenericName.UIRounded, ["Arial"]), W.set(A.GenericName.Math, []), W.set(A.GenericName.Emoji, []), W.set(A.GenericName.Fangsong, []);
501
+ W.set(k.GenericName.Serif, ["Tahoma"]), W.set(k.GenericName.SanSerif, ["Calibri"]), W.set(k.GenericName.MonoSpace, ["Courier New"]), W.set(k.GenericName.Cursive, ["Comic Sans MS"]), W.set(k.GenericName.Fantasy, ["Luminari"]), W.set(k.GenericName.UISystem, ["Arial"]), W.set(k.GenericName.UISerif, ["Tahoma"]), W.set(k.GenericName.UISanSerif, ["Arial"]), W.set(k.GenericName.UIMonoSpace, ["Courier New"]), W.set(k.GenericName.UIRounded, ["Arial"]), W.set(k.GenericName.Math, []), W.set(k.GenericName.Emoji, []), W.set(k.GenericName.Fangsong, []);
502
502
  var G = /* @__PURE__ */ new Map(), jt = [];
503
503
  K(At);
504
504
  var Mt = eval;
@@ -619,7 +619,7 @@ function Bt(e, t = !0, n = zt) {
619
619
  SoftEdge: "softEdge",
620
620
  Reflection: "reflection"
621
621
  };
622
- var Y = ne.BuiltInName, Vt = {
622
+ var Y = ut.BuiltInName, Vt = {
623
623
  [Y.Normal]: V("style.builtin.normal"),
624
624
  [Y.Comma]: V("style.builtin.comma"),
625
625
  [Y.Currency]: V("style.builtin.currency"),
@@ -660,52 +660,52 @@ function Jt(e) {
660
660
  }
661
661
  } : null));
662
662
  }
663
- var Yt, Xt, Zt, Qt, $t = (e, t, n, i, a) => {
664
- let o = JSON.parse(JSON.stringify(e.definition));
665
- o.adjs ||= [];
666
- let s = "", c = 0, l = 0;
667
- t > 0 ? (l = t, c = 100 - t, s = H("op.lighterPercent", { percent: t })) : t < 0 && (c = 100 + t, s = H("op.darkerPercent", { percent: -t })), c && o.adjs.push({ [f.AdjustmentType.LumMod]: c }), l && o.adjs.push({ [f.AdjustmentType.LumOff]: l });
668
- let u = new r({
669
- val: o.val,
670
- adjs: o.adjs
671
- }, n), d = u.toString();
672
- i?.set(d, u);
673
- let p = u.toRGBA().toString();
674
- return a?.set(p, u), {
675
- description: e.description + ", " + s,
676
- definition: o
663
+ var Yt, Xt, Zt, Qt, $t = (e, t, n, r, i) => {
664
+ let a = JSON.parse(JSON.stringify(e.definition));
665
+ a.adjs ||= [];
666
+ let o = "", s = 0, c = 0;
667
+ t > 0 ? (c = t, s = 100 - t, o = H("op.lighterPercent", { percent: t })) : t < 0 && (s = 100 + t, o = H("op.darkerPercent", { percent: -t })), s && a.adjs.push({ [C.AdjustmentType.LumMod]: s }), c && a.adjs.push({ [C.AdjustmentType.LumOff]: c });
668
+ let l = new w({
669
+ val: a.val,
670
+ adjs: a.adjs
671
+ }, n), u = l.toString();
672
+ r?.set(u, l);
673
+ let d = l.toRGBA().toString();
674
+ return i?.set(d, l), {
675
+ description: e.description + ", " + o,
676
+ definition: a
677
677
  };
678
678
  };
679
- function en(e, t, n, i) {
680
- let a = [];
681
- for (let o = 0; o < e.length; o++) {
682
- let s = [];
683
- a.push(s);
684
- let c = (r) => {
685
- for (let a = 0; a < r.length; a++) s.push($t(e[o], r[a], t, n, i));
686
- }, l = new r({
687
- val: e[o].definition.val,
688
- adjs: e[o].definition.adjs
679
+ function en(e, t, n, r) {
680
+ let i = [];
681
+ for (let a = 0; a < e.length; a++) {
682
+ let o = [];
683
+ i.push(o);
684
+ let s = (i) => {
685
+ for (let s = 0; s < i.length; s++) o.push($t(e[a], i[s], t, n, r));
686
+ }, c = new w({
687
+ val: e[a].definition.val,
688
+ adjs: e[a].definition.adjs
689
689
  }, t).toHSLA().lum;
690
- c(l === 0 ? [
690
+ s(c === 0 ? [
691
691
  50,
692
692
  35,
693
693
  25,
694
694
  15,
695
695
  5
696
- ] : l === 100 ? [
696
+ ] : c === 100 ? [
697
697
  -5,
698
698
  -15,
699
699
  -25,
700
700
  -35,
701
701
  -50
702
- ] : l <= 20 ? [
702
+ ] : c <= 20 ? [
703
703
  90,
704
704
  75,
705
705
  50,
706
706
  25,
707
707
  10
708
- ] : l >= 80 ? [
708
+ ] : c >= 80 ? [
709
709
  -10,
710
710
  -25,
711
711
  -50,
@@ -719,13 +719,13 @@ function en(e, t, n, i) {
719
719
  -50
720
720
  ]);
721
721
  }
722
- return a;
722
+ return i;
723
723
  }
724
724
  (Yt ||= {}).buildPalette = en, Xt ||= {}, Zt ||= {}, Qt ||= {};
725
725
  var X = null;
726
726
  function tn() {
727
727
  if (!X) {
728
- let e = import("./DPOelA1J3WHbMXyh.mjs").then(({ initializeFunctions: e }) => {
728
+ let e = import("./Dv8FyXyeygJPXoHo.mjs").then(({ initializeFunctions: e }) => {
729
729
  let t = e(() => null);
730
730
  return Object.freeze(Array.from(t.keys()));
731
731
  });
@@ -746,25 +746,25 @@ function nn(e) {
746
746
  } catch {
747
747
  return;
748
748
  }
749
- let r = 0, i = 0;
749
+ let i = 0, a = 0;
750
750
  if (n.length === 2) {
751
751
  let e = n[0].tokenType?.name;
752
- e === "MinOp" ? (r = -1, i = 1) : e === "PlusOp" && (r = 1, i = 1);
752
+ e === "MinOp" ? (i = -1, a = 1) : e === "PlusOp" && (i = 1, a = 1);
753
753
  }
754
- if (n.length - i !== 1) return;
755
- let a = n[i], o = a.image;
754
+ if (n.length - a !== 1) return;
755
+ let o = n[a], s = o.image;
756
756
  try {
757
- switch (a.tokenType?.name) {
757
+ switch (o.tokenType?.name) {
758
758
  case "NumberToken":
759
759
  case "ScientificDigit":
760
760
  case "DigitToken": {
761
- let e = d(o).value;
762
- return r === 0 ? e : r * e;
761
+ let e = oe(s).value;
762
+ return i === 0 ? e : i * e;
763
763
  }
764
- case "StringToken": return r === 0 ? m(o).value : void 0;
765
- case "BooleanToken": return r === 0 ? Me(o).value : void 0;
764
+ case "StringToken": return i === 0 ? se(s).value : void 0;
765
+ case "BooleanToken": return i === 0 ? _(s).value : void 0;
766
766
  case "LiteralError":
767
- case "RefError": return r === 0 ? ut(o).value : void 0;
767
+ case "RefError": return i === 0 ? r(s).value : void 0;
768
768
  default: return;
769
769
  }
770
770
  } catch {
@@ -836,7 +836,7 @@ var on = class {
836
836
  return t || (t = this._mergeFrequencies(), this._frequencies = t), t;
837
837
  }
838
838
  _mergeFrequencies(e) {
839
- let t = e?.keyFn ?? Oe, n = e?.limit, r = /* @__PURE__ */ new Map(), i = this._children, a = i.length, o = 0, s = 0, c = !1;
839
+ let t = e?.keyFn ?? Ee, n = e?.limit, r = /* @__PURE__ */ new Map(), i = this._children, a = i.length, o = 0, s = 0, c = !1;
840
840
  for (let l = 0; l < a; l++) {
841
841
  let a = i[l].getFrequencies(e);
842
842
  o += a.getVisitedCount(), s += a.getTotalCount(), c ||= a.isTruncated();
@@ -849,7 +849,7 @@ var on = class {
849
849
  }) : c = !0, d = u.next();
850
850
  }
851
851
  }
852
- return Re.fromGroups(r, t, e, rn, o, s, c);
852
+ return ke.fromGroups(r, t, e, rn, o, s, c);
853
853
  }
854
854
  getTypedCounts(e) {
855
855
  let t = this._typedCounts;
@@ -899,7 +899,7 @@ var on = class {
899
899
  let a = n.numericalCount;
900
900
  a <= 0 || (r.numericalCount += a, r.sum += n.sum, r.sumSq += n.varP * a + n.sum * n.sum / a, (r.min === void 0 || n.min < r.min) && (r.min = n.min), (r.max === void 0 || n.max > r.max) && (r.max = n.max));
901
901
  }
902
- return Je(r);
902
+ return qe(r);
903
903
  }
904
904
  }, sn = Object.freeze([]);
905
905
  function cn(e, t) {
@@ -956,9 +956,9 @@ var ln = class {
956
956
  constructor(e) {
957
957
  this._closed = !1, this._options = { ...e };
958
958
  let t = this;
959
- this._transactions = this._options.transactions ?? new c({ transient: !0 }), this._stateId = this._transactions.create(), this._transactionsRemoveListener = this._transactions.addStateListener(this._stateId, { onAfterStateChange(e, n, r) {
959
+ this._transactions = this._options.transactions ?? new s({ transient: !0 }), this._stateId = this._transactions.create(), this._transactionsRemoveListener = this._transactions.addStateListener(this._stateId, { onAfterStateChange(e, n, r) {
960
960
  t._emitter.notify("onCollectionChange");
961
- } }), this._emitter = new j(this, this._transactions), this._initState(e?.initial);
961
+ } }), this._emitter = new S(this, this._transactions), this._initState(e?.initial);
962
962
  }
963
963
  add(e, t, n) {
964
964
  let r = this;
@@ -1075,7 +1075,7 @@ var ln = class {
1075
1075
  return `Script has ${i} compile error${i === 1 ? "" : "s"}:\n${r.join("\n")}`;
1076
1076
  }, pn = class {
1077
1077
  constructor(e) {
1078
- this._options = e, this._emitter = new j(this), this._initState();
1078
+ this._options = e, this._emitter = new S(this), this._initState();
1079
1079
  }
1080
1080
  _initState() {}
1081
1081
  getModules() {
@@ -1097,13 +1097,13 @@ var ln = class {
1097
1097
  builtInNames: this._builtInNames(),
1098
1098
  ...e
1099
1099
  });
1100
- return t.module ? await S("scripts", t.module, e?.declarationsOnly ?? !1, t.diagnostics) : null;
1100
+ return t.module ? await T("scripts", t.module, e?.declarationsOnly ?? !1, t.diagnostics) : null;
1101
1101
  }
1102
1102
  addModule(e, t, n) {
1103
1103
  this._modules.add(e, t, n);
1104
1104
  }
1105
1105
  async addModuleFromJSON(e, t, n) {
1106
- let r = await S(e, t);
1106
+ let r = await T(e, t);
1107
1107
  return this.addModule(e, r, n), r;
1108
1108
  }
1109
1109
  executeMacro(e, t, n) {
@@ -1119,7 +1119,7 @@ var ln = class {
1119
1119
  }
1120
1120
  async run(e, t) {
1121
1121
  try {
1122
- let n = typeof e == "string" ? await this.createModule({ source: e }) : await S("scripts", e), r = typeof e == "string" ? e : e?.source ?? "";
1122
+ let n = typeof e == "string" ? await this.createModule({ source: e }) : await T("scripts", e), r = typeof e == "string" ? e : e?.source ?? "";
1123
1123
  return await this._runModule(n, r, t);
1124
1124
  } catch (e) {
1125
1125
  return {
@@ -1189,7 +1189,7 @@ var ln = class {
1189
1189
  }
1190
1190
  if (!i || i.length === 0) return I.EmptyArray;
1191
1191
  let o = e?.text ? e.text.trim().toUpperCase() : null;
1192
- return o && t.length > 1 && se(i, o), n !== void 0 && i.length > n ? i.slice(0, n) : i;
1192
+ return o && t.length > 1 && f(i, o), n !== void 0 && i.length > n ? i.slice(0, n) : i;
1193
1193
  }
1194
1194
  async getFunctionCategories(e) {
1195
1195
  await this._emitter.notify("onBeforeSearch", { async: !0 });
@@ -1232,7 +1232,7 @@ var ln = class {
1232
1232
  for (let r = 0; r < e.length; r++) {
1233
1233
  let i = e[r], a = t[i];
1234
1234
  try {
1235
- n[i] = await S(i, a);
1235
+ n[i] = await T(i, a);
1236
1236
  } catch (e) {
1237
1237
  z.error(`Could not load script '${i}'; it will be unavailable.`, e);
1238
1238
  }
@@ -1276,7 +1276,7 @@ var ln = class {
1276
1276
  }
1277
1277
  }, mn = class {
1278
1278
  constructor(e, t, n, r) {
1279
- this._mergedReading = [], this._colsReading = [], this._rowsReading = [], this._styles = n, this._topLeft = t ?? L.EmptyCell, this._sheet = new O({
1279
+ this._mergedReading = [], this._colsReading = [], this._rowsReading = [], this._styles = n, this._topLeft = t ?? L.EmptyCell, this._sheet = new A({
1280
1280
  runtime: e,
1281
1281
  styles: this._styles,
1282
1282
  container: {
@@ -1288,36 +1288,36 @@ var ln = class {
1288
1288
  applyCSSStyle(e, t) {
1289
1289
  let r = !1;
1290
1290
  e.style || (e.style = {}, r = !0);
1291
- let i = e.style, a = { ...t };
1291
+ let o = e.style, s = { ...t };
1292
1292
  if (t.msoIgnore) {
1293
- let e = t.msoIgnore.split(","), n = Object.keys(a);
1293
+ let e = t.msoIgnore.split(","), n = Object.keys(s);
1294
1294
  for (let t = 0; t < n.length; t++) {
1295
1295
  let r = n[t];
1296
- e.includes(r) && delete a[r];
1296
+ e.includes(r) && delete s[r];
1297
1297
  }
1298
1298
  }
1299
- let o = n(a.fontFamily);
1300
- i.font = {}, o && (i.font.family = o.family, i.font.fallbacks = o.fallbacks, i.font.size = o.size), i.font.size = a.fontSize, i.font.weight = a.fontWeight, i.font.style = a.fontStyle, i.font.color = a.color;
1301
- let c = s(a.textDecoration);
1302
- i.font.underline = c.underline, i.font.strike = c.strike, a.textUnderlineStyle && (i.font.underline = ee(a.textUnderlineStyle)), i.alignment = {}, a?.textAlign && (i.alignment.horizontal = l(a.textAlign)), a?.textAlign && !i.alignment.horizontal && a?.textAlign !== "general" && (a.textAlign === "center-across" ? i.alignment.horizontal = x.HorizontalAlignment.CenterContinuous : a.textAlign === "fill" ? i.alignment.horizontal = x.HorizontalAlignment.Fill : a.textAlign === "121" || a.textAlign === "010" ? (i.alignment.horizontal = x.HorizontalAlignment.Distributed, i.alignment.justifyLastLine = a.textAlign === "121") : console.warn("unknown text-align", a.textAlign)), a.verticalAlign && (a.verticalAlign.toLowerCase() === "super" ? i.font.verticalAlign = A.VerticalAlignment.Super : a.verticalAlign.toLowerCase() === "sup" ? i.font.verticalAlign = A.VerticalAlignment.Sub : i.alignment.vertical = Ne(a.verticalAlign), i.alignment.vertical || (a.verticalAlign === "121" ? i.alignment.vertical = x.VerticalAlignment.Distributed : console.warn("unknown vertical-align", a.verticalAlign))), a.msoCharIndentCount && (i.alignment.indent = a.msoCharIndentCount), a.whiteSpace && (i.alignment.overflow = a.whiteSpace === "no-wrap" || a.whiteSpace === "nowrap" ? x.Overflow.Visible : x.Overflow.Wrap), a.msoTextControl === "shrinktofit" && (i.alignment.overflow = x.Overflow.Shrink);
1303
- let u = null;
1304
- if (a.background ? u = a.background : a.backgroundColor && (u = a.backgroundColor), u && (i.fill = { color: u }), a.msoPattern) {
1305
- let e = v(a.msoPattern);
1306
- e && (e.patternType === N.BuiltInSheetPattern.Solid ? i.fill = { color: e.foreground } : e.patternType !== N.BuiltInSheetPattern.None && (u && (e.background = u), i.fill = e));
1307
- }
1308
- a.msoRotate !== void 0 && (i.alignment.rotation = ae(a.msoRotate));
1309
- let d = (e, t) => {
1310
- e && (i.border ||= {}, i.border[e] = t);
1299
+ let l = Me(s.fontFamily);
1300
+ o.font = {}, l && (o.font.family = l.family, o.font.fallbacks = l.fallbacks, o.font.size = l.size), o.font.size = s.fontSize, o.font.weight = s.fontWeight, o.font.style = s.fontStyle, o.font.color = s.color;
1301
+ let d = b(s.textDecoration);
1302
+ o.font.underline = d.underline, o.font.strike = d.strike, s.textUnderlineStyle && (o.font.underline = Ne(s.textUnderlineStyle)), o.alignment = {}, s?.textAlign && (o.alignment.horizontal = c(s.textAlign)), s?.textAlign && !o.alignment.horizontal && s?.textAlign !== "general" && (s.textAlign === "center-across" ? o.alignment.horizontal = a.HorizontalAlignment.CenterContinuous : s.textAlign === "fill" ? o.alignment.horizontal = a.HorizontalAlignment.Fill : s.textAlign === "121" || s.textAlign === "010" ? (o.alignment.horizontal = a.HorizontalAlignment.Distributed, o.alignment.justifyLastLine = s.textAlign === "121") : console.warn("unknown text-align", s.textAlign)), s.verticalAlign && (s.verticalAlign.toLowerCase() === "super" ? o.font.verticalAlign = k.VerticalAlignment.Super : s.verticalAlign.toLowerCase() === "sup" ? o.font.verticalAlign = k.VerticalAlignment.Sub : o.alignment.vertical = n(s.verticalAlign), o.alignment.vertical || (s.verticalAlign === "121" ? o.alignment.vertical = a.VerticalAlignment.Distributed : console.warn("unknown vertical-align", s.verticalAlign))), s.msoCharIndentCount && (o.alignment.indent = s.msoCharIndentCount), s.whiteSpace && (o.alignment.overflow = s.whiteSpace === "no-wrap" || s.whiteSpace === "nowrap" ? a.Overflow.Visible : a.Overflow.Wrap), s.msoTextControl === "shrinktofit" && (o.alignment.overflow = a.Overflow.Shrink);
1303
+ let f = null;
1304
+ if (s.background ? f = s.background : s.backgroundColor && (f = s.backgroundColor), f && (o.fill = { color: f }), s.msoPattern) {
1305
+ let e = y(s.msoPattern);
1306
+ e && (e.patternType === i.BuiltInSheetPattern.Solid ? o.fill = { color: e.foreground } : e.patternType !== i.BuiltInSheetPattern.None && (f && (e.background = f), o.fill = e));
1307
+ }
1308
+ s.msoRotate !== void 0 && (o.alignment.rotation = u(s.msoRotate));
1309
+ let p = (e, t) => {
1310
+ e && (o.border ||= {}, o.border[e] = t);
1311
1311
  };
1312
- a.border && a.border !== "none" && (d("top", a.border), d("left", a.border), d("right", a.border), d("bottom", a.border)), a.borderTop && d("top", a.borderTop), a.borderLeft && d("left", a.borderLeft), a.borderRight && d("right", a.borderRight), a.borderBottom && d("bottom", a.borderBottom), a.msoDiagonalUp && d("diagonalUp", a.msoDiagonalUp), a.msoDiagonalDown && d("diagonalDown", a.msoDiagonalDown);
1313
- let f = i.numberFormat;
1314
- a.msoNumberFormat && (f = y(a.msoNumberFormat), f.includes("\\") ? f = null : f === "Fixed" ? f = E.Styles.lookupStyle(i.numberFormat).formatType === E.Type.Number ? null : E.Type.Number : f === "Percent" && (f = E.Styles.lookupStyle(i.numberFormat).formatType === E.Type.Percentage ? null : E.Type.Percentage)), f && (i.numberFormat = f), e.style = this._styles.normalize(i), r && Object.keys(e.style).length === 0 && delete e.style;
1312
+ s.border && s.border !== "none" && (p("top", s.border), p("left", s.border), p("right", s.border), p("bottom", s.border)), s.borderTop && p("top", s.borderTop), s.borderLeft && p("left", s.borderLeft), s.borderRight && p("right", s.borderRight), s.borderBottom && p("bottom", s.borderBottom), s.msoDiagonalUp && p("diagonalUp", s.msoDiagonalUp), s.msoDiagonalDown && p("diagonalDown", s.msoDiagonalDown);
1313
+ let m = o.numberFormat;
1314
+ s.msoNumberFormat && (m = te(s.msoNumberFormat), m.includes("\\") ? m = null : m === "Fixed" ? m = M.Styles.lookupStyle(o.numberFormat).formatType === M.Type.Number ? null : M.Type.Number : m === "Percent" && (m = M.Styles.lookupStyle(o.numberFormat).formatType === M.Type.Percentage ? null : M.Type.Percentage)), m && (o.numberFormat = m), e.style = this._styles.normalize(o), r && Object.keys(e.style).length === 0 && delete e.style;
1315
1315
  }
1316
1316
  onCell(e, t, n, r, i) {
1317
1317
  let a = r(i), o = { value: t === void 0 ? n ?? "" : t };
1318
1318
  if (typeof o.value == "string" && o.value.length === 0 && (o.value = void 0), a && this.applyCSSStyle(o, a), i?.tagName.toUpperCase() === "TD") {
1319
1319
  let e = o.style, t = e?.font ?? {};
1320
- (i.querySelectorAll("s").length > 0 || i.querySelectorAll("strike").length > 0) && (t.strike = !0), i.querySelectorAll("sub").length > 0 && (t.verticalAlign = A.VerticalAlignment.Sub), i.querySelectorAll("sup").length > 0 && (t.verticalAlign = A.VerticalAlignment.Super), (i.querySelectorAll("b").length > 0 || i.querySelectorAll("strong").length > 0) && (t.weight = 700), i.querySelectorAll("i").length > 0 && (t.style = A.Style.Italic), i.querySelectorAll("u").length > 0 && (t.underline = A.UnderlineStyle.Single), Object.keys(t).length > 0 && (e || (e = {}, o.style = e), e.font ||= t);
1320
+ (i.querySelectorAll("s").length > 0 || i.querySelectorAll("strike").length > 0) && (t.strike = !0), i.querySelectorAll("sub").length > 0 && (t.verticalAlign = k.VerticalAlignment.Sub), i.querySelectorAll("sup").length > 0 && (t.verticalAlign = k.VerticalAlignment.Super), (i.querySelectorAll("b").length > 0 || i.querySelectorAll("strong").length > 0) && (t.weight = 700), i.querySelectorAll("i").length > 0 && (t.style = k.Style.Italic), i.querySelectorAll("u").length > 0 && (t.underline = k.UnderlineStyle.Single), Object.keys(t).length > 0 && (e || (e = {}, o.style = e), e.font ||= t);
1321
1321
  let n = i.querySelectorAll("a");
1322
1322
  if (n.length > 0) {
1323
1323
  let e = n[0].getAttribute("href");
@@ -1364,8 +1364,8 @@ var ln = class {
1364
1364
  let i = n(r);
1365
1365
  if (i.msoHeightSource !== "userset" || !r) return;
1366
1366
  let a = r.getAttribute("height") ?? i.height, o = null;
1367
- if (a && (o = D(a, this._styles.getNormal().getFont().getSize(), "px")), o === null) for (let e = 0; e < r.cells.length; e++) {
1368
- let t = r.cells[e], i = D(t.getAttribute("height") ?? n(t).height, this._styles.getNormal().getFont().getSize(), "px");
1367
+ if (a && (o = v(a, this._styles.getNormal().getFont().getSize(), "px")), o === null) for (let e = 0; e < r.cells.length; e++) {
1368
+ let t = r.cells[e], i = v(t.getAttribute("height") ?? n(t).height, this._styles.getNormal().getFont().getSize(), "px");
1369
1369
  i !== null && (o = Math.max(i, o ?? 0));
1370
1370
  }
1371
1371
  o !== null && this._rowsReading.push({
@@ -1373,19 +1373,19 @@ var ln = class {
1373
1373
  min: this._topLeft.rowIndex + e,
1374
1374
  max: this._topLeft.rowIndex + e + t - 1
1375
1375
  },
1376
- update: { size: o * A.getDeviceScale() }
1376
+ update: { size: o * k.getDeviceScale() }
1377
1377
  });
1378
1378
  }
1379
1379
  onColumn(e, t, n, r) {
1380
1380
  let i = n(r);
1381
1381
  if (i.msoWidthSource !== "userset" || !r) return;
1382
1382
  let a = r.getAttribute("width") ?? i.width, o = null;
1383
- a && (o = D(a, this._styles.getNormal().getFont().getSize(), "px")), o !== null && this._colsReading.push({
1383
+ a && (o = v(a, this._styles.getNormal().getFont().getSize(), "px")), o !== null && this._colsReading.push({
1384
1384
  address: {
1385
1385
  min: this._topLeft.colIndex + e,
1386
1386
  max: this._topLeft.colIndex + e + t - 1
1387
1387
  },
1388
- update: { size: o * A.getDeviceScale() }
1388
+ update: { size: o * k.getDeviceScale() }
1389
1389
  });
1390
1390
  }
1391
1391
  onDone() {
@@ -1482,7 +1482,7 @@ var ln = class {
1482
1482
  let r = new mn(this._runtime, this._topLeft, this._styles, n ? "HTML" : "Text");
1483
1483
  await r.sheet().getCalculation().ready(), await r.sheet().getCalculation().stop();
1484
1484
  let i = await Promise.resolve(t ? Ie(t) : [[]]), a;
1485
- if (We(n, i, r) ? (e = r.sheet(), a = e.getUsedRange()) : n = null, a) return this._parsed = {
1485
+ if (Ue(n, i, r) ? (e = r.sheet(), a = e.getUsedRange()) : n = null, a) return this._parsed = {
1486
1486
  copyTo: async (e, t) => (await e.copyFrom(a, t))?.getCoords() ?? null,
1487
1487
  getCoords: () => a.getCoords(),
1488
1488
  getSource: () => e,
@@ -1519,7 +1519,7 @@ var ln = class {
1519
1519
  activeSheetId: 0
1520
1520
  }, Q = class {
1521
1521
  constructor(e) {
1522
- this._emitter = new j(this), this._state = { ...Z }, e?.json && this._fromJSON(e?.json);
1522
+ this._emitter = new S(this), this._state = { ...Z }, e?.json && this._fromJSON(e?.json);
1523
1523
  }
1524
1524
  isShowFormulaBar() {
1525
1525
  return this._state.showFormulaBar;
@@ -1599,7 +1599,7 @@ var ln = class {
1599
1599
  revision: !1,
1600
1600
  password: null,
1601
1601
  revisionsPassword: null
1602
- }), vn = class extends a {
1602
+ }), vn = class extends ot {
1603
1603
  isWindowsAllowed() {
1604
1604
  return this._isPropertyAllowed("windows");
1605
1605
  }
@@ -1662,7 +1662,7 @@ function wn(e, t) {
1662
1662
  return {
1663
1663
  ...Xe,
1664
1664
  getSheet: () => null,
1665
- toString: () => C(e, t)
1665
+ toString: () => E(e, t)
1666
1666
  };
1667
1667
  }
1668
1668
  function Tn(e, t = !1) {
@@ -1685,7 +1685,7 @@ function Tn(e, t = !1) {
1685
1685
  }
1686
1686
  return e;
1687
1687
  }
1688
- var En, Dn, $ = class e extends he {
1688
+ var En, Dn, $ = class e extends ge {
1689
1689
  constructor(e, t, n, r) {
1690
1690
  super(e, t, r), this._workbook = n;
1691
1691
  }
@@ -1696,23 +1696,23 @@ var En, Dn, $ = class e extends he {
1696
1696
  let r = this._options;
1697
1697
  return n && (r = {
1698
1698
  ...this._options,
1699
- getOptions: k(this._options?.getOptions, n)
1699
+ getOptions: j(this._options?.getOptions, n)
1700
1700
  }), new e(t, this._internal, this._workbook, r);
1701
1701
  }
1702
- _createRange(e, n) {
1703
- let r = e ? { ...e } : null, i = r ? this._workbook._getSheetRef(r.scope, t.Visibility.VeryHidden) : null;
1704
- if (!i) {
1702
+ _createRange(e, t) {
1703
+ let n = e ? { ...e } : null, r = n ? this._workbook._getSheetRef(n.scope, O.Visibility.VeryHidden) : null;
1704
+ if (!r) {
1705
1705
  let e = this._workbook.getSelectedSheet();
1706
- return delete r?.scope, wn(r, r ? {
1707
- scope: qe,
1706
+ return delete n?.scope, wn(n, n ? {
1707
+ scope: h,
1708
1708
  ...e.getEntireRange().getCoords()
1709
1709
  } : null);
1710
1710
  }
1711
- let a = this._options;
1712
- return n && (a = {
1711
+ let i = this._options;
1712
+ return t && (i = {
1713
1713
  ...this._options,
1714
- getOptions: k(this._options.getOptions, n)
1715
- }), new On(e, w(i.sheet), this._workbook, a);
1714
+ getOptions: j(this._options.getOptions, t)
1715
+ }), new On(e, D(r.sheet), this._workbook, i);
1716
1716
  }
1717
1717
  async select(e) {
1718
1718
  let t = [], n = null, r = this.getCoords();
@@ -1736,15 +1736,15 @@ var En, Dn, $ = class e extends he {
1736
1736
  }
1737
1737
  getAddress(e) {
1738
1738
  let t = this._internal.getSheet(), n = t.getEntireRange().getCoords();
1739
- return h(this.getCoords(), {
1739
+ return ce(this.getCoords(), {
1740
1740
  ...n,
1741
1741
  scope: t.getName()
1742
- }, C, le, e);
1742
+ }, E, ne, e);
1743
1743
  }
1744
1744
  toString() {
1745
1745
  return this.getAddress();
1746
1746
  }
1747
- }, On = class e extends je {
1747
+ }, On = class e extends pe {
1748
1748
  constructor(e, t, n, r) {
1749
1749
  super(e, t, r), this._workbook = n;
1750
1750
  }
@@ -1752,17 +1752,17 @@ var En, Dn, $ = class e extends he {
1752
1752
  let n = this._options;
1753
1753
  return t && (n = {
1754
1754
  ...this._options,
1755
- getOptions: k(this._options?.getOptions, t)
1755
+ getOptions: j(this._options?.getOptions, t)
1756
1756
  }), new $(e, this._internal, this._workbook, n);
1757
1757
  }
1758
1758
  _createRange(t, n) {
1759
1759
  let r = this._internal;
1760
- if (!t) return ke(r.getSheet(), r.getSheet().getEntireCoords());
1761
- if (r.validateCoords(t), r.getSheet().isClosed()) return ke(null, r.getSheet().getEntireCoords(), t);
1760
+ if (!t) return Ae(r.getSheet(), r.getSheet().getEntireCoords());
1761
+ if (r.validateCoords(t), r.getSheet().isClosed()) return Ae(null, r.getSheet().getEntireCoords(), t);
1762
1762
  let i = this._options;
1763
1763
  return n && (i = {
1764
1764
  ...this._options,
1765
- getOptions: k(this._options?.getOptions, n)
1765
+ getOptions: j(this._options?.getOptions, n)
1766
1766
  }), new e(t, this._internal, this._workbook, i);
1767
1767
  }
1768
1768
  addListener(e, t) {
@@ -1775,7 +1775,7 @@ var En, Dn, $ = class e extends he {
1775
1775
  }
1776
1776
  getAddress(e) {
1777
1777
  let t = this._internal.getSheet(), n = t?.getEntireRange().getCoords() ?? null;
1778
- return C(this.getCoords(), {
1778
+ return E(this.getCoords(), {
1779
1779
  ...n,
1780
1780
  scope: t.getName()
1781
1781
  });
@@ -1786,166 +1786,166 @@ var En, Dn, $ = class e extends he {
1786
1786
  }, kn = class {
1787
1787
  constructor(e) {
1788
1788
  this._lastTransactionUUID = null, this._closed = !1, this._listenerOrigin = null, this._lastOriginName = null, this._initializing = !0, this._isDate1904 = !1, this._locale = null, this._localeOverrides = null;
1789
- let n = typeof e == "string" ? { origin: e } : { ...e }, r = n.origin;
1790
- this._origin = typeof r == "string" ? new U(null, { name: r }) : r ?? new U(null), delete n.origin, this._lastOriginName = this._origin.getName(), this._listenerOrigin = this._origin.addListeners({ onChange: () => {
1789
+ let t = typeof e == "string" ? { origin: e } : { ...e }, n = t.origin;
1790
+ this._origin = typeof n == "string" ? new U(null, { name: n }) : n ?? new U(null), delete t.origin, this._lastOriginName = this._origin.getName(), this._listenerOrigin = this._origin.addListeners({ onChange: () => {
1791
1791
  if (this._closed) return;
1792
1792
  let e = this._origin.getName();
1793
1793
  e !== this._lastOriginName && (this._lastOriginName = e, this._emitter.notify("onNameChange"));
1794
1794
  } });
1795
- let i = n.json;
1796
- delete n.json, this._transactions = n.transactions ?? new c(), this._id = this._transactions.create(), this._ownTransactions = !n.transactions, this._emitter = new j(this, this._transactions), this._runtime = n.runtime ?? new Se("Workbook Runtime", {
1795
+ let r = t.json;
1796
+ delete t.json, this._transactions = t.transactions ?? new s(), this._id = this._transactions.create(), this._ownTransactions = !t.transactions, this._emitter = new S(this, this._transactions), this._runtime = t.runtime ?? new We("Workbook Runtime", {
1797
1797
  isDate1904: () => this._isDate1904,
1798
- getLocale: () => this._locale ?? Le() ?? Ge(),
1798
+ getLocale: () => this._locale ?? Oe() ?? Le(),
1799
1799
  getLocaleOverrides: () => this._localeOverrides
1800
1800
  }), this._listenerLanguage = mt.addChangeListener(() => {
1801
1801
  this._locale !== null || this._closed || this._notifyAllChange();
1802
1802
  });
1803
- let a = this, o = this._beginCommit({ description: V(i ? "op.openWorkbook" : "op.newWorkbook") });
1803
+ let i = this, a = this._beginCommit({ description: V(r ? "op.openWorkbook" : "op.newWorkbook") });
1804
1804
  try {
1805
- this._strings = n.strings ?? new lt(), this._ownStrings = !n.strings, this._externalBooks = new un({ json: i?.externalBooks }), this._resources = n.resources ?? new me(), this._ownResources = !n.resources, this._createSheetName = n.createSheetNameCallback ?? Cn;
1806
- let e = n.createSheetCallback;
1807
- e ||= (e) => new O(e), this._sheetOnNameChange = /* @__PURE__ */ new Map(), this._sheetOnVisibilityChange = /* @__PURE__ */ new Map(), this._sheetOnIndexChange = /* @__PURE__ */ new Map(), this._createSheet = (n, r, i, o, s) => {
1808
- let c = null, l = {
1809
- runtime: a._runtime,
1810
- readonly: a._options.readonly ?? !1,
1811
- disableLoadAutoFit: a._options.disableLoadAutoFit ?? !1,
1812
- formulaTransform: a._options.formulaTransform,
1813
- opener: a._options.opener,
1814
- transactions: a._transactions,
1815
- styles: a._styles,
1816
- strings: a._strings,
1817
- resources: a._resources,
1818
- names: a._names,
1819
- workbook: a,
1820
- calculation: a._calculation,
1821
- resolveRange: (e) => a._options.resolveRange?.(e) ?? a.getRange(e),
1805
+ this._strings = t.strings ?? new he(), this._ownStrings = !t.strings, this._externalBooks = new un({ json: r?.externalBooks }), this._resources = t.resources ?? new st(), this._ownResources = !t.resources, this._createSheetName = t.createSheetNameCallback ?? Cn;
1806
+ let e = t.createSheetCallback;
1807
+ e ||= (e) => new A(e), this._sheetOnNameChange = /* @__PURE__ */ new Map(), this._sheetOnVisibilityChange = /* @__PURE__ */ new Map(), this._sheetOnIndexChange = /* @__PURE__ */ new Map(), this._createSheet = (t, n, r, a, o) => {
1808
+ let s = null, c = {
1809
+ runtime: i._runtime,
1810
+ readonly: i._options.readonly ?? !1,
1811
+ disableLoadAutoFit: i._options.disableLoadAutoFit ?? !1,
1812
+ formulaTransform: i._options.formulaTransform,
1813
+ opener: i._options.opener,
1814
+ transactions: i._transactions,
1815
+ styles: i._styles,
1816
+ strings: i._strings,
1817
+ resources: i._resources,
1818
+ names: i._names,
1819
+ workbook: i,
1820
+ calculation: i._calculation,
1821
+ resolveRange: (e) => i._options.resolveRange?.(e) ?? i.getRange(e),
1822
1822
  container: {
1823
1823
  beforeFromJSON: (e) => {
1824
- c = e, a._addSheetRef({
1825
- name: r,
1826
- id: n,
1827
- visibility: i ?? t.Visibility.Visible,
1824
+ s = e, i._addSheetRef({
1825
+ name: n,
1826
+ id: t,
1827
+ visibility: r ?? O.Visibility.Visible,
1828
1828
  sheet: e
1829
- }, o);
1829
+ }, a);
1830
1830
  },
1831
1831
  getName: () => {
1832
- let e = a._getSheetRef(c);
1833
- return e ? e.name : r;
1832
+ let e = i._getSheetRef(s);
1833
+ return e ? e.name : n;
1834
1834
  },
1835
1835
  setName: (e, t) => {
1836
- a._getSheetRef(c) && a._setSheetName(c, e, t);
1836
+ i._getSheetRef(s) && i._setSheetName(s, e, t);
1837
1837
  },
1838
1838
  setNameChangeCallback: (e) => {
1839
- a._sheetOnNameChange.set(n, e);
1839
+ i._sheetOnNameChange.set(t, e);
1840
1840
  },
1841
1841
  getVisibility: () => {
1842
- let e = a._getSheetRef(c);
1843
- return e ? e.visibility : t.Visibility.Visible;
1842
+ let e = i._getSheetRef(s);
1843
+ return e ? e.visibility : O.Visibility.Visible;
1844
1844
  },
1845
1845
  setVisibility: (e, t) => {
1846
- a._setSheetVisibility(c, e, t);
1846
+ i._setSheetVisibility(s, e, t);
1847
1847
  },
1848
1848
  setVisibilityCallback: (e) => {
1849
- a._sheetOnVisibilityChange.set(n, e);
1849
+ i._sheetOnVisibilityChange.set(t, e);
1850
1850
  },
1851
- duplicate: () => a._duplicateSheet(c),
1851
+ duplicate: () => i._duplicateSheet(s),
1852
1852
  getIndex: () => {
1853
- let e = a._getSheetRef(c);
1854
- return e ? a._getOffsetForId(e.id, a._getSheetRefs(t.Visibility.VeryHidden)) : o;
1853
+ let e = i._getSheetRef(s);
1854
+ return e ? i._getOffsetForId(e.id, i._getSheetRefs(O.Visibility.VeryHidden)) : a;
1855
1855
  },
1856
- setIndex: (e, n) => {
1857
- let r = a._getSheetRef(c, t.Visibility.VeryHidden);
1858
- return !!r && (a._moveSheet(r, e, n), !0);
1856
+ setIndex: (e, t) => {
1857
+ let n = i._getSheetRef(s, O.Visibility.VeryHidden);
1858
+ return !!n && (i._moveSheet(n, e, t), !0);
1859
1859
  },
1860
1860
  setIndexCallback: (e) => {
1861
- a._sheetOnIndexChange.set(n, e);
1861
+ i._sheetOnIndexChange.set(t, e);
1862
1862
  },
1863
- requestSelect: async () => (a._setSelectedSheet(c), await this._emitter.notify("onRequestSelect", {
1864
- source: a,
1865
- params: c,
1863
+ requestSelect: async () => (i._setSelectedSheet(s), await this._emitter.notify("onRequestSelect", {
1864
+ source: i,
1865
+ params: s,
1866
1866
  async: !0
1867
- }), a.getSelectedSheet() === c)
1867
+ }), i.getSelectedSheet() === s)
1868
1868
  }
1869
1869
  };
1870
- return s && (l.json = s), c = e(l, r, o, i), c;
1871
- }, this._namedTableSource = new de({
1872
- getSheets: () => a._sheets ? a.getSheets().getItems() : I.EmptyArray,
1873
- addSheetsListener: (e, t) => a.addListeners({ onSheetsChange: e }, t)
1874
- }), this._names = n.names ?? new be({
1875
- addressToRanges: (e) => a.getRanges(e),
1876
- getCurrentScope: () => a.getSelectedSheet().getName(),
1877
- isReadOnly: () => a._options.readonly ?? !1,
1878
- transactions: a._transactions,
1879
- getSources: () => a._calculation ? [a._calculation.getNamedFormulas(), a._namedTableSource] : I.EmptyArray
1880
- }), this._ownNames = !n.names, this._calculation = n.calculation ?? new ve({
1881
- runtime: a._runtime,
1882
- functions: n.functions,
1870
+ return o && (c.json = o), s = e(c, n, a, r), s;
1871
+ }, this._namedTableSource = new it({
1872
+ getSheets: () => i._sheets ? i.getSheets().getItems() : I.EmptyArray,
1873
+ addSheetsListener: (e, t) => i.addListeners({ onSheetsChange: e }, t)
1874
+ }), this._names = t.names ?? new we({
1875
+ addressToRanges: (e) => i.getRanges(e),
1876
+ getCurrentScope: () => i.getSelectedSheet().getName(),
1877
+ isReadOnly: () => i._options.readonly ?? !1,
1878
+ transactions: i._transactions,
1879
+ getSources: () => i._calculation ? [i._calculation.getNamedFormulas(), i._namedTableSource] : I.EmptyArray
1880
+ }), this._ownNames = !t.names, this._calculation = t.calculation ?? new ye({
1881
+ runtime: i._runtime,
1882
+ functions: t.functions,
1883
1883
  getActiveCell: () => {
1884
- let e = a.getSelectedSheet(), t = e?.getSelectedRange()?.getCoords();
1884
+ let e = i.getSelectedSheet(), t = e?.getSelectedRange()?.getCoords();
1885
1885
  return t ? {
1886
1886
  rowIndex: t.rowStart,
1887
1887
  colIndex: t.colStart,
1888
1888
  scope: e.getId()
1889
1889
  } : null;
1890
1890
  },
1891
- getRange: a.getRange.bind(a),
1892
- getRanges: a.getRanges.bind(a),
1893
- createGraphRanges: (e, t) => a._createGraphRanges(e, t),
1891
+ getRange: i.getRange.bind(i),
1892
+ getRanges: i.getRanges.bind(i),
1893
+ createGraphRanges: (e, t) => i._createGraphRanges(e, t),
1894
1894
  getSheetIndex: (e) => {
1895
1895
  if (e === void 0) {
1896
- let e = a.getSelectedSheet();
1897
- return e ? this._getSheetRefs(t.Visibility.VeryHidden).findIndex((t) => t.sheet === e) : -1;
1896
+ let e = i.getSelectedSheet();
1897
+ return e ? this._getSheetRefs(O.Visibility.VeryHidden).findIndex((t) => t.sheet === e) : -1;
1898
1898
  }
1899
- let n = this._getSheetRefs(t.Visibility.VeryHidden);
1899
+ let t = this._getSheetRefs(O.Visibility.VeryHidden);
1900
1900
  e = e.toLowerCase();
1901
- let r = n.length;
1902
- for (let t = 0; t < r; t++) if (n[t].name.toLowerCase() === e) return t;
1901
+ let n = t.length;
1902
+ for (let r = 0; r < n; r++) if (t[r].name.toLowerCase() === e) return r;
1903
1903
  try {
1904
1904
  An.address = e;
1905
- let n = this._names.getItems(An);
1906
- if (!n || n.length === 0) return -1;
1907
- let r = n[0].getRanges?.()?.getCoords()?.[0]?.scope;
1908
- if (!r) return -1;
1909
- let i = this._getSheetRefs(t.Visibility.VeryHidden);
1910
- r = r.toLowerCase();
1911
- let a = i.length;
1912
- for (let e = 0; e < a; e++) if (i[e].name.toLowerCase() === r) return e;
1905
+ let t = this._names.getItems(An);
1906
+ if (!t || t.length === 0) return -1;
1907
+ let n = t[0].getRanges?.()?.getCoords()?.[0]?.scope;
1908
+ if (!n) return -1;
1909
+ let r = this._getSheetRefs(O.Visibility.VeryHidden);
1910
+ n = n.toLowerCase();
1911
+ let i = r.length;
1912
+ for (let e = 0; e < i; e++) if (r[e].name.toLowerCase() === n) return e;
1913
1913
  } catch {
1914
1914
  return -1;
1915
1915
  }
1916
1916
  return -1;
1917
1917
  },
1918
- getSheetCount: () => a.getSheets().getItems({ visibility: t.Visibility.VeryHidden }).length,
1918
+ getSheetCount: () => i.getSheets().getItems({ visibility: O.Visibility.VeryHidden }).length,
1919
1919
  getSheetById: (e) => {
1920
- let n = a.getSheets().getItems({ visibility: t.Visibility.VeryHidden }), r = n.length;
1921
- for (let t = 0; t < r; t++) if (n[t].getId() === e) return n[t];
1920
+ let t = i.getSheets().getItems({ visibility: O.Visibility.VeryHidden }), n = t.length;
1921
+ for (let r = 0; r < n; r++) if (t[r].getId() === e) return t[r];
1922
1922
  return null;
1923
1923
  },
1924
1924
  getSheetByName: (e) => {
1925
1925
  try {
1926
- return a.getSheets().getByName(e) ?? null;
1926
+ return i.getSheets().getByName(e) ?? null;
1927
1927
  } catch {
1928
1928
  return null;
1929
1929
  }
1930
1930
  },
1931
- namedCollection: a._names,
1932
- strings: a._strings,
1933
- transactions: a._transactions,
1934
- names: i?.names,
1935
- formulaTransform: n.formulaTransform
1936
- }), this._ownCalculation = !n.calculation, this._scripts = this._createScripts(), this._ownNames = !n.names, this._options = Object.freeze({ ...n });
1937
- let r = async () => {
1931
+ namedCollection: i._names,
1932
+ strings: i._strings,
1933
+ transactions: i._transactions,
1934
+ names: r?.names,
1935
+ formulaTransform: t.formulaTransform
1936
+ }), this._ownCalculation = !t.calculation, this._scripts = this._createScripts(), this._ownNames = !t.names, this._options = Object.freeze({ ...t });
1937
+ let n = async () => {
1938
1938
  this._ownCalculation && await this._calculation.start(), await this._scripts.start(), this._starting = null;
1939
1939
  };
1940
- this._starting = r(), this._starting?.catch(() => {}), i ? this._fromJSON(i) : (this._initState(), this._addSheet(!1)), this._sheets = new bn((e) => a._addSheetOptions(e), (e, t) => {
1940
+ this._starting = n(), this._starting?.catch(() => {}), r ? this._fromJSON(r) : (this._initState(), this._addSheet(!1)), this._sheets = new bn((e) => i._addSheetOptions(e), (e, t) => {
1941
1941
  if (e) {
1942
1942
  let n = this._getSheetRef(e, t);
1943
1943
  return n ? [n.sheet] : I.EmptyArray;
1944
1944
  }
1945
1945
  return this._getSheets(t);
1946
- }), this._ownCalculation && this._calculation.hydrateNames(), this._emitter.notify("onLoad"), o.commit({ forceAmend: this._ownTransactions });
1946
+ }), this._ownCalculation && this._calculation.hydrateNames(), this._emitter.notify("onLoad"), a.commit({ forceAmend: this._ownTransactions });
1947
1947
  } catch (e) {
1948
- throw o.rollback(), e;
1948
+ throw a.rollback(), e;
1949
1949
  }
1950
1950
  this._initializing = !1;
1951
1951
  }
@@ -1953,7 +1953,7 @@ var En, Dn, $ = class e extends he {
1953
1953
  let e = this._getSheetRefs();
1954
1954
  for (let t = (e ? e.length : 0) - 1; t >= 0; t--);
1955
1955
  let t = this._options;
1956
- this._isDate1904 = t.runtime?.isDate1904() ?? !1, this._locale = null, this._localeOverrides = null, this._theme = t.theme ?? new p().getDefaultTheme(), this._styles = t?.styles ?? new ot(this._theme), this._ownStyles = !t.styles, this._styles.getTheme() || this._styles.setTheme(this.getTheme()), this._activeSheetOffset = 0, this.setView(new Q()), this._listenerProtection?.(), this._protection = new vn(void 0, this._options.readonly ?? !1), this._listenerProtection = this._protection.addListeners({ onChange: (e) => {
1956
+ this._isDate1904 = t.runtime?.isDate1904() ?? !1, this._locale = null, this._localeOverrides = null, this._theme = t.theme ?? new g().getDefaultTheme(), this._styles = t?.styles ?? new ae(this._theme), this._ownStyles = !t.styles, this._styles.getTheme() || this._styles.setTheme(this.getTheme()), this._activeSheetOffset = 0, this.setView(new Q()), this._listenerProtection?.(), this._protection = new vn(void 0, this._options.readonly ?? !1), this._listenerProtection = this._protection.addListeners({ onChange: (e) => {
1957
1957
  n._emitter.notify("onProtectionChange");
1958
1958
  } });
1959
1959
  let n = this;
@@ -2077,19 +2077,19 @@ var En, Dn, $ = class e extends he {
2077
2077
  let e = this._getSheetRef(this.getSelectedSheetIndex());
2078
2078
  return e ? e?.sheet : null;
2079
2079
  }
2080
- getSheet(e, n = t.Visibility.Visible) {
2080
+ getSheet(e, t = O.Visibility.Visible) {
2081
2081
  if (e === void 0) return this.getSelectedSheet();
2082
2082
  if (!e) throw Error(H("error.workbook.sheetNameNotProvided"));
2083
- let r = this._getSheetRef(e, n);
2084
- if (!r) throw new B(H("error.workbook.sheetNameNotFound", { sheetName: e }));
2085
- return r.sheet;
2083
+ let n = this._getSheetRef(e, t);
2084
+ if (!n) throw new B(H("error.workbook.sheetNameNotFound", { sheetName: e }));
2085
+ return n.sheet;
2086
2086
  }
2087
- getSheetAt(e, n = t.Visibility.Visible) {
2088
- let r = this._getSheetRef(e, n);
2089
- if (!r) throw new B(function(e) {
2087
+ getSheetAt(e, t = O.Visibility.Visible) {
2088
+ let n = this._getSheetRef(e, t);
2089
+ if (!n) throw new B(function(e) {
2090
2090
  return H("error.workbook.sheetIndexNotFound", { index: e });
2091
2091
  }(e));
2092
- return r.sheet;
2092
+ return n.sheet;
2093
2093
  }
2094
2094
  getSheets() {
2095
2095
  return this._sheets;
@@ -2097,18 +2097,18 @@ var En, Dn, $ = class e extends he {
2097
2097
  addSheet(e) {
2098
2098
  return this.getSheets().add(e);
2099
2099
  }
2100
- _getSheets(e = t.Visibility.Visible) {
2101
- let n = this._getSheetRefs(e), r = [], i = n.length;
2102
- for (let e = 0; e < i; e++) r.push(n[e].sheet);
2103
- return r;
2100
+ _getSheets(e = O.Visibility.Visible) {
2101
+ let t = this._getSheetRefs(e), n = [], r = t.length;
2102
+ for (let e = 0; e < r; e++) n.push(t[e].sheet);
2103
+ return n;
2104
2104
  }
2105
- _getSheetRefs(e = t.Visibility.Visible) {
2106
- let n = this._getState();
2107
- return n ? e === t.Visibility.Visible ? n.sheetRefsVisible : e === t.Visibility.Hidden ? n.sheetRefsVisibleAndHidden : e === t.Visibility.VeryHidden ? n.sheetRefsAll : I.EmptyArray : [];
2105
+ _getSheetRefs(e = O.Visibility.Visible) {
2106
+ let t = this._getState();
2107
+ return t ? e === O.Visibility.Visible ? t.sheetRefsVisible : e === O.Visibility.Hidden ? t.sheetRefsVisibleAndHidden : e === O.Visibility.VeryHidden ? t.sheetRefsAll : I.EmptyArray : [];
2108
2108
  }
2109
- _getSheetRef(e, n = t.Visibility.Visible) {
2110
- let r = null;
2111
- return typeof e == "number" ? this._getSheetRefs(n)[e] : (typeof e == "string" ? r = this._getState().refsByLowerCaseName.get(e.toLowerCase()) : e instanceof O ? r = this._getState().refsByInstance.get(e) : e?.id !== void 0 && (r = this._getState().refsById.get(e.id)), r);
2109
+ _getSheetRef(e, t = O.Visibility.Visible) {
2110
+ let n = null;
2111
+ return typeof e == "number" ? this._getSheetRefs(t)[e] : (typeof e == "string" ? n = this._getState().refsByLowerCaseName.get(e.toLowerCase()) : e instanceof A ? n = this._getState().refsByInstance.get(e) : e?.id !== void 0 && (n = this._getState().refsById.get(e.id)), n);
2112
2112
  }
2113
2113
  _validateNewSheetName(e, t = !0) {
2114
2114
  if (e == null) return e;
@@ -2188,100 +2188,100 @@ var En, Dn, $ = class e extends he {
2188
2188
  }
2189
2189
  return this._updateState({ lastId: i }), e;
2190
2190
  }
2191
- _addSheet(e, n = null, r = null) {
2192
- n = this._nextSheetName(n);
2193
- let i = this._getState(), a = this._createSheet(i.lastId, n, t.Visibility.Visible, r, null);
2194
- if (!a) throw new R(H("error.workbook.sheetNameBlank"));
2195
- return e && this._emitter.notify("onSheetsChange"), a;
2191
+ _addSheet(e, t = null, n = null) {
2192
+ t = this._nextSheetName(t);
2193
+ let r = this._getState(), i = this._createSheet(r.lastId, t, O.Visibility.Visible, n, null);
2194
+ if (!i) throw new R(H("error.workbook.sheetNameBlank"));
2195
+ return e && this._emitter.notify("onSheetsChange"), i;
2196
2196
  }
2197
2197
  _updateSheetRefStates(e) {
2198
2198
  if (this._closed) throw Error(H("error.workbook.modelClosed"));
2199
2199
  if (!this._initializing && !this.getProtection().isStructureAllowed()) throw new R(H("error.workbook.protection"));
2200
- let n = e, r = [], i = [], a = n.length;
2201
- for (let e = 0; e < a; e++) n[e].visibility === t.Visibility.Visible ? (r.push(n[e]), i.push(n[e])) : n[e].visibility === t.Visibility.Hidden && i.push(n[e]);
2200
+ let t = e, n = [], r = [], i = t.length;
2201
+ for (let e = 0; e < i; e++) t[e].visibility === O.Visibility.Visible ? (n.push(t[e]), r.push(t[e])) : t[e].visibility === O.Visibility.Hidden && r.push(t[e]);
2202
2202
  this._updateState({
2203
- sheetRefsAll: n,
2204
- sheetRefsVisible: r,
2205
- sheetRefsVisibleAndHidden: i
2203
+ sheetRefsAll: t,
2204
+ sheetRefsVisible: n,
2205
+ sheetRefsVisibleAndHidden: r
2206
2206
  });
2207
2207
  }
2208
- _addSheetRef(e, n = null) {
2209
- let r = this._getState(), i = r.sheetRefsAll, a = Math.max(0, Math.min(i.length, n ?? i.length)), o = [
2210
- ...i.slice(0, a),
2208
+ _addSheetRef(e, t = null) {
2209
+ let n = this._getState(), r = n.sheetRefsAll, i = Math.max(0, Math.min(r.length, t ?? r.length)), a = [
2210
+ ...r.slice(0, i),
2211
2211
  e,
2212
- ...i.slice(a)
2212
+ ...r.slice(i)
2213
2213
  ];
2214
- this._updateSheetRefStates(o);
2215
- let s = e.sheet, c = e.name.toLowerCase(), l = new Map(r.refsById);
2216
- l.set(e.id, e);
2217
- let u = new Map(r.refsByLowerCaseName);
2218
- u.set(c, e);
2219
- let d = new Map(r.refsByInstance);
2220
- d.set(s, e);
2221
- let f = new Map(r.sheetsById);
2222
- f.set(e.id, s);
2223
- let p = new Map(r.sheetsByLowerCaseName);
2224
- p.set(c, s);
2225
- let m = this, h = r.listenersSheets;
2226
- if (s !== void 0) {
2227
- let n = s.addListeners({
2214
+ this._updateSheetRefStates(a);
2215
+ let o = e.sheet, s = e.name.toLowerCase(), c = new Map(n.refsById);
2216
+ c.set(e.id, e);
2217
+ let l = new Map(n.refsByLowerCaseName);
2218
+ l.set(s, e);
2219
+ let u = new Map(n.refsByInstance);
2220
+ u.set(o, e);
2221
+ let d = new Map(n.sheetsById);
2222
+ d.set(e.id, o);
2223
+ let f = new Map(n.sheetsByLowerCaseName);
2224
+ f.set(s, o);
2225
+ let p = this, m = n.listenersSheets;
2226
+ if (o !== void 0) {
2227
+ let t = o.addListeners({
2228
2228
  onBeforeDelete: (e) => {
2229
- m._validateDeleteSheet(e);
2229
+ p._validateDeleteSheet(e);
2230
2230
  },
2231
2231
  onDelete(e) {
2232
- let n = m._getSheetRef(e, t.Visibility.VeryHidden);
2233
- if (!n) return;
2234
- let r = m._beginCommit({ description: H("op.deleteSheet", { name: n.name }) });
2232
+ let t = p._getSheetRef(e, O.Visibility.VeryHidden);
2233
+ if (!t) return;
2234
+ let n = p._beginCommit({ description: H("op.deleteSheet", { name: t.name }) });
2235
2235
  try {
2236
- let t = m._getState(), i = t.sheetRefsAll, a = m._getOffsetForId(n.id, i), o = [...i];
2237
- o.splice(a, 1), m._updateSheetRefStates(o);
2238
- let c = new Map(t.refsById);
2239
- c.delete(n.id);
2240
- let l = new Map(t.sheetsById);
2241
- l.delete(n.id);
2242
- let u = n.name.toLowerCase(), d = new Map(t.refsByLowerCaseName);
2236
+ let r = p._getState(), i = r.sheetRefsAll, a = p._getOffsetForId(t.id, i), s = [...i];
2237
+ s.splice(a, 1), p._updateSheetRefStates(s);
2238
+ let c = new Map(r.refsById);
2239
+ c.delete(t.id);
2240
+ let l = new Map(r.sheetsById);
2241
+ l.delete(t.id);
2242
+ let u = t.name.toLowerCase(), d = new Map(r.refsByLowerCaseName);
2243
2243
  d.delete(u);
2244
- let f = new Map(t.sheetsByLowerCaseName);
2244
+ let f = new Map(r.sheetsByLowerCaseName);
2245
2245
  f.delete(u);
2246
- let p = new Map(t.refsByInstance);
2247
- p.delete(e), t.listenersSheets.get(n.id)();
2248
- let h = new Map(t.listenersSheets);
2249
- h.delete(n.id), m._adjustRemoveSelectionIfRequired(a, n.id), m._adjustSheetNamesIfRequired(), m._sheetOnNameChange.delete(n.id), m._sheetOnVisibilityChange.delete(n.id), m._sheetOnIndexChange.delete(n.id), m._emitter.notify("onSheetsChange");
2250
- let g = new Set(t.sheetsCreated);
2251
- g.has(s) && g.delete(s), m._updateState({
2246
+ let m = new Map(r.refsByInstance);
2247
+ m.delete(e), r.listenersSheets.get(t.id)();
2248
+ let h = new Map(r.listenersSheets);
2249
+ h.delete(t.id), p._adjustRemoveSelectionIfRequired(a, t.id), p._adjustSheetNamesIfRequired(), p._sheetOnNameChange.delete(t.id), p._sheetOnVisibilityChange.delete(t.id), p._sheetOnIndexChange.delete(t.id), p._emitter.notify("onSheetsChange");
2250
+ let g = new Set(r.sheetsCreated);
2251
+ g.has(o) && g.delete(o), p._updateState({
2252
2252
  refsById: c,
2253
2253
  sheetsById: l,
2254
2254
  refsByLowerCaseName: d,
2255
2255
  sheetsByLowerCaseName: f,
2256
- refsByInstance: p,
2256
+ refsByInstance: m,
2257
2257
  sheetsCreated: g,
2258
2258
  listenersSheets: h
2259
- }), r.commit();
2259
+ }), n.commit();
2260
2260
  } catch (e) {
2261
- throw r.rollback(), e;
2261
+ throw n.rollback(), e;
2262
2262
  }
2263
2263
  }
2264
- }), i = s.addListeners({ onSelectionChange: (e) => {
2265
- m.getView().getActiveSheetId() === m._getSheetRef(e)?.id && m._emitter.notify("onSelectionChange", {
2266
- source: m,
2264
+ }), r = o.addListeners({ onSelectionChange: (e) => {
2265
+ p.getView().getActiveSheetId() === p._getSheetRef(e)?.id && p._emitter.notify("onSelectionChange", {
2266
+ source: p,
2267
2267
  params: e
2268
2268
  });
2269
2269
  } }, { transactional: !1 });
2270
- h = new Map(r.listenersSheets), h.set(e.id, () => {
2271
- n(), i();
2270
+ m = new Map(n.listenersSheets), m.set(e.id, () => {
2271
+ t(), r();
2272
2272
  });
2273
2273
  }
2274
- let g = r.lastId;
2275
- g !== -1 && (g = Math.max(g, e.id)), this._updateState({ lastId: g }), this._updateState({
2276
- refsById: l,
2277
- refsByLowerCaseName: u,
2278
- refsByInstance: d,
2279
- sheetsById: f,
2280
- sheetsByLowerCaseName: p,
2281
- listenersSheets: h
2274
+ let h = n.lastId;
2275
+ h !== -1 && (h = Math.max(h, e.id)), this._updateState({ lastId: h }), this._updateState({
2276
+ refsById: c,
2277
+ refsByLowerCaseName: l,
2278
+ refsByInstance: u,
2279
+ sheetsById: d,
2280
+ sheetsByLowerCaseName: f,
2281
+ listenersSheets: m
2282
2282
  }), this._adjustSheetNamesIfRequired();
2283
- let _ = new Set(this._getState().sheetsCreated);
2284
- return _.add(e.sheet), this._updateState({ sheetsCreated: _ }), e;
2283
+ let g = new Set(this._getState().sheetsCreated);
2284
+ return g.add(e.sheet), this._updateState({ sheetsCreated: g }), e;
2285
2285
  }
2286
2286
  _adjustRemoveSelectionIfRequired(e, t) {
2287
2287
  if (this._view.getActiveSheetId() === t) {
@@ -2290,12 +2290,12 @@ var En, Dn, $ = class e extends he {
2290
2290
  }
2291
2291
  }
2292
2292
  _adjustSheetNamesIfRequired() {
2293
- let e = this._getState(), n = e.lastId;
2294
- if (n === -1) return;
2295
- let r = this._view.getActiveSheetId();
2296
- r ??= (this._view.setActiveSheetId(n), n);
2297
- let i = e.refsById.get(r);
2298
- i || (this._view.setActiveSheetId(n), i = e.refsById.get(n), r = n), i.visibility === t.Visibility.Visible && (this._activeSheetOffset = this._getOffsetForId(r, e.sheetRefsVisible));
2293
+ let e = this._getState(), t = e.lastId;
2294
+ if (t === -1) return;
2295
+ let n = this._view.getActiveSheetId();
2296
+ n ??= (this._view.setActiveSheetId(t), t);
2297
+ let r = e.refsById.get(n);
2298
+ r || (this._view.setActiveSheetId(t), r = e.refsById.get(t), n = t), r.visibility === O.Visibility.Visible && (this._activeSheetOffset = this._getOffsetForId(n, e.sheetRefsVisible));
2299
2299
  }
2300
2300
  _validateDeleteSheet(e) {
2301
2301
  if (this._closed) throw Error(H("error.workbook.modelClosed"));
@@ -2340,7 +2340,7 @@ var En, Dn, $ = class e extends he {
2340
2340
  }
2341
2341
  if (!d && s && a === i && (u.done || !c || !u.done && f(u.value.getCoords(), c) >= 0) && (d = !0), d) {
2342
2342
  let e = u;
2343
- return u = ye, e;
2343
+ return u = Ce, e;
2344
2344
  }
2345
2345
  let p = u;
2346
2346
  return u = l.next(), p;
@@ -2352,7 +2352,7 @@ var En, Dn, $ = class e extends he {
2352
2352
  } };
2353
2353
  }
2354
2354
  replace(e, t, n) {
2355
- let r = 0, i = null, a = typeof t == "function", o = n?.maxCount ?? 2 ** 53 - 1, s = !n?.maxCount, c = "", l = typeof t == "string" ? ct(t) : null, u = n?.description ?? V("op.replace"), d = this._transactions.beginCommit({ description: u });
2355
+ let r = 0, i = null, a = typeof t == "function", o = n?.maxCount ?? 2 ** 53 - 1, s = !n?.maxCount, c = "", l = typeof t == "string" ? me(t) : null, u = n?.description ?? V("op.replace"), d = this._transactions.beginCommit({ description: u });
2356
2356
  try {
2357
2357
  let u = null, f = null, p = e.next();
2358
2358
  for (; !p.done && r < o;) {
@@ -2416,21 +2416,21 @@ var En, Dn, $ = class e extends he {
2416
2416
  }
2417
2417
  return c;
2418
2418
  }
2419
- _createRange(e, n) {
2420
- let r = e ? { ...e } : null, i = r ? this._getSheetRef(r.scope, t.Visibility.VeryHidden) : null;
2421
- if (!i) {
2419
+ _createRange(e, t) {
2420
+ let n = e ? { ...e } : null, r = n ? this._getSheetRef(n.scope, O.Visibility.VeryHidden) : null;
2421
+ if (!r) {
2422
2422
  let e = this.getSelectedSheet();
2423
- return e ? (delete r?.scope, wn(r, r ? {
2424
- scope: qe,
2423
+ return e ? (delete n?.scope, wn(n, n ? {
2424
+ scope: h,
2425
2425
  ...e.getEntireRange().getCoords()
2426
2426
  } : null)) : void console.warn(H("error.workbook.noVisibleRefs"));
2427
2427
  }
2428
- let a = i.sheet, o = null;
2429
- return n && (o = { getOptions: n }), new On(e, w(a), this, o);
2428
+ let i = r.sheet, a = null;
2429
+ return t && (a = { getOptions: t }), new On(e, D(i), this, a);
2430
2430
  }
2431
2431
  _createRanges(e, t) {
2432
2432
  let n = this.getSelectedSheet(), r = null;
2433
- return t && (r = { getOptions: t }), new $(e, w(n), this, r);
2433
+ return t && (r = { getOptions: t }), new $(e, D(n), this, r);
2434
2434
  }
2435
2435
  getRange(e, t) {
2436
2436
  if (e === void 0) return this.getSelectedRange(t);
@@ -2439,7 +2439,7 @@ var En, Dn, $ = class e extends he {
2439
2439
  if (n.length !== 1) throw new R(H("error.address.singleRangeOnlyAlt"));
2440
2440
  return this._createRange(n[0], t);
2441
2441
  } catch (t) {
2442
- throw t instanceof B ? new B(t.message) : new R(t.message ?? re(e));
2442
+ throw t instanceof B ? new B(t.message) : new R(t.message ?? o(e));
2443
2443
  }
2444
2444
  }
2445
2445
  getCell(e) {
@@ -2450,25 +2450,25 @@ var En, Dn, $ = class e extends he {
2450
2450
  }
2451
2451
  getRanges(e, t) {
2452
2452
  let n = this._rangesAddressToCoords(e);
2453
- if (n.length === 0) throw new R(re(e));
2453
+ if (n.length === 0) throw new R(o(e));
2454
2454
  return this._createRanges(n, t);
2455
2455
  }
2456
- _createGraphRanges(e, n) {
2457
- let r = [];
2458
- for (let e = 0; e < n.length; e++) {
2459
- let i = n[e], a = (i.sheetName ? this._getSheetRef(i.sheetName, t.Visibility.VeryHidden) : null)?.sheet ?? this.getSelectedSheet();
2460
- a && r.push(new Ye(i, w(a), null));
2456
+ _createGraphRanges(e, t) {
2457
+ let n = [];
2458
+ for (let e = 0; e < t.length; e++) {
2459
+ let r = t[e], i = (r.sheetName ? this._getSheetRef(r.sheetName, O.Visibility.VeryHidden) : null)?.sheet ?? this.getSelectedSheet();
2460
+ i && n.push(new je(r, D(i), null));
2461
2461
  }
2462
- for (let t = 0; t < e.length; t++) r.push(e[t]);
2463
- return r.length === 0 ? null : new $(r, w(this.getSelectedSheet()), this, null);
2462
+ for (let t = 0; t < e.length; t++) n.push(e[t]);
2463
+ return n.length === 0 ? null : new $(n, D(this.getSelectedSheet()), this, null);
2464
2464
  }
2465
2465
  getStats(e) {
2466
2466
  if (this._closed) throw Error(H("error.workbook.modelClosed"));
2467
- let n = this._getSheets(t.Visibility.VeryHidden), r = n.length;
2468
- if (r === 1) return n[0].getStats(e);
2469
- let i = Array(r);
2470
- for (let t = 0; t < r; t++) i[t] = n[t].getStats(e);
2471
- return new on(i);
2467
+ let t = this._getSheets(O.Visibility.VeryHidden), n = t.length;
2468
+ if (n === 1) return t[0].getStats(e);
2469
+ let r = Array(n);
2470
+ for (let i = 0; i < n; i++) r[i] = t[i].getStats(e);
2471
+ return new on(r);
2472
2472
  }
2473
2473
  _activeRangeCoords() {
2474
2474
  let e = this.getSelectedSheet(), t = e.getSelection().getRanges().getCoords(), n = e.getName(), r = t.length, i = Array(r);
@@ -2493,7 +2493,7 @@ var En, Dn, $ = class e extends he {
2493
2493
  getSelectedCell() {
2494
2494
  return this.getSelectedSheet().getSelectedCell();
2495
2495
  }
2496
- _rangesAddressToCoords(e, n = !0, r = t.Visibility.Hidden) {
2496
+ _rangesAddressToCoords(e, n = !0, r = O.Visibility.Hidden) {
2497
2497
  if (!e) throw new R(H("error.address.noAddress"));
2498
2498
  let i = this.getSelectedSheet(), a = { ...i?.getEntireRange().getCoords() }, o = i?.getName();
2499
2499
  if (o && (a.scope = o), typeof e == "string") {
@@ -2503,7 +2503,7 @@ var En, Dn, $ = class e extends he {
2503
2503
  t === "r" ? r.rowStart = r.rowEnd = n.rowIndex : r.colStart = r.colEnd = n.colIndex, e = r;
2504
2504
  }
2505
2505
  }
2506
- let s = this, c = ce(e, a, te, (e) => {
2506
+ let s = this, c = le(e, a, t, (e) => {
2507
2507
  if (!n) return null;
2508
2508
  if (typeof e == "string") {
2509
2509
  let t = s.getNames().getByName(e)?.getRanges?.();
@@ -2514,10 +2514,10 @@ var En, Dn, $ = class e extends he {
2514
2514
  for (let e = 0; e < l; e++) this._validateCoords(c[e], r);
2515
2515
  return c;
2516
2516
  }
2517
- _validateCoords(e, n = t.Visibility.Visible, r = H("error.sheet.oobRange")) {
2517
+ _validateCoords(e, t = O.Visibility.Visible, n = H("error.sheet.oobRange")) {
2518
2518
  if (e === null) return;
2519
- let i = this.getSheet(e.scope, n).getEntireRange().getCoords();
2520
- if (!L.isRangeWithinRange(e, i)) throw new B(r);
2519
+ let r = this.getSheet(e.scope, t).getEntireRange().getCoords();
2520
+ if (!L.isRangeWithinRange(e, r)) throw new B(n);
2521
2521
  if (e.rowEnd < e.rowStart || e.colEnd < e.colStart) throw new R(H("error.address.invalidRangeInverted"));
2522
2522
  }
2523
2523
  _updateSheetRef(e, t) {
@@ -2558,29 +2558,29 @@ var En, Dn, $ = class e extends he {
2558
2558
  }
2559
2559
  return a;
2560
2560
  }
2561
- _setSheetVisibility(e, n = t.Visibility.Visible, r) {
2561
+ _setSheetVisibility(e, t = O.Visibility.Visible, n) {
2562
2562
  if (this._closed) throw Error(H("error.workbook.modelClosed"));
2563
2563
  if (!this.getProtection().isStructureAllowed()) throw new R(H("error.workbook.protection"));
2564
- let i = this._getSheetRef(e, t.Visibility.VeryHidden);
2565
- if (!i) return null;
2566
- if (n === i.visibility) return;
2567
- let a = null, o = "";
2568
- n === t.Visibility.Visible ? o = V("op.unhideSheet") : n === t.Visibility.Hidden ? o = V("op.hideSheet") : n === t.Visibility.VeryHidden && (o = V("op.veryHideSheet"));
2569
- let s = this.beginCommit(o);
2564
+ let r = this._getSheetRef(e, O.Visibility.VeryHidden);
2565
+ if (!r) return null;
2566
+ if (t === r.visibility) return;
2567
+ let i = null, a = "";
2568
+ t === O.Visibility.Visible ? a = V("op.unhideSheet") : t === O.Visibility.Hidden ? a = V("op.hideSheet") : t === O.Visibility.VeryHidden && (a = V("op.veryHideSheet"));
2569
+ let o = this.beginCommit(a);
2570
2570
  try {
2571
2571
  let e = this._getState().sheetRefsVisible;
2572
- if (n !== t.Visibility.Visible && e.length === 1 && e[0].id === i.id) throw new R(H("error.workbook.sheetOne"));
2573
- let o = {
2574
- ...i,
2575
- visibility: n
2576
- }, c = -1;
2577
- n !== t.Visibility.Visible && (c = this._getOffsetForId(i.id, e)), a = this._updateSheetRef(i, o).sheet, n !== t.Visibility.Visible && this._adjustRemoveSelectionIfRequired(c, i.id), this._adjustSheetNamesIfRequired(), s.commit(r);
2572
+ if (t !== O.Visibility.Visible && e.length === 1 && e[0].id === r.id) throw new R(H("error.workbook.sheetOne"));
2573
+ let a = {
2574
+ ...r,
2575
+ visibility: t
2576
+ }, s = -1;
2577
+ t !== O.Visibility.Visible && (s = this._getOffsetForId(r.id, e)), i = this._updateSheetRef(r, a).sheet, t !== O.Visibility.Visible && this._adjustRemoveSelectionIfRequired(s, r.id), this._adjustSheetNamesIfRequired(), o.commit(n);
2578
2578
  } catch (e) {
2579
- throw s.rollback(), e;
2579
+ throw o.rollback(), e;
2580
2580
  }
2581
2581
  return this._sheetOnVisibilityChange.forEach((e, t) => {
2582
- i.id === t && e();
2583
- }), this._emitter.notify("onSheetsChange"), a;
2582
+ r.id === t && e();
2583
+ }), this._emitter.notify("onSheetsChange"), i;
2584
2584
  }
2585
2585
  _moveSheet(e, t, n) {
2586
2586
  if (this._closed) throw Error(H("error.workbook.modelClosed"));
@@ -2612,10 +2612,10 @@ var En, Dn, $ = class e extends he {
2612
2612
  }
2613
2613
  _setSelectedSheet(e) {
2614
2614
  if (this._closed) throw Error(H("error.workbook.modelClosed"));
2615
- let n = this._getSheetRef(e);
2616
- if (!n) throw new R(yn(e));
2617
- let r = null;
2618
- return n.visibility !== t.Visibility.Visible && this._setSheetVisibility(n, t.Visibility.Visible), this._view.setActiveSheetId(n.id), r = n.sheet, r;
2615
+ let t = this._getSheetRef(e);
2616
+ if (!t) throw new R(yn(e));
2617
+ let n = null;
2618
+ return t.visibility !== O.Visibility.Visible && this._setSheetVisibility(t, O.Visibility.Visible), this._view.setActiveSheetId(t.id), n = t.sheet, n;
2619
2619
  }
2620
2620
  getProtection() {
2621
2621
  return this._protection;
@@ -2683,24 +2683,24 @@ var En, Dn, $ = class e extends he {
2683
2683
  }
2684
2684
  _fromJSON(e) {
2685
2685
  if (this._emitter.notify("onBeforeLoad", { params: e }), this._initState(), !e.sheets || e.sheets.length === 0) throw new R(H("error.workbook.sheetOne"));
2686
- e.theme && (this._theme = new u(e.theme), this._styles.setTheme(this._theme));
2687
- let n = this._strings.beginPersist(), r = this._resources.beginPersist(), i = this._styles.beginPersist();
2686
+ e.theme && (this._theme = new m(e.theme), this._styles.setTheme(this._theme));
2687
+ let t = this._strings.beginPersist(), n = this._resources.beginPersist(), r = this._styles.beginPersist();
2688
2688
  try {
2689
- n.fromJSON(e.strings), r.fromJSON(e.resources), i.fromJSON(e.styles), e.date1904 && (this._isDate1904 = !0), e.locale && (this._locale = e.locale), e.localeOverrides && (this._localeOverrides = e.localeOverrides), e.view ||= {};
2690
- let a = e.sheets, o = a.length, s = e.view.activeSheetId ?? null;
2691
- s !== null && (s = Math.min(Math.max(0, s), o - 1));
2692
- let c = null, l = null, u = -1;
2693
- for (let e = 0; e < o; e++) {
2694
- let n = a[e], r = n.visibility || t.Visibility.Visible, i = e;
2695
- l = i, r === t.Visibility.Visible ? (u++, c === null && (c = i)) : s !== null && s === i && (s = null), this._createSheet(i, n.name, r, u, n.sheet);
2689
+ t.fromJSON(e.strings), n.fromJSON(e.resources), r.fromJSON(e.styles), e.date1904 && (this._isDate1904 = !0), e.locale && (this._locale = e.locale), e.localeOverrides && (this._localeOverrides = e.localeOverrides), e.view ||= {};
2690
+ let i = e.sheets, a = i.length, o = e.view.activeSheetId ?? null;
2691
+ o !== null && (o = Math.min(Math.max(0, o), a - 1));
2692
+ let s = null, c = null, l = -1;
2693
+ for (let e = 0; e < a; e++) {
2694
+ let t = i[e], n = t.visibility || O.Visibility.Visible, r = e;
2695
+ c = r, n === O.Visibility.Visible ? (l++, s === null && (s = r)) : o !== null && o === r && (o = null), this._createSheet(r, t.name, n, l, t.sheet);
2696
2696
  }
2697
- this._updateState({ lastId: l }), e.view.activeSheetId = s ?? c, this.setView(new Q({ json: e.view })), this._adjustSheetNamesIfRequired(), this._listenerProtection?.();
2698
- let d = this;
2697
+ this._updateState({ lastId: c }), e.view.activeSheetId = o ?? s, this.setView(new Q({ json: e.view })), this._adjustSheetNamesIfRequired(), this._listenerProtection?.();
2698
+ let u = this;
2699
2699
  this._protection = new vn(e?.protection, this._options?.readonly), this._listenerProtection = this._protection.addListeners({ onChange: (e) => {
2700
- d._emitter.notify("onProtectionChange", { source: e });
2700
+ u._emitter.notify("onProtectionChange", { source: e });
2701
2701
  } }), e.scripts && (this._scripts = this._createScripts(e.scripts)), this._emitter.notify("onLoad");
2702
2702
  } finally {
2703
- i.endPersist(), r.endPersist(), n.endPersist();
2703
+ r.endPersist(), n.endPersist(), t.endPersist();
2704
2704
  }
2705
2705
  }
2706
2706
  _createScripts(e) {
@@ -2712,7 +2712,7 @@ var En, Dn, $ = class e extends he {
2712
2712
  getBuiltInFunctions: () => t._calculation?.getFunctions(),
2713
2713
  onAdd: (e, n) => {
2714
2714
  let r = t._calculation;
2715
- r.getStatus() !== Ve.Status.Off && r.start().then(async () => {
2715
+ r.getStatus() !== Ye.Status.Off && r.start().then(async () => {
2716
2716
  let e = n.getFunctions().getItems({ type: "formula" }), t = e.length;
2717
2717
  for (let n = 0; n < t; n++) {
2718
2718
  let t = e[n];
@@ -2730,47 +2730,47 @@ var En, Dn, $ = class e extends he {
2730
2730
  async toJSON(e) {
2731
2731
  if (this._closed) throw Error(H("error.workbook.modelClosed"));
2732
2732
  await Promise.resolve(this._starting), await this._emitter.notify("onBeforeSave", { async: !0 });
2733
- let n = { sheets: [] }, r = e?.ignoreStyles ?? !1;
2734
- if (!r) {
2733
+ let t = { sheets: [] }, n = e?.ignoreStyles ?? !1;
2734
+ if (!n) {
2735
2735
  let e = this._theme.toJSON();
2736
- (e ? Object.keys(e).length : 0) > 0 && (n.theme = e);
2736
+ (e ? Object.keys(e).length : 0) > 0 && (t.theme = e);
2737
2737
  }
2738
2738
  if (this._scripts) {
2739
2739
  let e = this._scripts.toJSON();
2740
- e && Object.keys(e).length > 0 && (n.scripts = e);
2740
+ e && Object.keys(e).length > 0 && (t.scripts = e);
2741
2741
  }
2742
- this._isDate1904 && (n.date1904 = !0), this._locale && (n.locale = this._locale), this._localeOverrides && (n.localeOverrides = this._localeOverrides);
2743
- let i = e?.ignoreResources ?? !1, a = this._strings.beginPersist(), o = i ? null : this._resources.beginPersist(), s = this._styles.beginPersist();
2742
+ this._isDate1904 && (t.date1904 = !0), this._locale && (t.locale = this._locale), this._localeOverrides && (t.localeOverrides = this._localeOverrides);
2743
+ let r = e?.ignoreResources ?? !1, i = this._strings.beginPersist(), a = r ? null : this._resources.beginPersist(), o = this._styles.beginPersist();
2744
2744
  try {
2745
- let c = this._getSheetRef(this.getSelectedSheetIndex()).id, l = c, u = null, d = this._getState(), f = d.sheetRefsAll, p = d.sheetsById, m = f.length;
2746
- for (let r = 0; r < m; r++) {
2747
- let i = f[r], a = r + 1, o = await p.get(i.id).toJSON(e), s = {
2748
- name: i.name,
2749
- sheet: o
2745
+ let s = this._getSheetRef(this.getSelectedSheetIndex()).id, c = s, l = null, u = this._getState(), d = u.sheetRefsAll, f = u.sheetsById, p = d.length;
2746
+ for (let n = 0; n < p; n++) {
2747
+ let r = d[n], i = n + 1, a = await f.get(r.id).toJSON(e), o = {
2748
+ name: r.name,
2749
+ sheet: a
2750
2750
  };
2751
- i.visibility === t.Visibility.Visible ? u === null && (u = a) : s.visibility = i.visibility, i.id === c && (l = a), n.sheets.push(s);
2751
+ r.visibility === O.Visibility.Visible ? l === null && (l = i) : o.visibility = r.visibility, r.id === s && (c = i), t.sheets.push(o);
2752
2752
  }
2753
- if (!r) {
2754
- let e = s.toJSON();
2755
- e && Object.keys(e).length > 0 && (n.styles = e);
2753
+ if (!n) {
2754
+ let e = o.toJSON();
2755
+ e && Object.keys(e).length > 0 && (t.styles = e);
2756
2756
  }
2757
- let h = this.getProtection().toJSON();
2758
- h && (n.protection = h);
2759
- let g = await a.toJSONAsync();
2760
- g && g.length > 0 && (n.strings = g);
2761
- let _ = this._externalBooks.toJSON();
2762
- if (_ && (n.externalBooks = _), !i) {
2763
- let e = await o.toJSONAsync();
2764
- e && e.length > 0 && (n.resources = e);
2757
+ let m = this.getProtection().toJSON();
2758
+ m && (t.protection = m);
2759
+ let h = await i.toJSONAsync();
2760
+ h && h.length > 0 && (t.strings = h);
2761
+ let g = this._externalBooks.toJSON();
2762
+ if (g && (t.externalBooks = g), !r) {
2763
+ let e = await a.toJSONAsync();
2764
+ e && e.length > 0 && (t.resources = e);
2765
2765
  }
2766
- let v = this._calculation.getNamedFormulas().toJSON();
2767
- v && v.length > 0 && (n.names = v);
2768
- let y = this._view.toJSON();
2769
- y && (l === u ? delete y.activeSheetId : y.activeSheetId = l, Object.keys(y).length > 0 && (n.view = y));
2766
+ let _ = this._calculation.getNamedFormulas().toJSON();
2767
+ _ && _.length > 0 && (t.names = _);
2768
+ let v = this._view.toJSON();
2769
+ v && (c === l ? delete v.activeSheetId : v.activeSheetId = c, Object.keys(v).length > 0 && (t.view = v));
2770
2770
  } finally {
2771
- s.endPersist(), i || o.endPersist(), a.endPersist();
2771
+ o.endPersist(), r || a.endPersist(), i.endPersist();
2772
2772
  }
2773
- return this._emitter.notify("onSave", { params: n }), n;
2773
+ return this._emitter.notify("onSave", { params: t }), t;
2774
2774
  }
2775
2775
  isClosed() {
2776
2776
  return this._closed;
@@ -2911,7 +2911,7 @@ var En, Dn, $ = class e extends he {
2911
2911
  }
2912
2912
  }, Mn = (e) => !!e && typeof e == "object" && typeof e.getPath == "function" && typeof e.canWrite == "function", Nn = class {
2913
2913
  constructor() {
2914
- this._setInstalled = /* @__PURE__ */ new WeakSet(), this._backingStore = null, this._emitter = new j(this), this._registry = new jn(), this._defaultStore = new wt(() => this.getWriteFormats(), () => this.getReadFormats());
2914
+ this._setInstalled = /* @__PURE__ */ new WeakSet(), this._backingStore = null, this._emitter = new S(this), this._registry = new jn(), this._defaultStore = new wt(() => this.getWriteFormats(), () => this.getReadFormats());
2915
2915
  }
2916
2916
  getBackingStore() {
2917
2917
  return this._backingStore ?? this._defaultStore;
@@ -2970,7 +2970,7 @@ var En, Dn, $ = class e extends he {
2970
2970
  search: i,
2971
2971
  ext: a
2972
2972
  }))[0];
2973
- if (!o) throw Error(`No read format available for '${i ?? a}' input.`);
2973
+ if (!o) throw new R(H("error.io.readFormatUnavailable", { format: i ?? a }));
2974
2974
  let s = n?.typedCreateWorkbookOptions, c = s ? Object.keys(s).find((e) => e.toLowerCase() === o.key.toLowerCase()) : void 0, l = {
2975
2975
  ...n,
2976
2976
  ...c === void 0 ? void 0 : s[c]
@@ -3031,7 +3031,10 @@ var En, Dn, $ = class e extends he {
3031
3031
  bytes: i,
3032
3032
  password: n.password
3033
3033
  };
3034
- if (!n?.onPassword) throw new vt(`'${t.getName() ?? "This file"}' is encrypted. Supply options.password or options.onPassword to open it.`);
3034
+ if (!n?.onPassword) {
3035
+ let e = t.getName();
3036
+ throw new vt(e ? H("error.io.passwordRequired", { name: e }) : H("error.io.passwordRequiredUnnamed"));
3037
+ }
3035
3038
  let o = await Promise.resolve(n.onPassword({
3036
3039
  origin: t,
3037
3040
  encryption: r.key,
@@ -3042,12 +3045,12 @@ var En, Dn, $ = class e extends he {
3042
3045
  bytes: i,
3043
3046
  password: o
3044
3047
  };
3045
- throw new ht();
3048
+ throw new ht(H("error.io.passwordIncorrect"));
3046
3049
  }
3047
3050
  async writeArrayBuffer(e, t) {
3048
3051
  if (!t?.format) throw Error("A format must be specified to write to an ArrayBuffer (e.g. { format: 'xlsx' }).");
3049
3052
  let n = (await this._registry.getWriteFormats({ search: t.format }))[0];
3050
- if (!n) throw Error(`No write format available for '${t.format}'.`);
3053
+ if (!n) throw new R(H("error.io.writeFormatUnavailable", { format: t.format }));
3051
3054
  return this._writeArrayBuffer(e, n, t);
3052
3055
  }
3053
3056
  async write(e, t, n) {
@@ -3056,16 +3059,19 @@ var En, Dn, $ = class e extends he {
3056
3059
  let r = n, i = null;
3057
3060
  typeof t == "string" ? i = this.getOrigin(t) : Mn(t) ? i = t : t && (r = t);
3058
3061
  let a = !i, o = i ?? e.getOrigin(), s = o.getFormat(), c;
3059
- if ((r?.format || s) && (c = (await this._registry.getWriteFormats({ search: r?.format ?? s ?? void 0 }))[0]), c || o.getPath() && o.canWrite() && o.getExtension() || (c = (await this._registry.getWriteFormats({ ext: "sxl" }))[0] ?? (await this._registry.getWriteFormats())[0]), !c) throw Error("Unable to determine a write format. Specify options.format, or a destination with a known extension.");
3062
+ if ((r?.format || s) && (c = (await this._registry.getWriteFormats({ search: r?.format ?? s ?? void 0 }))[0]), c || o.getPath() && o.canWrite() && o.getExtension() || (c = (await this._registry.getWriteFormats({ ext: "sxl" }))[0] ?? (await this._registry.getWriteFormats())[0]), !c) throw new R(H("error.io.writeFormatUnresolved"));
3060
3063
  if (i && typeof t == "string") {
3061
3064
  let e = i.getPath();
3062
- e && !M(e) && i.update?.({ path: `${e}.${c.exts[0]}` });
3065
+ e && !x(e) && i.update?.({ path: `${e}.${c.exts[0]}` });
3063
3066
  }
3064
3067
  let l = o.getEncryption(), u = e.getOrigin?.(), d = (o instanceof U ? o.getPassword() : null) ?? (u instanceof U ? u.getPassword() : null), f = o.isEncrypted() || (u?.isEncrypted() ?? !1), p = r?.password === void 0 ? d ?? (f ? void 0 : null) : r.password, m = null;
3065
3068
  if (p === void 0) {
3066
- if (f) throw new vt(`'${o.getName() ?? "This file"}' is encrypted. Supply options.password to re-encrypt it, or options.password = null to write it without a password.`);
3067
- } else if (p !== null && (m = await this._registry.getEncryption(l), !m)) throw Error("No encryption support is installed, so this workbook cannot be password protected.");
3068
- let h = `${o.getName() ?? "workbook"}.${c.exts[0]}`, g = r?.progress, _ = !1, v = this, y = null, ee = {
3069
+ if (f) {
3070
+ let e = o.getName();
3071
+ throw new vt(e ? H("error.io.passwordRequiredSave", { name: e }) : H("error.io.passwordRequiredSaveUnnamed"));
3072
+ }
3073
+ } else if (p !== null && (m = await this._registry.getEncryption(l), !m)) throw new R(H("error.io.encryptionUnavailable"));
3074
+ let h = `${o.getName() ?? H("workbook.defaultName")}.${c.exts[0]}`, g = r?.progress, _ = !1, v = this, y = null, ee = {
3069
3075
  workbook: e,
3070
3076
  format: c,
3071
3077
  origin: o,
@@ -3098,7 +3104,7 @@ var En, Dn, $ = class e extends he {
3098
3104
  g?.onComplete && await Promise.resolve(g.onComplete(b));
3099
3105
  } catch (e) {
3100
3106
  let t = e instanceof Error ? e : Error(String(e));
3101
- throw g?.onError && await Promise.resolve(g.onError(t)), g?.onComplete && await Promise.resolve(g.onComplete(null)), Error("Unable to write workbook.", { cause: e });
3107
+ throw g?.onError && await Promise.resolve(g.onError(t)), g?.onComplete && await Promise.resolve(g.onComplete(null)), t instanceof R ? t : Error(H("error.io.writeFailed", { reason: t.message }), { cause: e });
3102
3108
  }
3103
3109
  return b;
3104
3110
  }
@@ -3106,7 +3112,7 @@ var En, Dn, $ = class e extends he {
3106
3112
  if (!t) throw Error("A target must be provided for writeAs (use write(workbook) for a plain save).");
3107
3113
  let r = e?.getOrigin?.();
3108
3114
  if (!(r instanceof U)) return this.write(e, t, n);
3109
- let i = typeof t == "string" ? t : t.getPath(), a = i && M(i)?.toLowerCase() || null, o = a ? (await this._registry.getWriteFormats({ search: a }))[0]?.key ?? a : null, s = {
3115
+ let i = typeof t == "string" ? t : t.getPath(), a = i && x(i)?.toLowerCase() || null, o = a ? (await this._registry.getWriteFormats({ search: a }))[0]?.key ?? a : null, s = {
3110
3116
  path: r.getPath(),
3111
3117
  name: r.getName(),
3112
3118
  format: r.getFormat(),
@@ -3127,7 +3133,7 @@ var En, Dn, $ = class e extends he {
3127
3133
  return c;
3128
3134
  }
3129
3135
  _stripExtension(e) {
3130
- let t = M(e);
3136
+ let t = x(e);
3131
3137
  return t ? e.slice(0, e.length - t.length - 1) : e;
3132
3138
  }
3133
3139
  _baseName(e) {
@@ -3136,29 +3142,28 @@ var En, Dn, $ = class e extends he {
3136
3142
  return this._stripExtension(n) || null;
3137
3143
  }
3138
3144
  async _writeArrayBuffer(e, t, n) {
3139
- if (!t) throw Error(`Invalid write type for '${t}'.`);
3140
- try {
3141
- let r = t.handler;
3142
- if (!r) throw Error(`Unable to resolve handler for type: ${t.description ?? t}.`);
3143
- return r(e, {
3144
- ...n,
3145
- format: t.key
3146
- });
3147
- } catch (e) {
3148
- throw Error(`Unable to load handler for '${t}.'`, { cause: e });
3149
- }
3145
+ if (!t) throw Error("A write format must be provided.");
3146
+ let r = t.handler;
3147
+ if (!r) throw Error(`Unable to resolve a write handler for '${t.key}'.`);
3148
+ return r(e, {
3149
+ ...n,
3150
+ format: t.key
3151
+ });
3150
3152
  }
3151
3153
  async _readArrayBuffer(e, t, n) {
3152
3154
  if (!e) throw Error("ArrayBuffer must be specified.");
3153
3155
  if (!t) throw Error("format must be specified.");
3154
3156
  if (e.byteLength === 0) return new kn(n?.createWorkbookOptions);
3155
3157
  let r = t.handler;
3156
- if (!r) throw Error(`Unable to resolve handler for format type: ${t?.description ?? t}.`);
3158
+ if (!r) throw Error(`Unable to resolve a read handler for '${t.key}'.`);
3157
3159
  let i;
3158
3160
  try {
3159
3161
  i = await r(e, n);
3160
3162
  } catch (e) {
3161
- throw Error(`Unable to read ${t.description ?? t.key} — ${e?.message ?? String(e)}`, { cause: e });
3163
+ throw e instanceof R ? e : new R(H("error.io.readFailed", {
3164
+ format: t.description ?? t.key,
3165
+ reason: e?.message ?? String(e)
3166
+ }), { cause: e });
3162
3167
  }
3163
3168
  return i;
3164
3169
  }
@@ -3208,7 +3213,7 @@ function Vn(e = 6e4) {
3208
3213
  return new Date(Math.floor(Date.now() / e) * e);
3209
3214
  }
3210
3215
  zn ||= {};
3211
- var Hn = class extends Ce {
3216
+ var Hn = class extends Ge {
3212
3217
  constructor(e) {
3213
3218
  super(e);
3214
3219
  }
@@ -3224,5 +3229,5 @@ var Hn = class extends Ce {
3224
3229
  getRanges: (e) => null
3225
3230
  }, super._initializeOptions(e);
3226
3231
  }
3227
- }, Un = "0.7.28-beta.2", Wn = "Mon Aug 24 2026";
3228
- export { _e as AddressUtils, Fn as ArrayBackingStore, xe as AutoFill, Wn as BUILD_DATE, r as Color, Ke as Condition, Bn as DateUtils, Nn as DefaultWorkbookIO, gn as ExternalRangeClipboardItem, Ln as FONTS_KIND, Rt as FontUtils, Ee as GeomUtils, at as IAnchored, Be as IBorder, Ve as ICalculation, rt as ICell, Qt as ICellHeaderRange, Fe as ICellRange, Zt as ICellRanges, f as IColor, Te as ICondition, Qe as IConditionalFormat, Ue as IDataValidation, Lt as IEffect, N as IFill, A as IFont, kt as IFontCollection, zn as IMovable, Dn as IPicture, En as IPrint, Xt as IResource, t as ISheet, pe as ISheetView, Ft as ISort, It as IStroke, ne as IStyle, b as ITableStyle, i as IText, x as ITextFrame, Yt as ITheme, _ as IThemeCollection, bt as IWorkbookIO, In as LOCALES_KIND, g as LicenseManager, E as NumberFormat, hn as RangeClipboardItem, o as Registry, st as Resource, me as ResourceCollection, Rn as SHEETXL_RESOURCE_KINDS, oe as SYSTEM_COLOR_CSS_PREFIX, O as Sheet, Ot as SimpleFontFace, et as Sort, lt as StringCollection, ot as StyleCollection, Hn as Table, ue as TextRotation, it as TextUtils, u as Theme, p as ThemeCollection, ie as TransactionConflictError, St as TransactionSaveStateManager, c as TransactionStore, xt as TransactionUndoManager, nt as Tuple, Un as VERSION, kn as Workbook, Pn as WorkbookIO, U as WorkbookOrigin, Q as WorkbookView, Jt as builtInStyleNameDisplay, tt as createCellRangeCounts, tn as getBuiltInFunctionNames, fe as getLanguagePack, De as getLocaleProfile, He as localizeBoolean, Ze as localizeErrorLabel, we as makeLocaleProfile, ge as parseBooleanLocal, Pe as parseErrorLocal, nn as parseFormulaLiteral, Ae as registerSdkLocales };
3232
+ }, Un = "0.7.28-beta.3", Wn = "Mon Aug 24 2026";
3233
+ export { Fe as AddressUtils, Fn as ArrayBackingStore, Se as AutoFill, Wn as BUILD_DATE, w as Color, Re as Condition, Bn as DateUtils, Nn as DefaultWorkbookIO, gn as ExternalRangeClipboardItem, Ln as FONTS_KIND, Rt as FontUtils, De as GeomUtils, lt as IAnchored, Je as IBorder, Ye as ICalculation, xe as ICell, Qt as ICellHeaderRange, nt as ICellRange, Zt as ICellRanges, C as IColor, de as ICondition, ve as IConditionalFormat, Qe as IDataValidation, Lt as IEffect, i as IFill, k as IFont, kt as IFontCollection, zn as IMovable, Dn as IPicture, En as IPrint, Xt as IResource, O as ISheet, He as ISheetView, Ft as ISort, It as IStroke, ut as IStyle, d as ITableStyle, at as IText, a as ITextFrame, Yt as ITheme, re as IThemeCollection, bt as IWorkbookIO, In as LOCALES_KIND, Ke as LicenseManager, M as NumberFormat, hn as RangeClipboardItem, ee as Registry, ie as Resource, st as ResourceCollection, Rn as SHEETXL_RESOURCE_KINDS, p as SYSTEM_COLOR_CSS_PREFIX, A as Sheet, Ot as SimpleFontFace, Be as Sort, he as StringCollection, ae as StyleCollection, Hn as Table, rt as TextRotation, ct as TextUtils, m as Theme, g as ThemeCollection, l as TransactionConflictError, St as TransactionSaveStateManager, s as TransactionStore, xt as TransactionUndoManager, be as Tuple, Un as VERSION, kn as Workbook, Pn as WorkbookIO, U as WorkbookOrigin, Q as WorkbookView, Jt as builtInStyleNameDisplay, et as createCellRangeCounts, tn as getBuiltInFunctionNames, Ve as getLanguagePack, Te as getLocaleProfile, Ze as localizeBoolean, _e as localizeErrorLabel, ue as makeLocaleProfile, Pe as parseBooleanLocal, tt as parseErrorLocal, nn as parseFormulaLiteral, fe as registerSdkLocales };