ooxml-core 1.31.0 → 1.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/{PptxHandler-KKLAYUGQ.mjs → PptxHandler-QY5VL3CY.mjs} +2 -2
  2. package/dist/PptxHandler-SJ5ZUIUX.mjs +4 -0
  3. package/dist/{PptxHandler-DHQPVTUI.cjs → PptxHandler-TESZUH66.cjs} +3 -3
  4. package/dist/{PresentationBuilder-YYZYCKTZ.mjs → PresentationBuilder-3CH5TR4W.mjs} +2 -2
  5. package/dist/{PresentationBuilder-JORMF5CP.cjs → PresentationBuilder-5NFBUP7Y.cjs} +5 -5
  6. package/dist/{PresentationBuilder-Q2Z33LLM.mjs → PresentationBuilder-S6HXHKEJ.mjs} +2 -2
  7. package/dist/automation/index.cjs +862 -389
  8. package/dist/automation/index.mjs +862 -389
  9. package/dist/{chunk-GJDFCP2T.mjs → chunk-3H5UAJB3.mjs} +258 -155
  10. package/dist/{chunk-MKDONWNO.mjs → chunk-4R65YYAD.mjs} +32 -14
  11. package/dist/{chunk-KWJYMAEF.mjs → chunk-IOTGRLJH.mjs} +255 -152
  12. package/dist/{chunk-6FXOAMNL.mjs → chunk-N6424WKA.mjs} +1 -1
  13. package/dist/{chunk-WZJ25K7P.mjs → chunk-NAWLWKOJ.mjs} +1 -1
  14. package/dist/{chunk-DJ3CDTMX.mjs → chunk-O7SVHLD7.mjs} +23 -5
  15. package/dist/{chunk-CZXM4ZJH.cjs → chunk-Q6NM64J2.cjs} +23 -4
  16. package/dist/{chunk-FFJBOR2Y.mjs → chunk-UYMSFJQZ.mjs} +76 -4
  17. package/dist/{chunk-B4LXDHBX.cjs → chunk-X6VNUBES.cjs} +1419 -1316
  18. package/dist/diagram/index.cjs +8 -4
  19. package/dist/diagram/index.mjs +8 -4
  20. package/dist/docx/embedded.cjs +8 -4
  21. package/dist/docx/embedded.mjs +8 -4
  22. package/dist/docx/index.cjs +8 -4
  23. package/dist/docx/index.mjs +8 -4
  24. package/dist/docx/layout/index.cjs +8 -4
  25. package/dist/docx/layout/index.mjs +8 -4
  26. package/dist/docx/load/index.cjs +8 -4
  27. package/dist/docx/load/index.mjs +8 -4
  28. package/dist/docx/ui/index.cjs +8 -4
  29. package/dist/docx/ui/index.mjs +8 -4
  30. package/dist/geometry/index.cjs +16 -12
  31. package/dist/geometry/index.mjs +16 -12
  32. package/dist/geometry/preset-shape-definitions-table.d.ts.map +1 -1
  33. package/dist/index.cjs +16 -12
  34. package/dist/index.mjs +16 -12
  35. package/dist/pptx/automation/index.cjs +294 -157
  36. package/dist/pptx/automation/index.d.ts +3 -3
  37. package/dist/pptx/automation/index.mjs +5 -5
  38. package/dist/pptx/chunks/{index-PdM5zpmu.d.ts → index-D-FdgqrP.d.ts} +102 -3
  39. package/dist/pptx/chunks/index-D-FdgqrP.d.ts.map +1 -0
  40. package/dist/pptx/chunks/{index-BQDcu_0a.d.ts → index-DKybuHPT.d.ts} +51 -3
  41. package/dist/pptx/chunks/{index-BQDcu_0a.d.ts.map → index-DKybuHPT.d.ts.map} +1 -1
  42. package/dist/pptx/chunks/{index-CBV1oHN7.d.ts → index-DnWlmYCy.d.ts} +2 -2
  43. package/dist/pptx/chunks/{index-CBV1oHN7.d.ts.map → index-DnWlmYCy.d.ts.map} +1 -1
  44. package/dist/pptx/cli/index.cjs +294 -157
  45. package/dist/pptx/cli/index.mjs +4 -4
  46. package/dist/pptx/converter/index.cjs +8 -4
  47. package/dist/pptx/converter/index.d.ts +1 -1
  48. package/dist/pptx/converter/index.mjs +2 -2
  49. package/dist/pptx/editor/render/find-replace.cjs +14 -14
  50. package/dist/pptx/editor/render/find-replace.d.ts +1 -1
  51. package/dist/pptx/editor/render/find-replace.mjs +1 -1
  52. package/dist/pptx/editor/render/slide-operations.cjs +8 -8
  53. package/dist/pptx/editor/render/slide-operations.mjs +2 -2
  54. package/dist/pptx/index.cjs +380 -171
  55. package/dist/pptx/index.d.ts +4 -4
  56. package/dist/pptx/index.mjs +5 -5
  57. package/dist/pptx/node/index.d.ts +1 -1
  58. package/dist/teams/chat-view.d.ts +10 -1
  59. package/dist/teams/chat-view.d.ts.map +1 -1
  60. package/dist/teams/index.cjs +805 -144
  61. package/dist/teams/index.d.ts +1 -0
  62. package/dist/teams/index.d.ts.map +1 -1
  63. package/dist/teams/index.mjs +795 -145
  64. package/dist/teams/presence-controller.d.ts +18 -3
  65. package/dist/teams/presence-controller.d.ts.map +1 -1
  66. package/dist/teams/presence-meetings.d.ts +21 -0
  67. package/dist/teams/presence-meetings.d.ts.map +1 -0
  68. package/dist/teams/presence.d.ts +40 -2
  69. package/dist/teams/presence.d.ts.map +1 -1
  70. package/dist/teams/store.d.ts +5 -0
  71. package/dist/teams/store.d.ts.map +1 -1
  72. package/dist/teams/view.d.ts +5 -0
  73. package/dist/teams/view.d.ts.map +1 -1
  74. package/dist/teams/workspace.d.ts +5 -2
  75. package/dist/teams/workspace.d.ts.map +1 -1
  76. package/dist/visio/index.cjs +6 -1
  77. package/dist/visio/index.mjs +6 -1
  78. package/dist/visio/ui/index.cjs +6 -1
  79. package/dist/visio/ui/index.mjs +6 -1
  80. package/dist/xlsx/formula/ets-drift-compare.d.ts +19 -0
  81. package/dist/xlsx/formula/ets-drift-compare.d.ts.map +1 -0
  82. package/dist/xlsx/formula/ets-excel-compare.d.ts +12 -0
  83. package/dist/xlsx/formula/ets-excel-compare.d.ts.map +1 -1
  84. package/dist/xlsx/formula/ets-init-compare.d.ts +24 -0
  85. package/dist/xlsx/formula/ets-init-compare.d.ts.map +1 -0
  86. package/dist/xlsx/formula/ets-init-maps.d.ts +21 -0
  87. package/dist/xlsx/formula/ets-init-maps.d.ts.map +1 -0
  88. package/dist/xlsx/formula/functions/ets-core.d.ts +1 -1
  89. package/dist/xlsx/formula/functions/ets-core.d.ts.map +1 -1
  90. package/dist/xlsx/formula/functions/ets-init-chain.d.ts +11 -0
  91. package/dist/xlsx/formula/functions/ets-init-chain.d.ts.map +1 -0
  92. package/dist/xlsx/formula/functions/ets-init-four.d.ts +3 -0
  93. package/dist/xlsx/formula/functions/ets-init-four.d.ts.map +1 -0
  94. package/dist/xlsx/formula/functions/ets-init-short.d.ts +17 -0
  95. package/dist/xlsx/formula/functions/ets-init-short.d.ts.map +1 -0
  96. package/dist/xlsx/formula/functions/ets-init-states.d.ts +5 -0
  97. package/dist/xlsx/formula/functions/ets-init-states.d.ts.map +1 -0
  98. package/dist/xlsx/formula/functions/ets-init-three.d.ts +23 -0
  99. package/dist/xlsx/formula/functions/ets-init-three.d.ts.map +1 -0
  100. package/dist/xlsx/formula/functions/ets-init-threeplus.d.ts +13 -0
  101. package/dist/xlsx/formula/functions/ets-init-threeplus.d.ts.map +1 -0
  102. package/dist/xlsx/formula/functions/ets-init.d.ts +18 -0
  103. package/dist/xlsx/formula/functions/ets-init.d.ts.map +1 -1
  104. package/dist/xlsx/formula/functions/ets-search-map.d.ts +24 -0
  105. package/dist/xlsx/formula/functions/ets-search-map.d.ts.map +1 -0
  106. package/dist/xlsx/formula/functions/ets-search.d.ts +17 -0
  107. package/dist/xlsx/formula/functions/ets-search.d.ts.map +1 -0
  108. package/dist/xlsx/formula/functions/ets-season.d.ts +2 -2
  109. package/dist/xlsx/formula/functions/ets-season.d.ts.map +1 -1
  110. package/dist/xlsx/formula/functions/ets-validate.d.ts +16 -0
  111. package/dist/xlsx/formula/functions/ets-validate.d.ts.map +1 -0
  112. package/dist/xlsx/index.cjs +762 -289
  113. package/dist/xlsx/index.mjs +762 -289
  114. package/dist/xlsx/layout/form-control-view.d.ts.map +1 -1
  115. package/dist/xlsx/layout/shape-view.d.ts.map +1 -1
  116. package/dist/xlsx/load/index.cjs +599 -126
  117. package/dist/xlsx/load/index.mjs +599 -126
  118. package/dist/xlsx/read/form-control.d.ts.map +1 -1
  119. package/dist/xlsx/ui/index.cjs +756 -283
  120. package/dist/xlsx/ui/index.mjs +756 -283
  121. package/package.json +1 -1
  122. package/dist/PptxHandler-E4DDV3FQ.mjs +0 -4
  123. package/dist/pptx/chunks/index-PdM5zpmu.d.ts.map +0 -1
@@ -6535,14 +6535,14 @@ function linearFit(xs, ys) {
6535
6535
  return { slope, intercept: my - slope * mx };
6536
6536
  }
6537
6537
  function rank(values2, x, ascending, average) {
6538
- let better = 0;
6538
+ let better2 = 0;
6539
6539
  let ties = 0;
6540
6540
  for (const v of values2) {
6541
6541
  if (v === x) ties++;
6542
- else if (ascending ? v < x : v > x) better++;
6542
+ else if (ascending ? v < x : v > x) better2++;
6543
6543
  }
6544
6544
  if (ties === 0) fail(ERR.NA);
6545
- return average ? better + (ties + 1) / 2 : better + 1;
6545
+ return average ? better2 + (ties + 1) / 2 : better2 + 1;
6546
6546
  }
