ooxml-core 1.31.0 → 1.32.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-KKLAYUGQ.mjs → PptxHandler-QY5VL3CY.mjs} +2 -2
- package/dist/PptxHandler-SJ5ZUIUX.mjs +4 -0
- package/dist/{PptxHandler-DHQPVTUI.cjs → PptxHandler-TESZUH66.cjs} +3 -3
- package/dist/{PresentationBuilder-YYZYCKTZ.mjs → PresentationBuilder-3CH5TR4W.mjs} +2 -2
- package/dist/{PresentationBuilder-JORMF5CP.cjs → PresentationBuilder-5NFBUP7Y.cjs} +5 -5
- package/dist/{PresentationBuilder-Q2Z33LLM.mjs → PresentationBuilder-S6HXHKEJ.mjs} +2 -2
- package/dist/automation/index.cjs +862 -389
- package/dist/automation/index.mjs +862 -389
- package/dist/{chunk-GJDFCP2T.mjs → chunk-3H5UAJB3.mjs} +258 -155
- package/dist/{chunk-MKDONWNO.mjs → chunk-4R65YYAD.mjs} +32 -14
- package/dist/{chunk-KWJYMAEF.mjs → chunk-IOTGRLJH.mjs} +255 -152
- package/dist/{chunk-6FXOAMNL.mjs → chunk-N6424WKA.mjs} +1 -1
- package/dist/{chunk-WZJ25K7P.mjs → chunk-NAWLWKOJ.mjs} +1 -1
- package/dist/{chunk-DJ3CDTMX.mjs → chunk-O7SVHLD7.mjs} +23 -5
- package/dist/{chunk-CZXM4ZJH.cjs → chunk-Q6NM64J2.cjs} +23 -4
- package/dist/{chunk-FFJBOR2Y.mjs → chunk-UYMSFJQZ.mjs} +76 -4
- package/dist/{chunk-B4LXDHBX.cjs → chunk-X6VNUBES.cjs} +1419 -1316
- package/dist/diagram/index.cjs +8 -4
- package/dist/diagram/index.mjs +8 -4
- package/dist/docx/embedded.cjs +8 -4
- package/dist/docx/embedded.mjs +8 -4
- package/dist/docx/index.cjs +8 -4
- package/dist/docx/index.mjs +8 -4
- package/dist/docx/layout/index.cjs +8 -4
- package/dist/docx/layout/index.mjs +8 -4
- package/dist/docx/load/index.cjs +8 -4
- package/dist/docx/load/index.mjs +8 -4
- package/dist/docx/ui/index.cjs +8 -4
- package/dist/docx/ui/index.mjs +8 -4
- package/dist/geometry/index.cjs +16 -12
- package/dist/geometry/index.mjs +16 -12
- package/dist/geometry/preset-shape-definitions-table.d.ts.map +1 -1
- package/dist/index.cjs +16 -12
- package/dist/index.mjs +16 -12
- package/dist/pptx/automation/index.cjs +294 -157
- package/dist/pptx/automation/index.d.ts +3 -3
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/chunks/{index-PdM5zpmu.d.ts → index-D-FdgqrP.d.ts} +102 -3
- package/dist/pptx/chunks/index-D-FdgqrP.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-BQDcu_0a.d.ts → index-DKybuHPT.d.ts} +51 -3
- package/dist/pptx/chunks/{index-BQDcu_0a.d.ts.map → index-DKybuHPT.d.ts.map} +1 -1
- package/dist/pptx/chunks/{index-CBV1oHN7.d.ts → index-DnWlmYCy.d.ts} +2 -2
- package/dist/pptx/chunks/{index-CBV1oHN7.d.ts.map → index-DnWlmYCy.d.ts.map} +1 -1
- package/dist/pptx/cli/index.cjs +294 -157
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.cjs +8 -4
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/editor/render/find-replace.cjs +14 -14
- package/dist/pptx/editor/render/find-replace.d.ts +1 -1
- package/dist/pptx/editor/render/find-replace.mjs +1 -1
- package/dist/pptx/editor/render/slide-operations.cjs +8 -8
- package/dist/pptx/editor/render/slide-operations.mjs +2 -2
- package/dist/pptx/index.cjs +380 -171
- package/dist/pptx/index.d.ts +4 -4
- package/dist/pptx/index.mjs +5 -5
- package/dist/pptx/node/index.d.ts +1 -1
- package/dist/teams/chat-view.d.ts +10 -1
- package/dist/teams/chat-view.d.ts.map +1 -1
- package/dist/teams/index.cjs +805 -144
- package/dist/teams/index.d.ts +1 -0
- package/dist/teams/index.d.ts.map +1 -1
- package/dist/teams/index.mjs +795 -145
- package/dist/teams/presence-controller.d.ts +18 -3
- package/dist/teams/presence-controller.d.ts.map +1 -1
- package/dist/teams/presence-meetings.d.ts +21 -0
- package/dist/teams/presence-meetings.d.ts.map +1 -0
- package/dist/teams/presence.d.ts +40 -2
- package/dist/teams/presence.d.ts.map +1 -1
- package/dist/teams/store.d.ts +5 -0
- package/dist/teams/store.d.ts.map +1 -1
- package/dist/teams/view.d.ts +5 -0
- package/dist/teams/view.d.ts.map +1 -1
- package/dist/teams/workspace.d.ts +5 -2
- package/dist/teams/workspace.d.ts.map +1 -1
- package/dist/visio/index.cjs +6 -1
- package/dist/visio/index.mjs +6 -1
- package/dist/visio/ui/index.cjs +6 -1
- package/dist/visio/ui/index.mjs +6 -1
- package/dist/xlsx/formula/ets-drift-compare.d.ts +19 -0
- package/dist/xlsx/formula/ets-drift-compare.d.ts.map +1 -0
- package/dist/xlsx/formula/ets-excel-compare.d.ts +12 -0
- package/dist/xlsx/formula/ets-excel-compare.d.ts.map +1 -1
- package/dist/xlsx/formula/ets-init-compare.d.ts +24 -0
- package/dist/xlsx/formula/ets-init-compare.d.ts.map +1 -0
- package/dist/xlsx/formula/ets-init-maps.d.ts +21 -0
- package/dist/xlsx/formula/ets-init-maps.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-core.d.ts +1 -1
- package/dist/xlsx/formula/functions/ets-core.d.ts.map +1 -1
- package/dist/xlsx/formula/functions/ets-init-chain.d.ts +11 -0
- package/dist/xlsx/formula/functions/ets-init-chain.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-init-four.d.ts +3 -0
- package/dist/xlsx/formula/functions/ets-init-four.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-init-short.d.ts +17 -0
- package/dist/xlsx/formula/functions/ets-init-short.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-init-states.d.ts +5 -0
- package/dist/xlsx/formula/functions/ets-init-states.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-init-three.d.ts +23 -0
- package/dist/xlsx/formula/functions/ets-init-three.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-init-threeplus.d.ts +13 -0
- package/dist/xlsx/formula/functions/ets-init-threeplus.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-init.d.ts +18 -0
- package/dist/xlsx/formula/functions/ets-init.d.ts.map +1 -1
- package/dist/xlsx/formula/functions/ets-search-map.d.ts +24 -0
- package/dist/xlsx/formula/functions/ets-search-map.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-search.d.ts +17 -0
- package/dist/xlsx/formula/functions/ets-search.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/ets-season.d.ts +2 -2
- package/dist/xlsx/formula/functions/ets-season.d.ts.map +1 -1
- package/dist/xlsx/formula/functions/ets-validate.d.ts +16 -0
- package/dist/xlsx/formula/functions/ets-validate.d.ts.map +1 -0
- package/dist/xlsx/index.cjs +755 -282
- package/dist/xlsx/index.mjs +755 -282
- package/dist/xlsx/layout/form-control-view.d.ts.map +1 -1
- package/dist/xlsx/layout/shape-view.d.ts.map +1 -1
- package/dist/xlsx/load/index.cjs +599 -126
- package/dist/xlsx/load/index.mjs +599 -126
- package/dist/xlsx/read/form-control.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +756 -283
- package/dist/xlsx/ui/index.mjs +756 -283
- package/package.json +1 -1
- package/dist/PptxHandler-E4DDV3FQ.mjs +0 -4
- package/dist/pptx/chunks/index-PdM5zpmu.d.ts.map +0 -1
package/dist/xlsx/index.cjs
CHANGED
|
@@ -6568,14 +6568,14 @@ function linearFit(xs, ys) {
|
|
|
6568
6568
|
return { slope, intercept: my - slope * mx };
|
|
6569
6569
|
}
|
|
6570
6570
|
function rank(values2, x, ascending, average) {
|
|
6571
|
-
let
|
|
6571
|
+
let better2 = 0;
|
|
6572
6572
|
let ties = 0;
|
|
6573
6573
|
for (const v of values2) {
|
|
6574
6574
|
if (v === x) ties++;
|
|
6575
|
-
else if (ascending ? v < x : v > x)
|
|
6575
|
+
else if (ascending ? v < x : v > x) better2++;
|
|
6576
6576
|
}
|
|
6577
6577
|
if (ties === 0) fail(ERR.NA);
|
|
6578
|
-
return average ?
|
|
6578
|
+
return average ? better2 + (ties + 1) / 2 : better2 + 1;
|
|
6579
6579
|
}
|
|
6580
6580
|
var LANCZOS = [
|
|
6581
6581
|
676.5203681218851,
|
|
@@ -11621,11 +11621,11 @@ function binomDist(k, n2, p, cumulative2) {
|
|
|
11621
11621
|
for (let i2 = 0; i2 <= kk; i2++) total2 += binomPmf(i2, nn, p);
|
|
11622
11622
|
return Math.min(1, total2);
|
|
11623
11623
|
}
|
|
11624
|
-
function poisson(k,
|
|
11624
|
+
function poisson(k, mean9, cumulative2) {
|
|
11625
11625
|
const kk = Math.trunc(k);
|
|
11626
|
-
if (kk < 0 ||
|
|
11627
|
-
if (cumulative2) return 1 - gammaP(kk + 1,
|
|
11628
|
-
return Math.exp(kk * Math.log(
|
|
11626
|
+
if (kk < 0 || mean9 < 0) fail(ERR.NUM);
|
|
11627
|
+
if (cumulative2) return 1 - gammaP(kk + 1, mean9);
|
|
11628
|
+
return Math.exp(kk * Math.log(mean9) - mean9 - gammaLn(kk + 1));
|
|
11629
11629
|
}
|
|
11630
11630
|
var normDist = (x, m, s, cumulative2) => {
|
|
11631
11631
|
positive2(s);
|
|
@@ -11633,13 +11633,272 @@ var normDist = (x, m, s, cumulative2) => {
|
|
|
11633
11633
|
return cumulative2 ? normCdf(z) : normPdf(z) / s;
|
|
11634
11634
|
};
|
|
11635
11635
|
|
|
11636
|
+
// xlsx/formula/functions/ets-init-three.ts
|
|
11637
|
+
var mean2 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
|
|
11638
|
+
function slopeOf(v) {
|
|
11639
|
+
const k = v.length;
|
|
11640
|
+
const mx = (k - 1) / 2;
|
|
11641
|
+
const my = mean2(v);
|
|
11642
|
+
let sxy = 0;
|
|
11643
|
+
let sxx = 0;
|
|
11644
|
+
for (let i2 = 0; i2 < k; i2++) {
|
|
11645
|
+
sxy += (i2 - mx) * (v[i2] - my);
|
|
11646
|
+
sxx += (i2 - mx) * (i2 - mx);
|
|
11647
|
+
}
|
|
11648
|
+
return sxx === 0 ? 0 : sxy / sxx;
|
|
11649
|
+
}
|
|
11650
|
+
function positionSlopes(y, m) {
|
|
11651
|
+
return Array.from({ length: m }, (_v, c2) => {
|
|
11652
|
+
const vals = [];
|
|
11653
|
+
for (let t = c2; t < y.length; t += m) vals.push(y[t]);
|
|
11654
|
+
return slopeOf(vals) / m;
|
|
11655
|
+
});
|
|
11656
|
+
}
|
|
11657
|
+
function isThreeSeasonLength(n2, m) {
|
|
11658
|
+
return m >= 4 && n2 >= 3 * m && n2 <= 3 * m + Math.ceil(m / 2) + 1;
|
|
11659
|
+
}
|
|
11660
|
+
function threeSeasonSeasonals(y, m, slopeSumOverride) {
|
|
11661
|
+
const n2 = y.length;
|
|
11662
|
+
const extra = n2 - 3 * m;
|
|
11663
|
+
const j0 = Math.floor(m / 2);
|
|
11664
|
+
const at2 = (t) => y[t];
|
|
11665
|
+
const slope = (j) => (at2(j + 2 * m) - at2(j)) / (2 * m);
|
|
11666
|
+
const B = (j) => j + 2 * m < n2 ? slope(j) : slope(j % m);
|
|
11667
|
+
const e = (t) => at2(t) - at2(t - 1) - B(t - j0);
|
|
11668
|
+
const slopeSum = slopeSumOverride ?? positionSlopes(y, m).reduce((a2, b) => a2 + b, 0);
|
|
11669
|
+
const out = [0];
|
|
11670
|
+
for (let k = 1; k < m; k++) {
|
|
11671
|
+
let back = 0;
|
|
11672
|
+
for (let t = k + 1; t <= m; t++) back -= e(t);
|
|
11673
|
+
let fwd = 0;
|
|
11674
|
+
for (let t = m + 1; t <= m + k; t++) fwd += e(t);
|
|
11675
|
+
if (k < j0 - 1) {
|
|
11676
|
+
out.push(fwd);
|
|
11677
|
+
continue;
|
|
11678
|
+
}
|
|
11679
|
+
if (k === m - 1 && extra <= Math.ceil(m / 2)) {
|
|
11680
|
+
out.push(back);
|
|
11681
|
+
continue;
|
|
11682
|
+
}
|
|
11683
|
+
const wrapped = Math.max(0, k - j0 + 1 - extra);
|
|
11684
|
+
let corner4 = 0;
|
|
11685
|
+
for (let i2 = extra; i2 <= k - j0; i2++)
|
|
11686
|
+
corner4 += (at2(i2 + m) + at2(i2 + 2 * m) - 2 * at2(i2)) / (4 * m);
|
|
11687
|
+
const level4 = (at2(k) + at2(m + k)) / 2 - at2(m);
|
|
11688
|
+
const bb = back - (at2(k) - at2(m));
|
|
11689
|
+
const ff = fwd - (at2(m + k) - at2(m));
|
|
11690
|
+
out.push(level4 + (bb + ff) / 2 - 3 * wrapped / (4 * m) * slopeSum + corner4);
|
|
11691
|
+
}
|
|
11692
|
+
return out;
|
|
11693
|
+
}
|
|
11694
|
+
function padThreeSeasons(y, m, slopeMean = mean2(positionSlopes(y, m))) {
|
|
11695
|
+
const n2 = y.length;
|
|
11696
|
+
const total2 = Math.max(3 * m + Math.ceil(m / 2), n2);
|
|
11697
|
+
const ext = [...y];
|
|
11698
|
+
for (let t = n2; t < total2; t++) ext.push(y[t - 3 * m] + 3 * m * slopeMean);
|
|
11699
|
+
return ext;
|
|
11700
|
+
}
|
|
11701
|
+
function threeSeasonTrend(y, m, rel, slopeMean) {
|
|
11702
|
+
const ext = padThreeSeasons(y, m, slopeMean);
|
|
11703
|
+
const total2 = ext.length;
|
|
11704
|
+
const mx = (total2 - 1) / 2;
|
|
11705
|
+
let sxx = 0;
|
|
11706
|
+
let sxy = 0;
|
|
11707
|
+
for (let t = 0; t < total2; t++) {
|
|
11708
|
+
sxx += (t - mx) * (t - mx);
|
|
11709
|
+
sxy += (t - mx) * (ext[t] - rel[t % m]);
|
|
11710
|
+
}
|
|
11711
|
+
return sxy / sxx;
|
|
11712
|
+
}
|
|
11713
|
+
function isTwoSeasonLength(n2, m) {
|
|
11714
|
+
return m >= 4 && n2 === 2 * m;
|
|
11715
|
+
}
|
|
11716
|
+
function isTwoPlusLength(n2, m) {
|
|
11717
|
+
return m >= 4 && n2 > 2 * m && n2 < 3 * m;
|
|
11718
|
+
}
|
|
11719
|
+
function slopeSumOf(y, m) {
|
|
11720
|
+
return positionSlopes(y, m).reduce((a2, c2) => a2 + c2, 0);
|
|
11721
|
+
}
|
|
11722
|
+
function extendTwoSeasons(y, m) {
|
|
11723
|
+
const b = mean2(positionSlopes(y, m));
|
|
11724
|
+
const out = [...y];
|
|
11725
|
+
for (let t = y.length; t < 3 * m; t++) out.push(y[t - 2 * m] + 2 * m * b);
|
|
11726
|
+
return out;
|
|
11727
|
+
}
|
|
11728
|
+
function paddedSearchSeries(y, m) {
|
|
11729
|
+
if (isTwoSeasonLength(y.length, m) || isTwoPlusLength(y.length, m))
|
|
11730
|
+
return padThreeSeasons(extendTwoSeasons(y, m), m, slopeSumOf(y, m) / m);
|
|
11731
|
+
if (isThreeSeasonLength(y.length, m)) return padThreeSeasons(y, m);
|
|
11732
|
+
return void 0;
|
|
11733
|
+
}
|
|
11734
|
+
|
|
11735
|
+
// xlsx/formula/functions/ets-init-states.ts
|
|
11736
|
+
var mean3 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
|
|
11737
|
+
function chainStates(y, m, seasons) {
|
|
11738
|
+
const h2 = Math.floor(seasons / 2);
|
|
11739
|
+
const first2 = seasons - h2;
|
|
11740
|
+
const at2 = (t) => y[t];
|
|
11741
|
+
const meanFirst = (t) => mean3(Array.from({ length: first2 }, (_v, c2) => at2(t + c2 * m)));
|
|
11742
|
+
const slope = (j) => {
|
|
11743
|
+
const early = mean3(Array.from({ length: h2 }, (_v, c2) => at2(j + c2 * m)));
|
|
11744
|
+
const late = mean3(Array.from({ length: h2 }, (_v, c2) => at2(j + (seasons - h2 + c2) * m)));
|
|
11745
|
+
return (late - early) / ((seasons - h2) * m);
|
|
11746
|
+
};
|
|
11747
|
+
const j0 = Math.floor(m / 2);
|
|
11748
|
+
const state = /* @__PURE__ */ new Map([[j0 - 1, 0]]);
|
|
11749
|
+
for (let t = j0; t <= j0 + m - 2; t++)
|
|
11750
|
+
state.set(t, state.get(t - 1) + meanFirst(t) - meanFirst(t - 1) - slope(t - j0));
|
|
11751
|
+
const byPosition2 = new Array(m).fill(0);
|
|
11752
|
+
for (const [t, s] of state) byPosition2[t % m] = s;
|
|
11753
|
+
return byPosition2;
|
|
11754
|
+
}
|
|
11755
|
+
function chainSeasonals(y, m, seasons) {
|
|
11756
|
+
const byPosition2 = chainStates(y, m, seasons);
|
|
11757
|
+
const origin = byPosition2[0];
|
|
11758
|
+
return byPosition2.map((s) => s - origin);
|
|
11759
|
+
}
|
|
11760
|
+
|
|
11761
|
+
// xlsx/formula/functions/ets-init-four.ts
|
|
11762
|
+
var mean4 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
|
|
11763
|
+
function template(w, m, a2) {
|
|
11764
|
+
const block = (c2) => mean4(w.slice(c2 * m, (c2 + 1) * m));
|
|
11765
|
+
const at2 = (i2) => w[i2];
|
|
11766
|
+
return (block(0) - block(2)) / 12 + (block(1) - block(3)) / 6 - (at2(a2) + at2(a2 + m) - 2 * at2(a2 + 2 * m)) / 6;
|
|
11767
|
+
}
|
|
11768
|
+
function fourSeasonPlusSeasonals(y, m) {
|
|
11769
|
+
const r = y.length - 4 * m;
|
|
11770
|
+
const a2 = Math.floor(m / 2) - 1;
|
|
11771
|
+
const states = chainStates(y.slice(0, 4 * m), m, 4);
|
|
11772
|
+
for (let q = 0; q < r; q++) {
|
|
11773
|
+
const pos = (a2 + q) % m;
|
|
11774
|
+
states[pos] = states[pos] + template(y.slice(q, q + 4 * m), m, a2);
|
|
11775
|
+
}
|
|
11776
|
+
const origin = states[0];
|
|
11777
|
+
return states.map((s) => s - origin);
|
|
11778
|
+
}
|
|
11779
|
+
|
|
11780
|
+
// xlsx/formula/functions/ets-init-threeplus.ts
|
|
11781
|
+
var mean5 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
|
|
11782
|
+
function isThreePlusLength(n2, m) {
|
|
11783
|
+
return m >= 4 && n2 >= 3 * m + Math.ceil(m / 2) + 2 && n2 < 4 * m;
|
|
11784
|
+
}
|
|
11785
|
+
function shift2(y, m, k) {
|
|
11786
|
+
const a2 = Math.ceil(m / 2) + 1;
|
|
11787
|
+
const at2 = (i2) => y[i2];
|
|
11788
|
+
return (at2(m + k) - at2(2 * m + k)) / 2 - (mean5(y.slice(a2 + k, a2 + k + m)) - mean5(y.slice(a2 + 2 * m + k, a2 + 3 * m + k))) / 4;
|
|
11789
|
+
}
|
|
11790
|
+
function isLowThreeLength(n2, m) {
|
|
11791
|
+
return m === 2 && n2 >= 5 && n2 < 8 || m === 3 && n2 >= 6 && n2 < 12;
|
|
11792
|
+
}
|
|
11793
|
+
function lowSeasonSeasonals(y, m, slopeSum) {
|
|
11794
|
+
const base = threeSeasonSeasonals(y, m, slopeSum);
|
|
11795
|
+
const d = -shift2(y, m, -m);
|
|
11796
|
+
return base.map((s, k) => k === 0 ? 0 : s + d);
|
|
11797
|
+
}
|
|
11798
|
+
function threePlusSeasonals(y, m) {
|
|
11799
|
+
const base = threeSeasonSeasonals(y, m);
|
|
11800
|
+
const moved = y.length - 3 * m - Math.ceil(m / 2) - 1;
|
|
11801
|
+
const z = base.map((s, k) => k < moved ? s - shift2(y, m, k) : s);
|
|
11802
|
+
const origin = z[0];
|
|
11803
|
+
return z.map((s) => s - origin);
|
|
11804
|
+
}
|
|
11805
|
+
|
|
11806
|
+
// xlsx/formula/functions/ets-init-short.ts
|
|
11807
|
+
function seasonStart(m) {
|
|
11808
|
+
return Math.ceil(10 * (m + 1) / 7);
|
|
11809
|
+
}
|
|
11810
|
+
function isShortSeasonLength(n2, m) {
|
|
11811
|
+
return m >= 5 && n2 >= seasonStart(m) && n2 < 2 * m;
|
|
11812
|
+
}
|
|
11813
|
+
function padTwoSeasons(y, m) {
|
|
11814
|
+
const p = [...y];
|
|
11815
|
+
for (let t = y.length; t < 2 * m; t++) p.push(p[t - m]);
|
|
11816
|
+
return p;
|
|
11817
|
+
}
|
|
11818
|
+
function trendShift(m, n2) {
|
|
11819
|
+
const j0 = Math.floor(m / 2);
|
|
11820
|
+
const u = 2 * m - 1 - n2;
|
|
11821
|
+
return (u * u - (j0 - 2) * u + 2 * (j0 - 1)) / 4;
|
|
11822
|
+
}
|
|
11823
|
+
function shortSeasonStart(y, m) {
|
|
11824
|
+
const n2 = y.length;
|
|
11825
|
+
const p = padTwoSeasons(y, m);
|
|
11826
|
+
const ss = slopeSumOf(p, m);
|
|
11827
|
+
const ext = extendTwoSeasons(p, m);
|
|
11828
|
+
const base = threeSeasonSeasonals(ext, m, ss);
|
|
11829
|
+
const total2 = 3 * m + Math.ceil(m / 2);
|
|
11830
|
+
const sxx = total2 * (total2 * total2 - 1) / 12;
|
|
11831
|
+
const trend = threeSeasonTrend(ext, m, base, ss / m) + trendShift(m, n2) * ss / sxx;
|
|
11832
|
+
const rel = base.map((s, k) => k >= n2 - m && k <= m - 2 ? s + ss / 2 : s);
|
|
11833
|
+
return { rel, trend };
|
|
11834
|
+
}
|
|
11835
|
+
function shortSearchSeries(y, m) {
|
|
11836
|
+
const p = padTwoSeasons(y, m);
|
|
11837
|
+
return padThreeSeasons(extendTwoSeasons(p, m), m, slopeSumOf(p, m) / m);
|
|
11838
|
+
}
|
|
11839
|
+
|
|
11840
|
+
// xlsx/formula/functions/ets-init-chain.ts
|
|
11841
|
+
var MAX_SEASONS = 5;
|
|
11842
|
+
var mean6 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
|
|
11843
|
+
function isExactLength(n2, m) {
|
|
11844
|
+
const whole = Math.floor(n2 / m);
|
|
11845
|
+
return whole >= MAX_SEASONS || whole === 4 || isThreeSeasonLength(n2, m) || isThreePlusLength(n2, m) || isLowThreeLength(n2, m) || isTwoSeasonLength(n2, m) || isTwoPlusLength(n2, m) || isShortSeasonLength(n2, m);
|
|
11846
|
+
}
|
|
11847
|
+
function fromRelative(y0, rel, trend) {
|
|
11848
|
+
const combined = rel.map((s) => y0 + s - trend);
|
|
11849
|
+
const level4 = mean6(combined);
|
|
11850
|
+
return { level: level4, trend, season: combined.map((c2) => c2 - level4) };
|
|
11851
|
+
}
|
|
11852
|
+
function chainStart(y, m) {
|
|
11853
|
+
const n2 = y.length;
|
|
11854
|
+
const whole = Math.floor(n2 / m);
|
|
11855
|
+
if (isShortSeasonLength(n2, m)) {
|
|
11856
|
+
const { rel: rel2, trend } = shortSeasonStart(y, m);
|
|
11857
|
+
return fromRelative(y[0], rel2, trend);
|
|
11858
|
+
}
|
|
11859
|
+
if (isThreeSeasonLength(n2, m) || isTwoSeasonLength(n2, m) || isTwoPlusLength(n2, m)) {
|
|
11860
|
+
const short = isTwoSeasonLength(n2, m) || isTwoPlusLength(n2, m);
|
|
11861
|
+
const series = short ? extendTwoSeasons(y, m) : y;
|
|
11862
|
+
const rel2 = threeSeasonSeasonals(series, m, short ? slopeSumOf(y, m) : void 0);
|
|
11863
|
+
return fromRelative(
|
|
11864
|
+
y[0],
|
|
11865
|
+
rel2,
|
|
11866
|
+
threeSeasonTrend(series, m, rel2, short ? slopeSumOf(y, m) / m : void 0)
|
|
11867
|
+
);
|
|
11868
|
+
}
|
|
11869
|
+
if (isLowThreeLength(n2, m)) {
|
|
11870
|
+
const short = n2 < 3 * m;
|
|
11871
|
+
const series = short ? extendTwoSeasons(y, m) : y;
|
|
11872
|
+
const rel2 = lowSeasonSeasonals(series, m, short ? slopeSumOf(y, m) : void 0);
|
|
11873
|
+
const pad8 = short ? slopeSumOf(y, m) / m : void 0;
|
|
11874
|
+
return fromRelative(y[0], rel2, threeSeasonTrend(series, m, rel2, pad8));
|
|
11875
|
+
}
|
|
11876
|
+
if (isThreePlusLength(n2, m)) {
|
|
11877
|
+
const rel2 = threePlusSeasonals(y, m);
|
|
11878
|
+
return fromRelative(y[0], rel2, threeSeasonTrend(y, m, rel2));
|
|
11879
|
+
}
|
|
11880
|
+
if (m < 2 || whole < 4) return void 0;
|
|
11881
|
+
const partial = whole < MAX_SEASONS && n2 % m !== 0;
|
|
11882
|
+
const rel = partial ? fourSeasonPlusSeasonals(y, m) : chainSeasonals(y, m, Math.min(whole, MAX_SEASONS));
|
|
11883
|
+
const mx = (n2 - 1) / 2;
|
|
11884
|
+
let sxy = 0;
|
|
11885
|
+
let sxx = 0;
|
|
11886
|
+
const my = mean6(y.map((v, t) => v - rel[t % m]));
|
|
11887
|
+
for (let t = 0; t < n2; t++) {
|
|
11888
|
+
const d = y[t] - rel[t % m] - my;
|
|
11889
|
+
sxy += (t - mx) * d;
|
|
11890
|
+
sxx += (t - mx) * (t - mx);
|
|
11891
|
+
}
|
|
11892
|
+
return fromRelative(y[0], rel, sxy / sxx);
|
|
11893
|
+
}
|
|
11894
|
+
|
|
11636
11895
|
// xlsx/formula/functions/ets-init.ts
|
|
11637
11896
|
var MAX_EXACT_SEASON = 24;
|
|
11638
|
-
var
|
|
11897
|
+
var mean7 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
|
|
11639
11898
|
function olsSlope(y) {
|
|
11640
11899
|
const n2 = y.length;
|
|
11641
11900
|
const mx = (n2 - 1) / 2;
|
|
11642
|
-
const my =
|
|
11901
|
+
const my = mean7(y);
|
|
11643
11902
|
let sxy = 0;
|
|
11644
11903
|
let sxx = 0;
|
|
11645
11904
|
for (let i2 = 0; i2 < n2; i2++) {
|
|
@@ -11648,12 +11907,30 @@ function olsSlope(y) {
|
|
|
11648
11907
|
}
|
|
11649
11908
|
return sxx === 0 ? 0 : sxy / sxx;
|
|
11650
11909
|
}
|
|
11910
|
+
var PADS = {
|
|
11911
|
+
6: [[0, 6]],
|
|
11912
|
+
5: [
|
|
11913
|
+
[1, 4],
|
|
11914
|
+
[0, 6]
|
|
11915
|
+
],
|
|
11916
|
+
4: [
|
|
11917
|
+
[0, 4],
|
|
11918
|
+
[1, 4],
|
|
11919
|
+
[0, 6]
|
|
11920
|
+
]
|
|
11921
|
+
};
|
|
11922
|
+
function shortSeriesTrend(y) {
|
|
11923
|
+
const pads = PADS[y.length];
|
|
11924
|
+
if (!pads) return olsSlope(y);
|
|
11925
|
+
const slope = olsSlope(y);
|
|
11926
|
+
return olsSlope([...y, ...pads.map(([src, lag]) => y[src] + lag * slope)]);
|
|
11927
|
+
}
|
|
11651
11928
|
function split(trend, combined) {
|
|
11652
|
-
const level4 =
|
|
11929
|
+
const level4 = mean7(combined);
|
|
11653
11930
|
return { level: level4, trend, season: combined.map((c2) => c2 - level4) };
|
|
11654
11931
|
}
|
|
11655
11932
|
function heuristicStates(y, m) {
|
|
11656
|
-
const trend = (
|
|
11933
|
+
const trend = (mean7(y.slice(m, 2 * m)) - mean7(y.slice(0, m))) / m;
|
|
11657
11934
|
return split(
|
|
11658
11935
|
trend,
|
|
11659
11936
|
Array.from({ length: m }, (_v, k) => y[k] - trend * (k + 1))
|
|
@@ -11690,9 +11967,11 @@ function solveSystem(a2, b) {
|
|
|
11690
11967
|
function initialStates(y, m, p, run2) {
|
|
11691
11968
|
const y0 = y[0];
|
|
11692
11969
|
if (m < 2) {
|
|
11693
|
-
const trend2 =
|
|
11970
|
+
const trend2 = shortSeriesTrend(y);
|
|
11694
11971
|
return { level: y0 - trend2, trend: trend2, season: [] };
|
|
11695
11972
|
}
|
|
11973
|
+
const exact = chainStart(y, m);
|
|
11974
|
+
if (exact) return exact;
|
|
11696
11975
|
if (m > MAX_EXACT_SEASON) return heuristicStates(y, m);
|
|
11697
11976
|
const zeros = new Array(y.length).fill(0);
|
|
11698
11977
|
const unit = (trend2, season) => run2(zeros, m, { level: 0, trend: trend2, season }, p).fitted;
|
|
@@ -11712,6 +11991,202 @@ function initialStates(y, m, p, run2) {
|
|
|
11712
11991
|
return split(trend, [y0 - trend, ...u.slice(1)]);
|
|
11713
11992
|
}
|
|
11714
11993
|
|
|
11994
|
+
// xlsx/formula/functions/ets-search-map.ts
|
|
11995
|
+
var LOW = 1e-3;
|
|
11996
|
+
var DRIFT_SHIFT = 1.5;
|
|
11997
|
+
var DRIFT_T = 9.3;
|
|
11998
|
+
var CANDIDATES = [
|
|
11999
|
+
...[2e-3, 0.1, 0.126, 0.25, 0.5, 0.75, 0.9].map((a2) => [a2, LOW]),
|
|
12000
|
+
[0.1, 0.099],
|
|
12001
|
+
[0.126, 0.125],
|
|
12002
|
+
[0.25, 0.249],
|
|
12003
|
+
[0.333333, 0.166667],
|
|
12004
|
+
[0.5, 0.25],
|
|
12005
|
+
[0.5, 0.499],
|
|
12006
|
+
[0.666667, 0.166667],
|
|
12007
|
+
[0.666667, 0.5],
|
|
12008
|
+
[0.75, 0.749],
|
|
12009
|
+
[0.833333, 0.75],
|
|
12010
|
+
[0.9, 0.899],
|
|
12011
|
+
[0.998, 0.099],
|
|
12012
|
+
[0.998, 0.249],
|
|
12013
|
+
[0.998, 0.499],
|
|
12014
|
+
[0.998, 0.749],
|
|
12015
|
+
[0.998, 0.899],
|
|
12016
|
+
[0.166667, 0.0833333],
|
|
12017
|
+
[0.833333, 0.0833333]
|
|
12018
|
+
];
|
|
12019
|
+
var ALWAYS_DRIFT = /* @__PURE__ */ new Set([
|
|
12020
|
+
"0.1/0.099",
|
|
12021
|
+
"0.998/0.899",
|
|
12022
|
+
"0.998/0.749",
|
|
12023
|
+
"0.166667/0.0833333",
|
|
12024
|
+
"0.25/0.249",
|
|
12025
|
+
"0.9/0.899",
|
|
12026
|
+
"0.666667/0.5",
|
|
12027
|
+
"0.75/0.749"
|
|
12028
|
+
]);
|
|
12029
|
+
var NEVER_DRIFT = /* @__PURE__ */ new Set(["0.333333/0.166667"]);
|
|
12030
|
+
function trendShape(y, h2) {
|
|
12031
|
+
const n2 = y.length;
|
|
12032
|
+
const hold = h2 > 0 ? h2 : Math.max(1, Math.round(0.3 * n2));
|
|
12033
|
+
const mx = (n2 - 1) / 2;
|
|
12034
|
+
let my = 0;
|
|
12035
|
+
for (const v of y) my += v;
|
|
12036
|
+
my /= n2;
|
|
12037
|
+
let sxy = 0;
|
|
12038
|
+
let sxx = 0;
|
|
12039
|
+
let syy = 0;
|
|
12040
|
+
for (let i2 = 0; i2 < n2; i2++) {
|
|
12041
|
+
const dy = y[i2] - my;
|
|
12042
|
+
sxy += (i2 - mx) * dy;
|
|
12043
|
+
sxx += (i2 - mx) * (i2 - mx);
|
|
12044
|
+
syy += dy * dy;
|
|
12045
|
+
}
|
|
12046
|
+
if (syy === 0 || sxx === 0 || n2 < 3) return { shift: 0, t: 0 };
|
|
12047
|
+
const slope = sxy / sxx;
|
|
12048
|
+
const resid = syy - slope * sxy;
|
|
12049
|
+
const se = Math.sqrt(Math.max(resid, 0) / (n2 - 2) / sxx);
|
|
12050
|
+
let tail = 0;
|
|
12051
|
+
for (let i2 = n2 - hold; i2 < n2; i2++) tail += y[i2];
|
|
12052
|
+
let head = 0;
|
|
12053
|
+
for (let i2 = 0; i2 < n2 - hold; i2++) head += y[i2];
|
|
12054
|
+
const shift3 = Math.abs(tail / hold - head / (n2 - hold)) / Math.sqrt(syy / n2);
|
|
12055
|
+
return { shift: shift3, t: se === 0 ? Number.POSITIVE_INFINITY : Math.abs(slope / se) };
|
|
12056
|
+
}
|
|
12057
|
+
function reportedFor(alpha, beta, shape2) {
|
|
12058
|
+
const key = `${alpha}/${beta}`;
|
|
12059
|
+
let drift;
|
|
12060
|
+
if (beta === LOW) drift = false;
|
|
12061
|
+
else if (ALWAYS_DRIFT.has(key)) drift = true;
|
|
12062
|
+
else if (NEVER_DRIFT.has(key)) drift = false;
|
|
12063
|
+
else drift = shape2.shift <= DRIFT_SHIFT && shape2.t <= DRIFT_T;
|
|
12064
|
+
return { alpha, beta: drift ? LOW : beta, fit: [alpha, beta], drift };
|
|
12065
|
+
}
|
|
12066
|
+
|
|
12067
|
+
// xlsx/formula/functions/ets-search.ts
|
|
12068
|
+
var LOW2 = 1e-3;
|
|
12069
|
+
var MIN_SEARCH_POINTS = 4;
|
|
12070
|
+
var THREE_POINTS = { alpha: 0.1, beta: 0.099, gamma: LOW2, drift: false };
|
|
12071
|
+
var SEASON_ALPHAS = [2e-3, 0.126, 0.251, 0.501, 2 / 3, 0.75, 0.9];
|
|
12072
|
+
var SEASON_STEPS = [LOW2, 0.125, 0.25, 0.5, 0.75, 0.9];
|
|
12073
|
+
var SHORT_SERIES = 16;
|
|
12074
|
+
function better(c2, best) {
|
|
12075
|
+
return c2 < best * (1 - 1e-6) && c2 < best - 1e-12;
|
|
12076
|
+
}
|
|
12077
|
+
var SEASONAL_TRIPLES = [
|
|
12078
|
+
[0.126, LOW2, LOW2],
|
|
12079
|
+
[0.251, LOW2, LOW2],
|
|
12080
|
+
[0.501, LOW2, LOW2],
|
|
12081
|
+
[0.751, LOW2, LOW2],
|
|
12082
|
+
[2e-3, LOW2, 0.125],
|
|
12083
|
+
[2e-3, LOW2, 0.25],
|
|
12084
|
+
[2e-3, LOW2, 0.5],
|
|
12085
|
+
[2e-3, LOW2, 0.75],
|
|
12086
|
+
[0.251, LOW2, 0.25],
|
|
12087
|
+
[0.75, LOW2, 0.249],
|
|
12088
|
+
[0.9, LOW2, 0.099],
|
|
12089
|
+
[0.251, 0.25, LOW2],
|
|
12090
|
+
[0.1, LOW2, 0.899],
|
|
12091
|
+
[0.126, 0.125, LOW2],
|
|
12092
|
+
[0.998, 0.099, LOW2],
|
|
12093
|
+
[0.25, LOW2, 0.749],
|
|
12094
|
+
[0.5, LOW2, 0.499],
|
|
12095
|
+
[0.5, 0.25, LOW2],
|
|
12096
|
+
[0.251, 0.25, 0.25],
|
|
12097
|
+
[0.501, 0.5, LOW2]
|
|
12098
|
+
];
|
|
12099
|
+
var SHORT_EXTRA_TRIPLES = [
|
|
12100
|
+
[1 / 6, 1 / 12, 1 / 12],
|
|
12101
|
+
[1 / 3, 1 / 6, 1 / 6],
|
|
12102
|
+
[1 / 6, 1 / 12, 0.75],
|
|
12103
|
+
[1 / 3, 1 / 6, 0.5],
|
|
12104
|
+
[5 / 6, 1 / 12, 1 / 12]
|
|
12105
|
+
];
|
|
12106
|
+
function searchSeasonalLattice(cost, extra = []) {
|
|
12107
|
+
let best = { alpha: 0.126, beta: LOW2, gamma: LOW2 };
|
|
12108
|
+
let bestCost = cost(best);
|
|
12109
|
+
for (const [alpha, beta, gamma2] of [...SEASONAL_TRIPLES, ...extra]) {
|
|
12110
|
+
const c2 = cost({ alpha, beta, gamma: gamma2 });
|
|
12111
|
+
if (better(c2, bestCost)) {
|
|
12112
|
+
bestCost = c2;
|
|
12113
|
+
best = { alpha, beta, gamma: gamma2 };
|
|
12114
|
+
}
|
|
12115
|
+
}
|
|
12116
|
+
return { ...best, drift: false };
|
|
12117
|
+
}
|
|
12118
|
+
function searchSeasonal(n2, cost) {
|
|
12119
|
+
let best = { alpha: 0.9, beta: LOW2, gamma: LOW2 };
|
|
12120
|
+
let bestCost = cost(best);
|
|
12121
|
+
for (const a2 of SEASON_ALPHAS)
|
|
12122
|
+
for (const b of n2 >= 7 && n2 <= SHORT_SERIES ? [LOW2, a2 - LOW2] : [LOW2])
|
|
12123
|
+
for (const g2 of [...SEASON_STEPS, 1 - a2 - LOW2]) {
|
|
12124
|
+
if (b < LOW2 || g2 > 1 - a2 - LOW2 + 1e-9) continue;
|
|
12125
|
+
const c2 = cost({ alpha: a2, beta: b, gamma: g2 });
|
|
12126
|
+
if (better(c2, bestCost)) {
|
|
12127
|
+
bestCost = c2;
|
|
12128
|
+
best = { alpha: a2, beta: b, gamma: g2 };
|
|
12129
|
+
}
|
|
12130
|
+
}
|
|
12131
|
+
return { ...best, drift: false };
|
|
12132
|
+
}
|
|
12133
|
+
function searchLattice(shape2, cost) {
|
|
12134
|
+
let best = [0.9, LOW2];
|
|
12135
|
+
let bestCost = cost({ alpha: 0.9, beta: LOW2, gamma: LOW2 });
|
|
12136
|
+
for (const [alpha, beta] of CANDIDATES) {
|
|
12137
|
+
const c2 = cost({ alpha, beta, gamma: LOW2 });
|
|
12138
|
+
if (better(c2, bestCost)) {
|
|
12139
|
+
bestCost = c2;
|
|
12140
|
+
best = [alpha, beta];
|
|
12141
|
+
}
|
|
12142
|
+
}
|
|
12143
|
+
const out = reportedFor(best[0], best[1], shape2);
|
|
12144
|
+
const [fa, fb] = out.fit;
|
|
12145
|
+
const same11 = fa === out.alpha && fb === out.beta;
|
|
12146
|
+
return {
|
|
12147
|
+
alpha: out.alpha,
|
|
12148
|
+
beta: out.beta,
|
|
12149
|
+
gamma: LOW2,
|
|
12150
|
+
drift: out.drift,
|
|
12151
|
+
...same11 ? {} : { fit: { alpha: fa, beta: fb, gamma: LOW2 } }
|
|
12152
|
+
};
|
|
12153
|
+
}
|
|
12154
|
+
function chooseSmoothing(n2, m, cost, shape2 = { shift: 9, t: 99 }) {
|
|
12155
|
+
if (m >= 2 && isShortSeasonLength(n2, m)) return searchSeasonalLattice(cost, SHORT_EXTRA_TRIPLES);
|
|
12156
|
+
if (m >= 2) return isExactLength(n2, m) ? searchSeasonalLattice(cost) : searchSeasonal(n2, cost);
|
|
12157
|
+
if (n2 < MIN_SEARCH_POINTS) return THREE_POINTS;
|
|
12158
|
+
return searchLattice(shape2, cost);
|
|
12159
|
+
}
|
|
12160
|
+
|
|
12161
|
+
// xlsx/formula/functions/ets-validate.ts
|
|
12162
|
+
function etsSearchSeries(y) {
|
|
12163
|
+
const pads = PADS[y.length];
|
|
12164
|
+
if (!pads) return y;
|
|
12165
|
+
const slope = olsSlope(y);
|
|
12166
|
+
return [...y, ...pads.map(([src, lag]) => y[src] + lag * slope)];
|
|
12167
|
+
}
|
|
12168
|
+
function etsValidationCost(y, m, init, p, holdout) {
|
|
12169
|
+
const n2 = y.length;
|
|
12170
|
+
const train = n2 - holdout;
|
|
12171
|
+
let { level: level4, trend } = init;
|
|
12172
|
+
const season = [...init.season];
|
|
12173
|
+
let sse = 0;
|
|
12174
|
+
for (let t = 0; t < train; t++) {
|
|
12175
|
+
const k = m >= 2 ? t % m : 0;
|
|
12176
|
+
const e = y[t] - (level4 + trend + (m >= 2 ? season[k] ?? 0 : 0));
|
|
12177
|
+
sse += e * e;
|
|
12178
|
+
level4 += trend + p.alpha * e;
|
|
12179
|
+
trend += p.beta * e;
|
|
12180
|
+
if (m >= 2) season[k] = (season[k] ?? 0) + p.gamma * e;
|
|
12181
|
+
}
|
|
12182
|
+
for (let j = 1; j <= holdout; j++) {
|
|
12183
|
+
const t = train + j - 1;
|
|
12184
|
+
const e = y[t] - (level4 + j * trend + (m >= 2 ? season[t % m] ?? 0 : 0));
|
|
12185
|
+
sse += e * e;
|
|
12186
|
+
}
|
|
12187
|
+
return sse;
|
|
12188
|
+
}
|
|
12189
|
+
|
|
11715
12190
|
// xlsx/formula/functions/ets-core.ts
|
|
11716
12191
|
function etsRun(y, m, init, p) {
|
|
11717
12192
|
let { level: level4, trend } = init;
|
|
@@ -11730,36 +12205,36 @@ function etsRun(y, m, init, p) {
|
|
|
11730
12205
|
}
|
|
11731
12206
|
return { fitted, level: level4, trend, season, sse };
|
|
11732
12207
|
}
|
|
11733
|
-
var LOW = 1e-3;
|
|
11734
|
-
var SHORT_SERIES = 16;
|
|
11735
12208
|
var NO_SEASON_GAMMA = Number.EPSILON;
|
|
11736
|
-
var ALPHAS = [2e-3, 0.1, 0.126, 0.25, 0.5, 2 / 3, 0.75, 0.9];
|
|
11737
|
-
var SEASON_ALPHAS = [2e-3, 0.126, 0.251, 0.501, 2 / 3, 0.75, 0.9];
|
|
11738
|
-
var SEASON_STEPS = [LOW, 0.125, 0.25, 0.5, 0.75, 0.9];
|
|
11739
12209
|
function fitEts(y, seasonLength) {
|
|
11740
12210
|
const n2 = y.length;
|
|
11741
12211
|
if (n2 < 2) fail(ERR.NUM);
|
|
11742
|
-
const m = seasonLength >= 2 && n2 >=
|
|
12212
|
+
const m = seasonLength >= 2 && n2 >= seasonStart(seasonLength) ? seasonLength : 0;
|
|
11743
12213
|
const solve2 = (p) => {
|
|
11744
12214
|
const init = initialStates(y, m, p, etsRun);
|
|
11745
12215
|
return { init, run: etsRun(y, m, init, p) };
|
|
11746
12216
|
};
|
|
11747
|
-
const
|
|
11748
|
-
|
|
11749
|
-
|
|
11750
|
-
|
|
11751
|
-
|
|
11752
|
-
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
|
|
11758
|
-
|
|
11759
|
-
|
|
11760
|
-
|
|
11761
|
-
|
|
11762
|
-
|
|
12217
|
+
const exact = m < 2 || isExactLength(n2, m);
|
|
12218
|
+
const padded = m >= 2 && exact ? isShortSeasonLength(n2, m) ? shortSearchSeries(y, m) : paddedSearchSeries(y, m) : void 0;
|
|
12219
|
+
const searched = padded ?? (m >= 2 ? y : etsSearchSeries(y));
|
|
12220
|
+
const holdout = m >= 2 && !exact ? 0 : etsHoldout(padded && !(m >= 2 && isShortSeasonLength(n2, m)) ? padded.length : n2, m);
|
|
12221
|
+
const { drift, fit: fit2, ...chosen } = chooseSmoothing(
|
|
12222
|
+
n2,
|
|
12223
|
+
m,
|
|
12224
|
+
(p) => etsValidationCost(searched, m, solve2(p).init, p, holdout),
|
|
12225
|
+
trendShape(y, holdout)
|
|
12226
|
+
);
|
|
12227
|
+
const { run: run2 } = solve2(fit2 ?? chosen);
|
|
12228
|
+
const state = drift ? solve2({ alpha: 1, beta: 0, gamma: chosen.gamma }).run : run2;
|
|
12229
|
+
return {
|
|
12230
|
+
...chosen,
|
|
12231
|
+
gamma: m >= 2 ? chosen.gamma : NO_SEASON_GAMMA,
|
|
12232
|
+
m,
|
|
12233
|
+
n: n2,
|
|
12234
|
+
...run2,
|
|
12235
|
+
level: state.level,
|
|
12236
|
+
trend: state.trend
|
|
12237
|
+
};
|
|
11763
12238
|
}
|
|
11764
12239
|
function etsHoldout(n2, m) {
|
|
11765
12240
|
if (n2 < 11) return 0;
|
|
@@ -11784,12 +12259,12 @@ function etsErrorSd(fit2, h2) {
|
|
|
11784
12259
|
// xlsx/formula/functions/ets-season.ts
|
|
11785
12260
|
var MAX_POINTS = 8192;
|
|
11786
12261
|
var MIN_CYCLES = 3;
|
|
11787
|
-
var
|
|
11788
|
-
var
|
|
12262
|
+
var MIN_ACF = 0.3;
|
|
12263
|
+
var mean8 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
|
|
11789
12264
|
function detrend(y) {
|
|
11790
12265
|
const n2 = y.length;
|
|
11791
12266
|
const mx = (n2 - 1) / 2;
|
|
11792
|
-
const my =
|
|
12267
|
+
const my = mean8(y);
|
|
11793
12268
|
let sxy = 0;
|
|
11794
12269
|
let sxx = 0;
|
|
11795
12270
|
for (let i2 = 0; i2 < n2; i2++) {
|
|
@@ -11806,34 +12281,23 @@ function detectSeasonality(series) {
|
|
|
11806
12281
|
const r = detrend(y);
|
|
11807
12282
|
const scale2 = Math.max(...y.map(Math.abs), 1);
|
|
11808
12283
|
if (r.every((v) => Math.abs(v) <= 1e-12 * scale2)) return 0;
|
|
11809
|
-
const
|
|
11810
|
-
|
|
11811
|
-
for (
|
|
11812
|
-
|
|
11813
|
-
|
|
11814
|
-
|
|
11815
|
-
|
|
11816
|
-
|
|
11817
|
-
let
|
|
11818
|
-
|
|
11819
|
-
|
|
11820
|
-
|
|
11821
|
-
|
|
11822
|
-
|
|
11823
|
-
|
|
11824
|
-
re += v * cos2[j];
|
|
11825
|
-
im -= v * sin2[j];
|
|
11826
|
-
}
|
|
11827
|
-
const power2 = re * re + im * im;
|
|
11828
|
-
total2 += power2;
|
|
11829
|
-
if (k >= MIN_CYCLES && power2 > best) {
|
|
11830
|
-
best = power2;
|
|
11831
|
-
bestK = k;
|
|
11832
|
-
}
|
|
12284
|
+
const maxLag = Math.floor(n2 / MIN_CYCLES);
|
|
12285
|
+
let energy = 0;
|
|
12286
|
+
for (const v of r) energy += v * v;
|
|
12287
|
+
const acf = (lag) => {
|
|
12288
|
+
let s = 0;
|
|
12289
|
+
for (let t = 0; t + lag < n2; t++) s += r[t] * r[t + lag];
|
|
12290
|
+
return s / energy;
|
|
12291
|
+
};
|
|
12292
|
+
let prev = acf(1);
|
|
12293
|
+
let cur = acf(2);
|
|
12294
|
+
for (let lag = 2; lag <= maxLag; lag++) {
|
|
12295
|
+
const next = acf(lag + 1);
|
|
12296
|
+
if (cur >= prev && cur >= next && cur >= MIN_ACF) return lag;
|
|
12297
|
+
prev = cur;
|
|
12298
|
+
cur = next;
|
|
11833
12299
|
}
|
|
11834
|
-
|
|
11835
|
-
const period = Math.round(n2 / bestK);
|
|
11836
|
-
return period >= 2 ? period : 0;
|
|
12300
|
+
return 0;
|
|
11837
12301
|
}
|
|
11838
12302
|
|
|
11839
12303
|
// xlsx/formula/functions/ets-grid.ts
|
|
@@ -11905,9 +12369,9 @@ function aggregate2(code, xs) {
|
|
|
11905
12369
|
case 4:
|
|
11906
12370
|
return Math.max(...xs);
|
|
11907
12371
|
case 5:
|
|
11908
|
-
return Math.min(...xs);
|
|
11909
|
-
case 6:
|
|
11910
12372
|
return median2(xs);
|
|
12373
|
+
case 6:
|
|
12374
|
+
return Math.min(...xs);
|
|
11911
12375
|
default:
|
|
11912
12376
|
return xs.reduce((a2, b) => a2 + b, 0);
|
|
11913
12377
|
}
|
|
@@ -14585,7 +15049,7 @@ var ENGLISH_PIVOT_CAPTIONS = {
|
|
|
14585
15049
|
functions: FUNCTIONS,
|
|
14586
15050
|
aggregates: aggregateNames()
|
|
14587
15051
|
};
|
|
14588
|
-
var fillCaption = (
|
|
15052
|
+
var fillCaption = (template2, ...args) => template2.replace(/\{(\d)\}/g, (_match, at2) => args[Number(at2)] ?? "");
|
|
14589
15053
|
function pivotCaptions(pivot) {
|
|
14590
15054
|
const own = pivot.captions;
|
|
14591
15055
|
if (!own) return ENGLISH_PIVOT_CAPTIONS;
|
|
@@ -15342,8 +15806,8 @@ var DIV0 = { error: "#DIV/0!" };
|
|
|
15342
15806
|
function variance2(numbers3, sample) {
|
|
15343
15807
|
const n2 = numbers3.length;
|
|
15344
15808
|
if (n2 < (sample ? 2 : 1)) return DIV0;
|
|
15345
|
-
const
|
|
15346
|
-
const squares = numbers3.reduce((total2, value2) => total2 + (value2 -
|
|
15809
|
+
const mean9 = numbers3.reduce((total2, value2) => total2 + value2, 0) / n2;
|
|
15810
|
+
const squares = numbers3.reduce((total2, value2) => total2 + (value2 - mean9) ** 2, 0);
|
|
15347
15811
|
return squares / (sample ? n2 - 1 : n2);
|
|
15348
15812
|
}
|
|
15349
15813
|
function aggregateValues(records, field, type) {
|
|
@@ -17008,11 +17472,11 @@ var ParseCache = class {
|
|
|
17008
17472
|
parseNew(formula2) {
|
|
17009
17473
|
if (formula2.length > MAX_TEMPLATE_LENGTH) return treeOf(makeTemplate(formula2, NO_RUNS));
|
|
17010
17474
|
const shape2 = formulaShape(formula2);
|
|
17011
|
-
const
|
|
17012
|
-
const reused =
|
|
17475
|
+
const template2 = this.templates.get(shape2.hash);
|
|
17476
|
+
const reused = template2 && fromTemplate(template2, formula2, shape2);
|
|
17013
17477
|
if (reused) return reused;
|
|
17014
17478
|
const made = makeTemplate(formula2, shape2);
|
|
17015
|
-
if (!
|
|
17479
|
+
if (!template2 && "ast" in made) {
|
|
17016
17480
|
if (this.templates.size > MAX_TEMPLATES) this.templates.clear();
|
|
17017
17481
|
this.templates.set(shape2.hash, made);
|
|
17018
17482
|
}
|
|
@@ -17730,22 +18194,22 @@ function astTraits(ast) {
|
|
|
17730
18194
|
traitsCache.set(ast, traits);
|
|
17731
18195
|
return traits;
|
|
17732
18196
|
}
|
|
17733
|
-
function intervalDelta(a2, b,
|
|
17734
|
-
const { at: at2, count: count2 } =
|
|
18197
|
+
function intervalDelta(a2, b, shift3) {
|
|
18198
|
+
const { at: at2, count: count2 } = shift3;
|
|
17735
18199
|
if (count2 > 0) {
|
|
17736
18200
|
if (b < at2) return 0;
|
|
17737
18201
|
if (a2 < at2) return void 0;
|
|
17738
|
-
return b + count2 > (
|
|
18202
|
+
return b + count2 > (shift3.axis === "row" ? MAX_ROW : MAX_COL) ? void 0 : count2;
|
|
17739
18203
|
}
|
|
17740
18204
|
const last = at2 - count2 - 1;
|
|
17741
18205
|
if (b < at2) return 0;
|
|
17742
18206
|
if (a2 > last) return count2;
|
|
17743
18207
|
return void 0;
|
|
17744
18208
|
}
|
|
17745
|
-
function areaDelta(area, sheet,
|
|
18209
|
+
function areaDelta(area, sheet, shift3) {
|
|
17746
18210
|
if (area.sheet !== sheet) return 0;
|
|
17747
18211
|
const { start, end } = area.range;
|
|
17748
|
-
return
|
|
18212
|
+
return shift3.axis === "row" ? intervalDelta(start.row, end.row, shift3) : intervalDelta(start.col, end.col, shift3);
|
|
17749
18213
|
}
|
|
17750
18214
|
function movedRange(range, axis, delta) {
|
|
17751
18215
|
if (delta === 0) return range;
|
|
@@ -17757,10 +18221,10 @@ function movedRange(range, axis, delta) {
|
|
|
17757
18221
|
end: { row: range.end.row, col: range.end.col + delta }
|
|
17758
18222
|
};
|
|
17759
18223
|
}
|
|
17760
|
-
function reachesEdit(areas, sheet,
|
|
18224
|
+
function reachesEdit(areas, sheet, shift3) {
|
|
17761
18225
|
for (const area of areas) {
|
|
17762
18226
|
if (area.sheet !== sheet) continue;
|
|
17763
|
-
if ((
|
|
18227
|
+
if ((shift3.axis === "row" ? area.range.end.row : area.range.end.col) >= shift3.at) return true;
|
|
17764
18228
|
}
|
|
17765
18229
|
return false;
|
|
17766
18230
|
}
|
|
@@ -17809,8 +18273,8 @@ var EngineStructure = class extends EngineCore {
|
|
|
17809
18273
|
* changed (cells moved, formulas rewritten). Spills on the sheet, array formulas the edit cuts
|
|
17810
18274
|
* and anything unexpected fall back to a rebuild on the next recalculation.
|
|
17811
18275
|
*/
|
|
17812
|
-
shiftCells(sheet,
|
|
17813
|
-
if (!this.graphReady() || !this.shiftable(sheet,
|
|
18276
|
+
shiftCells(sheet, shift3) {
|
|
18277
|
+
if (!this.graphReady() || !this.shiftable(sheet, shift3)) {
|
|
17814
18278
|
this.invalidate();
|
|
17815
18279
|
return;
|
|
17816
18280
|
}
|
|
@@ -17821,15 +18285,15 @@ var EngineStructure = class extends EngineCore {
|
|
|
17821
18285
|
if (own) {
|
|
17822
18286
|
const next = /* @__PURE__ */ new Map();
|
|
17823
18287
|
for (const node2 of own.values()) {
|
|
17824
|
-
const pos =
|
|
17825
|
-
const delta = intervalDelta(pos, pos,
|
|
18288
|
+
const pos = shift3.axis === "row" ? node2.row : node2.col;
|
|
18289
|
+
const delta = intervalDelta(pos, pos, shift3);
|
|
17826
18290
|
if (delta === void 0) {
|
|
17827
18291
|
this.dropNode(node2);
|
|
17828
18292
|
continue;
|
|
17829
18293
|
}
|
|
17830
18294
|
if (delta !== 0) {
|
|
17831
18295
|
moved.set(node2, delta);
|
|
17832
|
-
if (
|
|
18296
|
+
if (shift3.axis === "row") node2.row += delta;
|
|
17833
18297
|
else node2.col += delta;
|
|
17834
18298
|
}
|
|
17835
18299
|
next.set(cellKey(node2.row, node2.col), node2);
|
|
@@ -17838,7 +18302,7 @@ var EngineStructure = class extends EngineCore {
|
|
|
17838
18302
|
}
|
|
17839
18303
|
for (const map of this.nodes.values())
|
|
17840
18304
|
for (const node2 of map.values()) {
|
|
17841
|
-
if (!this.shiftNode(node2, sheet,
|
|
18305
|
+
if (!this.shiftNode(node2, sheet, shift3, moved.get(node2) ?? 0)) {
|
|
17842
18306
|
this.invalidate();
|
|
17843
18307
|
return;
|
|
17844
18308
|
}
|
|
@@ -17847,11 +18311,11 @@ var EngineStructure = class extends EngineCore {
|
|
|
17847
18311
|
this.graphChanged();
|
|
17848
18312
|
}
|
|
17849
18313
|
/** No spill or stale spilled value on the sheet, and no array formula the edit cuts. */
|
|
17850
|
-
shiftable(sheet,
|
|
18314
|
+
shiftable(sheet, shift3) {
|
|
17851
18315
|
for (const node2 of this.footprints) {
|
|
17852
18316
|
if (node2.sheet !== sheet) continue;
|
|
17853
18317
|
if (node2.spill || node2.blockedSpill) return false;
|
|
17854
|
-
if (node2.arrayRange && areaDelta({ sheet, range: node2.arrayRange }, sheet,
|
|
18318
|
+
if (node2.arrayRange && areaDelta({ sheet, range: node2.arrayRange }, sheet, shift3) === void 0)
|
|
17855
18319
|
return false;
|
|
17856
18320
|
}
|
|
17857
18321
|
const ws = this.workbook.sheets[sheet];
|
|
@@ -17867,19 +18331,19 @@ var EngineStructure = class extends EngineCore {
|
|
|
17867
18331
|
this.footprints.delete(node2);
|
|
17868
18332
|
}
|
|
17869
18333
|
/** Updates one formula for the edit; false when the graph cannot follow it. */
|
|
17870
|
-
shiftNode(node2, sheet,
|
|
18334
|
+
shiftNode(node2, sheet, shift3, nodeDelta) {
|
|
17871
18335
|
const cell = this.workbook.sheets[node2.sheet]?.rows.get(node2.row)?.get(node2.col);
|
|
17872
18336
|
if (cell?.formula === void 0) return false;
|
|
17873
18337
|
if (node2.arrayRange) {
|
|
17874
|
-
const delta = areaDelta({ sheet: node2.sheet, range: node2.arrayRange }, sheet,
|
|
18338
|
+
const delta = areaDelta({ sheet: node2.sheet, range: node2.arrayRange }, sheet, shift3);
|
|
17875
18339
|
if (delta === void 0) return false;
|
|
17876
|
-
node2.arrayRange = movedRange(node2.arrayRange,
|
|
18340
|
+
node2.arrayRange = movedRange(node2.arrayRange, shift3.axis, delta);
|
|
17877
18341
|
if (!cell.arrayRange || !sameRange(node2.arrayRange, normalizeRange(cell.arrayRange)))
|
|
17878
18342
|
return false;
|
|
17879
18343
|
}
|
|
17880
18344
|
const changed = cell.formula !== node2.formula;
|
|
17881
18345
|
const traits = node2.ast && astTraits(node2.ast);
|
|
17882
|
-
const reached = reachesEdit(node2.deps, sheet,
|
|
18346
|
+
const reached = reachesEdit(node2.deps, sheet, shift3) || reachesEdit(node2.dynamicDeps, sheet, shift3);
|
|
17883
18347
|
if (!changed && !reached && nodeDelta === 0 && !traits?.descriptive && !traits?.opaque)
|
|
17884
18348
|
return true;
|
|
17885
18349
|
if (traits?.complex) {
|
|
@@ -17888,10 +18352,10 @@ var EngineStructure = class extends EngineCore {
|
|
|
17888
18352
|
this.structuralSeeds.add(node2);
|
|
17889
18353
|
return true;
|
|
17890
18354
|
}
|
|
17891
|
-
const pos =
|
|
18355
|
+
const pos = shift3.axis === "row" ? node2.row - nodeDelta : node2.col - nodeDelta;
|
|
17892
18356
|
const moves = { seed: !!traits?.descriptive, moved: false, cut: false };
|
|
17893
|
-
const deps = this.moveAreas(node2.deps, sheet,
|
|
17894
|
-
const dynamicDeps = this.moveAreas(node2.dynamicDeps, sheet,
|
|
18357
|
+
const deps = this.moveAreas(node2.deps, sheet, shift3, pos, nodeDelta, moves);
|
|
18358
|
+
const dynamicDeps = this.moveAreas(node2.dynamicDeps, sheet, shift3, pos, nodeDelta, moves);
|
|
17895
18359
|
const { cut, moved: anyMoved } = moves;
|
|
17896
18360
|
let seed = moves.seed;
|
|
17897
18361
|
if (cut || changed !== anyMoved) {
|
|
@@ -17915,20 +18379,20 @@ var EngineStructure = class extends EngineCore {
|
|
|
17915
18379
|
* moved, one was cut (deleted, widened, pushed off the grid) and whether implicit intersection
|
|
17916
18380
|
* with one can now pick another cell.
|
|
17917
18381
|
*/
|
|
17918
|
-
moveAreas(list3, sheet,
|
|
18382
|
+
moveAreas(list3, sheet, shift3, pos, nodeDelta, moves) {
|
|
17919
18383
|
let out;
|
|
17920
18384
|
for (let i2 = 0; i2 < list3.length; i2++) {
|
|
17921
18385
|
const area = list3[i2];
|
|
17922
|
-
const delta = areaDelta(area, sheet,
|
|
18386
|
+
const delta = areaDelta(area, sheet, shift3);
|
|
17923
18387
|
if (delta === void 0) {
|
|
17924
18388
|
moves.cut = true;
|
|
17925
18389
|
continue;
|
|
17926
18390
|
}
|
|
17927
|
-
if (intersectionMoves(area, delta, pos, nodeDelta,
|
|
18391
|
+
if (intersectionMoves(area, delta, pos, nodeDelta, shift3.axis)) moves.seed = true;
|
|
17928
18392
|
if (delta === 0) continue;
|
|
17929
18393
|
moves.moved = true;
|
|
17930
18394
|
out ??= list3.slice();
|
|
17931
|
-
out[i2] = { sheet: area.sheet, range: movedRange(area.range,
|
|
18395
|
+
out[i2] = { sheet: area.sheet, range: movedRange(area.range, shift3.axis, delta) };
|
|
17932
18396
|
}
|
|
17933
18397
|
return out ?? list3;
|
|
17934
18398
|
}
|
|
@@ -18240,9 +18704,9 @@ function prefixText(prefix) {
|
|
|
18240
18704
|
// xlsx/formula/shift-formula.ts
|
|
18241
18705
|
var templates = /* @__PURE__ */ new Map();
|
|
18242
18706
|
var MAX_TEMPLATES2 = 2e5;
|
|
18243
|
-
function remember(text3,
|
|
18707
|
+
function remember(text3, template2) {
|
|
18244
18708
|
if (templates.size >= MAX_TEMPLATES2) templates.clear();
|
|
18245
|
-
templates.set(text3,
|
|
18709
|
+
templates.set(text3, template2);
|
|
18246
18710
|
}
|
|
18247
18711
|
function mergeSpacedAreas(tokens2) {
|
|
18248
18712
|
const out = [];
|
|
@@ -18273,16 +18737,16 @@ function templateOf(formula2) {
|
|
|
18273
18737
|
const cached = templates.get(formula2);
|
|
18274
18738
|
if (cached !== void 0) return cached;
|
|
18275
18739
|
const raw2 = safeTokens(formula2);
|
|
18276
|
-
let
|
|
18740
|
+
let template2 = null;
|
|
18277
18741
|
if (raw2) {
|
|
18278
|
-
|
|
18742
|
+
template2 = [];
|
|
18279
18743
|
let literal3 = "";
|
|
18280
18744
|
for (const token2 of mergeSpacedAreas(raw2)) {
|
|
18281
18745
|
if (token2.kind !== "ref" && !(token2.kind === "name" && token2.prefix)) {
|
|
18282
18746
|
literal3 += token2.text;
|
|
18283
18747
|
continue;
|
|
18284
18748
|
}
|
|
18285
|
-
if (literal3)
|
|
18749
|
+
if (literal3) template2.push(literal3);
|
|
18286
18750
|
literal3 = "";
|
|
18287
18751
|
const part = { kind: token2.kind, text: token2.text };
|
|
18288
18752
|
if (token2.prefix) {
|
|
@@ -18291,23 +18755,23 @@ function templateOf(formula2) {
|
|
|
18291
18755
|
}
|
|
18292
18756
|
if (token2.ref) part.ref = token2.ref;
|
|
18293
18757
|
if (token2.spill) part.spill = true;
|
|
18294
|
-
|
|
18758
|
+
template2.push(part);
|
|
18295
18759
|
}
|
|
18296
|
-
if (literal3)
|
|
18760
|
+
if (literal3) template2.push(literal3);
|
|
18297
18761
|
}
|
|
18298
|
-
remember(formula2,
|
|
18299
|
-
return
|
|
18762
|
+
remember(formula2, template2);
|
|
18763
|
+
return template2;
|
|
18300
18764
|
}
|
|
18301
18765
|
function rewriteTemplate(formula2, rewrite2) {
|
|
18302
|
-
const
|
|
18303
|
-
if (!
|
|
18766
|
+
const template2 = templateOf(formula2);
|
|
18767
|
+
if (!template2) return formula2;
|
|
18304
18768
|
let next;
|
|
18305
|
-
for (let i2 = 0; i2 <
|
|
18306
|
-
const part =
|
|
18769
|
+
for (let i2 = 0; i2 < template2.length; i2++) {
|
|
18770
|
+
const part = template2[i2];
|
|
18307
18771
|
if (typeof part === "string") continue;
|
|
18308
18772
|
const changed = rewrite2(part);
|
|
18309
18773
|
if (!changed) continue;
|
|
18310
|
-
next ??=
|
|
18774
|
+
next ??= template2.slice();
|
|
18311
18775
|
next[i2] = changed;
|
|
18312
18776
|
}
|
|
18313
18777
|
if (!next) return formula2;
|
|
@@ -19941,9 +20405,9 @@ function aggregateCaptionsOf(pivot) {
|
|
|
19941
20405
|
]) {
|
|
19942
20406
|
const at2 = measure4.caption.indexOf(measure4.field);
|
|
19943
20407
|
if (at2 < 0 || measure4.caption === measure4.field) continue;
|
|
19944
|
-
const
|
|
19945
|
-
if (
|
|
19946
|
-
out[measure4.aggregate] =
|
|
20408
|
+
const template2 = `${measure4.caption.slice(0, at2)}{0}${measure4.caption.slice(at2 + measure4.field.length)}`;
|
|
20409
|
+
if (template2 !== ENGLISH_PIVOT_CAPTIONS.aggregates[measure4.aggregate])
|
|
20410
|
+
out[measure4.aggregate] = template2;
|
|
19947
20411
|
}
|
|
19948
20412
|
return Object.keys(out).length ? out : void 0;
|
|
19949
20413
|
}
|
|
@@ -30473,7 +30937,8 @@ var pie = {
|
|
|
30473
30937
|
gd16("stAng", "pin 0 adj1 21599999"),
|
|
30474
30938
|
gd16("endAng", "pin 0 adj2 21599999"),
|
|
30475
30939
|
gd16("swAng", "+- endAng 0 stAng"),
|
|
30476
|
-
gd16("
|
|
30940
|
+
gd16("swAngWrap", "+- swAng 21600000 0"),
|
|
30941
|
+
gd16("swAng2", "?: swAng swAng swAngWrap"),
|
|
30477
30942
|
gd16("stx", "cos wd2 stAng"),
|
|
30478
30943
|
gd16("sty", "sin hd2 stAng"),
|
|
30479
30944
|
gd16("x1", "+- hc stx 0"),
|
|
@@ -30518,7 +30983,8 @@ var chord = {
|
|
|
30518
30983
|
gd16("stAng", "pin 0 adj1 21599999"),
|
|
30519
30984
|
gd16("endAng", "pin 0 adj2 21599999"),
|
|
30520
30985
|
gd16("swAng", "+- endAng 0 stAng"),
|
|
30521
|
-
gd16("
|
|
30986
|
+
gd16("swAngWrap", "+- swAng 21600000 0"),
|
|
30987
|
+
gd16("swAng2", "?: swAng swAng swAngWrap"),
|
|
30522
30988
|
gd16("stx", "cos wd2 stAng"),
|
|
30523
30989
|
gd16("sty", "sin hd2 stAng"),
|
|
30524
30990
|
gd16("x1", "+- hc stx 0"),
|
|
@@ -30542,7 +31008,8 @@ var arc = {
|
|
|
30542
31008
|
gd16("stAng", "pin 0 adj1 21599999"),
|
|
30543
31009
|
gd16("endAng", "pin 0 adj2 21599999"),
|
|
30544
31010
|
gd16("swAng", "+- endAng 0 stAng"),
|
|
30545
|
-
gd16("
|
|
31011
|
+
gd16("swAngWrap", "+- swAng 21600000 0"),
|
|
31012
|
+
gd16("swAng2", "?: swAng swAng swAngWrap"),
|
|
30546
31013
|
gd16("stx", "cos wd2 stAng"),
|
|
30547
31014
|
gd16("sty", "sin hd2 stAng"),
|
|
30548
31015
|
gd16("x1", "+- hc stx 0"),
|
|
@@ -30637,7 +31104,8 @@ var blockArc = {
|
|
|
30637
31104
|
gd16("iwd2", "+- wd2 0 thw"),
|
|
30638
31105
|
gd16("ihd2", "+- hd2 0 thh2"),
|
|
30639
31106
|
gd16("swAng", "+- endAng 0 stAng"),
|
|
30640
|
-
gd16("
|
|
31107
|
+
gd16("swAngWrap", "+- swAng 21600000 0"),
|
|
31108
|
+
gd16("swAng2", "?: swAng swAng swAngWrap"),
|
|
30641
31109
|
gd16("mswAng", "+- 0 0 swAng2"),
|
|
30642
31110
|
gd16("stx", "cos wd2 stAng"),
|
|
30643
31111
|
gd16("sty", "sin hd2 stAng"),
|
|
@@ -38762,8 +39230,8 @@ function writeDiagramFormatDefinition(source3, change) {
|
|
|
38762
39230
|
(entry3) => entry3.id === change.value
|
|
38763
39231
|
))
|
|
38764
39232
|
throw new RangeError("Unknown SmartArt format preset.");
|
|
38765
|
-
const
|
|
38766
|
-
const fresh = parseXml(
|
|
39233
|
+
const template2 = change.kind === "colors" ? buildFabricatedColorsXml(change.value) : buildFabricatedQuickStyleXml(change.value);
|
|
39234
|
+
const fresh = parseXml(template2).documentElement;
|
|
38767
39235
|
if (!source3) {
|
|
38768
39236
|
fresh.setAttribute("uniqueId", `urn:ooxml-core/${change.kind}/${change.value}`);
|
|
38769
39237
|
return buildXml(fresh);
|
|
@@ -40645,8 +41113,8 @@ function buildGeneratedDiagramCache(dataXml2, input) {
|
|
|
40645
41113
|
);
|
|
40646
41114
|
const direct = model2.nodes.find((node2) => node2.modelId === shape2.sourceNodeId);
|
|
40647
41115
|
const fillIndex = shape2.style?.fill?.index;
|
|
40648
|
-
const
|
|
40649
|
-
if (!direct?.fill && shape2.fill?.kind === "solid" && shape2.fill.color.kind === "srgb" && (!
|
|
41116
|
+
const template2 = fillIndex ? input.formatScheme?.fillStyles[fillIndex - 1]?.fill : void 0;
|
|
41117
|
+
if (!direct?.fill && shape2.fill?.kind === "solid" && shape2.fill.color.kind === "srgb" && (!template2 || template2.kind === "solid" && template2.color.kind === "scheme" && template2.color.value === "phClr")) {
|
|
40650
41118
|
const original = themed.get(`#${shape2.fill.color.value}`.toUpperCase());
|
|
40651
41119
|
if (original)
|
|
40652
41120
|
shape2.fill.color = {
|
|
@@ -40654,9 +41122,9 @@ function buildGeneratedDiagramCache(dataXml2, input) {
|
|
|
40654
41122
|
transforms: [...original.transforms, ...shape2.fill.color.transforms]
|
|
40655
41123
|
};
|
|
40656
41124
|
}
|
|
40657
|
-
if (!direct?.fill && shape2.fill?.kind === "gradient" &&
|
|
41125
|
+
if (!direct?.fill && shape2.fill?.kind === "gradient" && template2?.kind === "gradient") {
|
|
40658
41126
|
shape2.fill.stops.forEach((stop, index3) => {
|
|
40659
|
-
const authored =
|
|
41127
|
+
const authored = template2.stops[index3]?.color;
|
|
40660
41128
|
if (authored?.kind === "scheme" && authored.value === "phClr" && stop.color.kind === "srgb") {
|
|
40661
41129
|
const original = themed.get(`#${stop.color.value}`.toUpperCase());
|
|
40662
41130
|
if (original)
|
|
@@ -45740,7 +46208,12 @@ function vmlCaption(vml, shapeId) {
|
|
|
45740
46208
|
const shape2 = vml.slice(start, end < 0 ? void 0 : end);
|
|
45741
46209
|
const box2 = /<v:textbox[^>]*>([\s\S]*?)<\/v:textbox>/.exec(shape2)?.[1];
|
|
45742
46210
|
if (!box2) return void 0;
|
|
45743
|
-
|
|
46211
|
+
let stripped = box2.replace(/<br\s*\/?>/gi, "\n");
|
|
46212
|
+
for (let prev = ""; prev !== stripped; ) {
|
|
46213
|
+
prev = stripped;
|
|
46214
|
+
stripped = stripped.replace(/<[^>]*>/g, "");
|
|
46215
|
+
}
|
|
46216
|
+
const text3 = stripped.replace(/&(#x?[0-9a-f]+|\w+);/gi, (match2, code) => {
|
|
45744
46217
|
if (code.startsWith("#")) {
|
|
45745
46218
|
const value2 = code[1]?.toLowerCase() === "x" ? parseInt(code.slice(2), 16) : Number(code.slice(1));
|
|
45746
46219
|
return Number.isFinite(value2) ? String.fromCodePoint(value2) : match2;
|
|
@@ -49273,12 +49746,12 @@ function reanchor(xml, anchor) {
|
|
|
49273
49746
|
).documentElement;
|
|
49274
49747
|
for (const candidate of Array.from(holder.childNodes)) {
|
|
49275
49748
|
if (candidate.nodeType !== 1) continue;
|
|
49276
|
-
const
|
|
49277
|
-
const original = first(old,
|
|
49278
|
-
const position2 = original ? original.cloneNode(true) : doc.importNode(
|
|
49279
|
-
for (const attribute2 of Array.from(
|
|
49749
|
+
const template2 = candidate;
|
|
49750
|
+
const original = first(old, template2.localName, NS.xdr);
|
|
49751
|
+
const position2 = original ? original.cloneNode(true) : doc.importNode(template2, true);
|
|
49752
|
+
for (const attribute2 of Array.from(template2.attributes))
|
|
49280
49753
|
position2.setAttribute(attribute2.name, attribute2.value);
|
|
49281
|
-
for (const value2 of Array.from(
|
|
49754
|
+
for (const value2 of Array.from(template2.childNodes)) {
|
|
49282
49755
|
if (value2.nodeType !== 1) continue;
|
|
49283
49756
|
const item2 = value2;
|
|
49284
49757
|
const existing = first(position2, item2.localName, NS.xdr);
|
|
@@ -49481,9 +49954,9 @@ function writeDrawing(writer, partName, objects, sourceDrawing, context) {
|
|
|
49481
49954
|
|
|
49482
49955
|
// xlsx/edit/range-math.ts
|
|
49483
49956
|
var axisMax = (axis) => axis === "row" ? MAX_ROW : MAX_COL;
|
|
49484
|
-
function shiftSpan(start, end,
|
|
49485
|
-
const { at: at2, count: count2 } =
|
|
49486
|
-
const max = axisMax(
|
|
49957
|
+
function shiftSpan(start, end, shift3) {
|
|
49958
|
+
const { at: at2, count: count2 } = shift3;
|
|
49959
|
+
const max = axisMax(shift3.axis);
|
|
49487
49960
|
if (count2 > 0) {
|
|
49488
49961
|
if (start >= at2) {
|
|
49489
49962
|
if (start + count2 > max) return void 0;
|
|
@@ -49499,35 +49972,35 @@ function shiftSpan(start, end, shift2) {
|
|
|
49499
49972
|
const e = end >= max ? max : end < at2 ? end : end > last ? end - n2 : at2 - 1;
|
|
49500
49973
|
return s > e ? void 0 : { start: s, end: e };
|
|
49501
49974
|
}
|
|
49502
|
-
function shiftIndex(index3,
|
|
49503
|
-
const { at: at2, count: count2 } =
|
|
49975
|
+
function shiftIndex(index3, shift3) {
|
|
49976
|
+
const { at: at2, count: count2 } = shift3;
|
|
49504
49977
|
if (index3 < at2) return index3;
|
|
49505
|
-
if (count2 > 0) return index3 + count2 > axisMax(
|
|
49978
|
+
if (count2 > 0) return index3 + count2 > axisMax(shift3.axis) ? void 0 : index3 + count2;
|
|
49506
49979
|
return index3 < at2 - count2 ? void 0 : index3 + count2;
|
|
49507
49980
|
}
|
|
49508
|
-
function shiftIndexClamped(index3,
|
|
49509
|
-
const moved = shiftIndex(index3,
|
|
49981
|
+
function shiftIndexClamped(index3, shift3) {
|
|
49982
|
+
const moved = shiftIndex(index3, shift3);
|
|
49510
49983
|
if (moved !== void 0) return moved;
|
|
49511
|
-
return
|
|
49984
|
+
return shift3.count > 0 ? axisMax(shift3.axis) : shift3.at;
|
|
49512
49985
|
}
|
|
49513
|
-
function shiftRange(range,
|
|
49514
|
-
if (
|
|
49515
|
-
const span5 = shiftSpan(range.start.row, range.end.row,
|
|
49986
|
+
function shiftRange(range, shift3) {
|
|
49987
|
+
if (shift3.axis === "row") {
|
|
49988
|
+
const span5 = shiftSpan(range.start.row, range.end.row, shift3);
|
|
49516
49989
|
return span5 && {
|
|
49517
49990
|
start: { row: span5.start, col: range.start.col },
|
|
49518
49991
|
end: { row: span5.end, col: range.end.col }
|
|
49519
49992
|
};
|
|
49520
49993
|
}
|
|
49521
|
-
const span4 = shiftSpan(range.start.col, range.end.col,
|
|
49994
|
+
const span4 = shiftSpan(range.start.col, range.end.col, shift3);
|
|
49522
49995
|
return span4 && {
|
|
49523
49996
|
start: { row: range.start.row, col: span4.start },
|
|
49524
49997
|
end: { row: range.end.row, col: span4.end }
|
|
49525
49998
|
};
|
|
49526
49999
|
}
|
|
49527
|
-
function shiftRangeInBand(range,
|
|
49528
|
-
const other =
|
|
50000
|
+
function shiftRangeInBand(range, shift3, lo, hi) {
|
|
50001
|
+
const other = shift3.axis === "row" ? "col" : "row";
|
|
49529
50002
|
if (range.end[other] < lo || range.start[other] > hi) return range;
|
|
49530
|
-
if (range.start[other] >= lo && range.end[other] <= hi) return shiftRange(range,
|
|
50003
|
+
if (range.start[other] >= lo && range.end[other] <= hi) return shiftRange(range, shift3);
|
|
49531
50004
|
return range;
|
|
49532
50005
|
}
|
|
49533
50006
|
function subtractRange(a2, b) {
|
|
@@ -49558,7 +50031,7 @@ function pointsAt(token2, formulaSheet, sheet) {
|
|
|
49558
50031
|
if (!prefix) return formulaSheet.toLowerCase() === sheet.toLowerCase();
|
|
49559
50032
|
return prefix.book === void 0 && prefix.sheet2 === void 0 && prefix.sheet.toLowerCase() === sheet.toLowerCase();
|
|
49560
50033
|
}
|
|
49561
|
-
function shiftFormulaInBand(formula2, formulaSheet, sheet,
|
|
50034
|
+
function shiftFormulaInBand(formula2, formulaSheet, sheet, shift3, band) {
|
|
49562
50035
|
let tokens2;
|
|
49563
50036
|
try {
|
|
49564
50037
|
tokens2 = tokenize(formula2);
|
|
@@ -49579,7 +50052,7 @@ function shiftFormulaInBand(formula2, formulaSheet, sheet, shift2, band) {
|
|
|
49579
50052
|
},
|
|
49580
50053
|
end: { row: Math.max(ref.start.row, ref.end.row), col: Math.max(ref.start.col, ref.end.col) }
|
|
49581
50054
|
};
|
|
49582
|
-
const moved = shiftRangeInBand(range,
|
|
50055
|
+
const moved = shiftRangeInBand(range, shift3, band.lo, band.hi);
|
|
49583
50056
|
if (moved && sameRange2(moved, range)) continue;
|
|
49584
50057
|
const prefix = token2.prefix?.text ?? "";
|
|
49585
50058
|
if (!moved) {
|
|
@@ -49617,15 +50090,15 @@ function carriedRefEdits(sourceSheets, currentSheets, shiftsOf = () => []) {
|
|
|
49617
50090
|
edits.deleted.push(source3.name);
|
|
49618
50091
|
continue;
|
|
49619
50092
|
}
|
|
49620
|
-
for (const
|
|
50093
|
+
for (const shift3 of shiftsOf(current)) edits.shifts.push({ sheet: source3.name, shift: shift3 });
|
|
49621
50094
|
if (current.name !== source3.name) edits.renamed.push([source3.name, current.name]);
|
|
49622
50095
|
}
|
|
49623
50096
|
return edits;
|
|
49624
50097
|
}
|
|
49625
50098
|
var hasCarriedRefEdits = (edits) => edits.shifts.length > 0 || edits.deleted.length > 0 || edits.renamed.length > 0;
|
|
49626
|
-
function shiftOne(formula2, formulaSheet, sheet,
|
|
49627
|
-
if (
|
|
49628
|
-
const spec2 = { sheet, axis:
|
|
50099
|
+
function shiftOne(formula2, formulaSheet, sheet, shift3) {
|
|
50100
|
+
if (shift3.band) return shiftFormulaInBand(formula2, formulaSheet, sheet, shift3, shift3.band);
|
|
50101
|
+
const spec2 = { sheet, axis: shift3.axis, at: shift3.at, count: shift3.count };
|
|
49629
50102
|
return shiftFormula(formula2, formulaSheet, spec2);
|
|
49630
50103
|
}
|
|
49631
50104
|
function renameAll(formula2, renamed, taken) {
|
|
@@ -49648,7 +50121,7 @@ var takenNames = (edits) => new Set(
|
|
|
49648
50121
|
);
|
|
49649
50122
|
function patchCarriedFormula(formula2, formulaSheet, edits) {
|
|
49650
50123
|
let out = formula2;
|
|
49651
|
-
for (const { sheet, shift:
|
|
50124
|
+
for (const { sheet, shift: shift3 } of edits.shifts) out = shiftOne(out, formulaSheet, sheet, shift3);
|
|
49652
50125
|
for (const sheet of edits.deleted) out = deleteSheetInFormula(out, sheet);
|
|
49653
50126
|
return renameAll(out, edits.renamed, takenNames(edits));
|
|
49654
50127
|
}
|
|
@@ -51504,7 +51977,7 @@ function addChartSeries(space, input) {
|
|
|
51504
51977
|
const group2 = groups.find((_, i2) => i2 === (input.groupIndex ?? groups.length - 1));
|
|
51505
51978
|
if (!group2) throw new RangeError("The chart has no chart group to add a series to");
|
|
51506
51979
|
const all2 = chartSpaceSeries(draft);
|
|
51507
|
-
const
|
|
51980
|
+
const template2 = all2[0];
|
|
51508
51981
|
const series = {
|
|
51509
51982
|
index: nextNumber(all2.map((item2) => item2.index)),
|
|
51510
51983
|
order: nextNumber(all2.map((item2) => item2.order)),
|
|
@@ -51521,7 +51994,7 @@ function addChartSeries(space, input) {
|
|
|
51521
51994
|
};
|
|
51522
51995
|
else if (input.name !== void 0) series.tx = { value: input.name, text: input.name };
|
|
51523
51996
|
if (input.spPr) series.spPr = structuredClone(input.spPr);
|
|
51524
|
-
const templateCategories =
|
|
51997
|
+
const templateCategories = template2?.categories ?? template2?.xValues;
|
|
51525
51998
|
if (input.categories !== void 0)
|
|
51526
51999
|
series[categoryKey(group2)] = categorySource(
|
|
51527
52000
|
input.categories,
|
|
@@ -53864,8 +54337,8 @@ async function saveXlsx(workbook) {
|
|
|
53864
54337
|
|
|
53865
54338
|
// xlsx/edit/shift-preserved.ts
|
|
53866
54339
|
var XM3 = "http://schemas.microsoft.com/office/excel/2006/main";
|
|
53867
|
-
function hasPreservedOverflow(sheet,
|
|
53868
|
-
const keys = banded ? ["extLst"] : [
|
|
54340
|
+
function hasPreservedOverflow(sheet, shift3, clipped, banded) {
|
|
54341
|
+
const keys = banded ? ["extLst"] : [shift3.axis === "row" ? "rowBreaks" : "colBreaks", "extLst"];
|
|
53869
54342
|
for (const key of keys)
|
|
53870
54343
|
for (const xml of sheet.preserved.get(key) ?? []) {
|
|
53871
54344
|
if (!xml.includes(key === "extLst" ? "sqref" : "brk")) continue;
|
|
@@ -53881,7 +54354,7 @@ function hasPreservedOverflow(sheet, shift2, clipped, banded) {
|
|
|
53881
54354
|
))
|
|
53882
54355
|
return true;
|
|
53883
54356
|
} else if (elements(root).some(
|
|
53884
|
-
(node2) => node2.localName === "brk" && shiftIndex(Number(node2.getAttribute("id") ?? "0"),
|
|
54357
|
+
(node2) => node2.localName === "brk" && shiftIndex(Number(node2.getAttribute("id") ?? "0"), shift3) === void 0
|
|
53885
54358
|
))
|
|
53886
54359
|
return true;
|
|
53887
54360
|
}
|
|
@@ -53913,11 +54386,11 @@ function editEntries(sheet, key, edit, quick) {
|
|
|
53913
54386
|
if (next.length) sheet.preserved.set(key, next);
|
|
53914
54387
|
else sheet.preserved.delete(key);
|
|
53915
54388
|
}
|
|
53916
|
-
function shiftBreaks(root,
|
|
54389
|
+
function shiftBreaks(root, shift3) {
|
|
53917
54390
|
let changed = false;
|
|
53918
54391
|
for (const brk of elements(root).filter((e) => e.localName === "brk")) {
|
|
53919
54392
|
const id = Number(brk.getAttribute("id") ?? "0");
|
|
53920
|
-
const moved = shiftIndex(id,
|
|
54393
|
+
const moved = shiftIndex(id, shift3);
|
|
53921
54394
|
if (moved === id) continue;
|
|
53922
54395
|
changed = true;
|
|
53923
54396
|
if (moved === void 0 || moved === 0) root.removeChild(brk);
|
|
@@ -53962,12 +54435,12 @@ function shiftSqrefs(root, moveRange) {
|
|
|
53962
54435
|
list3.setAttribute("count", String(elements(list3).length));
|
|
53963
54436
|
return elements(root).length > 0 ? "changed" : "drop";
|
|
53964
54437
|
}
|
|
53965
|
-
function shiftPreservedXml(sheet,
|
|
54438
|
+
function shiftPreservedXml(sheet, shift3, moveRange, banded) {
|
|
53966
54439
|
if (!banded)
|
|
53967
54440
|
editEntries(
|
|
53968
54441
|
sheet,
|
|
53969
|
-
|
|
53970
|
-
(root) => shiftBreaks(root,
|
|
54442
|
+
shift3.axis === "row" ? "rowBreaks" : "colBreaks",
|
|
54443
|
+
(root) => shiftBreaks(root, shift3),
|
|
53971
54444
|
(xml) => xml.includes("brk")
|
|
53972
54445
|
);
|
|
53973
54446
|
editEntries(
|
|
@@ -55122,25 +55595,25 @@ function setBorders(ctx, s, range, preset, edge3 = { style: "thin" }) {
|
|
|
55122
55595
|
}
|
|
55123
55596
|
|
|
55124
55597
|
// xlsx/edit/insert-guard.ts
|
|
55125
|
-
function assertInsertFits(sheet,
|
|
55598
|
+
function assertInsertFits(sheet, shift3, band) {
|
|
55126
55599
|
for (const pivot of sheet.pivotTables ?? []) {
|
|
55127
|
-
const start = pivot.location.start[
|
|
55128
|
-
const end = pivot.location.end[
|
|
55129
|
-
const other2 =
|
|
55600
|
+
const start = pivot.location.start[shift3.axis];
|
|
55601
|
+
const end = pivot.location.end[shift3.axis];
|
|
55602
|
+
const other2 = shift3.axis === "row" ? "col" : "row";
|
|
55130
55603
|
if (band && (band.hi < pivot.location.start[other2] || band.lo > pivot.location.end[other2]))
|
|
55131
55604
|
continue;
|
|
55132
55605
|
const partial = band && (band.lo > pivot.location.start[other2] || band.hi < pivot.location.end[other2]);
|
|
55133
|
-
const overlap =
|
|
55134
|
-
if (overlap || partial &&
|
|
55606
|
+
const overlap = shift3.count > 0 ? shift3.at > start && shift3.at <= end : shift3.at <= end && shift3.at - shift3.count > start;
|
|
55607
|
+
if (overlap || partial && shift3.at <= end)
|
|
55135
55608
|
throw new Error("Cannot move or remove part of a PivotTable. Delete the PivotTable first.");
|
|
55136
55609
|
}
|
|
55137
|
-
if (
|
|
55138
|
-
const max =
|
|
55139
|
-
if (
|
|
55610
|
+
if (shift3.count <= 0) return;
|
|
55611
|
+
const max = shift3.axis === "row" ? MAX_ROW : MAX_COL;
|
|
55612
|
+
if (shift3.at + shift3.count > max + 1)
|
|
55140
55613
|
throw new RangeError("The insert area extends beyond the sheet.");
|
|
55141
|
-
const first2 = max -
|
|
55142
|
-
const lost =
|
|
55143
|
-
const other =
|
|
55614
|
+
const first2 = max - shift3.count + 1;
|
|
55615
|
+
const lost = shift3.axis === "row" ? cellRange(first2, band?.lo ?? 0, MAX_ROW, band?.hi ?? MAX_COL) : cellRange(band?.lo ?? 0, first2, band?.hi ?? MAX_ROW, MAX_COL);
|
|
55616
|
+
const other = shift3.axis === "row" ? "col" : "row";
|
|
55144
55617
|
const clipped = (range) => (!band || range.start[other] >= band.lo && range.end[other] <= band.hi) && rangesIntersect(range, lost);
|
|
55145
55618
|
const fail2 = () => {
|
|
55146
55619
|
throw new Error("Cannot insert cells: non-empty cells would be pushed off the sheet.");
|
|
@@ -55151,14 +55624,14 @@ function assertInsertFits(sheet, shift2, band) {
|
|
|
55151
55624
|
if (col >= lost.start.col && col <= lost.end.col && (!isEmptyCell(cell) || cell.cellMetadata !== void 0 || cell.valueMetadata !== void 0))
|
|
55152
55625
|
fail2();
|
|
55153
55626
|
}
|
|
55154
|
-
if (sheet.comments.some((c2) => rangesIntersect(cellRange(c2.address.row, c2.address.col), lost)) || sheet.hyperlinks.some((h2) => rangesIntersect(h2.range, lost)) || sheet.merges.some((m) => rangesIntersect(m, lost)) || sheet.tables.some((t) => rangesIntersect(t.range, lost)) || sheet.dataValidations.some((rule) => rule.ranges.some(clipped)) || sheet.conditionalFormats.some((format) => format.ranges.some(clipped)) || sheet.autoFilter !== void 0 && clipped(sheet.autoFilter.range) || sheet.pageSetup?.printArea !== void 0 && clipped(sheet.pageSetup.printArea) || hasPreservedOverflow(sheet,
|
|
55627
|
+
if (sheet.comments.some((c2) => rangesIntersect(cellRange(c2.address.row, c2.address.col), lost)) || sheet.hyperlinks.some((h2) => rangesIntersect(h2.range, lost)) || sheet.merges.some((m) => rangesIntersect(m, lost)) || sheet.tables.some((t) => rangesIntersect(t.range, lost)) || sheet.dataValidations.some((rule) => rule.ranges.some(clipped)) || sheet.conditionalFormats.some((format) => format.ranges.some(clipped)) || sheet.autoFilter !== void 0 && clipped(sheet.autoFilter.range) || sheet.pageSetup?.printArea !== void 0 && clipped(sheet.pageSetup.printArea) || hasPreservedOverflow(sheet, shift3, clipped, !!band))
|
|
55155
55628
|
fail2();
|
|
55156
55629
|
for (const { anchor } of sheet.drawings) {
|
|
55157
55630
|
if (band && (anchor.from[other] < band.lo || anchor.from[other] > band.hi)) continue;
|
|
55158
|
-
if (anchor.from[
|
|
55631
|
+
if (anchor.from[shift3.axis] >= first2 || anchor.to && anchor.to[shift3.axis] >= first2) fail2();
|
|
55159
55632
|
}
|
|
55160
55633
|
if (band) return;
|
|
55161
|
-
if (
|
|
55634
|
+
if (shift3.axis === "row") {
|
|
55162
55635
|
for (const [row2, info] of sheet.rowInfo) if (row2 >= first2 && Object.keys(info).length) fail2();
|
|
55163
55636
|
} else {
|
|
55164
55637
|
if (normalizeColumns(sheet.columns).some((c2) => c2.min >= first2)) fail2();
|
|
@@ -55166,11 +55639,11 @@ function assertInsertFits(sheet, shift2, band) {
|
|
|
55166
55639
|
}
|
|
55167
55640
|
|
|
55168
55641
|
// xlsx/edit/shift-rule-anchors.ts
|
|
55169
|
-
function rebaseRulesForDeletion(sheet,
|
|
55170
|
-
if (
|
|
55171
|
-
const last =
|
|
55172
|
-
const removed =
|
|
55173
|
-
const other =
|
|
55642
|
+
function rebaseRulesForDeletion(sheet, shift3, band) {
|
|
55643
|
+
if (shift3.count >= 0) return;
|
|
55644
|
+
const last = shift3.at - shift3.count - 1;
|
|
55645
|
+
const removed = shift3.axis === "row" ? cellRange(shift3.at, band?.lo ?? 0, last, band?.hi ?? MAX_COL) : cellRange(band?.lo ?? 0, shift3.at, band?.hi ?? MAX_ROW, last);
|
|
55646
|
+
const other = shift3.axis === "row" ? "col" : "row";
|
|
55174
55647
|
const surviving = (ranges) => ranges.flatMap(
|
|
55175
55648
|
(range) => band && (range.start[other] < band.lo || range.end[other] > band.hi) ? [range] : subtractRange(range, removed)
|
|
55176
55649
|
);
|
|
@@ -55435,10 +55908,10 @@ function shiftScenarios(sheet, move) {
|
|
|
55435
55908
|
}
|
|
55436
55909
|
|
|
55437
55910
|
// xlsx/edit/shift-sheet.ts
|
|
55438
|
-
function shiftSheetContent(sheet,
|
|
55439
|
-
assertInsertFits(sheet,
|
|
55440
|
-
const moveRange = (range) => band ? shiftRangeInBand(range,
|
|
55441
|
-
shiftCells(sheet,
|
|
55911
|
+
function shiftSheetContent(sheet, shift3, band) {
|
|
55912
|
+
assertInsertFits(sheet, shift3, band);
|
|
55913
|
+
const moveRange = (range) => band ? shiftRangeInBand(range, shift3, band.lo, band.hi) : shiftRange(range, shift3);
|
|
55914
|
+
shiftCells(sheet, shift3, band, moveRange);
|
|
55442
55915
|
sheet.merges = sheet.merges.map(moveRange).filter((m) => !!m && (m.start.row !== m.end.row || m.start.col !== m.end.col));
|
|
55443
55916
|
sheet.conditionalFormats = sheet.conditionalFormats.map((cf) => ({ ...cf, ranges: cf.ranges.map(moveRange).filter((r) => !!r) })).filter((cf) => cf.ranges.length > 0);
|
|
55444
55917
|
sheet.dataValidations = sheet.dataValidations.map((dv) => ({ ...dv, ranges: dv.ranges.map(moveRange).filter((r) => !!r) })).filter((dv) => dv.ranges.length > 0);
|
|
@@ -55450,7 +55923,7 @@ function shiftSheetContent(sheet, shift2, band) {
|
|
|
55450
55923
|
const range = moveRange({ start: c2.address, end: c2.address });
|
|
55451
55924
|
return range ? [{ ...c2, address: range.start }] : [];
|
|
55452
55925
|
});
|
|
55453
|
-
sheet.tables = sheet.tables.flatMap((t) => shiftTable2(sheet, t,
|
|
55926
|
+
sheet.tables = sheet.tables.flatMap((t) => shiftTable2(sheet, t, shift3, moveRange));
|
|
55454
55927
|
shiftDataTables(sheet, moveRange);
|
|
55455
55928
|
shiftScenarios(sheet, moveRange);
|
|
55456
55929
|
for (const pivot of sheet.pivotTables ?? []) {
|
|
@@ -55460,8 +55933,8 @@ function shiftSheetContent(sheet, shift2, band) {
|
|
|
55460
55933
|
pivot.dirty = true;
|
|
55461
55934
|
}
|
|
55462
55935
|
}
|
|
55463
|
-
for (const drawing of sheet.drawings) shiftAnchor(drawing.anchor,
|
|
55464
|
-
if (!band) shiftAxisFormats(sheet,
|
|
55936
|
+
for (const drawing of sheet.drawings) shiftAnchor(drawing.anchor, shift3, band);
|
|
55937
|
+
if (!band) shiftAxisFormats(sheet, shift3);
|
|
55465
55938
|
if (sheet.autoFilter) {
|
|
55466
55939
|
const old = sheet.autoFilter.range;
|
|
55467
55940
|
const range = moveRange(old);
|
|
@@ -55470,39 +55943,39 @@ function shiftSheetContent(sheet, shift2, band) {
|
|
|
55470
55943
|
clearFilteredRows(sheet);
|
|
55471
55944
|
} else {
|
|
55472
55945
|
const filter2 = { ...sheet.autoFilter, range };
|
|
55473
|
-
if (
|
|
55946
|
+
if (shift3.axis === "col" && filter2.columns)
|
|
55474
55947
|
filter2.columns = filter2.columns.flatMap((fc) => {
|
|
55475
|
-
const abs2 = shiftIndex(old.start.col + fc.offset,
|
|
55948
|
+
const abs2 = shiftIndex(old.start.col + fc.offset, shift3);
|
|
55476
55949
|
return abs2 === void 0 ? [] : [{ ...fc, offset: abs2 - range.start.col }];
|
|
55477
55950
|
});
|
|
55478
55951
|
sheet.autoFilter = filter2;
|
|
55479
55952
|
}
|
|
55480
55953
|
}
|
|
55481
|
-
if (!band) shiftFreeze(sheet,
|
|
55954
|
+
if (!band) shiftFreeze(sheet, shift3);
|
|
55482
55955
|
const printArea = sheet.pageSetup?.printArea;
|
|
55483
55956
|
if (sheet.pageSetup && printArea) {
|
|
55484
55957
|
const moved = moveRange(printArea);
|
|
55485
55958
|
if (moved) sheet.pageSetup.printArea = moved;
|
|
55486
55959
|
else delete sheet.pageSetup.printArea;
|
|
55487
55960
|
}
|
|
55488
|
-
shiftPreservedXml(sheet,
|
|
55961
|
+
shiftPreservedXml(sheet, shift3, moveRange, !!band);
|
|
55489
55962
|
}
|
|
55490
|
-
function shiftCells(sheet,
|
|
55963
|
+
function shiftCells(sheet, shift3, band, moveRange) {
|
|
55491
55964
|
const old = sheet.rows;
|
|
55492
55965
|
sheet.rows = /* @__PURE__ */ new Map();
|
|
55493
55966
|
for (const [row2, cells] of old)
|
|
55494
55967
|
for (const [col, cell] of cells) {
|
|
55495
|
-
const along =
|
|
55496
|
-
const across =
|
|
55968
|
+
const along = shift3.axis === "row" ? row2 : col;
|
|
55969
|
+
const across = shift3.axis === "row" ? col : row2;
|
|
55497
55970
|
const inBand = !band || across >= band.lo && across <= band.hi;
|
|
55498
|
-
const moved = inBand ? shiftIndex(along,
|
|
55971
|
+
const moved = inBand ? shiftIndex(along, shift3) : along;
|
|
55499
55972
|
if (moved === void 0) continue;
|
|
55500
55973
|
if (cell.arrayRange) {
|
|
55501
55974
|
const range = moveRange(cell.arrayRange);
|
|
55502
55975
|
if (range) cell.arrayRange = range;
|
|
55503
55976
|
else delete cell.arrayRange;
|
|
55504
55977
|
}
|
|
55505
|
-
if (
|
|
55978
|
+
if (shift3.axis === "row") putCell(sheet, moved, col, cell);
|
|
55506
55979
|
else putCell(sheet, row2, moved, cell);
|
|
55507
55980
|
}
|
|
55508
55981
|
}
|
|
@@ -55510,73 +55983,73 @@ function uniqueColumnName(columns) {
|
|
|
55510
55983
|
const taken = new Set(columns.map((c2) => c2.name.toLowerCase()));
|
|
55511
55984
|
for (let n2 = 1; ; n2++) if (!taken.has(`column${n2}`)) return `Column${n2}`;
|
|
55512
55985
|
}
|
|
55513
|
-
function shiftTable2(sheet, table3,
|
|
55986
|
+
function shiftTable2(sheet, table3, shift3, moveRange) {
|
|
55514
55987
|
const old = table3.range;
|
|
55515
55988
|
const range = moveRange(old);
|
|
55516
55989
|
if (!range) return [];
|
|
55517
55990
|
const next = { ...table3, range, columns: [...table3.columns] };
|
|
55518
55991
|
const widened = range.end.col - range.start.col !== old.end.col - old.start.col;
|
|
55519
|
-
if (
|
|
55520
|
-
if (
|
|
55521
|
-
const offset2 =
|
|
55522
|
-
for (let i2 = 0; i2 <
|
|
55992
|
+
if (shift3.axis === "col" && widened) {
|
|
55993
|
+
if (shift3.count > 0) {
|
|
55994
|
+
const offset2 = shift3.at - old.start.col;
|
|
55995
|
+
for (let i2 = 0; i2 < shift3.count; i2++) {
|
|
55523
55996
|
const column3 = { name: uniqueColumnName(next.columns) };
|
|
55524
55997
|
next.columns.splice(offset2 + i2, 0, column3);
|
|
55525
55998
|
if (next.headerRow) {
|
|
55526
55999
|
const cell = { value: column3.name };
|
|
55527
|
-
putCell(sheet, range.start.row,
|
|
56000
|
+
putCell(sheet, range.start.row, shift3.at + i2, cell);
|
|
55528
56001
|
}
|
|
55529
56002
|
}
|
|
55530
56003
|
} else {
|
|
55531
56004
|
next.columns = next.columns.filter(
|
|
55532
|
-
(_c, i2) => shiftIndex(old.start.col + i2,
|
|
56005
|
+
(_c, i2) => shiftIndex(old.start.col + i2, shift3) !== void 0
|
|
55533
56006
|
);
|
|
55534
56007
|
}
|
|
55535
56008
|
}
|
|
55536
56009
|
return [next];
|
|
55537
56010
|
}
|
|
55538
|
-
function shiftAnchor(anchor,
|
|
55539
|
-
const key =
|
|
55540
|
-
const other =
|
|
56011
|
+
function shiftAnchor(anchor, shift3, band) {
|
|
56012
|
+
const key = shift3.axis === "row" ? "row" : "col";
|
|
56013
|
+
const other = shift3.axis === "row" ? "col" : "row";
|
|
55541
56014
|
if (band && (anchor.from[other] < band.lo || anchor.from[other] > band.hi)) return;
|
|
55542
56015
|
const from = anchor.from[key];
|
|
55543
|
-
const movedFrom = shiftIndexClamped(from,
|
|
55544
|
-
if (shiftIndex(from,
|
|
56016
|
+
const movedFrom = shiftIndexClamped(from, shift3);
|
|
56017
|
+
if (shiftIndex(from, shift3) === void 0)
|
|
55545
56018
|
anchor.from[key === "row" ? "rowOffset" : "colOffset"] = 0;
|
|
55546
56019
|
anchor.from[key] = movedFrom;
|
|
55547
56020
|
if (anchor.to) {
|
|
55548
56021
|
const to = anchor.to[key];
|
|
55549
|
-
const moved = shiftIndex(to,
|
|
56022
|
+
const moved = shiftIndex(to, shift3);
|
|
55550
56023
|
if (moved === void 0) {
|
|
55551
|
-
anchor.to[key] = Math.max(movedFrom, shiftIndexClamped(to,
|
|
56024
|
+
anchor.to[key] = Math.max(movedFrom, shiftIndexClamped(to, shift3));
|
|
55552
56025
|
anchor.to[key === "row" ? "rowOffset" : "colOffset"] = 0;
|
|
55553
56026
|
} else anchor.to[key] = moved;
|
|
55554
56027
|
}
|
|
55555
56028
|
}
|
|
55556
|
-
function shiftAxisFormats(sheet,
|
|
55557
|
-
if (
|
|
56029
|
+
function shiftAxisFormats(sheet, shift3) {
|
|
56030
|
+
if (shift3.axis === "row") {
|
|
55558
56031
|
const old = sheet.rowInfo;
|
|
55559
56032
|
sheet.rowInfo = /* @__PURE__ */ new Map();
|
|
55560
56033
|
for (const [row2, info] of old) {
|
|
55561
|
-
const moved = shiftIndex(row2,
|
|
56034
|
+
const moved = shiftIndex(row2, shift3);
|
|
55562
56035
|
if (moved !== void 0) sheet.rowInfo.set(moved, info);
|
|
55563
56036
|
}
|
|
55564
56037
|
return;
|
|
55565
56038
|
}
|
|
55566
56039
|
sheet.columns = normalizeColumns(
|
|
55567
56040
|
sheet.columns.flatMap((info) => {
|
|
55568
|
-
const span4 = shiftSpan(info.min, info.max,
|
|
56041
|
+
const span4 = shiftSpan(info.min, info.max, shift3);
|
|
55569
56042
|
return span4 ? [{ ...info, min: span4.start, max: span4.end }] : [];
|
|
55570
56043
|
})
|
|
55571
56044
|
);
|
|
55572
56045
|
}
|
|
55573
|
-
function shiftFreeze(sheet,
|
|
56046
|
+
function shiftFreeze(sheet, shift3) {
|
|
55574
56047
|
const freeze = sheet.view.freeze;
|
|
55575
56048
|
if (!freeze) return;
|
|
55576
|
-
const key =
|
|
56049
|
+
const key = shift3.axis === "row" ? "rows" : "cols";
|
|
55577
56050
|
const frozen = freeze[key];
|
|
55578
|
-
if (
|
|
55579
|
-
const next =
|
|
56051
|
+
if (shift3.at >= frozen) return;
|
|
56052
|
+
const next = shift3.count > 0 ? frozen + shift3.count : frozen - Math.min(-shift3.count, frozen - shift3.at);
|
|
55580
56053
|
sheet.view.freeze = { ...freeze, [key]: next };
|
|
55581
56054
|
}
|
|
55582
56055
|
|
|
@@ -55586,15 +56059,15 @@ function checkSpan(axis, at2, count2) {
|
|
|
55586
56059
|
if (!Number.isInteger(at2) || !Number.isInteger(count2) || at2 < 0 || at2 > max || count2 < 1 || at2 + count2 > max + 1)
|
|
55587
56060
|
throw new RangeError(`Invalid ${axis} span ${at2} + ${count2}`);
|
|
55588
56061
|
}
|
|
55589
|
-
function applyAxisShift(ctx, sheet,
|
|
55590
|
-
assertInsertFits(sheet,
|
|
55591
|
-
rebaseRulesForDeletion(sheet,
|
|
55592
|
-
const spec2 = { sheet: sheet.name, axis:
|
|
56062
|
+
function applyAxisShift(ctx, sheet, shift3) {
|
|
56063
|
+
assertInsertFits(sheet, shift3);
|
|
56064
|
+
rebaseRulesForDeletion(sheet, shift3);
|
|
56065
|
+
const spec2 = { sheet: sheet.name, axis: shift3.axis, at: shift3.at, count: shift3.count };
|
|
55593
56066
|
rewriteFormulas(
|
|
55594
56067
|
ctx.workbook,
|
|
55595
56068
|
(formula2, formulaSheet) => shiftFormula(formula2, formulaSheet, spec2)
|
|
55596
56069
|
);
|
|
55597
|
-
shiftSheetContent(sheet,
|
|
56070
|
+
shiftSheetContent(sheet, shift3);
|
|
55598
56071
|
}
|
|
55599
56072
|
function inheritFormats(sheet, axis, at2, count2) {
|
|
55600
56073
|
if (at2 === 0) return;
|
|
@@ -55620,17 +56093,17 @@ function shiftAxis(ctx, s, axis, at2, count2, insert2) {
|
|
|
55620
56093
|
checkSpan(axis, at2, count2);
|
|
55621
56094
|
const sheet = sheetAt(ctx.workbook, s);
|
|
55622
56095
|
const noun = axis === "row" ? count2 === 1 ? "row" : "rows" : count2 === 1 ? "column" : "columns";
|
|
55623
|
-
const
|
|
55624
|
-
assertInsertFits(sheet,
|
|
56096
|
+
const shift3 = { axis, at: at2, count: insert2 ? count2 : -count2 };
|
|
56097
|
+
assertInsertFits(sheet, shift3);
|
|
55625
56098
|
const info = { sheet: s, structural: true };
|
|
55626
|
-
if (!sheet.autoFilter || shiftRange(sheet.autoFilter.range,
|
|
55627
|
-
info.calc = { kind: "shift", sheet: s, shift:
|
|
56099
|
+
if (!sheet.autoFilter || shiftRange(sheet.autoFilter.range, shift3))
|
|
56100
|
+
info.calc = { kind: "shift", sheet: s, shift: shift3 };
|
|
55628
56101
|
ctx.run(
|
|
55629
56102
|
`${insert2 ? "Insert" : "Delete"} ${noun}`,
|
|
55630
56103
|
"structure",
|
|
55631
|
-
[{ kind: "shift", sheet: s, shift:
|
|
56104
|
+
[{ kind: "shift", sheet: s, shift: shift3 }],
|
|
55632
56105
|
() => {
|
|
55633
|
-
applyAxisShift(ctx, sheet,
|
|
56106
|
+
applyAxisShift(ctx, sheet, shift3);
|
|
55634
56107
|
if (insert2) inheritFormats(sheet, axis, at2, count2);
|
|
55635
56108
|
},
|
|
55636
56109
|
info
|
|
@@ -55642,9 +56115,9 @@ var insertColumns = (ctx, s, at2, count2) => shiftAxis(ctx, s, "col", at2, count
|
|
|
55642
56115
|
var deleteColumns = (ctx, s, at2, count2) => shiftAxis(ctx, s, "col", at2, count2, false);
|
|
55643
56116
|
|
|
55644
56117
|
// xlsx/edit/cell-shift.ts
|
|
55645
|
-
function assertBandIntact(sheet,
|
|
55646
|
-
const zone =
|
|
55647
|
-
const other =
|
|
56118
|
+
function assertBandIntact(sheet, shift3, band) {
|
|
56119
|
+
const zone = shift3.axis === "row" ? cellRange(shift3.at, band.lo, MAX_ROW, band.hi) : cellRange(band.lo, shift3.at, band.hi, MAX_COL);
|
|
56120
|
+
const other = shift3.axis === "row" ? "col" : "row";
|
|
55648
56121
|
const torn = (r) => rangesIntersect(r, zone) && (r.start[other] < band.lo || r.end[other] > band.hi);
|
|
55649
56122
|
if (sheet.merges.some(torn))
|
|
55650
56123
|
throw new Error("Cannot shift cells: a merged range would be split.");
|
|
@@ -55657,25 +56130,25 @@ function shiftBand(ctx, s, range, direction) {
|
|
|
55657
56130
|
const vertical = direction === "down" || direction === "up";
|
|
55658
56131
|
const insert2 = direction === "down" || direction === "right";
|
|
55659
56132
|
const size = vertical ? r.end.row - r.start.row + 1 : r.end.col - r.start.col + 1;
|
|
55660
|
-
const
|
|
56133
|
+
const shift3 = {
|
|
55661
56134
|
axis: vertical ? "row" : "col",
|
|
55662
56135
|
at: vertical ? r.start.row : r.start.col,
|
|
55663
56136
|
count: insert2 ? size : -size
|
|
55664
56137
|
};
|
|
55665
56138
|
const band = vertical ? { lo: r.start.col, hi: r.end.col } : { lo: r.start.row, hi: r.end.row };
|
|
55666
|
-
assertBandIntact(sheet,
|
|
55667
|
-
assertInsertFits(sheet,
|
|
56139
|
+
assertBandIntact(sheet, shift3, band);
|
|
56140
|
+
assertInsertFits(sheet, shift3, band);
|
|
55668
56141
|
ctx.run(
|
|
55669
56142
|
`${insert2 ? "Insert" : "Delete"} cells`,
|
|
55670
56143
|
"structure",
|
|
55671
|
-
[{ kind: "shift", sheet: s, shift:
|
|
56144
|
+
[{ kind: "shift", sheet: s, shift: shift3, band }],
|
|
55672
56145
|
() => {
|
|
55673
|
-
rebaseRulesForDeletion(sheet,
|
|
56146
|
+
rebaseRulesForDeletion(sheet, shift3, band);
|
|
55674
56147
|
rewriteFormulas(
|
|
55675
56148
|
ctx.workbook,
|
|
55676
|
-
(formula2, formulaSheet) => shiftFormulaInBand(formula2, formulaSheet, sheet.name,
|
|
56149
|
+
(formula2, formulaSheet) => shiftFormulaInBand(formula2, formulaSheet, sheet.name, shift3, band)
|
|
55677
56150
|
);
|
|
55678
|
-
shiftSheetContent(sheet,
|
|
56151
|
+
shiftSheetContent(sheet, shift3, band);
|
|
55679
56152
|
},
|
|
55680
56153
|
{ sheet: s, ranges: [r], structural: true }
|
|
55681
56154
|
);
|
|
@@ -57228,14 +57701,14 @@ function restoreRefs(workbook, data) {
|
|
|
57228
57701
|
}
|
|
57229
57702
|
var sameRange3 = (a2, b) => a2 === b || !!a2 && !!b && a2.start.row === b.start.row && a2.start.col === b.start.col && a2.end.row === b.end.row && a2.end.col === b.end.col;
|
|
57230
57703
|
var sameEntry = (a2, b) => a2.formula === b.formula && sameRange3(a2.arrayRange, b.arrayRange);
|
|
57231
|
-
function movePosition(spec2,
|
|
57232
|
-
if (!spec2 || !
|
|
57233
|
-
const along =
|
|
57234
|
-
const across =
|
|
57704
|
+
function movePosition(spec2, shift3, s, row2, col) {
|
|
57705
|
+
if (!spec2 || !shift3 || s !== spec2.sheet) return [row2, col];
|
|
57706
|
+
const along = shift3.axis === "row" ? row2 : col;
|
|
57707
|
+
const across = shift3.axis === "row" ? col : row2;
|
|
57235
57708
|
if (spec2.band && (across < spec2.band.lo || across > spec2.band.hi)) return [row2, col];
|
|
57236
|
-
const moved = shiftIndex(along,
|
|
57709
|
+
const moved = shiftIndex(along, shift3);
|
|
57237
57710
|
if (moved === void 0) return void 0;
|
|
57238
|
-
return
|
|
57711
|
+
return shift3.axis === "row" ? [moved, col] : [row2, moved];
|
|
57239
57712
|
}
|
|
57240
57713
|
function diffRefs(workbook, before, spec2) {
|
|
57241
57714
|
const keptBefore = [];
|
|
@@ -57256,37 +57729,37 @@ function diffRefs(workbook, before, spec2) {
|
|
|
57256
57729
|
before.formulas = keptBefore;
|
|
57257
57730
|
return keptAfter;
|
|
57258
57731
|
}
|
|
57259
|
-
function moveCellsRaw(sheet,
|
|
57732
|
+
function moveCellsRaw(sheet, shift3, band) {
|
|
57260
57733
|
const old = sheet.rows;
|
|
57261
57734
|
sheet.rows = /* @__PURE__ */ new Map();
|
|
57262
|
-
if (
|
|
57735
|
+
if (shift3.axis === "row" && !band) {
|
|
57263
57736
|
for (const [row2, cells] of old) {
|
|
57264
|
-
const moved = shiftIndex(row2,
|
|
57737
|
+
const moved = shiftIndex(row2, shift3);
|
|
57265
57738
|
if (moved !== void 0) sheet.rows.set(moved, cells);
|
|
57266
57739
|
}
|
|
57267
57740
|
return;
|
|
57268
57741
|
}
|
|
57269
57742
|
for (const [row2, cells] of old)
|
|
57270
57743
|
for (const [col, cell] of cells) {
|
|
57271
|
-
const along =
|
|
57272
|
-
const across =
|
|
57744
|
+
const along = shift3.axis === "row" ? row2 : col;
|
|
57745
|
+
const across = shift3.axis === "row" ? col : row2;
|
|
57273
57746
|
const inBand = !band || across >= band.lo && across <= band.hi;
|
|
57274
|
-
const moved = inBand ? shiftIndex(along,
|
|
57747
|
+
const moved = inBand ? shiftIndex(along, shift3) : along;
|
|
57275
57748
|
if (moved === void 0) continue;
|
|
57276
|
-
if (
|
|
57749
|
+
if (shift3.axis === "row") putCell(sheet, moved, col, cell);
|
|
57277
57750
|
else putCell(sheet, row2, moved, cell);
|
|
57278
57751
|
}
|
|
57279
57752
|
}
|
|
57280
57753
|
function shiftEdgeCells(sheet, spec2, phase) {
|
|
57281
|
-
const { shift:
|
|
57754
|
+
const { shift: shift3, band } = spec2;
|
|
57282
57755
|
const out = [];
|
|
57283
|
-
if (phase === "after" &&
|
|
57284
|
-
const hit = (along) => phase === "before" ? shiftIndex(along,
|
|
57756
|
+
if (phase === "after" && shift3.count < 0) return out;
|
|
57757
|
+
const hit = (along) => phase === "before" ? shiftIndex(along, shift3) === void 0 : along >= shift3.at && along < shift3.at + shift3.count;
|
|
57285
57758
|
for (const [row2, cells] of sheet.rows) {
|
|
57286
|
-
if (
|
|
57759
|
+
if (shift3.axis === "row" && !hit(row2)) continue;
|
|
57287
57760
|
for (const [col, cell] of cells) {
|
|
57288
|
-
const along =
|
|
57289
|
-
const across =
|
|
57761
|
+
const along = shift3.axis === "row" ? row2 : col;
|
|
57762
|
+
const across = shift3.axis === "row" ? col : row2;
|
|
57290
57763
|
if (band && (across < band.lo || across > band.hi)) continue;
|
|
57291
57764
|
if (hit(along)) out.push([row2, col, structuredClone(cell)]);
|
|
57292
57765
|
}
|
|
@@ -57429,8 +57902,8 @@ function restoreShift(workbook, snapshot2) {
|
|
|
57429
57902
|
const { spec: spec2 } = snapshot2;
|
|
57430
57903
|
const sheet = workbook.sheets[spec2.sheet];
|
|
57431
57904
|
if (!sheet) return;
|
|
57432
|
-
const
|
|
57433
|
-
moveCellsRaw(sheet,
|
|
57905
|
+
const shift3 = snapshot2.phase === "before" ? { ...spec2.shift, count: -spec2.shift.count } : spec2.shift;
|
|
57906
|
+
moveCellsRaw(sheet, shift3, spec2.band);
|
|
57434
57907
|
for (const [row2, col, cell] of snapshot2.cells) putCell(sheet, row2, col, cloneCell(cell));
|
|
57435
57908
|
restoreRefs(workbook, snapshot2.data);
|
|
57436
57909
|
workbook.activeSheet = snapshot2.activeSheet;
|
|
@@ -61990,8 +62463,8 @@ function scottBinCount(values2, min, max) {
|
|
|
61990
62463
|
if (values2.length < 2 || max <= min) {
|
|
61991
62464
|
return 1;
|
|
61992
62465
|
}
|
|
61993
|
-
const
|
|
61994
|
-
const variance3 = values2.reduce((sum3, value2) => sum3 + (value2 -
|
|
62466
|
+
const mean9 = values2.reduce((sum3, value2) => sum3 + value2, 0) / values2.length;
|
|
62467
|
+
const variance3 = values2.reduce((sum3, value2) => sum3 + (value2 - mean9) ** 2, 0) / (values2.length - 1);
|
|
61995
62468
|
const sd = Math.sqrt(variance3);
|
|
61996
62469
|
if (!(sd > 0)) {
|
|
61997
62470
|
return 1;
|
|
@@ -62243,8 +62716,8 @@ function fitChartTrendline(options2, xVals, yVals) {
|
|
|
62243
62716
|
function chartSampleVariance(values2) {
|
|
62244
62717
|
const count2 = values2.length;
|
|
62245
62718
|
if (count2 === 0) return 0;
|
|
62246
|
-
const
|
|
62247
|
-
return values2.reduce((sum3, value2) => sum3 + (value2 -
|
|
62719
|
+
const mean9 = values2.reduce((sum3, value2) => sum3 + value2, 0) / count2;
|
|
62720
|
+
return values2.reduce((sum3, value2) => sum3 + (value2 - mean9) ** 2, 0) / Math.max(count2 - 1, 1);
|
|
62248
62721
|
}
|
|
62249
62722
|
function chartErrorBarAmount(options2, values2, displayIndex, sourceIndex, side) {
|
|
62250
62723
|
switch (options2.valueType) {
|
|
@@ -63166,7 +63639,7 @@ function boxWhiskerSvg(model2, frame2, out) {
|
|
|
63166
63639
|
trim2
|
|
63167
63640
|
);
|
|
63168
63641
|
if (!distribution) return;
|
|
63169
|
-
const { stats, whiskerMin, whiskerMax, mean:
|
|
63642
|
+
const { stats, whiskerMin, whiskerMax, mean: mean9 } = distribution;
|
|
63170
63643
|
const x = frame2.band(ci) - frame2.bandSize / 2 + si * slot2 + (slot2 - width) / 2;
|
|
63171
63644
|
const mid = x + width / 2;
|
|
63172
63645
|
const y = frame2.value;
|
|
@@ -63191,10 +63664,10 @@ function boxWhiskerSvg(model2, frame2, out) {
|
|
|
63191
63664
|
)
|
|
63192
63665
|
);
|
|
63193
63666
|
out.push(line3(x, y(stats.median), x + width, y(stats.median), "#1e293b", 2));
|
|
63194
|
-
if (visibility?.meanLine) out.push(line3(x, y(
|
|
63667
|
+
if (visibility?.meanLine) out.push(line3(x, y(mean9), x + width, y(mean9), "#0f766e", 1.5));
|
|
63195
63668
|
if (visibility?.meanMarker !== false)
|
|
63196
63669
|
out.push(
|
|
63197
|
-
`<path d="${boxMeanMarkerPath(mid, y(
|
|
63670
|
+
`<path d="${boxMeanMarkerPath(mid, y(mean9))}" fill="none" stroke="#0f766e" stroke-width="1.5" data-chart-part="mean"/>`
|
|
63198
63671
|
);
|
|
63199
63672
|
observations.forEach((point2, index3) => {
|
|
63200
63673
|
const outlier = point2.value < whiskerMin || point2.value > whiskerMax;
|
|
@@ -63440,10 +63913,10 @@ function categoryAnalysis(model2, frame2, out) {
|
|
|
63440
63913
|
const layout2 = barred ? barLayout(model2, frame2) : void 0;
|
|
63441
63914
|
model2.series.forEach((series, si) => {
|
|
63442
63915
|
if (!series.trendlines && !series.errorBars) return;
|
|
63443
|
-
const
|
|
63916
|
+
const shift3 = layout2 ? layout2.offset(si) + layout2.barSize / 2 : 0;
|
|
63444
63917
|
const barPlane = (x, y) => {
|
|
63445
63918
|
const [px, py] = plane(x, y);
|
|
63446
|
-
return model2.horizontal ? [px, py +
|
|
63919
|
+
return model2.horizontal ? [px, py + shift3] : [px + shift3, py];
|
|
63447
63920
|
};
|
|
63448
63921
|
seriesAnalysis(series, si, (i2) => i2 + 1, plane, barPlane, true, out);
|
|
63449
63922
|
});
|
|
@@ -66357,11 +66830,11 @@ var byId = (sheet, id) => {
|
|
|
66357
66830
|
return table3;
|
|
66358
66831
|
};
|
|
66359
66832
|
function insertBandRow(workbook, sheet, table3, row2) {
|
|
66360
|
-
const
|
|
66833
|
+
const shift3 = { axis: "row", at: row2, count: 1 };
|
|
66361
66834
|
const band = { lo: table3.range.start.col, hi: table3.range.end.col };
|
|
66362
|
-
assertInsertFits(sheet,
|
|
66363
|
-
rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name,
|
|
66364
|
-
shiftSheetContent(sheet,
|
|
66835
|
+
assertInsertFits(sheet, shift3, band);
|
|
66836
|
+
rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift3, band));
|
|
66837
|
+
shiftSheetContent(sheet, shift3, band);
|
|
66365
66838
|
}
|
|
66366
66839
|
function setHeaderRow(workbook, sheet, id, on) {
|
|
66367
66840
|
let table3 = byId(sheet, id);
|
|
@@ -69436,10 +69909,10 @@ function createTable(ctx, s, range, hasHeader, styleName = "TableStyleMedium2")
|
|
|
69436
69909
|
[hasHeader ? { kind: "sheet", sheet: s } : { kind: "workbook" }],
|
|
69437
69910
|
() => {
|
|
69438
69911
|
if (!hasHeader) {
|
|
69439
|
-
const
|
|
69912
|
+
const shift3 = { axis: "row", at: r.start.row, count: 1 };
|
|
69440
69913
|
const band = { lo: r.start.col, hi: r.end.col };
|
|
69441
|
-
rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name,
|
|
69442
|
-
shiftSheetContent(sheet,
|
|
69914
|
+
rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift3, band));
|
|
69915
|
+
shiftSheetContent(sheet, shift3, band);
|
|
69443
69916
|
r = { start: r.start, end: { row: r.end.row + 1, col: r.end.col } };
|
|
69444
69917
|
}
|
|
69445
69918
|
const width = r.end.col - r.start.col + 1;
|
|
@@ -71653,7 +72126,7 @@ function shapeStroke(node2, scale2, theme2) {
|
|
|
71653
72126
|
}
|
|
71654
72127
|
|
|
71655
72128
|
// xlsx/layout/shape-view.ts
|
|
71656
|
-
var escapeXml = (text3) => text3.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
72129
|
+
var escapeXml = (text3) => text3.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
71657
72130
|
var round4 = (value2) => Math.round(value2 * 100) / 100;
|
|
71658
72131
|
var POINT_PX = 96 / 72;
|
|
71659
72132
|
var DEFAULT_FONT_PT = 11;
|
|
@@ -71809,7 +72282,7 @@ var EDGE = "#adadad";
|
|
|
71809
72282
|
var TEXT = "#000000";
|
|
71810
72283
|
var FONT = 'font-family="Segoe UI,Arial,sans-serif"';
|
|
71811
72284
|
var round5 = (value2) => Math.round(value2 * 100) / 100;
|
|
71812
|
-
var escapeXml2 = (text3) => text3.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
72285
|
+
var escapeXml2 = (text3) => text3.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
71813
72286
|
function caption(text3, x, h2, size) {
|
|
71814
72287
|
if (!text3) return "";
|
|
71815
72288
|
return `<text x="${round5(x)}" y="${round5(h2 / 2)}" ${FONT} font-size="${round5(size)}" fill="${TEXT}" dominant-baseline="central">${escapeXml2(text3)}</text>`;
|