ooxml-core 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{PptxHandler-G63S6YZU.mjs → PptxHandler-75LOVF7I.mjs} +2 -2
- package/dist/automation/index.cjs +2559 -1169
- package/dist/automation/index.mjs +2559 -1169
- package/dist/chart/gradient-definition.d.ts +2 -2
- package/dist/chart/gradient-definition.d.ts.map +1 -1
- package/dist/chart/index.cjs +7 -7
- package/dist/chart/index.mjs +7 -7
- package/dist/{chunk-BICQYRPW.mjs → chunk-75LA7H3F.mjs} +1339 -1435
- package/dist/{chunk-CKJSWE7N.mjs → chunk-LA7D6ZYQ.mjs} +244 -115
- package/dist/{chunk-ROM5MZ7O.mjs → chunk-OMGH6IKY.mjs} +3 -3
- package/dist/{chunk-RWXFQJVF.mjs → chunk-Q27H4HFS.mjs} +1 -1
- package/dist/{chunk-DDG5HTGX.mjs → chunk-RFX7AJDZ.mjs} +1 -1
- package/dist/crypto/index.cjs +1406 -184
- package/dist/crypto/index.mjs +1406 -184
- package/dist/diagram/dom.d.ts +1 -14
- package/dist/diagram/dom.d.ts.map +1 -1
- package/dist/diagram/index.cjs +15 -15
- package/dist/diagram/index.d.ts +12 -12
- package/dist/diagram/index.d.ts.map +1 -1
- package/dist/diagram/index.mjs +15 -15
- package/dist/diagram/types.d.ts +12 -148
- package/dist/diagram/types.d.ts.map +1 -1
- package/dist/digest/algorithm-names.d.ts +2 -2
- package/dist/digest/algorithm-names.d.ts.map +1 -1
- package/dist/digest/bit-ops.d.ts +30 -0
- package/dist/digest/bit-ops.d.ts.map +1 -0
- package/dist/digest/digest.d.ts +2 -2
- package/dist/digest/digest.d.ts.map +1 -1
- package/dist/digest/index.cjs +1319 -90
- package/dist/digest/index.d.ts +7 -1
- package/dist/digest/index.d.ts.map +1 -1
- package/dist/digest/index.mjs +1313 -91
- package/dist/digest/md2.d.ts +22 -0
- package/dist/digest/md2.d.ts.map +1 -0
- package/dist/digest/md4.d.ts +3 -0
- package/dist/digest/md4.d.ts.map +1 -0
- package/dist/digest/md5.d.ts +3 -0
- package/dist/digest/md5.d.ts.map +1 -0
- package/dist/digest/password-hash.d.ts +7 -0
- package/dist/digest/password-hash.d.ts.map +1 -1
- package/dist/digest/ripemd-functions.d.ts +18 -0
- package/dist/digest/ripemd-functions.d.ts.map +1 -0
- package/dist/digest/ripemd128.d.ts +3 -0
- package/dist/digest/ripemd128.d.ts.map +1 -0
- package/dist/digest/ripemd160.d.ts +3 -0
- package/dist/digest/ripemd160.d.ts.map +1 -0
- package/dist/digest/whirlpool-sbox.d.ts +15 -0
- package/dist/digest/whirlpool-sbox.d.ts.map +1 -0
- package/dist/digest/whirlpool-table.d.ts +12 -0
- package/dist/digest/whirlpool-table.d.ts.map +1 -0
- package/dist/digest/whirlpool.d.ts +3 -0
- package/dist/digest/whirlpool.d.ts.map +1 -0
- package/dist/docx/block-parser.d.ts.map +1 -1
- package/dist/docx/diagram-theme.d.ts +3 -3
- package/dist/docx/diagram-theme.d.ts.map +1 -1
- package/dist/docx/embedded.cjs +470 -276
- package/dist/docx/embedded.mjs +470 -276
- package/dist/docx/field-flags.d.ts +8 -0
- package/dist/docx/field-flags.d.ts.map +1 -0
- package/dist/docx/field-lock.d.ts +6 -0
- package/dist/docx/field-lock.d.ts.map +1 -0
- package/dist/docx/field-runs.d.ts +4 -1
- package/dist/docx/field-runs.d.ts.map +1 -1
- package/dist/docx/index.cjs +1029 -850
- package/dist/docx/index.d.ts +2 -0
- package/dist/docx/index.d.ts.map +1 -1
- package/dist/docx/index.mjs +1027 -850
- package/dist/docx/layout/adapter.d.ts.map +1 -1
- package/dist/docx/layout/index.cjs +61 -47
- package/dist/docx/layout/index.mjs +61 -47
- package/dist/docx/layout/page-fields.d.ts.map +1 -1
- package/dist/docx/load/index.cjs +1883 -467
- package/dist/docx/load/index.mjs +1883 -467
- package/dist/docx/model-run.d.ts +5 -0
- package/dist/docx/model-run.d.ts.map +1 -1
- package/dist/docx/numbering-model.d.ts +1 -1
- package/dist/docx/numbering-model.d.ts.map +1 -1
- package/dist/docx/numbering-package.d.ts +4 -4
- package/dist/docx/numbering-package.d.ts.map +1 -1
- package/dist/docx/numbering-start-edit.d.ts +8 -0
- package/dist/docx/numbering-start-edit.d.ts.map +1 -0
- package/dist/docx/numbering-start-patch.d.ts +13 -0
- package/dist/docx/numbering-start-patch.d.ts.map +1 -0
- package/dist/docx/theme-color.d.ts.map +1 -1
- package/dist/docx/theme-model.d.ts +3 -2
- package/dist/docx/theme-model.d.ts.map +1 -1
- package/dist/docx/theme.d.ts +5 -1
- package/dist/docx/theme.d.ts.map +1 -1
- package/dist/docx/ui/field-guard.d.ts +2 -0
- package/dist/docx/ui/field-guard.d.ts.map +1 -1
- package/dist/docx/ui/field-results.d.ts.map +1 -1
- package/dist/docx/ui/index.cjs +547 -375
- package/dist/docx/ui/index.mjs +547 -376
- package/dist/docx/ui/review-commands.d.ts.map +1 -1
- package/dist/docx/ui/run-extra-mark.d.ts +1 -1
- package/dist/docx/ui/run-extra-mark.d.ts.map +1 -1
- package/dist/docx/ui/simple-field-input.d.ts +3 -0
- package/dist/docx/ui/simple-field-input.d.ts.map +1 -1
- package/dist/docx/ui/track-changes-mode.d.ts.map +1 -1
- package/dist/docx/ui/track-paragraph-boundaries.d.ts +5 -0
- package/dist/docx/ui/track-paragraph-boundaries.d.ts.map +1 -0
- package/dist/docx/write-inline.d.ts.map +1 -1
- package/dist/docx/write-run.d.ts.map +1 -1
- package/dist/drawingml/dom.d.ts +15 -0
- package/dist/drawingml/dom.d.ts.map +1 -0
- package/dist/drawingml/drawing-color-brightness.d.ts +6 -0
- package/dist/drawingml/drawing-color-brightness.d.ts.map +1 -0
- package/dist/drawingml/drawing-color-css.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/drawing-color.d.ts +5 -5
- package/dist/drawingml/drawing-color.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/drawing-fill.d.ts +3 -3
- package/dist/drawingml/drawing-fill.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/drawing-geometry.d.ts +4 -4
- package/dist/drawingml/drawing-geometry.d.ts.map +1 -0
- package/dist/drawingml/drawing-shadow.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/drawing-text.d.ts +2 -2
- package/dist/drawingml/drawing-text.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/gradient-geometry.d.ts +2 -2
- package/dist/drawingml/gradient-geometry.d.ts.map +1 -0
- package/dist/drawingml/gradient-preset-data.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/gradient-presets.d.ts +3 -3
- package/dist/drawingml/gradient-presets.d.ts.map +1 -0
- package/dist/drawingml/index.cjs +1545 -0
- package/dist/drawingml/index.d.ts +19 -0
- package/dist/drawingml/index.d.ts.map +1 -0
- package/dist/drawingml/index.mjs +1497 -0
- package/dist/{diagram → drawingml}/ordered-color-transforms.d.ts +2 -2
- package/dist/drawingml/ordered-color-transforms.d.ts.map +1 -0
- package/dist/drawingml/rect-path-gradient.d.ts.map +1 -0
- package/dist/drawingml/theme-color.d.ts +19 -0
- package/dist/drawingml/theme-color.d.ts.map +1 -0
- package/dist/drawingml/theme-model.d.ts +40 -0
- package/dist/drawingml/theme-model.d.ts.map +1 -0
- package/dist/drawingml/theme.d.ts +21 -0
- package/dist/drawingml/theme.d.ts.map +1 -0
- package/dist/drawingml/types.d.ts +152 -0
- package/dist/drawingml/types.d.ts.map +1 -0
- package/dist/drawingml/write-color.d.ts +4 -0
- package/dist/drawingml/write-color.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/write-fill.d.ts +2 -2
- package/dist/drawingml/write-fill.d.ts.map +1 -0
- package/dist/geometry/connector-elbow-geometry.d.ts +14 -0
- package/dist/geometry/connector-elbow-geometry.d.ts.map +1 -1
- package/dist/geometry/index.cjs +43 -0
- package/dist/geometry/index.mjs +42 -1
- package/dist/i18n/dictionary.d.ts +13 -0
- package/dist/i18n/dictionary.d.ts.map +1 -0
- package/dist/i18n/index.cjs +68 -0
- package/dist/i18n/index.d.ts +4 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.mjs +60 -0
- package/dist/i18n/locale.d.ts +17 -0
- package/dist/i18n/locale.d.ts.map +1 -0
- package/dist/i18n/translator.d.ts +18 -0
- package/dist/i18n/translator.d.ts.map +1 -0
- package/dist/index.cjs +3712 -2178
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +3711 -2179
- package/dist/pptx/automation/index.cjs +2852 -1568
- package/dist/pptx/automation/index.d.ts +3 -3
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/chunks/{index-C4mfzVoY.d.ts → index-BHqL5KXH.d.ts} +2 -2
- package/dist/pptx/chunks/{index-C4mfzVoY.d.ts.map → index-BHqL5KXH.d.ts.map} +1 -1
- package/dist/pptx/chunks/{index-lk7dyOPS.d.ts → index-BYkdcS8J.d.ts} +12 -16
- package/dist/pptx/chunks/index-BYkdcS8J.d.ts.map +1 -0
- package/dist/pptx/chunks/smart-art-CO2jmJFf.d.ts.map +1 -1
- package/dist/pptx/chunks/{text-operations-CDLx4hD5.d.ts → text-operations-DEJ7alZR.d.ts} +2 -2
- package/dist/pptx/chunks/text-operations-DEJ7alZR.d.ts.map +1 -0
- package/dist/pptx/cli/index.cjs +2680 -1396
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/index.cjs +1771 -1756
- package/dist/pptx/index.d.ts +3 -3
- package/dist/pptx/index.mjs +5 -5
- package/dist/teams/index.cjs +144 -74
- package/dist/teams/index.mjs +144 -74
- package/dist/visio/ui/index.cjs +14 -3
- package/dist/visio/ui/index.mjs +14 -3
- package/dist/visio/ui/shape-rotation.d.ts +1 -1
- package/dist/visio/ui/shape-rotation.d.ts.map +1 -1
- package/dist/xlsx/edit/chart-series-gradient.d.ts +1 -1
- package/dist/xlsx/edit/chart-series-gradient.d.ts.map +1 -1
- package/dist/xlsx/edit/protection.d.ts +1 -1
- package/dist/xlsx/index.cjs +3222 -1886
- package/dist/xlsx/index.mjs +3222 -1886
- package/dist/xlsx/layout/chart-appearance.d.ts +1 -1
- package/dist/xlsx/layout/chart-appearance.d.ts.map +1 -1
- package/dist/xlsx/layout/chart-scale.d.ts +5 -1
- package/dist/xlsx/layout/chart-scale.d.ts.map +1 -1
- package/dist/xlsx/layout/chart-svg-legend.d.ts +13 -0
- package/dist/xlsx/layout/chart-svg-legend.d.ts.map +1 -0
- package/dist/xlsx/layout/chart-svg.d.ts.map +1 -1
- package/dist/xlsx/layout/chart-view.d.ts +3 -1
- package/dist/xlsx/layout/chart-view.d.ts.map +1 -1
- package/dist/xlsx/load/index.cjs +2110 -838
- package/dist/xlsx/load/index.mjs +2110 -838
- package/dist/xlsx/read/theme.d.ts +2 -4
- package/dist/xlsx/read/theme.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +2017 -771
- package/dist/xlsx/ui/index.mjs +2017 -771
- package/dist/xlsx/ui/locales/merge.d.ts +2 -1
- package/dist/xlsx/ui/locales/merge.d.ts.map +1 -1
- package/dist/xlsx/ui/localization.d.ts.map +1 -1
- package/dist/xlsx/write/theme.d.ts.map +1 -1
- package/package.json +11 -1
- package/dist/diagram/drawing-color-brightness.d.ts +0 -6
- package/dist/diagram/drawing-color-brightness.d.ts.map +0 -1
- package/dist/diagram/drawing-color-css.d.ts.map +0 -1
- package/dist/diagram/drawing-color.d.ts.map +0 -1
- package/dist/diagram/drawing-fill.d.ts.map +0 -1
- package/dist/diagram/drawing-geometry.d.ts.map +0 -1
- package/dist/diagram/drawing-shadow.d.ts.map +0 -1
- package/dist/diagram/drawing-text.d.ts.map +0 -1
- package/dist/diagram/gradient-geometry.d.ts.map +0 -1
- package/dist/diagram/gradient-preset-data.d.ts.map +0 -1
- package/dist/diagram/gradient-presets.d.ts.map +0 -1
- package/dist/diagram/ordered-color-transforms.d.ts.map +0 -1
- package/dist/diagram/rect-path-gradient.d.ts.map +0 -1
- package/dist/diagram/write-color.d.ts +0 -4
- package/dist/diagram/write-color.d.ts.map +0 -1
- package/dist/diagram/write-fill.d.ts.map +0 -1
- package/dist/pptx/chunks/index-lk7dyOPS.d.ts.map +0 -1
- package/dist/pptx/chunks/text-operations-CDLx4hD5.d.ts.map +0 -1
- /package/dist/{diagram → drawingml}/drawing-color-css.d.ts +0 -0
- /package/dist/{diagram → drawingml}/drawing-shadow.d.ts +0 -0
- /package/dist/{diagram → drawingml}/gradient-preset-data.d.ts +0 -0
- /package/dist/{diagram → drawingml}/rect-path-gradient.d.ts +0 -0
package/dist/xlsx/ui/index.cjs
CHANGED
|
@@ -844,7 +844,7 @@ var FORMAT_PRESETS = [
|
|
|
844
844
|
var isDigit = (t) => t?.t === "digit";
|
|
845
845
|
function fractionSlash(tokens) {
|
|
846
846
|
return tokens.findIndex(
|
|
847
|
-
(t,
|
|
847
|
+
(t, i2) => t.t === "slash" && isDigit(tokens[i2 - 1]) && (isDigit(tokens[i2 + 1]) || tokens[i2 + 1]?.t === "num")
|
|
848
848
|
);
|
|
849
849
|
}
|
|
850
850
|
function compileFraction(tokens, slash) {
|
|
@@ -864,19 +864,19 @@ function compileFraction(tokens, slash) {
|
|
|
864
864
|
if (fixed2) {
|
|
865
865
|
plan.fixedDenominator = Number(denTokens.map((t) => t.t === "num" ? t.v : "0").join(""));
|
|
866
866
|
}
|
|
867
|
-
tokens.forEach((tok,
|
|
868
|
-
if (
|
|
869
|
-
else if (
|
|
867
|
+
tokens.forEach((tok, i2) => {
|
|
868
|
+
if (i2 === slash) plan.tokens.push({ r: "slash" });
|
|
869
|
+
else if (i2 > slash && i2 < denEnd) {
|
|
870
870
|
if (fixed2) {
|
|
871
|
-
if (
|
|
871
|
+
if (i2 === slash + 1) plan.tokens.push({ r: "den", index: 0 });
|
|
872
872
|
} else if (isDigit(tok)) {
|
|
873
873
|
plan.tokens.push({ r: "den", index: plan.denDigits.length });
|
|
874
874
|
plan.denDigits.push(tok.c);
|
|
875
875
|
}
|
|
876
|
-
} else if (isDigit(tok) &&
|
|
876
|
+
} else if (isDigit(tok) && i2 >= numStart && i2 < slash) {
|
|
877
877
|
plan.tokens.push({ r: "num", index: plan.numDigits.length });
|
|
878
878
|
plan.numDigits.push(tok.c);
|
|
879
|
-
} else if (isDigit(tok) &&
|
|
879
|
+
} else if (isDigit(tok) && i2 < numStart) {
|
|
880
880
|
plan.tokens.push({ r: "int", index: plan.intDigits.length });
|
|
881
881
|
plan.intDigits.push(tok.c);
|
|
882
882
|
} else if (tok.t === "lit") plan.tokens.push({ r: "lit", v: tok.v });
|
|
@@ -913,21 +913,21 @@ function approximate(x, maxDen) {
|
|
|
913
913
|
var pad = (c) => c === "0" ? "0" : c === "?" ? " " : "";
|
|
914
914
|
function padLeft(s, slots) {
|
|
915
915
|
let prefix = "";
|
|
916
|
-
for (let
|
|
916
|
+
for (let i2 = 0; i2 < slots.length - s.length; i2++) prefix += pad(slots[i2] ?? "#");
|
|
917
917
|
return prefix + s;
|
|
918
918
|
}
|
|
919
919
|
function padRight(s, slots) {
|
|
920
920
|
let suffix = "";
|
|
921
|
-
for (let
|
|
921
|
+
for (let i2 = s.length; i2 < slots.length; i2++) suffix += pad(slots[i2] ?? "#");
|
|
922
922
|
return s + suffix;
|
|
923
923
|
}
|
|
924
924
|
function renderFraction(value2, plan) {
|
|
925
925
|
const x = Math.abs(value2);
|
|
926
926
|
const hasInt = plan.intDigits.length > 0;
|
|
927
927
|
let ip = hasInt ? Math.floor(x) : 0;
|
|
928
|
-
const
|
|
928
|
+
const f6 = x - ip;
|
|
929
929
|
const maxDen = 10 ** Math.max(1, plan.denDigits.length) - 1;
|
|
930
|
-
let [n, d] = plan.fixedDenominator ? [Math.round(
|
|
930
|
+
let [n, d] = plan.fixedDenominator ? [Math.round(f6 * plan.fixedDenominator), plan.fixedDenominator] : approximate(f6, maxDen);
|
|
931
931
|
if (hasInt && n >= d) {
|
|
932
932
|
ip += 1;
|
|
933
933
|
n = 0;
|
|
@@ -939,13 +939,13 @@ function renderFraction(value2, plan) {
|
|
|
939
939
|
const numHash = allHash(plan.numDigits);
|
|
940
940
|
const hideFraction = blank && numHash && (plan.fixedDenominator !== void 0 || allHash(plan.denDigits));
|
|
941
941
|
const dropSeparator = hideFraction || hasInt && intText === "" && numHash;
|
|
942
|
-
const lastInt = plan.tokens.reduce((last, t,
|
|
942
|
+
const lastInt = plan.tokens.reduce((last, t, i2) => t.r === "int" ? i2 : last, -1);
|
|
943
943
|
const firstNum = plan.tokens.findIndex((t) => t.r === "num");
|
|
944
944
|
let text = "";
|
|
945
945
|
let intDone = false;
|
|
946
|
-
plan.tokens.forEach((tok,
|
|
946
|
+
plan.tokens.forEach((tok, i2) => {
|
|
947
947
|
if (tok.r === "lit") {
|
|
948
|
-
if (!(dropSeparator &&
|
|
948
|
+
if (!(dropSeparator && i2 > lastInt && i2 < firstNum)) text += tok.v;
|
|
949
949
|
} else if (tok.r === "int") {
|
|
950
950
|
if (!intDone) text += intText;
|
|
951
951
|
intDone = true;
|
|
@@ -988,16 +988,16 @@ function roundSignificant(v, keep) {
|
|
|
988
988
|
let point = v.point;
|
|
989
989
|
if (roundUp) {
|
|
990
990
|
const chars = head.split("");
|
|
991
|
-
let
|
|
992
|
-
while (
|
|
993
|
-
chars[
|
|
994
|
-
|
|
991
|
+
let i2 = chars.length - 1;
|
|
992
|
+
while (i2 >= 0 && chars[i2] === "9") {
|
|
993
|
+
chars[i2] = "0";
|
|
994
|
+
i2--;
|
|
995
995
|
}
|
|
996
|
-
if (
|
|
996
|
+
if (i2 < 0) {
|
|
997
997
|
chars.unshift("1");
|
|
998
998
|
point++;
|
|
999
999
|
} else {
|
|
1000
|
-
chars[
|
|
1000
|
+
chars[i2] = String(Number(chars[i2]) + 1);
|
|
1001
1001
|
}
|
|
1002
1002
|
head = chars.join("");
|
|
1003
1003
|
}
|
|
@@ -1034,7 +1034,7 @@ var isDigit2 = (t) => t?.t === "digit";
|
|
|
1034
1034
|
function compileNumber(tokens) {
|
|
1035
1035
|
const expAt = tokens.findIndex((t) => t.t === "exp");
|
|
1036
1036
|
const end = expAt < 0 ? tokens.length : expAt;
|
|
1037
|
-
let pointAt = tokens.findIndex((t,
|
|
1037
|
+
let pointAt = tokens.findIndex((t, i2) => t.t === "point" && i2 < end);
|
|
1038
1038
|
if (pointAt < 0) pointAt = end;
|
|
1039
1039
|
const intDigits = [];
|
|
1040
1040
|
const fracDigits = [];
|
|
@@ -1048,34 +1048,34 @@ function compileNumber(tokens) {
|
|
|
1048
1048
|
return false;
|
|
1049
1049
|
};
|
|
1050
1050
|
let seenDigit = false;
|
|
1051
|
-
for (let
|
|
1052
|
-
const tok = tokens[
|
|
1051
|
+
for (let i2 = 0; i2 < tokens.length; i2++) {
|
|
1052
|
+
const tok = tokens[i2];
|
|
1053
1053
|
if (!tok) continue;
|
|
1054
|
-
if (
|
|
1054
|
+
if (i2 === expAt && tok.t === "exp") {
|
|
1055
1055
|
let n = 0;
|
|
1056
|
-
while (isDigit2(tokens[
|
|
1056
|
+
while (isDigit2(tokens[i2 + 1 + n])) n++;
|
|
1057
1057
|
exponent = { plus: tok.plus, digits: n };
|
|
1058
1058
|
out.push({ r: "exp" });
|
|
1059
|
-
|
|
1059
|
+
i2 += n;
|
|
1060
1060
|
continue;
|
|
1061
1061
|
}
|
|
1062
1062
|
switch (tok.t) {
|
|
1063
1063
|
case "digit":
|
|
1064
1064
|
seenDigit = true;
|
|
1065
|
-
if (
|
|
1065
|
+
if (i2 < pointAt) {
|
|
1066
1066
|
out.push({ r: "int", c: tok.c, index: intDigits.length });
|
|
1067
1067
|
intDigits.push(tok.c);
|
|
1068
|
-
} else if (
|
|
1068
|
+
} else if (i2 < end) {
|
|
1069
1069
|
out.push({ r: "frac", c: tok.c, index: fracDigits.length });
|
|
1070
1070
|
fracDigits.push(tok.c);
|
|
1071
1071
|
} else out.push({ r: "lit", v: tok.c });
|
|
1072
1072
|
break;
|
|
1073
1073
|
case "point":
|
|
1074
|
-
out.push(
|
|
1074
|
+
out.push(i2 === pointAt ? { r: "point" } : { r: "lit", v: "." });
|
|
1075
1075
|
break;
|
|
1076
1076
|
case "comma":
|
|
1077
|
-
if (
|
|
1078
|
-
else if (seenDigit &&
|
|
1077
|
+
if (i2 < pointAt && seenDigit && hasIntAfter(i2)) grouping = true;
|
|
1078
|
+
else if (seenDigit && i2 < end) scaleCommas++;
|
|
1079
1079
|
else out.push({ r: "lit", v: "," });
|
|
1080
1080
|
break;
|
|
1081
1081
|
case "percent":
|
|
@@ -1131,11 +1131,11 @@ function placeIntegers(digits2, slots, grouping) {
|
|
|
1131
1131
|
});
|
|
1132
1132
|
}
|
|
1133
1133
|
function placeFraction(digits2, slots) {
|
|
1134
|
-
const out = slots.map((_,
|
|
1135
|
-
for (let
|
|
1136
|
-
const c = slots[
|
|
1137
|
-
if (digits2.charAt(
|
|
1138
|
-
out[
|
|
1134
|
+
const out = slots.map((_, i2) => digits2.charAt(i2));
|
|
1135
|
+
for (let i2 = slots.length - 1; i2 >= 0; i2--) {
|
|
1136
|
+
const c = slots[i2] ?? "0";
|
|
1137
|
+
if (digits2.charAt(i2) !== "0" || c === "0") break;
|
|
1138
|
+
out[i2] = pad2(c);
|
|
1139
1139
|
}
|
|
1140
1140
|
return out;
|
|
1141
1141
|
}
|
|
@@ -1250,21 +1250,21 @@ var PALETTE_56 = [
|
|
|
1250
1250
|
function splitSections(format) {
|
|
1251
1251
|
const sections = [];
|
|
1252
1252
|
let current = "";
|
|
1253
|
-
for (let
|
|
1254
|
-
const ch = format.charAt(
|
|
1253
|
+
for (let i2 = 0; i2 < format.length; i2++) {
|
|
1254
|
+
const ch = format.charAt(i2);
|
|
1255
1255
|
if (ch === '"') {
|
|
1256
|
-
const end = format.indexOf('"',
|
|
1256
|
+
const end = format.indexOf('"', i2 + 1);
|
|
1257
1257
|
const stop = end < 0 ? format.length : end + 1;
|
|
1258
|
-
current += format.slice(
|
|
1259
|
-
|
|
1258
|
+
current += format.slice(i2, stop);
|
|
1259
|
+
i2 = stop - 1;
|
|
1260
1260
|
} else if (ch === "\\" || ch === "_" || ch === "*") {
|
|
1261
|
-
current += format.slice(
|
|
1262
|
-
|
|
1261
|
+
current += format.slice(i2, i2 + 2);
|
|
1262
|
+
i2++;
|
|
1263
1263
|
} else if (ch === "[") {
|
|
1264
|
-
const end = format.indexOf("]",
|
|
1264
|
+
const end = format.indexOf("]", i2 + 1);
|
|
1265
1265
|
const stop = end < 0 ? format.length : end + 1;
|
|
1266
|
-
current += format.slice(
|
|
1267
|
-
|
|
1266
|
+
current += format.slice(i2, stop);
|
|
1267
|
+
i2 = stop - 1;
|
|
1268
1268
|
} else if (ch === ";") {
|
|
1269
1269
|
sections.push(current);
|
|
1270
1270
|
current = "";
|
|
@@ -1297,9 +1297,9 @@ function parseBracket(content) {
|
|
|
1297
1297
|
}
|
|
1298
1298
|
return {};
|
|
1299
1299
|
}
|
|
1300
|
-
function runLength(s,
|
|
1300
|
+
function runLength(s, i2, lowerCh) {
|
|
1301
1301
|
let n = 0;
|
|
1302
|
-
while (
|
|
1302
|
+
while (i2 + n < s.length && s.charAt(i2 + n).toLowerCase() === lowerCh) n++;
|
|
1303
1303
|
return n;
|
|
1304
1304
|
}
|
|
1305
1305
|
function datePartFor(ch, n) {
|
|
@@ -1327,31 +1327,31 @@ function tokenizeSection(src) {
|
|
|
1327
1327
|
if (last?.t === "lit") last.v += v;
|
|
1328
1328
|
else tokens.push({ t: "lit", v });
|
|
1329
1329
|
};
|
|
1330
|
-
for (let
|
|
1331
|
-
const ch = src.charAt(
|
|
1330
|
+
for (let i2 = 0; i2 < src.length; i2++) {
|
|
1331
|
+
const ch = src.charAt(i2);
|
|
1332
1332
|
const lower2 = ch.toLowerCase();
|
|
1333
1333
|
if (ch === '"') {
|
|
1334
|
-
const end = src.indexOf('"',
|
|
1334
|
+
const end = src.indexOf('"', i2 + 1);
|
|
1335
1335
|
const stop = end < 0 ? src.length : end;
|
|
1336
|
-
lit(src.slice(
|
|
1337
|
-
|
|
1336
|
+
lit(src.slice(i2 + 1, stop));
|
|
1337
|
+
i2 = stop;
|
|
1338
1338
|
} else if (ch === "\\") {
|
|
1339
|
-
if (
|
|
1340
|
-
|
|
1339
|
+
if (i2 + 1 < src.length) lit(src.charAt(i2 + 1));
|
|
1340
|
+
i2++;
|
|
1341
1341
|
} else if (ch === "_") {
|
|
1342
1342
|
lit(" ");
|
|
1343
|
-
|
|
1343
|
+
i2++;
|
|
1344
1344
|
} else if (ch === "*") {
|
|
1345
|
-
|
|
1345
|
+
i2++;
|
|
1346
1346
|
} else if (ch === "[") {
|
|
1347
|
-
const end = src.indexOf("]",
|
|
1347
|
+
const end = src.indexOf("]", i2 + 1);
|
|
1348
1348
|
const stop = end < 0 ? src.length : end;
|
|
1349
|
-
const res = parseBracket(src.slice(
|
|
1349
|
+
const res = parseBracket(src.slice(i2 + 1, stop));
|
|
1350
1350
|
if (res.color) color = res.color;
|
|
1351
1351
|
if (res.condition) condition = res.condition;
|
|
1352
1352
|
if (res.token?.t === "lit") lit(res.token.v);
|
|
1353
1353
|
else if (res.token) tokens.push(res.token);
|
|
1354
|
-
|
|
1354
|
+
i2 = stop;
|
|
1355
1355
|
} else if (ch === "0" || ch === "#" || ch === "?") {
|
|
1356
1356
|
tokens.push({ t: "digit", c: ch });
|
|
1357
1357
|
} else if (ch >= "1" && ch <= "9") {
|
|
@@ -1366,26 +1366,26 @@ function tokenizeSection(src) {
|
|
|
1366
1366
|
tokens.push({ t: "slash" });
|
|
1367
1367
|
} else if (ch === "@") {
|
|
1368
1368
|
tokens.push({ t: "text" });
|
|
1369
|
-
} else if (lower2 === "e" && (src.charAt(
|
|
1370
|
-
tokens.push({ t: "exp", plus: src.charAt(
|
|
1371
|
-
|
|
1372
|
-
} else if (lower2 === "g" && src.slice(
|
|
1369
|
+
} else if (lower2 === "e" && (src.charAt(i2 + 1) === "+" || src.charAt(i2 + 1) === "-")) {
|
|
1370
|
+
tokens.push({ t: "exp", plus: src.charAt(i2 + 1) === "+" });
|
|
1371
|
+
i2++;
|
|
1372
|
+
} else if (lower2 === "g" && src.slice(i2, i2 + 7).toLowerCase() === "general") {
|
|
1373
1373
|
tokens.push({ t: "general" });
|
|
1374
|
-
|
|
1375
|
-
} else if (lower2 === "a" && src.slice(
|
|
1374
|
+
i2 += 6;
|
|
1375
|
+
} else if (lower2 === "a" && src.slice(i2, i2 + 5).toUpperCase() === "AM/PM") {
|
|
1376
1376
|
tokens.push({ t: "ampm", kind: "AM/PM" });
|
|
1377
|
-
|
|
1378
|
-
} else if (lower2 === "a" && src.slice(
|
|
1377
|
+
i2 += 4;
|
|
1378
|
+
} else if (lower2 === "a" && src.slice(i2, i2 + 3).toUpperCase() === "A/P") {
|
|
1379
1379
|
tokens.push({ t: "ampm", kind: ch === "A" ? "A/P" : "a/p" });
|
|
1380
|
-
|
|
1380
|
+
i2 += 2;
|
|
1381
1381
|
} else if (lower2 === "e" || lower2 === "g") {
|
|
1382
|
-
const n = runLength(src,
|
|
1382
|
+
const n = runLength(src, i2, lower2);
|
|
1383
1383
|
tokens.push({ t: "date", part: lower2 });
|
|
1384
|
-
|
|
1384
|
+
i2 += n - 1;
|
|
1385
1385
|
} else if ("ymdhsb".includes(lower2)) {
|
|
1386
|
-
const n = runLength(src,
|
|
1386
|
+
const n = runLength(src, i2, lower2);
|
|
1387
1387
|
tokens.push({ t: "date", part: datePartFor(lower2, n) });
|
|
1388
|
-
|
|
1388
|
+
i2 += n - 1;
|
|
1389
1389
|
} else {
|
|
1390
1390
|
lit(ch);
|
|
1391
1391
|
}
|
|
@@ -1411,16 +1411,16 @@ function normalizeDateTokens(tokens) {
|
|
|
1411
1411
|
if (last?.t === "lit") last.v += v;
|
|
1412
1412
|
else out.push({ t: "lit", v });
|
|
1413
1413
|
};
|
|
1414
|
-
for (let
|
|
1415
|
-
const tok = tokens[
|
|
1414
|
+
for (let i2 = 0; i2 < tokens.length; i2++) {
|
|
1415
|
+
const tok = tokens[i2];
|
|
1416
1416
|
if (!tok) continue;
|
|
1417
1417
|
if (tok.t === "point") {
|
|
1418
1418
|
let n = 0;
|
|
1419
|
-
while (tokens[
|
|
1419
|
+
while (tokens[i2 + 1 + n]?.t === "digit" && tokens[i2 + 1 + n].c === "0")
|
|
1420
1420
|
n++;
|
|
1421
1421
|
if (n > 0) {
|
|
1422
1422
|
out.push({ t: "subsec", digits: n });
|
|
1423
|
-
|
|
1423
|
+
i2 += n;
|
|
1424
1424
|
} else lit(".");
|
|
1425
1425
|
} else if (tok.t === "digit") lit(tok.c);
|
|
1426
1426
|
else if (tok.t === "num") lit(tok.v);
|
|
@@ -1903,8 +1903,8 @@ function scan(section) {
|
|
|
1903
1903
|
let bracket = false;
|
|
1904
1904
|
let lastDigit = -1;
|
|
1905
1905
|
let dot = -1;
|
|
1906
|
-
for (let
|
|
1907
|
-
const ch = section[
|
|
1906
|
+
for (let i2 = 0; i2 < section.length; i2++) {
|
|
1907
|
+
const ch = section[i2] ?? "";
|
|
1908
1908
|
if (quoted) {
|
|
1909
1909
|
if (ch === '"') quoted = false;
|
|
1910
1910
|
continue;
|
|
@@ -1913,11 +1913,11 @@ function scan(section) {
|
|
|
1913
1913
|
if (ch === "]") bracket = false;
|
|
1914
1914
|
continue;
|
|
1915
1915
|
}
|
|
1916
|
-
if (ch === "\\" || ch === "_" || ch === "*")
|
|
1916
|
+
if (ch === "\\" || ch === "_" || ch === "*") i2++;
|
|
1917
1917
|
else if (ch === '"') quoted = true;
|
|
1918
1918
|
else if (ch === "[") bracket = true;
|
|
1919
|
-
else if (ch === "0" || ch === "#" || ch === "?") lastDigit =
|
|
1920
|
-
else if (ch === "." && dot < 0) dot =
|
|
1919
|
+
else if (ch === "0" || ch === "#" || ch === "?") lastDigit = i2;
|
|
1920
|
+
else if (ch === "." && dot < 0) dot = i2;
|
|
1921
1921
|
else if ((ch === "e" || ch === "E") && lastDigit >= 0) break;
|
|
1922
1922
|
}
|
|
1923
1923
|
return { lastDigit, dot: dot >= 0 && dot < lastDigit ? dot : -1 };
|
|
@@ -1972,11 +1972,11 @@ function splitItems(text) {
|
|
|
1972
1972
|
const items = [];
|
|
1973
1973
|
let depth = 0;
|
|
1974
1974
|
let current = "";
|
|
1975
|
-
for (let
|
|
1976
|
-
const ch = text[
|
|
1975
|
+
for (let i2 = 0; i2 < text.length; i2++) {
|
|
1976
|
+
const ch = text[i2] ?? "";
|
|
1977
1977
|
if (ch === "'") {
|
|
1978
|
-
current += ch + (text[
|
|
1979
|
-
|
|
1978
|
+
current += ch + (text[i2 + 1] ?? "");
|
|
1979
|
+
i2++;
|
|
1980
1980
|
continue;
|
|
1981
1981
|
}
|
|
1982
1982
|
if (ch === "[") depth++;
|
|
@@ -2132,38 +2132,38 @@ function readReference(source, at) {
|
|
|
2132
2132
|
return void 0;
|
|
2133
2133
|
}
|
|
2134
2134
|
function readQuoted(source, at) {
|
|
2135
|
-
let
|
|
2135
|
+
let i2 = at + 1;
|
|
2136
2136
|
let name = "";
|
|
2137
|
-
while (
|
|
2138
|
-
const ch = source[
|
|
2137
|
+
while (i2 < source.length) {
|
|
2138
|
+
const ch = source[i2];
|
|
2139
2139
|
if (ch === "'") {
|
|
2140
|
-
if (source[
|
|
2140
|
+
if (source[i2 + 1] === "'") {
|
|
2141
2141
|
name += "'";
|
|
2142
|
-
|
|
2142
|
+
i2 += 2;
|
|
2143
2143
|
continue;
|
|
2144
2144
|
}
|
|
2145
|
-
return { name, length:
|
|
2145
|
+
return { name, length: i2 + 1 - at };
|
|
2146
2146
|
}
|
|
2147
2147
|
name += ch;
|
|
2148
|
-
|
|
2148
|
+
i2++;
|
|
2149
2149
|
}
|
|
2150
2150
|
throw new FormulaError("Unterminated quoted sheet name", at);
|
|
2151
2151
|
}
|
|
2152
2152
|
function readBrackets(source, at) {
|
|
2153
2153
|
let depth = 0;
|
|
2154
|
-
let
|
|
2155
|
-
while (
|
|
2156
|
-
const ch = source[
|
|
2154
|
+
let i2 = at;
|
|
2155
|
+
while (i2 < source.length) {
|
|
2156
|
+
const ch = source[i2];
|
|
2157
2157
|
if (ch === "'") {
|
|
2158
|
-
|
|
2158
|
+
i2 += 2;
|
|
2159
2159
|
continue;
|
|
2160
2160
|
}
|
|
2161
2161
|
if (ch === "[") depth++;
|
|
2162
2162
|
else if (ch === "]") {
|
|
2163
2163
|
depth--;
|
|
2164
|
-
if (depth === 0) return
|
|
2164
|
+
if (depth === 0) return i2 + 1 - at;
|
|
2165
2165
|
}
|
|
2166
|
-
|
|
2166
|
+
i2++;
|
|
2167
2167
|
}
|
|
2168
2168
|
throw new FormulaError("Unterminated structured reference", at);
|
|
2169
2169
|
}
|
|
@@ -2214,22 +2214,22 @@ function numberLiteral(text) {
|
|
|
2214
2214
|
function tokenize(formula) {
|
|
2215
2215
|
const source = formula;
|
|
2216
2216
|
const tokens = [];
|
|
2217
|
-
let
|
|
2218
|
-
if (
|
|
2217
|
+
let i2 = source.startsWith("=") ? 1 : 0;
|
|
2218
|
+
if (i2 === 1) tokens.push({ kind: "ws", text: "=", start: 0 });
|
|
2219
2219
|
const push3 = (token) => {
|
|
2220
2220
|
tokens.push(token);
|
|
2221
|
-
|
|
2221
|
+
i2 = token.start + token.text.length;
|
|
2222
2222
|
};
|
|
2223
|
-
while (
|
|
2224
|
-
const ch = source[
|
|
2225
|
-
const start =
|
|
2223
|
+
while (i2 < source.length) {
|
|
2224
|
+
const ch = source[i2] ?? "";
|
|
2225
|
+
const start = i2;
|
|
2226
2226
|
if (/[ \t\r\n]/.test(ch)) {
|
|
2227
|
-
const m = /^[ \t\r\n]+/.exec(source.slice(
|
|
2227
|
+
const m = /^[ \t\r\n]+/.exec(source.slice(i2));
|
|
2228
2228
|
push3({ kind: "ws", text: m?.[0] ?? ch, start });
|
|
2229
2229
|
continue;
|
|
2230
2230
|
}
|
|
2231
2231
|
if (ch === '"') {
|
|
2232
|
-
let j =
|
|
2232
|
+
let j = i2 + 1;
|
|
2233
2233
|
let value2 = "";
|
|
2234
2234
|
for (; ; ) {
|
|
2235
2235
|
if (j >= source.length) throw new FormulaError("Unterminated string", start);
|
|
@@ -2248,11 +2248,11 @@ function tokenize(formula) {
|
|
|
2248
2248
|
continue;
|
|
2249
2249
|
}
|
|
2250
2250
|
if (ch === "#") {
|
|
2251
|
-
const code = matchError(source,
|
|
2251
|
+
const code = matchError(source, i2);
|
|
2252
2252
|
if (!code) throw new FormulaError(`Unexpected '#'`, start);
|
|
2253
2253
|
push3({
|
|
2254
2254
|
kind: code === "#REF!" ? "ref" : "error",
|
|
2255
|
-
text: source.slice(
|
|
2255
|
+
text: source.slice(i2, i2 + code.length),
|
|
2256
2256
|
start,
|
|
2257
2257
|
value: code
|
|
2258
2258
|
});
|
|
@@ -2271,40 +2271,40 @@ function tokenize(formula) {
|
|
|
2271
2271
|
push3({ kind, text: ch, start });
|
|
2272
2272
|
continue;
|
|
2273
2273
|
}
|
|
2274
|
-
if (ch === "[" && !/^\[\d+\]/.test(source.slice(
|
|
2275
|
-
const length = readBrackets(source,
|
|
2276
|
-
push3({ kind: "structured", text: source.slice(
|
|
2274
|
+
if (ch === "[" && !/^\[\d+\]/.test(source.slice(i2))) {
|
|
2275
|
+
const length = readBrackets(source, i2);
|
|
2276
|
+
push3({ kind: "structured", text: source.slice(i2, i2 + length), start, value: "" });
|
|
2277
2277
|
continue;
|
|
2278
2278
|
}
|
|
2279
2279
|
const prefixed = ch === "'" || ch === "[" || NAME_START.test(ch) || /\d/.test(ch);
|
|
2280
2280
|
if (prefixed) {
|
|
2281
|
-
const prefix = readPrefix(source,
|
|
2281
|
+
const prefix = readPrefix(source, i2);
|
|
2282
2282
|
if (prefix) {
|
|
2283
|
-
push3(readAfterPrefix(source,
|
|
2283
|
+
push3(readAfterPrefix(source, i2 + prefix.length, start, prefix.prefix));
|
|
2284
2284
|
continue;
|
|
2285
2285
|
}
|
|
2286
2286
|
if (ch === "'" || ch === "[") throw new FormulaError("Malformed sheet reference", start);
|
|
2287
2287
|
}
|
|
2288
2288
|
if (/[\d.]/.test(ch) || ch === "$" || NAME_START.test(ch)) {
|
|
2289
|
-
const ref = readReference(source,
|
|
2289
|
+
const ref = readReference(source, i2);
|
|
2290
2290
|
if (ref) {
|
|
2291
|
-
push3(refToken(source, start,
|
|
2291
|
+
push3(refToken(source, start, i2 + ref.length, ref.ref, void 0));
|
|
2292
2292
|
continue;
|
|
2293
2293
|
}
|
|
2294
2294
|
if (/[\d.]/.test(ch)) {
|
|
2295
|
-
const m = NUMBER_RE2.exec(source.slice(
|
|
2295
|
+
const m = NUMBER_RE2.exec(source.slice(i2));
|
|
2296
2296
|
if (!m) throw new FormulaError(`Unexpected '${ch}'`, start);
|
|
2297
2297
|
push3({ kind: "number", text: m[0], start, value: numberLiteral(m[0]) });
|
|
2298
2298
|
continue;
|
|
2299
2299
|
}
|
|
2300
2300
|
if (ch !== "$") {
|
|
2301
|
-
push3(readName(source,
|
|
2301
|
+
push3(readName(source, i2, start, void 0));
|
|
2302
2302
|
continue;
|
|
2303
2303
|
}
|
|
2304
2304
|
}
|
|
2305
|
-
const
|
|
2306
|
-
if (
|
|
2307
|
-
push3({ kind: "op", text:
|
|
2305
|
+
const op2 = OPERATORS.find((o) => source.startsWith(o, i2));
|
|
2306
|
+
if (op2) {
|
|
2307
|
+
push3({ kind: "op", text: op2, start });
|
|
2308
2308
|
continue;
|
|
2309
2309
|
}
|
|
2310
2310
|
throw new FormulaError(`Unexpected character '${ch}'`, start);
|
|
@@ -2866,16 +2866,16 @@ var Matrix = class _Matrix {
|
|
|
2866
2866
|
}
|
|
2867
2867
|
/** Every row, materialising a padded matrix (bounded by `MAX_ARRAY_CELLS`). */
|
|
2868
2868
|
get data() {
|
|
2869
|
-
const
|
|
2870
|
-
if (!
|
|
2869
|
+
const pad4 = this.padding;
|
|
2870
|
+
if (!pad4) return this.dense;
|
|
2871
2871
|
if (this.materialized) return this.materialized;
|
|
2872
|
-
checkArraySize(
|
|
2872
|
+
checkArraySize(pad4.rows, pad4.cols);
|
|
2873
2873
|
const out = [];
|
|
2874
|
-
for (let r = 0; r <
|
|
2874
|
+
for (let r = 0; r < pad4.rows; r++) {
|
|
2875
2875
|
const line2 = [];
|
|
2876
2876
|
const stored = this.dense[r];
|
|
2877
|
-
for (let c = 0; c <
|
|
2878
|
-
line2.push(stored && c < stored.length ? stored[c] :
|
|
2877
|
+
for (let c = 0; c < pad4.cols; c++)
|
|
2878
|
+
line2.push(stored && c < stored.length ? stored[c] : pad4.fill);
|
|
2879
2879
|
out.push(line2);
|
|
2880
2880
|
}
|
|
2881
2881
|
this.materialized = out;
|
|
@@ -2905,8 +2905,8 @@ var Matrix = class _Matrix {
|
|
|
2905
2905
|
get(row2, col) {
|
|
2906
2906
|
const stored = this.dense[row2];
|
|
2907
2907
|
if (stored && col < stored.length) return stored[col] ?? null;
|
|
2908
|
-
const
|
|
2909
|
-
return
|
|
2908
|
+
const pad4 = this.padding;
|
|
2909
|
+
return pad4 && row2 < pad4.rows && col < pad4.cols ? pad4.fill : null;
|
|
2910
2910
|
}
|
|
2911
2911
|
/** Only the stored block of a padded matrix (what a spilling formula shows). */
|
|
2912
2912
|
block() {
|
|
@@ -2928,21 +2928,21 @@ var Matrix = class _Matrix {
|
|
|
2928
2928
|
/** Maps every value; a padded matrix maps its block and its fill once. */
|
|
2929
2929
|
mapValues(fn) {
|
|
2930
2930
|
const block = this.dense.map((line2) => line2.map((value2) => fn(value2)));
|
|
2931
|
-
const
|
|
2932
|
-
return new _Matrix(block,
|
|
2931
|
+
const pad4 = this.padding;
|
|
2932
|
+
return new _Matrix(block, pad4 ? { ...pad4, fill: fn(pad4.fill) } : void 0);
|
|
2933
2933
|
}
|
|
2934
2934
|
/** Visits every value in row-major order without materialising a padded matrix. */
|
|
2935
2935
|
forEachValue(visit2) {
|
|
2936
|
-
const
|
|
2937
|
-
if (!
|
|
2936
|
+
const pad4 = this.padding;
|
|
2937
|
+
if (!pad4) {
|
|
2938
2938
|
for (const line2 of this.dense) for (const v of line2) visit2(v);
|
|
2939
2939
|
return;
|
|
2940
2940
|
}
|
|
2941
|
-
for (let r = 0; r <
|
|
2941
|
+
for (let r = 0; r < pad4.rows; r++) {
|
|
2942
2942
|
const stored = this.dense[r];
|
|
2943
2943
|
const n = stored ? stored.length : 0;
|
|
2944
2944
|
for (let c = 0; c < n; c++) visit2(stored[c] ?? null);
|
|
2945
|
-
for (let c = n; c <
|
|
2945
|
+
for (let c = n; c < pad4.cols; c++) visit2(pad4.fill);
|
|
2946
2946
|
}
|
|
2947
2947
|
}
|
|
2948
2948
|
/** Every element in row-major order. */
|
|
@@ -3068,9 +3068,9 @@ var num = (value2) => toNumber(scalar(value2));
|
|
|
3068
3068
|
var str = (value2) => toText(scalar(value2));
|
|
3069
3069
|
var bool = (value2) => toBool(scalar(value2));
|
|
3070
3070
|
var int = (value2) => Math.trunc(num(value2));
|
|
3071
|
-
var optNum = (args,
|
|
3072
|
-
var optBool = (args,
|
|
3073
|
-
var omitted = (args,
|
|
3071
|
+
var optNum = (args, i2, fallback) => i2 < args.length ? num(args[i2]) : fallback;
|
|
3072
|
+
var optBool = (args, i2, fallback) => i2 < args.length ? bool(args[i2]) : fallback;
|
|
3073
|
+
var omitted = (args, i2) => i2 >= args.length || args[i2] === null;
|
|
3074
3074
|
function collectNumbers(ctx, args, options = {}) {
|
|
3075
3075
|
const out = [];
|
|
3076
3076
|
for (const arg of args) {
|
|
@@ -3100,11 +3100,11 @@ var all = (ctx, args) => collectNumbers(ctx, args, { includeAll: true });
|
|
|
3100
3100
|
var domain = (ok, value2) => ok ? value2 : fail(ERR.NUM);
|
|
3101
3101
|
function wildcardRegex(pattern) {
|
|
3102
3102
|
let source = "";
|
|
3103
|
-
for (let
|
|
3104
|
-
const ch = pattern[
|
|
3105
|
-
if (ch === "~" &&
|
|
3106
|
-
source += escapeRegex(pattern[
|
|
3107
|
-
|
|
3103
|
+
for (let i2 = 0; i2 < pattern.length; i2++) {
|
|
3104
|
+
const ch = pattern[i2] ?? "";
|
|
3105
|
+
if (ch === "~" && i2 + 1 < pattern.length) {
|
|
3106
|
+
source += escapeRegex(pattern[i2 + 1] ?? "");
|
|
3107
|
+
i2++;
|
|
3108
3108
|
} else if (ch === "*") source += "[\\s\\S]*";
|
|
3109
3109
|
else if (ch === "?") source += "[\\s\\S]";
|
|
3110
3110
|
else source += escapeRegex(ch);
|
|
@@ -3121,20 +3121,20 @@ function makeCriteria(criteria) {
|
|
|
3121
3121
|
if (typeof criteria === "boolean") return (value2) => value2 === criteria;
|
|
3122
3122
|
if (criteria === null) return (value2) => value2 === null || value2 === "";
|
|
3123
3123
|
const match2 = /^(<=|>=|<>|<|>|=)?([\s\S]*)$/.exec(criteria);
|
|
3124
|
-
const
|
|
3124
|
+
const op2 = match2?.[1] ?? "";
|
|
3125
3125
|
const operandText = match2?.[2] ?? "";
|
|
3126
3126
|
const asNumber2 = parseNumberText(operandText);
|
|
3127
3127
|
const upper2 = operandText.toUpperCase();
|
|
3128
3128
|
const asBool = upper2 === "TRUE" ? true : upper2 === "FALSE" ? false : void 0;
|
|
3129
3129
|
const errorOperand = /^#/.test(operandText) ? operandText.toUpperCase() : void 0;
|
|
3130
|
-
if (
|
|
3130
|
+
if (op2 === "" || op2 === "=" || op2 === "<>") {
|
|
3131
3131
|
let test;
|
|
3132
3132
|
if (operandText === "") {
|
|
3133
|
-
if (
|
|
3134
|
-
if (
|
|
3133
|
+
if (op2 === "") return (value2) => value2 === null || value2 === "";
|
|
3134
|
+
if (op2 === "=") return (value2) => value2 === null;
|
|
3135
3135
|
return (value2) => value2 !== null;
|
|
3136
3136
|
} else if (asNumber2 !== void 0) {
|
|
3137
|
-
if (
|
|
3137
|
+
if (op2 === "<>")
|
|
3138
3138
|
return (value2) => !(typeof value2 === "number" && compareScalars(value2, asNumber2) === 0);
|
|
3139
3139
|
test = (value2) => typeof value2 === "number" && compareScalars(value2, asNumber2) === 0 || typeof value2 === "string" && parseNumberText(value2) === asNumber2;
|
|
3140
3140
|
} else if (asBool !== void 0) {
|
|
@@ -3148,9 +3148,9 @@ function makeCriteria(criteria) {
|
|
|
3148
3148
|
const lower2 = operandText.toLowerCase();
|
|
3149
3149
|
test = (value2) => typeof value2 === "string" && value2.toLowerCase() === lower2;
|
|
3150
3150
|
}
|
|
3151
|
-
return
|
|
3151
|
+
return op2 === "<>" ? (value2) => !test(value2) : test;
|
|
3152
3152
|
}
|
|
3153
|
-
const sign2 = (c) =>
|
|
3153
|
+
const sign2 = (c) => op2 === "<" ? c < 0 : op2 === ">" ? c > 0 : op2 === "<=" ? c <= 0 : c >= 0;
|
|
3154
3154
|
if (asNumber2 !== void 0) {
|
|
3155
3155
|
return (value2) => typeof value2 === "number" && sign2(compareScalars(value2, asNumber2));
|
|
3156
3156
|
}
|
|
@@ -3168,9 +3168,9 @@ function spec(name, category, syntax, description, minArgs, maxArgs, fn, params,
|
|
|
3168
3168
|
function numeric(name, category, syntax, description, minArgs, maxArgs, fn, defaults = []) {
|
|
3169
3169
|
return spec(name, category, syntax, description, minArgs, maxArgs, (args) => {
|
|
3170
3170
|
const values2 = [];
|
|
3171
|
-
for (let
|
|
3172
|
-
if (
|
|
3173
|
-
else if (defaults[
|
|
3171
|
+
for (let i2 = 0; i2 < maxArgs; i2++) {
|
|
3172
|
+
if (i2 < args.length) values2.push(num(args[i2]));
|
|
3173
|
+
else if (defaults[i2] !== void 0) values2.push(defaults[i2]);
|
|
3174
3174
|
}
|
|
3175
3175
|
const result2 = fn(...values2);
|
|
3176
3176
|
return typeof result2 === "number" ? finite(result2) : result2;
|
|
@@ -3179,7 +3179,7 @@ function numeric(name, category, syntax, description, minArgs, maxArgs, fn, defa
|
|
|
3179
3179
|
|
|
3180
3180
|
// xlsx/formula/functions/array-shape.ts
|
|
3181
3181
|
var C = "Lookup & Reference";
|
|
3182
|
-
var intAt = (ctx, args,
|
|
3182
|
+
var intAt = (ctx, args, i2) => i2 < args.length && args[i2] !== null ? Math.trunc(num(ctx.toScalar(args[i2] ?? null))) : void 0;
|
|
3183
3183
|
function take(m, rows2, cols, drop) {
|
|
3184
3184
|
const slice = (length, n) => {
|
|
3185
3185
|
if (n === void 0) return [0, length];
|
|
@@ -3193,9 +3193,9 @@ function take(m, rows2, cols, drop) {
|
|
|
3193
3193
|
return new Matrix(m.data.slice(r1, r2).map((row2) => row2.slice(c1, c2)));
|
|
3194
3194
|
}
|
|
3195
3195
|
function choose(indexes2, length) {
|
|
3196
|
-
return indexes2.map((
|
|
3197
|
-
const at =
|
|
3198
|
-
if (
|
|
3196
|
+
return indexes2.map((i2) => {
|
|
3197
|
+
const at = i2 < 0 ? length + i2 : i2 - 1;
|
|
3198
|
+
if (i2 === 0 || at < 0 || at >= length) fail(ERR.VALUE);
|
|
3199
3199
|
return at;
|
|
3200
3200
|
});
|
|
3201
3201
|
}
|
|
@@ -3216,7 +3216,7 @@ function stack(ctx, args, vertical2) {
|
|
|
3216
3216
|
)
|
|
3217
3217
|
);
|
|
3218
3218
|
}
|
|
3219
|
-
const height = parts.reduce((
|
|
3219
|
+
const height = parts.reduce((h2, p) => Math.max(h2, p.rows), 0);
|
|
3220
3220
|
return Matrix.build(
|
|
3221
3221
|
height,
|
|
3222
3222
|
parts.reduce((a, p) => a + p.cols, 0),
|
|
@@ -3253,9 +3253,9 @@ function wrap(ctx, args, byRows) {
|
|
|
3253
3253
|
const flat = values2.flat();
|
|
3254
3254
|
const count2 = intAt(ctx, args, 1) ?? 0;
|
|
3255
3255
|
if (count2 < 1) return ERR.NUM;
|
|
3256
|
-
const
|
|
3256
|
+
const pad4 = args.length > 2 ? ctx.toScalar(args[2] ?? null) : ERR.NA;
|
|
3257
3257
|
const other = Math.ceil(flat.length / count2);
|
|
3258
|
-
return byRows ? Matrix.build(other, count2, (r, c) => flat[r * count2 + c] ??
|
|
3258
|
+
return byRows ? Matrix.build(other, count2, (r, c) => flat[r * count2 + c] ?? pad4) : Matrix.build(count2, other, (r, c) => flat[c * count2 + r] ?? pad4);
|
|
3259
3259
|
}
|
|
3260
3260
|
var ARRAY_SHAPE_FUNCTIONS = [
|
|
3261
3261
|
spec(
|
|
@@ -3384,8 +3384,8 @@ var ARRAY_SHAPE_FUNCTIONS = [
|
|
|
3384
3384
|
const cols = intAt(ctx, args, 2) ?? m.cols;
|
|
3385
3385
|
if (rows2 < m.rows || cols < m.cols) return ERR.VALUE;
|
|
3386
3386
|
if (rows2 > MAX_ARRAY_SIDE || cols > MAX_ARRAY_SIDE) return ERR.NUM;
|
|
3387
|
-
const
|
|
3388
|
-
return Matrix.build(rows2, cols, (r, c) => r < m.rows && c < m.cols ? m.get(r, c) :
|
|
3387
|
+
const pad4 = args.length > 3 ? ctx.toScalar(args[3] ?? null) : ERR.NA;
|
|
3388
|
+
return Matrix.build(rows2, cols, (r, c) => r < m.rows && c < m.cols ? m.get(r, c) : pad4);
|
|
3389
3389
|
},
|
|
3390
3390
|
["any"]
|
|
3391
3391
|
)
|
|
@@ -3402,7 +3402,7 @@ function sortCompare(a, b, descending) {
|
|
|
3402
3402
|
else c = compareScalars(a, b);
|
|
3403
3403
|
return descending ? -c : c;
|
|
3404
3404
|
}
|
|
3405
|
-
var optInt = (ctx, args,
|
|
3405
|
+
var optInt = (ctx, args, i2, fallback) => i2 < args.length && args[i2] !== null ? Math.trunc(num(ctx.toScalar(args[i2] ?? null))) : fallback;
|
|
3406
3406
|
function transpose(m) {
|
|
3407
3407
|
return Matrix.build(m.cols, m.rows, (r, c) => m.get(c, r));
|
|
3408
3408
|
}
|
|
@@ -3437,7 +3437,7 @@ function filter(args, ctx) {
|
|
|
3437
3437
|
return out;
|
|
3438
3438
|
}
|
|
3439
3439
|
function sortRows(rows2, keys) {
|
|
3440
|
-
const order = rows2.map((_,
|
|
3440
|
+
const order = rows2.map((_, i2) => i2);
|
|
3441
3441
|
order.sort((x, y) => {
|
|
3442
3442
|
for (const key of keys) {
|
|
3443
3443
|
const c = sortCompare(key.values[x] ?? null, key.values[y] ?? null, key.descending);
|
|
@@ -3445,7 +3445,7 @@ function sortRows(rows2, keys) {
|
|
|
3445
3445
|
}
|
|
3446
3446
|
return x - y;
|
|
3447
3447
|
});
|
|
3448
|
-
return order.map((
|
|
3448
|
+
return order.map((i2) => rows2[i2] ?? []);
|
|
3449
3449
|
}
|
|
3450
3450
|
function sort(args, ctx) {
|
|
3451
3451
|
let m = ctx.toMatrix(args[0] ?? null);
|
|
@@ -3466,9 +3466,9 @@ function sortBy(args, ctx) {
|
|
|
3466
3466
|
const m = ctx.toMatrix(args[0] ?? null);
|
|
3467
3467
|
const keys = [];
|
|
3468
3468
|
let byCol;
|
|
3469
|
-
for (let
|
|
3470
|
-
const by = ctx.toMatrix(args[
|
|
3471
|
-
const order =
|
|
3469
|
+
for (let i2 = 1; i2 < args.length; i2 += 2) {
|
|
3470
|
+
const by = ctx.toMatrix(args[i2] ?? null);
|
|
3471
|
+
const order = i2 + 1 < args.length && args[i2 + 1] !== null ? num(ctx.toScalar(args[i2 + 1] ?? null)) : 1;
|
|
3472
3472
|
if (order !== 1 && order !== -1) fail(ERR.VALUE);
|
|
3473
3473
|
const column = by.cols === 1 && by.rows === m.rows;
|
|
3474
3474
|
const row2 = by.rows === 1 && by.cols === m.cols;
|
|
@@ -3659,22 +3659,22 @@ function extreme(values2, max) {
|
|
|
3659
3659
|
function percentileInc(values2, p) {
|
|
3660
3660
|
if (values2.length === 0 || p < 0 || p > 1) fail(ERR.NUM);
|
|
3661
3661
|
const s = sorted(values2);
|
|
3662
|
-
const
|
|
3663
|
-
const lo = Math.floor(
|
|
3662
|
+
const h2 = (s.length - 1) * p;
|
|
3663
|
+
const lo = Math.floor(h2);
|
|
3664
3664
|
const a = s[lo];
|
|
3665
3665
|
const b = s[Math.min(lo + 1, s.length - 1)];
|
|
3666
|
-
return a + (
|
|
3666
|
+
return a + (h2 - lo) * (b - a);
|
|
3667
3667
|
}
|
|
3668
3668
|
function percentileExc(values2, p) {
|
|
3669
3669
|
const n = values2.length;
|
|
3670
3670
|
if (n === 0 || p <= 0 || p >= 1) fail(ERR.NUM);
|
|
3671
|
-
const
|
|
3672
|
-
if (
|
|
3671
|
+
const h2 = (n + 1) * p;
|
|
3672
|
+
if (h2 < 1 || h2 > n) fail(ERR.NUM);
|
|
3673
3673
|
const s = sorted(values2);
|
|
3674
|
-
const lo = Math.floor(
|
|
3674
|
+
const lo = Math.floor(h2);
|
|
3675
3675
|
const a = s[lo - 1];
|
|
3676
3676
|
const b = s[Math.min(lo, n - 1)];
|
|
3677
|
-
return a + (
|
|
3677
|
+
return a + (h2 - lo) * (b - a);
|
|
3678
3678
|
}
|
|
3679
3679
|
function quartile(values2, q, exclusive) {
|
|
3680
3680
|
const quart = Math.trunc(q);
|
|
@@ -3713,7 +3713,7 @@ function covariance(xs, ys, sample) {
|
|
|
3713
3713
|
const mx = mean(xs);
|
|
3714
3714
|
const my = mean(ys);
|
|
3715
3715
|
let total2 = 0;
|
|
3716
|
-
for (let
|
|
3716
|
+
for (let i2 = 0; i2 < n; i2++) total2 += (xs[i2] - mx) * (ys[i2] - my);
|
|
3717
3717
|
return total2 / (sample ? n - 1 : n);
|
|
3718
3718
|
}
|
|
3719
3719
|
function correlation(xs, ys) {
|
|
@@ -3729,9 +3729,9 @@ function linearFit(xs, ys) {
|
|
|
3729
3729
|
const my = mean(ys);
|
|
3730
3730
|
let sxy = 0;
|
|
3731
3731
|
let sxx = 0;
|
|
3732
|
-
for (let
|
|
3733
|
-
const dx = xs[
|
|
3734
|
-
sxy += dx * (ys[
|
|
3732
|
+
for (let i2 = 0; i2 < xs.length; i2++) {
|
|
3733
|
+
const dx = xs[i2] - mx;
|
|
3734
|
+
sxy += dx * (ys[i2] - my);
|
|
3735
3735
|
sxx += dx * dx;
|
|
3736
3736
|
}
|
|
3737
3737
|
if (sxx === 0) fail(ERR.DIV0);
|
|
@@ -3763,7 +3763,7 @@ function gamma(z) {
|
|
|
3763
3763
|
const x = z - 1;
|
|
3764
3764
|
let a = 0.9999999999998099;
|
|
3765
3765
|
const t = x + 7.5;
|
|
3766
|
-
for (let
|
|
3766
|
+
for (let i2 = 0; i2 < LANCZOS.length; i2++) a += LANCZOS[i2] / (x + i2 + 1);
|
|
3767
3767
|
return Math.sqrt(2 * Math.PI) * Math.pow(t, x + 0.5) * Math.exp(-t) * a;
|
|
3768
3768
|
}
|
|
3769
3769
|
function gammaLn(z) {
|
|
@@ -3772,7 +3772,7 @@ function gammaLn(z) {
|
|
|
3772
3772
|
const x = z - 1;
|
|
3773
3773
|
let a = 0.9999999999998099;
|
|
3774
3774
|
const t = x + 7.5;
|
|
3775
|
-
for (let
|
|
3775
|
+
for (let i2 = 0; i2 < LANCZOS.length; i2++) a += LANCZOS[i2] / (x + i2 + 1);
|
|
3776
3776
|
return 0.5 * Math.log(2 * Math.PI) + (x + 0.5) * Math.log(t) - t + Math.log(a);
|
|
3777
3777
|
}
|
|
3778
3778
|
|
|
@@ -3886,7 +3886,7 @@ function weekendDays(value2) {
|
|
|
3886
3886
|
if (typeof v === "string") {
|
|
3887
3887
|
if (!/^[01]{7}$/.test(v)) fail(ERR.VALUE);
|
|
3888
3888
|
const days = /* @__PURE__ */ new Set();
|
|
3889
|
-
for (let
|
|
3889
|
+
for (let i2 = 0; i2 < 7; i2++) if (v[i2] === "1") days.add((i2 + 1) % 7);
|
|
3890
3890
|
return days;
|
|
3891
3891
|
}
|
|
3892
3892
|
const code = Math.trunc(num(v));
|
|
@@ -4239,11 +4239,11 @@ var DATETIME_FUNCTIONS = [
|
|
|
4239
4239
|
3,
|
|
4240
4240
|
3,
|
|
4241
4241
|
(args) => {
|
|
4242
|
-
const
|
|
4242
|
+
const h2 = Math.trunc(num(args[0]));
|
|
4243
4243
|
const m = Math.trunc(num(args[1]));
|
|
4244
4244
|
const s = Math.trunc(num(args[2]));
|
|
4245
|
-
if (
|
|
4246
|
-
const total2 =
|
|
4245
|
+
if (h2 > 32767 || m > 32767 || s > 32767) fail(ERR.NUM);
|
|
4246
|
+
const total2 = h2 * 3600 + m * 60 + s;
|
|
4247
4247
|
if (total2 < 0) fail(ERR.NUM);
|
|
4248
4248
|
return total2 % 86400 / 86400;
|
|
4249
4249
|
}
|
|
@@ -4395,11 +4395,11 @@ function digits(n) {
|
|
|
4395
4395
|
}
|
|
4396
4396
|
function formatComplex({ re, im, suffix }) {
|
|
4397
4397
|
const r = Math.abs(re) < 1e-15 * Math.max(1, Math.abs(im)) ? 0 : re;
|
|
4398
|
-
const
|
|
4399
|
-
if (
|
|
4400
|
-
const imaginary =
|
|
4398
|
+
const i2 = Math.abs(im) < 1e-15 * Math.max(1, Math.abs(re)) ? 0 : im;
|
|
4399
|
+
if (i2 === 0) return digits(r);
|
|
4400
|
+
const imaginary = i2 === 1 ? suffix : i2 === -1 ? `-${suffix}` : `${digits(i2)}${suffix}`;
|
|
4401
4401
|
if (r === 0) return imaginary;
|
|
4402
|
-
return `${digits(r)}${
|
|
4402
|
+
return `${digits(r)}${i2 > 0 ? "+" : ""}${imaginary}`;
|
|
4403
4403
|
}
|
|
4404
4404
|
var make = (re, im, suffix) => ({ re, im, suffix });
|
|
4405
4405
|
var modulus = (z) => Math.hypot(z.re, z.im);
|
|
@@ -4412,7 +4412,7 @@ function divide(a, b) {
|
|
|
4412
4412
|
}
|
|
4413
4413
|
function integerPower(z, n) {
|
|
4414
4414
|
let result2 = one(z);
|
|
4415
|
-
for (let
|
|
4415
|
+
for (let i2 = 0; i2 < Math.abs(n); i2++)
|
|
4416
4416
|
result2 = make(
|
|
4417
4417
|
result2.re * z.re - result2.im * z.im,
|
|
4418
4418
|
result2.re * z.im + result2.im * z.re,
|
|
@@ -4808,9 +4808,9 @@ var bitArg = (value2) => {
|
|
|
4808
4808
|
if (n < 0 || n >= 2 ** 48 || !Number.isInteger(n)) fail(ERR.NUM);
|
|
4809
4809
|
return n;
|
|
4810
4810
|
};
|
|
4811
|
-
var bitwise = (a, b,
|
|
4812
|
-
const hi =
|
|
4813
|
-
const lo =
|
|
4811
|
+
var bitwise = (a, b, op2) => {
|
|
4812
|
+
const hi = op2(Math.floor(a / 2 ** 24), Math.floor(b / 2 ** 24));
|
|
4813
|
+
const lo = op2(a % 2 ** 24, b % 2 ** 24);
|
|
4814
4814
|
return hi * 2 ** 24 + lo;
|
|
4815
4815
|
};
|
|
4816
4816
|
var ENGINEERING_FUNCTIONS = [
|
|
@@ -4904,9 +4904,9 @@ var ENGINEERING_FUNCTIONS = [
|
|
|
4904
4904
|
if (!/^[MDCLXVI]*$/.test(body2)) fail(ERR.VALUE);
|
|
4905
4905
|
const value2 = { M: 1e3, D: 500, C: 100, L: 50, X: 10, V: 5, I: 1 };
|
|
4906
4906
|
let total2 = 0;
|
|
4907
|
-
for (let
|
|
4908
|
-
const cur = value2[body2[
|
|
4909
|
-
const next = value2[body2[
|
|
4907
|
+
for (let i2 = 0; i2 < body2.length; i2++) {
|
|
4908
|
+
const cur = value2[body2[i2] ?? ""] ?? 0;
|
|
4909
|
+
const next = value2[body2[i2 + 1] ?? ""] ?? 0;
|
|
4910
4910
|
total2 += cur < next ? -cur : cur;
|
|
4911
4911
|
}
|
|
4912
4912
|
return negative ? -total2 : total2;
|
|
@@ -4993,38 +4993,38 @@ var security = (name, description, pick2) => spec(
|
|
|
4993
4993
|
)
|
|
4994
4994
|
);
|
|
4995
4995
|
var COUPON_FUNCTIONS = [
|
|
4996
|
-
security("COUPPCD", "The coupon date before the settlement date.", (
|
|
4997
|
-
security("COUPNCD", "The coupon date after the settlement date.", (
|
|
4998
|
-
security("COUPNUM", "The number of coupons between settlement and maturity.", (
|
|
4996
|
+
security("COUPPCD", "The coupon date before the settlement date.", (f6) => f6.previous),
|
|
4997
|
+
security("COUPNCD", "The coupon date after the settlement date.", (f6) => f6.next),
|
|
4998
|
+
security("COUPNUM", "The number of coupons between settlement and maturity.", (f6) => f6.count),
|
|
4999
4999
|
security(
|
|
5000
5000
|
"COUPDAYBS",
|
|
5001
5001
|
"The days from the start of the coupon period to settlement.",
|
|
5002
|
-
(
|
|
5002
|
+
(f6) => f6.daysSincePrevious
|
|
5003
5003
|
),
|
|
5004
5004
|
security(
|
|
5005
5005
|
"COUPDAYS",
|
|
5006
5006
|
"The days in the coupon period that contains the settlement date.",
|
|
5007
|
-
(
|
|
5007
|
+
(f6) => f6.daysInPeriod
|
|
5008
5008
|
),
|
|
5009
|
-
security("COUPDAYSNC", "The days from settlement to the next coupon date.", (
|
|
5009
|
+
security("COUPDAYSNC", "The days from settlement to the next coupon date.", (f6) => f6.daysToNext)
|
|
5010
5010
|
];
|
|
5011
5011
|
|
|
5012
5012
|
// xlsx/formula/functions/financial-core.ts
|
|
5013
5013
|
function pmt(rate, nper, pv2, fv2 = 0, type = 0) {
|
|
5014
5014
|
if (nper === 0) fail(ERR.NUM);
|
|
5015
5015
|
if (rate === 0) return -(pv2 + fv2) / nper;
|
|
5016
|
-
const
|
|
5017
|
-
return -rate * (fv2 + pv2 *
|
|
5016
|
+
const f6 = Math.pow(1 + rate, nper);
|
|
5017
|
+
return -rate * (fv2 + pv2 * f6) / ((1 + rate * type) * (f6 - 1));
|
|
5018
5018
|
}
|
|
5019
5019
|
function fv(rate, nper, payment, pv2 = 0, type = 0) {
|
|
5020
5020
|
if (rate === 0) return -(pv2 + payment * nper);
|
|
5021
|
-
const
|
|
5022
|
-
return -(pv2 *
|
|
5021
|
+
const f6 = Math.pow(1 + rate, nper);
|
|
5022
|
+
return -(pv2 * f6 + payment * (1 + rate * type) * (f6 - 1) / rate);
|
|
5023
5023
|
}
|
|
5024
5024
|
function pv(rate, nper, payment, future = 0, type = 0) {
|
|
5025
5025
|
if (rate === 0) return -(future + payment * nper);
|
|
5026
|
-
const
|
|
5027
|
-
return -(future + payment * (1 + rate * type) * (
|
|
5026
|
+
const f6 = Math.pow(1 + rate, nper);
|
|
5027
|
+
return -(future + payment * (1 + rate * type) * (f6 - 1) / rate) / f6;
|
|
5028
5028
|
}
|
|
5029
5029
|
function ipmt(rate, per, nper, present, future = 0, type = 0) {
|
|
5030
5030
|
if (per < 1 || per > nper) fail(ERR.NUM);
|
|
@@ -5035,14 +5035,14 @@ function ipmt(rate, per, nper, present, future = 0, type = 0) {
|
|
|
5035
5035
|
interest = type === 1 ? fv(rate, per - 2, payment, present, 1) - payment : fv(rate, per - 1, payment, present, 0);
|
|
5036
5036
|
return interest * rate;
|
|
5037
5037
|
}
|
|
5038
|
-
function solve(
|
|
5038
|
+
function solve(f6, guess) {
|
|
5039
5039
|
let x = guess;
|
|
5040
|
-
for (let
|
|
5041
|
-
const y =
|
|
5040
|
+
for (let i2 = 0; i2 < 100; i2++) {
|
|
5041
|
+
const y = f6(x);
|
|
5042
5042
|
if (!Number.isFinite(y)) break;
|
|
5043
5043
|
if (y === 0) return x;
|
|
5044
|
-
const
|
|
5045
|
-
const slope = (
|
|
5044
|
+
const h2 = Math.max(1e-9, Math.abs(x) * 1e-9);
|
|
5045
|
+
const slope = (f6(x + h2) - f6(x - h2)) / (2 * h2);
|
|
5046
5046
|
if (slope === 0 || !Number.isFinite(slope)) break;
|
|
5047
5047
|
const next = x - y / slope;
|
|
5048
5048
|
if (Math.abs(next - x) <= 1e-14 * Math.max(1, Math.abs(next))) return next;
|
|
@@ -5051,11 +5051,11 @@ function solve(f, guess) {
|
|
|
5051
5051
|
}
|
|
5052
5052
|
let lo = -0.999999;
|
|
5053
5053
|
let hi = 10;
|
|
5054
|
-
let flo =
|
|
5055
|
-
if (!Number.isFinite(flo) || flo *
|
|
5056
|
-
for (let
|
|
5054
|
+
let flo = f6(lo);
|
|
5055
|
+
if (!Number.isFinite(flo) || flo * f6(hi) > 0) fail(ERR.NUM);
|
|
5056
|
+
for (let i2 = 0; i2 < 300; i2++) {
|
|
5057
5057
|
const mid = (lo + hi) / 2;
|
|
5058
|
-
const fm =
|
|
5058
|
+
const fm = f6(mid);
|
|
5059
5059
|
if (Math.abs(fm) < 1e-10) return mid;
|
|
5060
5060
|
if (fm * flo < 0) hi = mid;
|
|
5061
5061
|
else {
|
|
@@ -5148,8 +5148,8 @@ function accruedInterest(args, ctx) {
|
|
|
5148
5148
|
const dates = quasiPeriods(first2, start, settlement, frequency2, ctx);
|
|
5149
5149
|
const count2 = (a, b) => basis === 0 || basis === 4 ? days360(a, b, basis === 4, ctx) : b - a;
|
|
5150
5150
|
let sum2 = 0;
|
|
5151
|
-
for (let
|
|
5152
|
-
const [p, q] = [dates[
|
|
5151
|
+
for (let i2 = 0; i2 + 1 < dates.length; i2++) {
|
|
5152
|
+
const [p, q] = [dates[i2], dates[i2 + 1]];
|
|
5153
5153
|
const a = count2(Math.max(start, p), Math.min(settlement, q));
|
|
5154
5154
|
if (a <= 0) continue;
|
|
5155
5155
|
const length = basis === 1 ? q - p : basis === 3 ? 365 / frequency2 : 360 / frequency2;
|
|
@@ -5184,8 +5184,8 @@ var BOND_FUNCTIONS = [
|
|
|
5184
5184
|
const bond = bondOf(args, ctx, 4, 6);
|
|
5185
5185
|
const price = num(args[3]);
|
|
5186
5186
|
if (bond.rate < 0 || price <= 0 || bond.redemption <= 0) fail(ERR.NUM);
|
|
5187
|
-
const
|
|
5188
|
-
return solve(
|
|
5187
|
+
const f6 = (y) => pricePerHundred(bond.facts, bond.rate, y, bond.redemption, bond.frequency) - price;
|
|
5188
|
+
return solve(f6, bond.rate || 0.05);
|
|
5189
5189
|
}
|
|
5190
5190
|
),
|
|
5191
5191
|
...["DURATION", "MDURATION"].map(
|
|
@@ -5316,9 +5316,9 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5316
5316
|
"Double-declining balance depreciation.",
|
|
5317
5317
|
4,
|
|
5318
5318
|
5,
|
|
5319
|
-
(c, s = 0, l = 1, p = 1,
|
|
5320
|
-
if (c < 0 || s < 0 || l <= 0 || p <= 0 || p > l ||
|
|
5321
|
-
const rate = Math.min(
|
|
5319
|
+
(c, s = 0, l = 1, p = 1, f6 = 2) => {
|
|
5320
|
+
if (c < 0 || s < 0 || l <= 0 || p <= 0 || p > l || f6 <= 0) fail(ERR.NUM);
|
|
5321
|
+
const rate = Math.min(f6 / l, 1);
|
|
5322
5322
|
const book = c * Math.pow(1 - rate, Math.max(0, p - 1));
|
|
5323
5323
|
return Math.max(0, Math.min(book * rate, book - s));
|
|
5324
5324
|
}
|
|
@@ -5331,7 +5331,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5331
5331
|
5,
|
|
5332
5332
|
7,
|
|
5333
5333
|
(args) => {
|
|
5334
|
-
const [cost, salvage, life, start, end] = [0, 1, 2, 3, 4].map((
|
|
5334
|
+
const [cost, salvage, life, start, end] = [0, 1, 2, 3, 4].map((i2) => num(args[i2]));
|
|
5335
5335
|
const factor = args.length > 5 && args[5] !== null ? num(args[5]) : 2;
|
|
5336
5336
|
const noSwitch = args.length > 6 && args[6] !== null ? bool(args[6]) : false;
|
|
5337
5337
|
if ([cost, salvage, life, start, end, factor].some((v) => v === void 0 || Number.isNaN(v)) || cost < 0 || salvage < 0 || life <= 0 || start < 0 || end < start || end > life || factor <= 0)
|
|
@@ -5429,9 +5429,9 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5429
5429
|
"Periods required to reach a value.",
|
|
5430
5430
|
3,
|
|
5431
5431
|
3,
|
|
5432
|
-
(r, p = 0,
|
|
5433
|
-
if (r <= 0 || p <= 0 ||
|
|
5434
|
-
return (Math.log(
|
|
5432
|
+
(r, p = 0, f6 = 0) => {
|
|
5433
|
+
if (r <= 0 || p <= 0 || f6 <= 0) fail(ERR.NUM);
|
|
5434
|
+
return (Math.log(f6) - Math.log(p)) / Math.log(1 + r);
|
|
5435
5435
|
}
|
|
5436
5436
|
),
|
|
5437
5437
|
numeric(
|
|
@@ -5441,9 +5441,9 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5441
5441
|
"An equivalent interest rate for growth.",
|
|
5442
5442
|
3,
|
|
5443
5443
|
3,
|
|
5444
|
-
(n, p = 0,
|
|
5444
|
+
(n, p = 0, f6 = 0) => {
|
|
5445
5445
|
if (n <= 0 || p === 0) fail(ERR.NUM);
|
|
5446
|
-
return Math.pow(
|
|
5446
|
+
return Math.pow(f6 / p, 1 / n) - 1;
|
|
5447
5447
|
}
|
|
5448
5448
|
),
|
|
5449
5449
|
spec(
|
|
@@ -5463,8 +5463,8 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5463
5463
|
"Converts a fractional price to a decimal.",
|
|
5464
5464
|
2,
|
|
5465
5465
|
2,
|
|
5466
|
-
(d,
|
|
5467
|
-
const frac = Math.trunc(
|
|
5466
|
+
(d, f6) => {
|
|
5467
|
+
const frac = Math.trunc(f6 ?? 0);
|
|
5468
5468
|
if (frac < 0) fail(ERR.NUM);
|
|
5469
5469
|
if (frac === 0) fail(ERR.DIV0);
|
|
5470
5470
|
const digits2 = Math.ceil(Math.log10(frac));
|
|
@@ -5479,8 +5479,8 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5479
5479
|
"Converts a decimal price to a fraction.",
|
|
5480
5480
|
2,
|
|
5481
5481
|
2,
|
|
5482
|
-
(d,
|
|
5483
|
-
const frac = Math.trunc(
|
|
5482
|
+
(d, f6) => {
|
|
5483
|
+
const frac = Math.trunc(f6 ?? 0);
|
|
5484
5484
|
if (frac < 0) fail(ERR.NUM);
|
|
5485
5485
|
if (frac === 0) fail(ERR.DIV0);
|
|
5486
5486
|
const digits2 = Math.ceil(Math.log10(frac));
|
|
@@ -5536,31 +5536,31 @@ var SECURITY_FUNCTIONS = [
|
|
|
5536
5536
|
"DISC",
|
|
5537
5537
|
"The discount rate of a security.",
|
|
5538
5538
|
"DISC(settlement, maturity, pr, redemption, [basis])",
|
|
5539
|
-
(pr, redemption,
|
|
5539
|
+
(pr, redemption, f6) => (redemption - pr) / redemption / f6
|
|
5540
5540
|
),
|
|
5541
5541
|
discount(
|
|
5542
5542
|
"PRICEDISC",
|
|
5543
5543
|
"The price per 100 face value of a discounted security.",
|
|
5544
5544
|
"PRICEDISC(settlement, maturity, discount, redemption, [basis])",
|
|
5545
|
-
(rate, redemption,
|
|
5545
|
+
(rate, redemption, f6) => redemption - rate * redemption * f6
|
|
5546
5546
|
),
|
|
5547
5547
|
discount(
|
|
5548
5548
|
"YIELDDISC",
|
|
5549
5549
|
"The annual yield of a discounted security.",
|
|
5550
5550
|
"YIELDDISC(settlement, maturity, pr, redemption, [basis])",
|
|
5551
|
-
(pr, redemption,
|
|
5551
|
+
(pr, redemption, f6) => (redemption - pr) / pr / f6
|
|
5552
5552
|
),
|
|
5553
5553
|
discount(
|
|
5554
5554
|
"INTRATE",
|
|
5555
5555
|
"The interest rate of a fully invested security.",
|
|
5556
5556
|
"INTRATE(settlement, maturity, investment, redemption, [basis])",
|
|
5557
|
-
(investment, redemption,
|
|
5557
|
+
(investment, redemption, f6) => (redemption - investment) / investment / f6
|
|
5558
5558
|
),
|
|
5559
5559
|
discount(
|
|
5560
5560
|
"RECEIVED",
|
|
5561
5561
|
"The amount received at maturity for a fully invested security.",
|
|
5562
5562
|
"RECEIVED(settlement, maturity, investment, discount, [basis])",
|
|
5563
|
-
(investment, rate,
|
|
5563
|
+
(investment, rate, f6) => investment / (1 - rate * f6)
|
|
5564
5564
|
),
|
|
5565
5565
|
atMaturity(
|
|
5566
5566
|
"PRICEMAT",
|
|
@@ -5625,7 +5625,7 @@ var SECURITY_FUNCTIONS = [
|
|
|
5625
5625
|
|
|
5626
5626
|
// xlsx/formula/functions/financial.ts
|
|
5627
5627
|
var C12 = "Financial";
|
|
5628
|
-
var npv = (rate, values2) => values2.reduce((acc, v,
|
|
5628
|
+
var npv = (rate, values2) => values2.reduce((acc, v, i2) => acc + v / Math.pow(1 + rate, i2 + 1), 0);
|
|
5629
5629
|
function datedFlows(ctx, args) {
|
|
5630
5630
|
const values2 = collectNumbers(ctx, [args[0] ?? null]);
|
|
5631
5631
|
const dates = collectNumbers(ctx, [args[1] ?? null]).map(Math.floor);
|
|
@@ -5635,7 +5635,7 @@ function datedFlows(ctx, args) {
|
|
|
5635
5635
|
return { values: values2, dates };
|
|
5636
5636
|
}
|
|
5637
5637
|
var xnpv = (rate, values2, dates) => values2.reduce(
|
|
5638
|
-
(acc, v,
|
|
5638
|
+
(acc, v, i2) => acc + v / Math.pow(1 + rate, (dates[i2] - dates[0]) / 365),
|
|
5639
5639
|
0
|
|
5640
5640
|
);
|
|
5641
5641
|
var FINANCIAL_FUNCTIONS = [
|
|
@@ -5651,7 +5651,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5651
5651
|
"The payment for a loan.",
|
|
5652
5652
|
3,
|
|
5653
5653
|
5,
|
|
5654
|
-
(r, n, p,
|
|
5654
|
+
(r, n, p, f6, t) => pmt(r, n ?? 0, p ?? 0, f6, t)
|
|
5655
5655
|
),
|
|
5656
5656
|
numeric(
|
|
5657
5657
|
"FV",
|
|
@@ -5669,7 +5669,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5669
5669
|
"The present value of an investment.",
|
|
5670
5670
|
3,
|
|
5671
5671
|
5,
|
|
5672
|
-
(r, n, p,
|
|
5672
|
+
(r, n, p, f6, t) => pv(r, n ?? 0, p ?? 0, f6, t)
|
|
5673
5673
|
),
|
|
5674
5674
|
numeric(
|
|
5675
5675
|
"NPER",
|
|
@@ -5678,11 +5678,11 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5678
5678
|
"The number of periods for an investment.",
|
|
5679
5679
|
3,
|
|
5680
5680
|
5,
|
|
5681
|
-
(r, p, v,
|
|
5681
|
+
(r, p, v, f6 = 0, t = 0) => {
|
|
5682
5682
|
const payment = p ?? 0;
|
|
5683
5683
|
const present = v ?? 0;
|
|
5684
|
-
if (r === 0) return payment === 0 ? fail(ERR.NUM) : -(present +
|
|
5685
|
-
const num1 = payment * (1 + r * t) -
|
|
5684
|
+
if (r === 0) return payment === 0 ? fail(ERR.NUM) : -(present + f6) / payment;
|
|
5685
|
+
const num1 = payment * (1 + r * t) - f6 * r;
|
|
5686
5686
|
const den = present * r + payment * (1 + r * t);
|
|
5687
5687
|
if (num1 / den <= 0) fail(ERR.NUM);
|
|
5688
5688
|
return Math.log(num1 / den) / Math.log(1 + r);
|
|
@@ -5695,7 +5695,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5695
5695
|
"The interest part of a payment.",
|
|
5696
5696
|
4,
|
|
5697
5697
|
6,
|
|
5698
|
-
(r, per, n, p,
|
|
5698
|
+
(r, per, n, p, f6, t) => ipmt(r, per ?? 0, n ?? 0, p ?? 0, f6, t)
|
|
5699
5699
|
),
|
|
5700
5700
|
numeric(
|
|
5701
5701
|
"PPMT",
|
|
@@ -5704,7 +5704,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5704
5704
|
"The principal part of a payment.",
|
|
5705
5705
|
4,
|
|
5706
5706
|
6,
|
|
5707
|
-
(r, per, n, p,
|
|
5707
|
+
(r, per, n, p, f6, t) => pmt(r, n ?? 0, p ?? 0, f6, t) - ipmt(r, per ?? 0, n ?? 0, p ?? 0, f6, t)
|
|
5708
5708
|
),
|
|
5709
5709
|
numeric(
|
|
5710
5710
|
"RATE",
|
|
@@ -5713,11 +5713,11 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5713
5713
|
"The interest rate per period.",
|
|
5714
5714
|
3,
|
|
5715
5715
|
6,
|
|
5716
|
-
(n, p, v,
|
|
5717
|
-
if (Math.abs(r) < 1e-12) return (v ?? 0) + (p ?? 0) * n +
|
|
5716
|
+
(n, p, v, f6 = 0, t = 0, g2 = 0.1) => solve((r) => {
|
|
5717
|
+
if (Math.abs(r) < 1e-12) return (v ?? 0) + (p ?? 0) * n + f6;
|
|
5718
5718
|
const growth = Math.expm1(n * Math.log1p(r));
|
|
5719
|
-
return (v ?? 0) * (1 + growth) + (p ?? 0) * (1 + r * t) * growth / r +
|
|
5720
|
-
},
|
|
5719
|
+
return (v ?? 0) * (1 + growth) + (p ?? 0) * (1 + r * t) * growth / r + f6;
|
|
5720
|
+
}, g2)
|
|
5721
5721
|
),
|
|
5722
5722
|
spec(
|
|
5723
5723
|
"NPV",
|
|
@@ -5740,7 +5740,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5740
5740
|
const values2 = collectNumbers(ctx, [args[0] ?? null]);
|
|
5741
5741
|
if (!values2.some((v) => v > 0) || !values2.some((v) => v < 0)) fail(ERR.NUM);
|
|
5742
5742
|
return solve(
|
|
5743
|
-
(r) => values2.reduce((acc, v,
|
|
5743
|
+
(r) => values2.reduce((acc, v, i2) => acc + v / Math.pow(1 + r, i2), 0),
|
|
5744
5744
|
optNum(args, 1, 0.1)
|
|
5745
5745
|
);
|
|
5746
5746
|
},
|
|
@@ -5787,8 +5787,8 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5787
5787
|
const n = values2.length;
|
|
5788
5788
|
const positive3 = values2.map((v) => v > 0 ? v : 0);
|
|
5789
5789
|
const negative = values2.map((v) => v < 0 ? v : 0);
|
|
5790
|
-
const fvPos = positive3.reduce((acc, v,
|
|
5791
|
-
const pvNeg = negative.reduce((acc, v,
|
|
5790
|
+
const fvPos = positive3.reduce((acc, v, i2) => acc + v * Math.pow(1 + reinvest, n - 1 - i2), 0);
|
|
5791
|
+
const pvNeg = negative.reduce((acc, v, i2) => acc + v / Math.pow(1 + finance, i2), 0);
|
|
5792
5792
|
if (fvPos === 0 || pvNeg === 0) fail(ERR.DIV0);
|
|
5793
5793
|
return Math.pow(-fvPos / pvNeg, 1 / (n - 1)) - 1;
|
|
5794
5794
|
},
|
|
@@ -5810,7 +5810,7 @@ function prefixSheets(host, prefix, current) {
|
|
|
5810
5810
|
const last = sheetIndex(host, prefix.sheet2);
|
|
5811
5811
|
if (last < 0) return void 0;
|
|
5812
5812
|
const out = [];
|
|
5813
|
-
for (let
|
|
5813
|
+
for (let i2 = Math.min(first2, last); i2 <= Math.max(first2, last); i2++) out.push(i2);
|
|
5814
5814
|
return out;
|
|
5815
5815
|
}
|
|
5816
5816
|
var specRange = (spec2) => normalizeRange({
|
|
@@ -6193,14 +6193,14 @@ function snapToZero(result2, a, b) {
|
|
|
6193
6193
|
if (result2 !== 0 && Math.abs(result2) <= Math.max(Math.abs(a), Math.abs(b)) * 1e-15) return 0;
|
|
6194
6194
|
return result2;
|
|
6195
6195
|
}
|
|
6196
|
-
function arithmetic(
|
|
6196
|
+
function arithmetic(op2, x, y, snap) {
|
|
6197
6197
|
if (isError(x)) return x;
|
|
6198
6198
|
if (isError(y)) return y;
|
|
6199
6199
|
return signal(() => {
|
|
6200
6200
|
const a = toNumber(x);
|
|
6201
6201
|
const b = toNumber(y);
|
|
6202
6202
|
let r;
|
|
6203
|
-
switch (
|
|
6203
|
+
switch (op2) {
|
|
6204
6204
|
case "+":
|
|
6205
6205
|
r = a + b;
|
|
6206
6206
|
if (snap) r = snapToZero(r, a, b);
|
|
@@ -6222,11 +6222,11 @@ function arithmetic(op, x, y, snap) {
|
|
|
6222
6222
|
return Number.isFinite(r) ? r === 0 ? 0 : r : ERR.NUM;
|
|
6223
6223
|
});
|
|
6224
6224
|
}
|
|
6225
|
-
function comparison(
|
|
6225
|
+
function comparison(op2, x, y) {
|
|
6226
6226
|
if (isError(x)) return x;
|
|
6227
6227
|
if (isError(y)) return y;
|
|
6228
6228
|
const c = compareScalars(x, y);
|
|
6229
|
-
switch (
|
|
6229
|
+
switch (op2) {
|
|
6230
6230
|
case "=":
|
|
6231
6231
|
return c === 0;
|
|
6232
6232
|
case "<>":
|
|
@@ -6246,18 +6246,18 @@ function concat(x, y) {
|
|
|
6246
6246
|
if (isError(y)) return y;
|
|
6247
6247
|
return toText(x) + toText(y);
|
|
6248
6248
|
}
|
|
6249
|
-
function scalarBinary(
|
|
6250
|
-
if (
|
|
6251
|
-
if (
|
|
6252
|
-
return arithmetic(
|
|
6249
|
+
function scalarBinary(op2, x, y, snap = false) {
|
|
6250
|
+
if (op2 === "&") return concat(x, y);
|
|
6251
|
+
if (op2 === "+" || op2 === "-" || op2 === "*" || op2 === "/" || op2 === "^") {
|
|
6252
|
+
return arithmetic(op2, x, y, snap);
|
|
6253
6253
|
}
|
|
6254
|
-
return comparison(
|
|
6254
|
+
return comparison(op2, x, y);
|
|
6255
6255
|
}
|
|
6256
|
-
function scalarUnary(
|
|
6256
|
+
function scalarUnary(op2, x) {
|
|
6257
6257
|
if (isError(x)) return x;
|
|
6258
6258
|
return signal(() => {
|
|
6259
6259
|
const n = toNumber(x);
|
|
6260
|
-
const r =
|
|
6260
|
+
const r = op2 === "-" ? -n : n / 100;
|
|
6261
6261
|
return r === 0 ? 0 : r;
|
|
6262
6262
|
});
|
|
6263
6263
|
}
|
|
@@ -6539,10 +6539,10 @@ var LOGICAL_FUNCTIONS = [
|
|
|
6539
6539
|
254,
|
|
6540
6540
|
(args, ctx) => {
|
|
6541
6541
|
if (args.length % 2 !== 0) fail(ERR.VALUE);
|
|
6542
|
-
for (let
|
|
6543
|
-
const cond = ctx.toScalar(deref(ctx, args[
|
|
6542
|
+
for (let i2 = 0; i2 < args.length; i2 += 2) {
|
|
6543
|
+
const cond = ctx.toScalar(deref(ctx, args[i2].get()));
|
|
6544
6544
|
if (isError(cond)) return cond;
|
|
6545
|
-
if (toBool(cond)) return args[
|
|
6545
|
+
if (toBool(cond)) return args[i2 + 1].get();
|
|
6546
6546
|
}
|
|
6547
6547
|
return ERR.NA;
|
|
6548
6548
|
}
|
|
@@ -6556,15 +6556,15 @@ var LOGICAL_FUNCTIONS = [
|
|
|
6556
6556
|
(args, ctx) => {
|
|
6557
6557
|
const target2 = ctx.toScalar(deref(ctx, args[0].get()));
|
|
6558
6558
|
if (isError(target2)) return target2;
|
|
6559
|
-
let
|
|
6560
|
-
for (;
|
|
6561
|
-
const candidate = ctx.toScalar(deref(ctx, args[
|
|
6559
|
+
let i2 = 1;
|
|
6560
|
+
for (; i2 + 1 < args.length; i2 += 2) {
|
|
6561
|
+
const candidate = ctx.toScalar(deref(ctx, args[i2].get()));
|
|
6562
6562
|
if (isError(candidate)) return candidate;
|
|
6563
6563
|
if (typeof candidate === typeof target2 && compareScalars(candidate, target2) === 0) {
|
|
6564
|
-
return args[
|
|
6564
|
+
return args[i2 + 1].get();
|
|
6565
6565
|
}
|
|
6566
6566
|
}
|
|
6567
|
-
return
|
|
6567
|
+
return i2 < args.length ? args[i2].get() : ERR.NA;
|
|
6568
6568
|
}
|
|
6569
6569
|
),
|
|
6570
6570
|
lazySpec(
|
|
@@ -6627,9 +6627,9 @@ var LOGICAL_FUNCTIONS = [
|
|
|
6627
6627
|
(args, ctx) => {
|
|
6628
6628
|
if (args.length % 2 === 0) fail(ERR.VALUE);
|
|
6629
6629
|
let scope = new Map(ctx.frame.scope ?? []);
|
|
6630
|
-
for (let
|
|
6631
|
-
const name = localName(args[
|
|
6632
|
-
const value2 = ctx.evaluate(args[
|
|
6630
|
+
for (let i2 = 0; i2 + 1 < args.length; i2 += 2) {
|
|
6631
|
+
const name = localName(args[i2]);
|
|
6632
|
+
const value2 = ctx.evaluate(args[i2 + 1].node, scope);
|
|
6633
6633
|
scope = new Map(scope);
|
|
6634
6634
|
scope.set(name, value2);
|
|
6635
6635
|
}
|
|
@@ -6674,7 +6674,7 @@ function line(ctx, value2, axis, index2) {
|
|
|
6674
6674
|
return {
|
|
6675
6675
|
length: length2,
|
|
6676
6676
|
logicalLength: end.row - start.row + 1,
|
|
6677
|
-
get: (
|
|
6677
|
+
get: (i2) => ctx.readCell(area.sheet, start.row + i2, col)
|
|
6678
6678
|
};
|
|
6679
6679
|
}
|
|
6680
6680
|
const row2 = start.row + index2;
|
|
@@ -6682,12 +6682,12 @@ function line(ctx, value2, axis, index2) {
|
|
|
6682
6682
|
return {
|
|
6683
6683
|
length,
|
|
6684
6684
|
logicalLength: end.col - start.col + 1,
|
|
6685
|
-
get: (
|
|
6685
|
+
get: (i2) => ctx.readCell(area.sheet, row2, start.col + i2)
|
|
6686
6686
|
};
|
|
6687
6687
|
}
|
|
6688
6688
|
const m = value2 instanceof Matrix ? value2 : new Matrix([[value2]]);
|
|
6689
|
-
if (axis === "col") return { length: m.rows, get: (
|
|
6690
|
-
return { length: m.cols, get: (
|
|
6689
|
+
if (axis === "col") return { length: m.rows, get: (i2) => m.get(i2, index2) };
|
|
6690
|
+
return { length: m.cols, get: (i2) => m.get(index2, i2) };
|
|
6691
6691
|
}
|
|
6692
6692
|
function vectorOf(ctx, value2) {
|
|
6693
6693
|
const { rows: rows2, cols } = shape(value2);
|
|
@@ -6710,10 +6710,10 @@ function findExact(vector, lookup2, wildcards, reverse = false) {
|
|
|
6710
6710
|
const logicalLength = vector.logicalLength ?? vector.length;
|
|
6711
6711
|
if (reverse) {
|
|
6712
6712
|
if (lookup2 === null && logicalLength > vector.length) return logicalLength - 1;
|
|
6713
|
-
for (let
|
|
6713
|
+
for (let i2 = vector.length - 1; i2 >= 0; i2--) if (test(vector.get(i2))) return i2;
|
|
6714
6714
|
return -1;
|
|
6715
6715
|
}
|
|
6716
|
-
for (let
|
|
6716
|
+
for (let i2 = 0; i2 < vector.length; i2++) if (test(vector.get(i2))) return i2;
|
|
6717
6717
|
if (lookup2 === null && logicalLength > vector.length) return vector.length;
|
|
6718
6718
|
return -1;
|
|
6719
6719
|
}
|
|
@@ -6741,13 +6741,13 @@ function findAscending(vector, lookup2) {
|
|
|
6741
6741
|
function findDescending(vector, lookup2) {
|
|
6742
6742
|
if (isError(lookup2)) fail(lookup2);
|
|
6743
6743
|
let best = -1;
|
|
6744
|
-
for (let
|
|
6745
|
-
const v = vector.get(
|
|
6744
|
+
for (let i2 = 0; i2 < vector.length; i2++) {
|
|
6745
|
+
const v = vector.get(i2);
|
|
6746
6746
|
if (!sameKind(v, lookup2)) continue;
|
|
6747
6747
|
const c = compareScalars(v, lookup2);
|
|
6748
|
-
if (c === 0) return
|
|
6748
|
+
if (c === 0) return i2;
|
|
6749
6749
|
if (c < 0) break;
|
|
6750
|
-
best =
|
|
6750
|
+
best = i2;
|
|
6751
6751
|
}
|
|
6752
6752
|
return best;
|
|
6753
6753
|
}
|
|
@@ -6788,16 +6788,16 @@ function findNearest(vector, lookup2, mode, reverse) {
|
|
|
6788
6788
|
let best = -1;
|
|
6789
6789
|
let bestValue = null;
|
|
6790
6790
|
const n = vector.length;
|
|
6791
|
-
const consider = (
|
|
6791
|
+
const consider = (i2, v) => {
|
|
6792
6792
|
if (isError(v)) return false;
|
|
6793
6793
|
const c = compareLookup(v, lookup2);
|
|
6794
6794
|
if (c === 0) {
|
|
6795
|
-
best =
|
|
6795
|
+
best = i2;
|
|
6796
6796
|
return true;
|
|
6797
6797
|
}
|
|
6798
6798
|
if (mode === -1 ? c < 0 : c > 0) {
|
|
6799
6799
|
if (best < 0 || (mode === -1 ? compareLookup(v, bestValue) > 0 : compareLookup(v, bestValue) < 0)) {
|
|
6800
|
-
best =
|
|
6800
|
+
best = i2;
|
|
6801
6801
|
bestValue = v;
|
|
6802
6802
|
}
|
|
6803
6803
|
}
|
|
@@ -6806,8 +6806,8 @@ function findNearest(vector, lookup2, mode, reverse) {
|
|
|
6806
6806
|
const logicalLength = vector.logicalLength ?? n;
|
|
6807
6807
|
if (reverse && logicalLength > n && consider(logicalLength - 1, null)) return best;
|
|
6808
6808
|
for (let k = 0; k < n; k++) {
|
|
6809
|
-
const
|
|
6810
|
-
if (consider(
|
|
6809
|
+
const i2 = reverse ? n - 1 - k : k;
|
|
6810
|
+
if (consider(i2, vector.get(i2))) return best;
|
|
6811
6811
|
}
|
|
6812
6812
|
if (!reverse && logicalLength > n) consider(n, null);
|
|
6813
6813
|
return best;
|
|
@@ -7288,9 +7288,9 @@ var LOOKUP_FUNCTIONS = [
|
|
|
7288
7288
|
2,
|
|
7289
7289
|
255,
|
|
7290
7290
|
(args) => {
|
|
7291
|
-
const
|
|
7292
|
-
if (
|
|
7293
|
-
return args[
|
|
7291
|
+
const i2 = int(args[0]);
|
|
7292
|
+
if (i2 < 1 || i2 >= args.length) fail(ERR.VALUE);
|
|
7293
|
+
return args[i2] ?? null;
|
|
7294
7294
|
},
|
|
7295
7295
|
["value", "any"]
|
|
7296
7296
|
)
|
|
@@ -7409,8 +7409,8 @@ function matchingCells(ctx, pairs, target2, sameShape) {
|
|
|
7409
7409
|
const out = [];
|
|
7410
7410
|
const first2 = matrices[0];
|
|
7411
7411
|
const holds = (r, c) => {
|
|
7412
|
-
for (let
|
|
7413
|
-
if (!tests[
|
|
7412
|
+
for (let i2 = 0; i2 < tests.length; i2++) {
|
|
7413
|
+
if (!tests[i2](matrices[i2].get(r, c))) return false;
|
|
7414
7414
|
}
|
|
7415
7415
|
return true;
|
|
7416
7416
|
};
|
|
@@ -7431,10 +7431,10 @@ function matchingCells(ctx, pairs, target2, sameShape) {
|
|
|
7431
7431
|
}
|
|
7432
7432
|
function indexedCandidates(pairs, matrices) {
|
|
7433
7433
|
const first2 = matrices[0];
|
|
7434
|
-
for (let
|
|
7435
|
-
const m = matrices[
|
|
7436
|
-
if (!(pairs[
|
|
7437
|
-
const key = equalityKey(scalar(pairs[
|
|
7434
|
+
for (let i2 = 0; i2 < pairs.length; i2++) {
|
|
7435
|
+
const m = matrices[i2];
|
|
7436
|
+
if (!(pairs[i2]?.range instanceof RefValue) || m.cols !== first2.cols) continue;
|
|
7437
|
+
const key = equalityKey(scalar(pairs[i2]?.criteria));
|
|
7438
7438
|
if (key === void 0) continue;
|
|
7439
7439
|
const found = positionsOf(m, key);
|
|
7440
7440
|
if (found) return found;
|
|
@@ -7445,8 +7445,8 @@ var matchingValues = (ctx, pairs, target2, sameShape) => matchingCells(ctx, pair
|
|
|
7445
7445
|
function criteriaPairs(args, from) {
|
|
7446
7446
|
if ((args.length - from) % 2 !== 0) fail(ERR.VALUE);
|
|
7447
7447
|
const pairs = [];
|
|
7448
|
-
for (let
|
|
7449
|
-
pairs.push({ range: args[
|
|
7448
|
+
for (let i2 = from; i2 < args.length; i2 += 2) {
|
|
7449
|
+
pairs.push({ range: args[i2] ?? null, criteria: args[i2 + 1] ?? null });
|
|
7450
7450
|
}
|
|
7451
7451
|
return pairs;
|
|
7452
7452
|
}
|
|
@@ -7512,9 +7512,9 @@ function pairwise(ctx, args, fn) {
|
|
|
7512
7512
|
const ys = ctx.toMatrix(args[1] ?? null).flat();
|
|
7513
7513
|
if (xs.length !== ys.length) fail(ERR.NA);
|
|
7514
7514
|
let total2 = 0;
|
|
7515
|
-
for (let
|
|
7516
|
-
const x = xs[
|
|
7517
|
-
const y = ys[
|
|
7515
|
+
for (let i2 = 0; i2 < xs.length; i2++) {
|
|
7516
|
+
const x = xs[i2] ?? null;
|
|
7517
|
+
const y = ys[i2] ?? null;
|
|
7518
7518
|
if (isError(x)) fail(x);
|
|
7519
7519
|
if (isError(y)) fail(y);
|
|
7520
7520
|
if (typeof x === "number" && typeof y === "number") total2 += fn(x, y);
|
|
@@ -7909,7 +7909,7 @@ var MATH_MORE = [
|
|
|
7909
7909
|
const n = num(args[1]);
|
|
7910
7910
|
const m = num(args[2]);
|
|
7911
7911
|
return collectNumbers(ctx, [args[3] ?? null]).reduce(
|
|
7912
|
-
(acc, a,
|
|
7912
|
+
(acc, a, i2) => acc + a * Math.pow(x, n + i2 * m),
|
|
7913
7913
|
0
|
|
7914
7914
|
);
|
|
7915
7915
|
},
|
|
@@ -7922,7 +7922,7 @@ var C20 = "Math & Trig";
|
|
|
7922
7922
|
var fact = (n) => {
|
|
7923
7923
|
if (n < 0) fail(ERR.NUM);
|
|
7924
7924
|
let out = 1;
|
|
7925
|
-
for (let
|
|
7925
|
+
for (let i2 = 2; i2 <= Math.trunc(n); i2++) out *= i2;
|
|
7926
7926
|
return out;
|
|
7927
7927
|
};
|
|
7928
7928
|
function combin(n, k) {
|
|
@@ -7930,8 +7930,8 @@ function combin(n, k) {
|
|
|
7930
7930
|
const kk = Math.trunc(k);
|
|
7931
7931
|
if (nn < 0 || kk < 0 || kk > nn) fail(ERR.NUM);
|
|
7932
7932
|
let out = 1;
|
|
7933
|
-
for (let
|
|
7934
|
-
out = out * (nn - Math.min(kk, nn - kk) +
|
|
7933
|
+
for (let i2 = 1; i2 <= Math.min(kk, nn - kk); i2++)
|
|
7934
|
+
out = out * (nn - Math.min(kk, nn - kk) + i2) / i2;
|
|
7935
7935
|
return Math.round(out);
|
|
7936
7936
|
}
|
|
7937
7937
|
var gcd2 = (a, b) => b === 0 ? a : gcd2(b, a % b);
|
|
@@ -7946,7 +7946,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
7946
7946
|
numeric("FACTDOUBLE", C20, "FACTDOUBLE(number)", "The double factorial of a number.", 1, 1, (n) => {
|
|
7947
7947
|
if (n < -1) fail(ERR.NUM);
|
|
7948
7948
|
let out = 1;
|
|
7949
|
-
for (let
|
|
7949
|
+
for (let i2 = Math.trunc(n); i2 > 1; i2 -= 2) out *= i2;
|
|
7950
7950
|
return out;
|
|
7951
7951
|
}),
|
|
7952
7952
|
numeric(
|
|
@@ -8056,9 +8056,9 @@ function roundTo(x, digits2, mode) {
|
|
|
8056
8056
|
const result2 = d >= 0 ? rounded / factor : rounded * factor;
|
|
8057
8057
|
return result2 === 0 ? 0 : sign2 * result2;
|
|
8058
8058
|
}
|
|
8059
|
-
var quotientMultiple = (x, sig,
|
|
8059
|
+
var quotientMultiple = (x, sig, op2) => {
|
|
8060
8060
|
if (sig === 0) return 0;
|
|
8061
|
-
return
|
|
8061
|
+
return op2(round15(x / sig)) * sig;
|
|
8062
8062
|
};
|
|
8063
8063
|
var MATH_FUNCTIONS = [
|
|
8064
8064
|
...MATH_MORE,
|
|
@@ -8324,7 +8324,7 @@ function eliminate(input, invert2) {
|
|
|
8324
8324
|
const a = input.map((row2) => [...row2]);
|
|
8325
8325
|
const inv = Array.from(
|
|
8326
8326
|
{ length: n },
|
|
8327
|
-
(_,
|
|
8327
|
+
(_, i2) => Array.from({ length: n }, (_2, j) => i2 === j ? 1 : 0)
|
|
8328
8328
|
);
|
|
8329
8329
|
let det = 1;
|
|
8330
8330
|
for (let col = 0; col < n; col++) {
|
|
@@ -8429,7 +8429,7 @@ function fitLeastSquares(x, y, hasIntercept) {
|
|
|
8429
8429
|
);
|
|
8430
8430
|
const moment = Array.from(
|
|
8431
8431
|
{ length: k },
|
|
8432
|
-
(_, a) => total(xc.map((row2,
|
|
8432
|
+
(_, a) => total(xc.map((row2, i2) => (row2[a] ?? 0) * (yc[i2] ?? 0)))
|
|
8433
8433
|
);
|
|
8434
8434
|
const { det, inverse } = eliminate(gram, true);
|
|
8435
8435
|
if (!inverse || det === 0 || !Number.isFinite(det)) fail(ERR.NUM);
|
|
@@ -8437,10 +8437,10 @@ function fitLeastSquares(x, y, hasIntercept) {
|
|
|
8437
8437
|
const intercept = hasIntercept ? yMean - total(slopes.map((m, j) => m * (means[j] ?? 0))) : 0;
|
|
8438
8438
|
let ssResid = 0;
|
|
8439
8439
|
let ssTotal = 0;
|
|
8440
|
-
for (let
|
|
8441
|
-
const predicted = intercept + total(slopes.map((m, j) => m * (x[
|
|
8442
|
-
ssResid += ((y[
|
|
8443
|
-
ssTotal += ((y[
|
|
8440
|
+
for (let i2 = 0; i2 < n; i2++) {
|
|
8441
|
+
const predicted = intercept + total(slopes.map((m, j) => m * (x[i2]?.[j] ?? 0)));
|
|
8442
|
+
ssResid += ((y[i2] ?? 0) - predicted) ** 2;
|
|
8443
|
+
ssTotal += ((y[i2] ?? 0) - yMean) ** 2;
|
|
8444
8444
|
}
|
|
8445
8445
|
return { slopes, intercept, inverse, means, n, hasIntercept, ssTotal, ssResid };
|
|
8446
8446
|
}
|
|
@@ -8491,7 +8491,7 @@ function layout(ctx, args) {
|
|
|
8491
8491
|
if (rows2 === 0 || cols === 0 || rows2 > 1 && cols > 1) fail(ERR.REF);
|
|
8492
8492
|
const column = cols === 1;
|
|
8493
8493
|
const y = ym.flat();
|
|
8494
|
-
if (omitted(args, 1)) return { y, x: y.map((_,
|
|
8494
|
+
if (omitted(args, 1)) return { y, x: y.map((_, i2) => [i2 + 1]), column };
|
|
8495
8495
|
const xm = numbersOf2(ctx, args[1]);
|
|
8496
8496
|
const x = asObservations(xm, column);
|
|
8497
8497
|
if (x.length !== y.length) {
|
|
@@ -8505,11 +8505,11 @@ var row = (values2, width) => [
|
|
|
8505
8505
|
...values2,
|
|
8506
8506
|
...new Array(Math.max(0, width - values2.length)).fill(ERR.NA)
|
|
8507
8507
|
];
|
|
8508
|
-
function coefficientTable(fit, stats,
|
|
8508
|
+
function coefficientTable(fit, stats, transform6) {
|
|
8509
8509
|
const k = fit.slopes.length;
|
|
8510
8510
|
const width = k + 1;
|
|
8511
|
-
const slopes = [...fit.slopes].reverse().map(
|
|
8512
|
-
const head = [...slopes,
|
|
8511
|
+
const slopes = [...fit.slopes].reverse().map(transform6);
|
|
8512
|
+
const head = [...slopes, transform6(fit.intercept)];
|
|
8513
8513
|
if (!stats) return new Matrix([head]);
|
|
8514
8514
|
const s = fitStatistics(fit);
|
|
8515
8515
|
const errors = [...s.slopeErrors].reverse();
|
|
@@ -8521,8 +8521,8 @@ function coefficientTable(fit, stats, transform) {
|
|
|
8521
8521
|
row([s.ssRegression, s.ssResidual], width)
|
|
8522
8522
|
]);
|
|
8523
8523
|
}
|
|
8524
|
-
function predictions(ctx, args, lay, fit,
|
|
8525
|
-
const predict = (obs) =>
|
|
8524
|
+
function predictions(ctx, args, lay, fit, transform6) {
|
|
8525
|
+
const predict = (obs) => transform6(fit.intercept + fit.slopes.reduce((a, m, j) => a + m * (obs[j] ?? 0), 0));
|
|
8526
8526
|
if (omitted(args, 2)) {
|
|
8527
8527
|
const out2 = lay.x.map(predict);
|
|
8528
8528
|
return new Matrix(lay.column ? out2.map((v) => [v]) : [out2]);
|
|
@@ -8622,9 +8622,9 @@ function gammaP(a, x) {
|
|
|
8622
8622
|
let b = x + 1 - a;
|
|
8623
8623
|
let c = 1 / 1e-300;
|
|
8624
8624
|
let d = 1 / b;
|
|
8625
|
-
let
|
|
8626
|
-
for (let
|
|
8627
|
-
const an = -
|
|
8625
|
+
let h2 = d;
|
|
8626
|
+
for (let i2 = 1; i2 < 1e3; i2++) {
|
|
8627
|
+
const an = -i2 * (i2 - a);
|
|
8628
8628
|
b += 2;
|
|
8629
8629
|
d = an * d + b;
|
|
8630
8630
|
if (Math.abs(d) < 1e-300) d = 1e-300;
|
|
@@ -8632,10 +8632,10 @@ function gammaP(a, x) {
|
|
|
8632
8632
|
if (Math.abs(c) < 1e-300) c = 1e-300;
|
|
8633
8633
|
d = 1 / d;
|
|
8634
8634
|
const del = d * c;
|
|
8635
|
-
|
|
8635
|
+
h2 *= del;
|
|
8636
8636
|
if (Math.abs(del - 1) < EPS) break;
|
|
8637
8637
|
}
|
|
8638
|
-
return 1 - Math.exp(lnPrefix) *
|
|
8638
|
+
return 1 - Math.exp(lnPrefix) * h2;
|
|
8639
8639
|
}
|
|
8640
8640
|
function betaCf(a, b, x) {
|
|
8641
8641
|
const qab = a + b;
|
|
@@ -8645,7 +8645,7 @@ function betaCf(a, b, x) {
|
|
|
8645
8645
|
let d = 1 - qab * x / qap;
|
|
8646
8646
|
if (Math.abs(d) < 1e-300) d = 1e-300;
|
|
8647
8647
|
d = 1 / d;
|
|
8648
|
-
let
|
|
8648
|
+
let h2 = d;
|
|
8649
8649
|
for (let m = 1; m <= 1e3; m++) {
|
|
8650
8650
|
const m2 = 2 * m;
|
|
8651
8651
|
let aa = m * (b - m) * x / ((qam + m2) * (a + m2));
|
|
@@ -8654,7 +8654,7 @@ function betaCf(a, b, x) {
|
|
|
8654
8654
|
c = 1 + aa / c;
|
|
8655
8655
|
if (Math.abs(c) < 1e-300) c = 1e-300;
|
|
8656
8656
|
d = 1 / d;
|
|
8657
|
-
|
|
8657
|
+
h2 *= d * c;
|
|
8658
8658
|
aa = -(a + m) * (qab + m) * x / ((a + m2) * (qap + m2));
|
|
8659
8659
|
d = 1 + aa * d;
|
|
8660
8660
|
if (Math.abs(d) < 1e-300) d = 1e-300;
|
|
@@ -8662,10 +8662,10 @@ function betaCf(a, b, x) {
|
|
|
8662
8662
|
if (Math.abs(c) < 1e-300) c = 1e-300;
|
|
8663
8663
|
d = 1 / d;
|
|
8664
8664
|
const del = d * c;
|
|
8665
|
-
|
|
8665
|
+
h2 *= del;
|
|
8666
8666
|
if (Math.abs(del - 1) < EPS) break;
|
|
8667
8667
|
}
|
|
8668
|
-
return
|
|
8668
|
+
return h2;
|
|
8669
8669
|
}
|
|
8670
8670
|
function betaI(x, a, b) {
|
|
8671
8671
|
if (x <= 0) return 0;
|
|
@@ -8704,7 +8704,7 @@ function normInv(p) {
|
|
|
8704
8704
|
2.938163982698783
|
|
8705
8705
|
];
|
|
8706
8706
|
const d = [0.007784695709041462, 0.3224671290700398, 2.445134137142996, 3.754408661907416];
|
|
8707
|
-
const at = (arr,
|
|
8707
|
+
const at = (arr, i2) => arr[i2];
|
|
8708
8708
|
let x;
|
|
8709
8709
|
if (p < 0.02425) {
|
|
8710
8710
|
const q = Math.sqrt(-2 * Math.log(p));
|
|
@@ -8725,7 +8725,7 @@ function invert(cdf, p, lo, hi) {
|
|
|
8725
8725
|
let a = lo;
|
|
8726
8726
|
let b = hi;
|
|
8727
8727
|
while (cdf(b) < p && b < 1e10) b *= 2;
|
|
8728
|
-
for (let
|
|
8728
|
+
for (let i2 = 0; i2 < 200; i2++) {
|
|
8729
8729
|
const mid = (a + b) / 2;
|
|
8730
8730
|
if (cdf(mid) < p) a = mid;
|
|
8731
8731
|
else b = mid;
|
|
@@ -8757,7 +8757,7 @@ function binomDist(k, n, p, cumulative2) {
|
|
|
8757
8757
|
if (kk < 0 || kk > nn || p < 0 || p > 1) fail(ERR.NUM);
|
|
8758
8758
|
if (!cumulative2) return binomPmf(kk, nn, p);
|
|
8759
8759
|
let total2 = 0;
|
|
8760
|
-
for (let
|
|
8760
|
+
for (let i2 = 0; i2 <= kk; i2++) total2 += binomPmf(i2, nn, p);
|
|
8761
8761
|
return Math.min(1, total2);
|
|
8762
8762
|
}
|
|
8763
8763
|
function poisson(k, mean2, cumulative2) {
|
|
@@ -8815,16 +8815,16 @@ function binomInverse(trials, p, alpha) {
|
|
|
8815
8815
|
}
|
|
8816
8816
|
return n;
|
|
8817
8817
|
}
|
|
8818
|
-
var hypgeomPmf = (k, n,
|
|
8818
|
+
var hypgeomPmf = (k, n, K5, N) => {
|
|
8819
8819
|
const kk = Math.trunc(k);
|
|
8820
8820
|
const nn = Math.trunc(n);
|
|
8821
|
-
const KK = Math.trunc(
|
|
8821
|
+
const KK = Math.trunc(K5);
|
|
8822
8822
|
const NN = Math.trunc(N);
|
|
8823
8823
|
if (kk < 0 || nn > NN || KK > NN || kk > Math.min(nn, KK) || kk < nn - (NN - KK)) fail(ERR.NUM);
|
|
8824
8824
|
return combin(KK, kk) * combin(NN - KK, nn - kk) / combin(NN, nn);
|
|
8825
8825
|
};
|
|
8826
|
-
var negbinomPmf = (
|
|
8827
|
-
const ff = Math.trunc(
|
|
8826
|
+
var negbinomPmf = (f6, s, p) => {
|
|
8827
|
+
const ff = Math.trunc(f6);
|
|
8828
8828
|
const ss = Math.trunc(s);
|
|
8829
8829
|
if (ff < 0 || ss < 1 || p < 0 || p > 1) fail(ERR.NUM);
|
|
8830
8830
|
return combin(ff + ss - 1, ss - 1) * Math.pow(p, ss) * Math.pow(1 - p, ff);
|
|
@@ -9020,7 +9020,7 @@ function moments(values2) {
|
|
|
9020
9020
|
return { n, m: mean(values2), s: stdev(values2, true) };
|
|
9021
9021
|
}
|
|
9022
9022
|
function frequency(data, bins) {
|
|
9023
|
-
const order = bins.map((b,
|
|
9023
|
+
const order = bins.map((b, i2) => ({ b, i: i2 })).sort((x, y) => x.b - y.b);
|
|
9024
9024
|
const counts = new Array(bins.length + 1).fill(0);
|
|
9025
9025
|
for (const v of data) {
|
|
9026
9026
|
const slot = order.find((o) => v <= o.b);
|
|
@@ -9182,7 +9182,7 @@ var STATISTICAL_SHAPE = [
|
|
|
9182
9182
|
const kk = Math.trunc(k ?? 0);
|
|
9183
9183
|
if (nn < 0 || kk < 0 || kk > nn) fail(ERR.NUM);
|
|
9184
9184
|
let out = 1;
|
|
9185
|
-
for (let
|
|
9185
|
+
for (let i2 = 0; i2 < kk; i2++) out *= nn - i2;
|
|
9186
9186
|
return out;
|
|
9187
9187
|
}
|
|
9188
9188
|
),
|
|
@@ -9243,9 +9243,9 @@ function pairedNumbers(ctx, a, b) {
|
|
|
9243
9243
|
if (ma.length !== mb.length) fail(ERR.NA);
|
|
9244
9244
|
const xs = [];
|
|
9245
9245
|
const ys = [];
|
|
9246
|
-
for (let
|
|
9247
|
-
const x = ma[
|
|
9248
|
-
const y = mb[
|
|
9246
|
+
for (let i2 = 0; i2 < ma.length; i2++) {
|
|
9247
|
+
const x = ma[i2] ?? null;
|
|
9248
|
+
const y = mb[i2] ?? null;
|
|
9249
9249
|
if (isError(x)) fail(x);
|
|
9250
9250
|
if (isError(y)) fail(y);
|
|
9251
9251
|
if (typeof x === "number" && typeof y === "number") {
|
|
@@ -9340,9 +9340,9 @@ var STATISTICAL_MORE = [
|
|
|
9340
9340
|
let sxy = 0;
|
|
9341
9341
|
let sxx = 0;
|
|
9342
9342
|
let syy = 0;
|
|
9343
|
-
for (let
|
|
9344
|
-
const dx = xs[
|
|
9345
|
-
const dy = ys[
|
|
9343
|
+
for (let i2 = 0; i2 < n; i2++) {
|
|
9344
|
+
const dx = xs[i2] - mx;
|
|
9345
|
+
const dy = ys[i2] - my;
|
|
9346
9346
|
sxy += dx * dy;
|
|
9347
9347
|
sxx += dx * dx;
|
|
9348
9348
|
syy += dy * dy;
|
|
@@ -9377,7 +9377,7 @@ var numbersOf3 = (ctx, value2) => collectNumbers(ctx, [value2 ?? null]);
|
|
|
9377
9377
|
function tStatistic(a, b, type) {
|
|
9378
9378
|
if (type === 1) {
|
|
9379
9379
|
if (a.length !== b.length) fail(ERR.NA);
|
|
9380
|
-
const diffs = a.map((v,
|
|
9380
|
+
const diffs = a.map((v, i2) => v - (b[i2] ?? 0));
|
|
9381
9381
|
const n = diffs.length;
|
|
9382
9382
|
if (n < 2) fail(ERR.DIV0);
|
|
9383
9383
|
const sd = stdev(diffs, true);
|
|
@@ -9439,8 +9439,8 @@ function probability2(ctx, args) {
|
|
|
9439
9439
|
const upper2 = args.length > 3 && args[3] !== null ? num(args[3]) : lower2;
|
|
9440
9440
|
let total2 = 0;
|
|
9441
9441
|
let hit = 0;
|
|
9442
|
-
for (let
|
|
9443
|
-
const [x, p] = [xs[
|
|
9442
|
+
for (let i2 = 0; i2 < xs.length; i2++) {
|
|
9443
|
+
const [x, p] = [xs[i2] ?? null, ps[i2] ?? null];
|
|
9444
9444
|
if (isError(x)) fail(x);
|
|
9445
9445
|
if (isError(p)) fail(p);
|
|
9446
9446
|
if (typeof p !== "number" || p < 0 || p > 1) fail(ERR.NUM);
|
|
@@ -10097,8 +10097,8 @@ var DISTRIBUTION_MORE = [
|
|
|
10097
10097
|
"The negative binomial distribution.",
|
|
10098
10098
|
4,
|
|
10099
10099
|
4,
|
|
10100
|
-
(
|
|
10101
|
-
const ff = Math.trunc(
|
|
10100
|
+
(f6, s, p, c) => {
|
|
10101
|
+
const ff = Math.trunc(f6);
|
|
10102
10102
|
const ss = Math.trunc(s ?? 0);
|
|
10103
10103
|
const pp = p ?? 0;
|
|
10104
10104
|
if (ff < 0 || ss < 1 || pp < 0 || pp > 1) fail(ERR.NUM);
|
|
@@ -10116,16 +10116,16 @@ var DISTRIBUTION_MORE = [
|
|
|
10116
10116
|
"The hypergeometric distribution.",
|
|
10117
10117
|
5,
|
|
10118
10118
|
5,
|
|
10119
|
-
(k, n,
|
|
10119
|
+
(k, n, K5, N, c) => {
|
|
10120
10120
|
const kk = Math.trunc(k);
|
|
10121
10121
|
const nn = Math.trunc(n ?? 0);
|
|
10122
|
-
const KK = Math.trunc(
|
|
10122
|
+
const KK = Math.trunc(K5 ?? 0);
|
|
10123
10123
|
const NN = Math.trunc(N ?? 0);
|
|
10124
10124
|
if (kk < 0 || nn > NN || KK > NN || kk > Math.min(nn, KK)) fail(ERR.NUM);
|
|
10125
|
-
const pmf = (
|
|
10125
|
+
const pmf = (i2) => combin(KK, i2) * combin(NN - KK, nn - i2) / combin(NN, nn);
|
|
10126
10126
|
if (!c) return pmf(kk);
|
|
10127
10127
|
let total2 = 0;
|
|
10128
|
-
for (let
|
|
10128
|
+
for (let i2 = Math.max(0, nn - (NN - KK)); i2 <= kk; i2++) total2 += pmf(i2);
|
|
10129
10129
|
return total2;
|
|
10130
10130
|
}
|
|
10131
10131
|
)
|
|
@@ -10541,15 +10541,15 @@ function lowerChar(ch, before, after) {
|
|
|
10541
10541
|
function mapChars(text, fn) {
|
|
10542
10542
|
const chars = [...text];
|
|
10543
10543
|
let out = "";
|
|
10544
|
-
for (let
|
|
10544
|
+
for (let i2 = 0; i2 < chars.length; i2++) out += fn(chars[i2], i2, chars);
|
|
10545
10545
|
return out;
|
|
10546
10546
|
}
|
|
10547
10547
|
var upper = (text) => mapChars(text, upperChar);
|
|
10548
|
-
var lower = (text) => mapChars(text, (ch,
|
|
10549
|
-
var proper = (text) => mapChars(text, (ch,
|
|
10548
|
+
var lower = (text) => mapChars(text, (ch, i2, all2) => lowerChar(ch, all2[i2 - 1], all2[i2 + 1]));
|
|
10549
|
+
var proper = (text) => mapChars(text, (ch, i2, all2) => {
|
|
10550
10550
|
if (!isLetter(ch)) return ch;
|
|
10551
|
-
const before = all2[
|
|
10552
|
-
return before !== void 0 && isLetter(before) ? lowerChar(ch, before, all2[
|
|
10551
|
+
const before = all2[i2 - 1];
|
|
10552
|
+
return before !== void 0 && isLetter(before) ? lowerChar(ch, before, all2[i2 + 1]) : upperChar(ch);
|
|
10553
10553
|
});
|
|
10554
10554
|
var isHigh = (code) => code >= 55296 && code <= 56319;
|
|
10555
10555
|
var isLow = (code) => code >= 56320 && code <= 57343;
|
|
@@ -10628,8 +10628,8 @@ var TEXT_FUNCTIONS = [
|
|
|
10628
10628
|
const ignoreEmpty = bool(ctx.toScalar(args[1] ?? null));
|
|
10629
10629
|
const parts = joinValues(ctx, args.slice(2)).filter((p) => !ignoreEmpty || p !== "");
|
|
10630
10630
|
let out = "";
|
|
10631
|
-
parts.forEach((p,
|
|
10632
|
-
if (
|
|
10631
|
+
parts.forEach((p, i2) => {
|
|
10632
|
+
if (i2 > 0) out += delimiters.length ? delimiters[(i2 - 1) % delimiters.length] : "";
|
|
10633
10633
|
out += p;
|
|
10634
10634
|
});
|
|
10635
10635
|
return limit(out);
|
|
@@ -10741,7 +10741,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10741
10741
|
const instance = Math.trunc(num(args[3]));
|
|
10742
10742
|
if (instance < 1) fail(ERR.VALUE);
|
|
10743
10743
|
let at = -1;
|
|
10744
|
-
for (let
|
|
10744
|
+
for (let i2 = 0; i2 < instance; i2++) {
|
|
10745
10745
|
at = text.indexOf(oldText, at + 1);
|
|
10746
10746
|
if (at < 0) return text;
|
|
10747
10747
|
}
|
|
@@ -10887,19 +10887,19 @@ function occurrences(text, delimiters, insensitive) {
|
|
|
10887
10887
|
const hay = insensitive ? text.toLowerCase() : text;
|
|
10888
10888
|
const needles = delimiters.map((d) => insensitive ? d.toLowerCase() : d);
|
|
10889
10889
|
const out = [];
|
|
10890
|
-
let
|
|
10891
|
-
while (
|
|
10890
|
+
let i2 = 0;
|
|
10891
|
+
while (i2 <= hay.length) {
|
|
10892
10892
|
let best;
|
|
10893
10893
|
for (const n of needles) {
|
|
10894
10894
|
if (n === "") continue;
|
|
10895
|
-
const at = hay.indexOf(n,
|
|
10895
|
+
const at = hay.indexOf(n, i2);
|
|
10896
10896
|
if (at >= 0 && (!best || at < best.at || at === best.at && n.length > best.length)) {
|
|
10897
10897
|
best = { at, length: n.length };
|
|
10898
10898
|
}
|
|
10899
10899
|
}
|
|
10900
10900
|
if (!best) break;
|
|
10901
10901
|
out.push(best);
|
|
10902
|
-
|
|
10902
|
+
i2 = best.at + best.length;
|
|
10903
10903
|
}
|
|
10904
10904
|
return out;
|
|
10905
10905
|
}
|
|
@@ -10975,13 +10975,13 @@ var TEXT_EXTRA_FUNCTIONS = [
|
|
|
10975
10975
|
const rowDelims = delimitersOf(ctx, args[2]);
|
|
10976
10976
|
const ignoreEmpty = args.length > 3 && args[3] !== null && Boolean(scalar(ctx.toScalar(args[3] ?? null)));
|
|
10977
10977
|
const insensitive = args.length > 4 && optNum([ctx.toScalar(args[4] ?? null)], 0, 0) === 1;
|
|
10978
|
-
const
|
|
10978
|
+
const pad4 = args.length > 5 ? ctx.toScalar(args[5] ?? null) : ERR.NA;
|
|
10979
10979
|
if (colDelims.length === 0 && rowDelims.length === 0) fail(ERR.VALUE);
|
|
10980
10980
|
const rows2 = splitText(text, rowDelims, insensitive, ignoreEmpty).map(
|
|
10981
10981
|
(line2) => splitText(line2, colDelims, insensitive, ignoreEmpty)
|
|
10982
10982
|
);
|
|
10983
10983
|
const width = rows2.reduce((w, r) => Math.max(w, r.length), 0);
|
|
10984
|
-
return new Matrix(rows2.map((r) => Array.from({ length: width }, (_,
|
|
10984
|
+
return new Matrix(rows2.map((r) => Array.from({ length: width }, (_, i2) => r[i2] ?? pad4)));
|
|
10985
10985
|
},
|
|
10986
10986
|
["any"]
|
|
10987
10987
|
),
|
|
@@ -11087,12 +11087,12 @@ function callFunction(node, frame) {
|
|
|
11087
11087
|
}
|
|
11088
11088
|
const arrayFrame = frame.legacy ? { ...frame, legacy: false } : frame;
|
|
11089
11089
|
const args = node.args.map(
|
|
11090
|
-
(arg,
|
|
11090
|
+
(arg, i2) => evaluateNode(arg, paramKind(spec2, i2) === "any" ? arrayFrame : frame)
|
|
11091
11091
|
);
|
|
11092
|
-
for (let
|
|
11093
|
-
const fallback = spec2.missingDefaults?.[
|
|
11094
|
-
if (node.args[
|
|
11095
|
-
args[
|
|
11092
|
+
for (let i2 = 0; i2 < args.length; i2++) {
|
|
11093
|
+
const fallback = spec2.missingDefaults?.[i2];
|
|
11094
|
+
if (node.args[i2]?.type === "missing" && fallback !== void 0)
|
|
11095
|
+
args[i2] = typeof fallback === "function" ? guard(() => fallback(args, ctx)) : fallback;
|
|
11096
11096
|
}
|
|
11097
11097
|
return applyFunction(spec2, args, ctx);
|
|
11098
11098
|
}
|
|
@@ -11100,9 +11100,9 @@ function applyFunction(spec2, args, ctx) {
|
|
|
11100
11100
|
const fn = spec2.fn;
|
|
11101
11101
|
if (!fn) return ERR.VALUE;
|
|
11102
11102
|
const lifted = [];
|
|
11103
|
-
for (let
|
|
11104
|
-
if (paramKind(spec2,
|
|
11105
|
-
let arg = args[
|
|
11103
|
+
for (let i2 = 0; i2 < args.length; i2++) {
|
|
11104
|
+
if (paramKind(spec2, i2) !== "value") continue;
|
|
11105
|
+
let arg = args[i2];
|
|
11106
11106
|
if (arg instanceof RefValue) {
|
|
11107
11107
|
if (ctx.frame.legacy && !arg.isCell()) arg = ctx.toScalar(arg);
|
|
11108
11108
|
else if (arg.isCell()) {
|
|
@@ -11121,12 +11121,12 @@ function applyFunction(spec2, args, ctx) {
|
|
|
11121
11121
|
if (arg.rows === 1 && arg.cols === 1) arg = arg.get(0, 0);
|
|
11122
11122
|
else lifted.push(arg);
|
|
11123
11123
|
}
|
|
11124
|
-
args[
|
|
11124
|
+
args[i2] = arg;
|
|
11125
11125
|
}
|
|
11126
11126
|
if (lifted.length === 0) return guard(() => fn(args, ctx));
|
|
11127
11127
|
return broadcastShape(lifted, (r, c) => {
|
|
11128
11128
|
const element2 = args.map(
|
|
11129
|
-
(arg,
|
|
11129
|
+
(arg, i2) => arg instanceof Matrix && paramKind(spec2, i2) === "value" ? pick(arg, r, c) : arg
|
|
11130
11130
|
);
|
|
11131
11131
|
return toElement2(
|
|
11132
11132
|
guard(() => fn(element2, ctx)),
|
|
@@ -11258,8 +11258,8 @@ function evaluateBinary(node, frame) {
|
|
|
11258
11258
|
leftmost = leftmost.left;
|
|
11259
11259
|
}
|
|
11260
11260
|
let value2 = evaluateNode(leftmost, frame);
|
|
11261
|
-
for (let
|
|
11262
|
-
value2 = applyBinary(spine[
|
|
11261
|
+
for (let i2 = spine.length - 1; i2 >= 0; i2--)
|
|
11262
|
+
value2 = applyBinary(spine[i2], value2, frame);
|
|
11263
11263
|
return value2;
|
|
11264
11264
|
}
|
|
11265
11265
|
function applyBinary(node, left2, frame) {
|
|
@@ -11320,7 +11320,7 @@ function invokeLambda(callee, args, frame) {
|
|
|
11320
11320
|
if (!(callee instanceof LambdaValue)) return ERR.VALUE;
|
|
11321
11321
|
if (args.length > callee.params.length) return ERR.VALUE;
|
|
11322
11322
|
const scope = new Map(callee.scope ?? []);
|
|
11323
|
-
callee.params.forEach((param,
|
|
11323
|
+
callee.params.forEach((param, i2) => scope.set(param, args[i2] ?? null));
|
|
11324
11324
|
return evaluateNode(callee.body, { ...frame, scope, root: void 0 });
|
|
11325
11325
|
}
|
|
11326
11326
|
|
|
@@ -11400,8 +11400,8 @@ function visit(node, c) {
|
|
|
11400
11400
|
if (spec2?.volatile) c.volatile = true;
|
|
11401
11401
|
if (!spec2 && !isLocalOrDefined(node.rawName, c)) c.unsupported = true;
|
|
11402
11402
|
const reference = spec2 !== void 0 && REFERENCE_ARGUMENT.has(node.name);
|
|
11403
|
-
node.args.forEach((arg,
|
|
11404
|
-
if (reference &&
|
|
11403
|
+
node.args.forEach((arg, i2) => {
|
|
11404
|
+
if (reference && i2 === 0) {
|
|
11405
11405
|
c.dynamic++;
|
|
11406
11406
|
visit(arg, c);
|
|
11407
11407
|
c.dynamic--;
|
|
@@ -11427,11 +11427,11 @@ function visitBinary(node, c) {
|
|
|
11427
11427
|
const staticStart = c.deps.length;
|
|
11428
11428
|
const dynamicStart = c.dynamicDeps.length;
|
|
11429
11429
|
visit(leftmost, c);
|
|
11430
|
-
for (let
|
|
11431
|
-
const
|
|
11432
|
-
visit(
|
|
11433
|
-
if (
|
|
11434
|
-
if (
|
|
11430
|
+
for (let i2 = spine.length - 1; i2 >= 0; i2--) {
|
|
11431
|
+
const op2 = spine[i2];
|
|
11432
|
+
visit(op2.right, c);
|
|
11433
|
+
if (op2.op !== ":") continue;
|
|
11434
|
+
if (op2.left.type === "ref" && op2.right.type === "ref") {
|
|
11435
11435
|
const list = c.dynamic > 0 ? c.dynamicDeps : c.deps;
|
|
11436
11436
|
const l = list[list.length - 2];
|
|
11437
11437
|
const r = list[list.length - 1];
|
|
@@ -11601,8 +11601,8 @@ var ColumnIndex = class {
|
|
|
11601
11601
|
if (list[mid].row < start.row) lo = mid + 1;
|
|
11602
11602
|
else hi = mid;
|
|
11603
11603
|
}
|
|
11604
|
-
for (let
|
|
11605
|
-
const node = list[
|
|
11604
|
+
for (let i2 = lo; i2 < list.length; i2++) {
|
|
11605
|
+
const node = list[i2];
|
|
11606
11606
|
if (node.row > end.row) break;
|
|
11607
11607
|
out.push(node);
|
|
11608
11608
|
}
|
|
@@ -12143,11 +12143,11 @@ var EngineCore = class extends EngineHost {
|
|
|
12143
12143
|
}
|
|
12144
12144
|
run(seeds, everything) {
|
|
12145
12145
|
let current = seeds;
|
|
12146
|
-
for (let
|
|
12147
|
-
const dirty = everything &&
|
|
12146
|
+
for (let round3 = 0; round3 < MAX_ROUNDS && current.size; round3++) {
|
|
12147
|
+
const dirty = everything && round3 === 0 ? current : this.closure(current);
|
|
12148
12148
|
this.footprintChanges = [];
|
|
12149
12149
|
this.evaluatedAt = /* @__PURE__ */ new Map();
|
|
12150
|
-
this.evaluateSet(dirty, everything &&
|
|
12150
|
+
this.evaluateSet(dirty, everything && round3 === 0);
|
|
12151
12151
|
if (this.footprintChanges.length === 0) break;
|
|
12152
12152
|
const next = /* @__PURE__ */ new Set();
|
|
12153
12153
|
const reverse = this.reverse();
|
|
@@ -12563,22 +12563,22 @@ function shiftInterval(a, b, at, count2, max) {
|
|
|
12563
12563
|
function mergeSpacedAreas(tokens) {
|
|
12564
12564
|
const out = [];
|
|
12565
12565
|
const plainCell = (t) => t?.kind === "ref" && t.ref?.kind === "cell" && !t.spill;
|
|
12566
|
-
for (let
|
|
12567
|
-
const first2 = tokens[
|
|
12568
|
-
let j =
|
|
12566
|
+
for (let i2 = 0; i2 < tokens.length; i2++) {
|
|
12567
|
+
const first2 = tokens[i2];
|
|
12568
|
+
let j = i2 + 1;
|
|
12569
12569
|
while (tokens[j]?.kind === "ws") j++;
|
|
12570
12570
|
let k = j + 1;
|
|
12571
12571
|
while (tokens[k]?.kind === "ws") k++;
|
|
12572
12572
|
const colon = tokens[j];
|
|
12573
12573
|
const last = tokens[k];
|
|
12574
|
-
if (plainCell(first2) && colon?.kind === "op" && colon.text === ":" && plainCell(last) && !last?.prefix && k >
|
|
12575
|
-
const text = tokens.slice(
|
|
12574
|
+
if (plainCell(first2) && colon?.kind === "op" && colon.text === ":" && plainCell(last) && !last?.prefix && k > i2 + 2 && first2.ref && last?.ref) {
|
|
12575
|
+
const text = tokens.slice(i2, k + 1).map((t) => t.text).join("");
|
|
12576
12576
|
out.push({
|
|
12577
12577
|
...first2,
|
|
12578
12578
|
text,
|
|
12579
12579
|
ref: { kind: "area", start: first2.ref.start, end: last.ref.start }
|
|
12580
12580
|
});
|
|
12581
|
-
|
|
12581
|
+
i2 = k;
|
|
12582
12582
|
continue;
|
|
12583
12583
|
}
|
|
12584
12584
|
out.push(first2);
|
|
@@ -12753,8 +12753,8 @@ function a1For(ref, t) {
|
|
|
12753
12753
|
const { start, end } = table2.range;
|
|
12754
12754
|
const index2 = (name) => {
|
|
12755
12755
|
if (name === void 0) return void 0;
|
|
12756
|
-
const
|
|
12757
|
-
return
|
|
12756
|
+
const i2 = table2.columns.findIndex((c) => c.name.toLowerCase() === name.toLowerCase());
|
|
12757
|
+
return i2 < 0 ? -1 : start.col + i2;
|
|
12758
12758
|
};
|
|
12759
12759
|
const c1 = index2(ref.column);
|
|
12760
12760
|
const c2 = index2(ref.column2) ?? c1;
|
|
@@ -13003,7 +13003,7 @@ var CHART_COLOR_PALETTES = [
|
|
|
13003
13003
|
colorful(11, 2, ["accent1", "accent3", "accent5"]),
|
|
13004
13004
|
colorful(12, 3, ["accent2", "accent4", "accent6"]),
|
|
13005
13005
|
colorful(13, 4, ["accent6", "accent5", "accent4"]),
|
|
13006
|
-
...ACCENTS2.map((accent,
|
|
13006
|
+
...ACCENTS2.map((accent, i2) => mono(14 + i2, 1 + i2, accent, "withinLinear")),
|
|
13007
13007
|
{
|
|
13008
13008
|
id: 20,
|
|
13009
13009
|
group: "monochromatic",
|
|
@@ -13012,43 +13012,43 @@ var CHART_COLOR_PALETTES = [
|
|
|
13012
13012
|
base: ["dk1"],
|
|
13013
13013
|
variations: GRAY_VARIATIONS
|
|
13014
13014
|
},
|
|
13015
|
-
...ACCENTS2.map((accent,
|
|
13015
|
+
...ACCENTS2.map((accent, i2) => mono(21 + i2, 8 + i2, accent, "withinLinearReversed"))
|
|
13016
13016
|
];
|
|
13017
13017
|
function findChartColorPalette(id) {
|
|
13018
13018
|
return CHART_COLOR_PALETTES.find((palette) => palette.id === id);
|
|
13019
13019
|
}
|
|
13020
|
-
function withinLinearTransform(
|
|
13020
|
+
function withinLinearTransform(i2, n) {
|
|
13021
13021
|
if (n <= 1) {
|
|
13022
13022
|
return {};
|
|
13023
13023
|
}
|
|
13024
13024
|
const step = 140 / (n + 1);
|
|
13025
13025
|
const centre = (n - 1) / 2;
|
|
13026
|
-
const value2 = 100 - step * Math.abs(
|
|
13027
|
-
if (
|
|
13026
|
+
const value2 = 100 - step * Math.abs(i2 - centre);
|
|
13027
|
+
if (i2 < centre) {
|
|
13028
13028
|
return { shade: Math.floor(value2 + 1e-9) * 1e3 };
|
|
13029
13029
|
}
|
|
13030
|
-
if (
|
|
13030
|
+
if (i2 > centre) {
|
|
13031
13031
|
return { tint: Math.ceil(value2 - 1e-9) * 1e3 };
|
|
13032
13032
|
}
|
|
13033
13033
|
return {};
|
|
13034
13034
|
}
|
|
13035
|
-
function chartPaletteSeriesColorChoice(palette,
|
|
13035
|
+
function chartPaletteSeriesColorChoice(palette, i2, n) {
|
|
13036
13036
|
let base;
|
|
13037
|
-
let
|
|
13037
|
+
let transform6;
|
|
13038
13038
|
if (palette.meth === "cycle") {
|
|
13039
|
-
base = palette.base[
|
|
13040
|
-
const
|
|
13041
|
-
|
|
13039
|
+
base = palette.base[i2 % palette.base.length];
|
|
13040
|
+
const round3 = Math.floor(i2 / palette.base.length);
|
|
13041
|
+
transform6 = (palette.variations.length ? palette.variations[round3 % palette.variations.length] : {}) ?? {};
|
|
13042
13042
|
} else {
|
|
13043
|
-
const index2 = palette.meth === "withinLinearReversed" ? n - 1 -
|
|
13043
|
+
const index2 = palette.meth === "withinLinearReversed" ? n - 1 - i2 : i2;
|
|
13044
13044
|
base = palette.base[0];
|
|
13045
|
-
|
|
13045
|
+
transform6 = withinLinearTransform(index2, n);
|
|
13046
13046
|
}
|
|
13047
13047
|
if (!base) throw new RangeError("A chart palette must have a base color");
|
|
13048
13048
|
return {
|
|
13049
13049
|
kind: "scheme",
|
|
13050
13050
|
value: base,
|
|
13051
|
-
transforms: Object.entries(
|
|
13051
|
+
transforms: Object.entries(transform6).map(([name, value2]) => ({ name, value: String(value2) }))
|
|
13052
13052
|
};
|
|
13053
13053
|
}
|
|
13054
13054
|
|
|
@@ -13056,7 +13056,7 @@ function chartPaletteSeriesColorChoice(palette, i, n) {
|
|
|
13056
13056
|
function sameChartColor(a, b) {
|
|
13057
13057
|
if (!a || !b) return a === b;
|
|
13058
13058
|
return a.kind === b.kind && a.value === b.value && a.fallback === b.fallback && a.transforms.length === b.transforms.length && a.transforms.every(
|
|
13059
|
-
(t,
|
|
13059
|
+
(t, i2) => b.transforms[i2]?.name === t.name && b.transforms[i2]?.value === t.value
|
|
13060
13060
|
);
|
|
13061
13061
|
}
|
|
13062
13062
|
function recolorGradient(fill, previous, next) {
|
|
@@ -13125,38 +13125,38 @@ function chartColorPalettePatch(chart, id) {
|
|
|
13125
13125
|
var HLSMAX = 240;
|
|
13126
13126
|
var RGBMAX = 255;
|
|
13127
13127
|
var idiv = (a, b) => Math.trunc(a / b);
|
|
13128
|
-
function rgbToHls240(r,
|
|
13129
|
-
const max = Math.max(r,
|
|
13130
|
-
const min = Math.min(r,
|
|
13128
|
+
function rgbToHls240(r, g2, b) {
|
|
13129
|
+
const max = Math.max(r, g2, b);
|
|
13130
|
+
const min = Math.min(r, g2, b);
|
|
13131
13131
|
const l = idiv((max + min) * HLSMAX + RGBMAX, 2 * RGBMAX);
|
|
13132
13132
|
if (max === min) return { h: idiv(HLSMAX * 2, 3), l, s: 0 };
|
|
13133
13133
|
const sum2 = max + min;
|
|
13134
13134
|
const s = l <= HLSMAX / 2 ? idiv((max - min) * HLSMAX + idiv(sum2, 2), sum2) : idiv((max - min) * HLSMAX + idiv(2 * RGBMAX - sum2, 2), 2 * RGBMAX - sum2);
|
|
13135
13135
|
const delta = (c) => idiv((max - c) * idiv(HLSMAX, 6) + idiv(max - min, 2), max - min);
|
|
13136
13136
|
const rd = delta(r);
|
|
13137
|
-
const gd = delta(
|
|
13137
|
+
const gd = delta(g2);
|
|
13138
13138
|
const bd = delta(b);
|
|
13139
|
-
let
|
|
13140
|
-
if (r === max)
|
|
13141
|
-
else if (
|
|
13142
|
-
else
|
|
13143
|
-
if (
|
|
13144
|
-
if (
|
|
13145
|
-
return { h, l, s };
|
|
13139
|
+
let h2;
|
|
13140
|
+
if (r === max) h2 = bd - gd;
|
|
13141
|
+
else if (g2 === max) h2 = idiv(HLSMAX, 3) + rd - bd;
|
|
13142
|
+
else h2 = idiv(2 * HLSMAX, 3) + gd - rd;
|
|
13143
|
+
if (h2 < 0) h2 += HLSMAX;
|
|
13144
|
+
if (h2 > HLSMAX) h2 -= HLSMAX;
|
|
13145
|
+
return { h: h2, l, s };
|
|
13146
13146
|
}
|
|
13147
13147
|
function hueToRgb(n1, n2, hue) {
|
|
13148
|
-
let
|
|
13149
|
-
if (
|
|
13150
|
-
if (
|
|
13148
|
+
let h2 = hue;
|
|
13149
|
+
if (h2 < 0) h2 += HLSMAX;
|
|
13150
|
+
if (h2 > HLSMAX) h2 -= HLSMAX;
|
|
13151
13151
|
const sixth = idiv(HLSMAX, 6);
|
|
13152
|
-
if (
|
|
13153
|
-
if (
|
|
13154
|
-
if (
|
|
13155
|
-
return n1 + idiv((n2 - n1) * (idiv(HLSMAX * 2, 3) -
|
|
13152
|
+
if (h2 < sixth) return n1 + idiv((n2 - n1) * h2 + idiv(HLSMAX, 12), sixth);
|
|
13153
|
+
if (h2 < idiv(HLSMAX, 2)) return n2;
|
|
13154
|
+
if (h2 < idiv(HLSMAX * 2, 3))
|
|
13155
|
+
return n1 + idiv((n2 - n1) * (idiv(HLSMAX * 2, 3) - h2) + idiv(HLSMAX, 12), sixth);
|
|
13156
13156
|
return n1;
|
|
13157
13157
|
}
|
|
13158
13158
|
var clamp255 = (v) => Math.max(0, Math.min(255, v));
|
|
13159
|
-
function hls240ToRgb({ h, l, s }) {
|
|
13159
|
+
function hls240ToRgb({ h: h2, l, s }) {
|
|
13160
13160
|
if (s === 0) {
|
|
13161
13161
|
const v = clamp255(Math.round(l * RGBMAX / HLSMAX));
|
|
13162
13162
|
return [v, v, v];
|
|
@@ -13164,13 +13164,13 @@ function hls240ToRgb({ h, l, s }) {
|
|
|
13164
13164
|
const m2 = l <= HLSMAX / 2 ? idiv(l * (HLSMAX + s) + idiv(HLSMAX, 2), HLSMAX) : l + s - idiv(l * s + idiv(HLSMAX, 2), HLSMAX);
|
|
13165
13165
|
const m1 = 2 * l - m2;
|
|
13166
13166
|
const channel = (hue) => clamp255(idiv(hueToRgb(m1, m2, hue) * RGBMAX + idiv(HLSMAX, 2), HLSMAX));
|
|
13167
|
-
return [channel(
|
|
13167
|
+
return [channel(h2 + idiv(HLSMAX, 3)), channel(h2), channel(h2 - idiv(HLSMAX, 3))];
|
|
13168
13168
|
}
|
|
13169
13169
|
function parseHex(hex2) {
|
|
13170
13170
|
const clean2 = hex2.replace(/^#/, "");
|
|
13171
13171
|
const rgb2 = clean2.length === 8 ? clean2.slice(2) : clean2;
|
|
13172
13172
|
if (!/^[0-9a-fA-F]{6}$/.test(rgb2)) return void 0;
|
|
13173
|
-
return [0, 2, 4].map((
|
|
13173
|
+
return [0, 2, 4].map((i2) => parseInt(rgb2.slice(i2, i2 + 2), 16));
|
|
13174
13174
|
}
|
|
13175
13175
|
var toHexColor = (rgb2) => `#${rgb2.map((v) => clamp255(Math.round(v)).toString(16).padStart(2, "0")).join("").toUpperCase()}`;
|
|
13176
13176
|
function applyTint(hex2, tint) {
|
|
@@ -13298,8 +13298,8 @@ function mixColors(a, b, t, rounding = "nearest") {
|
|
|
13298
13298
|
const cb = parseHex(b) ?? [0, 0, 0];
|
|
13299
13299
|
const k = Math.max(0, Math.min(1, t));
|
|
13300
13300
|
return toHexColor(
|
|
13301
|
-
ca.map((v,
|
|
13302
|
-
const delta = ((cb[
|
|
13301
|
+
ca.map((v, i2) => {
|
|
13302
|
+
const delta = ((cb[i2] ?? 0) - v) * k;
|
|
13303
13303
|
return v + (rounding === "towardStart" ? Math.trunc(delta) : delta);
|
|
13304
13304
|
})
|
|
13305
13305
|
);
|
|
@@ -13683,15 +13683,15 @@ function clearIn(ctx, sheet, r, what) {
|
|
|
13683
13683
|
(c) => !rangesIntersect(cellRange(c.address.row, c.address.col), r)
|
|
13684
13684
|
);
|
|
13685
13685
|
if (what === "all" || what === "hyperlinks")
|
|
13686
|
-
sheet.hyperlinks = sheet.hyperlinks.filter((
|
|
13686
|
+
sheet.hyperlinks = sheet.hyperlinks.filter((h2) => !rangesIntersect(h2.range, r));
|
|
13687
13687
|
}
|
|
13688
13688
|
|
|
13689
13689
|
// xlsx/edit/columns.ts
|
|
13690
13690
|
function copyColumnWidths(sheet, start, end) {
|
|
13691
13691
|
const fallback = sheet.defaultColWidth ?? DEFAULT_COL_WIDTH;
|
|
13692
13692
|
const widths = Array(end - start + 1).fill(fallback);
|
|
13693
|
-
for (let
|
|
13694
|
-
const info = sheet.columns[
|
|
13693
|
+
for (let i2 = sheet.columns.length - 1; i2 >= 0; i2--) {
|
|
13694
|
+
const info = sheet.columns[i2];
|
|
13695
13695
|
const first2 = Math.max(start, info.min);
|
|
13696
13696
|
const last = Math.min(end, info.max);
|
|
13697
13697
|
if (first2 <= last)
|
|
@@ -13976,7 +13976,7 @@ function dateSeries(serials, date1904, format) {
|
|
|
13976
13976
|
const monthIndex = dates.map((d) => d.getUTCFullYear() * 12 + d.getUTCMonth());
|
|
13977
13977
|
const sameDay = dates.every((d) => d.getUTCDate() === dates[0]?.getUTCDate());
|
|
13978
13978
|
const stepMonths = (monthIndex[1] ?? 0) - (monthIndex[0] ?? 0);
|
|
13979
|
-
const evenMonths = stepMonths !== 0 && monthIndex.every((m,
|
|
13979
|
+
const evenMonths = stepMonths !== 0 && monthIndex.every((m, i2) => m - (monthIndex[0] ?? 0) === stepMonths * i2);
|
|
13980
13980
|
const first2 = serials[0] ?? 0;
|
|
13981
13981
|
if (sameDay && evenMonths)
|
|
13982
13982
|
return (k) => ({ kind: "value", value: addMonths2(first2, stepMonths * k, date1904) });
|
|
@@ -14037,21 +14037,21 @@ function fillRange(ctx, s, source, target2, mode = "auto") {
|
|
|
14037
14037
|
const laneCount = vertical2 ? src.end.col - src.start.col + 1 : src.end.row - src.start.row + 1;
|
|
14038
14038
|
const length = vertical2 ? src.end.row - src.start.row + 1 : src.end.col - src.start.col + 1;
|
|
14039
14039
|
for (let lane = 0; lane < laneCount; lane++) {
|
|
14040
|
-
const at = (
|
|
14041
|
-
const cells = Array.from({ length }, (_v,
|
|
14040
|
+
const at = (i2) => vertical2 ? [src.start.row + i2, src.start.col + lane] : [src.start.row + lane, src.start.col + i2];
|
|
14041
|
+
const cells = Array.from({ length }, (_v, i2) => getCell(sheet, ...at(i2)));
|
|
14042
14042
|
const series = mode === "auto" ? detectSeries(ctx.workbook, cells) : void 0;
|
|
14043
14043
|
const from = vertical2 ? all2.start.row - src.start.row : all2.start.col - src.start.col;
|
|
14044
14044
|
const to = vertical2 ? all2.end.row - src.start.row : all2.end.col - src.start.col;
|
|
14045
14045
|
for (let k = from; k <= to; k++) {
|
|
14046
14046
|
if (k >= 0 && k < length) continue;
|
|
14047
14047
|
const [row2, col] = at(k);
|
|
14048
|
-
const
|
|
14049
|
-
const origin = cells[
|
|
14048
|
+
const i2 = mod(k, length);
|
|
14049
|
+
const origin = cells[i2];
|
|
14050
14050
|
if (!origin) {
|
|
14051
14051
|
deleteCell(sheet, row2, col);
|
|
14052
14052
|
continue;
|
|
14053
14053
|
}
|
|
14054
|
-
const [srcRow, srcCol] = at(
|
|
14054
|
+
const [srcRow, srcCol] = at(i2);
|
|
14055
14055
|
const step = series?.(k);
|
|
14056
14056
|
const cell = !step || step.kind === "copy" ? copyCell(origin, row2 - srcRow, col - srcCol) : { value: step.value, ...origin.styleId ? { styleId: origin.styleId } : {} };
|
|
14057
14057
|
putCell(sheet, row2, col, cell);
|
|
@@ -14122,11 +14122,11 @@ function formatAt(sheet, index2) {
|
|
|
14122
14122
|
return format;
|
|
14123
14123
|
}
|
|
14124
14124
|
function rulesByPriority(sheet) {
|
|
14125
|
-
return sheet.conditionalFormats.flatMap((
|
|
14125
|
+
return sheet.conditionalFormats.flatMap((f6) => f6.rules).map((rule, order) => ({ rule, order })).sort((a, b) => a.rule.priority - b.rule.priority || a.order - b.order).map((e) => e.rule);
|
|
14126
14126
|
}
|
|
14127
14127
|
function renumber(rules) {
|
|
14128
|
-
rules.forEach((rule,
|
|
14129
|
-
rule.priority =
|
|
14128
|
+
rules.forEach((rule, i2) => {
|
|
14129
|
+
rule.priority = i2 + 1;
|
|
14130
14130
|
});
|
|
14131
14131
|
}
|
|
14132
14132
|
function replaceConditionalFormat(ctx, s, index2, format) {
|
|
@@ -14169,7 +14169,7 @@ function setConditionalRulePriority(ctx, s, formatIndex, ruleIndex, priority) {
|
|
|
14169
14169
|
const order = rulesByPriority(sheet);
|
|
14170
14170
|
const from = order.indexOf(rule);
|
|
14171
14171
|
const to = Math.max(0, Math.min(order.length - 1, Math.round(priority) - 1));
|
|
14172
|
-
if (from === to && order.every((r,
|
|
14172
|
+
if (from === to && order.every((r, i2) => r.priority === i2 + 1)) return;
|
|
14173
14173
|
ctx.run(
|
|
14174
14174
|
"Rule priority",
|
|
14175
14175
|
"format",
|
|
@@ -14204,7 +14204,7 @@ function randomBytes(length) {
|
|
|
14204
14204
|
const cryptoObj = globalThis.crypto;
|
|
14205
14205
|
if (cryptoObj?.getRandomValues) return cryptoObj.getRandomValues(new Uint8Array(length));
|
|
14206
14206
|
const bytes = new Uint8Array(length);
|
|
14207
|
-
for (let
|
|
14207
|
+
for (let i2 = 0; i2 < length; i2++) bytes[i2] = Math.floor(Math.random() * 256);
|
|
14208
14208
|
return bytes;
|
|
14209
14209
|
}
|
|
14210
14210
|
function randomHex(length) {
|
|
@@ -14225,7 +14225,7 @@ function rebaseConditionalFormat(format, ranges) {
|
|
|
14225
14225
|
for (const rule of next.rules)
|
|
14226
14226
|
rewriteConditionalRule(
|
|
14227
14227
|
rule,
|
|
14228
|
-
(
|
|
14228
|
+
(f6) => moveValidationFormula(f6, to.row - from.row, to.col - from.col)
|
|
14229
14229
|
);
|
|
14230
14230
|
return next;
|
|
14231
14231
|
}
|
|
@@ -14298,8 +14298,8 @@ function pasteConditionalFormats(sheet, dest, cells, transpose2, skipBlanks, cut
|
|
|
14298
14298
|
for (const rule of next.rules)
|
|
14299
14299
|
rewriteConditionalRule(
|
|
14300
14300
|
rule,
|
|
14301
|
-
cutFormula ?? ((
|
|
14302
|
-
|
|
14301
|
+
cutFormula ?? ((f6) => moveValidationFormula(
|
|
14302
|
+
f6,
|
|
14303
14303
|
target2.row - origin.row - source.row,
|
|
14304
14304
|
target2.col - origin.col - source.col
|
|
14305
14305
|
))
|
|
@@ -14344,7 +14344,7 @@ function setComment(ctx, s, at, text, author) {
|
|
|
14344
14344
|
function setHyperlink(ctx, s, range2, link) {
|
|
14345
14345
|
const sheet = sheetAt(ctx.workbook, s);
|
|
14346
14346
|
const r = normalizeRange(range2);
|
|
14347
|
-
if (!link && !sheet.hyperlinks.some((
|
|
14347
|
+
if (!link && !sheet.hyperlinks.some((h2) => rangesIntersect(h2.range, r))) return;
|
|
14348
14348
|
if (link && !link.target && !link.location)
|
|
14349
14349
|
throw new Error("A hyperlink needs a target or a location.");
|
|
14350
14350
|
ctx.run(
|
|
@@ -14352,7 +14352,7 @@ function setHyperlink(ctx, s, range2, link) {
|
|
|
14352
14352
|
"annotations",
|
|
14353
14353
|
[{ kind: "sheet", sheet: s }],
|
|
14354
14354
|
() => {
|
|
14355
|
-
sheet.hyperlinks = sheet.hyperlinks.filter((
|
|
14355
|
+
sheet.hyperlinks = sheet.hyperlinks.filter((h2) => !rangesIntersect(h2.range, r));
|
|
14356
14356
|
if (!link) return;
|
|
14357
14357
|
sheet.hyperlinks.push({ ...structuredClone(link), range: r });
|
|
14358
14358
|
const anchor = getCell(sheet, r.start.row, r.start.col);
|
|
@@ -14381,8 +14381,8 @@ function addConditionalFormat(ctx, s, format) {
|
|
|
14381
14381
|
for (const rule of cf.rules) rule.priority += count2;
|
|
14382
14382
|
const added = structuredClone(format);
|
|
14383
14383
|
added.ranges = added.ranges.map(normalizeRange);
|
|
14384
|
-
added.rules.forEach((rule,
|
|
14385
|
-
rule.priority =
|
|
14384
|
+
added.rules.forEach((rule, i2) => {
|
|
14385
|
+
rule.priority = i2 + 1;
|
|
14386
14386
|
});
|
|
14387
14387
|
sheet.conditionalFormats.push(added);
|
|
14388
14388
|
},
|
|
@@ -14622,8 +14622,8 @@ function rewritePreservedFormulas(sheet, rewrite2) {
|
|
|
14622
14622
|
"extLst",
|
|
14623
14623
|
(root) => {
|
|
14624
14624
|
let changed = false;
|
|
14625
|
-
for (const
|
|
14626
|
-
const text =
|
|
14625
|
+
for (const f6 of descendants2(root, XM2, "f")) {
|
|
14626
|
+
const text = f6.textContent ?? "";
|
|
14627
14627
|
let next = text;
|
|
14628
14628
|
try {
|
|
14629
14629
|
next = rewrite2(text, sheet.name);
|
|
@@ -14631,7 +14631,7 @@ function rewritePreservedFormulas(sheet, rewrite2) {
|
|
|
14631
14631
|
next = text;
|
|
14632
14632
|
}
|
|
14633
14633
|
if (next === text) continue;
|
|
14634
|
-
|
|
14634
|
+
f6.textContent = next;
|
|
14635
14635
|
changed = true;
|
|
14636
14636
|
}
|
|
14637
14637
|
return changed ? "changed" : "same";
|
|
@@ -14667,7 +14667,7 @@ function rewriteSheetFormulas(sheet, rewrite2) {
|
|
|
14667
14667
|
for (const cell of cells.values())
|
|
14668
14668
|
if (cell.formula !== void 0) cell.formula = safe(rewrite2, cell.formula, name);
|
|
14669
14669
|
for (const cf of sheet.conditionalFormats)
|
|
14670
|
-
for (const rule of cf.rules) rewriteConditionalRule(rule, (
|
|
14670
|
+
for (const rule of cf.rules) rewriteConditionalRule(rule, (f6) => rewrite2(f6, name));
|
|
14671
14671
|
for (const dv of sheet.dataValidations) {
|
|
14672
14672
|
if (dv.formula1 !== void 0) dv.formula1 = safe(rewrite2, dv.formula1, name);
|
|
14673
14673
|
if (dv.formula2 !== void 0) dv.formula2 = safe(rewrite2, dv.formula2, name);
|
|
@@ -14693,9 +14693,9 @@ function shiftSheetContent(sheet, shift2, band) {
|
|
|
14693
14693
|
sheet.merges = sheet.merges.map(moveRange).filter((m) => !!m && (m.start.row !== m.end.row || m.start.col !== m.end.col));
|
|
14694
14694
|
sheet.conditionalFormats = sheet.conditionalFormats.map((cf) => ({ ...cf, ranges: cf.ranges.map(moveRange).filter((r) => !!r) })).filter((cf) => cf.ranges.length > 0);
|
|
14695
14695
|
sheet.dataValidations = sheet.dataValidations.map((dv) => ({ ...dv, ranges: dv.ranges.map(moveRange).filter((r) => !!r) })).filter((dv) => dv.ranges.length > 0);
|
|
14696
|
-
sheet.hyperlinks = sheet.hyperlinks.flatMap((
|
|
14697
|
-
const range2 = moveRange(
|
|
14698
|
-
return range2 ? [{ ...
|
|
14696
|
+
sheet.hyperlinks = sheet.hyperlinks.flatMap((h2) => {
|
|
14697
|
+
const range2 = moveRange(h2.range);
|
|
14698
|
+
return range2 ? [{ ...h2, range: range2 }] : [];
|
|
14699
14699
|
});
|
|
14700
14700
|
sheet.comments = sheet.comments.flatMap((c) => {
|
|
14701
14701
|
const range2 = moveRange({ start: c.address, end: c.address });
|
|
@@ -14759,17 +14759,17 @@ function shiftTable(sheet, table2, shift2, moveRange) {
|
|
|
14759
14759
|
if (shift2.axis === "col" && widened) {
|
|
14760
14760
|
if (shift2.count > 0) {
|
|
14761
14761
|
const offset2 = shift2.at - old.start.col;
|
|
14762
|
-
for (let
|
|
14762
|
+
for (let i2 = 0; i2 < shift2.count; i2++) {
|
|
14763
14763
|
const column = { name: uniqueColumnName(next.columns) };
|
|
14764
|
-
next.columns.splice(offset2 +
|
|
14764
|
+
next.columns.splice(offset2 + i2, 0, column);
|
|
14765
14765
|
if (next.headerRow) {
|
|
14766
14766
|
const cell = { value: column.name };
|
|
14767
|
-
putCell(sheet, range2.start.row, shift2.at +
|
|
14767
|
+
putCell(sheet, range2.start.row, shift2.at + i2, cell);
|
|
14768
14768
|
}
|
|
14769
14769
|
}
|
|
14770
14770
|
} else {
|
|
14771
14771
|
next.columns = next.columns.filter(
|
|
14772
|
-
(_c,
|
|
14772
|
+
(_c, i2) => shiftIndex(old.start.col + i2, shift2) !== void 0
|
|
14773
14773
|
);
|
|
14774
14774
|
}
|
|
14775
14775
|
}
|
|
@@ -15009,8 +15009,8 @@ function cssFor(style2, theme2) {
|
|
|
15009
15009
|
const bg = cssColor(style2.fill.fgColor, theme2);
|
|
15010
15010
|
if (bg) css.push(`background:${bg}`);
|
|
15011
15011
|
}
|
|
15012
|
-
const
|
|
15013
|
-
if (
|
|
15012
|
+
const h2 = style2.alignment?.horizontal;
|
|
15013
|
+
if (h2 && h2 !== "general") css.push(`text-align:${h2 === "centerContinuous" ? "center" : h2}`);
|
|
15014
15014
|
const v = style2.alignment?.vertical;
|
|
15015
15015
|
if (v) css.push(`vertical-align:${v === "center" ? "middle" : v}`);
|
|
15016
15016
|
if (style2.alignment?.wrapText) css.push("white-space:normal");
|
|
@@ -15162,9 +15162,9 @@ function stylePatchFromCss(css, inner2) {
|
|
|
15162
15162
|
const background = css.get("background-color") ?? css.get("background");
|
|
15163
15163
|
const fill = background && parseCssColor(background.split(/\s+/)[0] ?? "");
|
|
15164
15164
|
if (fill) patch.fill = { type: "pattern", pattern: "solid", fgColor: fill };
|
|
15165
|
-
const
|
|
15165
|
+
const h2 = H_ALIGN[css.get("text-align") ?? ""];
|
|
15166
15166
|
const v = V_ALIGN[css.get("vertical-align") ?? ""];
|
|
15167
|
-
if (
|
|
15167
|
+
if (h2 || v) patch.alignment = { ...h2 ? { horizontal: h2 } : {}, ...v ? { vertical: v } : {} };
|
|
15168
15168
|
const numFmt = css.get("mso-number-format");
|
|
15169
15169
|
if (numFmt) patch.numFmt = decodeNumberFormat(numFmt);
|
|
15170
15170
|
return patch;
|
|
@@ -15182,19 +15182,19 @@ function removeComments(text) {
|
|
|
15182
15182
|
}
|
|
15183
15183
|
function removeTags(text) {
|
|
15184
15184
|
let out = "";
|
|
15185
|
-
let
|
|
15186
|
-
while (
|
|
15187
|
-
const ch = text[
|
|
15185
|
+
let i2 = 0;
|
|
15186
|
+
while (i2 < text.length) {
|
|
15187
|
+
const ch = text[i2];
|
|
15188
15188
|
if (ch === "<") {
|
|
15189
|
-
let j =
|
|
15189
|
+
let j = i2 + 1;
|
|
15190
15190
|
while (j < text.length && text[j] !== "<" && text[j] !== ">") j++;
|
|
15191
15191
|
if (text[j] === ">") {
|
|
15192
|
-
|
|
15192
|
+
i2 = j + 1;
|
|
15193
15193
|
continue;
|
|
15194
15194
|
}
|
|
15195
15195
|
}
|
|
15196
15196
|
out += ch;
|
|
15197
|
-
|
|
15197
|
+
i2++;
|
|
15198
15198
|
}
|
|
15199
15199
|
return out;
|
|
15200
15200
|
}
|
|
@@ -15276,10 +15276,10 @@ function parseHtmlTable(html, base) {
|
|
|
15276
15276
|
r++;
|
|
15277
15277
|
}
|
|
15278
15278
|
const rows2 = grid6.length;
|
|
15279
|
-
const cols = Math.max(0, ...grid6.map((
|
|
15279
|
+
const cols = Math.max(0, ...grid6.map((g2) => g2.length));
|
|
15280
15280
|
const data = Array.from(
|
|
15281
15281
|
{ length: rows2 },
|
|
15282
|
-
(_v,
|
|
15282
|
+
(_v, i2) => Array.from({ length: cols }, (_w, j) => grid6[i2]?.[j] ?? null)
|
|
15283
15283
|
);
|
|
15284
15284
|
return rows2 && cols ? { rows: rows2, cols, data, merges, hyperlinks } : void 0;
|
|
15285
15285
|
}
|
|
@@ -15308,19 +15308,19 @@ function parseTsv(text) {
|
|
|
15308
15308
|
const rows2 = [];
|
|
15309
15309
|
let row2 = [];
|
|
15310
15310
|
let field = "";
|
|
15311
|
-
let
|
|
15311
|
+
let i2 = 0;
|
|
15312
15312
|
let atFieldStart = true;
|
|
15313
15313
|
const body2 = text.replace(/\r\n?/g, "\n").replace(/\n$/, "");
|
|
15314
15314
|
if (body2 === "") return text === "" ? [] : [[""]];
|
|
15315
|
-
while (
|
|
15316
|
-
const ch = body2[
|
|
15315
|
+
while (i2 < body2.length) {
|
|
15316
|
+
const ch = body2[i2] ?? "";
|
|
15317
15317
|
if (atFieldStart && ch === '"') {
|
|
15318
|
-
const close = findClosingQuote(body2,
|
|
15318
|
+
const close = findClosingQuote(body2, i2 + 1);
|
|
15319
15319
|
if (close >= 0) {
|
|
15320
15320
|
const next = body2[close + 1];
|
|
15321
15321
|
if (next === void 0 || next === " " || next === "\n") {
|
|
15322
|
-
field = body2.slice(
|
|
15323
|
-
|
|
15322
|
+
field = body2.slice(i2 + 1, close).replace(/""/g, '"');
|
|
15323
|
+
i2 = close + 1;
|
|
15324
15324
|
atFieldStart = false;
|
|
15325
15325
|
continue;
|
|
15326
15326
|
}
|
|
@@ -15338,7 +15338,7 @@ function parseTsv(text) {
|
|
|
15338
15338
|
field = "";
|
|
15339
15339
|
atFieldStart = true;
|
|
15340
15340
|
} else field += ch;
|
|
15341
|
-
|
|
15341
|
+
i2++;
|
|
15342
15342
|
}
|
|
15343
15343
|
row2.push(field);
|
|
15344
15344
|
rows2.push(row2);
|
|
@@ -15347,13 +15347,13 @@ function parseTsv(text) {
|
|
|
15347
15347
|
return rows2;
|
|
15348
15348
|
}
|
|
15349
15349
|
function findClosingQuote(text, from) {
|
|
15350
|
-
for (let
|
|
15351
|
-
if (text[
|
|
15352
|
-
if (text[
|
|
15353
|
-
|
|
15350
|
+
for (let i2 = from; i2 < text.length; i2++) {
|
|
15351
|
+
if (text[i2] !== '"') continue;
|
|
15352
|
+
if (text[i2 + 1] === '"') {
|
|
15353
|
+
i2++;
|
|
15354
15354
|
continue;
|
|
15355
15355
|
}
|
|
15356
|
-
return
|
|
15356
|
+
return i2;
|
|
15357
15357
|
}
|
|
15358
15358
|
return -1;
|
|
15359
15359
|
}
|
|
@@ -15402,12 +15402,12 @@ function pasteArithmetic(destination, source, operation) {
|
|
|
15402
15402
|
return { value: dest.value, ...dest.formula !== void 0 ? { formula: dest.formula } : {} };
|
|
15403
15403
|
if (source.value === null && dest.value === null && !source.formula && !dest.formula)
|
|
15404
15404
|
return { value: null };
|
|
15405
|
-
const
|
|
15405
|
+
const op2 = OPS[operation];
|
|
15406
15406
|
const result2 = {
|
|
15407
|
-
value: scalarBinary(
|
|
15407
|
+
value: scalarBinary(op2, dest.value, source.value)
|
|
15408
15408
|
};
|
|
15409
15409
|
if (dest.formula !== void 0 || source.formula !== void 0)
|
|
15410
|
-
result2.formula = `${operand2(dest)}${
|
|
15410
|
+
result2.formula = `${operand2(dest)}${op2}${operand2(source)}`;
|
|
15411
15411
|
return result2;
|
|
15412
15412
|
}
|
|
15413
15413
|
|
|
@@ -15698,7 +15698,7 @@ function pasteAt(ctx, s, at, payload, request) {
|
|
|
15698
15698
|
if (cut && move) {
|
|
15699
15699
|
const from = sheetAt(workbook, cut.sheet);
|
|
15700
15700
|
removeConditionalArea(from, cut.range);
|
|
15701
|
-
rewriteFormulas(workbook, (
|
|
15701
|
+
rewriteFormulas(workbook, (f6, fs) => moveReferencesInFormula(f6, fs, move));
|
|
15702
15702
|
const doomed = [];
|
|
15703
15703
|
forEachCellInRange(from, cut.range, (_c, row2, col) => doomed.push([row2, col]));
|
|
15704
15704
|
for (const [row2, col] of doomed) deleteCell(from, row2, col);
|
|
@@ -15713,7 +15713,7 @@ function pasteAt(ctx, s, at, payload, request) {
|
|
|
15713
15713
|
mode,
|
|
15714
15714
|
transpose2,
|
|
15715
15715
|
skipBlanks,
|
|
15716
|
-
move ? (
|
|
15716
|
+
move ? (f6) => moveReferencesInFormula(f6, move.fromSheet, move, move.toSheet) : void 0
|
|
15717
15717
|
);
|
|
15718
15718
|
if (mode === "all" || mode === "mergeFormats" || mode === "noBorders")
|
|
15719
15719
|
pasteHyperlinks(
|
|
@@ -15722,7 +15722,7 @@ function pasteAt(ctx, s, at, payload, request) {
|
|
|
15722
15722
|
cells,
|
|
15723
15723
|
transpose2,
|
|
15724
15724
|
skipBlanks,
|
|
15725
|
-
move ? (
|
|
15725
|
+
move ? (f6) => moveReferencesInFormula(f6, move.fromSheet, move, move.toSheet) : void 0
|
|
15726
15726
|
);
|
|
15727
15727
|
const styleIds = /* @__PURE__ */ new Map();
|
|
15728
15728
|
if (mode === "all" || mode === "mergeFormats" || mode === "noBorders" || mode === "formats")
|
|
@@ -15732,7 +15732,7 @@ function pasteAt(ctx, s, at, payload, request) {
|
|
|
15732
15732
|
cells,
|
|
15733
15733
|
transpose2,
|
|
15734
15734
|
skipBlanks,
|
|
15735
|
-
move ? (
|
|
15735
|
+
move ? (f6) => moveReferencesInFormula(f6, move.fromSheet, move, move.toSheet) : void 0,
|
|
15736
15736
|
mode === "mergeFormats"
|
|
15737
15737
|
);
|
|
15738
15738
|
const styleOf = (clip) => {
|
|
@@ -15904,10 +15904,10 @@ function setRowHeight(ctx, s, rows2, height) {
|
|
|
15904
15904
|
else info.height = fit;
|
|
15905
15905
|
delete info.customHeight;
|
|
15906
15906
|
} else {
|
|
15907
|
-
const
|
|
15908
|
-
info.height =
|
|
15907
|
+
const h2 = Math.max(0, Math.min(MAX_HEIGHT, height));
|
|
15908
|
+
info.height = h2;
|
|
15909
15909
|
info.customHeight = true;
|
|
15910
|
-
if (
|
|
15910
|
+
if (h2 === 0) info.hidden = true;
|
|
15911
15911
|
else delete info.hidden;
|
|
15912
15912
|
}
|
|
15913
15913
|
if (Object.keys(info).length) sheet.rowInfo.set(row2, info);
|
|
@@ -16009,9 +16009,9 @@ function sortRows2(sheet, range2, keys, hasHeader) {
|
|
|
16009
16009
|
return 0;
|
|
16010
16010
|
});
|
|
16011
16011
|
for (const { row: row2, cells } of rows2) for (const col of cells.keys()) deleteCell(sheet, row2, col);
|
|
16012
|
-
moveAnnotations(sheet, dataArea, new Map(sorted2.map((source,
|
|
16013
|
-
sorted2.forEach((source,
|
|
16014
|
-
const row2 = firstRow +
|
|
16012
|
+
moveAnnotations(sheet, dataArea, new Map(sorted2.map((source, i2) => [source.row, firstRow + i2])));
|
|
16013
|
+
sorted2.forEach((source, i2) => {
|
|
16014
|
+
const row2 = firstRow + i2;
|
|
16015
16015
|
const dRow = row2 - source.row;
|
|
16016
16016
|
for (const [col, cell] of source.cells) {
|
|
16017
16017
|
if (cell.formula !== void 0 && dRow) {
|
|
@@ -16206,10 +16206,10 @@ function queryPattern(query, global = false) {
|
|
|
16206
16206
|
if (!query.text) return void 0;
|
|
16207
16207
|
let source = "";
|
|
16208
16208
|
const wildcards = query.wildcards ?? true;
|
|
16209
|
-
for (let
|
|
16210
|
-
const ch = query.text[
|
|
16211
|
-
if (wildcards && ch === "~" &&
|
|
16212
|
-
source += escapeRegex2(query.text[++
|
|
16209
|
+
for (let i2 = 0; i2 < query.text.length; i2++) {
|
|
16210
|
+
const ch = query.text[i2] ?? "";
|
|
16211
|
+
if (wildcards && ch === "~" && i2 + 1 < query.text.length) {
|
|
16212
|
+
source += escapeRegex2(query.text[++i2] ?? "");
|
|
16213
16213
|
} else if (wildcards && ch === "*") source += "[\\s\\S]*";
|
|
16214
16214
|
else if (wildcards && ch === "?") source += "[\\s\\S]";
|
|
16215
16215
|
else source += escapeRegex2(ch);
|
|
@@ -16229,7 +16229,7 @@ function searchText(workbook, query, sheet, row2, col) {
|
|
|
16229
16229
|
function findAll(workbook, query) {
|
|
16230
16230
|
const pattern = queryPattern(query);
|
|
16231
16231
|
if (!pattern) return [];
|
|
16232
|
-
const indices = query.sheet !== void 0 ? [query.sheet] : workbook.sheets.map((_s,
|
|
16232
|
+
const indices = query.sheet !== void 0 ? [query.sheet] : workbook.sheets.map((_s, i2) => i2);
|
|
16233
16233
|
const matches2 = [];
|
|
16234
16234
|
for (const s of indices) {
|
|
16235
16235
|
const sheet = workbook.sheets[s];
|
|
@@ -16624,8 +16624,8 @@ var History = class {
|
|
|
16624
16624
|
undo(workbook) {
|
|
16625
16625
|
const step = this.done.pop();
|
|
16626
16626
|
if (!step) return void 0;
|
|
16627
|
-
for (let
|
|
16628
|
-
const entry = step.entries[
|
|
16627
|
+
for (let i2 = step.entries.length - 1; i2 >= 0; i2--) {
|
|
16628
|
+
const entry = step.entries[i2];
|
|
16629
16629
|
if (entry) restoreSnapshot(workbook, entry.before);
|
|
16630
16630
|
}
|
|
16631
16631
|
this.undone.push(step);
|
|
@@ -16896,8 +16896,8 @@ function updateChart(ctx, s, index2, patch) {
|
|
|
16896
16896
|
const changes = structuredClone(patch);
|
|
16897
16897
|
delete changes.elementFills;
|
|
16898
16898
|
if (formatting) live.formatting = formatting;
|
|
16899
|
-
changes.series?.forEach((series,
|
|
16900
|
-
const before = live.series[
|
|
16899
|
+
changes.series?.forEach((series, i2) => {
|
|
16900
|
+
const before = live.series[i2];
|
|
16901
16901
|
if (!before) return;
|
|
16902
16902
|
const legacyChanged = JSON.stringify(before.color) !== JSON.stringify(series.color);
|
|
16903
16903
|
const drawingChanged = JSON.stringify(before.drawingColor) !== JSON.stringify(series.drawingColor);
|
|
@@ -16996,8 +16996,8 @@ function applyTotalsRow(sheet, table2) {
|
|
|
16996
16996
|
if (first2 && columns.length > 1) first2.totalsRowLabel = "Total";
|
|
16997
16997
|
if (last) last.totalsRowFunction = "sum";
|
|
16998
16998
|
}
|
|
16999
|
-
columns.forEach((column,
|
|
17000
|
-
const col = table2.range.start.col +
|
|
16999
|
+
columns.forEach((column, i2) => {
|
|
17000
|
+
const col = table2.range.start.col + i2;
|
|
17001
17001
|
const code = SUBTOTAL[column.totalsRowFunction ?? ""];
|
|
17002
17002
|
if (code !== void 0) {
|
|
17003
17003
|
const cell = ensureCell(sheet, row2, col);
|
|
@@ -17016,8 +17016,8 @@ function nextTableName(workbook) {
|
|
|
17016
17016
|
}
|
|
17017
17017
|
function uniqueHeaders(texts) {
|
|
17018
17018
|
const used = /* @__PURE__ */ new Set();
|
|
17019
|
-
return texts.map((text,
|
|
17020
|
-
let base = text.trim() || `Column${
|
|
17019
|
+
return texts.map((text, i2) => {
|
|
17020
|
+
let base = text.trim() || `Column${i2 + 1}`;
|
|
17021
17021
|
if (!used.has(base.toLowerCase())) {
|
|
17022
17022
|
used.add(base.toLowerCase());
|
|
17023
17023
|
return base;
|
|
@@ -17049,22 +17049,22 @@ function createTable(ctx, s, range2, hasHeader, styleName = "TableStyleMedium2")
|
|
|
17049
17049
|
if (!hasHeader) {
|
|
17050
17050
|
const shift2 = { axis: "row", at: r.start.row, count: 1 };
|
|
17051
17051
|
const band = { lo: r.start.col, hi: r.end.col };
|
|
17052
|
-
rewriteFormulas(workbook, (
|
|
17052
|
+
rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift2, band));
|
|
17053
17053
|
shiftSheetContent(sheet, shift2, band);
|
|
17054
17054
|
r = { start: r.start, end: { row: r.end.row + 1, col: r.end.col } };
|
|
17055
17055
|
}
|
|
17056
17056
|
const width = r.end.col - r.start.col + 1;
|
|
17057
17057
|
const texts = Array.from(
|
|
17058
17058
|
{ length: width },
|
|
17059
|
-
(_v,
|
|
17059
|
+
(_v, i2) => hasHeader ? displayText(workbook, getCell(sheet, r.start.row, r.start.col + i2)) : ""
|
|
17060
17060
|
);
|
|
17061
17061
|
const headers = uniqueHeaders(texts);
|
|
17062
|
-
const columns = headers.map((name2,
|
|
17063
|
-
const cell = getCell(sheet, r.start.row, r.start.col +
|
|
17062
|
+
const columns = headers.map((name2, i2) => {
|
|
17063
|
+
const cell = getCell(sheet, r.start.row, r.start.col + i2);
|
|
17064
17064
|
if (cell?.value !== name2) {
|
|
17065
17065
|
const styleId = cell?.styleId;
|
|
17066
|
-
writeValue(sheet, r.start.row, r.start.col +
|
|
17067
|
-
const written = getCell(sheet, r.start.row, r.start.col +
|
|
17066
|
+
writeValue(sheet, r.start.row, r.start.col + i2, name2);
|
|
17067
|
+
const written = getCell(sheet, r.start.row, r.start.col + i2);
|
|
17068
17068
|
if (written && styleId) written.styleId = styleId;
|
|
17069
17069
|
}
|
|
17070
17070
|
return { name: name2 };
|
|
@@ -17113,7 +17113,7 @@ function validateTableName(workbook, name, self) {
|
|
|
17113
17113
|
function renameTableIn(workbook, table2, name) {
|
|
17114
17114
|
const old = table2.name;
|
|
17115
17115
|
if (old === name) return;
|
|
17116
|
-
const rename = (
|
|
17116
|
+
const rename = (f6) => renameTableInFormula(f6, old, name);
|
|
17117
17117
|
rewriteFormulas(workbook, rename);
|
|
17118
17118
|
for (const sheet of workbook.sheets)
|
|
17119
17119
|
for (const t of sheet.tables)
|
|
@@ -17131,7 +17131,7 @@ var byId = (sheet, id) => {
|
|
|
17131
17131
|
function insertBandRow(workbook, sheet, table2, row2) {
|
|
17132
17132
|
const shift2 = { axis: "row", at: row2, count: 1 };
|
|
17133
17133
|
const band = { lo: table2.range.start.col, hi: table2.range.end.col };
|
|
17134
|
-
rewriteFormulas(workbook, (
|
|
17134
|
+
rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift2, band));
|
|
17135
17135
|
shiftSheetContent(sheet, shift2, band);
|
|
17136
17136
|
}
|
|
17137
17137
|
function setHeaderRow(workbook, sheet, id, on) {
|
|
@@ -17153,10 +17153,10 @@ function setHeaderRow(workbook, sheet, id, on) {
|
|
|
17153
17153
|
const left2 = table2.range.start.col;
|
|
17154
17154
|
table2.range = { start: { row: top, col: left2 }, end: table2.range.end };
|
|
17155
17155
|
table2.headerRow = true;
|
|
17156
|
-
uniqueHeaders(table2.columns.map((c) => c.name)).forEach((name,
|
|
17157
|
-
const column = table2.columns[
|
|
17156
|
+
uniqueHeaders(table2.columns.map((c) => c.name)).forEach((name, i2) => {
|
|
17157
|
+
const column = table2.columns[i2];
|
|
17158
17158
|
if (column) column.name = name;
|
|
17159
|
-
writeValue(sheet, top, left2 +
|
|
17159
|
+
writeValue(sheet, top, left2 + i2, name);
|
|
17160
17160
|
});
|
|
17161
17161
|
}
|
|
17162
17162
|
function setTotalsRow(workbook, sheet, id, on) {
|
|
@@ -17180,14 +17180,14 @@ function setTotalsRow(workbook, sheet, id, on) {
|
|
|
17180
17180
|
function resizedColumns(workbook, sheet, table2, range2) {
|
|
17181
17181
|
const width = range2.end.col - range2.start.col + 1;
|
|
17182
17182
|
const oldAt = (col) => col >= table2.range.start.col && col <= table2.range.end.col ? table2.columns[col - table2.range.start.col] : void 0;
|
|
17183
|
-
const texts = Array.from({ length: width }, (_v,
|
|
17184
|
-
const col = range2.start.col +
|
|
17183
|
+
const texts = Array.from({ length: width }, (_v, i2) => {
|
|
17184
|
+
const col = range2.start.col + i2;
|
|
17185
17185
|
const old = oldAt(col);
|
|
17186
17186
|
if (old) return old.name;
|
|
17187
17187
|
return table2.headerRow ? displayText(workbook, getCell(sheet, range2.start.row, col)) : "";
|
|
17188
17188
|
});
|
|
17189
|
-
return uniqueHeaders(texts).map((name,
|
|
17190
|
-
const old = oldAt(range2.start.col +
|
|
17189
|
+
return uniqueHeaders(texts).map((name, i2) => {
|
|
17190
|
+
const old = oldAt(range2.start.col + i2);
|
|
17191
17191
|
return old ? { ...old, name } : { name };
|
|
17192
17192
|
});
|
|
17193
17193
|
}
|
|
@@ -17207,9 +17207,9 @@ function resizeTableIn(workbook, sheet, id, range2) {
|
|
|
17207
17207
|
table2.columns = resizedColumns(workbook, sheet, table2, r);
|
|
17208
17208
|
table2.range = r;
|
|
17209
17209
|
if (table2.headerRow)
|
|
17210
|
-
table2.columns.forEach((column,
|
|
17211
|
-
const cell = getCell(sheet, r.start.row, r.start.col +
|
|
17212
|
-
if (cell?.value !== column.name) writeValue(sheet, r.start.row, r.start.col +
|
|
17210
|
+
table2.columns.forEach((column, i2) => {
|
|
17211
|
+
const cell = getCell(sheet, r.start.row, r.start.col + i2);
|
|
17212
|
+
if (cell?.value !== column.name) writeValue(sheet, r.start.row, r.start.col + i2, column.name);
|
|
17213
17213
|
});
|
|
17214
17214
|
if (table2.totalsRow) {
|
|
17215
17215
|
if (oldEnd !== r.end.row) clearRow(sheet, oldEnd, r.start.col, r.end.col);
|
|
@@ -17296,7 +17296,7 @@ function convertTableToRange(ctx, s, ref) {
|
|
|
17296
17296
|
inside
|
|
17297
17297
|
});
|
|
17298
17298
|
});
|
|
17299
|
-
rewriteFormulas(workbook, (
|
|
17299
|
+
rewriteFormulas(workbook, (f6, fs) => structuredToA1(f6, { ...base, formulaSheet: fs }));
|
|
17300
17300
|
for (const ws of workbook.sheets)
|
|
17301
17301
|
for (const t of ws.tables)
|
|
17302
17302
|
for (const column of t.columns)
|
|
@@ -17322,7 +17322,7 @@ function removeDuplicates(ctx, s, range2, columns, hasHeader) {
|
|
|
17322
17322
|
if (sheet.merges.some((m) => rangesIntersect(m, data)))
|
|
17323
17323
|
throw new Error("Cannot remove duplicates from a range that contains merged cells.");
|
|
17324
17324
|
const keyCols = columns.filter((c) => c >= r.start.col && c <= r.end.col);
|
|
17325
|
-
const cols = keyCols.length ? keyCols : Array.from({ length: r.end.col - r.start.col + 1 }, (_v,
|
|
17325
|
+
const cols = keyCols.length ? keyCols : Array.from({ length: r.end.col - r.start.col + 1 }, (_v, i2) => r.start.col + i2);
|
|
17326
17326
|
let lastStored = first2;
|
|
17327
17327
|
for (const row2 of sheet.rows.keys()) if (row2 > lastStored) lastStored = row2;
|
|
17328
17328
|
const lastRow = Math.min(r.end.row, lastStored);
|
|
@@ -17350,8 +17350,8 @@ function removeDuplicates(ctx, s, range2, columns, hasHeader) {
|
|
|
17350
17350
|
for (let row2 = first2; row2 <= lastRow; row2++)
|
|
17351
17351
|
for (const col of [...sheet.rows.get(row2)?.keys() ?? []])
|
|
17352
17352
|
if (col >= r.start.col && col <= r.end.col) deleteCell(sheet, row2, col);
|
|
17353
|
-
moved.forEach(({ row: from, cells },
|
|
17354
|
-
const row2 = first2 +
|
|
17353
|
+
moved.forEach(({ row: from, cells }, i2) => {
|
|
17354
|
+
const row2 = first2 + i2;
|
|
17355
17355
|
for (const [col, cell] of cells) {
|
|
17356
17356
|
if (cell.formula !== void 0 && row2 !== from)
|
|
17357
17357
|
cell.formula = translateFormula(cell.formula, row2 - from, 0);
|
|
@@ -17372,7 +17372,7 @@ function nextLevel(level, delta) {
|
|
|
17372
17372
|
function span2(from, to) {
|
|
17373
17373
|
const lo = Math.max(0, Math.min(from, to));
|
|
17374
17374
|
const hi = Math.max(from, to);
|
|
17375
|
-
return Array.from({ length: hi - lo + 1 }, (_v,
|
|
17375
|
+
return Array.from({ length: hi - lo + 1 }, (_v, i2) => lo + i2);
|
|
17376
17376
|
}
|
|
17377
17377
|
function outlineRows(ctx, s, from, to, delta) {
|
|
17378
17378
|
const sheet = sheetAt(ctx.workbook, s);
|
|
@@ -17514,6 +17514,846 @@ function decodeBase64(text) {
|
|
|
17514
17514
|
return out;
|
|
17515
17515
|
}
|
|
17516
17516
|
|
|
17517
|
+
// digest/md2.ts
|
|
17518
|
+
var S = [
|
|
17519
|
+
41,
|
|
17520
|
+
46,
|
|
17521
|
+
67,
|
|
17522
|
+
201,
|
|
17523
|
+
162,
|
|
17524
|
+
216,
|
|
17525
|
+
124,
|
|
17526
|
+
1,
|
|
17527
|
+
61,
|
|
17528
|
+
54,
|
|
17529
|
+
84,
|
|
17530
|
+
161,
|
|
17531
|
+
236,
|
|
17532
|
+
240,
|
|
17533
|
+
6,
|
|
17534
|
+
19,
|
|
17535
|
+
98,
|
|
17536
|
+
167,
|
|
17537
|
+
5,
|
|
17538
|
+
243,
|
|
17539
|
+
192,
|
|
17540
|
+
199,
|
|
17541
|
+
115,
|
|
17542
|
+
140,
|
|
17543
|
+
152,
|
|
17544
|
+
147,
|
|
17545
|
+
43,
|
|
17546
|
+
217,
|
|
17547
|
+
188,
|
|
17548
|
+
76,
|
|
17549
|
+
130,
|
|
17550
|
+
202,
|
|
17551
|
+
30,
|
|
17552
|
+
155,
|
|
17553
|
+
87,
|
|
17554
|
+
60,
|
|
17555
|
+
253,
|
|
17556
|
+
212,
|
|
17557
|
+
224,
|
|
17558
|
+
22,
|
|
17559
|
+
103,
|
|
17560
|
+
66,
|
|
17561
|
+
111,
|
|
17562
|
+
24,
|
|
17563
|
+
138,
|
|
17564
|
+
23,
|
|
17565
|
+
229,
|
|
17566
|
+
18,
|
|
17567
|
+
190,
|
|
17568
|
+
78,
|
|
17569
|
+
196,
|
|
17570
|
+
214,
|
|
17571
|
+
218,
|
|
17572
|
+
158,
|
|
17573
|
+
222,
|
|
17574
|
+
73,
|
|
17575
|
+
160,
|
|
17576
|
+
251,
|
|
17577
|
+
245,
|
|
17578
|
+
142,
|
|
17579
|
+
187,
|
|
17580
|
+
47,
|
|
17581
|
+
238,
|
|
17582
|
+
122,
|
|
17583
|
+
169,
|
|
17584
|
+
104,
|
|
17585
|
+
121,
|
|
17586
|
+
145,
|
|
17587
|
+
21,
|
|
17588
|
+
178,
|
|
17589
|
+
7,
|
|
17590
|
+
63,
|
|
17591
|
+
148,
|
|
17592
|
+
194,
|
|
17593
|
+
16,
|
|
17594
|
+
137,
|
|
17595
|
+
11,
|
|
17596
|
+
34,
|
|
17597
|
+
95,
|
|
17598
|
+
33,
|
|
17599
|
+
128,
|
|
17600
|
+
127,
|
|
17601
|
+
93,
|
|
17602
|
+
154,
|
|
17603
|
+
90,
|
|
17604
|
+
144,
|
|
17605
|
+
50,
|
|
17606
|
+
39,
|
|
17607
|
+
53,
|
|
17608
|
+
62,
|
|
17609
|
+
204,
|
|
17610
|
+
231,
|
|
17611
|
+
191,
|
|
17612
|
+
247,
|
|
17613
|
+
151,
|
|
17614
|
+
3,
|
|
17615
|
+
255,
|
|
17616
|
+
25,
|
|
17617
|
+
48,
|
|
17618
|
+
179,
|
|
17619
|
+
72,
|
|
17620
|
+
165,
|
|
17621
|
+
181,
|
|
17622
|
+
209,
|
|
17623
|
+
215,
|
|
17624
|
+
94,
|
|
17625
|
+
146,
|
|
17626
|
+
42,
|
|
17627
|
+
172,
|
|
17628
|
+
86,
|
|
17629
|
+
170,
|
|
17630
|
+
198,
|
|
17631
|
+
79,
|
|
17632
|
+
184,
|
|
17633
|
+
56,
|
|
17634
|
+
210,
|
|
17635
|
+
150,
|
|
17636
|
+
164,
|
|
17637
|
+
125,
|
|
17638
|
+
182,
|
|
17639
|
+
118,
|
|
17640
|
+
252,
|
|
17641
|
+
107,
|
|
17642
|
+
226,
|
|
17643
|
+
156,
|
|
17644
|
+
116,
|
|
17645
|
+
4,
|
|
17646
|
+
241,
|
|
17647
|
+
69,
|
|
17648
|
+
157,
|
|
17649
|
+
112,
|
|
17650
|
+
89,
|
|
17651
|
+
100,
|
|
17652
|
+
113,
|
|
17653
|
+
135,
|
|
17654
|
+
32,
|
|
17655
|
+
134,
|
|
17656
|
+
91,
|
|
17657
|
+
207,
|
|
17658
|
+
101,
|
|
17659
|
+
230,
|
|
17660
|
+
45,
|
|
17661
|
+
168,
|
|
17662
|
+
2,
|
|
17663
|
+
27,
|
|
17664
|
+
96,
|
|
17665
|
+
37,
|
|
17666
|
+
173,
|
|
17667
|
+
174,
|
|
17668
|
+
176,
|
|
17669
|
+
185,
|
|
17670
|
+
246,
|
|
17671
|
+
28,
|
|
17672
|
+
70,
|
|
17673
|
+
97,
|
|
17674
|
+
105,
|
|
17675
|
+
52,
|
|
17676
|
+
64,
|
|
17677
|
+
126,
|
|
17678
|
+
15,
|
|
17679
|
+
85,
|
|
17680
|
+
71,
|
|
17681
|
+
163,
|
|
17682
|
+
35,
|
|
17683
|
+
221,
|
|
17684
|
+
81,
|
|
17685
|
+
175,
|
|
17686
|
+
58,
|
|
17687
|
+
195,
|
|
17688
|
+
92,
|
|
17689
|
+
249,
|
|
17690
|
+
206,
|
|
17691
|
+
186,
|
|
17692
|
+
197,
|
|
17693
|
+
234,
|
|
17694
|
+
38,
|
|
17695
|
+
44,
|
|
17696
|
+
83,
|
|
17697
|
+
13,
|
|
17698
|
+
110,
|
|
17699
|
+
133,
|
|
17700
|
+
40,
|
|
17701
|
+
132,
|
|
17702
|
+
9,
|
|
17703
|
+
211,
|
|
17704
|
+
223,
|
|
17705
|
+
205,
|
|
17706
|
+
244,
|
|
17707
|
+
65,
|
|
17708
|
+
129,
|
|
17709
|
+
77,
|
|
17710
|
+
82,
|
|
17711
|
+
106,
|
|
17712
|
+
220,
|
|
17713
|
+
55,
|
|
17714
|
+
200,
|
|
17715
|
+
108,
|
|
17716
|
+
193,
|
|
17717
|
+
171,
|
|
17718
|
+
250,
|
|
17719
|
+
36,
|
|
17720
|
+
225,
|
|
17721
|
+
123,
|
|
17722
|
+
8,
|
|
17723
|
+
12,
|
|
17724
|
+
189,
|
|
17725
|
+
177,
|
|
17726
|
+
74,
|
|
17727
|
+
120,
|
|
17728
|
+
136,
|
|
17729
|
+
149,
|
|
17730
|
+
139,
|
|
17731
|
+
227,
|
|
17732
|
+
99,
|
|
17733
|
+
232,
|
|
17734
|
+
109,
|
|
17735
|
+
233,
|
|
17736
|
+
203,
|
|
17737
|
+
213,
|
|
17738
|
+
254,
|
|
17739
|
+
59,
|
|
17740
|
+
0,
|
|
17741
|
+
29,
|
|
17742
|
+
57,
|
|
17743
|
+
242,
|
|
17744
|
+
239,
|
|
17745
|
+
183,
|
|
17746
|
+
14,
|
|
17747
|
+
102,
|
|
17748
|
+
88,
|
|
17749
|
+
208,
|
|
17750
|
+
228,
|
|
17751
|
+
166,
|
|
17752
|
+
119,
|
|
17753
|
+
114,
|
|
17754
|
+
248,
|
|
17755
|
+
235,
|
|
17756
|
+
117,
|
|
17757
|
+
75,
|
|
17758
|
+
10,
|
|
17759
|
+
49,
|
|
17760
|
+
68,
|
|
17761
|
+
80,
|
|
17762
|
+
180,
|
|
17763
|
+
143,
|
|
17764
|
+
237,
|
|
17765
|
+
31,
|
|
17766
|
+
26,
|
|
17767
|
+
219,
|
|
17768
|
+
153,
|
|
17769
|
+
141,
|
|
17770
|
+
51,
|
|
17771
|
+
159,
|
|
17772
|
+
17,
|
|
17773
|
+
131,
|
|
17774
|
+
20
|
|
17775
|
+
];
|
|
17776
|
+
function transform(state, checksum, block) {
|
|
17777
|
+
const x = new Uint8Array(48);
|
|
17778
|
+
x.set(state, 0);
|
|
17779
|
+
x.set(block, 16);
|
|
17780
|
+
for (let k = 0; k < 16; k++) {
|
|
17781
|
+
x[32 + k] = state[k] ^ block[k];
|
|
17782
|
+
}
|
|
17783
|
+
let t = 0;
|
|
17784
|
+
for (let round3 = 0; round3 < 18; round3++) {
|
|
17785
|
+
for (let k = 0; k < 48; k++) {
|
|
17786
|
+
x[k] = x[k] ^ S[t];
|
|
17787
|
+
t = x[k];
|
|
17788
|
+
}
|
|
17789
|
+
t = t + round3 & 255;
|
|
17790
|
+
}
|
|
17791
|
+
state.set(x.subarray(0, 16));
|
|
17792
|
+
t = checksum[15];
|
|
17793
|
+
for (let k = 0; k < 16; k++) {
|
|
17794
|
+
checksum[k] = checksum[k] ^ S[block[k] ^ t];
|
|
17795
|
+
t = checksum[k];
|
|
17796
|
+
}
|
|
17797
|
+
}
|
|
17798
|
+
function md2(message) {
|
|
17799
|
+
const padLength = 16 - message.length % 16;
|
|
17800
|
+
const padded = new Uint8Array(message.length + padLength);
|
|
17801
|
+
padded.set(message);
|
|
17802
|
+
padded.fill(padLength, message.length);
|
|
17803
|
+
const state = new Uint8Array(16);
|
|
17804
|
+
const checksum = new Uint8Array(16);
|
|
17805
|
+
for (let offset2 = 0; offset2 < padded.length; offset2 += 16) {
|
|
17806
|
+
transform(state, checksum, padded.subarray(offset2, offset2 + 16));
|
|
17807
|
+
}
|
|
17808
|
+
transform(state, checksum, checksum.slice());
|
|
17809
|
+
return state;
|
|
17810
|
+
}
|
|
17811
|
+
|
|
17812
|
+
// digest/bit-ops.ts
|
|
17813
|
+
function rotl32(x, n) {
|
|
17814
|
+
return (x << n | x >>> 32 - n) >>> 0;
|
|
17815
|
+
}
|
|
17816
|
+
function add32(...values2) {
|
|
17817
|
+
let sum2 = 0;
|
|
17818
|
+
for (const value2 of values2) sum2 = sum2 + value2 >>> 0;
|
|
17819
|
+
return sum2;
|
|
17820
|
+
}
|
|
17821
|
+
function padMd4Style(message) {
|
|
17822
|
+
const paddedLength = message.length + 9 + 63 & -64;
|
|
17823
|
+
const padded = new Uint8Array(paddedLength);
|
|
17824
|
+
padded.set(message);
|
|
17825
|
+
padded[message.length] = 128;
|
|
17826
|
+
new DataView(padded.buffer).setBigUint64(paddedLength - 8, BigInt(message.length) * 8n, true);
|
|
17827
|
+
return padded;
|
|
17828
|
+
}
|
|
17829
|
+
function applyRotatingRound(r, ops, f6, x, feedback = false) {
|
|
17830
|
+
let target2 = 0;
|
|
17831
|
+
for (const [k, s, addConst] of ops) {
|
|
17832
|
+
const i1 = target2 + 1 & 3;
|
|
17833
|
+
const next = r[i1];
|
|
17834
|
+
const rotated = rotl32(
|
|
17835
|
+
add32(r[target2], f6(next, r[target2 + 2 & 3], r[target2 + 3 & 3]), x[k], addConst),
|
|
17836
|
+
s
|
|
17837
|
+
);
|
|
17838
|
+
r[target2] = feedback ? add32(next, rotated) : rotated;
|
|
17839
|
+
target2 = target2 + 3 & 3;
|
|
17840
|
+
}
|
|
17841
|
+
}
|
|
17842
|
+
function mdStyleDigest(message, initialState, transform6) {
|
|
17843
|
+
const padded = padMd4Style(message);
|
|
17844
|
+
const view = new DataView(padded.buffer);
|
|
17845
|
+
const state = [...initialState];
|
|
17846
|
+
const words2 = new Array(16).fill(0);
|
|
17847
|
+
for (let offset2 = 0; offset2 < padded.length; offset2 += 64) {
|
|
17848
|
+
for (let i2 = 0; i2 < 16; i2++) words2[i2] = view.getUint32(offset2 + i2 * 4, true);
|
|
17849
|
+
transform6(state, words2);
|
|
17850
|
+
}
|
|
17851
|
+
const out = new Uint8Array(state.length * 4);
|
|
17852
|
+
const outView = new DataView(out.buffer);
|
|
17853
|
+
for (let i2 = 0; i2 < state.length; i2++) outView.setUint32(i2 * 4, state[i2], true);
|
|
17854
|
+
return out;
|
|
17855
|
+
}
|
|
17856
|
+
|
|
17857
|
+
// digest/md4.ts
|
|
17858
|
+
var INITIAL_STATE = [1732584193, 4023233417, 2562383102, 271733878];
|
|
17859
|
+
var K2 = 1518500249;
|
|
17860
|
+
var K3 = 1859775393;
|
|
17861
|
+
var f1 = (x, y, z) => x & y | ~x & z;
|
|
17862
|
+
var f2 = (x, y, z) => x & y | x & z | y & z;
|
|
17863
|
+
var f3 = (x, y, z) => x ^ y ^ z;
|
|
17864
|
+
function round(order, shifts, k) {
|
|
17865
|
+
return order.map((word, i2) => [word, shifts[i2 % 4], k]);
|
|
17866
|
+
}
|
|
17867
|
+
var SEQUENTIAL = Array.from({ length: 16 }, (_, i2) => i2);
|
|
17868
|
+
var COLUMNS = Array.from({ length: 16 }, (_, i2) => i2 % 4 * 4 + (i2 >> 2));
|
|
17869
|
+
var BIT_REVERSED = [0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15];
|
|
17870
|
+
var ROUND1 = round(SEQUENTIAL, [3, 7, 11, 19], 0);
|
|
17871
|
+
var ROUND2 = round(COLUMNS, [3, 5, 9, 13], K2);
|
|
17872
|
+
var ROUND3 = round(BIT_REVERSED, [3, 9, 11, 15], K3);
|
|
17873
|
+
function transform2(state, x) {
|
|
17874
|
+
const r = [...state];
|
|
17875
|
+
applyRotatingRound(r, ROUND1, f1, x);
|
|
17876
|
+
applyRotatingRound(r, ROUND2, f2, x);
|
|
17877
|
+
applyRotatingRound(r, ROUND3, f3, x);
|
|
17878
|
+
for (let i2 = 0; i2 < 4; i2++) state[i2] = add32(state[i2], r[i2]);
|
|
17879
|
+
}
|
|
17880
|
+
function md4(message) {
|
|
17881
|
+
return mdStyleDigest(message, INITIAL_STATE, transform2);
|
|
17882
|
+
}
|
|
17883
|
+
|
|
17884
|
+
// digest/md5.ts
|
|
17885
|
+
var INITIAL_STATE2 = [1732584193, 4023233417, 2562383102, 271733878];
|
|
17886
|
+
function f(x, y, z) {
|
|
17887
|
+
return x & y | ~x & z;
|
|
17888
|
+
}
|
|
17889
|
+
function g(x, y, z) {
|
|
17890
|
+
return x & z | y & ~z;
|
|
17891
|
+
}
|
|
17892
|
+
function h(x, y, z) {
|
|
17893
|
+
return x ^ y ^ z;
|
|
17894
|
+
}
|
|
17895
|
+
function i(x, y, z) {
|
|
17896
|
+
return y ^ (x | ~z);
|
|
17897
|
+
}
|
|
17898
|
+
var T = Array.from(
|
|
17899
|
+
{ length: 64 },
|
|
17900
|
+
(_, index2) => Math.floor(Math.abs(Math.sin(index2 + 1)) * 2 ** 32)
|
|
17901
|
+
);
|
|
17902
|
+
var SHIFTS = [
|
|
17903
|
+
[7, 12, 17, 22],
|
|
17904
|
+
[5, 9, 14, 20],
|
|
17905
|
+
[4, 11, 16, 23],
|
|
17906
|
+
[6, 10, 15, 21]
|
|
17907
|
+
];
|
|
17908
|
+
var WORD_INDEX = [
|
|
17909
|
+
(idx) => idx,
|
|
17910
|
+
(idx) => (5 * idx + 1) % 16,
|
|
17911
|
+
(idx) => (3 * idx + 5) % 16,
|
|
17912
|
+
(idx) => 7 * idx % 16
|
|
17913
|
+
];
|
|
17914
|
+
var ROUND_FNS = [f, g, h, i];
|
|
17915
|
+
function buildOps(round3) {
|
|
17916
|
+
const shifts = SHIFTS[round3];
|
|
17917
|
+
const wordIndex = WORD_INDEX[round3];
|
|
17918
|
+
return Array.from({ length: 16 }, (_, idx) => {
|
|
17919
|
+
const opNumber = round3 * 16 + idx;
|
|
17920
|
+
return [wordIndex(idx), shifts[idx % 4], T[opNumber]];
|
|
17921
|
+
});
|
|
17922
|
+
}
|
|
17923
|
+
var ROUNDS = [0, 1, 2, 3].map(buildOps);
|
|
17924
|
+
function transform3(state, x) {
|
|
17925
|
+
const r = [...state];
|
|
17926
|
+
for (let round3 = 0; round3 < 4; round3++) {
|
|
17927
|
+
applyRotatingRound(r, ROUNDS[round3], ROUND_FNS[round3], x, true);
|
|
17928
|
+
}
|
|
17929
|
+
for (let idx = 0; idx < 4; idx++) {
|
|
17930
|
+
state[idx] = add32(state[idx], r[idx]);
|
|
17931
|
+
}
|
|
17932
|
+
}
|
|
17933
|
+
function md5(message) {
|
|
17934
|
+
return mdStyleDigest(message, INITIAL_STATE2, transform3);
|
|
17935
|
+
}
|
|
17936
|
+
|
|
17937
|
+
// digest/ripemd-functions.ts
|
|
17938
|
+
function f12(x, y, z) {
|
|
17939
|
+
return x ^ y ^ z;
|
|
17940
|
+
}
|
|
17941
|
+
function f22(x, y, z) {
|
|
17942
|
+
return x & y | ~x & z;
|
|
17943
|
+
}
|
|
17944
|
+
function f32(x, y, z) {
|
|
17945
|
+
return (x | ~y) ^ z;
|
|
17946
|
+
}
|
|
17947
|
+
function f4(x, y, z) {
|
|
17948
|
+
return z & x | ~z & y;
|
|
17949
|
+
}
|
|
17950
|
+
function f5(x, y, z) {
|
|
17951
|
+
return x ^ (y | ~z);
|
|
17952
|
+
}
|
|
17953
|
+
|
|
17954
|
+
// digest/ripemd128.ts
|
|
17955
|
+
var INITIAL_STATE3 = [1732584193, 4023233417, 2562383102, 271733878];
|
|
17956
|
+
var LEFT_ROUNDS = [
|
|
17957
|
+
[
|
|
17958
|
+
[0, 11, 0],
|
|
17959
|
+
[1, 14, 0],
|
|
17960
|
+
[2, 15, 0],
|
|
17961
|
+
[3, 12, 0],
|
|
17962
|
+
[4, 5, 0],
|
|
17963
|
+
[5, 8, 0],
|
|
17964
|
+
[6, 7, 0],
|
|
17965
|
+
[7, 9, 0],
|
|
17966
|
+
[8, 11, 0],
|
|
17967
|
+
[9, 13, 0],
|
|
17968
|
+
[10, 14, 0],
|
|
17969
|
+
[11, 15, 0],
|
|
17970
|
+
[12, 6, 0],
|
|
17971
|
+
[13, 7, 0],
|
|
17972
|
+
[14, 9, 0],
|
|
17973
|
+
[15, 8, 0]
|
|
17974
|
+
],
|
|
17975
|
+
[
|
|
17976
|
+
[7, 7, 1518500249],
|
|
17977
|
+
[4, 6, 1518500249],
|
|
17978
|
+
[13, 8, 1518500249],
|
|
17979
|
+
[1, 13, 1518500249],
|
|
17980
|
+
[10, 11, 1518500249],
|
|
17981
|
+
[6, 9, 1518500249],
|
|
17982
|
+
[15, 7, 1518500249],
|
|
17983
|
+
[3, 15, 1518500249],
|
|
17984
|
+
[12, 7, 1518500249],
|
|
17985
|
+
[0, 12, 1518500249],
|
|
17986
|
+
[9, 15, 1518500249],
|
|
17987
|
+
[5, 9, 1518500249],
|
|
17988
|
+
[2, 11, 1518500249],
|
|
17989
|
+
[14, 7, 1518500249],
|
|
17990
|
+
[11, 13, 1518500249],
|
|
17991
|
+
[8, 12, 1518500249]
|
|
17992
|
+
],
|
|
17993
|
+
[
|
|
17994
|
+
[3, 11, 1859775393],
|
|
17995
|
+
[10, 13, 1859775393],
|
|
17996
|
+
[14, 6, 1859775393],
|
|
17997
|
+
[4, 7, 1859775393],
|
|
17998
|
+
[9, 14, 1859775393],
|
|
17999
|
+
[15, 9, 1859775393],
|
|
18000
|
+
[8, 13, 1859775393],
|
|
18001
|
+
[1, 15, 1859775393],
|
|
18002
|
+
[2, 14, 1859775393],
|
|
18003
|
+
[7, 8, 1859775393],
|
|
18004
|
+
[0, 13, 1859775393],
|
|
18005
|
+
[6, 6, 1859775393],
|
|
18006
|
+
[13, 5, 1859775393],
|
|
18007
|
+
[11, 12, 1859775393],
|
|
18008
|
+
[5, 7, 1859775393],
|
|
18009
|
+
[12, 5, 1859775393]
|
|
18010
|
+
],
|
|
18011
|
+
[
|
|
18012
|
+
[1, 11, 2400959708],
|
|
18013
|
+
[9, 12, 2400959708],
|
|
18014
|
+
[11, 14, 2400959708],
|
|
18015
|
+
[10, 15, 2400959708],
|
|
18016
|
+
[0, 14, 2400959708],
|
|
18017
|
+
[8, 15, 2400959708],
|
|
18018
|
+
[12, 9, 2400959708],
|
|
18019
|
+
[4, 8, 2400959708],
|
|
18020
|
+
[13, 9, 2400959708],
|
|
18021
|
+
[3, 14, 2400959708],
|
|
18022
|
+
[7, 5, 2400959708],
|
|
18023
|
+
[15, 6, 2400959708],
|
|
18024
|
+
[14, 8, 2400959708],
|
|
18025
|
+
[5, 6, 2400959708],
|
|
18026
|
+
[6, 5, 2400959708],
|
|
18027
|
+
[2, 12, 2400959708]
|
|
18028
|
+
]
|
|
18029
|
+
];
|
|
18030
|
+
var RIGHT_ROUNDS = [
|
|
18031
|
+
[
|
|
18032
|
+
[5, 8, 1352829926],
|
|
18033
|
+
[14, 9, 1352829926],
|
|
18034
|
+
[7, 9, 1352829926],
|
|
18035
|
+
[0, 11, 1352829926],
|
|
18036
|
+
[9, 13, 1352829926],
|
|
18037
|
+
[2, 15, 1352829926],
|
|
18038
|
+
[11, 15, 1352829926],
|
|
18039
|
+
[4, 5, 1352829926],
|
|
18040
|
+
[13, 7, 1352829926],
|
|
18041
|
+
[6, 7, 1352829926],
|
|
18042
|
+
[15, 8, 1352829926],
|
|
18043
|
+
[8, 11, 1352829926],
|
|
18044
|
+
[1, 14, 1352829926],
|
|
18045
|
+
[10, 14, 1352829926],
|
|
18046
|
+
[3, 12, 1352829926],
|
|
18047
|
+
[12, 6, 1352829926]
|
|
18048
|
+
],
|
|
18049
|
+
[
|
|
18050
|
+
[6, 9, 1548603684],
|
|
18051
|
+
[11, 13, 1548603684],
|
|
18052
|
+
[3, 15, 1548603684],
|
|
18053
|
+
[7, 7, 1548603684],
|
|
18054
|
+
[0, 12, 1548603684],
|
|
18055
|
+
[13, 8, 1548603684],
|
|
18056
|
+
[5, 9, 1548603684],
|
|
18057
|
+
[10, 11, 1548603684],
|
|
18058
|
+
[14, 7, 1548603684],
|
|
18059
|
+
[15, 7, 1548603684],
|
|
18060
|
+
[8, 12, 1548603684],
|
|
18061
|
+
[12, 7, 1548603684],
|
|
18062
|
+
[4, 6, 1548603684],
|
|
18063
|
+
[9, 15, 1548603684],
|
|
18064
|
+
[1, 13, 1548603684],
|
|
18065
|
+
[2, 11, 1548603684]
|
|
18066
|
+
],
|
|
18067
|
+
[
|
|
18068
|
+
[15, 9, 1836072691],
|
|
18069
|
+
[5, 7, 1836072691],
|
|
18070
|
+
[1, 15, 1836072691],
|
|
18071
|
+
[3, 11, 1836072691],
|
|
18072
|
+
[7, 8, 1836072691],
|
|
18073
|
+
[14, 6, 1836072691],
|
|
18074
|
+
[6, 6, 1836072691],
|
|
18075
|
+
[9, 14, 1836072691],
|
|
18076
|
+
[11, 12, 1836072691],
|
|
18077
|
+
[8, 13, 1836072691],
|
|
18078
|
+
[12, 5, 1836072691],
|
|
18079
|
+
[2, 14, 1836072691],
|
|
18080
|
+
[10, 13, 1836072691],
|
|
18081
|
+
[0, 13, 1836072691],
|
|
18082
|
+
[4, 7, 1836072691],
|
|
18083
|
+
[13, 5, 1836072691]
|
|
18084
|
+
],
|
|
18085
|
+
[
|
|
18086
|
+
[8, 15, 0],
|
|
18087
|
+
[6, 5, 0],
|
|
18088
|
+
[4, 8, 0],
|
|
18089
|
+
[1, 11, 0],
|
|
18090
|
+
[3, 14, 0],
|
|
18091
|
+
[11, 14, 0],
|
|
18092
|
+
[15, 6, 0],
|
|
18093
|
+
[0, 14, 0],
|
|
18094
|
+
[5, 6, 0],
|
|
18095
|
+
[12, 9, 0],
|
|
18096
|
+
[2, 12, 0],
|
|
18097
|
+
[13, 9, 0],
|
|
18098
|
+
[9, 12, 0],
|
|
18099
|
+
[7, 5, 0],
|
|
18100
|
+
[10, 15, 0],
|
|
18101
|
+
[14, 8, 0]
|
|
18102
|
+
]
|
|
18103
|
+
];
|
|
18104
|
+
var LEFT_FNS = [f12, f22, f32, f4];
|
|
18105
|
+
var RIGHT_FNS = [f4, f32, f22, f12];
|
|
18106
|
+
function transform4(state, x) {
|
|
18107
|
+
const left2 = [...state];
|
|
18108
|
+
const right2 = [...state];
|
|
18109
|
+
for (let round3 = 0; round3 < 4; round3++) {
|
|
18110
|
+
applyRotatingRound(left2, LEFT_ROUNDS[round3], LEFT_FNS[round3], x);
|
|
18111
|
+
applyRotatingRound(right2, RIGHT_ROUNDS[round3], RIGHT_FNS[round3], x);
|
|
18112
|
+
}
|
|
18113
|
+
const orig = state;
|
|
18114
|
+
const newState = [
|
|
18115
|
+
add32(right2[3], left2[2], orig[1]),
|
|
18116
|
+
add32(orig[2], left2[3], right2[0]),
|
|
18117
|
+
add32(orig[3], left2[0], right2[1]),
|
|
18118
|
+
add32(orig[0], left2[1], right2[2])
|
|
18119
|
+
];
|
|
18120
|
+
for (let i2 = 0; i2 < 4; i2++) {
|
|
18121
|
+
state[i2] = newState[i2];
|
|
18122
|
+
}
|
|
18123
|
+
}
|
|
18124
|
+
function ripemd128(message) {
|
|
18125
|
+
return mdStyleDigest(message, INITIAL_STATE3, transform4);
|
|
18126
|
+
}
|
|
18127
|
+
|
|
18128
|
+
// digest/ripemd160.ts
|
|
18129
|
+
var INITIAL_STATE4 = [1732584193, 4023233417, 2562383102, 271733878, 3285377520];
|
|
18130
|
+
var LEFT_ROUNDS2 = [
|
|
18131
|
+
[
|
|
18132
|
+
[0, 11, 0],
|
|
18133
|
+
[1, 14, 0],
|
|
18134
|
+
[2, 15, 0],
|
|
18135
|
+
[3, 12, 0],
|
|
18136
|
+
[4, 5, 0],
|
|
18137
|
+
[5, 8, 0],
|
|
18138
|
+
[6, 7, 0],
|
|
18139
|
+
[7, 9, 0],
|
|
18140
|
+
[8, 11, 0],
|
|
18141
|
+
[9, 13, 0],
|
|
18142
|
+
[10, 14, 0],
|
|
18143
|
+
[11, 15, 0],
|
|
18144
|
+
[12, 6, 0],
|
|
18145
|
+
[13, 7, 0],
|
|
18146
|
+
[14, 9, 0],
|
|
18147
|
+
[15, 8, 0]
|
|
18148
|
+
],
|
|
18149
|
+
[
|
|
18150
|
+
[7, 7, 1518500249],
|
|
18151
|
+
[4, 6, 1518500249],
|
|
18152
|
+
[13, 8, 1518500249],
|
|
18153
|
+
[1, 13, 1518500249],
|
|
18154
|
+
[10, 11, 1518500249],
|
|
18155
|
+
[6, 9, 1518500249],
|
|
18156
|
+
[15, 7, 1518500249],
|
|
18157
|
+
[3, 15, 1518500249],
|
|
18158
|
+
[12, 7, 1518500249],
|
|
18159
|
+
[0, 12, 1518500249],
|
|
18160
|
+
[9, 15, 1518500249],
|
|
18161
|
+
[5, 9, 1518500249],
|
|
18162
|
+
[2, 11, 1518500249],
|
|
18163
|
+
[14, 7, 1518500249],
|
|
18164
|
+
[11, 13, 1518500249],
|
|
18165
|
+
[8, 12, 1518500249]
|
|
18166
|
+
],
|
|
18167
|
+
[
|
|
18168
|
+
[3, 11, 1859775393],
|
|
18169
|
+
[10, 13, 1859775393],
|
|
18170
|
+
[14, 6, 1859775393],
|
|
18171
|
+
[4, 7, 1859775393],
|
|
18172
|
+
[9, 14, 1859775393],
|
|
18173
|
+
[15, 9, 1859775393],
|
|
18174
|
+
[8, 13, 1859775393],
|
|
18175
|
+
[1, 15, 1859775393],
|
|
18176
|
+
[2, 14, 1859775393],
|
|
18177
|
+
[7, 8, 1859775393],
|
|
18178
|
+
[0, 13, 1859775393],
|
|
18179
|
+
[6, 6, 1859775393],
|
|
18180
|
+
[13, 5, 1859775393],
|
|
18181
|
+
[11, 12, 1859775393],
|
|
18182
|
+
[5, 7, 1859775393],
|
|
18183
|
+
[12, 5, 1859775393]
|
|
18184
|
+
],
|
|
18185
|
+
[
|
|
18186
|
+
[1, 11, 2400959708],
|
|
18187
|
+
[9, 12, 2400959708],
|
|
18188
|
+
[11, 14, 2400959708],
|
|
18189
|
+
[10, 15, 2400959708],
|
|
18190
|
+
[0, 14, 2400959708],
|
|
18191
|
+
[8, 15, 2400959708],
|
|
18192
|
+
[12, 9, 2400959708],
|
|
18193
|
+
[4, 8, 2400959708],
|
|
18194
|
+
[13, 9, 2400959708],
|
|
18195
|
+
[3, 14, 2400959708],
|
|
18196
|
+
[7, 5, 2400959708],
|
|
18197
|
+
[15, 6, 2400959708],
|
|
18198
|
+
[14, 8, 2400959708],
|
|
18199
|
+
[5, 6, 2400959708],
|
|
18200
|
+
[6, 5, 2400959708],
|
|
18201
|
+
[2, 12, 2400959708]
|
|
18202
|
+
],
|
|
18203
|
+
[
|
|
18204
|
+
[4, 9, 2840853838],
|
|
18205
|
+
[0, 15, 2840853838],
|
|
18206
|
+
[5, 5, 2840853838],
|
|
18207
|
+
[9, 11, 2840853838],
|
|
18208
|
+
[7, 6, 2840853838],
|
|
18209
|
+
[12, 8, 2840853838],
|
|
18210
|
+
[2, 13, 2840853838],
|
|
18211
|
+
[10, 12, 2840853838],
|
|
18212
|
+
[14, 5, 2840853838],
|
|
18213
|
+
[1, 12, 2840853838],
|
|
18214
|
+
[3, 13, 2840853838],
|
|
18215
|
+
[8, 14, 2840853838],
|
|
18216
|
+
[11, 11, 2840853838],
|
|
18217
|
+
[6, 8, 2840853838],
|
|
18218
|
+
[15, 5, 2840853838],
|
|
18219
|
+
[13, 6, 2840853838]
|
|
18220
|
+
]
|
|
18221
|
+
];
|
|
18222
|
+
var RIGHT_ROUNDS2 = [
|
|
18223
|
+
[
|
|
18224
|
+
[5, 8, 1352829926],
|
|
18225
|
+
[14, 9, 1352829926],
|
|
18226
|
+
[7, 9, 1352829926],
|
|
18227
|
+
[0, 11, 1352829926],
|
|
18228
|
+
[9, 13, 1352829926],
|
|
18229
|
+
[2, 15, 1352829926],
|
|
18230
|
+
[11, 15, 1352829926],
|
|
18231
|
+
[4, 5, 1352829926],
|
|
18232
|
+
[13, 7, 1352829926],
|
|
18233
|
+
[6, 7, 1352829926],
|
|
18234
|
+
[15, 8, 1352829926],
|
|
18235
|
+
[8, 11, 1352829926],
|
|
18236
|
+
[1, 14, 1352829926],
|
|
18237
|
+
[10, 14, 1352829926],
|
|
18238
|
+
[3, 12, 1352829926],
|
|
18239
|
+
[12, 6, 1352829926]
|
|
18240
|
+
],
|
|
18241
|
+
[
|
|
18242
|
+
[6, 9, 1548603684],
|
|
18243
|
+
[11, 13, 1548603684],
|
|
18244
|
+
[3, 15, 1548603684],
|
|
18245
|
+
[7, 7, 1548603684],
|
|
18246
|
+
[0, 12, 1548603684],
|
|
18247
|
+
[13, 8, 1548603684],
|
|
18248
|
+
[5, 9, 1548603684],
|
|
18249
|
+
[10, 11, 1548603684],
|
|
18250
|
+
[14, 7, 1548603684],
|
|
18251
|
+
[15, 7, 1548603684],
|
|
18252
|
+
[8, 12, 1548603684],
|
|
18253
|
+
[12, 7, 1548603684],
|
|
18254
|
+
[4, 6, 1548603684],
|
|
18255
|
+
[9, 15, 1548603684],
|
|
18256
|
+
[1, 13, 1548603684],
|
|
18257
|
+
[2, 11, 1548603684]
|
|
18258
|
+
],
|
|
18259
|
+
[
|
|
18260
|
+
[15, 9, 1836072691],
|
|
18261
|
+
[5, 7, 1836072691],
|
|
18262
|
+
[1, 15, 1836072691],
|
|
18263
|
+
[3, 11, 1836072691],
|
|
18264
|
+
[7, 8, 1836072691],
|
|
18265
|
+
[14, 6, 1836072691],
|
|
18266
|
+
[6, 6, 1836072691],
|
|
18267
|
+
[9, 14, 1836072691],
|
|
18268
|
+
[11, 12, 1836072691],
|
|
18269
|
+
[8, 13, 1836072691],
|
|
18270
|
+
[12, 5, 1836072691],
|
|
18271
|
+
[2, 14, 1836072691],
|
|
18272
|
+
[10, 13, 1836072691],
|
|
18273
|
+
[0, 13, 1836072691],
|
|
18274
|
+
[4, 7, 1836072691],
|
|
18275
|
+
[13, 5, 1836072691]
|
|
18276
|
+
],
|
|
18277
|
+
[
|
|
18278
|
+
[8, 15, 2053994217],
|
|
18279
|
+
[6, 5, 2053994217],
|
|
18280
|
+
[4, 8, 2053994217],
|
|
18281
|
+
[1, 11, 2053994217],
|
|
18282
|
+
[3, 14, 2053994217],
|
|
18283
|
+
[11, 14, 2053994217],
|
|
18284
|
+
[15, 6, 2053994217],
|
|
18285
|
+
[0, 14, 2053994217],
|
|
18286
|
+
[5, 6, 2053994217],
|
|
18287
|
+
[12, 9, 2053994217],
|
|
18288
|
+
[2, 12, 2053994217],
|
|
18289
|
+
[13, 9, 2053994217],
|
|
18290
|
+
[9, 12, 2053994217],
|
|
18291
|
+
[7, 5, 2053994217],
|
|
18292
|
+
[10, 15, 2053994217],
|
|
18293
|
+
[14, 8, 2053994217]
|
|
18294
|
+
],
|
|
18295
|
+
[
|
|
18296
|
+
[12, 8, 0],
|
|
18297
|
+
[15, 5, 0],
|
|
18298
|
+
[10, 12, 0],
|
|
18299
|
+
[4, 9, 0],
|
|
18300
|
+
[1, 12, 0],
|
|
18301
|
+
[5, 5, 0],
|
|
18302
|
+
[8, 14, 0],
|
|
18303
|
+
[7, 6, 0],
|
|
18304
|
+
[6, 8, 0],
|
|
18305
|
+
[2, 13, 0],
|
|
18306
|
+
[13, 6, 0],
|
|
18307
|
+
[14, 5, 0],
|
|
18308
|
+
[0, 15, 0],
|
|
18309
|
+
[3, 13, 0],
|
|
18310
|
+
[9, 11, 0],
|
|
18311
|
+
[11, 11, 0]
|
|
18312
|
+
]
|
|
18313
|
+
];
|
|
18314
|
+
var LEFT_FNS2 = [f12, f22, f32, f4, f5];
|
|
18315
|
+
var RIGHT_FNS2 = [f5, f4, f32, f22, f12];
|
|
18316
|
+
function applyLane(r, ops, f6, x, startTarget) {
|
|
18317
|
+
let target2 = startTarget;
|
|
18318
|
+
for (const [k, s, addConst] of ops) {
|
|
18319
|
+
const i1 = (target2 + 1) % 5;
|
|
18320
|
+
const i2 = (target2 + 2) % 5;
|
|
18321
|
+
const i3 = (target2 + 3) % 5;
|
|
18322
|
+
const i4 = (target2 + 4) % 5;
|
|
18323
|
+
const sum2 = r[target2] + f6(r[i1], r[i2], r[i3]) + x[k] + addConst >>> 0;
|
|
18324
|
+
const newTarget = (sum2 << s | sum2 >>> 32 - s) + r[i4] >>> 0;
|
|
18325
|
+
const c = r[i2];
|
|
18326
|
+
r[i2] = (c << 10 | c >>> 22) >>> 0;
|
|
18327
|
+
r[target2] = newTarget;
|
|
18328
|
+
target2 = (target2 + 4) % 5;
|
|
18329
|
+
}
|
|
18330
|
+
return target2;
|
|
18331
|
+
}
|
|
18332
|
+
function transform5(state, x) {
|
|
18333
|
+
const left2 = [...state];
|
|
18334
|
+
const right2 = [...state];
|
|
18335
|
+
let leftTarget = 0;
|
|
18336
|
+
let rightTarget = 0;
|
|
18337
|
+
for (let round3 = 0; round3 < 5; round3++) {
|
|
18338
|
+
leftTarget = applyLane(left2, LEFT_ROUNDS2[round3], LEFT_FNS2[round3], x, leftTarget);
|
|
18339
|
+
rightTarget = applyLane(right2, RIGHT_ROUNDS2[round3], RIGHT_FNS2[round3], x, rightTarget);
|
|
18340
|
+
}
|
|
18341
|
+
const orig = state;
|
|
18342
|
+
const newState = [
|
|
18343
|
+
add32(right2[3], left2[2], orig[1]),
|
|
18344
|
+
add32(orig[2], left2[3], right2[4]),
|
|
18345
|
+
add32(orig[3], left2[4], right2[0]),
|
|
18346
|
+
add32(orig[4], left2[0], right2[1]),
|
|
18347
|
+
add32(orig[0], left2[1], right2[2])
|
|
18348
|
+
];
|
|
18349
|
+
for (let i2 = 0; i2 < 5; i2++) {
|
|
18350
|
+
state[i2] = newState[i2];
|
|
18351
|
+
}
|
|
18352
|
+
}
|
|
18353
|
+
function ripemd160(message) {
|
|
18354
|
+
return mdStyleDigest(message, INITIAL_STATE4, transform5);
|
|
18355
|
+
}
|
|
18356
|
+
|
|
17517
18357
|
// digest/sha256.ts
|
|
17518
18358
|
var K = new Uint32Array([
|
|
17519
18359
|
1116352408,
|
|
@@ -17593,40 +18433,40 @@ var IV = [
|
|
|
17593
18433
|
];
|
|
17594
18434
|
var W = new Uint32Array(64);
|
|
17595
18435
|
var rotr = (x, n) => x >>> n | x << 32 - n;
|
|
17596
|
-
function compress(
|
|
17597
|
-
for (let
|
|
17598
|
-
for (let
|
|
17599
|
-
const a2 = W[
|
|
17600
|
-
const b2 = W[
|
|
18436
|
+
function compress(h2, view, offset2) {
|
|
18437
|
+
for (let i2 = 0; i2 < 16; i2++) W[i2] = view.getUint32(offset2 + i2 * 4);
|
|
18438
|
+
for (let i2 = 16; i2 < 64; i2++) {
|
|
18439
|
+
const a2 = W[i2 - 15];
|
|
18440
|
+
const b2 = W[i2 - 2];
|
|
17601
18441
|
const s0 = rotr(a2, 7) ^ rotr(a2, 18) ^ a2 >>> 3;
|
|
17602
18442
|
const s1 = rotr(b2, 17) ^ rotr(b2, 19) ^ b2 >>> 10;
|
|
17603
|
-
W[
|
|
18443
|
+
W[i2] = W[i2 - 16] + s0 + W[i2 - 7] + s1 >>> 0;
|
|
17604
18444
|
}
|
|
17605
|
-
let a =
|
|
17606
|
-
for (let
|
|
18445
|
+
let a = h2[0], b = h2[1], c = h2[2], d = h2[3], e = h2[4], f6 = h2[5], g2 = h2[6], k = h2[7];
|
|
18446
|
+
for (let i2 = 0; i2 < 64; i2++) {
|
|
17607
18447
|
const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
|
|
17608
|
-
const ch = e &
|
|
17609
|
-
const t1 = k + S1 + ch + K[
|
|
18448
|
+
const ch = e & f6 ^ ~e & g2;
|
|
18449
|
+
const t1 = k + S1 + ch + K[i2] + W[i2] >>> 0;
|
|
17610
18450
|
const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
|
|
17611
18451
|
const maj = a & b ^ a & c ^ b & c;
|
|
17612
18452
|
const t2 = S0 + maj >>> 0;
|
|
17613
|
-
k =
|
|
17614
|
-
|
|
17615
|
-
|
|
18453
|
+
k = g2;
|
|
18454
|
+
g2 = f6;
|
|
18455
|
+
f6 = e;
|
|
17616
18456
|
e = d + t1 >>> 0;
|
|
17617
18457
|
d = c;
|
|
17618
18458
|
c = b;
|
|
17619
18459
|
b = a;
|
|
17620
18460
|
a = t1 + t2 >>> 0;
|
|
17621
18461
|
}
|
|
17622
|
-
|
|
17623
|
-
|
|
17624
|
-
|
|
17625
|
-
|
|
17626
|
-
|
|
17627
|
-
|
|
17628
|
-
|
|
17629
|
-
|
|
18462
|
+
h2[0] = h2[0] + a >>> 0;
|
|
18463
|
+
h2[1] = h2[1] + b >>> 0;
|
|
18464
|
+
h2[2] = h2[2] + c >>> 0;
|
|
18465
|
+
h2[3] = h2[3] + d >>> 0;
|
|
18466
|
+
h2[4] = h2[4] + e >>> 0;
|
|
18467
|
+
h2[5] = h2[5] + f6 >>> 0;
|
|
18468
|
+
h2[6] = h2[6] + g2 >>> 0;
|
|
18469
|
+
h2[7] = h2[7] + k >>> 0;
|
|
17630
18470
|
}
|
|
17631
18471
|
function pad64(data) {
|
|
17632
18472
|
const padded = new Uint8Array(Math.ceil((data.length + 9) / 64) * 64);
|
|
@@ -17638,64 +18478,64 @@ function pad64(data) {
|
|
|
17638
18478
|
view.setUint32(padded.length - 4, bits >>> 0);
|
|
17639
18479
|
return view;
|
|
17640
18480
|
}
|
|
17641
|
-
function wordsOut(
|
|
17642
|
-
const out = new Uint8Array(
|
|
18481
|
+
function wordsOut(h2) {
|
|
18482
|
+
const out = new Uint8Array(h2.length * 4);
|
|
17643
18483
|
const view = new DataView(out.buffer);
|
|
17644
|
-
for (let
|
|
18484
|
+
for (let i2 = 0; i2 < h2.length; i2++) view.setUint32(i2 * 4, h2[i2]);
|
|
17645
18485
|
return out;
|
|
17646
18486
|
}
|
|
17647
18487
|
function sha256(data) {
|
|
17648
|
-
const
|
|
18488
|
+
const h2 = new Uint32Array(IV);
|
|
17649
18489
|
const view = pad64(data);
|
|
17650
|
-
for (let offset2 = 0; offset2 < view.byteLength; offset2 += 64) compress(
|
|
17651
|
-
return wordsOut(
|
|
18490
|
+
for (let offset2 = 0; offset2 < view.byteLength; offset2 += 64) compress(h2, view, offset2);
|
|
18491
|
+
return wordsOut(h2);
|
|
17652
18492
|
}
|
|
17653
18493
|
|
|
17654
18494
|
// digest/sha1.ts
|
|
17655
18495
|
var W2 = new Uint32Array(80);
|
|
17656
18496
|
var rotl = (x, n) => x << n | x >>> 32 - n;
|
|
17657
|
-
function compress2(
|
|
17658
|
-
for (let
|
|
17659
|
-
for (let
|
|
17660
|
-
let a =
|
|
17661
|
-
for (let
|
|
17662
|
-
let
|
|
18497
|
+
function compress2(h2, view, offset2) {
|
|
18498
|
+
for (let i2 = 0; i2 < 16; i2++) W2[i2] = view.getUint32(offset2 + i2 * 4);
|
|
18499
|
+
for (let i2 = 16; i2 < 80; i2++) W2[i2] = rotl(W2[i2 - 3] ^ W2[i2 - 8] ^ W2[i2 - 14] ^ W2[i2 - 16], 1);
|
|
18500
|
+
let a = h2[0], b = h2[1], c = h2[2], d = h2[3], e = h2[4];
|
|
18501
|
+
for (let i2 = 0; i2 < 80; i2++) {
|
|
18502
|
+
let f6;
|
|
17663
18503
|
let k;
|
|
17664
|
-
if (
|
|
17665
|
-
|
|
18504
|
+
if (i2 < 20) {
|
|
18505
|
+
f6 = b & c | ~b & d;
|
|
17666
18506
|
k = 1518500249;
|
|
17667
|
-
} else if (
|
|
17668
|
-
|
|
18507
|
+
} else if (i2 < 40) {
|
|
18508
|
+
f6 = b ^ c ^ d;
|
|
17669
18509
|
k = 1859775393;
|
|
17670
|
-
} else if (
|
|
17671
|
-
|
|
18510
|
+
} else if (i2 < 60) {
|
|
18511
|
+
f6 = b & c | b & d | c & d;
|
|
17672
18512
|
k = 2400959708;
|
|
17673
18513
|
} else {
|
|
17674
|
-
|
|
18514
|
+
f6 = b ^ c ^ d;
|
|
17675
18515
|
k = 3395469782;
|
|
17676
18516
|
}
|
|
17677
|
-
const t = rotl(a, 5) +
|
|
18517
|
+
const t = rotl(a, 5) + f6 + e + k + W2[i2] >>> 0;
|
|
17678
18518
|
e = d;
|
|
17679
18519
|
d = c;
|
|
17680
18520
|
c = rotl(b, 30) >>> 0;
|
|
17681
18521
|
b = a;
|
|
17682
18522
|
a = t;
|
|
17683
18523
|
}
|
|
17684
|
-
|
|
17685
|
-
|
|
17686
|
-
|
|
17687
|
-
|
|
17688
|
-
|
|
18524
|
+
h2[0] = h2[0] + a >>> 0;
|
|
18525
|
+
h2[1] = h2[1] + b >>> 0;
|
|
18526
|
+
h2[2] = h2[2] + c >>> 0;
|
|
18527
|
+
h2[3] = h2[3] + d >>> 0;
|
|
18528
|
+
h2[4] = h2[4] + e >>> 0;
|
|
17689
18529
|
}
|
|
17690
18530
|
function sha1(data) {
|
|
17691
|
-
const
|
|
18531
|
+
const h2 = new Uint32Array([1732584193, 4023233417, 2562383102, 271733878, 3285377520]);
|
|
17692
18532
|
const view = pad64(data);
|
|
17693
|
-
for (let offset2 = 0; offset2 < view.byteLength; offset2 += 64) compress2(
|
|
17694
|
-
return wordsOut(
|
|
18533
|
+
for (let offset2 = 0; offset2 < view.byteLength; offset2 += 64) compress2(h2, view, offset2);
|
|
18534
|
+
return wordsOut(h2);
|
|
17695
18535
|
}
|
|
17696
18536
|
|
|
17697
18537
|
// digest/sha512.ts
|
|
17698
|
-
var
|
|
18538
|
+
var K4 = new Uint32Array([
|
|
17699
18539
|
1116352408,
|
|
17700
18540
|
3609767458,
|
|
17701
18541
|
1899447441,
|
|
@@ -17894,35 +18734,35 @@ var IV_384 = [
|
|
|
17894
18734
|
3204075428
|
|
17895
18735
|
];
|
|
17896
18736
|
var W3 = new Uint32Array(160);
|
|
17897
|
-
function compress3(
|
|
17898
|
-
for (let
|
|
17899
|
-
const o = offset2 +
|
|
17900
|
-
W3[
|
|
17901
|
-
}
|
|
17902
|
-
for (let
|
|
17903
|
-
const xh = W3[(
|
|
17904
|
-
const xl = W3[(
|
|
18737
|
+
function compress3(h2, data, offset2) {
|
|
18738
|
+
for (let i2 = 0; i2 < 32; i2++) {
|
|
18739
|
+
const o = offset2 + i2 * 4;
|
|
18740
|
+
W3[i2] = (data[o] << 24 | data[o + 1] << 16 | data[o + 2] << 8 | data[o + 3]) >>> 0;
|
|
18741
|
+
}
|
|
18742
|
+
for (let i2 = 16; i2 < 80; i2++) {
|
|
18743
|
+
const xh = W3[(i2 - 15) * 2];
|
|
18744
|
+
const xl = W3[(i2 - 15) * 2 + 1];
|
|
17905
18745
|
const s0h = (xh >>> 1 | xl << 31) ^ (xh >>> 8 | xl << 24) ^ xh >>> 7;
|
|
17906
18746
|
const s0l = (xl >>> 1 | xh << 31) ^ (xl >>> 8 | xh << 24) ^ (xl >>> 7 | xh << 25);
|
|
17907
|
-
const yh = W3[(
|
|
17908
|
-
const yl = W3[(
|
|
18747
|
+
const yh = W3[(i2 - 2) * 2];
|
|
18748
|
+
const yl = W3[(i2 - 2) * 2 + 1];
|
|
17909
18749
|
const s1h = (yh >>> 19 | yl << 13) ^ (yl >>> 29 | yh << 3) ^ yh >>> 6;
|
|
17910
18750
|
const s1l = (yl >>> 19 | yh << 13) ^ (yh >>> 29 | yl << 3) ^ (yl >>> 6 | yh << 26);
|
|
17911
|
-
let lo = (s0l >>> 0) + (s1l >>> 0) + W3[(
|
|
17912
|
-
const hi = s0h + s1h + W3[(
|
|
18751
|
+
let lo = (s0l >>> 0) + (s1l >>> 0) + W3[(i2 - 7) * 2 + 1] + W3[(i2 - 16) * 2 + 1];
|
|
18752
|
+
const hi = s0h + s1h + W3[(i2 - 7) * 2] + W3[(i2 - 16) * 2] + Math.floor(lo / 4294967296);
|
|
17913
18753
|
lo >>>= 0;
|
|
17914
|
-
W3[
|
|
17915
|
-
W3[
|
|
18754
|
+
W3[i2 * 2] = hi >>> 0;
|
|
18755
|
+
W3[i2 * 2 + 1] = lo;
|
|
17916
18756
|
}
|
|
17917
|
-
let ah =
|
|
17918
|
-
let eh =
|
|
17919
|
-
for (let
|
|
18757
|
+
let ah = h2[0], al = h2[1], bh = h2[2], bl = h2[3], ch = h2[4], cl = h2[5], dh = h2[6], dl = h2[7];
|
|
18758
|
+
let eh = h2[8], el = h2[9], fh = h2[10], fl = h2[11], gh = h2[12], gl = h2[13], hh = h2[14], hl = h2[15];
|
|
18759
|
+
for (let i2 = 0; i2 < 80; i2++) {
|
|
17920
18760
|
const S1h = (eh >>> 14 | el << 18) ^ (eh >>> 18 | el << 14) ^ (el >>> 9 | eh << 23);
|
|
17921
18761
|
const S1l = (el >>> 14 | eh << 18) ^ (el >>> 18 | eh << 14) ^ (eh >>> 9 | el << 23);
|
|
17922
18762
|
const chh = eh & fh ^ ~eh & gh;
|
|
17923
18763
|
const chl = el & fl ^ ~el & gl;
|
|
17924
|
-
let t1l = (hl >>> 0) + (S1l >>> 0) + (chl >>> 0) +
|
|
17925
|
-
const t1h = hh + S1h + chh +
|
|
18764
|
+
let t1l = (hl >>> 0) + (S1l >>> 0) + (chl >>> 0) + K4[i2 * 2 + 1] + W3[i2 * 2 + 1];
|
|
18765
|
+
const t1h = hh + S1h + chh + K4[i2 * 2] + W3[i2 * 2] + Math.floor(t1l / 4294967296);
|
|
17926
18766
|
t1l >>>= 0;
|
|
17927
18767
|
const S0h = (ah >>> 28 | al << 4) ^ (al >>> 2 | ah << 30) ^ (al >>> 7 | ah << 25);
|
|
17928
18768
|
const S0l = (al >>> 28 | ah << 4) ^ (ah >>> 2 | al << 30) ^ (ah >>> 7 | al << 25);
|
|
@@ -17950,10 +18790,10 @@ function compress3(h, data, offset2) {
|
|
|
17950
18790
|
ah = t1h + t2h + Math.floor(nl / 4294967296) >>> 0;
|
|
17951
18791
|
al = nl >>> 0;
|
|
17952
18792
|
}
|
|
17953
|
-
const add2 = (
|
|
17954
|
-
const lo = (
|
|
17955
|
-
|
|
17956
|
-
|
|
18793
|
+
const add2 = (i2, xh, xl) => {
|
|
18794
|
+
const lo = (h2[i2 + 1] >>> 0) + (xl >>> 0);
|
|
18795
|
+
h2[i2] = h2[i2] + xh + Math.floor(lo / 4294967296) >>> 0;
|
|
18796
|
+
h2[i2 + 1] = lo >>> 0;
|
|
17957
18797
|
};
|
|
17958
18798
|
add2(0, ah, al);
|
|
17959
18799
|
add2(2, bh, bl);
|
|
@@ -17965,7 +18805,7 @@ function compress3(h, data, offset2) {
|
|
|
17965
18805
|
add2(14, hh, hl);
|
|
17966
18806
|
}
|
|
17967
18807
|
function digest64(data, iv, bytes) {
|
|
17968
|
-
const
|
|
18808
|
+
const h2 = new Uint32Array(iv);
|
|
17969
18809
|
const padded = new Uint8Array(Math.ceil((data.length + 17) / 128) * 128);
|
|
17970
18810
|
padded.set(data);
|
|
17971
18811
|
padded[data.length] = 128;
|
|
@@ -17973,44 +18813,426 @@ function digest64(data, iv, bytes) {
|
|
|
17973
18813
|
const view = new DataView(padded.buffer);
|
|
17974
18814
|
view.setUint32(padded.length - 8, Math.floor(bits / 4294967296));
|
|
17975
18815
|
view.setUint32(padded.length - 4, bits >>> 0);
|
|
17976
|
-
for (let offset2 = 0; offset2 < padded.length; offset2 += 128) compress3(
|
|
18816
|
+
for (let offset2 = 0; offset2 < padded.length; offset2 += 128) compress3(h2, padded, offset2);
|
|
17977
18817
|
const out = new Uint8Array(bytes);
|
|
17978
18818
|
const outView = new DataView(out.buffer);
|
|
17979
|
-
for (let
|
|
18819
|
+
for (let i2 = 0; i2 < bytes / 4; i2++) outView.setUint32(i2 * 4, h2[i2]);
|
|
17980
18820
|
return out;
|
|
17981
18821
|
}
|
|
17982
18822
|
var sha512 = (data) => digest64(data, IV_512, 64);
|
|
17983
18823
|
var sha384 = (data) => digest64(data, IV_384, 48);
|
|
17984
18824
|
|
|
18825
|
+
// digest/whirlpool-sbox.ts
|
|
18826
|
+
var TABLE0 = [
|
|
18827
|
+
0x18186018c07830d8n,
|
|
18828
|
+
0x23238c2305af4626n,
|
|
18829
|
+
0xc6c63fc67ef991b8n,
|
|
18830
|
+
0xe8e887e8136fcdfbn,
|
|
18831
|
+
0x878726874ca113cbn,
|
|
18832
|
+
0xb8b8dab8a9626d11n,
|
|
18833
|
+
0x0101040108050209n,
|
|
18834
|
+
0x4f4f214f426e9e0dn,
|
|
18835
|
+
0x3636d836adee6c9bn,
|
|
18836
|
+
0xa6a6a2a6590451ffn,
|
|
18837
|
+
0xd2d26fd2debdb90cn,
|
|
18838
|
+
0xf5f5f3f5fb06f70en,
|
|
18839
|
+
0x7979f979ef80f296n,
|
|
18840
|
+
0x6f6fa16f5fcede30n,
|
|
18841
|
+
0x91917e91fcef3f6dn,
|
|
18842
|
+
0x52525552aa07a4f8n,
|
|
18843
|
+
0x60609d6027fdc047n,
|
|
18844
|
+
0xbcbccabc89766535n,
|
|
18845
|
+
0x9b9b569baccd2b37n,
|
|
18846
|
+
0x8e8e028e048c018an,
|
|
18847
|
+
0xa3a3b6a371155bd2n,
|
|
18848
|
+
0x0c0c300c603c186cn,
|
|
18849
|
+
0x7b7bf17bff8af684n,
|
|
18850
|
+
0x3535d435b5e16a80n,
|
|
18851
|
+
0x1d1d741de8693af5n,
|
|
18852
|
+
0xe0e0a7e05347ddb3n,
|
|
18853
|
+
0xd7d77bd7f6acb321n,
|
|
18854
|
+
0xc2c22fc25eed999cn,
|
|
18855
|
+
0x2e2eb82e6d965c43n,
|
|
18856
|
+
0x4b4b314b627a9629n,
|
|
18857
|
+
0xfefedffea321e15dn,
|
|
18858
|
+
0x575741578216aed5n,
|
|
18859
|
+
0x15155415a8412abdn,
|
|
18860
|
+
0x7777c1779fb6eee8n,
|
|
18861
|
+
0x3737dc37a5eb6e92n,
|
|
18862
|
+
0xe5e5b3e57b56d79en,
|
|
18863
|
+
0x9f9f469f8cd92313n,
|
|
18864
|
+
0xf0f0e7f0d317fd23n,
|
|
18865
|
+
0x4a4a354a6a7f9420n,
|
|
18866
|
+
0xdada4fda9e95a944n,
|
|
18867
|
+
0x58587d58fa25b0a2n,
|
|
18868
|
+
0xc9c903c906ca8fcfn,
|
|
18869
|
+
0x2929a429558d527cn,
|
|
18870
|
+
0x0a0a280a5022145an,
|
|
18871
|
+
0xb1b1feb1e14f7f50n,
|
|
18872
|
+
0xa0a0baa0691a5dc9n,
|
|
18873
|
+
0x6b6bb16b7fdad614n,
|
|
18874
|
+
0x85852e855cab17d9n,
|
|
18875
|
+
0xbdbdcebd8173673cn,
|
|
18876
|
+
0x5d5d695dd234ba8fn,
|
|
18877
|
+
0x1010401080502090n,
|
|
18878
|
+
0xf4f4f7f4f303f507n,
|
|
18879
|
+
0xcbcb0bcb16c08bddn,
|
|
18880
|
+
0x3e3ef83eedc67cd3n,
|
|
18881
|
+
0x0505140528110a2dn,
|
|
18882
|
+
0x676781671fe6ce78n,
|
|
18883
|
+
0xe4e4b7e47353d597n,
|
|
18884
|
+
0x27279c2725bb4e02n,
|
|
18885
|
+
0x4141194132588273n,
|
|
18886
|
+
0x8b8b168b2c9d0ba7n,
|
|
18887
|
+
0xa7a7a6a7510153f6n,
|
|
18888
|
+
0x7d7de97dcf94fab2n,
|
|
18889
|
+
0x95956e95dcfb3749n,
|
|
18890
|
+
0xd8d847d88e9fad56n,
|
|
18891
|
+
0xfbfbcbfb8b30eb70n,
|
|
18892
|
+
0xeeee9fee2371c1cdn,
|
|
18893
|
+
0x7c7ced7cc791f8bbn,
|
|
18894
|
+
0x6666856617e3cc71n,
|
|
18895
|
+
0xdddd53dda68ea77bn,
|
|
18896
|
+
0x17175c17b84b2eafn,
|
|
18897
|
+
0x4747014702468e45n,
|
|
18898
|
+
0x9e9e429e84dc211an,
|
|
18899
|
+
0xcaca0fca1ec589d4n,
|
|
18900
|
+
0x2d2db42d75995a58n,
|
|
18901
|
+
0xbfbfc6bf9179632en,
|
|
18902
|
+
0x07071c07381b0e3fn,
|
|
18903
|
+
0xadad8ead012347acn,
|
|
18904
|
+
0x5a5a755aea2fb4b0n,
|
|
18905
|
+
0x838336836cb51befn,
|
|
18906
|
+
0x3333cc3385ff66b6n,
|
|
18907
|
+
0x636391633ff2c65cn,
|
|
18908
|
+
0x02020802100a0412n,
|
|
18909
|
+
0xaaaa92aa39384993n,
|
|
18910
|
+
0x7171d971afa8e2den,
|
|
18911
|
+
0xc8c807c80ecf8dc6n,
|
|
18912
|
+
0x19196419c87d32d1n,
|
|
18913
|
+
0x494939497270923bn,
|
|
18914
|
+
0xd9d943d9869aaf5fn,
|
|
18915
|
+
0xf2f2eff2c31df931n,
|
|
18916
|
+
0xe3e3abe34b48dba8n,
|
|
18917
|
+
0x5b5b715be22ab6b9n,
|
|
18918
|
+
0x88881a8834920dbcn,
|
|
18919
|
+
0x9a9a529aa4c8293en,
|
|
18920
|
+
0x262698262dbe4c0bn,
|
|
18921
|
+
0x3232c8328dfa64bfn,
|
|
18922
|
+
0xb0b0fab0e94a7d59n,
|
|
18923
|
+
0xe9e983e91b6acff2n,
|
|
18924
|
+
0x0f0f3c0f78331e77n,
|
|
18925
|
+
0xd5d573d5e6a6b733n,
|
|
18926
|
+
0x80803a8074ba1df4n,
|
|
18927
|
+
0xbebec2be997c6127n,
|
|
18928
|
+
0xcdcd13cd26de87ebn,
|
|
18929
|
+
0x3434d034bde46889n,
|
|
18930
|
+
0x48483d487a759032n,
|
|
18931
|
+
0xffffdbffab24e354n,
|
|
18932
|
+
0x7a7af57af78ff48dn,
|
|
18933
|
+
0x90907a90f4ea3d64n,
|
|
18934
|
+
0x5f5f615fc23ebe9dn,
|
|
18935
|
+
0x202080201da0403dn,
|
|
18936
|
+
0x6868bd6867d5d00fn,
|
|
18937
|
+
0x1a1a681ad07234can,
|
|
18938
|
+
0xaeae82ae192c41b7n,
|
|
18939
|
+
0xb4b4eab4c95e757dn,
|
|
18940
|
+
0x54544d549a19a8cen,
|
|
18941
|
+
0x93937693ece53b7fn,
|
|
18942
|
+
0x222288220daa442fn,
|
|
18943
|
+
0x64648d6407e9c863n,
|
|
18944
|
+
0xf1f1e3f1db12ff2an,
|
|
18945
|
+
0x7373d173bfa2e6ccn,
|
|
18946
|
+
0x12124812905a2482n,
|
|
18947
|
+
0x40401d403a5d807an,
|
|
18948
|
+
0x0808200840281048n,
|
|
18949
|
+
0xc3c32bc356e89b95n,
|
|
18950
|
+
0xecec97ec337bc5dfn,
|
|
18951
|
+
0xdbdb4bdb9690ab4dn,
|
|
18952
|
+
0xa1a1bea1611f5fc0n,
|
|
18953
|
+
0x8d8d0e8d1c830791n,
|
|
18954
|
+
0x3d3df43df5c97ac8n,
|
|
18955
|
+
0x97976697ccf1335bn,
|
|
18956
|
+
0x0000000000000000n,
|
|
18957
|
+
0xcfcf1bcf36d483f9n,
|
|
18958
|
+
0x2b2bac2b4587566en,
|
|
18959
|
+
0x7676c57697b3ece1n,
|
|
18960
|
+
0x8282328264b019e6n,
|
|
18961
|
+
0xd6d67fd6fea9b128n,
|
|
18962
|
+
0x1b1b6c1bd87736c3n,
|
|
18963
|
+
0xb5b5eeb5c15b7774n,
|
|
18964
|
+
0xafaf86af112943ben,
|
|
18965
|
+
0x6a6ab56a77dfd41dn,
|
|
18966
|
+
0x50505d50ba0da0ean,
|
|
18967
|
+
0x45450945124c8a57n,
|
|
18968
|
+
0xf3f3ebf3cb18fb38n,
|
|
18969
|
+
0x3030c0309df060adn,
|
|
18970
|
+
0xefef9bef2b74c3c4n,
|
|
18971
|
+
0x3f3ffc3fe5c37edan,
|
|
18972
|
+
0x55554955921caac7n,
|
|
18973
|
+
0xa2a2b2a2791059dbn,
|
|
18974
|
+
0xeaea8fea0365c9e9n,
|
|
18975
|
+
0x656589650fecca6an,
|
|
18976
|
+
0xbabad2bab9686903n,
|
|
18977
|
+
0x2f2fbc2f65935e4an,
|
|
18978
|
+
0xc0c027c04ee79d8en,
|
|
18979
|
+
0xdede5fdebe81a160n,
|
|
18980
|
+
0x1c1c701ce06c38fcn,
|
|
18981
|
+
0xfdfdd3fdbb2ee746n,
|
|
18982
|
+
0x4d4d294d52649a1fn,
|
|
18983
|
+
0x92927292e4e03976n,
|
|
18984
|
+
0x7575c9758fbceafan,
|
|
18985
|
+
0x06061806301e0c36n,
|
|
18986
|
+
0x8a8a128a249809aen,
|
|
18987
|
+
0xb2b2f2b2f940794bn,
|
|
18988
|
+
0xe6e6bfe66359d185n,
|
|
18989
|
+
0x0e0e380e70361c7en,
|
|
18990
|
+
0x1f1f7c1ff8633ee7n,
|
|
18991
|
+
0x6262956237f7c455n,
|
|
18992
|
+
0xd4d477d4eea3b53an,
|
|
18993
|
+
0xa8a89aa829324d81n,
|
|
18994
|
+
0x96966296c4f43152n,
|
|
18995
|
+
0xf9f9c3f99b3aef62n,
|
|
18996
|
+
0xc5c533c566f697a3n,
|
|
18997
|
+
0x2525942535b14a10n,
|
|
18998
|
+
0x59597959f220b2abn,
|
|
18999
|
+
0x84842a8454ae15d0n,
|
|
19000
|
+
0x7272d572b7a7e4c5n,
|
|
19001
|
+
0x3939e439d5dd72ecn,
|
|
19002
|
+
0x4c4c2d4c5a619816n,
|
|
19003
|
+
0x5e5e655eca3bbc94n,
|
|
19004
|
+
0x7878fd78e785f09fn,
|
|
19005
|
+
0x3838e038ddd870e5n,
|
|
19006
|
+
0x8c8c0a8c14860598n,
|
|
19007
|
+
0xd1d163d1c6b2bf17n,
|
|
19008
|
+
0xa5a5aea5410b57e4n,
|
|
19009
|
+
0xe2e2afe2434dd9a1n,
|
|
19010
|
+
0x616199612ff8c24en,
|
|
19011
|
+
0xb3b3f6b3f1457b42n,
|
|
19012
|
+
0x2121842115a54234n,
|
|
19013
|
+
0x9c9c4a9c94d62508n,
|
|
19014
|
+
0x1e1e781ef0663ceen,
|
|
19015
|
+
0x4343114322528661n,
|
|
19016
|
+
0xc7c73bc776fc93b1n,
|
|
19017
|
+
0xfcfcd7fcb32be54fn,
|
|
19018
|
+
0x0404100420140824n,
|
|
19019
|
+
0x51515951b208a2e3n,
|
|
19020
|
+
0x99995e99bcc72f25n,
|
|
19021
|
+
0x6d6da96d4fc4da22n,
|
|
19022
|
+
0x0d0d340d68391a65n,
|
|
19023
|
+
0xfafacffa8335e979n,
|
|
19024
|
+
0xdfdf5bdfb684a369n,
|
|
19025
|
+
0x7e7ee57ed79bfca9n,
|
|
19026
|
+
0x242490243db44819n,
|
|
19027
|
+
0x3b3bec3bc5d776fen,
|
|
19028
|
+
0xabab96ab313d4b9an,
|
|
19029
|
+
0xcece1fce3ed181f0n,
|
|
19030
|
+
0x1111441188552299n,
|
|
19031
|
+
0x8f8f068f0c890383n,
|
|
19032
|
+
0x4e4e254e4a6b9c04n,
|
|
19033
|
+
0xb7b7e6b7d1517366n,
|
|
19034
|
+
0xebeb8beb0b60cbe0n,
|
|
19035
|
+
0x3c3cf03cfdcc78c1n,
|
|
19036
|
+
0x81813e817cbf1ffdn,
|
|
19037
|
+
0x94946a94d4fe3540n,
|
|
19038
|
+
0xf7f7fbf7eb0cf31cn,
|
|
19039
|
+
0xb9b9deb9a1676f18n,
|
|
19040
|
+
0x13134c13985f268bn,
|
|
19041
|
+
0x2c2cb02c7d9c5851n,
|
|
19042
|
+
0xd3d36bd3d6b8bb05n,
|
|
19043
|
+
0xe7e7bbe76b5cd38cn,
|
|
19044
|
+
0x6e6ea56e57cbdc39n,
|
|
19045
|
+
0xc4c437c46ef395aan,
|
|
19046
|
+
0x03030c03180f061bn,
|
|
19047
|
+
0x565645568a13acdcn,
|
|
19048
|
+
0x44440d441a49885en,
|
|
19049
|
+
0x7f7fe17fdf9efea0n,
|
|
19050
|
+
0xa9a99ea921374f88n,
|
|
19051
|
+
0x2a2aa82a4d825467n,
|
|
19052
|
+
0xbbbbd6bbb16d6b0an,
|
|
19053
|
+
0xc1c123c146e29f87n,
|
|
19054
|
+
0x53535153a202a6f1n,
|
|
19055
|
+
0xdcdc57dcae8ba572n,
|
|
19056
|
+
0x0b0b2c0b58271653n,
|
|
19057
|
+
0x9d9d4e9d9cd32701n,
|
|
19058
|
+
0x6c6cad6c47c1d82bn,
|
|
19059
|
+
0x3131c43195f562a4n,
|
|
19060
|
+
0x7474cd7487b9e8f3n,
|
|
19061
|
+
0xf6f6fff6e309f115n,
|
|
19062
|
+
0x464605460a438c4cn,
|
|
19063
|
+
0xacac8aac092645a5n,
|
|
19064
|
+
0x89891e893c970fb5n,
|
|
19065
|
+
0x14145014a04428b4n,
|
|
19066
|
+
0xe1e1a3e15b42dfban,
|
|
19067
|
+
0x16165816b04e2ca6n,
|
|
19068
|
+
0x3a3ae83acdd274f7n,
|
|
19069
|
+
0x6969b9696fd0d206n,
|
|
19070
|
+
0x09092409482d1241n,
|
|
19071
|
+
0x7070dd70a7ade0d7n,
|
|
19072
|
+
0xb6b6e2b6d954716fn,
|
|
19073
|
+
0xd0d067d0ceb7bd1en,
|
|
19074
|
+
0xeded93ed3b7ec7d6n,
|
|
19075
|
+
0xcccc17cc2edb85e2n,
|
|
19076
|
+
0x424215422a578468n,
|
|
19077
|
+
0x98985a98b4c22d2cn,
|
|
19078
|
+
0xa4a4aaa4490e55edn,
|
|
19079
|
+
0x2828a0285d885075n,
|
|
19080
|
+
0x5c5c6d5cda31b886n,
|
|
19081
|
+
0xf8f8c7f8933fed6bn,
|
|
19082
|
+
0x8686228644a411c2n
|
|
19083
|
+
];
|
|
19084
|
+
|
|
19085
|
+
// digest/whirlpool-table.ts
|
|
19086
|
+
var WORD_MASK = (1n << 64n) - 1n;
|
|
19087
|
+
var LOW_MASK = 0xffffffffn;
|
|
19088
|
+
function rotateBytesRight(value2, bytes) {
|
|
19089
|
+
const bits = BigInt(bytes) * 8n;
|
|
19090
|
+
return (value2 >> bits | value2 << 64n - bits) & WORD_MASK;
|
|
19091
|
+
}
|
|
19092
|
+
var TABLES_HI = new Uint32Array(8 * 256);
|
|
19093
|
+
var TABLES_LO = new Uint32Array(8 * 256);
|
|
19094
|
+
for (let t = 0; t < 8; t++) {
|
|
19095
|
+
for (let x = 0; x < 256; x++) {
|
|
19096
|
+
const value2 = t === 0 ? TABLE0[x] : rotateBytesRight(TABLE0[x], t);
|
|
19097
|
+
TABLES_HI[t * 256 + x] = Number(value2 >> 32n);
|
|
19098
|
+
TABLES_LO[t * 256 + x] = Number(value2 & LOW_MASK);
|
|
19099
|
+
}
|
|
19100
|
+
}
|
|
19101
|
+
var ROUND_CONSTANTS = [
|
|
19102
|
+
0x1823c6e887b8014fn,
|
|
19103
|
+
0x36a6d2f5796f9152n,
|
|
19104
|
+
0x60bc9b8ea30c7b35n,
|
|
19105
|
+
0x1de0d7c22e4bfe57n,
|
|
19106
|
+
0x157737e59ff04adan,
|
|
19107
|
+
0x58c9290ab1a06b85n,
|
|
19108
|
+
0xbd5d10f4cb3e0567n,
|
|
19109
|
+
0xe427418ba77d95d8n,
|
|
19110
|
+
0xfbee7c66dd17479en,
|
|
19111
|
+
0xca2dbf07ad5a8333n
|
|
19112
|
+
];
|
|
19113
|
+
var ROUND_CONSTANTS_HI = Uint32Array.from(ROUND_CONSTANTS, (c) => Number(c >> 32n));
|
|
19114
|
+
var ROUND_CONSTANTS_LO = Uint32Array.from(ROUND_CONSTANTS, (c) => Number(c & LOW_MASK));
|
|
19115
|
+
|
|
19116
|
+
// digest/whirlpool.ts
|
|
19117
|
+
var TABLES_HI2 = TABLES_HI;
|
|
19118
|
+
var TABLES_LO2 = TABLES_LO;
|
|
19119
|
+
var ROUND_CONSTANTS_HI2 = ROUND_CONSTANTS_HI;
|
|
19120
|
+
var ROUND_CONSTANTS_LO2 = ROUND_CONSTANTS_LO;
|
|
19121
|
+
var BLOCK_BYTES = 64;
|
|
19122
|
+
var WORDS = 8;
|
|
19123
|
+
var ROUNDS2 = 10;
|
|
19124
|
+
var words = () => ({ hi: new Uint32Array(WORDS), lo: new Uint32Array(WORDS) });
|
|
19125
|
+
function op(src, column, out) {
|
|
19126
|
+
const { hi: h2, lo: l } = src;
|
|
19127
|
+
const b0 = h2[column] >>> 24;
|
|
19128
|
+
const b1 = h2[column + 7 & 7] >>> 16 & 255;
|
|
19129
|
+
const b2 = h2[column + 6 & 7] >>> 8 & 255;
|
|
19130
|
+
const b3 = h2[column + 5 & 7] & 255;
|
|
19131
|
+
const b4 = l[column + 4 & 7] >>> 24;
|
|
19132
|
+
const b5 = l[column + 3 & 7] >>> 16 & 255;
|
|
19133
|
+
const b6 = l[column + 2 & 7] >>> 8 & 255;
|
|
19134
|
+
const b7 = l[column + 1 & 7] & 255;
|
|
19135
|
+
out.hi[column] = TABLES_HI2[b0] ^ TABLES_HI2[256 + b1] ^ TABLES_HI2[512 + b2] ^ TABLES_HI2[768 + b3] ^ TABLES_HI2[1024 + b4] ^ TABLES_HI2[1280 + b5] ^ TABLES_HI2[1536 + b6] ^ TABLES_HI2[1792 + b7];
|
|
19136
|
+
out.lo[column] = TABLES_LO2[b0] ^ TABLES_LO2[256 + b1] ^ TABLES_LO2[512 + b2] ^ TABLES_LO2[768 + b3] ^ TABLES_LO2[1024 + b4] ^ TABLES_LO2[1280 + b5] ^ TABLES_LO2[1536 + b6] ^ TABLES_LO2[1792 + b7];
|
|
19137
|
+
}
|
|
19138
|
+
var scratch = { key: words(), state: words(), initial: words(), nextKey: words(), next: words() };
|
|
19139
|
+
function processBlock(hash, block) {
|
|
19140
|
+
const { key, state, initial, nextKey, next } = scratch;
|
|
19141
|
+
for (let i2 = 0; i2 < WORDS; i2++) {
|
|
19142
|
+
initial.hi[i2] = block.hi[i2] ^ hash.hi[i2];
|
|
19143
|
+
initial.lo[i2] = block.lo[i2] ^ hash.lo[i2];
|
|
19144
|
+
}
|
|
19145
|
+
key.hi.set(hash.hi);
|
|
19146
|
+
key.lo.set(hash.lo);
|
|
19147
|
+
state.hi.set(initial.hi);
|
|
19148
|
+
state.lo.set(initial.lo);
|
|
19149
|
+
for (let round3 = 0; round3 < ROUNDS2; round3++) {
|
|
19150
|
+
for (let j = 0; j < WORDS; j++) op(key, j, nextKey);
|
|
19151
|
+
nextKey.hi[0] = nextKey.hi[0] ^ ROUND_CONSTANTS_HI2[round3];
|
|
19152
|
+
nextKey.lo[0] = nextKey.lo[0] ^ ROUND_CONSTANTS_LO2[round3];
|
|
19153
|
+
for (let j = 0; j < WORDS; j++) {
|
|
19154
|
+
op(state, j, next);
|
|
19155
|
+
next.hi[j] = next.hi[j] ^ nextKey.hi[j];
|
|
19156
|
+
next.lo[j] = next.lo[j] ^ nextKey.lo[j];
|
|
19157
|
+
}
|
|
19158
|
+
key.hi.set(nextKey.hi);
|
|
19159
|
+
key.lo.set(nextKey.lo);
|
|
19160
|
+
state.hi.set(next.hi);
|
|
19161
|
+
state.lo.set(next.lo);
|
|
19162
|
+
}
|
|
19163
|
+
for (let i2 = 0; i2 < WORDS; i2++) {
|
|
19164
|
+
hash.hi[i2] = initial.hi[i2] ^ state.hi[i2];
|
|
19165
|
+
hash.lo[i2] = initial.lo[i2] ^ state.lo[i2];
|
|
19166
|
+
}
|
|
19167
|
+
}
|
|
19168
|
+
function pad3(message) {
|
|
19169
|
+
let total2 = message.length + 1;
|
|
19170
|
+
while (total2 % BLOCK_BYTES !== 32) {
|
|
19171
|
+
total2++;
|
|
19172
|
+
}
|
|
19173
|
+
total2 += 32;
|
|
19174
|
+
const padded = new Uint8Array(total2);
|
|
19175
|
+
padded.set(message);
|
|
19176
|
+
padded[message.length] = 128;
|
|
19177
|
+
new DataView(padded.buffer).setBigUint64(total2 - 8, BigInt(message.length) * 8n, false);
|
|
19178
|
+
return padded;
|
|
19179
|
+
}
|
|
19180
|
+
function whirlpool(message) {
|
|
19181
|
+
const padded = pad3(message);
|
|
19182
|
+
const view = new DataView(padded.buffer);
|
|
19183
|
+
const hash = words();
|
|
19184
|
+
const block = words();
|
|
19185
|
+
for (let offset2 = 0; offset2 < padded.length; offset2 += BLOCK_BYTES) {
|
|
19186
|
+
for (let i2 = 0; i2 < WORDS; i2++) {
|
|
19187
|
+
block.hi[i2] = view.getUint32(offset2 + i2 * 8, false);
|
|
19188
|
+
block.lo[i2] = view.getUint32(offset2 + i2 * 8 + 4, false);
|
|
19189
|
+
}
|
|
19190
|
+
processBlock(hash, block);
|
|
19191
|
+
}
|
|
19192
|
+
const out = new Uint8Array(BLOCK_BYTES);
|
|
19193
|
+
const outView = new DataView(out.buffer);
|
|
19194
|
+
for (let i2 = 0; i2 < WORDS; i2++) {
|
|
19195
|
+
outView.setUint32(i2 * 8, hash.hi[i2], false);
|
|
19196
|
+
outView.setUint32(i2 * 8 + 4, hash.lo[i2], false);
|
|
19197
|
+
}
|
|
19198
|
+
return out;
|
|
19199
|
+
}
|
|
19200
|
+
|
|
17985
19201
|
// digest/digest.ts
|
|
17986
19202
|
var DIGESTS = {
|
|
17987
19203
|
"SHA-1": sha1,
|
|
17988
19204
|
"SHA-256": sha256,
|
|
17989
19205
|
"SHA-384": sha384,
|
|
17990
|
-
"SHA-512": sha512
|
|
19206
|
+
"SHA-512": sha512,
|
|
19207
|
+
MD2: md2,
|
|
19208
|
+
MD4: md4,
|
|
19209
|
+
MD5: md5,
|
|
19210
|
+
"RIPEMD-128": ripemd128,
|
|
19211
|
+
"RIPEMD-160": ripemd160,
|
|
19212
|
+
WHIRLPOOL: whirlpool
|
|
17991
19213
|
};
|
|
17992
19214
|
function digestFunction(name) {
|
|
17993
19215
|
const canonical = normalizeDigestAlgorithmName(name);
|
|
17994
|
-
return canonical &&
|
|
19216
|
+
return canonical && DIGESTS[canonical];
|
|
17995
19217
|
}
|
|
17996
19218
|
|
|
17997
19219
|
// digest/password-hash.ts
|
|
17998
19220
|
var MAX_SPIN_COUNT = 1e7;
|
|
17999
19221
|
var validSpinCount = (spinCount) => spinCount === void 0 || Number.isInteger(spinCount) && spinCount >= 0 && spinCount <= MAX_SPIN_COUNT;
|
|
18000
|
-
function
|
|
19222
|
+
function spinPasswordHash(password, salt, spinCount, digest) {
|
|
18001
19223
|
const input = new Uint8Array(salt.length + password.length * 2);
|
|
18002
19224
|
input.set(salt);
|
|
18003
|
-
for (let
|
|
18004
|
-
const code = password.charCodeAt(
|
|
18005
|
-
input[salt.length +
|
|
18006
|
-
input[salt.length +
|
|
19225
|
+
for (let i2 = 0; i2 < password.length; i2++) {
|
|
19226
|
+
const code = password.charCodeAt(i2);
|
|
19227
|
+
input[salt.length + i2 * 2] = code & 255;
|
|
19228
|
+
input[salt.length + i2 * 2 + 1] = code >> 8;
|
|
18007
19229
|
}
|
|
18008
19230
|
let value2 = digest(input);
|
|
18009
19231
|
const buffer = new Uint8Array(value2.length + 4);
|
|
18010
19232
|
const view = new DataView(buffer.buffer);
|
|
18011
|
-
for (let
|
|
19233
|
+
for (let i2 = 0; i2 < spinCount; i2++) {
|
|
18012
19234
|
buffer.set(value2);
|
|
18013
|
-
view.setUint32(value2.length,
|
|
19235
|
+
view.setUint32(value2.length, i2, true);
|
|
18014
19236
|
value2 = digest(buffer);
|
|
18015
19237
|
}
|
|
18016
19238
|
return value2;
|
|
@@ -18019,7 +19241,7 @@ function hashBytes(password, { algorithmName, saltValue, spinCount }) {
|
|
|
18019
19241
|
const digest = digestFunction(algorithmName);
|
|
18020
19242
|
const salt = decodeBase64(saltValue);
|
|
18021
19243
|
if (!digest || !salt || !validSpinCount(spinCount)) return void 0;
|
|
18022
|
-
return
|
|
19244
|
+
return spinPasswordHash(password, salt, spinCount ?? 0, digest);
|
|
18023
19245
|
}
|
|
18024
19246
|
function verifyPasswordHash(password, hash) {
|
|
18025
19247
|
if (!digestFunction(hash.algorithmName)) return void 0;
|
|
@@ -18027,15 +19249,15 @@ function verifyPasswordHash(password, hash) {
|
|
|
18027
19249
|
const actual = expected && hashBytes(password, hash);
|
|
18028
19250
|
if (!expected || !actual || actual.length !== expected.length) return false;
|
|
18029
19251
|
let difference = 0;
|
|
18030
|
-
for (let
|
|
19252
|
+
for (let i2 = 0; i2 < actual.length; i2++) difference |= actual[i2] ^ expected[i2];
|
|
18031
19253
|
return difference === 0;
|
|
18032
19254
|
}
|
|
18033
19255
|
|
|
18034
19256
|
// xlsx/edit/protection.ts
|
|
18035
19257
|
function legacyPasswordHash(password) {
|
|
18036
19258
|
let hash = 0;
|
|
18037
|
-
for (let
|
|
18038
|
-
const value2 = (password.charCodeAt(
|
|
19259
|
+
for (let i2 = 0; i2 < password.length; i2++) {
|
|
19260
|
+
const value2 = (password.charCodeAt(i2) & 65535) << i2 + 1;
|
|
18039
19261
|
hash ^= value2 & 32767 | value2 >> 15;
|
|
18040
19262
|
}
|
|
18041
19263
|
hash ^= password.length;
|
|
@@ -18109,7 +19331,7 @@ var hasContent = (cell) => !!cell && !isSpilledCell(cell) && (cell.formula !== v
|
|
|
18109
19331
|
function mergeTargets(r, mode) {
|
|
18110
19332
|
return mode === "across" ? Array.from(
|
|
18111
19333
|
{ length: r.end.row - r.start.row + 1 },
|
|
18112
|
-
(_v,
|
|
19334
|
+
(_v, i2) => cellRange(r.start.row + i2, r.start.col, r.start.row + i2, r.end.col)
|
|
18113
19335
|
).filter((m) => m.start.col !== m.end.col) : [r];
|
|
18114
19336
|
}
|
|
18115
19337
|
function filledCells(sheet, target2) {
|
|
@@ -18215,10 +19437,10 @@ function fontView(font, theme2) {
|
|
|
18215
19437
|
function fillView(fill, theme2, differential = false) {
|
|
18216
19438
|
if (!fill) return void 0;
|
|
18217
19439
|
if (fill.type === "gradient") {
|
|
18218
|
-
const stops = [...fill.stops].sort((a, b) => a.position - b.position).map((stop) => `${resolveColor(stop.color, theme2, WHITE)} ${
|
|
19440
|
+
const stops = [...fill.stops].sort((a, b) => a.position - b.position).map((stop) => `${resolveColor(stop.color, theme2, WHITE)} ${round2(stop.position * 100)}%`);
|
|
18219
19441
|
if (stops.length === 0) return void 0;
|
|
18220
19442
|
if (stops.length === 1) stops.push(stops[0] ?? WHITE);
|
|
18221
|
-
const css = fill.gradient === "path" ? `radial-gradient(circle, ${stops.join(", ")})` : `linear-gradient(${
|
|
19443
|
+
const css = fill.gradient === "path" ? `radial-gradient(circle, ${stops.join(", ")})` : `linear-gradient(${round2(((fill.degree ?? 0) + 90) % 360)}deg, ${stops.join(", ")})`;
|
|
18222
19444
|
return { gradient: css };
|
|
18223
19445
|
}
|
|
18224
19446
|
if (fill.pattern === "none") {
|
|
@@ -18236,7 +19458,7 @@ function fillView(fill, theme2, differential = false) {
|
|
|
18236
19458
|
bg: resolveColor(fill.bgColor, theme2, WHITE) ?? WHITE
|
|
18237
19459
|
};
|
|
18238
19460
|
}
|
|
18239
|
-
var
|
|
19461
|
+
var round2 = (n) => Math.round(n * 100) / 100;
|
|
18240
19462
|
var BORDER_STYLES = {
|
|
18241
19463
|
hair: { widthPx: 1, style: "dotted" },
|
|
18242
19464
|
thin: { widthPx: 1, style: "solid" },
|
|
@@ -18383,7 +19605,7 @@ function cellView(workbook, sheetIndex2, row2, col, cf, options = {}) {
|
|
|
18383
19605
|
if (fill) view.fill = fill;
|
|
18384
19606
|
if (conditional?.dataBar) view.dataBar = conditional.dataBar;
|
|
18385
19607
|
if (conditional?.icon) view.icon = conditional.icon;
|
|
18386
|
-
const link = sheet.hyperlinks.find((
|
|
19608
|
+
const link = sheet.hyperlinks.find((h2) => rangeContains(h2.range, { row: row2, col }));
|
|
18387
19609
|
if (link) {
|
|
18388
19610
|
view.hasHyperlink = true;
|
|
18389
19611
|
const title = link.tooltip ?? link.target ?? link.location;
|
|
@@ -18444,10 +19666,10 @@ var AxisMetrics = class {
|
|
|
18444
19666
|
}
|
|
18445
19667
|
/** Offset of the leading edge of `index` (`index` may equal `count` for the axis end). */
|
|
18446
19668
|
start(index2) {
|
|
18447
|
-
const
|
|
18448
|
-
const k = this.rank(
|
|
19669
|
+
const i2 = Math.max(0, Math.min(index2, this.count));
|
|
19670
|
+
const k = this.rank(i2);
|
|
18449
19671
|
const before = k < this.indices.length ? this.prefix[k] ?? 0 : this.totalDelta;
|
|
18450
|
-
return
|
|
19672
|
+
return i2 * this.defaultSize + before;
|
|
18451
19673
|
}
|
|
18452
19674
|
/** Total extent of lines `0..count-1`. */
|
|
18453
19675
|
get total() {
|
|
@@ -18480,12 +19702,12 @@ var AxisMetrics = class {
|
|
|
18480
19702
|
}
|
|
18481
19703
|
/** The first line at or after `index` with a non-zero size (or `count - 1`). */
|
|
18482
19704
|
firstVisible(index2) {
|
|
18483
|
-
for (let
|
|
19705
|
+
for (let i2 = Math.max(0, index2); i2 < this.count; i2++) if (this.size(i2) > 0) return i2;
|
|
18484
19706
|
return this.count - 1;
|
|
18485
19707
|
}
|
|
18486
19708
|
/** The last line at or before `index` with a non-zero size (or 0). */
|
|
18487
19709
|
lastVisible(index2) {
|
|
18488
|
-
for (let
|
|
19710
|
+
for (let i2 = Math.min(index2, this.count - 1); i2 >= 0; i2--) if (this.size(i2) > 0) return i2;
|
|
18489
19711
|
return 0;
|
|
18490
19712
|
}
|
|
18491
19713
|
/** Largest custom-entry index, or -1. */
|
|
@@ -18581,10 +19803,10 @@ function lineHeightPoints(sizePt) {
|
|
|
18581
19803
|
if (sizePt <= first2[0]) height = first2[1] / first2[0] * sizePt;
|
|
18582
19804
|
else if (sizePt >= last[0]) height = last[1] / last[0] * sizePt;
|
|
18583
19805
|
else {
|
|
18584
|
-
let
|
|
18585
|
-
while (LINE_HEIGHTS[
|
|
18586
|
-
const [s0, h0] = LINE_HEIGHTS[
|
|
18587
|
-
const [s1, h1] = LINE_HEIGHTS[
|
|
19806
|
+
let i2 = 1;
|
|
19807
|
+
while (LINE_HEIGHTS[i2][0] < sizePt) i2++;
|
|
19808
|
+
const [s0, h0] = LINE_HEIGHTS[i2 - 1];
|
|
19809
|
+
const [s1, h1] = LINE_HEIGHTS[i2];
|
|
18588
19810
|
height = h0 + (h1 - h0) * (sizePt - s0) / (s1 - s0);
|
|
18589
19811
|
}
|
|
18590
19812
|
return Math.max(0.75, Math.ceil(height / 0.75 - 1e-9) * 0.75);
|
|
@@ -18628,7 +19850,7 @@ function autoFitRowHeight(workbook, sheetIndex2, row2, measure2) {
|
|
|
18628
19850
|
const view = cellView(workbook, sheetIndex2, row2, col);
|
|
18629
19851
|
if (!view.text) continue;
|
|
18630
19852
|
const fonts = view.rich?.length ? view.rich.map((run) => run.font) : [view.font];
|
|
18631
|
-
const sizePt = Math.max(...fonts.map((
|
|
19853
|
+
const sizePt = Math.max(...fonts.map((f6) => f6.sizePx * 3 / 4));
|
|
18632
19854
|
let lines = 1;
|
|
18633
19855
|
if (view.wrap) {
|
|
18634
19856
|
const width = metrics.colWidth(col) - COLUMN_PADDING_PX - 1 - view.indentPx;
|
|
@@ -18703,9 +19925,9 @@ function remapSheets(workbook, map) {
|
|
|
18703
19925
|
}
|
|
18704
19926
|
var visibleCount = (workbook) => workbook.sheets.filter((s) => s.state === "visible").length;
|
|
18705
19927
|
function nearestVisible(workbook, index2) {
|
|
18706
|
-
for (let
|
|
18707
|
-
if (workbook.sheets[
|
|
18708
|
-
for (let
|
|
19928
|
+
for (let i2 = index2; i2 < workbook.sheets.length; i2++)
|
|
19929
|
+
if (workbook.sheets[i2]?.state === "visible") return i2;
|
|
19930
|
+
for (let i2 = index2 - 1; i2 >= 0; i2--) if (workbook.sheets[i2]?.state === "visible") return i2;
|
|
18709
19931
|
return 0;
|
|
18710
19932
|
}
|
|
18711
19933
|
function addSheet(ctx, name, at) {
|
|
@@ -18721,7 +19943,7 @@ function addSheet(ctx, name, at) {
|
|
|
18721
19943
|
[{ kind: "workbook" }],
|
|
18722
19944
|
() => {
|
|
18723
19945
|
workbook.sheets.splice(index2, 0, createWorksheet(sheetName, nextSheetId(workbook)));
|
|
18724
|
-
remapSheets(workbook, (
|
|
19946
|
+
remapSheets(workbook, (i2) => i2 >= index2 ? i2 + 1 : i2);
|
|
18725
19947
|
workbook.activeSheet = index2;
|
|
18726
19948
|
return index2;
|
|
18727
19949
|
},
|
|
@@ -18741,7 +19963,7 @@ function deleteSheet(ctx, index2) {
|
|
|
18741
19963
|
() => {
|
|
18742
19964
|
const tables = sheet.tables.map((t) => t.name);
|
|
18743
19965
|
workbook.sheets.splice(index2, 1);
|
|
18744
|
-
remapSheets(workbook, (
|
|
19966
|
+
remapSheets(workbook, (i2) => i2 === index2 ? void 0 : i2 > index2 ? i2 - 1 : i2);
|
|
18745
19967
|
rewriteFormulas(workbook, (formula) => deleteSheetInFormula(formula, sheet.name, tables));
|
|
18746
19968
|
if (workbook.activeSheet > index2) workbook.activeSheet--;
|
|
18747
19969
|
else if (workbook.activeSheet === index2)
|
|
@@ -18783,11 +20005,11 @@ function moveSheet(ctx, from, to) {
|
|
|
18783
20005
|
"sheets",
|
|
18784
20006
|
[{ kind: "workbook" }],
|
|
18785
20007
|
() => {
|
|
18786
|
-
const order = workbook.sheets.map((_s,
|
|
20008
|
+
const order = workbook.sheets.map((_s, i2) => i2);
|
|
18787
20009
|
const [moved] = order.splice(from, 1);
|
|
18788
20010
|
if (moved === void 0) return;
|
|
18789
20011
|
order.splice(target2, 0, moved);
|
|
18790
|
-
const sheets = order.map((
|
|
20012
|
+
const sheets = order.map((i2) => workbook.sheets[i2]).filter((s) => s !== void 0);
|
|
18791
20013
|
workbook.sheets.splice(0, workbook.sheets.length, ...sheets);
|
|
18792
20014
|
const newIndex = (old) => order.indexOf(old);
|
|
18793
20015
|
remapSheets(workbook, newIndex);
|
|
@@ -18851,12 +20073,12 @@ function duplicateSheet(ctx, index2) {
|
|
|
18851
20073
|
if (renames.length)
|
|
18852
20074
|
rewriteSheetFormulas(
|
|
18853
20075
|
copy2,
|
|
18854
|
-
(formula) => renames.reduce((
|
|
20076
|
+
(formula) => renames.reduce((f6, [from, to]) => renameTableInFormula(f6, from, to), formula)
|
|
18855
20077
|
);
|
|
18856
20078
|
for (const drawing of copy2.drawings) if (drawing.kind === "chart") delete drawing.partName;
|
|
18857
20079
|
const copiedNames = namesForCopy(workbook, index2, sheet.name, copy2.name);
|
|
18858
20080
|
workbook.sheets.splice(at, 0, copy2);
|
|
18859
|
-
remapSheets(workbook, (
|
|
20081
|
+
remapSheets(workbook, (i2) => i2 >= at ? i2 + 1 : i2);
|
|
18860
20082
|
for (const n of copiedNames) workbook.definedNames.push({ ...n, localSheet: at });
|
|
18861
20083
|
workbook.activeSheet = at;
|
|
18862
20084
|
return at;
|
|
@@ -19035,18 +20257,18 @@ function withProposedValue(workbook, at, value2, fn) {
|
|
|
19035
20257
|
}
|
|
19036
20258
|
}
|
|
19037
20259
|
function check2(workbook, dv, value2, at, evaluate) {
|
|
19038
|
-
const
|
|
19039
|
-
const
|
|
20260
|
+
const f13 = dv.formula1 === void 0 ? void 0 : relativeTo(dv, dv.formula1, at);
|
|
20261
|
+
const f23 = dv.formula2 === void 0 ? void 0 : relativeTo(dv, dv.formula2, at);
|
|
19040
20262
|
if (dv.type === "list") {
|
|
19041
|
-
const items =
|
|
20263
|
+
const items = f13 === void 0 ? [] : listSource(workbook, at.sheet, f13, evaluate, at) ?? [];
|
|
19042
20264
|
return items.some((item) => listItemMatches(item, value2));
|
|
19043
20265
|
}
|
|
19044
20266
|
if (dv.type === "custom") {
|
|
19045
|
-
const result2 = withProposedValue(workbook, at, value2, () => operand3(
|
|
20267
|
+
const result2 = withProposedValue(workbook, at, value2, () => operand3(f13, evaluate, at));
|
|
19046
20268
|
return result2 === true || typeof result2 === "number" && result2 !== 0;
|
|
19047
20269
|
}
|
|
19048
|
-
const a = asNumber(operand3(
|
|
19049
|
-
const b = asNumber(operand3(
|
|
20270
|
+
const a = asNumber(operand3(f13, evaluate, at) ?? null);
|
|
20271
|
+
const b = asNumber(operand3(f23, evaluate, at) ?? null);
|
|
19050
20272
|
if (a === void 0) return true;
|
|
19051
20273
|
const operator = dv.operator ?? "between";
|
|
19052
20274
|
if (dv.type === "textLength") return compare(operator, rawText(value2).length, a, b);
|
|
@@ -19166,8 +20388,8 @@ function createEditSession(workbook, options = {}) {
|
|
|
19166
20388
|
emit(change);
|
|
19167
20389
|
};
|
|
19168
20390
|
const rollback = (current, from) => {
|
|
19169
|
-
for (let
|
|
19170
|
-
const entry = current.step.entries[
|
|
20391
|
+
for (let i2 = current.step.entries.length - 1; i2 >= from; i2--) {
|
|
20392
|
+
const entry = current.step.entries[i2];
|
|
19171
20393
|
if (entry) restoreSnapshot(workbook, entry.before);
|
|
19172
20394
|
}
|
|
19173
20395
|
current.step.entries.length = from;
|
|
@@ -19187,16 +20409,16 @@ function createEditSession(workbook, options = {}) {
|
|
|
19187
20409
|
try {
|
|
19188
20410
|
result2 = fn();
|
|
19189
20411
|
} catch (error) {
|
|
19190
|
-
for (let
|
|
19191
|
-
const snapshot = befores[
|
|
20412
|
+
for (let i2 = befores.length - 1; i2 >= 0; i2--) {
|
|
20413
|
+
const snapshot = befores[i2];
|
|
19192
20414
|
if (snapshot) restoreSnapshot(workbook, snapshot);
|
|
19193
20415
|
}
|
|
19194
20416
|
current.step.entries.length = mark;
|
|
19195
20417
|
if (outer) open = void 0;
|
|
19196
20418
|
throw error;
|
|
19197
20419
|
}
|
|
19198
|
-
scopes.forEach((scope,
|
|
19199
|
-
const before = befores[
|
|
20420
|
+
scopes.forEach((scope, i2) => {
|
|
20421
|
+
const before = befores[i2];
|
|
19200
20422
|
if (before)
|
|
19201
20423
|
current.step.entries.push({ before, after: captureScope(workbook, scope, before) });
|
|
19202
20424
|
});
|
|
@@ -19260,12 +20482,12 @@ function createEditSession(workbook, options = {}) {
|
|
|
19260
20482
|
replaceAll: (query, replacement) => replaceAll(ctx, query, replacement),
|
|
19261
20483
|
replaceOne: (query, replacement, at) => replaceOne(ctx, query, replacement, at),
|
|
19262
20484
|
addSheet: (name, at) => addSheet(ctx, name, at),
|
|
19263
|
-
deleteSheet: (
|
|
19264
|
-
renameSheet: (
|
|
20485
|
+
deleteSheet: (i2) => deleteSheet(ctx, i2),
|
|
20486
|
+
renameSheet: (i2, name) => renameSheet(ctx, i2, name),
|
|
19265
20487
|
moveSheet: (from, to) => moveSheet(ctx, from, to),
|
|
19266
|
-
duplicateSheet: (
|
|
19267
|
-
setSheetState: (
|
|
19268
|
-
setTabColor: (
|
|
20488
|
+
duplicateSheet: (i2) => duplicateSheet(ctx, i2),
|
|
20489
|
+
setSheetState: (i2, state) => setSheetState(ctx, i2, state),
|
|
20490
|
+
setTabColor: (i2, color) => setTabColor(ctx, i2, color),
|
|
19269
20491
|
setFreeze: (s, freeze) => setFreeze(ctx, s, freeze),
|
|
19270
20492
|
setComment: (s, at, text, author) => setComment(ctx, s, at, text, author),
|
|
19271
20493
|
setHyperlink: (s, range2, link) => setHyperlink(ctx, s, range2, link),
|
|
@@ -19286,8 +20508,8 @@ function createEditSession(workbook, options = {}) {
|
|
|
19286
20508
|
addImage: (s, bytes, type, anchor, name) => addImage(ctx, s, bytes, type, anchor, name),
|
|
19287
20509
|
replaceConditionalFormat: (s, index2, cf) => replaceConditionalFormat(ctx, s, index2, cf),
|
|
19288
20510
|
removeConditionalFormat: (s, index2) => removeConditionalFormat(ctx, s, index2),
|
|
19289
|
-
setConditionalRulePriority: (s,
|
|
19290
|
-
moveConditionalRule: (s,
|
|
20511
|
+
setConditionalRulePriority: (s, f6, r, priority) => setConditionalRulePriority(ctx, s, f6, r, priority),
|
|
20512
|
+
moveConditionalRule: (s, f6, r, direction) => moveConditionalRule(ctx, s, f6, r, direction),
|
|
19291
20513
|
updateTable: (s, table2, patch) => updateTable(ctx, s, table2, patch),
|
|
19292
20514
|
resizeTable: (s, table2, range2) => resizeTable(ctx, s, table2, range2),
|
|
19293
20515
|
convertTableToRange: (s, table2) => convertTableToRange(ctx, s, table2),
|
|
@@ -19375,9 +20597,9 @@ function mergeDxf(acc, next) {
|
|
|
19375
20597
|
}
|
|
19376
20598
|
function iconIndex(value2, cuts, list) {
|
|
19377
20599
|
let index2 = 0;
|
|
19378
|
-
for (let
|
|
19379
|
-
const cut = cuts[
|
|
19380
|
-
if (list[
|
|
20600
|
+
for (let i2 = 1; i2 < cuts.length; i2++) {
|
|
20601
|
+
const cut = cuts[i2] ?? Infinity;
|
|
20602
|
+
if (list[i2]?.gte === false ? value2 > cut : value2 >= cut) index2 = i2;
|
|
19381
20603
|
}
|
|
19382
20604
|
return index2;
|
|
19383
20605
|
}
|
|
@@ -19386,12 +20608,12 @@ function scaleColor(value2, cuts, colors) {
|
|
|
19386
20608
|
if (value2 <= (cuts[0] ?? 0)) return colors[0];
|
|
19387
20609
|
const last = cuts.length - 1;
|
|
19388
20610
|
if (value2 >= (cuts[last] ?? 0)) return colors[last];
|
|
19389
|
-
for (let
|
|
19390
|
-
const lo = cuts[
|
|
19391
|
-
const hi = cuts[
|
|
20611
|
+
for (let i2 = 0; i2 < last; i2++) {
|
|
20612
|
+
const lo = cuts[i2] ?? 0;
|
|
20613
|
+
const hi = cuts[i2 + 1] ?? 0;
|
|
19392
20614
|
if (value2 >= lo && value2 <= hi) {
|
|
19393
|
-
const a = colors[
|
|
19394
|
-
const b = colors[
|
|
20615
|
+
const a = colors[i2] ?? "#FFFFFF";
|
|
20616
|
+
const b = colors[i2 + 1] ?? a;
|
|
19395
20617
|
return hi > lo ? mixColors(a, b, (value2 - lo) / (hi - lo), "towardStart") : b;
|
|
19396
20618
|
}
|
|
19397
20619
|
}
|
|
@@ -19443,27 +20665,27 @@ function dataBarGeometry(value2, low, high, options) {
|
|
|
19443
20665
|
const clamp = (v) => Math.max(0, Math.min(1, v));
|
|
19444
20666
|
const minimum = options.minLength;
|
|
19445
20667
|
const delta = options.maxLength - minimum;
|
|
19446
|
-
const
|
|
20668
|
+
const interpolate2 = (ratio, offset2 = minimum) => clamp(offset2 + clamp(ratio) * delta);
|
|
19447
20669
|
if (options.axis === "none") {
|
|
19448
20670
|
const ratio = hi > lo ? clamp((value2 - lo) / (hi - lo)) : 0.5;
|
|
19449
20671
|
return {
|
|
19450
20672
|
start: 0,
|
|
19451
|
-
fraction:
|
|
20673
|
+
fraction: interpolate2(ratio),
|
|
19452
20674
|
reverse: false
|
|
19453
20675
|
};
|
|
19454
20676
|
}
|
|
19455
20677
|
if (options.axis === "middle") {
|
|
19456
20678
|
const span4 = Math.max(Math.abs(lo), Math.abs(hi));
|
|
19457
|
-
const fraction2 =
|
|
20679
|
+
const fraction2 = interpolate2(span4 > 0 ? Math.abs(value2) / span4 : 0) / 2;
|
|
19458
20680
|
return { start: value2 < 0 ? 0.5 - fraction2 : 0.5, fraction: fraction2, axis: 0.5, reverse: value2 < 0 };
|
|
19459
20681
|
}
|
|
19460
20682
|
if (lo === 0 && hi === 0) return { start: 0.5, fraction: minimum / 2, axis: 0.5, reverse: false };
|
|
19461
20683
|
if (lo >= 0) {
|
|
19462
|
-
const fraction2 = hi > lo ?
|
|
20684
|
+
const fraction2 = hi > lo ? interpolate2((value2 - lo) / (hi - lo), lo === 0 ? minimum / 2 : minimum) : interpolate2(0.5);
|
|
19463
20685
|
return { start: 0, fraction: fraction2, reverse: false };
|
|
19464
20686
|
}
|
|
19465
20687
|
if (hi <= 0) {
|
|
19466
|
-
const fraction2 = hi > lo ?
|
|
20688
|
+
const fraction2 = hi > lo ? interpolate2((hi - value2) / (hi - lo), hi === 0 ? minimum / 2 : minimum) : interpolate2(0.5);
|
|
19467
20689
|
const axis2 = hi === 0 ? (1 + options.maxLength - minimum) / 2 : options.maxLength;
|
|
19468
20690
|
return {
|
|
19469
20691
|
start: axis2 - fraction2,
|
|
@@ -19474,7 +20696,7 @@ function dataBarGeometry(value2, low, high, options) {
|
|
|
19474
20696
|
}
|
|
19475
20697
|
const axis = (1 - options.maxLength + minimum) / 2 + -lo / (hi - lo) * delta;
|
|
19476
20698
|
const bounded = Math.max(lo, Math.min(hi, value2));
|
|
19477
|
-
const fraction =
|
|
20699
|
+
const fraction = interpolate2(Math.abs(bounded) / (hi - lo), minimum / 2);
|
|
19478
20700
|
return { start: bounded < 0 ? axis - fraction : axis, fraction, axis, reverse: bounded < 0 };
|
|
19479
20701
|
}
|
|
19480
20702
|
|
|
@@ -19819,7 +21041,7 @@ function overflowExtent(sheet, metrics, row2, col, textWidth, hAlign, maxSpan =
|
|
|
19819
21041
|
const extend = (need, step) => {
|
|
19820
21042
|
let gained = 0;
|
|
19821
21043
|
let c = col;
|
|
19822
|
-
for (let
|
|
21044
|
+
for (let i2 = 0; i2 < maxSpan && gained < need; i2++) {
|
|
19823
21045
|
const next = c + step;
|
|
19824
21046
|
if (next < 0 || next > MAX_COL || !isOverflowTarget(sheet, row2, next)) break;
|
|
19825
21047
|
c = next;
|
|
@@ -20180,7 +21402,7 @@ var wholeColumns = (r) => r.start.row === 0 && r.end.row >= MAX_ROW;
|
|
|
20180
21402
|
var wholeRows = (r) => r.start.col === 0 && r.end.col >= MAX_COL;
|
|
20181
21403
|
function span3(from, to) {
|
|
20182
21404
|
const out = [];
|
|
20183
|
-
for (let
|
|
21405
|
+
for (let i2 = Math.min(from, to); i2 <= Math.max(from, to); i2++) out.push(i2);
|
|
20184
21406
|
return out;
|
|
20185
21407
|
}
|
|
20186
21408
|
function rowsOf(ranges) {
|
|
@@ -20562,12 +21784,12 @@ function alignmentCommands() {
|
|
|
20562
21784
|
run: (ctx) => {
|
|
20563
21785
|
const current = activeStyle(ctx)?.alignment?.indent ?? 0;
|
|
20564
21786
|
const next = Math.max(0, Math.min(250, current + delta));
|
|
20565
|
-
const
|
|
20566
|
-
const keep =
|
|
21787
|
+
const h2 = horizontal(ctx);
|
|
21788
|
+
const keep = h2 === "right" || h2 === "distributed" || h2 === "left";
|
|
20567
21789
|
style(ctx, {
|
|
20568
21790
|
alignment: {
|
|
20569
21791
|
indent: next || UNSET,
|
|
20570
|
-
horizontal: next ? keep ?
|
|
21792
|
+
horizontal: next ? keep ? h2 : "left" : h2 === "general" ? UNSET : h2
|
|
20571
21793
|
}
|
|
20572
21794
|
});
|
|
20573
21795
|
}
|
|
@@ -20593,8 +21815,24 @@ function alignmentCommands() {
|
|
|
20593
21815
|
];
|
|
20594
21816
|
}
|
|
20595
21817
|
|
|
20596
|
-
//
|
|
20597
|
-
|
|
21818
|
+
// i18n/locale.ts
|
|
21819
|
+
var DEFAULT_REJECTED_SUBTAGS = ["hant", "tw", "hk", "mo"];
|
|
21820
|
+
function normalizeLocale(input, supported, fallback, options = {}) {
|
|
21821
|
+
const parts = (input ?? "").trim().toLowerCase().split(/[-_]/).filter(Boolean);
|
|
21822
|
+
const language = parts[0];
|
|
21823
|
+
if (!language) return fallback;
|
|
21824
|
+
const find2 = (tag) => supported.find((item) => item.toLowerCase() === tag);
|
|
21825
|
+
const exact = find2(parts.join("-"));
|
|
21826
|
+
if (exact) return exact;
|
|
21827
|
+
const base = find2(language);
|
|
21828
|
+
if (base) return base;
|
|
21829
|
+
const rejected = options.rejectedSubtags ?? DEFAULT_REJECTED_SUBTAGS;
|
|
21830
|
+
if (parts.slice(1).some((part) => rejected.includes(part))) return fallback;
|
|
21831
|
+
return supported.find((item) => item.toLowerCase().split("-")[0] === language && item.includes("-")) ?? fallback;
|
|
21832
|
+
}
|
|
21833
|
+
|
|
21834
|
+
// i18n/dictionary.ts
|
|
21835
|
+
function mergeMessageModules(modules) {
|
|
20598
21836
|
const merged = {};
|
|
20599
21837
|
for (const path of Object.keys(modules).sort()) {
|
|
20600
21838
|
const module = modules[path];
|
|
@@ -20609,6 +21847,29 @@ function mergeStringModules(modules) {
|
|
|
20609
21847
|
return merged;
|
|
20610
21848
|
}
|
|
20611
21849
|
|
|
21850
|
+
// i18n/translator.ts
|
|
21851
|
+
var SINGLE = /\{(\w+)\}/g;
|
|
21852
|
+
var DOUBLE = /\{\{\s*(\w+)\s*\}\}/g;
|
|
21853
|
+
function interpolate(template, params, placeholder = "single") {
|
|
21854
|
+
if (!params) return template;
|
|
21855
|
+
const pattern = placeholder === "double" ? DOUBLE : SINGLE;
|
|
21856
|
+
return template.replace(
|
|
21857
|
+
pattern,
|
|
21858
|
+
(match2, name) => Object.prototype.hasOwnProperty.call(params, name) && params[name] !== void 0 ? String(params[name]) : match2
|
|
21859
|
+
);
|
|
21860
|
+
}
|
|
21861
|
+
function createTranslator(messages, fallbacks = [], options = {}) {
|
|
21862
|
+
const placeholder = options.placeholder ?? "single";
|
|
21863
|
+
return (key, params) => {
|
|
21864
|
+
let text = messages?.[key];
|
|
21865
|
+
for (let i2 = 0; text === void 0 && i2 < fallbacks.length; i2++) text = fallbacks[i2]?.[key];
|
|
21866
|
+
return interpolate(text ?? options.missing?.(key) ?? key, params, placeholder);
|
|
21867
|
+
};
|
|
21868
|
+
}
|
|
21869
|
+
|
|
21870
|
+
// xlsx/ui/locales/merge.ts
|
|
21871
|
+
var mergeStringModules = mergeMessageModules;
|
|
21872
|
+
|
|
20612
21873
|
// xlsx/ui/locales/de/commands.ts
|
|
20613
21874
|
var commands_exports = {};
|
|
20614
21875
|
__export(commands_exports, {
|
|
@@ -26229,28 +27490,13 @@ var STRINGS = {
|
|
|
26229
27490
|
"zh-CN": zhCN
|
|
26230
27491
|
};
|
|
26231
27492
|
function normalizeEditorLocale(value2) {
|
|
26232
|
-
|
|
26233
|
-
switch (parts[0]) {
|
|
26234
|
-
case "fr":
|
|
26235
|
-
case "de":
|
|
26236
|
-
case "es":
|
|
26237
|
-
return parts[0];
|
|
26238
|
-
case "zh":
|
|
26239
|
-
return parts.some((part) => ["hant", "tw", "hk", "mo"].includes(part)) ? "en" : "zh-CN";
|
|
26240
|
-
default:
|
|
26241
|
-
return "en";
|
|
26242
|
-
}
|
|
27493
|
+
return normalizeLocale(value2, EDITOR_LOCALES, "en");
|
|
26243
27494
|
}
|
|
26244
27495
|
function fillTemplate(text, vars) {
|
|
26245
|
-
|
|
26246
|
-
return text.replace(
|
|
26247
|
-
/\{(\w+)\}/g,
|
|
26248
|
-
(match2, name) => name in vars ? String(vars[name]) : match2
|
|
26249
|
-
);
|
|
27496
|
+
return interpolate(text, vars);
|
|
26250
27497
|
}
|
|
26251
27498
|
function translate(locale, key, vars) {
|
|
26252
|
-
|
|
26253
|
-
return fillTemplate(text, vars);
|
|
27499
|
+
return createTranslator(STRINGS[locale], [STRINGS.en])(key, vars);
|
|
26254
27500
|
}
|
|
26255
27501
|
function translator(locale) {
|
|
26256
27502
|
return (key, vars) => translate(locale(), key, vars);
|
|
@@ -26403,7 +27649,7 @@ function cellCommands() {
|
|
|
26403
27649
|
const index2 = ctx.activeSheet();
|
|
26404
27650
|
session.deleteSheet(index2);
|
|
26405
27651
|
const next = session.workbook.sheets.findIndex(
|
|
26406
|
-
(s,
|
|
27652
|
+
(s, i2) => i2 >= Math.min(index2, session.workbook.sheets.length - 1) && s.state === "visible"
|
|
26407
27653
|
);
|
|
26408
27654
|
ctx.setActiveSheet(next >= 0 ? next : 0);
|
|
26409
27655
|
}
|
|
@@ -26629,9 +27875,9 @@ var ICON_SETS = [
|
|
|
26629
27875
|
];
|
|
26630
27876
|
var iconCount = (set) => Number(/^\d/.exec(set)?.[0] ?? 3);
|
|
26631
27877
|
function iconThresholds(count2) {
|
|
26632
|
-
return Array.from({ length: count2 }, (_v,
|
|
27878
|
+
return Array.from({ length: count2 }, (_v, i2) => ({
|
|
26633
27879
|
type: "percent",
|
|
26634
|
-
value: String(Math.round(
|
|
27880
|
+
value: String(Math.round(i2 * 100 / count2))
|
|
26635
27881
|
}));
|
|
26636
27882
|
}
|
|
26637
27883
|
function dataBarRule(hex2) {
|
|
@@ -27221,7 +28467,7 @@ function autoSum(ctx, fn) {
|
|
|
27221
28467
|
}
|
|
27222
28468
|
t.session.batch("AutoSum", () => {
|
|
27223
28469
|
const lastEmpty = [...Array(r.end.col - r.start.col + 1).keys()].every(
|
|
27224
|
-
(
|
|
28470
|
+
(i2) => getCell(t.ws, r.end.row, r.start.col + i2)?.value == null
|
|
27225
28471
|
);
|
|
27226
28472
|
const row2 = lastEmpty ? r.end.row : r.end.row + 1;
|
|
27227
28473
|
const bottom = lastEmpty ? r.end.row - 1 : r.end.row;
|
|
@@ -27414,7 +28660,7 @@ var FUNCTION_MENUS = [
|
|
|
27414
28660
|
["Math & Trig", "Math & Trig", "math"]
|
|
27415
28661
|
];
|
|
27416
28662
|
var MORE_FUNCTION_CATEGORIES = ["Statistical", "Engineering", "Information"];
|
|
27417
|
-
var functionsIn = (category) => FUNCTION_CATALOG.filter((
|
|
28663
|
+
var functionsIn = (category) => FUNCTION_CATALOG.filter((f6) => f6.category === category);
|
|
27418
28664
|
var recent = [
|
|
27419
28665
|
"SUM",
|
|
27420
28666
|
"AVERAGE",
|
|
@@ -27427,10 +28673,10 @@ var recent = [
|
|
|
27427
28673
|
"PMT",
|
|
27428
28674
|
"STDEV"
|
|
27429
28675
|
];
|
|
27430
|
-
var recentFunctions = () => recent.filter((name) => FUNCTION_CATALOG.some((
|
|
28676
|
+
var recentFunctions = () => recent.filter((name) => FUNCTION_CATALOG.some((f6) => f6.name === name));
|
|
27431
28677
|
function noteFunctionUse(name) {
|
|
27432
|
-
const
|
|
27433
|
-
if (
|
|
28678
|
+
const i2 = recent.indexOf(name);
|
|
28679
|
+
if (i2 >= 0) recent.splice(i2, 1);
|
|
27434
28680
|
recent.unshift(name);
|
|
27435
28681
|
recent.length = Math.min(recent.length, 10);
|
|
27436
28682
|
}
|
|
@@ -27469,7 +28715,7 @@ function formulaCommands() {
|
|
|
27469
28715
|
icon: icon("function"),
|
|
27470
28716
|
lock: false,
|
|
27471
28717
|
run: (ctx, arg) => {
|
|
27472
|
-
if (typeof arg === "string" && FUNCTION_CATALOG.some((
|
|
28718
|
+
if (typeof arg === "string" && FUNCTION_CATALOG.some((f6) => f6.name === arg))
|
|
27473
28719
|
insertFunctionCall(ctx, arg);
|
|
27474
28720
|
}
|
|
27475
28721
|
}),
|
|
@@ -27833,20 +29079,20 @@ function pageLayoutCommands() {
|
|
|
27833
29079
|
|
|
27834
29080
|
// xlsx/ui/commands/style-presets.ts
|
|
27835
29081
|
var TABLE_STYLES = [
|
|
27836
|
-
...Array.from({ length: 21 }, (_v,
|
|
27837
|
-
name: `TableStyleLight${
|
|
29082
|
+
...Array.from({ length: 21 }, (_v, i2) => ({
|
|
29083
|
+
name: `TableStyleLight${i2 + 1}`,
|
|
27838
29084
|
family: "Light",
|
|
27839
|
-
index:
|
|
29085
|
+
index: i2 + 1
|
|
27840
29086
|
})),
|
|
27841
|
-
...Array.from({ length: 28 }, (_v,
|
|
27842
|
-
name: `TableStyleMedium${
|
|
29087
|
+
...Array.from({ length: 28 }, (_v, i2) => ({
|
|
29088
|
+
name: `TableStyleMedium${i2 + 1}`,
|
|
27843
29089
|
family: "Medium",
|
|
27844
|
-
index:
|
|
29090
|
+
index: i2 + 1
|
|
27845
29091
|
})),
|
|
27846
|
-
...Array.from({ length: 11 }, (_v,
|
|
27847
|
-
name: `TableStyleDark${
|
|
29092
|
+
...Array.from({ length: 11 }, (_v, i2) => ({
|
|
29093
|
+
name: `TableStyleDark${i2 + 1}`,
|
|
27848
29094
|
family: "Dark",
|
|
27849
|
-
index:
|
|
29095
|
+
index: i2 + 1
|
|
27850
29096
|
}))
|
|
27851
29097
|
];
|
|
27852
29098
|
function tableStyleColor(info, theme2) {
|
|
@@ -28209,8 +29455,8 @@ function buildChart(workbook, sheetIndex2, range2, type, options = {}) {
|
|
|
28209
29455
|
return out;
|
|
28210
29456
|
};
|
|
28211
29457
|
const count2 = byRows ? r.end.row - dataRow0 + 1 : r.end.col - dataCol0 + 1;
|
|
28212
|
-
for (let
|
|
28213
|
-
const fixed2 = byRows ? dataRow0 +
|
|
29458
|
+
for (let i2 = 0; i2 < count2; i2++) {
|
|
29459
|
+
const fixed2 = byRows ? dataRow0 + i2 : dataCol0 + i2;
|
|
28214
29460
|
const values2 = byRows ? lane(fixed2, dataCol0, r.end.col, true) : lane(fixed2, dataRow0, r.end.row, false);
|
|
28215
29461
|
const s = {
|
|
28216
29462
|
valuesRef: prefix + absolute(values2),
|
|
@@ -28383,16 +29629,16 @@ function fillPaint(fill) {
|
|
|
28383
29629
|
}
|
|
28384
29630
|
var edgeCss = (edge) => edge ? `${edge.style === "double" ? Math.max(3, edge.widthPx) : edge.widthPx}px ${edge.style} ${edge.color}` : "";
|
|
28385
29631
|
var hasBorders = (b) => Boolean(b.top || b.right || b.bottom || b.left || b.diagonalUp || b.diagonalDown);
|
|
28386
|
-
function diagonalSvg(b, w,
|
|
29632
|
+
function diagonalSvg(b, w, h2) {
|
|
28387
29633
|
if (!b.diagonalUp && !b.diagonalDown) return void 0;
|
|
28388
29634
|
const line2 = (edge, x1, y1, x2, y2) => {
|
|
28389
29635
|
const dash = edge.style === "dashed" ? ' stroke-dasharray="4 2"' : edge.style === "dotted" ? ' stroke-dasharray="1 2"' : "";
|
|
28390
29636
|
return `<line x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" stroke="${edge.color.replace(/[^#\w(),.%\s-]/gu, "")}" stroke-width="${Number(edge.widthPx)}"${dash}/>`;
|
|
28391
29637
|
};
|
|
28392
29638
|
let body2 = "";
|
|
28393
|
-
if (b.diagonalDown) body2 += line2(b.diagonalDown, 0, 0, w,
|
|
28394
|
-
if (b.diagonalUp) body2 += line2(b.diagonalUp, 0,
|
|
28395
|
-
return `<svg xmlns="http://www.w3.org/2000/svg" width="${Number(w)}" height="${Number(
|
|
29639
|
+
if (b.diagonalDown) body2 += line2(b.diagonalDown, 0, 0, w, h2);
|
|
29640
|
+
if (b.diagonalUp) body2 += line2(b.diagonalUp, 0, h2, w, 0);
|
|
29641
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${Number(w)}" height="${Number(h2)}" viewBox="0 0 ${Number(w)} ${Number(h2)}">${body2}</svg>`;
|
|
28396
29642
|
}
|
|
28397
29643
|
function justify(hAlign) {
|
|
28398
29644
|
if (hAlign === "right") return "flex-end";
|
|
@@ -28442,7 +29688,7 @@ function makeItem(input, row2, col, view, merge2) {
|
|
|
28442
29688
|
const x = metrics.colLeft(col);
|
|
28443
29689
|
const y = metrics.rowTop(row2);
|
|
28444
29690
|
const w = merge2 ? metrics.colLeft(merge2.end.col + 1) - x : metrics.colWidth(col);
|
|
28445
|
-
const
|
|
29691
|
+
const h2 = merge2 ? metrics.rowTop(merge2.end.row + 1) - y : metrics.rowHeight(row2);
|
|
28446
29692
|
const item = {
|
|
28447
29693
|
key: `${row2}:${col}`,
|
|
28448
29694
|
row: row2,
|
|
@@ -28450,7 +29696,7 @@ function makeItem(input, row2, col, view, merge2) {
|
|
|
28450
29696
|
x,
|
|
28451
29697
|
y,
|
|
28452
29698
|
w,
|
|
28453
|
-
h,
|
|
29699
|
+
h: h2,
|
|
28454
29700
|
view,
|
|
28455
29701
|
text: view.text,
|
|
28456
29702
|
textLeft: 0,
|
|
@@ -28701,8 +29947,8 @@ var GridGeometry = class {
|
|
|
28701
29947
|
const x = this.colX(range2.start.col);
|
|
28702
29948
|
const y = this.rowY(range2.start.row);
|
|
28703
29949
|
const w = this.metrics.colLeft(range2.end.col + 1) - this.metrics.colLeft(range2.start.col);
|
|
28704
|
-
const
|
|
28705
|
-
return { x, y, w, h };
|
|
29950
|
+
const h2 = this.metrics.rowTop(range2.end.row + 1) - this.metrics.rowTop(range2.start.row);
|
|
29951
|
+
return { x, y, w, h: h2 };
|
|
28706
29952
|
}
|
|
28707
29953
|
/** Column under a view x (clamped into the cell area). */
|
|
28708
29954
|
colAtX(x) {
|
|
@@ -28759,22 +30005,22 @@ function rowHeaderWidth(lastRow, zoom) {
|
|
|
28759
30005
|
return Math.round((Math.max(2, digits2) * 7 + 12) * (zoom / 100));
|
|
28760
30006
|
}
|
|
28761
30007
|
var columnHeaderHeight = (zoom) => Math.round(20 * (zoom / 100));
|
|
28762
|
-
function scrollToReveal(
|
|
28763
|
-
let { scrollLeft: left2, scrollTop: top } =
|
|
28764
|
-
const m =
|
|
28765
|
-
if (col >=
|
|
28766
|
-
const x = m.colLeft(col) -
|
|
30008
|
+
function scrollToReveal(g2, row2, col) {
|
|
30009
|
+
let { scrollLeft: left2, scrollTop: top } = g2;
|
|
30010
|
+
const m = g2.metrics;
|
|
30011
|
+
if (col >= g2.fCols) {
|
|
30012
|
+
const x = m.colLeft(col) - g2.frozenW;
|
|
28767
30013
|
const w = m.colWidth(col);
|
|
28768
|
-
const viewW = Math.max(0,
|
|
30014
|
+
const viewW = Math.max(0, g2.cellsW - g2.frozenW);
|
|
28769
30015
|
if (x < left2) left2 = x;
|
|
28770
30016
|
else if (x + w > left2 + viewW) left2 = Math.min(x, x + w - viewW);
|
|
28771
30017
|
}
|
|
28772
|
-
if (row2 >=
|
|
28773
|
-
const y = m.rowTop(row2) -
|
|
28774
|
-
const
|
|
28775
|
-
const viewH = Math.max(0,
|
|
30018
|
+
if (row2 >= g2.fRows) {
|
|
30019
|
+
const y = m.rowTop(row2) - g2.frozenH;
|
|
30020
|
+
const h2 = m.rowHeight(row2);
|
|
30021
|
+
const viewH = Math.max(0, g2.cellsH - g2.frozenH);
|
|
28776
30022
|
if (y < top) top = y;
|
|
28777
|
-
else if (y +
|
|
30023
|
+
else if (y + h2 > top + viewH) top = Math.min(y, y + h2 - viewH);
|
|
28778
30024
|
}
|
|
28779
30025
|
return { left: Math.max(0, left2), top: Math.max(0, top) };
|
|
28780
30026
|
}
|
|
@@ -28802,9 +30048,9 @@ var star = (fill) => {
|
|
|
28802
30048
|
};
|
|
28803
30049
|
var bars = (filled, total2) => {
|
|
28804
30050
|
let out = "";
|
|
28805
|
-
for (let
|
|
28806
|
-
const
|
|
28807
|
-
out += `<rect x="${1.5 +
|
|
30051
|
+
for (let i2 = 0; i2 < total2; i2++) {
|
|
30052
|
+
const h2 = 3 + i2 * 10 / Math.max(1, total2 - 1);
|
|
30053
|
+
out += `<rect x="${1.5 + i2 * (13 / total2)}" y="${14.5 - h2}" width="${13 / total2 - 1}" height="${h2}" fill="${i2 < filled ? "#2f6db5" : "#c8c8c8"}"/>`;
|
|
28808
30054
|
}
|
|
28809
30055
|
return out;
|
|
28810
30056
|
};
|
|
@@ -28818,10 +30064,10 @@ var quarters = (n) => {
|
|
|
28818
30064
|
};
|
|
28819
30065
|
var boxes = (n) => {
|
|
28820
30066
|
let out = "";
|
|
28821
|
-
for (let
|
|
28822
|
-
const x =
|
|
28823
|
-
const y =
|
|
28824
|
-
out += `<rect x="${x}" y="${y}" width="6" height="6" fill="${
|
|
30067
|
+
for (let i2 = 0; i2 < 4; i2++) {
|
|
30068
|
+
const x = i2 % 2 ? 8.5 : 1.5;
|
|
30069
|
+
const y = i2 < 2 ? 1.5 : 8.5;
|
|
30070
|
+
out += `<rect x="${x}" y="${y}" width="6" height="6" fill="${i2 < n ? "#2f6db5" : "#d6d6d6"}"/>`;
|
|
28825
30071
|
}
|
|
28826
30072
|
return out;
|
|
28827
30073
|
};
|
|
@@ -29503,7 +30749,7 @@ function themePaletteItems(ctx) {
|
|
|
29503
30749
|
if (!theme2) return [];
|
|
29504
30750
|
const order = [1, 0, 3, 2, 4, 5, 6, 7, 8, 9];
|
|
29505
30751
|
const rects = order.map(
|
|
29506
|
-
(slot,
|
|
30752
|
+
(slot, i2) => `<rect x="${i2 * 6}" y="0" width="6" height="16" fill="${hex(theme2.colors[slot])}"><title>${THEME_SLOTS[slot] ?? ""}</title></rect>`
|
|
29507
30753
|
).join("");
|
|
29508
30754
|
return [
|
|
29509
30755
|
{
|
|
@@ -29517,8 +30763,8 @@ function themePaletteItems(ctx) {
|
|
|
29517
30763
|
// xlsx/ui/ribbon/tell-me.ts
|
|
29518
30764
|
var MAX_RESULTS = 8;
|
|
29519
30765
|
function searchCommands(ctx, query, isHidden) {
|
|
29520
|
-
const
|
|
29521
|
-
if (!
|
|
30766
|
+
const words2 = query.trim().toLocaleLowerCase().split(/\s+/).filter(Boolean);
|
|
30767
|
+
if (!words2.length) return [];
|
|
29522
30768
|
const scored = [];
|
|
29523
30769
|
const seen = /* @__PURE__ */ new Set();
|
|
29524
30770
|
for (const command of ctx.commands.list()) {
|
|
@@ -29526,10 +30772,10 @@ function searchCommands(ctx, query, isHidden) {
|
|
|
29526
30772
|
const label2 = ctx.t(command.label).toLocaleLowerCase();
|
|
29527
30773
|
const english = command.label.toLocaleLowerCase();
|
|
29528
30774
|
const haystack = `${label2} ${english} ${command.id.replace(/[.-]/g, " ")}`;
|
|
29529
|
-
if (!
|
|
30775
|
+
if (!words2.every((word) => haystack.includes(word))) continue;
|
|
29530
30776
|
if (seen.has(label2)) continue;
|
|
29531
30777
|
seen.add(label2);
|
|
29532
|
-
const score = label2.startsWith(
|
|
30778
|
+
const score = label2.startsWith(words2[0]) ? 0 : label2.includes(words2[0]) ? 1 : 2;
|
|
29533
30779
|
scored.push({ command, score });
|
|
29534
30780
|
}
|
|
29535
30781
|
return scored.sort(
|