6547
6547
  var LANCZOS = [
6548
6548
  676.5203681218851,
@@ -11588,11 +11588,11 @@ function binomDist(k, n2, p, cumulative2) {
11588
11588
  for (let i2 = 0; i2 <= kk; i2++) total2 += binomPmf(i2, nn, p);
11589
11589
  return Math.min(1, total2);
11590
11590
  }
11591
- function poisson(k, mean4, cumulative2) {
11591
+ function poisson(k, mean9, cumulative2) {
11592
11592
  const kk = Math.trunc(k);
11593
- if (kk < 0 || mean4 < 0) fail(ERR.NUM);
11594
- if (cumulative2) return 1 - gammaP(kk + 1, mean4);
11595
- return Math.exp(kk * Math.log(mean4) - mean4 - gammaLn(kk + 1));
11593
+ if (kk < 0 || mean9 < 0) fail(ERR.NUM);
11594
+ if (cumulative2) return 1 - gammaP(kk + 1, mean9);
11595
+ return Math.exp(kk * Math.log(mean9) - mean9 - gammaLn(kk + 1));
11596
11596
  }
11597
11597
  var normDist = (x, m, s, cumulative2) => {
11598
11598
  positive2(s);
@@ -11600,13 +11600,272 @@ var normDist = (x, m, s, cumulative2) => {
11600
11600
  return cumulative2 ? normCdf(z) : normPdf(z) / s;
11601
11601
  };
11602
11602
 
11603
+ // xlsx/formula/functions/ets-init-three.ts
11604
+ var mean2 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11605
+ function slopeOf(v) {
11606
+ const k = v.length;
11607
+ const mx = (k - 1) / 2;
11608
+ const my = mean2(v);
11609
+ let sxy = 0;
11610
+ let sxx = 0;
11611
+ for (let i2 = 0; i2 < k; i2++) {
11612
+ sxy += (i2 - mx) * (v[i2] - my);
11613
+ sxx += (i2 - mx) * (i2 - mx);
11614
+ }
11615
+ return sxx === 0 ? 0 : sxy / sxx;
11616
+ }
11617
+ function positionSlopes(y, m) {
11618
+ return Array.from({ length: m }, (_v, c2) => {
11619
+ const vals = [];
11620
+ for (let t = c2; t < y.length; t += m) vals.push(y[t]);
11621
+ return slopeOf(vals) / m;
11622
+ });
11623
+ }
11624
+ function isThreeSeasonLength(n2, m) {
11625
+ return m >= 4 && n2 >= 3 * m && n2 <= 3 * m + Math.ceil(m / 2) + 1;
11626
+ }
11627
+ function threeSeasonSeasonals(y, m, slopeSumOverride) {
11628
+ const n2 = y.length;
11629
+ const extra = n2 - 3 * m;
11630
+ const j0 = Math.floor(m / 2);
11631
+ const at2 = (t) => y[t];
11632
+ const slope = (j) => (at2(j + 2 * m) - at2(j)) / (2 * m);
11633
+ const B = (j) => j + 2 * m < n2 ? slope(j) : slope(j % m);
11634
+ const e = (t) => at2(t) - at2(t - 1) - B(t - j0);
11635
+ const slopeSum = slopeSumOverride ?? positionSlopes(y, m).reduce((a2, b) => a2 + b, 0);
11636
+ const out = [0];
11637
+ for (let k = 1; k < m; k++) {
11638
+ let back = 0;
11639
+ for (let t = k + 1; t <= m; t++) back -= e(t);
11640
+ let fwd = 0;
11641
+ for (let t = m + 1; t <= m + k; t++) fwd += e(t);
11642
+ if (k < j0 - 1) {
11643
+ out.push(fwd);
11644
+ continue;
11645
+ }
11646
+ if (k === m - 1 && extra <= Math.ceil(m / 2)) {
11647
+ out.push(back);
11648
+ continue;
11649
+ }
11650
+ const wrapped = Math.max(0, k - j0 + 1 - extra);
11651
+ let corner4 = 0;
11652
+ for (let i2 = extra; i2 <= k - j0; i2++)
11653
+ corner4 += (at2(i2 + m) + at2(i2 + 2 * m) - 2 * at2(i2)) / (4 * m);
11654
+ const level4 = (at2(k) + at2(m + k)) / 2 - at2(m);
11655
+ const bb = back - (at2(k) - at2(m));
11656
+ const ff = fwd - (at2(m + k) - at2(m));
11657
+ out.push(level4 + (bb + ff) / 2 - 3 * wrapped / (4 * m) * slopeSum + corner4);
11658
+ }
11659
+ return out;
11660
+ }
11661
+ function padThreeSeasons(y, m, slopeMean = mean2(positionSlopes(y, m))) {
11662
+ const n2 = y.length;
11663
+ const total2 = Math.max(3 * m + Math.ceil(m / 2), n2);
11664
+ const ext = [...y];
11665
+ for (let t = n2; t < total2; t++) ext.push(y[t - 3 * m] + 3 * m * slopeMean);
11666
+ return ext;
11667
+ }
11668
+ function threeSeasonTrend(y, m, rel, slopeMean) {
11669
+ const ext = padThreeSeasons(y, m, slopeMean);
11670
+ const total2 = ext.length;
11671
+ const mx = (total2 - 1) / 2;
11672
+ let sxx = 0;
11673
+ let sxy = 0;
11674
+ for (let t = 0; t < total2; t++) {
11675
+ sxx += (t - mx) * (t - mx);
11676
+ sxy += (t - mx) * (ext[t] - rel[t % m]);
11677
+ }
11678
+ return sxy / sxx;
11679
+ }
11680
+ function isTwoSeasonLength(n2, m) {
11681
+ return m >= 4 && n2 === 2 * m;
11682
+ }
11683
+ function isTwoPlusLength(n2, m) {
11684
+ return m >= 4 && n2 > 2 * m && n2 < 3 * m;
11685
+ }
11686
+ function slopeSumOf(y, m) {
11687
+ return positionSlopes(y, m).reduce((a2, c2) => a2 + c2, 0);
11688
+ }
11689
+ function extendTwoSeasons(y, m) {
11690
+ const b = mean2(positionSlopes(y, m));
11691
+ const out = [...y];
11692
+ for (let t = y.length; t < 3 * m; t++) out.push(y[t - 2 * m] + 2 * m * b);
11693
+ return out;
11694
+ }
11695
+ function paddedSearchSeries(y, m) {
11696
+ if (isTwoSeasonLength(y.length, m) || isTwoPlusLength(y.length, m))
11697
+ return padThreeSeasons(extendTwoSeasons(y, m), m, slopeSumOf(y, m) / m);
11698
+ if (isThreeSeasonLength(y.length, m)) return padThreeSeasons(y, m);
11699
+ return void 0;
11700
+ }
11701
+
11702
+ // xlsx/formula/functions/ets-init-states.ts
11703
+ var mean3 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11704
+ function chainStates(y, m, seasons) {
11705
+ const h2 = Math.floor(seasons / 2);
11706
+ const first2 = seasons - h2;
11707
+ const at2 = (t) => y[t];
11708
+ const meanFirst = (t) => mean3(Array.from({ length: first2 }, (_v, c2) => at2(t + c2 * m)));
11709
+ const slope = (j) => {
11710
+ const early = mean3(Array.from({ length: h2 }, (_v, c2) => at2(j + c2 * m)));
11711
+ const late = mean3(Array.from({ length: h2 }, (_v, c2) => at2(j + (seasons - h2 + c2) * m)));
11712
+ return (late - early) / ((seasons - h2) * m);
11713
+ };
11714
+ const j0 = Math.floor(m / 2);
11715
+ const state = /* @__PURE__ */ new Map([[j0 - 1, 0]]);
11716
+ for (let t = j0; t <= j0 + m - 2; t++)
11717
+ state.set(t, state.get(t - 1) + meanFirst(t) - meanFirst(t - 1) - slope(t - j0));
11718
+ const byPosition = new Array(m).fill(0);
11719
+ for (const [t, s] of state) byPosition[t % m] = s;
11720
+ return byPosition;
11721
+ }
11722
+ function chainSeasonals(y, m, seasons) {
11723
+ const byPosition = chainStates(y, m, seasons);
11724
+ const origin = byPosition[0];
11725
+ return byPosition.map((s) => s - origin);
11726
+ }
11727
+
11728
+ // xlsx/formula/functions/ets-init-four.ts
11729
+ var mean4 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11730
+ function template(w, m, a2) {
11731
+ const block = (c2) => mean4(w.slice(c2 * m, (c2 + 1) * m));
11732
+ const at2 = (i2) => w[i2];
11733
+ return (block(0) - block(2)) / 12 + (block(1) - block(3)) / 6 - (at2(a2) + at2(a2 + m) - 2 * at2(a2 + 2 * m)) / 6;
11734
+ }
11735
+ function fourSeasonPlusSeasonals(y, m) {
11736
+ const r = y.length - 4 * m;
11737
+ const a2 = Math.floor(m / 2) - 1;
11738
+ const states2 = chainStates(y.slice(0, 4 * m), m, 4);
11739
+ for (let q = 0; q < r; q++) {
11740
+ const pos = (a2 + q) % m;
11741
+ states2[pos] = states2[pos] + template(y.slice(q, q + 4 * m), m, a2);
11742
+ }
11743
+ const origin = states2[0];
11744
+ return states2.map((s) => s - origin);
11745
+ }
11746
+
11747
+ // xlsx/formula/functions/ets-init-threeplus.ts
11748
+ var mean5 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11749
+ function isThreePlusLength(n2, m) {
11750
+ return m >= 4 && n2 >= 3 * m + Math.ceil(m / 2) + 2 && n2 < 4 * m;
11751
+ }
11752
+ function shift2(y, m, k) {
11753
+ const a2 = Math.ceil(m / 2) + 1;
11754
+ const at2 = (i2) => y[i2];
11755
+ 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;
11756
+ }
11757
+ function isLowThreeLength(n2, m) {
11758
+ return m === 2 && n2 >= 5 && n2 < 8 || m === 3 && n2 >= 6 && n2 < 12;
11759
+ }
11760
+ function lowSeasonSeasonals(y, m, slopeSum) {
11761
+ const base = threeSeasonSeasonals(y, m, slopeSum);
11762
+ const d = -shift2(y, m, -m);
11763
+ return base.map((s, k) => k === 0 ? 0 : s + d);
11764
+ }
11765
+ function threePlusSeasonals(y, m) {
11766
+ const base = threeSeasonSeasonals(y, m);
11767
+ const moved = y.length - 3 * m - Math.ceil(m / 2) - 1;
11768
+ const z = base.map((s, k) => k < moved ? s - shift2(y, m, k) : s);
11769
+ const origin = z[0];
11770
+ return z.map((s) => s - origin);
11771
+ }
11772
+
11773
+ // xlsx/formula/functions/ets-init-short.ts
11774
+ function seasonStart(m) {
11775
+ return Math.ceil(10 * (m + 1) / 7);
11776
+ }
11777
+ function isShortSeasonLength(n2, m) {
11778
+ return m >= 5 && n2 >= seasonStart(m) && n2 < 2 * m;
11779
+ }
11780
+ function padTwoSeasons(y, m) {
11781
+ const p = [...y];
11782
+ for (let t = y.length; t < 2 * m; t++) p.push(p[t - m]);
11783
+ return p;
11784
+ }
11785
+ function trendShift(m, n2) {
11786
+ const j0 = Math.floor(m / 2);
11787
+ const u = 2 * m - 1 - n2;
11788
+ return (u * u - (j0 - 2) * u + 2 * (j0 - 1)) / 4;
11789
+ }
11790
+ function shortSeasonStart(y, m) {
11791
+ const n2 = y.length;
11792
+ const p = padTwoSeasons(y, m);
11793
+ const ss = slopeSumOf(p, m);
11794
+ const ext = extendTwoSeasons(p, m);
11795
+ const base = threeSeasonSeasonals(ext, m, ss);
11796
+ const total2 = 3 * m + Math.ceil(m / 2);
11797
+ const sxx = total2 * (total2 * total2 - 1) / 12;
11798
+ const trend = threeSeasonTrend(ext, m, base, ss / m) + trendShift(m, n2) * ss / sxx;
11799
+ const rel = base.map((s, k) => k >= n2 - m && k <= m - 2 ? s + ss / 2 : s);
11800
+ return { rel, trend };
11801
+ }
11802
+ function shortSearchSeries(y, m) {
11803
+ const p = padTwoSeasons(y, m);
11804
+ return padThreeSeasons(extendTwoSeasons(p, m), m, slopeSumOf(p, m) / m);
11805
+ }
11806
+
11807
+ // xlsx/formula/functions/ets-init-chain.ts
11808
+ var MAX_SEASONS = 5;
11809
+ var mean6 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11810
+ function isExactLength(n2, m) {
11811
+ const whole = Math.floor(n2 / m);
11812
+ return whole >= MAX_SEASONS || whole === 4 || isThreeSeasonLength(n2, m) || isThreePlusLength(n2, m) || isLowThreeLength(n2, m) || isTwoSeasonLength(n2, m) || isTwoPlusLength(n2, m) || isShortSeasonLength(n2, m);
11813
+ }
11814
+ function fromRelative(y0, rel, trend) {
11815
+ const combined = rel.map((s) => y0 + s - trend);
11816
+ const level4 = mean6(combined);
11817
+ return { level: level4, trend, season: combined.map((c2) => c2 - level4) };
11818
+ }
11819
+ function chainStart(y, m) {
11820
+ const n2 = y.length;
11821
+ const whole = Math.floor(n2 / m);
11822
+ if (isShortSeasonLength(n2, m)) {
11823
+ const { rel: rel2, trend } = shortSeasonStart(y, m);
11824
+ return fromRelative(y[0], rel2, trend);
11825
+ }
11826
+ if (isThreeSeasonLength(n2, m) || isTwoSeasonLength(n2, m) || isTwoPlusLength(n2, m)) {
11827
+ const short = isTwoSeasonLength(n2, m) || isTwoPlusLength(n2, m);
11828
+ const series = short ? extendTwoSeasons(y, m) : y;
11829
+ const rel2 = threeSeasonSeasonals(series, m, short ? slopeSumOf(y, m) : void 0);
11830
+ return fromRelative(
11831
+ y[0],
11832
+ rel2,
11833
+ threeSeasonTrend(series, m, rel2, short ? slopeSumOf(y, m) / m : void 0)
11834
+ );
11835
+ }
11836
+ if (isLowThreeLength(n2, m)) {
11837
+ const short = n2 < 3 * m;
11838
+ const series = short ? extendTwoSeasons(y, m) : y;
11839
+ const rel2 = lowSeasonSeasonals(series, m, short ? slopeSumOf(y, m) : void 0);
11840
+ const pad8 = short ? slopeSumOf(y, m) / m : void 0;
11841
+ return fromRelative(y[0], rel2, threeSeasonTrend(series, m, rel2, pad8));
11842
+ }
11843
+ if (isThreePlusLength(n2, m)) {
11844
+ const rel2 = threePlusSeasonals(y, m);
11845
+ return fromRelative(y[0], rel2, threeSeasonTrend(y, m, rel2));
11846
+ }
11847
+ if (m < 2 || whole < 4) return void 0;
11848
+ const partial = whole < MAX_SEASONS && n2 % m !== 0;
11849
+ const rel = partial ? fourSeasonPlusSeasonals(y, m) : chainSeasonals(y, m, Math.min(whole, MAX_SEASONS));
11850
+ const mx = (n2 - 1) / 2;
11851
+ let sxy = 0;
11852
+ let sxx = 0;
11853
+ const my = mean6(y.map((v, t) => v - rel[t % m]));
11854
+ for (let t = 0; t < n2; t++) {
11855
+ const d = y[t] - rel[t % m] - my;
11856
+ sxy += (t - mx) * d;
11857
+ sxx += (t - mx) * (t - mx);
11858
+ }
11859
+ return fromRelative(y[0], rel, sxy / sxx);
11860
+ }
11861
+
11603
11862
  // xlsx/formula/functions/ets-init.ts
11604
11863
  var MAX_EXACT_SEASON = 24;
11605
- var mean2 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11864
+ var mean7 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11606
11865
  function olsSlope(y) {
11607
11866
  const n2 = y.length;
11608
11867
  const mx = (n2 - 1) / 2;
11609
- const my = mean2(y);
11868
+ const my = mean7(y);
11610
11869
  let sxy = 0;
11611
11870
  let sxx = 0;
11612
11871
  for (let i2 = 0; i2 < n2; i2++) {
@@ -11615,12 +11874,30 @@ function olsSlope(y) {
11615
11874
  }
11616
11875
  return sxx === 0 ? 0 : sxy / sxx;
11617
11876
  }
11877
+ var PADS = {
11878
+ 6: [[0, 6]],
11879
+ 5: [
11880
+ [1, 4],
11881
+ [0, 6]
11882
+ ],
11883
+ 4: [
11884
+ [0, 4],
11885
+ [1, 4],
11886
+ [0, 6]
11887
+ ]
11888
+ };
11889
+ function shortSeriesTrend(y) {
11890
+ const pads = PADS[y.length];
11891
+ if (!pads) return olsSlope(y);
11892
+ const slope = olsSlope(y);
11893
+ return olsSlope([...y, ...pads.map(([src, lag]) => y[src] + lag * slope)]);
11894
+ }
11618
11895
  function split(trend, combined) {
11619
- const level4 = mean2(combined);
11896
+ const level4 = mean7(combined);
11620
11897
  return { level: level4, trend, season: combined.map((c2) => c2 - level4) };
11621
11898
  }
11622
11899
  function heuristicStates(y, m) {
11623
- const trend = (mean2(y.slice(m, 2 * m)) - mean2(y.slice(0, m))) / m;
11900
+ const trend = (mean7(y.slice(m, 2 * m)) - mean7(y.slice(0, m))) / m;
11624
11901
  return split(
11625
11902
  trend,
11626
11903
  Array.from({ length: m }, (_v, k) => y[k] - trend * (k + 1))
@@ -11657,9 +11934,11 @@ function solveSystem(a2, b) {
11657
11934
  function initialStates(y, m, p, run2) {
11658
11935
  const y0 = y[0];
11659
11936
  if (m < 2) {
11660
- const trend2 = olsSlope(y);
11937
+ const trend2 = shortSeriesTrend(y);
11661
11938
  return { level: y0 - trend2, trend: trend2, season: [] };
11662
11939
  }
11940
+ const exact = chainStart(y, m);
11941
+ if (exact) return exact;
11663
11942
  if (m > MAX_EXACT_SEASON) return heuristicStates(y, m);
11664
11943
  const zeros = new Array(y.length).fill(0);
11665
11944
  const unit = (trend2, season) => run2(zeros, m, { level: 0, trend: trend2, season }, p).fitted;
@@ -11679,6 +11958,202 @@ function initialStates(y, m, p, run2) {
11679
11958
  return split(trend, [y0 - trend, ...u.slice(1)]);
11680
11959
  }
11681
11960
 
11961
+ // xlsx/formula/functions/ets-search-map.ts
11962
+ var LOW = 1e-3;
11963
+ var DRIFT_SHIFT = 1.5;
11964
+ var DRIFT_T = 9.3;
11965
+ var CANDIDATES = [
11966
+ ...[2e-3, 0.1, 0.126, 0.25, 0.5, 0.75, 0.9].map((a2) => [a2, LOW]),
11967
+ [0.1, 0.099],
11968
+ [0.126, 0.125],
11969
+ [0.25, 0.249],
11970
+ [0.333333, 0.166667],
11971
+ [0.5, 0.25],
11972
+ [0.5, 0.499],
11973
+ [0.666667, 0.166667],
11974
+ [0.666667, 0.5],
11975
+ [0.75, 0.749],
11976
+ [0.833333, 0.75],
11977
+ [0.9, 0.899],
11978
+ [0.998, 0.099],
11979
+ [0.998, 0.249],
11980
+ [0.998, 0.499],
11981
+ [0.998, 0.749],
11982
+ [0.998, 0.899],
11983
+ [0.166667, 0.0833333],
11984
+ [0.833333, 0.0833333]
11985
+ ];
11986
+ var ALWAYS_DRIFT = /* @__PURE__ */ new Set([
11987
+ "0.1/0.099",
11988
+ "0.998/0.899",
11989
+ "0.998/0.749",
11990
+ "0.166667/0.0833333",
11991
+ "0.25/0.249",
11992
+ "0.9/0.899",
11993
+ "0.666667/0.5",
11994
+ "0.75/0.749"
11995
+ ]);
11996
+ var NEVER_DRIFT = /* @__PURE__ */ new Set(["0.333333/0.166667"]);
11997
+ function trendShape(y, h2) {
11998
+ const n2 = y.length;
11999
+ const hold = h2 > 0 ? h2 : Math.max(1, Math.round(0.3 * n2));
12000
+ const mx = (n2 - 1) / 2;
12001
+ let my = 0;
12002
+ for (const v of y) my += v;
12003
+ my /= n2;
12004
+ let sxy = 0;
12005
+ let sxx = 0;
12006
+ let syy = 0;
12007
+ for (let i2 = 0; i2 < n2; i2++) {
12008
+ const dy = y[i2] - my;
12009
+ sxy += (i2 - mx) * dy;
12010
+ sxx += (i2 - mx) * (i2 - mx);
12011
+ syy += dy * dy;
12012
+ }
12013
+ if (syy === 0 || sxx === 0 || n2 < 3) return { shift: 0, t: 0 };
12014
+ const slope = sxy / sxx;
12015
+ const resid = syy - slope * sxy;
12016
+ const se = Math.sqrt(Math.max(resid, 0) / (n2 - 2) / sxx);
12017
+ let tail = 0;
12018
+ for (let i2 = n2 - hold; i2 < n2; i2++) tail += y[i2];
12019
+ let head = 0;
12020
+ for (let i2 = 0; i2 < n2 - hold; i2++) head += y[i2];
12021
+ const shift3 = Math.abs(tail / hold - head / (n2 - hold)) / Math.sqrt(syy / n2);
12022
+ return { shift: shift3, t: se === 0 ? Number.POSITIVE_INFINITY : Math.abs(slope / se) };
12023
+ }
12024
+ function reportedFor(alpha, beta, shape2) {
12025
+ const key = `${alpha}/${beta}`;
12026
+ let drift;
12027
+ if (beta === LOW) drift = false;
12028
+ else if (ALWAYS_DRIFT.has(key)) drift = true;
12029
+ else if (NEVER_DRIFT.has(key)) drift = false;
12030
+ else drift = shape2.shift <= DRIFT_SHIFT && shape2.t <= DRIFT_T;
12031
+ return { alpha, beta: drift ? LOW : beta, fit: [alpha, beta], drift };
12032
+ }
12033
+
12034
+ // xlsx/formula/functions/ets-search.ts
12035
+ var LOW2 = 1e-3;
12036
+ var MIN_SEARCH_POINTS = 4;
12037
+ var THREE_POINTS = { alpha: 0.1, beta: 0.099, gamma: LOW2, drift: false };
12038
+ var SEASON_ALPHAS = [2e-3, 0.126, 0.251, 0.501, 2 / 3, 0.75, 0.9];
12039
+ var SEASON_STEPS = [LOW2, 0.125, 0.25, 0.5, 0.75, 0.9];
12040
+ var SHORT_SERIES = 16;
12041
+ function better(c2, best) {
12042
+ return c2 < best * (1 - 1e-6) && c2 < best - 1e-12;
12043
+ }
12044
+ var SEASONAL_TRIPLES = [
12045
+ [0.126, LOW2, LOW2],
12046
+ [0.251, LOW2, LOW2],
12047
+ [0.501, LOW2, LOW2],
12048
+ [0.751, LOW2, LOW2],
12049
+ [2e-3, LOW2, 0.125],
12050
+ [2e-3, LOW2, 0.25],
12051
+ [2e-3, LOW2, 0.5],
12052
+ [2e-3, LOW2, 0.75],
12053
+ [0.251, LOW2, 0.25],
12054
+ [0.75, LOW2, 0.249],
12055
+ [0.9, LOW2, 0.099],
12056
+ [0.251, 0.25, LOW2],
12057
+ [0.1, LOW2, 0.899],
12058
+ [0.126, 0.125, LOW2],
12059
+ [0.998, 0.099, LOW2],
12060
+ [0.25, LOW2, 0.749],
12061
+ [0.5, LOW2, 0.499],
12062
+ [0.5, 0.25, LOW2],
12063
+ [0.251, 0.25, 0.25],
12064
+ [0.501, 0.5, LOW2]
12065
+ ];
12066
+ var SHORT_EXTRA_TRIPLES = [
12067
+ [1 / 6, 1 / 12, 1 / 12],
12068
+ [1 / 3, 1 / 6, 1 / 6],
12069
+ [1 / 6, 1 / 12, 0.75],
12070
+ [1 / 3, 1 / 6, 0.5],
12071
+ [5 / 6, 1 / 12, 1 / 12]
12072
+ ];
12073
+ function searchSeasonalLattice(cost, extra = []) {
12074
+ let best = { alpha: 0.126, beta: LOW2, gamma: LOW2 };
12075
+ let bestCost = cost(best);
12076
+ for (const [alpha, beta, gamma2] of [...SEASONAL_TRIPLES, ...extra]) {
12077
+ const c2 = cost({ alpha, beta, gamma: gamma2 });
12078
+ if (better(c2, bestCost)) {
12079
+ bestCost = c2;
12080
+ best = { alpha, beta, gamma: gamma2 };
12081
+ }
12082
+ }
12083
+ return { ...best, drift: false };
12084
+ }
12085
+ function searchSeasonal(n2, cost) {
12086
+ let best = { alpha: 0.9, beta: LOW2, gamma: LOW2 };
12087
+ let bestCost = cost(best);
12088
+ for (const a2 of SEASON_ALPHAS)
12089
+ for (const b of n2 >= 7 && n2 <= SHORT_SERIES ? [LOW2, a2 - LOW2] : [LOW2])
12090
+ for (const g2 of [...SEASON_STEPS, 1 - a2 - LOW2]) {
12091
+ if (b < LOW2 || g2 > 1 - a2 - LOW2 + 1e-9) continue;
12092
+ const c2 = cost({ alpha: a2, beta: b, gamma: g2 });
12093
+ if (better(c2, bestCost)) {
12094
+ bestCost = c2;
12095
+ best = { alpha: a2, beta: b, gamma: g2 };
12096
+ }
12097
+ }
12098
+ return { ...best, drift: false };
12099
+ }
12100
+ function searchLattice(shape2, cost) {
12101
+ let best = [0.9, LOW2];
12102
+ let bestCost = cost({ alpha: 0.9, beta: LOW2, gamma: LOW2 });
12103
+ for (const [alpha, beta] of CANDIDATES) {
12104
+ const c2 = cost({ alpha, beta, gamma: LOW2 });
12105
+ if (better(c2, bestCost)) {
12106
+ bestCost = c2;
12107
+ best = [alpha, beta];
12108
+ }
12109
+ }
12110
+ const out = reportedFor(best[0], best[1], shape2);
12111
+ const [fa, fb] = out.fit;
12112
+ const same12 = fa === out.alpha && fb === out.beta;
12113
+ return {
12114
+ alpha: out.alpha,
12115
+ beta: out.beta,
12116
+ gamma: LOW2,
12117
+ drift: out.drift,
12118
+ ...same12 ? {} : { fit: { alpha: fa, beta: fb, gamma: LOW2 } }
12119
+ };
12120
+ }
12121
+ function chooseSmoothing(n2, m, cost, shape2 = { shift: 9, t: 99 }) {
12122
+ if (m >= 2 && isShortSeasonLength(n2, m)) return searchSeasonalLattice(cost, SHORT_EXTRA_TRIPLES);
12123
+ if (m >= 2) return isExactLength(n2, m) ? searchSeasonalLattice(cost) : searchSeasonal(n2, cost);
12124
+ if (n2 < MIN_SEARCH_POINTS) return THREE_POINTS;
12125
+ return searchLattice(shape2, cost);
12126
+ }
12127
+
12128
+ // xlsx/formula/functions/ets-validate.ts
12129
+ function etsSearchSeries(y) {
12130
+ const pads = PADS[y.length];
12131
+ if (!pads) return y;
12132
+ const slope = olsSlope(y);
12133
+ return [...y, ...pads.map(([src, lag]) => y[src] + lag * slope)];
12134
+ }
12135
+ function etsValidationCost(y, m, init, p, holdout) {
12136
+ const n2 = y.length;
12137
+ const train = n2 - holdout;
12138
+ let { level: level4, trend } = init;
12139
+ const season = [...init.season];
12140
+ let sse = 0;
12141
+ for (let t = 0; t < train; t++) {
12142
+ const k = m >= 2 ? t % m : 0;
12143
+ const e = y[t] - (level4 + trend + (m >= 2 ? season[k] ?? 0 : 0));
12144
+ sse += e * e;
12145
+ level4 += trend + p.alpha * e;
12146
+ trend += p.beta * e;
12147
+ if (m >= 2) season[k] = (season[k] ?? 0) + p.gamma * e;
12148
+ }
12149
+ for (let j = 1; j <= holdout; j++) {
12150
+ const t = train + j - 1;
12151
+ const e = y[t] - (level4 + j * trend + (m >= 2 ? season[t % m] ?? 0 : 0));
12152
+ sse += e * e;
12153
+ }
12154
+ return sse;
12155
+ }
12156
+
11682
12157
  // xlsx/formula/functions/ets-core.ts
11683
12158
  function etsRun(y, m, init, p) {
11684
12159
  let { level: level4, trend } = init;
@@ -11697,36 +12172,36 @@ function etsRun(y, m, init, p) {
11697
12172
  }
11698
12173
  return { fitted, level: level4, trend, season, sse };
11699
12174
  }
11700
- var LOW = 1e-3;
11701
- var SHORT_SERIES = 16;
11702
12175
  var NO_SEASON_GAMMA = Number.EPSILON;
11703
- var ALPHAS = [2e-3, 0.1, 0.126, 0.25, 0.5, 2 / 3, 0.75, 0.9];
11704
- var SEASON_ALPHAS = [2e-3, 0.126, 0.251, 0.501, 2 / 3, 0.75, 0.9];
11705
- var SEASON_STEPS = [LOW, 0.125, 0.25, 0.5, 0.75, 0.9];
11706
12176
  function fitEts(y, seasonLength) {
11707
12177
  const n2 = y.length;
11708
12178
  if (n2 < 2) fail(ERR.NUM);
11709
- const m = seasonLength >= 2 && n2 >= 2 * seasonLength ? seasonLength : 0;
12179
+ const m = seasonLength >= 2 && n2 >= seasonStart(seasonLength) ? seasonLength : 0;
11710
12180
  const solve2 = (p) => {
11711
12181
  const init = initialStates(y, m, p, etsRun);
11712
12182
  return { init, run: etsRun(y, m, init, p) };
11713
12183
  };
11714
- const cost = (v) => solve2({ alpha: v[0], beta: v[1], gamma: v[2] }).run.sse;
11715
- let best = [0.9, LOW, LOW];
11716
- let bestCost = cost(best);
11717
- for (const a2 of m >= 2 ? SEASON_ALPHAS : ALPHAS)
11718
- for (const b of n2 >= 7 && n2 <= SHORT_SERIES ? [LOW, a2 - LOW] : [LOW])
11719
- for (const g2 of m >= 2 ? [...SEASON_STEPS, 1 - a2 - LOW] : [LOW]) {
11720
- if (b < LOW || g2 > 1 - a2 - LOW + 1e-9) continue;
11721
- const c2 = cost([a2, b, g2]);
11722
- if (c2 < bestCost * (1 - 1e-6) && c2 < bestCost - 1e-12) {
11723
- bestCost = c2;
11724
- best = [a2, b, g2];
11725
- }
11726
- }
11727
- const [alpha, beta, gamma2] = best;
11728
- const { run: run2 } = solve2({ alpha, beta, gamma: gamma2 });
11729
- return { alpha, beta, gamma: m >= 2 ? gamma2 : NO_SEASON_GAMMA, m, n: n2, ...run2 };
12184
+ const exact = m < 2 || isExactLength(n2, m);
12185
+ const padded = m >= 2 && exact ? isShortSeasonLength(n2, m) ? shortSearchSeries(y, m) : paddedSearchSeries(y, m) : void 0;
12186
+ const searched = padded ?? (m >= 2 ? y : etsSearchSeries(y));
12187
+ const holdout = m >= 2 && !exact ? 0 : etsHoldout(padded && !(m >= 2 && isShortSeasonLength(n2, m)) ? padded.length : n2, m);
12188
+ const { drift, fit: fit2, ...chosen } = chooseSmoothing(
12189
+ n2,
12190
+ m,
12191
+ (p) => etsValidationCost(searched, m, solve2(p).init, p, holdout),
12192
+ trendShape(y, holdout)
12193
+ );
12194
+ const { run: run2 } = solve2(fit2 ?? chosen);
12195
+ const state = drift ? solve2({ alpha: 1, beta: 0, gamma: chosen.gamma }).run : run2;
12196
+ return {
12197
+ ...chosen,
12198
+ gamma: m >= 2 ? chosen.gamma : NO_SEASON_GAMMA,
12199
+ m,
12200
+ n: n2,
12201
+ ...run2,
12202
+ level: state.level,
12203
+ trend: state.trend
12204
+ };
11730
12205
  }
11731
12206
  function etsHoldout(n2, m) {
11732
12207
  if (n2 < 11) return 0;
@@ -11751,12 +12226,12 @@ function etsErrorSd(fit2, h2) {
11751
12226
  // xlsx/formula/functions/ets-season.ts
11752
12227
  var MAX_POINTS = 8192;
11753
12228
  var MIN_CYCLES = 3;
11754
- var MIN_SHARE = 0.3;
11755
- var mean3 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
12229
+ var MIN_ACF = 0.3;
12230
+ var mean8 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11756
12231
  function detrend(y) {
11757
12232
  const n2 = y.length;
11758
12233
  const mx = (n2 - 1) / 2;
11759
- const my = mean3(y);
12234
+ const my = mean8(y);
11760
12235
  let sxy = 0;
11761
12236
  let sxx = 0;
11762
12237
  for (let i2 = 0; i2 < n2; i2++) {
@@ -11773,34 +12248,23 @@ function detectSeasonality(series) {
11773
12248
  const r = detrend(y);
11774
12249
  const scale2 = Math.max(...y.map(Math.abs), 1);
11775
12250
  if (r.every((v) => Math.abs(v) <= 1e-12 * scale2)) return 0;
11776
- const cos2 = new Float64Array(n2);
11777
- const sin2 = new Float64Array(n2);
11778
- for (let j = 0; j < n2; j++) {
11779
- cos2[j] = Math.cos(2 * Math.PI * j / n2);
11780
- sin2[j] = Math.sin(2 * Math.PI * j / n2);
11781
- }
11782
- let total2 = 0;
11783
- let best = 0;
11784
- let bestK = 0;
11785
- for (let k = 1; k <= Math.floor(n2 / 2); k++) {
11786
- let re = 0;
11787
- let im = 0;
11788
- for (let t = 0; t < n2; t++) {
11789
- const j = k * t % n2;
11790
- const v = r[t];
11791
- re += v * cos2[j];
11792
- im -= v * sin2[j];
11793
- }
11794
- const power2 = re * re + im * im;
11795
- total2 += power2;
11796
- if (k >= MIN_CYCLES && power2 > best) {
11797
- best = power2;
11798
- bestK = k;
11799
- }
12251
+ const maxLag = Math.floor(n2 / MIN_CYCLES);
12252
+ let energy = 0;
12253
+ for (const v of r) energy += v * v;
12254
+ const acf = (lag) => {
12255
+ let s = 0;
12256
+ for (let t = 0; t + lag < n2; t++) s += r[t] * r[t + lag];
12257
+ return s / energy;
12258
+ };
12259
+ let prev = acf(1);
12260
+ let cur = acf(2);
12261
+ for (let lag = 2; lag <= maxLag; lag++) {
12262
+ const next = acf(lag + 1);
12263
+ if (cur >= prev && cur >= next && cur >= MIN_ACF) return lag;
12264
+ prev = cur;
12265
+ cur = next;
11800
12266
  }
11801
- if (bestK === 0 || !(best / total2 >= MIN_SHARE)) return 0;
11802
- const period = Math.round(n2 / bestK);
11803
- return period >= 2 ? period : 0;
12267
+ return 0;
11804
12268
  }
11805
12269
 
11806
12270
  // xlsx/formula/functions/ets-grid.ts
@@ -11872,9 +12336,9 @@ function aggregate2(code, xs) {
11872
12336
  case 4:
11873
12337
  return Math.max(...xs);
11874
12338
  case 5:
11875
- return Math.min(...xs);
11876
- case 6:
11877
12339
  return median2(xs);
12340
+ case 6:
12341
+ return Math.min(...xs);
11878
12342
  default:
11879
12343
  return xs.reduce((a2, b) => a2 + b, 0);
11880
12344
  }
@@ -14416,10 +14880,10 @@ function mergeMessageModules(modules) {
14416
14880
  // i18n/translator.ts
14417
14881
  var SINGLE2 = /\{(\w+)\}/g;
14418
14882
  var DOUBLE = /\{\{\s*(\w+)\s*\}\}/g;
14419
- function interpolate(template, params, placeholder2 = "single") {
14420
- if (!params) return template;
14883
+ function interpolate(template2, params, placeholder2 = "single") {
14884
+ if (!params) return template2;
14421
14885
  const pattern = placeholder2 === "double" ? DOUBLE : SINGLE2;
14422
- return template.replace(
14886
+ return template2.replace(
14423
14887
  pattern,
14424
14888
  (match2, name) => Object.prototype.hasOwnProperty.call(params, name) && params[name] !== void 0 ? String(params[name]) : match2
14425
14889
  );
@@ -14852,7 +15316,7 @@ var ENGLISH_PIVOT_CAPTIONS = {
14852
15316
  functions: FUNCTIONS,
14853
15317
  aggregates: aggregateNames()
14854
15318
  };
14855
- var fillCaption = (template, ...args) => template.replace(/\{(\d)\}/g, (_match, at2) => args[Number(at2)] ?? "");
15319
+ var fillCaption = (template2, ...args) => template2.replace(/\{(\d)\}/g, (_match, at2) => args[Number(at2)] ?? "");
14856
15320
  function pivotCaptions(pivot) {
14857
15321
  const own = pivot.captions;
14858
15322
  if (!own) return ENGLISH_PIVOT_CAPTIONS;
@@ -15563,8 +16027,8 @@ var DIV0 = { error: "#DIV/0!" };
15563
16027
  function variance2(numbers3, sample) {
15564
16028
  const n2 = numbers3.length;
15565
16029
  if (n2 < (sample ? 2 : 1)) return DIV0;
15566
- const mean4 = numbers3.reduce((total2, value3) => total2 + value3, 0) / n2;
15567
- const squares = numbers3.reduce((total2, value3) => total2 + (value3 - mean4) ** 2, 0);
16030
+ const mean9 = numbers3.reduce((total2, value3) => total2 + value3, 0) / n2;
16031
+ const squares = numbers3.reduce((total2, value3) => total2 + (value3 - mean9) ** 2, 0);
15568
16032
  return squares / (sample ? n2 - 1 : n2);
15569
16033
  }
15570
16034
  function aggregateValues(records, field, type) {
@@ -17229,11 +17693,11 @@ var ParseCache = class {
17229
17693
  parseNew(formula2) {
17230
17694
  if (formula2.length > MAX_TEMPLATE_LENGTH) return treeOf(makeTemplate(formula2, NO_RUNS));
17231
17695
  const shape2 = formulaShape(formula2);
17232
- const template = this.templates.get(shape2.hash);
17233
- const reused = template && fromTemplate(template, formula2, shape2);
17696
+ const template2 = this.templates.get(shape2.hash);
17697
+ const reused = template2 && fromTemplate(template2, formula2, shape2);
17234
17698
  if (reused) return reused;
17235
17699
  const made = makeTemplate(formula2, shape2);
17236
- if (!template && "ast" in made) {
17700
+ if (!template2 && "ast" in made) {
17237
17701
  if (this.templates.size > MAX_TEMPLATES) this.templates.clear();
17238
17702
  this.templates.set(shape2.hash, made);
17239
17703
  }
@@ -17951,22 +18415,22 @@ function astTraits(ast) {
17951
18415
  traitsCache.set(ast, traits);
17952
18416
  return traits;
17953
18417
  }
17954
- function intervalDelta(a2, b, shift2) {
17955
- const { at: at2, count: count2 } = shift2;
18418
+ function intervalDelta(a2, b, shift3) {
18419
+ const { at: at2, count: count2 } = shift3;
17956
18420
  if (count2 > 0) {
17957
18421
  if (b < at2) return 0;
17958
18422
  if (a2 < at2) return void 0;
17959
- return b + count2 > (shift2.axis === "row" ? MAX_ROW : MAX_COL) ? void 0 : count2;
18423
+ return b + count2 > (shift3.axis === "row" ? MAX_ROW : MAX_COL) ? void 0 : count2;
17960
18424
  }
17961
18425
  const last = at2 - count2 - 1;
17962
18426
  if (b < at2) return 0;
17963
18427
  if (a2 > last) return count2;
17964
18428
  return void 0;
17965
18429
  }
17966
- function areaDelta(area, sheet, shift2) {
18430
+ function areaDelta(area, sheet, shift3) {
17967
18431
  if (area.sheet !== sheet) return 0;
17968
18432
  const { start, end } = area.range;
17969
- return shift2.axis === "row" ? intervalDelta(start.row, end.row, shift2) : intervalDelta(start.col, end.col, shift2);
18433
+ return shift3.axis === "row" ? intervalDelta(start.row, end.row, shift3) : intervalDelta(start.col, end.col, shift3);
17970
18434
  }
17971
18435
  function movedRange(range2, axis, delta) {
17972
18436
  if (delta === 0) return range2;
@@ -17978,10 +18442,10 @@ function movedRange(range2, axis, delta) {
17978
18442
  end: { row: range2.end.row, col: range2.end.col + delta }
17979
18443
  };
17980
18444
  }
17981
- function reachesEdit(areas, sheet, shift2) {
18445
+ function reachesEdit(areas, sheet, shift3) {
17982
18446
  for (const area of areas) {
17983
18447
  if (area.sheet !== sheet) continue;
17984
- if ((shift2.axis === "row" ? area.range.end.row : area.range.end.col) >= shift2.at) return true;
18448
+ if ((shift3.axis === "row" ? area.range.end.row : area.range.end.col) >= shift3.at) return true;
17985
18449
  }
17986
18450
  return false;
17987
18451
  }
@@ -18030,8 +18494,8 @@ var EngineStructure = class extends EngineCore {
18030
18494
  * changed (cells moved, formulas rewritten). Spills on the sheet, array formulas the edit cuts
18031
18495
  * and anything unexpected fall back to a rebuild on the next recalculation.
18032
18496
  */
18033
- shiftCells(sheet, shift2) {
18034
- if (!this.graphReady() || !this.shiftable(sheet, shift2)) {
18497
+ shiftCells(sheet, shift3) {
18498
+ if (!this.graphReady() || !this.shiftable(sheet, shift3)) {
18035
18499
  this.invalidate();
18036
18500
  return;
18037
18501
  }
@@ -18042,15 +18506,15 @@ var EngineStructure = class extends EngineCore {
18042
18506
  if (own) {
18043
18507
  const next = /* @__PURE__ */ new Map();
18044
18508
  for (const node2 of own.values()) {
18045
- const pos = shift2.axis === "row" ? node2.row : node2.col;
18046
- const delta = intervalDelta(pos, pos, shift2);
18509
+ const pos = shift3.axis === "row" ? node2.row : node2.col;
18510
+ const delta = intervalDelta(pos, pos, shift3);
18047
18511
  if (delta === void 0) {
18048
18512
  this.dropNode(node2);
18049
18513
  continue;
18050
18514
  }
18051
18515
  if (delta !== 0) {
18052
18516
  moved.set(node2, delta);
18053
- if (shift2.axis === "row") node2.row += delta;
18517
+ if (shift3.axis === "row") node2.row += delta;
18054
18518
  else node2.col += delta;
18055
18519
  }
18056
18520
  next.set(cellKey(node2.row, node2.col), node2);
@@ -18059,7 +18523,7 @@ var EngineStructure = class extends EngineCore {
18059
18523
  }
18060
18524
  for (const map of this.nodes.values())
18061
18525
  for (const node2 of map.values()) {
18062
- if (!this.shiftNode(node2, sheet, shift2, moved.get(node2) ?? 0)) {
18526
+ if (!this.shiftNode(node2, sheet, shift3, moved.get(node2) ?? 0)) {
18063
18527
  this.invalidate();
18064
18528
  return;
18065
18529
  }
@@ -18068,11 +18532,11 @@ var EngineStructure = class extends EngineCore {
18068
18532
  this.graphChanged();
18069
18533
  }
18070
18534
  /** No spill or stale spilled value on the sheet, and no array formula the edit cuts. */
18071
- shiftable(sheet, shift2) {
18535
+ shiftable(sheet, shift3) {
18072
18536
  for (const node2 of this.footprints) {
18073
18537
  if (node2.sheet !== sheet) continue;
18074
18538
  if (node2.spill || node2.blockedSpill) return false;
18075
- if (node2.arrayRange && areaDelta({ sheet, range: node2.arrayRange }, sheet, shift2) === void 0)
18539
+ if (node2.arrayRange && areaDelta({ sheet, range: node2.arrayRange }, sheet, shift3) === void 0)
18076
18540
  return false;
18077
18541
  }
18078
18542
  const ws = this.workbook.sheets[sheet];
@@ -18088,19 +18552,19 @@ var EngineStructure = class extends EngineCore {
18088
18552
  this.footprints.delete(node2);
18089
18553
  }
18090
18554
  /** Updates one formula for the edit; false when the graph cannot follow it. */
18091
- shiftNode(node2, sheet, shift2, nodeDelta) {
18555
+ shiftNode(node2, sheet, shift3, nodeDelta) {
18092
18556
  const cell = this.workbook.sheets[node2.sheet]?.rows.get(node2.row)?.get(node2.col);
18093
18557
  if (cell?.formula === void 0) return false;
18094
18558
  if (node2.arrayRange) {
18095
- const delta = areaDelta({ sheet: node2.sheet, range: node2.arrayRange }, sheet, shift2);
18559
+ const delta = areaDelta({ sheet: node2.sheet, range: node2.arrayRange }, sheet, shift3);
18096
18560
  if (delta === void 0) return false;
18097
- node2.arrayRange = movedRange(node2.arrayRange, shift2.axis, delta);
18561
+ node2.arrayRange = movedRange(node2.arrayRange, shift3.axis, delta);
18098
18562
  if (!cell.arrayRange || !sameRange(node2.arrayRange, normalizeRange(cell.arrayRange)))
18099
18563
  return false;
18100
18564
  }
18101
18565
  const changed = cell.formula !== node2.formula;
18102
18566
  const traits = node2.ast && astTraits(node2.ast);
18103
- const reached = reachesEdit(node2.deps, sheet, shift2) || reachesEdit(node2.dynamicDeps, sheet, shift2);
18567
+ const reached = reachesEdit(node2.deps, sheet, shift3) || reachesEdit(node2.dynamicDeps, sheet, shift3);
18104
18568
  if (!changed && !reached && nodeDelta === 0 && !traits?.descriptive && !traits?.opaque)
18105
18569
  return true;
18106
18570
  if (traits?.complex) {
@@ -18109,10 +18573,10 @@ var EngineStructure = class extends EngineCore {
18109
18573
  this.structuralSeeds.add(node2);
18110
18574
  return true;
18111
18575
  }
18112
- const pos = shift2.axis === "row" ? node2.row - nodeDelta : node2.col - nodeDelta;
18576
+ const pos = shift3.axis === "row" ? node2.row - nodeDelta : node2.col - nodeDelta;
18113
18577
  const moves = { seed: !!traits?.descriptive, moved: false, cut: false };
18114
- const deps = this.moveAreas(node2.deps, sheet, shift2, pos, nodeDelta, moves);
18115
- const dynamicDeps = this.moveAreas(node2.dynamicDeps, sheet, shift2, pos, nodeDelta, moves);
18578
+ const deps = this.moveAreas(node2.deps, sheet, shift3, pos, nodeDelta, moves);
18579
+ const dynamicDeps = this.moveAreas(node2.dynamicDeps, sheet, shift3, pos, nodeDelta, moves);
18116
18580
  const { cut, moved: anyMoved } = moves;
18117
18581
  let seed = moves.seed;
18118
18582
  if (cut || changed !== anyMoved) {
@@ -18136,20 +18600,20 @@ var EngineStructure = class extends EngineCore {
18136
18600
  * moved, one was cut (deleted, widened, pushed off the grid) and whether implicit intersection
18137
18601
  * with one can now pick another cell.
18138
18602
  */
18139
- moveAreas(list2, sheet, shift2, pos, nodeDelta, moves) {
18603
+ moveAreas(list2, sheet, shift3, pos, nodeDelta, moves) {
18140
18604
  let out;
18141
18605
  for (let i2 = 0; i2 < list2.length; i2++) {
18142
18606
  const area = list2[i2];
18143
- const delta = areaDelta(area, sheet, shift2);
18607
+ const delta = areaDelta(area, sheet, shift3);
18144
18608
  if (delta === void 0) {
18145
18609
  moves.cut = true;
18146
18610
  continue;
18147
18611
  }
18148
- if (intersectionMoves(area, delta, pos, nodeDelta, shift2.axis)) moves.seed = true;
18612
+ if (intersectionMoves(area, delta, pos, nodeDelta, shift3.axis)) moves.seed = true;
18149
18613
  if (delta === 0) continue;
18150
18614
  moves.moved = true;
18151
18615
  out ??= list2.slice();
18152
- out[i2] = { sheet: area.sheet, range: movedRange(area.range, shift2.axis, delta) };
18616
+ out[i2] = { sheet: area.sheet, range: movedRange(area.range, shift3.axis, delta) };
18153
18617
  }
18154
18618
  return out ?? list2;
18155
18619
  }
@@ -18461,9 +18925,9 @@ function prefixText(prefix) {
18461
18925
  // xlsx/formula/shift-formula.ts
18462
18926
  var templates = /* @__PURE__ */ new Map();
18463
18927
  var MAX_TEMPLATES2 = 2e5;
18464
- function remember(text3, template) {
18928
+ function remember(text3, template2) {
18465
18929
  if (templates.size >= MAX_TEMPLATES2) templates.clear();
18466
- templates.set(text3, template);
18930
+ templates.set(text3, template2);
18467
18931
  }
18468
18932
  function mergeSpacedAreas(tokens2) {
18469
18933
  const out = [];
@@ -18494,16 +18958,16 @@ function templateOf(formula2) {
18494
18958
  const cached = templates.get(formula2);
18495
18959
  if (cached !== void 0) return cached;
18496
18960
  const raw2 = safeTokens(formula2);
18497
- let template = null;
18961
+ let template2 = null;
18498
18962
  if (raw2) {
18499
- template = [];
18963
+ template2 = [];
18500
18964
  let literal3 = "";
18501
18965
  for (const token2 of mergeSpacedAreas(raw2)) {
18502
18966
  if (token2.kind !== "ref" && !(token2.kind === "name" && token2.prefix)) {
18503
18967
  literal3 += token2.text;
18504
18968
  continue;
18505
18969
  }
18506
- if (literal3) template.push(literal3);
18970
+ if (literal3) template2.push(literal3);
18507
18971
  literal3 = "";
18508
18972
  const part = { kind: token2.kind, text: token2.text };
18509
18973
  if (token2.prefix) {
@@ -18512,23 +18976,23 @@ function templateOf(formula2) {
18512
18976
  }
18513
18977
  if (token2.ref) part.ref = token2.ref;
18514
18978
  if (token2.spill) part.spill = true;
18515
- template.push(part);
18979
+ template2.push(part);
18516
18980
  }
18517
- if (literal3) template.push(literal3);
18981
+ if (literal3) template2.push(literal3);
18518
18982
  }
18519
- remember(formula2, template);
18520
- return template;
18983
+ remember(formula2, template2);
18984
+ return template2;
18521
18985
  }
18522
18986
  function rewriteTemplate(formula2, rewrite2) {
18523
- const template = templateOf(formula2);
18524
- if (!template) return formula2;
18987
+ const template2 = templateOf(formula2);
18988
+ if (!template2) return formula2;
18525
18989
  let next;
18526
- for (let i2 = 0; i2 < template.length; i2++) {
18527
- const part = template[i2];
18990
+ for (let i2 = 0; i2 < template2.length; i2++) {
18991
+ const part = template2[i2];
18528
18992
  if (typeof part === "string") continue;
18529
18993
  const changed = rewrite2(part);
18530
18994
  if (!changed) continue;
18531
- next ??= template.slice();
18995
+ next ??= template2.slice();
18532
18996
  next[i2] = changed;
18533
18997
  }
18534
18998
  if (!next) return formula2;
@@ -19966,9 +20430,9 @@ function aggregateCaptionsOf(pivot) {
19966
20430
  ]) {
19967
20431
  const at2 = measure5.caption.indexOf(measure5.field);
19968
20432
  if (at2 < 0 || measure5.caption === measure5.field) continue;
19969
- const template = `${measure5.caption.slice(0, at2)}{0}${measure5.caption.slice(at2 + measure5.field.length)}`;
19970
- if (template !== ENGLISH_PIVOT_CAPTIONS.aggregates[measure5.aggregate])
19971
- out[measure5.aggregate] = template;
20433
+ const template2 = `${measure5.caption.slice(0, at2)}{0}${measure5.caption.slice(at2 + measure5.field.length)}`;
20434
+ if (template2 !== ENGLISH_PIVOT_CAPTIONS.aggregates[measure5.aggregate])
20435
+ out[measure5.aggregate] = template2;
19972
20436
  }
19973
20437
  return Object.keys(out).length ? out : void 0;
19974
20438
  }
@@ -30475,7 +30939,8 @@ var pie = {
30475
30939
  gd16("stAng", "pin 0 adj1 21599999"),
30476
30940
  gd16("endAng", "pin 0 adj2 21599999"),
30477
30941
  gd16("swAng", "+- endAng 0 stAng"),
30478
- gd16("swAng2", "?: swAng swAng +- 21600000 swAng 0"),
30942
+ gd16("swAngWrap", "+- swAng 21600000 0"),
30943
+ gd16("swAng2", "?: swAng swAng swAngWrap"),
30479
30944
  gd16("stx", "cos wd2 stAng"),
30480
30945
  gd16("sty", "sin hd2 stAng"),
30481
30946
  gd16("x1", "+- hc stx 0"),
@@ -30520,7 +30985,8 @@ var chord = {
30520
30985
  gd16("stAng", "pin 0 adj1 21599999"),
30521
30986
  gd16("endAng", "pin 0 adj2 21599999"),
30522
30987
  gd16("swAng", "+- endAng 0 stAng"),
30523
- gd16("swAng2", "?: swAng swAng +- 21600000 swAng 0"),
30988
+ gd16("swAngWrap", "+- swAng 21600000 0"),
30989
+ gd16("swAng2", "?: swAng swAng swAngWrap"),
30524
30990
  gd16("stx", "cos wd2 stAng"),
30525
30991
  gd16("sty", "sin hd2 stAng"),
30526
30992
  gd16("x1", "+- hc stx 0"),
@@ -30544,7 +31010,8 @@ var arc = {
30544
31010
  gd16("stAng", "pin 0 adj1 21599999"),
30545
31011
  gd16("endAng", "pin 0 adj2 21599999"),
30546
31012
  gd16("swAng", "+- endAng 0 stAng"),
30547
- gd16("swAng2", "?: swAng swAng +- 21600000 swAng 0"),
31013
+ gd16("swAngWrap", "+- swAng 21600000 0"),
31014
+ gd16("swAng2", "?: swAng swAng swAngWrap"),
30548
31015
  gd16("stx", "cos wd2 stAng"),
30549
31016
  gd16("sty", "sin hd2 stAng"),
30550
31017
  gd16("x1", "+- hc stx 0"),
@@ -30639,7 +31106,8 @@ var blockArc = {
30639
31106
  gd16("iwd2", "+- wd2 0 thw"),
30640
31107
  gd16("ihd2", "+- hd2 0 thh2"),
30641
31108
  gd16("swAng", "+- endAng 0 stAng"),
30642
- gd16("swAng2", "?: swAng swAng +- 21600000 swAng 0"),
31109
+ gd16("swAngWrap", "+- swAng 21600000 0"),
31110
+ gd16("swAng2", "?: swAng swAng swAngWrap"),
30643
31111
  gd16("mswAng", "+- 0 0 swAng2"),
30644
31112
  gd16("stx", "cos wd2 stAng"),
30645
31113
  gd16("sty", "sin hd2 stAng"),
@@ -38764,8 +39232,8 @@ function writeDiagramFormatDefinition(source3, change) {
38764
39232
  (entry3) => entry3.id === change.value
38765
39233
  ))
38766
39234
  throw new RangeError("Unknown SmartArt format preset.");
38767
- const template = change.kind === "colors" ? buildFabricatedColorsXml(change.value) : buildFabricatedQuickStyleXml(change.value);
38768
- const fresh = parseXml(template).documentElement;
39235
+ const template2 = change.kind === "colors" ? buildFabricatedColorsXml(change.value) : buildFabricatedQuickStyleXml(change.value);
39236
+ const fresh = parseXml(template2).documentElement;
38769
39237
  if (!source3) {
38770
39238
  fresh.setAttribute("uniqueId", `urn:ooxml-core/${change.kind}/${change.value}`);
38771
39239
  return buildXml(fresh);
@@ -40647,8 +41115,8 @@ function buildGeneratedDiagramCache(dataXml2, input) {
40647
41115
  );
40648
41116
  const direct = model2.nodes.find((node2) => node2.modelId === shape2.sourceNodeId);
40649
41117
  const fillIndex = shape2.style?.fill?.index;
40650
- const template = fillIndex ? input.formatScheme?.fillStyles[fillIndex - 1]?.fill : void 0;
40651
- if (!direct?.fill && shape2.fill?.kind === "solid" && shape2.fill.color.kind === "srgb" && (!template || template.kind === "solid" && template.color.kind === "scheme" && template.color.value === "phClr")) {
41118
+ const template2 = fillIndex ? input.formatScheme?.fillStyles[fillIndex - 1]?.fill : void 0;
41119
+ if (!direct?.fill && shape2.fill?.kind === "solid" && shape2.fill.color.kind === "srgb" && (!template2 || template2.kind === "solid" && template2.color.kind === "scheme" && template2.color.value === "phClr")) {
40652
41120
  const original = themed.get(`#${shape2.fill.color.value}`.toUpperCase());
40653
41121
  if (original)
40654
41122
  shape2.fill.color = {
@@ -40656,9 +41124,9 @@ function buildGeneratedDiagramCache(dataXml2, input) {
40656
41124
  transforms: [...original.transforms, ...shape2.fill.color.transforms]
40657
41125
  };
40658
41126
  }
40659
- if (!direct?.fill && shape2.fill?.kind === "gradient" && template?.kind === "gradient") {
41127
+ if (!direct?.fill && shape2.fill?.kind === "gradient" && template2?.kind === "gradient") {
40660
41128
  shape2.fill.stops.forEach((stop, index3) => {
40661
- const authored = template.stops[index3]?.color;
41129
+ const authored = template2.stops[index3]?.color;
40662
41130
  if (authored?.kind === "scheme" && authored.value === "phClr" && stop.color.kind === "srgb") {
40663
41131
  const original = themed.get(`#${stop.color.value}`.toUpperCase());
40664
41132
  if (original)
@@ -45858,7 +46326,12 @@ function vmlCaption(vml, shapeId) {
45858
46326
  const shape2 = vml.slice(start, end < 0 ? void 0 : end);
45859
46327
  const box2 = /<v:textbox[^>]*>([\s\S]*?)<\/v:textbox>/.exec(shape2)?.[1];
45860
46328
  if (!box2) return void 0;
45861
- const text3 = box2.replace(/<br\s*\/?>/gi, "\n").replace(/<[^>]*>/g, "").replace(/&(#x?[0-9a-f]+|\w+);/gi, (match2, code) => {
46329
+ let stripped = box2.replace(/<br\s*\/?>/gi, "\n");
46330
+ for (let prev = ""; prev !== stripped; ) {
46331
+ prev = stripped;
46332
+ stripped = stripped.replace(/<[^>]*>/g, "");
46333
+ }
46334
+ const text3 = stripped.replace(/&(#x?[0-9a-f]+|\w+);/gi, (match2, code) => {
45862
46335
  if (code.startsWith("#")) {
45863
46336
  const value3 = code[1]?.toLowerCase() === "x" ? parseInt(code.slice(2), 16) : Number(code.slice(1));
45864
46337
  return Number.isFinite(value3) ? String.fromCodePoint(value3) : match2;
@@ -49095,12 +49568,12 @@ function reanchor(xml, anchor) {
49095
49568
  ).documentElement;
49096
49569
  for (const candidate of Array.from(holder.childNodes)) {
49097
49570
  if (candidate.nodeType !== 1) continue;
49098
- const template = candidate;
49099
- const original = first(old, template.localName, NS.xdr);
49100
- const position = original ? original.cloneNode(true) : doc.importNode(template, true);
49101
- for (const attribute2 of Array.from(template.attributes))
49571
+ const template2 = candidate;
49572
+ const original = first(old, template2.localName, NS.xdr);
49573
+ const position = original ? original.cloneNode(true) : doc.importNode(template2, true);
49574
+ for (const attribute2 of Array.from(template2.attributes))
49102
49575
  position.setAttribute(attribute2.name, attribute2.value);
49103
- for (const value3 of Array.from(template.childNodes)) {
49576
+ for (const value3 of Array.from(template2.childNodes)) {
49104
49577
  if (value3.nodeType !== 1) continue;
49105
49578
  const item2 = value3;
49106
49579
  const existing = first(position, item2.localName, NS.xdr);
@@ -49303,9 +49776,9 @@ function writeDrawing(writer, partName, objects, sourceDrawing, context) {
49303
49776
 
49304
49777
  // xlsx/edit/range-math.ts
49305
49778
  var axisMax = (axis) => axis === "row" ? MAX_ROW : MAX_COL;
49306
- function shiftSpan(start, end, shift2) {
49307
- const { at: at2, count: count2 } = shift2;
49308
- const max = axisMax(shift2.axis);
49779
+ function shiftSpan(start, end, shift3) {
49780
+ const { at: at2, count: count2 } = shift3;
49781
+ const max = axisMax(shift3.axis);
49309
49782
  if (count2 > 0) {
49310
49783
  if (start >= at2) {
49311
49784
  if (start + count2 > max) return void 0;
@@ -49321,35 +49794,35 @@ function shiftSpan(start, end, shift2) {
49321
49794
  const e = end >= max ? max : end < at2 ? end : end > last ? end - n2 : at2 - 1;
49322
49795
  return s > e ? void 0 : { start: s, end: e };
49323
49796
  }
49324
- function shiftIndex(index3, shift2) {
49325
- const { at: at2, count: count2 } = shift2;
49797
+ function shiftIndex(index3, shift3) {
49798
+ const { at: at2, count: count2 } = shift3;
49326
49799
  if (index3 < at2) return index3;
49327
- if (count2 > 0) return index3 + count2 > axisMax(shift2.axis) ? void 0 : index3 + count2;
49800
+ if (count2 > 0) return index3 + count2 > axisMax(shift3.axis) ? void 0 : index3 + count2;
49328
49801
  return index3 < at2 - count2 ? void 0 : index3 + count2;
49329
49802
  }
49330
- function shiftIndexClamped(index3, shift2) {
49331
- const moved = shiftIndex(index3, shift2);
49803
+ function shiftIndexClamped(index3, shift3) {
49804
+ const moved = shiftIndex(index3, shift3);
49332
49805
  if (moved !== void 0) return moved;
49333
- return shift2.count > 0 ? axisMax(shift2.axis) : shift2.at;
49806
+ return shift3.count > 0 ? axisMax(shift3.axis) : shift3.at;
49334
49807
  }
49335
- function shiftRange(range2, shift2) {
49336
- if (shift2.axis === "row") {
49337
- const span6 = shiftSpan(range2.start.row, range2.end.row, shift2);
49808
+ function shiftRange(range2, shift3) {
49809
+ if (shift3.axis === "row") {
49810
+ const span6 = shiftSpan(range2.start.row, range2.end.row, shift3);
49338
49811
  return span6 && {
49339
49812
  start: { row: span6.start, col: range2.start.col },
49340
49813
  end: { row: span6.end, col: range2.end.col }
49341
49814
  };
49342
49815
  }
49343
- const span5 = shiftSpan(range2.start.col, range2.end.col, shift2);
49816
+ const span5 = shiftSpan(range2.start.col, range2.end.col, shift3);
49344
49817
  return span5 && {
49345
49818
  start: { row: range2.start.row, col: span5.start },
49346
49819
  end: { row: range2.end.row, col: span5.end }
49347
49820
  };
49348
49821
  }
49349
- function shiftRangeInBand(range2, shift2, lo, hi) {
49350
- const other = shift2.axis === "row" ? "col" : "row";
49822
+ function shiftRangeInBand(range2, shift3, lo, hi) {
49823
+ const other = shift3.axis === "row" ? "col" : "row";
49351
49824
  if (range2.end[other] < lo || range2.start[other] > hi) return range2;
49352
- if (range2.start[other] >= lo && range2.end[other] <= hi) return shiftRange(range2, shift2);
49825
+ if (range2.start[other] >= lo && range2.end[other] <= hi) return shiftRange(range2, shift3);
49353
49826
  return range2;
49354
49827
  }
49355
49828
  function subtractRange(a2, b) {
@@ -49380,7 +49853,7 @@ function pointsAt(token2, formulaSheet, sheet) {
49380
49853
  if (!prefix) return formulaSheet.toLowerCase() === sheet.toLowerCase();
49381
49854
  return prefix.book === void 0 && prefix.sheet2 === void 0 && prefix.sheet.toLowerCase() === sheet.toLowerCase();
49382
49855
  }
49383
- function shiftFormulaInBand(formula2, formulaSheet, sheet, shift2, band) {
49856
+ function shiftFormulaInBand(formula2, formulaSheet, sheet, shift3, band) {
49384
49857
  let tokens2;
49385
49858
  try {
49386
49859
  tokens2 = tokenize(formula2);
@@ -49401,7 +49874,7 @@ function shiftFormulaInBand(formula2, formulaSheet, sheet, shift2, band) {
49401
49874
  },
49402
49875
  end: { row: Math.max(ref.start.row, ref.end.row), col: Math.max(ref.start.col, ref.end.col) }
49403
49876
  };
49404
- const moved = shiftRangeInBand(range2, shift2, band.lo, band.hi);
49877
+ const moved = shiftRangeInBand(range2, shift3, band.lo, band.hi);
49405
49878
  if (moved && sameRange2(moved, range2)) continue;
49406
49879
  const prefix = token2.prefix?.text ?? "";
49407
49880
  if (!moved) {
@@ -49439,15 +49912,15 @@ function carriedRefEdits(sourceSheets, currentSheets, shiftsOf = () => []) {
49439
49912
  edits.deleted.push(source3.name);
49440
49913
  continue;
49441
49914
  }
49442
- for (const shift2 of shiftsOf(current)) edits.shifts.push({ sheet: source3.name, shift: shift2 });
49915
+ for (const shift3 of shiftsOf(current)) edits.shifts.push({ sheet: source3.name, shift: shift3 });
49443
49916
  if (current.name !== source3.name) edits.renamed.push([source3.name, current.name]);
49444
49917
  }
49445
49918
  return edits;
49446
49919
  }
49447
49920
  var hasCarriedRefEdits = (edits) => edits.shifts.length > 0 || edits.deleted.length > 0 || edits.renamed.length > 0;
49448
- function shiftOne(formula2, formulaSheet, sheet, shift2) {
49449
- if (shift2.band) return shiftFormulaInBand(formula2, formulaSheet, sheet, shift2, shift2.band);
49450
- const spec2 = { sheet, axis: shift2.axis, at: shift2.at, count: shift2.count };
49921
+ function shiftOne(formula2, formulaSheet, sheet, shift3) {
49922
+ if (shift3.band) return shiftFormulaInBand(formula2, formulaSheet, sheet, shift3, shift3.band);
49923
+ const spec2 = { sheet, axis: shift3.axis, at: shift3.at, count: shift3.count };
49451
49924
  return shiftFormula(formula2, formulaSheet, spec2);
49452
49925
  }
49453
49926
  function renameAll(formula2, renamed, taken) {
@@ -49470,7 +49943,7 @@ var takenNames = (edits) => new Set(
49470
49943
  );
49471
49944
  function patchCarriedFormula(formula2, formulaSheet, edits) {
49472
49945
  let out = formula2;
49473
- for (const { sheet, shift: shift2 } of edits.shifts) out = shiftOne(out, formulaSheet, sheet, shift2);
49946
+ for (const { sheet, shift: shift3 } of edits.shifts) out = shiftOne(out, formulaSheet, sheet, shift3);
49474
49947
  for (const sheet of edits.deleted) out = deleteSheetInFormula(out, sheet);
49475
49948
  return renameAll(out, edits.renamed, takenNames(edits));
49476
49949
  }
@@ -51245,7 +51718,7 @@ function addChartSeries(space, input) {
51245
51718
  const group2 = groups.find((_, i2) => i2 === (input.groupIndex ?? groups.length - 1));
51246
51719
  if (!group2) throw new RangeError("The chart has no chart group to add a series to");
51247
51720
  const all2 = chartSpaceSeries(draft);
51248
- const template = all2[0];
51721
+ const template2 = all2[0];
51249
51722
  const series = {
51250
51723
  index: nextNumber(all2.map((item2) => item2.index)),
51251
51724
  order: nextNumber(all2.map((item2) => item2.order)),
@@ -51262,7 +51735,7 @@ function addChartSeries(space, input) {
51262
51735
  };
51263
51736
  else if (input.name !== void 0) series.tx = { value: input.name, text: input.name };
51264
51737
  if (input.spPr) series.spPr = structuredClone(input.spPr);
51265
- const templateCategories = template?.categories ?? template?.xValues;
51738
+ const templateCategories = template2?.categories ?? template2?.xValues;
51266
51739
  if (input.categories !== void 0)
51267
51740
  series[categoryKey(group2)] = categorySource(
51268
51741
  input.categories,
@@ -53308,8 +53781,8 @@ async function saveXlsx(workbook) {
53308
53781
 
53309
53782
  // xlsx/edit/shift-preserved.ts
53310
53783
  var XM3 = "http://schemas.microsoft.com/office/excel/2006/main";
53311
- function hasPreservedOverflow(sheet, shift2, clipped, banded) {
53312
- const keys = banded ? ["extLst"] : [shift2.axis === "row" ? "rowBreaks" : "colBreaks", "extLst"];
53784
+ function hasPreservedOverflow(sheet, shift3, clipped, banded) {
53785
+ const keys = banded ? ["extLst"] : [shift3.axis === "row" ? "rowBreaks" : "colBreaks", "extLst"];
53313
53786
  for (const key of keys)
53314
53787
  for (const xml of sheet.preserved.get(key) ?? []) {
53315
53788
  if (!xml.includes(key === "extLst" ? "sqref" : "brk")) continue;
@@ -53325,7 +53798,7 @@ function hasPreservedOverflow(sheet, shift2, clipped, banded) {
53325
53798
  ))
53326
53799
  return true;
53327
53800
  } else if (elements(root).some(
53328
- (node2) => node2.localName === "brk" && shiftIndex(Number(node2.getAttribute("id") ?? "0"), shift2) === void 0
53801
+ (node2) => node2.localName === "brk" && shiftIndex(Number(node2.getAttribute("id") ?? "0"), shift3) === void 0
53329
53802
  ))
53330
53803
  return true;
53331
53804
  }
@@ -53357,11 +53830,11 @@ function editEntries(sheet, key, edit, quick) {
53357
53830
  if (next.length) sheet.preserved.set(key, next);
53358
53831
  else sheet.preserved.delete(key);
53359
53832
  }
53360
- function shiftBreaks(root, shift2) {
53833
+ function shiftBreaks(root, shift3) {
53361
53834
  let changed = false;
53362
53835
  for (const brk of elements(root).filter((e) => e.localName === "brk")) {
53363
53836
  const id = Number(brk.getAttribute("id") ?? "0");
53364
- const moved = shiftIndex(id, shift2);
53837
+ const moved = shiftIndex(id, shift3);
53365
53838
  if (moved === id) continue;
53366
53839
  changed = true;
53367
53840
  if (moved === void 0 || moved === 0) root.removeChild(brk);
@@ -53406,12 +53879,12 @@ function shiftSqrefs(root, moveRange) {
53406
53879
  list2.setAttribute("count", String(elements(list2).length));
53407
53880
  return elements(root).length > 0 ? "changed" : "drop";
53408
53881
  }
53409
- function shiftPreservedXml(sheet, shift2, moveRange, banded) {
53882
+ function shiftPreservedXml(sheet, shift3, moveRange, banded) {
53410
53883
  if (!banded)
53411
53884
  editEntries(
53412
53885
  sheet,
53413
- shift2.axis === "row" ? "rowBreaks" : "colBreaks",
53414
- (root) => shiftBreaks(root, shift2),
53886
+ shift3.axis === "row" ? "rowBreaks" : "colBreaks",
53887
+ (root) => shiftBreaks(root, shift3),
53415
53888
  (xml) => xml.includes("brk")
53416
53889
  );
53417
53890
  editEntries(
@@ -54566,25 +55039,25 @@ function setBorders(ctx, s, range2, preset, edge2 = { style: "thin" }) {
54566
55039
  }
54567
55040
 
54568
55041
  // xlsx/edit/insert-guard.ts
54569
- function assertInsertFits(sheet, shift2, band) {
55042
+ function assertInsertFits(sheet, shift3, band) {
54570
55043
  for (const pivot of sheet.pivotTables ?? []) {
54571
- const start = pivot.location.start[shift2.axis];
54572
- const end = pivot.location.end[shift2.axis];
54573
- const other2 = shift2.axis === "row" ? "col" : "row";
55044
+ const start = pivot.location.start[shift3.axis];
55045
+ const end = pivot.location.end[shift3.axis];
55046
+ const other2 = shift3.axis === "row" ? "col" : "row";
54574
55047
  if (band && (band.hi < pivot.location.start[other2] || band.lo > pivot.location.end[other2]))
54575
55048
  continue;
54576
55049
  const partial = band && (band.lo > pivot.location.start[other2] || band.hi < pivot.location.end[other2]);
54577
- const overlap = shift2.count > 0 ? shift2.at > start && shift2.at <= end : shift2.at <= end && shift2.at - shift2.count > start;
54578
- if (overlap || partial && shift2.at <= end)
55050
+ const overlap = shift3.count > 0 ? shift3.at > start && shift3.at <= end : shift3.at <= end && shift3.at - shift3.count > start;
55051
+ if (overlap || partial && shift3.at <= end)
54579
55052
  throw new Error("Cannot move or remove part of a PivotTable. Delete the PivotTable first.");
54580
55053
  }
54581
- if (shift2.count <= 0) return;
54582
- const max = shift2.axis === "row" ? MAX_ROW : MAX_COL;
54583
- if (shift2.at + shift2.count > max + 1)
55054
+ if (shift3.count <= 0) return;
55055
+ const max = shift3.axis === "row" ? MAX_ROW : MAX_COL;
55056
+ if (shift3.at + shift3.count > max + 1)
54584
55057
  throw new RangeError("The insert area extends beyond the sheet.");
54585
- const first2 = max - shift2.count + 1;
54586
- const lost = shift2.axis === "row" ? cellRange(first2, band?.lo ?? 0, MAX_ROW, band?.hi ?? MAX_COL) : cellRange(band?.lo ?? 0, first2, band?.hi ?? MAX_ROW, MAX_COL);
54587
- const other = shift2.axis === "row" ? "col" : "row";
55058
+ const first2 = max - shift3.count + 1;
55059
+ 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);
55060
+ const other = shift3.axis === "row" ? "col" : "row";
54588
55061
  const clipped = (range2) => (!band || range2.start[other] >= band.lo && range2.end[other] <= band.hi) && rangesIntersect(range2, lost);
54589
55062
  const fail2 = () => {
54590
55063
  throw new Error("Cannot insert cells: non-empty cells would be pushed off the sheet.");
@@ -54595,14 +55068,14 @@ function assertInsertFits(sheet, shift2, band) {
54595
55068
  if (col >= lost.start.col && col <= lost.end.col && (!isEmptyCell(cell) || cell.cellMetadata !== void 0 || cell.valueMetadata !== void 0))
54596
55069
  fail2();
54597
55070
  }
54598
- 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, shift2, clipped, !!band))
55071
+ 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))
54599
55072
  fail2();
54600
55073
  for (const { anchor } of sheet.drawings) {
54601
55074
  if (band && (anchor.from[other] < band.lo || anchor.from[other] > band.hi)) continue;
54602
- if (anchor.from[shift2.axis] >= first2 || anchor.to && anchor.to[shift2.axis] >= first2) fail2();
55075
+ if (anchor.from[shift3.axis] >= first2 || anchor.to && anchor.to[shift3.axis] >= first2) fail2();
54603
55076
  }
54604
55077
  if (band) return;
54605
- if (shift2.axis === "row") {
55078
+ if (shift3.axis === "row") {
54606
55079
  for (const [row2, info] of sheet.rowInfo) if (row2 >= first2 && Object.keys(info).length) fail2();
54607
55080
  } else {
54608
55081
  if (normalizeColumns(sheet.columns).some((c2) => c2.min >= first2)) fail2();
@@ -54610,11 +55083,11 @@ function assertInsertFits(sheet, shift2, band) {
54610
55083
  }
54611
55084
 
54612
55085
  // xlsx/edit/shift-rule-anchors.ts
54613
- function rebaseRulesForDeletion(sheet, shift2, band) {
54614
- if (shift2.count >= 0) return;
54615
- const last = shift2.at - shift2.count - 1;
54616
- const removed = shift2.axis === "row" ? cellRange(shift2.at, band?.lo ?? 0, last, band?.hi ?? MAX_COL) : cellRange(band?.lo ?? 0, shift2.at, band?.hi ?? MAX_ROW, last);
54617
- const other = shift2.axis === "row" ? "col" : "row";
55086
+ function rebaseRulesForDeletion(sheet, shift3, band) {
55087
+ if (shift3.count >= 0) return;
55088
+ const last = shift3.at - shift3.count - 1;
55089
+ 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);
55090
+ const other = shift3.axis === "row" ? "col" : "row";
54618
55091
  const surviving = (ranges) => ranges.flatMap(
54619
55092
  (range2) => band && (range2.start[other] < band.lo || range2.end[other] > band.hi) ? [range2] : subtractRange(range2, removed)
54620
55093
  );
@@ -54862,10 +55335,10 @@ function shiftScenarios(sheet, move) {
54862
55335
  }
54863
55336
 
54864
55337
  // xlsx/edit/shift-sheet.ts
54865
- function shiftSheetContent(sheet, shift2, band) {
54866
- assertInsertFits(sheet, shift2, band);
54867
- const moveRange = (range2) => band ? shiftRangeInBand(range2, shift2, band.lo, band.hi) : shiftRange(range2, shift2);
54868
- shiftCells(sheet, shift2, band, moveRange);
55338
+ function shiftSheetContent(sheet, shift3, band) {
55339
+ assertInsertFits(sheet, shift3, band);
55340
+ const moveRange = (range2) => band ? shiftRangeInBand(range2, shift3, band.lo, band.hi) : shiftRange(range2, shift3);
55341
+ shiftCells(sheet, shift3, band, moveRange);
54869
55342
  sheet.merges = sheet.merges.map(moveRange).filter((m) => !!m && (m.start.row !== m.end.row || m.start.col !== m.end.col));
54870
55343
  sheet.conditionalFormats = sheet.conditionalFormats.map((cf) => ({ ...cf, ranges: cf.ranges.map(moveRange).filter((r) => !!r) })).filter((cf) => cf.ranges.length > 0);
54871
55344
  sheet.dataValidations = sheet.dataValidations.map((dv) => ({ ...dv, ranges: dv.ranges.map(moveRange).filter((r) => !!r) })).filter((dv) => dv.ranges.length > 0);
@@ -54877,7 +55350,7 @@ function shiftSheetContent(sheet, shift2, band) {
54877
55350
  const range2 = moveRange({ start: c2.address, end: c2.address });
54878
55351
  return range2 ? [{ ...c2, address: range2.start }] : [];
54879
55352
  });
54880
- sheet.tables = sheet.tables.flatMap((t) => shiftTable2(sheet, t, shift2, moveRange));
55353
+ sheet.tables = sheet.tables.flatMap((t) => shiftTable2(sheet, t, shift3, moveRange));
54881
55354
  shiftDataTables(sheet, moveRange);
54882
55355
  shiftScenarios(sheet, moveRange);
54883
55356
  for (const pivot of sheet.pivotTables ?? []) {
@@ -54887,8 +55360,8 @@ function shiftSheetContent(sheet, shift2, band) {
54887
55360
  pivot.dirty = true;
54888
55361
  }
54889
55362
  }
54890
- for (const drawing of sheet.drawings) shiftAnchor(drawing.anchor, shift2, band);
54891
- if (!band) shiftAxisFormats(sheet, shift2);
55363
+ for (const drawing of sheet.drawings) shiftAnchor(drawing.anchor, shift3, band);
55364
+ if (!band) shiftAxisFormats(sheet, shift3);
54892
55365
  if (sheet.autoFilter) {
54893
55366
  const old = sheet.autoFilter.range;
54894
55367
  const range2 = moveRange(old);
@@ -54897,39 +55370,39 @@ function shiftSheetContent(sheet, shift2, band) {
54897
55370
  clearFilteredRows(sheet);
54898
55371
  } else {
54899
55372
  const filter2 = { ...sheet.autoFilter, range: range2 };
54900
- if (shift2.axis === "col" && filter2.columns)
55373
+ if (shift3.axis === "col" && filter2.columns)
54901
55374
  filter2.columns = filter2.columns.flatMap((fc) => {
54902
- const abs3 = shiftIndex(old.start.col + fc.offset, shift2);
55375
+ const abs3 = shiftIndex(old.start.col + fc.offset, shift3);
54903
55376
  return abs3 === void 0 ? [] : [{ ...fc, offset: abs3 - range2.start.col }];
54904
55377
  });
54905
55378
  sheet.autoFilter = filter2;
54906
55379
  }
54907
55380
  }
54908
- if (!band) shiftFreeze(sheet, shift2);
55381
+ if (!band) shiftFreeze(sheet, shift3);
54909
55382
  const printArea = sheet.pageSetup?.printArea;
54910
55383
  if (sheet.pageSetup && printArea) {
54911
55384
  const moved = moveRange(printArea);
54912
55385
  if (moved) sheet.pageSetup.printArea = moved;
54913
55386
  else delete sheet.pageSetup.printArea;
54914
55387
  }
54915
- shiftPreservedXml(sheet, shift2, moveRange, !!band);
55388
+ shiftPreservedXml(sheet, shift3, moveRange, !!band);
54916
55389
  }
54917
- function shiftCells(sheet, shift2, band, moveRange) {
55390
+ function shiftCells(sheet, shift3, band, moveRange) {
54918
55391
  const old = sheet.rows;
54919
55392
  sheet.rows = /* @__PURE__ */ new Map();
54920
55393
  for (const [row2, cells] of old)
54921
55394
  for (const [col, cell] of cells) {
54922
- const along = shift2.axis === "row" ? row2 : col;
54923
- const across = shift2.axis === "row" ? col : row2;
55395
+ const along = shift3.axis === "row" ? row2 : col;
55396
+ const across = shift3.axis === "row" ? col : row2;
54924
55397
  const inBand = !band || across >= band.lo && across <= band.hi;
54925
- const moved = inBand ? shiftIndex(along, shift2) : along;
55398
+ const moved = inBand ? shiftIndex(along, shift3) : along;
54926
55399
  if (moved === void 0) continue;
54927
55400
  if (cell.arrayRange) {
54928
55401
  const range2 = moveRange(cell.arrayRange);
54929
55402
  if (range2) cell.arrayRange = range2;
54930
55403
  else delete cell.arrayRange;
54931
55404
  }
54932
- if (shift2.axis === "row") putCell(sheet, moved, col, cell);
55405
+ if (shift3.axis === "row") putCell(sheet, moved, col, cell);
54933
55406
  else putCell(sheet, row2, moved, cell);
54934
55407
  }
54935
55408
  }
@@ -54937,73 +55410,73 @@ function uniqueColumnName(columns) {
54937
55410
  const taken = new Set(columns.map((c2) => c2.name.toLowerCase()));
54938
55411
  for (let n2 = 1; ; n2++) if (!taken.has(`column${n2}`)) return `Column${n2}`;
54939
55412
  }
54940
- function shiftTable2(sheet, table3, shift2, moveRange) {
55413
+ function shiftTable2(sheet, table3, shift3, moveRange) {
54941
55414
  const old = table3.range;
54942
55415
  const range2 = moveRange(old);
54943
55416
  if (!range2) return [];
54944
55417
  const next = { ...table3, range: range2, columns: [...table3.columns] };
54945
55418
  const widened = range2.end.col - range2.start.col !== old.end.col - old.start.col;
54946
- if (shift2.axis === "col" && widened) {
54947
- if (shift2.count > 0) {
54948
- const offset2 = shift2.at - old.start.col;
54949
- for (let i2 = 0; i2 < shift2.count; i2++) {
55419
+ if (shift3.axis === "col" && widened) {
55420
+ if (shift3.count > 0) {
55421
+ const offset2 = shift3.at - old.start.col;
55422
+ for (let i2 = 0; i2 < shift3.count; i2++) {
54950
55423
  const column2 = { name: uniqueColumnName(next.columns) };
54951
55424
  next.columns.splice(offset2 + i2, 0, column2);
54952
55425
  if (next.headerRow) {
54953
55426
  const cell = { value: column2.name };
54954
- putCell(sheet, range2.start.row, shift2.at + i2, cell);
55427
+ putCell(sheet, range2.start.row, shift3.at + i2, cell);
54955
55428
  }
54956
55429
  }
54957
55430
  } else {
54958
55431
  next.columns = next.columns.filter(
54959
- (_c, i2) => shiftIndex(old.start.col + i2, shift2) !== void 0
55432
+ (_c, i2) => shiftIndex(old.start.col + i2, shift3) !== void 0
54960
55433
  );
54961
55434
  }
54962
55435
  }
54963
55436
  return [next];
54964
55437
  }
54965
- function shiftAnchor(anchor, shift2, band) {
54966
- const key = shift2.axis === "row" ? "row" : "col";
54967
- const other = shift2.axis === "row" ? "col" : "row";
55438
+ function shiftAnchor(anchor, shift3, band) {
55439
+ const key = shift3.axis === "row" ? "row" : "col";
55440
+ const other = shift3.axis === "row" ? "col" : "row";
54968
55441
  if (band && (anchor.from[other] < band.lo || anchor.from[other] > band.hi)) return;
54969
55442
  const from = anchor.from[key];
54970
- const movedFrom = shiftIndexClamped(from, shift2);
54971
- if (shiftIndex(from, shift2) === void 0)
55443
+ const movedFrom = shiftIndexClamped(from, shift3);
55444
+ if (shiftIndex(from, shift3) === void 0)
54972
55445
  anchor.from[key === "row" ? "rowOffset" : "colOffset"] = 0;
54973
55446
  anchor.from[key] = movedFrom;
54974
55447
  if (anchor.to) {
54975
55448
  const to = anchor.to[key];
54976
- const moved = shiftIndex(to, shift2);
55449
+ const moved = shiftIndex(to, shift3);
54977
55450
  if (moved === void 0) {
54978
- anchor.to[key] = Math.max(movedFrom, shiftIndexClamped(to, shift2));
55451
+ anchor.to[key] = Math.max(movedFrom, shiftIndexClamped(to, shift3));
54979
55452
  anchor.to[key === "row" ? "rowOffset" : "colOffset"] = 0;
54980
55453
  } else anchor.to[key] = moved;
54981
55454
  }
54982
55455
  }
54983
- function shiftAxisFormats(sheet, shift2) {
54984
- if (shift2.axis === "row") {
55456
+ function shiftAxisFormats(sheet, shift3) {
55457
+ if (shift3.axis === "row") {
54985
55458
  const old = sheet.rowInfo;
54986
55459
  sheet.rowInfo = /* @__PURE__ */ new Map();
54987
55460
  for (const [row2, info] of old) {
54988
- const moved = shiftIndex(row2, shift2);
55461
+ const moved = shiftIndex(row2, shift3);
54989
55462
  if (moved !== void 0) sheet.rowInfo.set(moved, info);
54990
55463
  }
54991
55464
  return;
54992
55465
  }
54993
55466
  sheet.columns = normalizeColumns(
54994
55467
  sheet.columns.flatMap((info) => {
54995
- const span5 = shiftSpan(info.min, info.max, shift2);
55468
+ const span5 = shiftSpan(info.min, info.max, shift3);
54996
55469
  return span5 ? [{ ...info, min: span5.start, max: span5.end }] : [];
54997
55470
  })
54998
55471
  );
54999
55472
  }
55000
- function shiftFreeze(sheet, shift2) {
55473
+ function shiftFreeze(sheet, shift3) {
55001
55474
  const freeze = sheet.view.freeze;
55002
55475
  if (!freeze) return;
55003
- const key = shift2.axis === "row" ? "rows" : "cols";
55476
+ const key = shift3.axis === "row" ? "rows" : "cols";
55004
55477
  const frozen = freeze[key];
55005
- if (shift2.at >= frozen) return;
55006
- const next = shift2.count > 0 ? frozen + shift2.count : frozen - Math.min(-shift2.count, frozen - shift2.at);
55478
+ if (shift3.at >= frozen) return;
55479
+ const next = shift3.count > 0 ? frozen + shift3.count : frozen - Math.min(-shift3.count, frozen - shift3.at);
55007
55480
  sheet.view.freeze = { ...freeze, [key]: next };
55008
55481
  }
55009
55482
 
@@ -55013,15 +55486,15 @@ function checkSpan(axis, at2, count2) {
55013
55486
  if (!Number.isInteger(at2) || !Number.isInteger(count2) || at2 < 0 || at2 > max || count2 < 1 || at2 + count2 > max + 1)
55014
55487
  throw new RangeError(`Invalid ${axis} span ${at2} + ${count2}`);
55015
55488
  }
55016
- function applyAxisShift(ctx, sheet, shift2) {
55017
- assertInsertFits(sheet, shift2);
55018
- rebaseRulesForDeletion(sheet, shift2);
55019
- const spec2 = { sheet: sheet.name, axis: shift2.axis, at: shift2.at, count: shift2.count };
55489
+ function applyAxisShift(ctx, sheet, shift3) {
55490
+ assertInsertFits(sheet, shift3);
55491
+ rebaseRulesForDeletion(sheet, shift3);
55492
+ const spec2 = { sheet: sheet.name, axis: shift3.axis, at: shift3.at, count: shift3.count };
55020
55493
  rewriteFormulas(
55021
55494
  ctx.workbook,
55022
55495
  (formula2, formulaSheet) => shiftFormula(formula2, formulaSheet, spec2)
55023
55496
  );
55024
- shiftSheetContent(sheet, shift2);
55497
+ shiftSheetContent(sheet, shift3);
55025
55498
  }
55026
55499
  function inheritFormats(sheet, axis, at2, count2) {
55027
55500
  if (at2 === 0) return;
@@ -55047,17 +55520,17 @@ function shiftAxis(ctx, s, axis, at2, count2, insert2) {
55047
55520
  checkSpan(axis, at2, count2);
55048
55521
  const sheet = sheetAt(ctx.workbook, s);
55049
55522
  const noun = axis === "row" ? count2 === 1 ? "row" : "rows" : count2 === 1 ? "column" : "columns";
55050
- const shift2 = { axis, at: at2, count: insert2 ? count2 : -count2 };
55051
- assertInsertFits(sheet, shift2);
55523
+ const shift3 = { axis, at: at2, count: insert2 ? count2 : -count2 };
55524
+ assertInsertFits(sheet, shift3);
55052
55525
  const info = { sheet: s, structural: true };
55053
- if (!sheet.autoFilter || shiftRange(sheet.autoFilter.range, shift2))
55054
- info.calc = { kind: "shift", sheet: s, shift: shift2 };
55526
+ if (!sheet.autoFilter || shiftRange(sheet.autoFilter.range, shift3))
55527
+ info.calc = { kind: "shift", sheet: s, shift: shift3 };
55055
55528
  ctx.run(
55056
55529
  `${insert2 ? "Insert" : "Delete"} ${noun}`,
55057
55530
  "structure",
55058
- [{ kind: "shift", sheet: s, shift: shift2 }],
55531
+ [{ kind: "shift", sheet: s, shift: shift3 }],
55059
55532
  () => {
55060
- applyAxisShift(ctx, sheet, shift2);
55533
+ applyAxisShift(ctx, sheet, shift3);
55061
55534
  if (insert2) inheritFormats(sheet, axis, at2, count2);
55062
55535
  },
55063
55536
  info
@@ -55069,9 +55542,9 @@ var insertColumns = (ctx, s, at2, count2) => shiftAxis(ctx, s, "col", at2, count
55069
55542
  var deleteColumns = (ctx, s, at2, count2) => shiftAxis(ctx, s, "col", at2, count2, false);
55070
55543
 
55071
55544
  // xlsx/edit/cell-shift.ts
55072
- function assertBandIntact(sheet, shift2, band) {
55073
- const zone = shift2.axis === "row" ? cellRange(shift2.at, band.lo, MAX_ROW, band.hi) : cellRange(band.lo, shift2.at, band.hi, MAX_COL);
55074
- const other = shift2.axis === "row" ? "col" : "row";
55545
+ function assertBandIntact(sheet, shift3, band) {
55546
+ const zone = shift3.axis === "row" ? cellRange(shift3.at, band.lo, MAX_ROW, band.hi) : cellRange(band.lo, shift3.at, band.hi, MAX_COL);
55547
+ const other = shift3.axis === "row" ? "col" : "row";
55075
55548
  const torn = (r) => rangesIntersect(r, zone) && (r.start[other] < band.lo || r.end[other] > band.hi);
55076
55549
  if (sheet.merges.some(torn))
55077
55550
  throw new Error("Cannot shift cells: a merged range would be split.");
@@ -55084,25 +55557,25 @@ function shiftBand(ctx, s, range2, direction) {
55084
55557
  const vertical2 = direction === "down" || direction === "up";
55085
55558
  const insert2 = direction === "down" || direction === "right";
55086
55559
  const size = vertical2 ? r.end.row - r.start.row + 1 : r.end.col - r.start.col + 1;
55087
- const shift2 = {
55560
+ const shift3 = {
55088
55561
  axis: vertical2 ? "row" : "col",
55089
55562
  at: vertical2 ? r.start.row : r.start.col,
55090
55563
  count: insert2 ? size : -size
55091
55564
  };
55092
55565
  const band = vertical2 ? { lo: r.start.col, hi: r.end.col } : { lo: r.start.row, hi: r.end.row };
55093
- assertBandIntact(sheet, shift2, band);
55094
- assertInsertFits(sheet, shift2, band);
55566
+ assertBandIntact(sheet, shift3, band);
55567
+ assertInsertFits(sheet, shift3, band);
55095
55568
  ctx.run(
55096
55569
  `${insert2 ? "Insert" : "Delete"} cells`,
55097
55570
  "structure",
55098
- [{ kind: "shift", sheet: s, shift: shift2, band }],
55571
+ [{ kind: "shift", sheet: s, shift: shift3, band }],
55099
55572
  () => {
55100
- rebaseRulesForDeletion(sheet, shift2, band);
55573
+ rebaseRulesForDeletion(sheet, shift3, band);
55101
55574
  rewriteFormulas(
55102
55575
  ctx.workbook,
55103
- (formula2, formulaSheet) => shiftFormulaInBand(formula2, formulaSheet, sheet.name, shift2, band)
55576
+ (formula2, formulaSheet) => shiftFormulaInBand(formula2, formulaSheet, sheet.name, shift3, band)
55104
55577
  );
55105
- shiftSheetContent(sheet, shift2, band);
55578
+ shiftSheetContent(sheet, shift3, band);
55106
55579
  },
55107
55580
  { sheet: s, ranges: [r], structural: true }
55108
55581
  );
@@ -56630,14 +57103,14 @@ function restoreRefs(workbook, data) {
56630
57103
  }
56631
57104
  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;
56632
57105
  var sameEntry = (a2, b) => a2.formula === b.formula && sameRange3(a2.arrayRange, b.arrayRange);
56633
- function movePosition(spec2, shift2, s, row2, col) {
56634
- if (!spec2 || !shift2 || s !== spec2.sheet) return [row2, col];
56635
- const along = shift2.axis === "row" ? row2 : col;
56636
- const across = shift2.axis === "row" ? col : row2;
57106
+ function movePosition(spec2, shift3, s, row2, col) {
57107
+ if (!spec2 || !shift3 || s !== spec2.sheet) return [row2, col];
57108
+ const along = shift3.axis === "row" ? row2 : col;
57109
+ const across = shift3.axis === "row" ? col : row2;
56637
57110
  if (spec2.band && (across < spec2.band.lo || across > spec2.band.hi)) return [row2, col];
56638
- const moved = shiftIndex(along, shift2);
57111
+ const moved = shiftIndex(along, shift3);
56639
57112
  if (moved === void 0) return void 0;
56640
- return shift2.axis === "row" ? [moved, col] : [row2, moved];
57113
+ return shift3.axis === "row" ? [moved, col] : [row2, moved];
56641
57114
  }
56642
57115
  function diffRefs(workbook, before, spec2) {
56643
57116
  const keptBefore = [];
@@ -56658,37 +57131,37 @@ function diffRefs(workbook, before, spec2) {
56658
57131
  before.formulas = keptBefore;
56659
57132
  return keptAfter;
56660
57133
  }
56661
- function moveCellsRaw(sheet, shift2, band) {
57134
+ function moveCellsRaw(sheet, shift3, band) {
56662
57135
  const old = sheet.rows;
56663
57136
  sheet.rows = /* @__PURE__ */ new Map();
56664
- if (shift2.axis === "row" && !band) {
57137
+ if (shift3.axis === "row" && !band) {
56665
57138
  for (const [row2, cells] of old) {
56666
- const moved = shiftIndex(row2, shift2);
57139
+ const moved = shiftIndex(row2, shift3);
56667
57140
  if (moved !== void 0) sheet.rows.set(moved, cells);
56668
57141
  }
56669
57142
  return;
56670
57143
  }
56671
57144
  for (const [row2, cells] of old)
56672
57145
  for (const [col, cell] of cells) {
56673
- const along = shift2.axis === "row" ? row2 : col;
56674
- const across = shift2.axis === "row" ? col : row2;
57146
+ const along = shift3.axis === "row" ? row2 : col;
57147
+ const across = shift3.axis === "row" ? col : row2;
56675
57148
  const inBand = !band || across >= band.lo && across <= band.hi;
56676
- const moved = inBand ? shiftIndex(along, shift2) : along;
57149
+ const moved = inBand ? shiftIndex(along, shift3) : along;
56677
57150
  if (moved === void 0) continue;
56678
- if (shift2.axis === "row") putCell(sheet, moved, col, cell);
57151
+ if (shift3.axis === "row") putCell(sheet, moved, col, cell);
56679
57152
  else putCell(sheet, row2, moved, cell);
56680
57153
  }
56681
57154
  }
56682
57155
  function shiftEdgeCells(sheet, spec2, phase) {
56683
- const { shift: shift2, band } = spec2;
57156
+ const { shift: shift3, band } = spec2;
56684
57157
  const out = [];
56685
- if (phase === "after" && shift2.count < 0) return out;
56686
- const hit = (along) => phase === "before" ? shiftIndex(along, shift2) === void 0 : along >= shift2.at && along < shift2.at + shift2.count;
57158
+ if (phase === "after" && shift3.count < 0) return out;
57159
+ const hit = (along) => phase === "before" ? shiftIndex(along, shift3) === void 0 : along >= shift3.at && along < shift3.at + shift3.count;
56687
57160
  for (const [row2, cells] of sheet.rows) {
56688
- if (shift2.axis === "row" && !hit(row2)) continue;
57161
+ if (shift3.axis === "row" && !hit(row2)) continue;
56689
57162
  for (const [col, cell] of cells) {
56690
- const along = shift2.axis === "row" ? row2 : col;
56691
- const across = shift2.axis === "row" ? col : row2;
57163
+ const along = shift3.axis === "row" ? row2 : col;
57164
+ const across = shift3.axis === "row" ? col : row2;
56692
57165
  if (band && (across < band.lo || across > band.hi)) continue;
56693
57166
  if (hit(along)) out.push([row2, col, structuredClone(cell)]);
56694
57167
  }
@@ -56831,8 +57304,8 @@ function restoreShift(workbook, snapshot2) {
56831
57304
  const { spec: spec2 } = snapshot2;
56832
57305
  const sheet = workbook.sheets[spec2.sheet];
56833
57306
  if (!sheet) return;
56834
- const shift2 = snapshot2.phase === "before" ? { ...spec2.shift, count: -spec2.shift.count } : spec2.shift;
56835
- moveCellsRaw(sheet, shift2, spec2.band);
57307
+ const shift3 = snapshot2.phase === "before" ? { ...spec2.shift, count: -spec2.shift.count } : spec2.shift;
57308
+ moveCellsRaw(sheet, shift3, spec2.band);
56836
57309
  for (const [row2, col, cell] of snapshot2.cells) putCell(sheet, row2, col, cloneCell(cell));
56837
57310
  restoreRefs(workbook, snapshot2.data);
56838
57311
  workbook.activeSheet = snapshot2.activeSheet;
@@ -61256,8 +61729,8 @@ function scottBinCount(values2, min, max) {
61256
61729
  if (values2.length < 2 || max <= min) {
61257
61730
  return 1;
61258
61731
  }
61259
- const mean4 = values2.reduce((sum3, value3) => sum3 + value3, 0) / values2.length;
61260
- const variance3 = values2.reduce((sum3, value3) => sum3 + (value3 - mean4) ** 2, 0) / (values2.length - 1);
61732
+ const mean9 = values2.reduce((sum3, value3) => sum3 + value3, 0) / values2.length;
61733
+ const variance3 = values2.reduce((sum3, value3) => sum3 + (value3 - mean9) ** 2, 0) / (values2.length - 1);
61261
61734
  const sd = Math.sqrt(variance3);
61262
61735
  if (!(sd > 0)) {
61263
61736
  return 1;
@@ -61509,8 +61982,8 @@ function fitChartTrendline(options7, xVals, yVals) {
61509
61982
  function chartSampleVariance(values2) {
61510
61983
  const count2 = values2.length;
61511
61984
  if (count2 === 0) return 0;
61512
- const mean4 = values2.reduce((sum3, value3) => sum3 + value3, 0) / count2;
61513
- return values2.reduce((sum3, value3) => sum3 + (value3 - mean4) ** 2, 0) / Math.max(count2 - 1, 1);
61985
+ const mean9 = values2.reduce((sum3, value3) => sum3 + value3, 0) / count2;
61986
+ return values2.reduce((sum3, value3) => sum3 + (value3 - mean9) ** 2, 0) / Math.max(count2 - 1, 1);
61514
61987
  }
61515
61988
  function chartErrorBarAmount(options7, values2, displayIndex, sourceIndex, side) {
61516
61989
  switch (options7.valueType) {
@@ -62378,7 +62851,7 @@ function boxWhiskerSvg(model2, frame2, out) {
62378
62851
  trim2
62379
62852
  );
62380
62853
  if (!distribution) return;
62381
- const { stats, whiskerMin, whiskerMax, mean: mean4 } = distribution;
62854
+ const { stats, whiskerMin, whiskerMax, mean: mean9 } = distribution;
62382
62855
  const x = frame2.band(ci) - frame2.bandSize / 2 + si * slot2 + (slot2 - width) / 2;
62383
62856
  const mid = x + width / 2;
62384
62857
  const y = frame2.value;
@@ -62403,10 +62876,10 @@ function boxWhiskerSvg(model2, frame2, out) {
62403
62876
  )
62404
62877
  );
62405
62878
  out.push(line3(x, y(stats.median), x + width, y(stats.median), "#1e293b", 2));
62406
- if (visibility?.meanLine) out.push(line3(x, y(mean4), x + width, y(mean4), "#0f766e", 1.5));
62879
+ if (visibility?.meanLine) out.push(line3(x, y(mean9), x + width, y(mean9), "#0f766e", 1.5));
62407
62880
  if (visibility?.meanMarker !== false)
62408
62881
  out.push(
62409
- `<path d="${boxMeanMarkerPath(mid, y(mean4))}" fill="none" stroke="#0f766e" stroke-width="1.5" data-chart-part="mean"/>`
62882
+ `<path d="${boxMeanMarkerPath(mid, y(mean9))}" fill="none" stroke="#0f766e" stroke-width="1.5" data-chart-part="mean"/>`
62410
62883
  );
62411
62884
  observations.forEach((point2, index3) => {
62412
62885
  const outlier = point2.value < whiskerMin || point2.value > whiskerMax;
@@ -62652,10 +63125,10 @@ function categoryAnalysis(model2, frame2, out) {
62652
63125
  const layout2 = barred ? barLayout(model2, frame2) : void 0;
62653
63126
  model2.series.forEach((series, si) => {
62654
63127
  if (!series.trendlines && !series.errorBars) return;
62655
- const shift2 = layout2 ? layout2.offset(si) + layout2.barSize / 2 : 0;
63128
+ const shift3 = layout2 ? layout2.offset(si) + layout2.barSize / 2 : 0;
62656
63129
  const barPlane = (x, y) => {
62657
63130
  const [px, py] = plane(x, y);
62658
- return model2.horizontal ? [px, py + shift2] : [px + shift2, py];
63131
+ return model2.horizontal ? [px, py + shift3] : [px + shift3, py];
62659
63132
  };
62660
63133
  seriesAnalysis(series, si, (i2) => i2 + 1, plane, barPlane, true, out);
62661
63134
  });
@@ -65539,11 +66012,11 @@ var byId = (sheet, id) => {
65539
66012
  return table3;
65540
66013
  };
65541
66014
  function insertBandRow(workbook, sheet, table3, row2) {
65542
- const shift2 = { axis: "row", at: row2, count: 1 };
66015
+ const shift3 = { axis: "row", at: row2, count: 1 };
65543
66016
  const band = { lo: table3.range.start.col, hi: table3.range.end.col };
65544
- assertInsertFits(sheet, shift2, band);
65545
- rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift2, band));
65546
- shiftSheetContent(sheet, shift2, band);
66017
+ assertInsertFits(sheet, shift3, band);
66018
+ rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift3, band));
66019
+ shiftSheetContent(sheet, shift3, band);
65547
66020
  }
65548
66021
  function setHeaderRow(workbook, sheet, id, on) {
65549
66022
  let table3 = byId(sheet, id);
@@ -68580,10 +69053,10 @@ function createTable(ctx, s, range2, hasHeader, styleName = "TableStyleMedium2")
68580
69053
  [hasHeader ? { kind: "sheet", sheet: s } : { kind: "workbook" }],
68581
69054
  () => {
68582
69055
  if (!hasHeader) {
68583
- const shift2 = { axis: "row", at: r.start.row, count: 1 };
69056
+ const shift3 = { axis: "row", at: r.start.row, count: 1 };
68584
69057
  const band = { lo: r.start.col, hi: r.end.col };
68585
- rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift2, band));
68586
- shiftSheetContent(sheet, shift2, band);
69058
+ rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift3, band));
69059
+ shiftSheetContent(sheet, shift3, band);
68587
69060
  r = { start: r.start, end: { row: r.end.row + 1, col: r.end.col } };
68588
69061
  }
68589
69062
  const width = r.end.col - r.start.col + 1;