@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.
- package/browser/cjs/{BREMLtxkQhtNSVra.cjs → BF14ZEAnaqxXroSj.cjs} +1 -1
- package/browser/cjs/{BG7YDVxiC4ErxvF1.cjs → BXtvdT1Z-MsB_o5F.cjs} +1 -1
- package/browser/cjs/Bc4JjVVZfFo3R4He.cjs +33 -0
- package/browser/cjs/{CQf4zxkBmheTVbjX.cjs → CD2RXdnfqSYNc6gX.cjs} +2 -2
- package/browser/cjs/DcLpXGexEtOxi-dD.cjs +1 -0
- package/browser/cjs/index.cjs +2 -2
- package/browser/esm/{DN4d5bDBkti28wuc.mjs → 0Mj5WKM362q6CECb.mjs} +213 -207
- package/browser/esm/{BxIOX1TojvA-1ZZP.mjs → CHSahmMFYNB0Ajkf.mjs} +2 -2
- package/browser/esm/{CZO1RubmqnJV96rq.mjs → CKk58ZLcrllMzfou.mjs} +2 -2
- package/browser/esm/{DRWu3TmcE9JFf78V.mjs → CPTtL2f6_4iblmFM.mjs} +2 -2
- package/browser/esm/{DPOelA1J3WHbMXyh.mjs → CoA-sUxjiIUIpTUF.mjs} +2 -2
- package/browser/esm/{vHWuKF-ftK7LM1uw.mjs → DBIu6NUHIcxOOBQp.mjs} +1 -1
- package/browser/esm/{CB_4gdPPPruwremH.mjs → Dy4Sdpju1T2icURu.mjs} +4748 -3883
- package/browser/esm/index.mjs +419 -411
- package/node/esm/{XQhP3dYwF_tEuswB.mjs → BtGxbEbBm79YvF_k.mjs} +303 -297
- package/node/esm/{B-tgcZihStNV9CbZ.mjs → DUYP6faJJHCaW1Xf.mjs} +1 -1
- package/node/esm/{C8tfYGL3wHy9IDDc.mjs → DqgWsVXROpSgKq6c.mjs} +2 -2
- package/node/esm/index.mjs +8686 -7802
- package/package.json +6 -6
- package/resources/locales/de/model.msg.json +12 -0
- package/resources/locales/en/model.msg.json +12 -0
- package/types/scripting-enums.json +2 -0
- package/types/scripting.d.ts +341 -15
- package/types/src/anchored/IAnchored.d.ts +27 -0
- package/types/src/calculation/Calculation.d.ts +21 -12
- package/types/src/calculation/ICalculation.d.ts +183 -0
- package/types/src/calculation/compiler/CompilerUtils.d.ts +20 -0
- package/types/src/calculation/compiler/FormulaParser.d.ts +32 -6
- package/types/src/calculation/executor/CalcExecutor.d.ts +204 -13
- package/types/src/calculation/executor/CalcExecutorUtils.d.ts +31 -0
- package/types/src/calculation/executor/CircularReference.d.ts +81 -0
- package/types/src/calculation/functions/Operators.d.ts +1 -1
- package/types/src/calculation/grid/CalcGrid.d.ts +5 -1
- package/types/src/calculation/grid/CalcGridUtils.d.ts +3 -2
- package/types/src/calculation/grid/ICalcGrid.d.ts +23 -1
- package/types/src/calculation/spatial/CircularEntry.d.ts +18 -0
- package/types/src/calculation/spatial/index.d.ts +1 -0
- package/types/src/calculation/state/CalcNode.d.ts +24 -17
- package/types/src/calculation/state/CalcState.d.ts +78 -15
- package/types/src/calculation/state/CalculationContext.d.ts +39 -0
- package/types/src/calculation/state/_ReadObservedGrid.d.ts +90 -0
- package/types/src/cell/ICell.d.ts +16 -0
- package/types/src/cellRange/ICellRange.d.ts +72 -6
- package/types/src/condition/AnchoredConditional.d.ts +26 -6
- package/types/src/conditionalFormat/ConditionalFormat.d.ts +8 -1
- package/types/src/conditionalFormat/IConditionalFormat.d.ts +4 -1
- package/types/src/conditionalFormat/IConditionalFormatCollection.d.ts +6 -2
- package/types/src/dataValidation/IDataValidationCollection.d.ts +6 -2
- package/types/src/hyperlink/IHyperlink.d.ts +3 -1
- package/types/src/hyperlink/_Hyperlink.d.ts +6 -0
- package/types/src/lib/utils/utils.browser.d.ts +5 -0
- package/types/src/license/LicenseDetails.d.ts +5 -0
- package/types/src/primitives/CalcSignal.d.ts +20 -0
- package/types/src/protectedRange/IProtectedRangeCollection.d.ts +7 -2
- package/types/src/scripting/_ScriptUtils.d.ts +13 -0
- package/types/src/sheet/Sheet.d.ts +33 -2
- package/types/src/sheet/SheetCell.d.ts +2 -0
- package/types/src/sheet/SheetRange.d.ts +12 -1
- package/types/src/sheet/_SheetStateTypes.d.ts +14 -1
- package/types/src/style/IStyle.d.ts +5 -0
- package/types/src/table/AnchoredTable.d.ts +17 -1
- package/types/src/text/TextUtils.d.ts +18 -0
- package/browser/cjs/DoemwsUQoGCk0vBK.cjs +0 -33
- package/browser/cjs/_c2uwwpr03Y7lzIj.cjs +0 -1
package/browser/esm/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.7.28-beta.
|
|
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 { n as e } from "./
|
|
8
|
-
import { $t as t, At as n,
|
|
9
|
-
import { t as dt } from "./
|
|
7
|
+
import { n as e } from "./DBIu6NUHIcxOOBQp.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 "./Dy4Sdpju1T2icURu.mjs";
|
|
9
|
+
import { t as dt } from "./CPTtL2f6_4iblmFM.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
|
|
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
|
|
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 &&
|
|
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 =
|
|
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 ? `${
|
|
233
|
+
let e = n, t = e?.name, i = t ? `${N(t)}` : "";
|
|
234
234
|
a = await e.arrayBuffer(), o = {
|
|
235
235
|
format: r,
|
|
236
|
-
ext:
|
|
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 =
|
|
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:
|
|
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(
|
|
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 =
|
|
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,
|
|
664
|
-
let
|
|
665
|
-
|
|
666
|
-
let
|
|
667
|
-
t > 0 ? (
|
|
668
|
-
let
|
|
669
|
-
val:
|
|
670
|
-
adjs:
|
|
671
|
-
}, n),
|
|
672
|
-
|
|
673
|
-
let
|
|
674
|
-
return
|
|
675
|
-
description: e.description + ", " +
|
|
676
|
-
definition:
|
|
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,
|
|
680
|
-
let
|
|
681
|
-
for (let
|
|
682
|
-
let
|
|
683
|
-
|
|
684
|
-
let
|
|
685
|
-
for (let
|
|
686
|
-
},
|
|
687
|
-
val: e[
|
|
688
|
-
adjs: e[
|
|
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
|
|
690
|
+
s(c === 0 ? [
|
|
691
691
|
50,
|
|
692
692
|
35,
|
|
693
693
|
25,
|
|
694
694
|
15,
|
|
695
695
|
5
|
|
696
|
-
] :
|
|
696
|
+
] : c === 100 ? [
|
|
697
697
|
-5,
|
|
698
698
|
-15,
|
|
699
699
|
-25,
|
|
700
700
|
-35,
|
|
701
701
|
-50
|
|
702
|
-
] :
|
|
702
|
+
] : c <= 20 ? [
|
|
703
703
|
90,
|
|
704
704
|
75,
|
|
705
705
|
50,
|
|
706
706
|
25,
|
|
707
707
|
10
|
|
708
|
-
] :
|
|
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
|
|
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("./
|
|
728
|
+
let e = import("./CoA-sUxjiIUIpTUF.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
|
|
749
|
+
let i = 0, a = 0;
|
|
750
750
|
if (n.length === 2) {
|
|
751
751
|
let e = n[0].tokenType?.name;
|
|
752
|
-
e === "MinOp" ? (
|
|
752
|
+
e === "MinOp" ? (i = -1, a = 1) : e === "PlusOp" && (i = 1, a = 1);
|
|
753
753
|
}
|
|
754
|
-
if (n.length -
|
|
755
|
-
let
|
|
754
|
+
if (n.length - a !== 1) return;
|
|
755
|
+
let o = n[a], s = o.image;
|
|
756
756
|
try {
|
|
757
|
-
switch (
|
|
757
|
+
switch (o.tokenType?.name) {
|
|
758
758
|
case "NumberToken":
|
|
759
759
|
case "ScientificDigit":
|
|
760
760
|
case "DigitToken": {
|
|
761
|
-
let e =
|
|
762
|
-
return
|
|
761
|
+
let e = oe(s).value;
|
|
762
|
+
return i === 0 ? e : i * e;
|
|
763
763
|
}
|
|
764
|
-
case "StringToken": return
|
|
765
|
-
case "BooleanToken": return
|
|
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
|
|
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 ??
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 &&
|
|
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
|
|
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
|
|
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
|
|
1291
|
+
let o = e.style, s = { ...t };
|
|
1292
1292
|
if (t.msoIgnore) {
|
|
1293
|
-
let e = t.msoIgnore.split(","), n = Object.keys(
|
|
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
|
|
1296
|
+
e.includes(r) && delete s[r];
|
|
1297
1297
|
}
|
|
1298
1298
|
}
|
|
1299
|
-
let
|
|
1300
|
-
|
|
1301
|
-
let
|
|
1302
|
-
|
|
1303
|
-
let
|
|
1304
|
-
if (
|
|
1305
|
-
let e =
|
|
1306
|
-
e && (e.patternType ===
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
let
|
|
1310
|
-
e && (
|
|
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
|
-
|
|
1313
|
-
let
|
|
1314
|
-
|
|
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 =
|
|
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 =
|
|
1368
|
-
let t = r.cells[e], i =
|
|
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 *
|
|
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 =
|
|
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 *
|
|
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 (
|
|
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
|
|
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
|
|
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: () =>
|
|
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
|
|
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:
|
|
1699
|
+
getOptions: j(this._options?.getOptions, n)
|
|
1700
1700
|
}), new e(t, this._internal, this._workbook, r);
|
|
1701
1701
|
}
|
|
1702
|
-
_createRange(e,
|
|
1703
|
-
let
|
|
1704
|
-
if (!
|
|
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
|
|
1707
|
-
scope:
|
|
1706
|
+
return delete n?.scope, wn(n, n ? {
|
|
1707
|
+
scope: h,
|
|
1708
1708
|
...e.getEntireRange().getCoords()
|
|
1709
1709
|
} : null);
|
|
1710
1710
|
}
|
|
1711
|
-
let
|
|
1712
|
-
return
|
|
1711
|
+
let i = this._options;
|
|
1712
|
+
return t && (i = {
|
|
1713
1713
|
...this._options,
|
|
1714
|
-
getOptions:
|
|
1715
|
-
}), new On(e,
|
|
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
|
|
1739
|
+
return ce(this.getCoords(), {
|
|
1740
1740
|
...n,
|
|
1741
1741
|
scope: t.getName()
|
|
1742
|
-
},
|
|
1742
|
+
}, E, ne, e);
|
|
1743
1743
|
}
|
|
1744
1744
|
toString() {
|
|
1745
1745
|
return this.getAddress();
|
|
1746
1746
|
}
|
|
1747
|
-
}, On = class e extends
|
|
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:
|
|
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
|
|
1761
|
-
if (r.validateCoords(t), r.getSheet().isClosed()) return
|
|
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:
|
|
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
|
|
1778
|
+
return E(this.getCoords(), {
|
|
1779
1779
|
...n,
|
|
1780
1780
|
scope: t.getName()
|
|
1781
1781
|
});
|
|
@@ -1786,166 +1786,167 @@ 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
|
|
1790
|
-
this._origin = typeof
|
|
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
|
|
1796
|
-
delete
|
|
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 ??
|
|
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
|
|
1803
|
+
let i = this, a = this._beginCommit({ description: V(r ? "op.openWorkbook" : "op.newWorkbook") });
|
|
1804
1804
|
try {
|
|
1805
|
-
this._strings =
|
|
1806
|
-
let e =
|
|
1807
|
-
e ||= (e) => new
|
|
1808
|
-
let
|
|
1809
|
-
runtime:
|
|
1810
|
-
readonly:
|
|
1811
|
-
disableLoadAutoFit:
|
|
1812
|
-
formulaTransform:
|
|
1813
|
-
opener:
|
|
1814
|
-
transactions:
|
|
1815
|
-
styles:
|
|
1816
|
-
strings:
|
|
1817
|
-
resources:
|
|
1818
|
-
names:
|
|
1819
|
-
workbook:
|
|
1820
|
-
calculation:
|
|
1821
|
-
resolveRange: (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
|
-
|
|
1825
|
-
name:
|
|
1826
|
-
id:
|
|
1827
|
-
visibility:
|
|
1824
|
+
s = e, i._addSheetRef({
|
|
1825
|
+
name: n,
|
|
1826
|
+
id: t,
|
|
1827
|
+
visibility: r ?? O.Visibility.Visible,
|
|
1828
1828
|
sheet: e
|
|
1829
|
-
},
|
|
1829
|
+
}, a);
|
|
1830
1830
|
},
|
|
1831
1831
|
getName: () => {
|
|
1832
|
-
let e =
|
|
1833
|
-
return e ? e.name :
|
|
1832
|
+
let e = i._getSheetRef(s);
|
|
1833
|
+
return e ? e.name : n;
|
|
1834
1834
|
},
|
|
1835
1835
|
setName: (e, t) => {
|
|
1836
|
-
|
|
1836
|
+
i._getSheetRef(s) && i._setSheetName(s, e, t);
|
|
1837
1837
|
},
|
|
1838
1838
|
setNameChangeCallback: (e) => {
|
|
1839
|
-
|
|
1839
|
+
i._sheetOnNameChange.set(t, e);
|
|
1840
1840
|
},
|
|
1841
1841
|
getVisibility: () => {
|
|
1842
|
-
let e =
|
|
1843
|
-
return e ? e.visibility :
|
|
1842
|
+
let e = i._getSheetRef(s);
|
|
1843
|
+
return e ? e.visibility : O.Visibility.Visible;
|
|
1844
1844
|
},
|
|
1845
1845
|
setVisibility: (e, t) => {
|
|
1846
|
-
|
|
1846
|
+
i._setSheetVisibility(s, e, t);
|
|
1847
1847
|
},
|
|
1848
1848
|
setVisibilityCallback: (e) => {
|
|
1849
|
-
|
|
1849
|
+
i._sheetOnVisibilityChange.set(t, e);
|
|
1850
1850
|
},
|
|
1851
|
-
duplicate: () =>
|
|
1851
|
+
duplicate: () => i._duplicateSheet(s),
|
|
1852
1852
|
getIndex: () => {
|
|
1853
|
-
let e =
|
|
1854
|
-
return e ?
|
|
1853
|
+
let e = i._getSheetRef(s);
|
|
1854
|
+
return e ? i._getOffsetForId(e.id, i._getSheetRefs(O.Visibility.VeryHidden)) : a;
|
|
1855
1855
|
},
|
|
1856
|
-
setIndex: (e,
|
|
1857
|
-
let
|
|
1858
|
-
return !!
|
|
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
|
-
|
|
1861
|
+
i._sheetOnIndexChange.set(t, e);
|
|
1862
1862
|
},
|
|
1863
|
-
requestSelect: async () => (
|
|
1864
|
-
source:
|
|
1865
|
-
params:
|
|
1863
|
+
requestSelect: async () => (i._setSelectedSheet(s), await this._emitter.notify("onRequestSelect", {
|
|
1864
|
+
source: i,
|
|
1865
|
+
params: s,
|
|
1866
1866
|
async: !0
|
|
1867
|
-
}),
|
|
1867
|
+
}), i.getSelectedSheet() === s)
|
|
1868
1868
|
}
|
|
1869
1869
|
};
|
|
1870
|
-
return
|
|
1871
|
-
}, this._namedTableSource = new
|
|
1872
|
-
getSheets: () =>
|
|
1873
|
-
addSheetsListener: (e, t) =>
|
|
1874
|
-
}), this._names =
|
|
1875
|
-
addressToRanges: (e) =>
|
|
1876
|
-
getCurrentScope: () =>
|
|
1877
|
-
isReadOnly: () =>
|
|
1878
|
-
transactions:
|
|
1879
|
-
getSources: () =>
|
|
1880
|
-
}), this._ownNames = !
|
|
1881
|
-
runtime:
|
|
1882
|
-
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
|
+
json: r?.calc,
|
|
1883
1884
|
getActiveCell: () => {
|
|
1884
|
-
let e =
|
|
1885
|
+
let e = i.getSelectedSheet(), t = e?.getSelectedRange()?.getCoords();
|
|
1885
1886
|
return t ? {
|
|
1886
1887
|
rowIndex: t.rowStart,
|
|
1887
1888
|
colIndex: t.colStart,
|
|
1888
1889
|
scope: e.getId()
|
|
1889
1890
|
} : null;
|
|
1890
1891
|
},
|
|
1891
|
-
getRange:
|
|
1892
|
-
getRanges:
|
|
1893
|
-
createGraphRanges: (e, t) =>
|
|
1892
|
+
getRange: i.getRange.bind(i),
|
|
1893
|
+
getRanges: i.getRanges.bind(i),
|
|
1894
|
+
createGraphRanges: (e, t) => i._createGraphRanges(e, t),
|
|
1894
1895
|
getSheetIndex: (e) => {
|
|
1895
1896
|
if (e === void 0) {
|
|
1896
|
-
let e =
|
|
1897
|
-
return e ? this._getSheetRefs(
|
|
1897
|
+
let e = i.getSelectedSheet();
|
|
1898
|
+
return e ? this._getSheetRefs(O.Visibility.VeryHidden).findIndex((t) => t.sheet === e) : -1;
|
|
1898
1899
|
}
|
|
1899
|
-
let
|
|
1900
|
+
let t = this._getSheetRefs(O.Visibility.VeryHidden);
|
|
1900
1901
|
e = e.toLowerCase();
|
|
1901
|
-
let
|
|
1902
|
-
for (let
|
|
1902
|
+
let n = t.length;
|
|
1903
|
+
for (let r = 0; r < n; r++) if (t[r].name.toLowerCase() === e) return r;
|
|
1903
1904
|
try {
|
|
1904
1905
|
An.address = e;
|
|
1905
|
-
let
|
|
1906
|
-
if (!
|
|
1907
|
-
let
|
|
1908
|
-
if (!
|
|
1909
|
-
let
|
|
1910
|
-
|
|
1911
|
-
let
|
|
1912
|
-
for (let e = 0; e <
|
|
1906
|
+
let t = this._names.getItems(An);
|
|
1907
|
+
if (!t || t.length === 0) return -1;
|
|
1908
|
+
let n = t[0].getRanges?.()?.getCoords()?.[0]?.scope;
|
|
1909
|
+
if (!n) return -1;
|
|
1910
|
+
let r = this._getSheetRefs(O.Visibility.VeryHidden);
|
|
1911
|
+
n = n.toLowerCase();
|
|
1912
|
+
let i = r.length;
|
|
1913
|
+
for (let e = 0; e < i; e++) if (r[e].name.toLowerCase() === n) return e;
|
|
1913
1914
|
} catch {
|
|
1914
1915
|
return -1;
|
|
1915
1916
|
}
|
|
1916
1917
|
return -1;
|
|
1917
1918
|
},
|
|
1918
|
-
getSheetCount: () =>
|
|
1919
|
+
getSheetCount: () => i.getSheets().getItems({ visibility: O.Visibility.VeryHidden }).length,
|
|
1919
1920
|
getSheetById: (e) => {
|
|
1920
|
-
let
|
|
1921
|
-
for (let
|
|
1921
|
+
let t = i.getSheets().getItems({ visibility: O.Visibility.VeryHidden }), n = t.length;
|
|
1922
|
+
for (let r = 0; r < n; r++) if (t[r].getId() === e) return t[r];
|
|
1922
1923
|
return null;
|
|
1923
1924
|
},
|
|
1924
1925
|
getSheetByName: (e) => {
|
|
1925
1926
|
try {
|
|
1926
|
-
return
|
|
1927
|
+
return i.getSheets().getByName(e) ?? null;
|
|
1927
1928
|
} catch {
|
|
1928
1929
|
return null;
|
|
1929
1930
|
}
|
|
1930
1931
|
},
|
|
1931
|
-
namedCollection:
|
|
1932
|
-
strings:
|
|
1933
|
-
transactions:
|
|
1934
|
-
names:
|
|
1935
|
-
formulaTransform:
|
|
1936
|
-
}), this._ownCalculation = !
|
|
1937
|
-
let
|
|
1932
|
+
namedCollection: i._names,
|
|
1933
|
+
strings: i._strings,
|
|
1934
|
+
transactions: i._transactions,
|
|
1935
|
+
names: r?.names,
|
|
1936
|
+
formulaTransform: t.formulaTransform
|
|
1937
|
+
}), this._ownCalculation = !t.calculation, this._scripts = this._createScripts(), this._ownNames = !t.names, this._options = Object.freeze({ ...t });
|
|
1938
|
+
let n = async () => {
|
|
1938
1939
|
this._ownCalculation && await this._calculation.start(), await this._scripts.start(), this._starting = null;
|
|
1939
1940
|
};
|
|
1940
|
-
this._starting =
|
|
1941
|
+
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
1942
|
if (e) {
|
|
1942
1943
|
let n = this._getSheetRef(e, t);
|
|
1943
1944
|
return n ? [n.sheet] : I.EmptyArray;
|
|
1944
1945
|
}
|
|
1945
1946
|
return this._getSheets(t);
|
|
1946
|
-
}), this._ownCalculation && this._calculation.hydrateNames(), this._emitter.notify("onLoad"),
|
|
1947
|
+
}), this._ownCalculation && this._calculation.hydrateNames(), this._emitter.notify("onLoad"), a.commit({ forceAmend: this._ownTransactions });
|
|
1947
1948
|
} catch (e) {
|
|
1948
|
-
throw
|
|
1949
|
+
throw a.rollback(), e;
|
|
1949
1950
|
}
|
|
1950
1951
|
this._initializing = !1;
|
|
1951
1952
|
}
|
|
@@ -1953,7 +1954,7 @@ var En, Dn, $ = class e extends he {
|
|
|
1953
1954
|
let e = this._getSheetRefs();
|
|
1954
1955
|
for (let t = (e ? e.length : 0) - 1; t >= 0; t--);
|
|
1955
1956
|
let t = this._options;
|
|
1956
|
-
this._isDate1904 = t.runtime?.isDate1904() ?? !1, this._locale = null, this._localeOverrides = null, this._theme = t.theme ?? new
|
|
1957
|
+
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
1958
|
n._emitter.notify("onProtectionChange");
|
|
1958
1959
|
} });
|
|
1959
1960
|
let n = this;
|
|
@@ -2077,19 +2078,19 @@ var En, Dn, $ = class e extends he {
|
|
|
2077
2078
|
let e = this._getSheetRef(this.getSelectedSheetIndex());
|
|
2078
2079
|
return e ? e?.sheet : null;
|
|
2079
2080
|
}
|
|
2080
|
-
getSheet(e,
|
|
2081
|
+
getSheet(e, t = O.Visibility.Visible) {
|
|
2081
2082
|
if (e === void 0) return this.getSelectedSheet();
|
|
2082
2083
|
if (!e) throw Error(H("error.workbook.sheetNameNotProvided"));
|
|
2083
|
-
let
|
|
2084
|
-
if (!
|
|
2085
|
-
return
|
|
2084
|
+
let n = this._getSheetRef(e, t);
|
|
2085
|
+
if (!n) throw new B(H("error.workbook.sheetNameNotFound", { sheetName: e }));
|
|
2086
|
+
return n.sheet;
|
|
2086
2087
|
}
|
|
2087
|
-
getSheetAt(e,
|
|
2088
|
-
let
|
|
2089
|
-
if (!
|
|
2088
|
+
getSheetAt(e, t = O.Visibility.Visible) {
|
|
2089
|
+
let n = this._getSheetRef(e, t);
|
|
2090
|
+
if (!n) throw new B(function(e) {
|
|
2090
2091
|
return H("error.workbook.sheetIndexNotFound", { index: e });
|
|
2091
2092
|
}(e));
|
|
2092
|
-
return
|
|
2093
|
+
return n.sheet;
|
|
2093
2094
|
}
|
|
2094
2095
|
getSheets() {
|
|
2095
2096
|
return this._sheets;
|
|
@@ -2097,18 +2098,18 @@ var En, Dn, $ = class e extends he {
|
|
|
2097
2098
|
addSheet(e) {
|
|
2098
2099
|
return this.getSheets().add(e);
|
|
2099
2100
|
}
|
|
2100
|
-
_getSheets(e =
|
|
2101
|
-
let
|
|
2102
|
-
for (let e = 0; e <
|
|
2103
|
-
return
|
|
2101
|
+
_getSheets(e = O.Visibility.Visible) {
|
|
2102
|
+
let t = this._getSheetRefs(e), n = [], r = t.length;
|
|
2103
|
+
for (let e = 0; e < r; e++) n.push(t[e].sheet);
|
|
2104
|
+
return n;
|
|
2104
2105
|
}
|
|
2105
|
-
_getSheetRefs(e =
|
|
2106
|
-
let
|
|
2107
|
-
return
|
|
2106
|
+
_getSheetRefs(e = O.Visibility.Visible) {
|
|
2107
|
+
let t = this._getState();
|
|
2108
|
+
return t ? e === O.Visibility.Visible ? t.sheetRefsVisible : e === O.Visibility.Hidden ? t.sheetRefsVisibleAndHidden : e === O.Visibility.VeryHidden ? t.sheetRefsAll : I.EmptyArray : [];
|
|
2108
2109
|
}
|
|
2109
|
-
_getSheetRef(e,
|
|
2110
|
-
let
|
|
2111
|
-
return typeof e == "number" ? this._getSheetRefs(
|
|
2110
|
+
_getSheetRef(e, t = O.Visibility.Visible) {
|
|
2111
|
+
let n = null;
|
|
2112
|
+
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
2113
|
}
|
|
2113
2114
|
_validateNewSheetName(e, t = !0) {
|
|
2114
2115
|
if (e == null) return e;
|
|
@@ -2188,100 +2189,100 @@ var En, Dn, $ = class e extends he {
|
|
|
2188
2189
|
}
|
|
2189
2190
|
return this._updateState({ lastId: i }), e;
|
|
2190
2191
|
}
|
|
2191
|
-
_addSheet(e,
|
|
2192
|
-
|
|
2193
|
-
let
|
|
2194
|
-
if (!
|
|
2195
|
-
return e && this._emitter.notify("onSheetsChange"),
|
|
2192
|
+
_addSheet(e, t = null, n = null) {
|
|
2193
|
+
t = this._nextSheetName(t);
|
|
2194
|
+
let r = this._getState(), i = this._createSheet(r.lastId, t, O.Visibility.Visible, n, null);
|
|
2195
|
+
if (!i) throw new R(H("error.workbook.sheetNameBlank"));
|
|
2196
|
+
return e && this._emitter.notify("onSheetsChange"), i;
|
|
2196
2197
|
}
|
|
2197
2198
|
_updateSheetRefStates(e) {
|
|
2198
2199
|
if (this._closed) throw Error(H("error.workbook.modelClosed"));
|
|
2199
2200
|
if (!this._initializing && !this.getProtection().isStructureAllowed()) throw new R(H("error.workbook.protection"));
|
|
2200
|
-
let
|
|
2201
|
-
for (let e = 0; e <
|
|
2201
|
+
let t = e, n = [], r = [], i = t.length;
|
|
2202
|
+
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
2203
|
this._updateState({
|
|
2203
|
-
sheetRefsAll:
|
|
2204
|
-
sheetRefsVisible:
|
|
2205
|
-
sheetRefsVisibleAndHidden:
|
|
2204
|
+
sheetRefsAll: t,
|
|
2205
|
+
sheetRefsVisible: n,
|
|
2206
|
+
sheetRefsVisibleAndHidden: r
|
|
2206
2207
|
});
|
|
2207
2208
|
}
|
|
2208
|
-
_addSheetRef(e,
|
|
2209
|
-
let
|
|
2210
|
-
...
|
|
2209
|
+
_addSheetRef(e, t = null) {
|
|
2210
|
+
let n = this._getState(), r = n.sheetRefsAll, i = Math.max(0, Math.min(r.length, t ?? r.length)), a = [
|
|
2211
|
+
...r.slice(0, i),
|
|
2211
2212
|
e,
|
|
2212
|
-
...
|
|
2213
|
+
...r.slice(i)
|
|
2213
2214
|
];
|
|
2214
|
-
this._updateSheetRefStates(
|
|
2215
|
-
let
|
|
2216
|
-
|
|
2217
|
-
let
|
|
2218
|
-
|
|
2219
|
-
let
|
|
2220
|
-
|
|
2221
|
-
let
|
|
2222
|
-
|
|
2223
|
-
let
|
|
2224
|
-
|
|
2225
|
-
let
|
|
2226
|
-
if (
|
|
2227
|
-
let
|
|
2215
|
+
this._updateSheetRefStates(a);
|
|
2216
|
+
let o = e.sheet, s = e.name.toLowerCase(), c = new Map(n.refsById);
|
|
2217
|
+
c.set(e.id, e);
|
|
2218
|
+
let l = new Map(n.refsByLowerCaseName);
|
|
2219
|
+
l.set(s, e);
|
|
2220
|
+
let u = new Map(n.refsByInstance);
|
|
2221
|
+
u.set(o, e);
|
|
2222
|
+
let d = new Map(n.sheetsById);
|
|
2223
|
+
d.set(e.id, o);
|
|
2224
|
+
let f = new Map(n.sheetsByLowerCaseName);
|
|
2225
|
+
f.set(s, o);
|
|
2226
|
+
let p = this, m = n.listenersSheets;
|
|
2227
|
+
if (o !== void 0) {
|
|
2228
|
+
let t = o.addListeners({
|
|
2228
2229
|
onBeforeDelete: (e) => {
|
|
2229
|
-
|
|
2230
|
+
p._validateDeleteSheet(e);
|
|
2230
2231
|
},
|
|
2231
2232
|
onDelete(e) {
|
|
2232
|
-
let
|
|
2233
|
-
if (!
|
|
2234
|
-
let
|
|
2233
|
+
let t = p._getSheetRef(e, O.Visibility.VeryHidden);
|
|
2234
|
+
if (!t) return;
|
|
2235
|
+
let n = p._beginCommit({ description: H("op.deleteSheet", { name: t.name }) });
|
|
2235
2236
|
try {
|
|
2236
|
-
let
|
|
2237
|
-
|
|
2238
|
-
let c = new Map(
|
|
2239
|
-
c.delete(
|
|
2240
|
-
let l = new Map(
|
|
2241
|
-
l.delete(
|
|
2242
|
-
let u =
|
|
2237
|
+
let r = p._getState(), i = r.sheetRefsAll, a = p._getOffsetForId(t.id, i), s = [...i];
|
|
2238
|
+
s.splice(a, 1), p._updateSheetRefStates(s);
|
|
2239
|
+
let c = new Map(r.refsById);
|
|
2240
|
+
c.delete(t.id);
|
|
2241
|
+
let l = new Map(r.sheetsById);
|
|
2242
|
+
l.delete(t.id);
|
|
2243
|
+
let u = t.name.toLowerCase(), d = new Map(r.refsByLowerCaseName);
|
|
2243
2244
|
d.delete(u);
|
|
2244
|
-
let f = new Map(
|
|
2245
|
+
let f = new Map(r.sheetsByLowerCaseName);
|
|
2245
2246
|
f.delete(u);
|
|
2246
|
-
let
|
|
2247
|
-
|
|
2248
|
-
let h = new Map(
|
|
2249
|
-
h.delete(
|
|
2250
|
-
let g = new Set(
|
|
2251
|
-
g.has(
|
|
2247
|
+
let m = new Map(r.refsByInstance);
|
|
2248
|
+
m.delete(e), r.listenersSheets.get(t.id)();
|
|
2249
|
+
let h = new Map(r.listenersSheets);
|
|
2250
|
+
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");
|
|
2251
|
+
let g = new Set(r.sheetsCreated);
|
|
2252
|
+
g.has(o) && g.delete(o), p._updateState({
|
|
2252
2253
|
refsById: c,
|
|
2253
2254
|
sheetsById: l,
|
|
2254
2255
|
refsByLowerCaseName: d,
|
|
2255
2256
|
sheetsByLowerCaseName: f,
|
|
2256
|
-
refsByInstance:
|
|
2257
|
+
refsByInstance: m,
|
|
2257
2258
|
sheetsCreated: g,
|
|
2258
2259
|
listenersSheets: h
|
|
2259
|
-
}),
|
|
2260
|
+
}), n.commit();
|
|
2260
2261
|
} catch (e) {
|
|
2261
|
-
throw
|
|
2262
|
+
throw n.rollback(), e;
|
|
2262
2263
|
}
|
|
2263
2264
|
}
|
|
2264
|
-
}),
|
|
2265
|
-
|
|
2266
|
-
source:
|
|
2265
|
+
}), r = o.addListeners({ onSelectionChange: (e) => {
|
|
2266
|
+
p.getView().getActiveSheetId() === p._getSheetRef(e)?.id && p._emitter.notify("onSelectionChange", {
|
|
2267
|
+
source: p,
|
|
2267
2268
|
params: e
|
|
2268
2269
|
});
|
|
2269
2270
|
} }, { transactional: !1 });
|
|
2270
|
-
|
|
2271
|
-
|
|
2271
|
+
m = new Map(n.listenersSheets), m.set(e.id, () => {
|
|
2272
|
+
t(), r();
|
|
2272
2273
|
});
|
|
2273
2274
|
}
|
|
2274
|
-
let
|
|
2275
|
-
|
|
2276
|
-
refsById:
|
|
2277
|
-
refsByLowerCaseName:
|
|
2278
|
-
refsByInstance:
|
|
2279
|
-
sheetsById:
|
|
2280
|
-
sheetsByLowerCaseName:
|
|
2281
|
-
listenersSheets:
|
|
2275
|
+
let h = n.lastId;
|
|
2276
|
+
h !== -1 && (h = Math.max(h, e.id)), this._updateState({ lastId: h }), this._updateState({
|
|
2277
|
+
refsById: c,
|
|
2278
|
+
refsByLowerCaseName: l,
|
|
2279
|
+
refsByInstance: u,
|
|
2280
|
+
sheetsById: d,
|
|
2281
|
+
sheetsByLowerCaseName: f,
|
|
2282
|
+
listenersSheets: m
|
|
2282
2283
|
}), this._adjustSheetNamesIfRequired();
|
|
2283
|
-
let
|
|
2284
|
-
return
|
|
2284
|
+
let g = new Set(this._getState().sheetsCreated);
|
|
2285
|
+
return g.add(e.sheet), this._updateState({ sheetsCreated: g }), e;
|
|
2285
2286
|
}
|
|
2286
2287
|
_adjustRemoveSelectionIfRequired(e, t) {
|
|
2287
2288
|
if (this._view.getActiveSheetId() === t) {
|
|
@@ -2290,12 +2291,12 @@ var En, Dn, $ = class e extends he {
|
|
|
2290
2291
|
}
|
|
2291
2292
|
}
|
|
2292
2293
|
_adjustSheetNamesIfRequired() {
|
|
2293
|
-
let e = this._getState(),
|
|
2294
|
-
if (
|
|
2295
|
-
let
|
|
2296
|
-
|
|
2297
|
-
let
|
|
2298
|
-
|
|
2294
|
+
let e = this._getState(), t = e.lastId;
|
|
2295
|
+
if (t === -1) return;
|
|
2296
|
+
let n = this._view.getActiveSheetId();
|
|
2297
|
+
n ??= (this._view.setActiveSheetId(t), t);
|
|
2298
|
+
let r = e.refsById.get(n);
|
|
2299
|
+
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
2300
|
}
|
|
2300
2301
|
_validateDeleteSheet(e) {
|
|
2301
2302
|
if (this._closed) throw Error(H("error.workbook.modelClosed"));
|
|
@@ -2340,7 +2341,7 @@ var En, Dn, $ = class e extends he {
|
|
|
2340
2341
|
}
|
|
2341
2342
|
if (!d && s && a === i && (u.done || !c || !u.done && f(u.value.getCoords(), c) >= 0) && (d = !0), d) {
|
|
2342
2343
|
let e = u;
|
|
2343
|
-
return u =
|
|
2344
|
+
return u = Ce, e;
|
|
2344
2345
|
}
|
|
2345
2346
|
let p = u;
|
|
2346
2347
|
return u = l.next(), p;
|
|
@@ -2352,7 +2353,7 @@ var En, Dn, $ = class e extends he {
|
|
|
2352
2353
|
} };
|
|
2353
2354
|
}
|
|
2354
2355
|
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" ?
|
|
2356
|
+
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
2357
|
try {
|
|
2357
2358
|
let u = null, f = null, p = e.next();
|
|
2358
2359
|
for (; !p.done && r < o;) {
|
|
@@ -2416,21 +2417,21 @@ var En, Dn, $ = class e extends he {
|
|
|
2416
2417
|
}
|
|
2417
2418
|
return c;
|
|
2418
2419
|
}
|
|
2419
|
-
_createRange(e,
|
|
2420
|
-
let
|
|
2421
|
-
if (!
|
|
2420
|
+
_createRange(e, t) {
|
|
2421
|
+
let n = e ? { ...e } : null, r = n ? this._getSheetRef(n.scope, O.Visibility.VeryHidden) : null;
|
|
2422
|
+
if (!r) {
|
|
2422
2423
|
let e = this.getSelectedSheet();
|
|
2423
|
-
return e ? (delete
|
|
2424
|
-
scope:
|
|
2424
|
+
return e ? (delete n?.scope, wn(n, n ? {
|
|
2425
|
+
scope: h,
|
|
2425
2426
|
...e.getEntireRange().getCoords()
|
|
2426
2427
|
} : null)) : void console.warn(H("error.workbook.noVisibleRefs"));
|
|
2427
2428
|
}
|
|
2428
|
-
let
|
|
2429
|
-
return
|
|
2429
|
+
let i = r.sheet, a = null;
|
|
2430
|
+
return t && (a = { getOptions: t }), new On(e, D(i), this, a);
|
|
2430
2431
|
}
|
|
2431
2432
|
_createRanges(e, t) {
|
|
2432
2433
|
let n = this.getSelectedSheet(), r = null;
|
|
2433
|
-
return t && (r = { getOptions: t }), new $(e,
|
|
2434
|
+
return t && (r = { getOptions: t }), new $(e, D(n), this, r);
|
|
2434
2435
|
}
|
|
2435
2436
|
getRange(e, t) {
|
|
2436
2437
|
if (e === void 0) return this.getSelectedRange(t);
|
|
@@ -2439,7 +2440,7 @@ var En, Dn, $ = class e extends he {
|
|
|
2439
2440
|
if (n.length !== 1) throw new R(H("error.address.singleRangeOnlyAlt"));
|
|
2440
2441
|
return this._createRange(n[0], t);
|
|
2441
2442
|
} catch (t) {
|
|
2442
|
-
throw t instanceof B ? new B(t.message) : new R(t.message ??
|
|
2443
|
+
throw t instanceof B ? new B(t.message) : new R(t.message ?? o(e));
|
|
2443
2444
|
}
|
|
2444
2445
|
}
|
|
2445
2446
|
getCell(e) {
|
|
@@ -2450,25 +2451,25 @@ var En, Dn, $ = class e extends he {
|
|
|
2450
2451
|
}
|
|
2451
2452
|
getRanges(e, t) {
|
|
2452
2453
|
let n = this._rangesAddressToCoords(e);
|
|
2453
|
-
if (n.length === 0) throw new R(
|
|
2454
|
+
if (n.length === 0) throw new R(o(e));
|
|
2454
2455
|
return this._createRanges(n, t);
|
|
2455
2456
|
}
|
|
2456
|
-
_createGraphRanges(e,
|
|
2457
|
-
let
|
|
2458
|
-
for (let e = 0; e <
|
|
2459
|
-
let
|
|
2460
|
-
|
|
2457
|
+
_createGraphRanges(e, t) {
|
|
2458
|
+
let n = [];
|
|
2459
|
+
for (let e = 0; e < t.length; e++) {
|
|
2460
|
+
let r = t[e], i = (r.sheetName ? this._getSheetRef(r.sheetName, O.Visibility.VeryHidden) : null)?.sheet ?? this.getSelectedSheet();
|
|
2461
|
+
i && n.push(new je(r, D(i), null));
|
|
2461
2462
|
}
|
|
2462
|
-
for (let t = 0; t < e.length; t++)
|
|
2463
|
-
return
|
|
2463
|
+
for (let t = 0; t < e.length; t++) n.push(e[t]);
|
|
2464
|
+
return n.length === 0 ? null : new $(n, D(this.getSelectedSheet()), this, null);
|
|
2464
2465
|
}
|
|
2465
2466
|
getStats(e) {
|
|
2466
2467
|
if (this._closed) throw Error(H("error.workbook.modelClosed"));
|
|
2467
|
-
let
|
|
2468
|
-
if (
|
|
2469
|
-
let
|
|
2470
|
-
for (let
|
|
2471
|
-
return new on(
|
|
2468
|
+
let t = this._getSheets(O.Visibility.VeryHidden), n = t.length;
|
|
2469
|
+
if (n === 1) return t[0].getStats(e);
|
|
2470
|
+
let r = Array(n);
|
|
2471
|
+
for (let i = 0; i < n; i++) r[i] = t[i].getStats(e);
|
|
2472
|
+
return new on(r);
|
|
2472
2473
|
}
|
|
2473
2474
|
_activeRangeCoords() {
|
|
2474
2475
|
let e = this.getSelectedSheet(), t = e.getSelection().getRanges().getCoords(), n = e.getName(), r = t.length, i = Array(r);
|
|
@@ -2493,7 +2494,7 @@ var En, Dn, $ = class e extends he {
|
|
|
2493
2494
|
getSelectedCell() {
|
|
2494
2495
|
return this.getSelectedSheet().getSelectedCell();
|
|
2495
2496
|
}
|
|
2496
|
-
_rangesAddressToCoords(e, n = !0, r =
|
|
2497
|
+
_rangesAddressToCoords(e, n = !0, r = O.Visibility.Hidden) {
|
|
2497
2498
|
if (!e) throw new R(H("error.address.noAddress"));
|
|
2498
2499
|
let i = this.getSelectedSheet(), a = { ...i?.getEntireRange().getCoords() }, o = i?.getName();
|
|
2499
2500
|
if (o && (a.scope = o), typeof e == "string") {
|
|
@@ -2503,7 +2504,7 @@ var En, Dn, $ = class e extends he {
|
|
|
2503
2504
|
t === "r" ? r.rowStart = r.rowEnd = n.rowIndex : r.colStart = r.colEnd = n.colIndex, e = r;
|
|
2504
2505
|
}
|
|
2505
2506
|
}
|
|
2506
|
-
let s = this, c =
|
|
2507
|
+
let s = this, c = le(e, a, t, (e) => {
|
|
2507
2508
|
if (!n) return null;
|
|
2508
2509
|
if (typeof e == "string") {
|
|
2509
2510
|
let t = s.getNames().getByName(e)?.getRanges?.();
|
|
@@ -2514,10 +2515,10 @@ var En, Dn, $ = class e extends he {
|
|
|
2514
2515
|
for (let e = 0; e < l; e++) this._validateCoords(c[e], r);
|
|
2515
2516
|
return c;
|
|
2516
2517
|
}
|
|
2517
|
-
_validateCoords(e,
|
|
2518
|
+
_validateCoords(e, t = O.Visibility.Visible, n = H("error.sheet.oobRange")) {
|
|
2518
2519
|
if (e === null) return;
|
|
2519
|
-
let
|
|
2520
|
-
if (!L.isRangeWithinRange(e,
|
|
2520
|
+
let r = this.getSheet(e.scope, t).getEntireRange().getCoords();
|
|
2521
|
+
if (!L.isRangeWithinRange(e, r)) throw new B(n);
|
|
2521
2522
|
if (e.rowEnd < e.rowStart || e.colEnd < e.colStart) throw new R(H("error.address.invalidRangeInverted"));
|
|
2522
2523
|
}
|
|
2523
2524
|
_updateSheetRef(e, t) {
|
|
@@ -2558,29 +2559,29 @@ var En, Dn, $ = class e extends he {
|
|
|
2558
2559
|
}
|
|
2559
2560
|
return a;
|
|
2560
2561
|
}
|
|
2561
|
-
_setSheetVisibility(e,
|
|
2562
|
+
_setSheetVisibility(e, t = O.Visibility.Visible, n) {
|
|
2562
2563
|
if (this._closed) throw Error(H("error.workbook.modelClosed"));
|
|
2563
2564
|
if (!this.getProtection().isStructureAllowed()) throw new R(H("error.workbook.protection"));
|
|
2564
|
-
let
|
|
2565
|
-
if (!
|
|
2566
|
-
if (
|
|
2567
|
-
let
|
|
2568
|
-
|
|
2569
|
-
let
|
|
2565
|
+
let r = this._getSheetRef(e, O.Visibility.VeryHidden);
|
|
2566
|
+
if (!r) return null;
|
|
2567
|
+
if (t === r.visibility) return;
|
|
2568
|
+
let i = null, a = "";
|
|
2569
|
+
t === O.Visibility.Visible ? a = V("op.unhideSheet") : t === O.Visibility.Hidden ? a = V("op.hideSheet") : t === O.Visibility.VeryHidden && (a = V("op.veryHideSheet"));
|
|
2570
|
+
let o = this.beginCommit(a);
|
|
2570
2571
|
try {
|
|
2571
2572
|
let e = this._getState().sheetRefsVisible;
|
|
2572
|
-
if (
|
|
2573
|
-
let
|
|
2574
|
-
...
|
|
2575
|
-
visibility:
|
|
2576
|
-
},
|
|
2577
|
-
|
|
2573
|
+
if (t !== O.Visibility.Visible && e.length === 1 && e[0].id === r.id) throw new R(H("error.workbook.sheetOne"));
|
|
2574
|
+
let a = {
|
|
2575
|
+
...r,
|
|
2576
|
+
visibility: t
|
|
2577
|
+
}, s = -1;
|
|
2578
|
+
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
2579
|
} catch (e) {
|
|
2579
|
-
throw
|
|
2580
|
+
throw o.rollback(), e;
|
|
2580
2581
|
}
|
|
2581
2582
|
return this._sheetOnVisibilityChange.forEach((e, t) => {
|
|
2582
|
-
|
|
2583
|
-
}), this._emitter.notify("onSheetsChange"),
|
|
2583
|
+
r.id === t && e();
|
|
2584
|
+
}), this._emitter.notify("onSheetsChange"), i;
|
|
2584
2585
|
}
|
|
2585
2586
|
_moveSheet(e, t, n) {
|
|
2586
2587
|
if (this._closed) throw Error(H("error.workbook.modelClosed"));
|
|
@@ -2612,10 +2613,10 @@ var En, Dn, $ = class e extends he {
|
|
|
2612
2613
|
}
|
|
2613
2614
|
_setSelectedSheet(e) {
|
|
2614
2615
|
if (this._closed) throw Error(H("error.workbook.modelClosed"));
|
|
2615
|
-
let
|
|
2616
|
-
if (!
|
|
2617
|
-
let
|
|
2618
|
-
return
|
|
2616
|
+
let t = this._getSheetRef(e);
|
|
2617
|
+
if (!t) throw new R(yn(e));
|
|
2618
|
+
let n = null;
|
|
2619
|
+
return t.visibility !== O.Visibility.Visible && this._setSheetVisibility(t, O.Visibility.Visible), this._view.setActiveSheetId(t.id), n = t.sheet, n;
|
|
2619
2620
|
}
|
|
2620
2621
|
getProtection() {
|
|
2621
2622
|
return this._protection;
|
|
@@ -2683,24 +2684,24 @@ var En, Dn, $ = class e extends he {
|
|
|
2683
2684
|
}
|
|
2684
2685
|
_fromJSON(e) {
|
|
2685
2686
|
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
|
|
2687
|
-
let
|
|
2687
|
+
e.theme && (this._theme = new m(e.theme), this._styles.setTheme(this._theme));
|
|
2688
|
+
let t = this._strings.beginPersist(), n = this._resources.beginPersist(), r = this._styles.beginPersist();
|
|
2688
2689
|
try {
|
|
2689
|
-
|
|
2690
|
-
let
|
|
2691
|
-
|
|
2692
|
-
let
|
|
2693
|
-
for (let e = 0; e <
|
|
2694
|
-
let
|
|
2695
|
-
|
|
2690
|
+
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 ||= {};
|
|
2691
|
+
let i = e.sheets, a = i.length, o = e.view.activeSheetId ?? null;
|
|
2692
|
+
o !== null && (o = Math.min(Math.max(0, o), a - 1));
|
|
2693
|
+
let s = null, c = null, l = -1;
|
|
2694
|
+
for (let e = 0; e < a; e++) {
|
|
2695
|
+
let t = i[e], n = t.visibility || O.Visibility.Visible, r = e;
|
|
2696
|
+
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
2697
|
}
|
|
2697
|
-
this._updateState({ lastId:
|
|
2698
|
-
let
|
|
2698
|
+
this._updateState({ lastId: c }), e.view.activeSheetId = o ?? s, this.setView(new Q({ json: e.view })), this._adjustSheetNamesIfRequired(), this._listenerProtection?.();
|
|
2699
|
+
let u = this;
|
|
2699
2700
|
this._protection = new vn(e?.protection, this._options?.readonly), this._listenerProtection = this._protection.addListeners({ onChange: (e) => {
|
|
2700
|
-
|
|
2701
|
+
u._emitter.notify("onProtectionChange", { source: e });
|
|
2701
2702
|
} }), e.scripts && (this._scripts = this._createScripts(e.scripts)), this._emitter.notify("onLoad");
|
|
2702
2703
|
} finally {
|
|
2703
|
-
|
|
2704
|
+
r.endPersist(), n.endPersist(), t.endPersist();
|
|
2704
2705
|
}
|
|
2705
2706
|
}
|
|
2706
2707
|
_createScripts(e) {
|
|
@@ -2712,7 +2713,7 @@ var En, Dn, $ = class e extends he {
|
|
|
2712
2713
|
getBuiltInFunctions: () => t._calculation?.getFunctions(),
|
|
2713
2714
|
onAdd: (e, n) => {
|
|
2714
2715
|
let r = t._calculation;
|
|
2715
|
-
r.getStatus() !==
|
|
2716
|
+
r.getStatus() !== Ye.Status.Off && r.start().then(async () => {
|
|
2716
2717
|
let e = n.getFunctions().getItems({ type: "formula" }), t = e.length;
|
|
2717
2718
|
for (let n = 0; n < t; n++) {
|
|
2718
2719
|
let t = e[n];
|
|
@@ -2730,47 +2731,49 @@ var En, Dn, $ = class e extends he {
|
|
|
2730
2731
|
async toJSON(e) {
|
|
2731
2732
|
if (this._closed) throw Error(H("error.workbook.modelClosed"));
|
|
2732
2733
|
await Promise.resolve(this._starting), await this._emitter.notify("onBeforeSave", { async: !0 });
|
|
2733
|
-
let
|
|
2734
|
-
if (!
|
|
2734
|
+
let t = { sheets: [] }, n = e?.ignoreStyles ?? !1;
|
|
2735
|
+
if (!n) {
|
|
2735
2736
|
let e = this._theme.toJSON();
|
|
2736
|
-
(e ? Object.keys(e).length : 0) > 0 && (
|
|
2737
|
+
(e ? Object.keys(e).length : 0) > 0 && (t.theme = e);
|
|
2737
2738
|
}
|
|
2738
2739
|
if (this._scripts) {
|
|
2739
2740
|
let e = this._scripts.toJSON();
|
|
2740
|
-
e && Object.keys(e).length > 0 && (
|
|
2741
|
+
e && Object.keys(e).length > 0 && (t.scripts = e);
|
|
2741
2742
|
}
|
|
2742
|
-
this._isDate1904 && (
|
|
2743
|
-
let
|
|
2743
|
+
this._isDate1904 && (t.date1904 = !0), this._locale && (t.locale = this._locale), this._localeOverrides && (t.localeOverrides = this._localeOverrides);
|
|
2744
|
+
let r = e?.ignoreResources ?? !1, i = this._strings.beginPersist(), a = r ? null : this._resources.beginPersist(), o = this._styles.beginPersist();
|
|
2744
2745
|
try {
|
|
2745
|
-
let
|
|
2746
|
-
for (let
|
|
2747
|
-
let
|
|
2748
|
-
name:
|
|
2749
|
-
sheet:
|
|
2746
|
+
let s = this._getSheetRef(this.getSelectedSheetIndex()).id, c = s, l = null, u = this._getState(), d = u.sheetRefsAll, f = u.sheetsById, p = d.length;
|
|
2747
|
+
for (let n = 0; n < p; n++) {
|
|
2748
|
+
let r = d[n], i = n + 1, a = await f.get(r.id).toJSON(e), o = {
|
|
2749
|
+
name: r.name,
|
|
2750
|
+
sheet: a
|
|
2750
2751
|
};
|
|
2751
|
-
|
|
2752
|
+
r.visibility === O.Visibility.Visible ? l === null && (l = i) : o.visibility = r.visibility, r.id === s && (c = i), t.sheets.push(o);
|
|
2752
2753
|
}
|
|
2753
|
-
if (!
|
|
2754
|
-
let e =
|
|
2755
|
-
e && Object.keys(e).length > 0 && (
|
|
2754
|
+
if (!n) {
|
|
2755
|
+
let e = o.toJSON();
|
|
2756
|
+
e && Object.keys(e).length > 0 && (t.styles = e);
|
|
2756
2757
|
}
|
|
2757
|
-
let
|
|
2758
|
-
|
|
2759
|
-
let
|
|
2760
|
-
|
|
2758
|
+
let m = this.getProtection().toJSON();
|
|
2759
|
+
m && (t.protection = m);
|
|
2760
|
+
let h = this._calculation.toJSON();
|
|
2761
|
+
Object.keys(h).length > 0 && (t.calc = h);
|
|
2762
|
+
let g = await i.toJSONAsync();
|
|
2763
|
+
g && g.length > 0 && (t.strings = g);
|
|
2761
2764
|
let _ = this._externalBooks.toJSON();
|
|
2762
|
-
if (_ && (
|
|
2763
|
-
let e = await
|
|
2764
|
-
e && e.length > 0 && (
|
|
2765
|
+
if (_ && (t.externalBooks = _), !r) {
|
|
2766
|
+
let e = await a.toJSONAsync();
|
|
2767
|
+
e && e.length > 0 && (t.resources = e);
|
|
2765
2768
|
}
|
|
2766
2769
|
let v = this._calculation.getNamedFormulas().toJSON();
|
|
2767
|
-
v && v.length > 0 && (
|
|
2770
|
+
v && v.length > 0 && (t.names = v);
|
|
2768
2771
|
let y = this._view.toJSON();
|
|
2769
|
-
y && (
|
|
2772
|
+
y && (c === l ? delete y.activeSheetId : y.activeSheetId = c, Object.keys(y).length > 0 && (t.view = y));
|
|
2770
2773
|
} finally {
|
|
2771
|
-
|
|
2774
|
+
o.endPersist(), r || a.endPersist(), i.endPersist();
|
|
2772
2775
|
}
|
|
2773
|
-
return this._emitter.notify("onSave", { params:
|
|
2776
|
+
return this._emitter.notify("onSave", { params: t }), t;
|
|
2774
2777
|
}
|
|
2775
2778
|
isClosed() {
|
|
2776
2779
|
return this._closed;
|
|
@@ -2911,7 +2914,7 @@ var En, Dn, $ = class e extends he {
|
|
|
2911
2914
|
}
|
|
2912
2915
|
}, Mn = (e) => !!e && typeof e == "object" && typeof e.getPath == "function" && typeof e.canWrite == "function", Nn = class {
|
|
2913
2916
|
constructor() {
|
|
2914
|
-
this._setInstalled = /* @__PURE__ */ new WeakSet(), this._backingStore = null, this._emitter = new
|
|
2917
|
+
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
2918
|
}
|
|
2916
2919
|
getBackingStore() {
|
|
2917
2920
|
return this._backingStore ?? this._defaultStore;
|
|
@@ -2970,7 +2973,7 @@ var En, Dn, $ = class e extends he {
|
|
|
2970
2973
|
search: i,
|
|
2971
2974
|
ext: a
|
|
2972
2975
|
}))[0];
|
|
2973
|
-
if (!o) throw
|
|
2976
|
+
if (!o) throw new R(H("error.io.readFormatUnavailable", { format: i ?? a }));
|
|
2974
2977
|
let s = n?.typedCreateWorkbookOptions, c = s ? Object.keys(s).find((e) => e.toLowerCase() === o.key.toLowerCase()) : void 0, l = {
|
|
2975
2978
|
...n,
|
|
2976
2979
|
...c === void 0 ? void 0 : s[c]
|
|
@@ -3031,7 +3034,10 @@ var En, Dn, $ = class e extends he {
|
|
|
3031
3034
|
bytes: i,
|
|
3032
3035
|
password: n.password
|
|
3033
3036
|
};
|
|
3034
|
-
if (!n?.onPassword)
|
|
3037
|
+
if (!n?.onPassword) {
|
|
3038
|
+
let e = t.getName();
|
|
3039
|
+
throw new vt(e ? H("error.io.passwordRequired", { name: e }) : H("error.io.passwordRequiredUnnamed"));
|
|
3040
|
+
}
|
|
3035
3041
|
let o = await Promise.resolve(n.onPassword({
|
|
3036
3042
|
origin: t,
|
|
3037
3043
|
encryption: r.key,
|
|
@@ -3042,12 +3048,12 @@ var En, Dn, $ = class e extends he {
|
|
|
3042
3048
|
bytes: i,
|
|
3043
3049
|
password: o
|
|
3044
3050
|
};
|
|
3045
|
-
throw new ht();
|
|
3051
|
+
throw new ht(H("error.io.passwordIncorrect"));
|
|
3046
3052
|
}
|
|
3047
3053
|
async writeArrayBuffer(e, t) {
|
|
3048
3054
|
if (!t?.format) throw Error("A format must be specified to write to an ArrayBuffer (e.g. { format: 'xlsx' }).");
|
|
3049
3055
|
let n = (await this._registry.getWriteFormats({ search: t.format }))[0];
|
|
3050
|
-
if (!n) throw
|
|
3056
|
+
if (!n) throw new R(H("error.io.writeFormatUnavailable", { format: t.format }));
|
|
3051
3057
|
return this._writeArrayBuffer(e, n, t);
|
|
3052
3058
|
}
|
|
3053
3059
|
async write(e, t, n) {
|
|
@@ -3056,16 +3062,19 @@ var En, Dn, $ = class e extends he {
|
|
|
3056
3062
|
let r = n, i = null;
|
|
3057
3063
|
typeof t == "string" ? i = this.getOrigin(t) : Mn(t) ? i = t : t && (r = t);
|
|
3058
3064
|
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
|
|
3065
|
+
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
3066
|
if (i && typeof t == "string") {
|
|
3061
3067
|
let e = i.getPath();
|
|
3062
|
-
e && !
|
|
3068
|
+
e && !x(e) && i.update?.({ path: `${e}.${c.exts[0]}` });
|
|
3063
3069
|
}
|
|
3064
3070
|
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
3071
|
if (p === void 0) {
|
|
3066
|
-
if (f)
|
|
3067
|
-
|
|
3068
|
-
|
|
3072
|
+
if (f) {
|
|
3073
|
+
let e = o.getName();
|
|
3074
|
+
throw new vt(e ? H("error.io.passwordRequiredSave", { name: e }) : H("error.io.passwordRequiredSaveUnnamed"));
|
|
3075
|
+
}
|
|
3076
|
+
} else if (p !== null && (m = await this._registry.getEncryption(l), !m)) throw new R(H("error.io.encryptionUnavailable"));
|
|
3077
|
+
let h = `${o.getName() ?? H("workbook.defaultName")}.${c.exts[0]}`, g = r?.progress, _ = !1, v = this, y = null, ee = {
|
|
3069
3078
|
workbook: e,
|
|
3070
3079
|
format: c,
|
|
3071
3080
|
origin: o,
|
|
@@ -3098,7 +3107,7 @@ var En, Dn, $ = class e extends he {
|
|
|
3098
3107
|
g?.onComplete && await Promise.resolve(g.onComplete(b));
|
|
3099
3108
|
} catch (e) {
|
|
3100
3109
|
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("
|
|
3110
|
+
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
3111
|
}
|
|
3103
3112
|
return b;
|
|
3104
3113
|
}
|
|
@@ -3106,7 +3115,7 @@ var En, Dn, $ = class e extends he {
|
|
|
3106
3115
|
if (!t) throw Error("A target must be provided for writeAs (use write(workbook) for a plain save).");
|
|
3107
3116
|
let r = e?.getOrigin?.();
|
|
3108
3117
|
if (!(r instanceof U)) return this.write(e, t, n);
|
|
3109
|
-
let i = typeof t == "string" ? t : t.getPath(), a = i &&
|
|
3118
|
+
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
3119
|
path: r.getPath(),
|
|
3111
3120
|
name: r.getName(),
|
|
3112
3121
|
format: r.getFormat(),
|
|
@@ -3127,7 +3136,7 @@ var En, Dn, $ = class e extends he {
|
|
|
3127
3136
|
return c;
|
|
3128
3137
|
}
|
|
3129
3138
|
_stripExtension(e) {
|
|
3130
|
-
let t =
|
|
3139
|
+
let t = x(e);
|
|
3131
3140
|
return t ? e.slice(0, e.length - t.length - 1) : e;
|
|
3132
3141
|
}
|
|
3133
3142
|
_baseName(e) {
|
|
@@ -3136,29 +3145,28 @@ var En, Dn, $ = class e extends he {
|
|
|
3136
3145
|
return this._stripExtension(n) || null;
|
|
3137
3146
|
}
|
|
3138
3147
|
async _writeArrayBuffer(e, t, n) {
|
|
3139
|
-
if (!t) throw Error(
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
});
|
|
3147
|
-
} catch (e) {
|
|
3148
|
-
throw Error(`Unable to load handler for '${t}.'`, { cause: e });
|
|
3149
|
-
}
|
|
3148
|
+
if (!t) throw Error("A write format must be provided.");
|
|
3149
|
+
let r = t.handler;
|
|
3150
|
+
if (!r) throw Error(`Unable to resolve a write handler for '${t.key}'.`);
|
|
3151
|
+
return r(e, {
|
|
3152
|
+
...n,
|
|
3153
|
+
format: t.key
|
|
3154
|
+
});
|
|
3150
3155
|
}
|
|
3151
3156
|
async _readArrayBuffer(e, t, n) {
|
|
3152
3157
|
if (!e) throw Error("ArrayBuffer must be specified.");
|
|
3153
3158
|
if (!t) throw Error("format must be specified.");
|
|
3154
3159
|
if (e.byteLength === 0) return new kn(n?.createWorkbookOptions);
|
|
3155
3160
|
let r = t.handler;
|
|
3156
|
-
if (!r) throw Error(`Unable to resolve handler for
|
|
3161
|
+
if (!r) throw Error(`Unable to resolve a read handler for '${t.key}'.`);
|
|
3157
3162
|
let i;
|
|
3158
3163
|
try {
|
|
3159
3164
|
i = await r(e, n);
|
|
3160
3165
|
} catch (e) {
|
|
3161
|
-
throw
|
|
3166
|
+
throw e instanceof R ? e : new R(H("error.io.readFailed", {
|
|
3167
|
+
format: t.description ?? t.key,
|
|
3168
|
+
reason: e?.message ?? String(e)
|
|
3169
|
+
}), { cause: e });
|
|
3162
3170
|
}
|
|
3163
3171
|
return i;
|
|
3164
3172
|
}
|
|
@@ -3208,7 +3216,7 @@ function Vn(e = 6e4) {
|
|
|
3208
3216
|
return new Date(Math.floor(Date.now() / e) * e);
|
|
3209
3217
|
}
|
|
3210
3218
|
zn ||= {};
|
|
3211
|
-
var Hn = class extends
|
|
3219
|
+
var Hn = class extends Ge {
|
|
3212
3220
|
constructor(e) {
|
|
3213
3221
|
super(e);
|
|
3214
3222
|
}
|
|
@@ -3224,5 +3232,5 @@ var Hn = class extends Ce {
|
|
|
3224
3232
|
getRanges: (e) => null
|
|
3225
3233
|
}, super._initializeOptions(e);
|
|
3226
3234
|
}
|
|
3227
|
-
}, Un = "0.7.28-beta.
|
|
3228
|
-
export {
|
|
3235
|
+
}, Un = "0.7.28-beta.4", Wn = "Wed Aug 26 2026";
|
|
3236
|
+
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 };
|