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
@@ -6562,14 +6562,14 @@ function linearFit(xs, ys) {
6562
6562
  return { slope, intercept: my - slope * mx };
6563
6563
  }
6564
6564
  function rank(values2, x, ascending, average) {
6565
- let better = 0;
6565
+ let better2 = 0;
6566
6566
  let ties = 0;
6567
6567
  for (const v of values2) {
6568
6568
  if (v === x) ties++;
6569
- else if (ascending ? v < x : v > x) better++;
6569
+ else if (ascending ? v < x : v > x) better2++;
6570
6570
  }
6571
6571
  if (ties === 0) fail(ERR.NA);
6572
- return average ? better + (ties + 1) / 2 : better + 1;
6572
+ return average ? better2 + (ties + 1) / 2 : better2 + 1;
6573
6573
  }
6574
6574
  var LANCZOS = [
6575
6575
  676.5203681218851,
@@ -11615,11 +11615,11 @@ function binomDist(k, n2, p, cumulative2) {
11615
11615
  for (let i2 = 0; i2 <= kk; i2++) total2 += binomPmf(i2, nn, p);
11616
11616
  return Math.min(1, total2);
11617
11617
  }
11618
- function poisson(k, mean4, cumulative2) {
11618
+ function poisson(k, mean9, cumulative2) {
11619
11619
  const kk = Math.trunc(k);
11620
- if (kk < 0 || mean4 < 0) fail(ERR.NUM);
11621
- if (cumulative2) return 1 - gammaP(kk + 1, mean4);
11622
- return Math.exp(kk * Math.log(mean4) - mean4 - gammaLn(kk + 1));
11620
+ if (kk < 0 || mean9 < 0) fail(ERR.NUM);
11621
+ if (cumulative2) return 1 - gammaP(kk + 1, mean9);
11622
+ return Math.exp(kk * Math.log(mean9) - mean9 - gammaLn(kk + 1));
11623
11623
  }
11624
11624
  var normDist = (x, m, s, cumulative2) => {
11625
11625
  positive2(s);
@@ -11627,13 +11627,272 @@ var normDist = (x, m, s, cumulative2) => {
11627
11627
  return cumulative2 ? normCdf(z) : normPdf(z) / s;
11628
11628
  };
11629
11629
 
11630
+ // xlsx/formula/functions/ets-init-three.ts
11631
+ var mean2 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11632
+ function slopeOf(v) {
11633
+ const k = v.length;
11634
+ const mx = (k - 1) / 2;
11635
+ const my = mean2(v);
11636
+ let sxy = 0;
11637
+ let sxx = 0;
11638
+ for (let i2 = 0; i2 < k; i2++) {
11639
+ sxy += (i2 - mx) * (v[i2] - my);
11640
+ sxx += (i2 - mx) * (i2 - mx);
11641
+ }
11642
+ return sxx === 0 ? 0 : sxy / sxx;
11643
+ }
11644
+ function positionSlopes(y, m) {
11645
+ return Array.from({ length: m }, (_v, c2) => {
11646
+ const vals = [];
11647
+ for (let t = c2; t < y.length; t += m) vals.push(y[t]);
11648
+ return slopeOf(vals) / m;
11649
+ });
11650
+ }
11651
+ function isThreeSeasonLength(n2, m) {
11652
+ return m >= 4 && n2 >= 3 * m && n2 <= 3 * m + Math.ceil(m / 2) + 1;
11653
+ }
11654
+ function threeSeasonSeasonals(y, m, slopeSumOverride) {
11655
+ const n2 = y.length;
11656
+ const extra = n2 - 3 * m;
11657
+ const j0 = Math.floor(m / 2);
11658
+ const at2 = (t) => y[t];
11659
+ const slope = (j) => (at2(j + 2 * m) - at2(j)) / (2 * m);
11660
+ const B = (j) => j + 2 * m < n2 ? slope(j) : slope(j % m);
11661
+ const e = (t) => at2(t) - at2(t - 1) - B(t - j0);
11662
+ const slopeSum = slopeSumOverride ?? positionSlopes(y, m).reduce((a2, b) => a2 + b, 0);
11663
+ const out = [0];
11664
+ for (let k = 1; k < m; k++) {
11665
+ let back = 0;
11666
+ for (let t = k + 1; t <= m; t++) back -= e(t);
11667
+ let fwd = 0;
11668
+ for (let t = m + 1; t <= m + k; t++) fwd += e(t);
11669
+ if (k < j0 - 1) {
11670
+ out.push(fwd);
11671
+ continue;
11672
+ }
11673
+ if (k === m - 1 && extra <= Math.ceil(m / 2)) {
11674
+ out.push(back);
11675
+ continue;
11676
+ }
11677
+ const wrapped = Math.max(0, k - j0 + 1 - extra);
11678
+ let corner4 = 0;
11679
+ for (let i2 = extra; i2 <= k - j0; i2++)
11680
+ corner4 += (at2(i2 + m) + at2(i2 + 2 * m) - 2 * at2(i2)) / (4 * m);
11681
+ const level4 = (at2(k) + at2(m + k)) / 2 - at2(m);
11682
+ const bb = back - (at2(k) - at2(m));
11683
+ const ff = fwd - (at2(m + k) - at2(m));
11684
+ out.push(level4 + (bb + ff) / 2 - 3 * wrapped / (4 * m) * slopeSum + corner4);
11685
+ }
11686
+ return out;
11687
+ }
11688
+ function padThreeSeasons(y, m, slopeMean = mean2(positionSlopes(y, m))) {
11689
+ const n2 = y.length;
11690
+ const total2 = Math.max(3 * m + Math.ceil(m / 2), n2);
11691
+ const ext = [...y];
11692
+ for (let t = n2; t < total2; t++) ext.push(y[t - 3 * m] + 3 * m * slopeMean);
11693
+ return ext;
11694
+ }
11695
+ function threeSeasonTrend(y, m, rel, slopeMean) {
11696
+ const ext = padThreeSeasons(y, m, slopeMean);
11697
+ const total2 = ext.length;
11698
+ const mx = (total2 - 1) / 2;
11699
+ let sxx = 0;
11700
+ let sxy = 0;
11701
+ for (let t = 0; t < total2; t++) {
11702
+ sxx += (t - mx) * (t - mx);
11703
+ sxy += (t - mx) * (ext[t] - rel[t % m]);
11704
+ }
11705
+ return sxy / sxx;
11706
+ }
11707
+ function isTwoSeasonLength(n2, m) {
11708
+ return m >= 4 && n2 === 2 * m;
11709
+ }
11710
+ function isTwoPlusLength(n2, m) {
11711
+ return m >= 4 && n2 > 2 * m && n2 < 3 * m;
11712
+ }
11713
+ function slopeSumOf(y, m) {
11714
+ return positionSlopes(y, m).reduce((a2, c2) => a2 + c2, 0);
11715
+ }
11716
+ function extendTwoSeasons(y, m) {
11717
+ const b = mean2(positionSlopes(y, m));
11718
+ const out = [...y];
11719
+ for (let t = y.length; t < 3 * m; t++) out.push(y[t - 2 * m] + 2 * m * b);
11720
+ return out;
11721
+ }
11722
+ function paddedSearchSeries(y, m) {
11723
+ if (isTwoSeasonLength(y.length, m) || isTwoPlusLength(y.length, m))
11724
+ return padThreeSeasons(extendTwoSeasons(y, m), m, slopeSumOf(y, m) / m);
11725
+ if (isThreeSeasonLength(y.length, m)) return padThreeSeasons(y, m);
11726
+ return void 0;
11727
+ }
11728
+
11729
+ // xlsx/formula/functions/ets-init-states.ts
11730
+ var mean3 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11731
+ function chainStates(y, m, seasons) {
11732
+ const h2 = Math.floor(seasons / 2);
11733
+ const first2 = seasons - h2;
11734
+ const at2 = (t) => y[t];
11735
+ const meanFirst = (t) => mean3(Array.from({ length: first2 }, (_v, c2) => at2(t + c2 * m)));
11736
+ const slope = (j) => {
11737
+ const early = mean3(Array.from({ length: h2 }, (_v, c2) => at2(j + c2 * m)));
11738
+ const late = mean3(Array.from({ length: h2 }, (_v, c2) => at2(j + (seasons - h2 + c2) * m)));
11739
+ return (late - early) / ((seasons - h2) * m);
11740
+ };
11741
+ const j0 = Math.floor(m / 2);
11742
+ const state = /* @__PURE__ */ new Map([[j0 - 1, 0]]);
11743
+ for (let t = j0; t <= j0 + m - 2; t++)
11744
+ state.set(t, state.get(t - 1) + meanFirst(t) - meanFirst(t - 1) - slope(t - j0));
11745
+ const byPosition2 = new Array(m).fill(0);
11746
+ for (const [t, s] of state) byPosition2[t % m] = s;
11747
+ return byPosition2;
11748
+ }
11749
+ function chainSeasonals(y, m, seasons) {
11750
+ const byPosition2 = chainStates(y, m, seasons);
11751
+ const origin = byPosition2[0];
11752
+ return byPosition2.map((s) => s - origin);
11753
+ }
11754
+
11755
+ // xlsx/formula/functions/ets-init-four.ts
11756
+ var mean4 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11757
+ function template(w, m, a2) {
11758
+ const block = (c2) => mean4(w.slice(c2 * m, (c2 + 1) * m));
11759
+ const at2 = (i2) => w[i2];
11760
+ return (block(0) - block(2)) / 12 + (block(1) - block(3)) / 6 - (at2(a2) + at2(a2 + m) - 2 * at2(a2 + 2 * m)) / 6;
11761
+ }
11762
+ function fourSeasonPlusSeasonals(y, m) {
11763
+ const r = y.length - 4 * m;
11764
+ const a2 = Math.floor(m / 2) - 1;
11765
+ const states = chainStates(y.slice(0, 4 * m), m, 4);
11766
+ for (let q = 0; q < r; q++) {
11767
+ const pos = (a2 + q) % m;
11768
+ states[pos] = states[pos] + template(y.slice(q, q + 4 * m), m, a2);
11769
+ }
11770
+ const origin = states[0];
11771
+ return states.map((s) => s - origin);
11772
+ }
11773
+
11774
+ // xlsx/formula/functions/ets-init-threeplus.ts
11775
+ var mean5 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11776
+ function isThreePlusLength(n2, m) {
11777
+ return m >= 4 && n2 >= 3 * m + Math.ceil(m / 2) + 2 && n2 < 4 * m;
11778
+ }
11779
+ function shift2(y, m, k) {
11780
+ const a2 = Math.ceil(m / 2) + 1;
11781
+ const at2 = (i2) => y[i2];
11782
+ 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;
11783
+ }
11784
+ function isLowThreeLength(n2, m) {
11785
+ return m === 2 && n2 >= 5 && n2 < 8 || m === 3 && n2 >= 6 && n2 < 12;
11786
+ }
11787
+ function lowSeasonSeasonals(y, m, slopeSum) {
11788
+ const base = threeSeasonSeasonals(y, m, slopeSum);
11789
+ const d = -shift2(y, m, -m);
11790
+ return base.map((s, k) => k === 0 ? 0 : s + d);
11791
+ }
11792
+ function threePlusSeasonals(y, m) {
11793
+ const base = threeSeasonSeasonals(y, m);
11794
+ const moved = y.length - 3 * m - Math.ceil(m / 2) - 1;
11795
+ const z = base.map((s, k) => k < moved ? s - shift2(y, m, k) : s);
11796
+ const origin = z[0];
11797
+ return z.map((s) => s - origin);
11798
+ }
11799
+
11800
+ // xlsx/formula/functions/ets-init-short.ts
11801
+ function seasonStart(m) {
11802
+ return Math.ceil(10 * (m + 1) / 7);
11803
+ }
11804
+ function isShortSeasonLength(n2, m) {
11805
+ return m >= 5 && n2 >= seasonStart(m) && n2 < 2 * m;
11806
+ }
11807
+ function padTwoSeasons(y, m) {
11808
+ const p = [...y];
11809
+ for (let t = y.length; t < 2 * m; t++) p.push(p[t - m]);
11810
+ return p;
11811
+ }
11812
+ function trendShift(m, n2) {
11813
+ const j0 = Math.floor(m / 2);
11814
+ const u = 2 * m - 1 - n2;
11815
+ return (u * u - (j0 - 2) * u + 2 * (j0 - 1)) / 4;
11816
+ }
11817
+ function shortSeasonStart(y, m) {
11818
+ const n2 = y.length;
11819
+ const p = padTwoSeasons(y, m);
11820
+ const ss = slopeSumOf(p, m);
11821
+ const ext = extendTwoSeasons(p, m);
11822
+ const base = threeSeasonSeasonals(ext, m, ss);
11823
+ const total2 = 3 * m + Math.ceil(m / 2);
11824
+ const sxx = total2 * (total2 * total2 - 1) / 12;
11825
+ const trend = threeSeasonTrend(ext, m, base, ss / m) + trendShift(m, n2) * ss / sxx;
11826
+ const rel = base.map((s, k) => k >= n2 - m && k <= m - 2 ? s + ss / 2 : s);
11827
+ return { rel, trend };
11828
+ }
11829
+ function shortSearchSeries(y, m) {
11830
+ const p = padTwoSeasons(y, m);
11831
+ return padThreeSeasons(extendTwoSeasons(p, m), m, slopeSumOf(p, m) / m);
11832
+ }
11833
+
11834
+ // xlsx/formula/functions/ets-init-chain.ts
11835
+ var MAX_SEASONS = 5;
11836
+ var mean6 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11837
+ function isExactLength(n2, m) {
11838
+ const whole = Math.floor(n2 / m);
11839
+ return whole >= MAX_SEASONS || whole === 4 || isThreeSeasonLength(n2, m) || isThreePlusLength(n2, m) || isLowThreeLength(n2, m) || isTwoSeasonLength(n2, m) || isTwoPlusLength(n2, m) || isShortSeasonLength(n2, m);
11840
+ }
11841
+ function fromRelative(y0, rel, trend) {
11842
+ const combined = rel.map((s) => y0 + s - trend);
11843
+ const level4 = mean6(combined);
11844
+ return { level: level4, trend, season: combined.map((c2) => c2 - level4) };
11845
+ }
11846
+ function chainStart(y, m) {
11847
+ const n2 = y.length;
11848
+ const whole = Math.floor(n2 / m);
11849
+ if (isShortSeasonLength(n2, m)) {
11850
+ const { rel: rel2, trend } = shortSeasonStart(y, m);
11851
+ return fromRelative(y[0], rel2, trend);
11852
+ }
11853
+ if (isThreeSeasonLength(n2, m) || isTwoSeasonLength(n2, m) || isTwoPlusLength(n2, m)) {
11854
+ const short = isTwoSeasonLength(n2, m) || isTwoPlusLength(n2, m);
11855
+ const series = short ? extendTwoSeasons(y, m) : y;
11856
+ const rel2 = threeSeasonSeasonals(series, m, short ? slopeSumOf(y, m) : void 0);
11857
+ return fromRelative(
11858
+ y[0],
11859
+ rel2,
11860
+ threeSeasonTrend(series, m, rel2, short ? slopeSumOf(y, m) / m : void 0)
11861
+ );
11862
+ }
11863
+ if (isLowThreeLength(n2, m)) {
11864
+ const short = n2 < 3 * m;
11865
+ const series = short ? extendTwoSeasons(y, m) : y;
11866
+ const rel2 = lowSeasonSeasonals(series, m, short ? slopeSumOf(y, m) : void 0);
11867
+ const pad8 = short ? slopeSumOf(y, m) / m : void 0;
11868
+ return fromRelative(y[0], rel2, threeSeasonTrend(series, m, rel2, pad8));
11869
+ }
11870
+ if (isThreePlusLength(n2, m)) {
11871
+ const rel2 = threePlusSeasonals(y, m);
11872
+ return fromRelative(y[0], rel2, threeSeasonTrend(y, m, rel2));
11873
+ }
11874
+ if (m < 2 || whole < 4) return void 0;
11875
+ const partial = whole < MAX_SEASONS && n2 % m !== 0;
11876
+ const rel = partial ? fourSeasonPlusSeasonals(y, m) : chainSeasonals(y, m, Math.min(whole, MAX_SEASONS));
11877
+ const mx = (n2 - 1) / 2;
11878
+ let sxy = 0;
11879
+ let sxx = 0;
11880
+ const my = mean6(y.map((v, t) => v - rel[t % m]));
11881
+ for (let t = 0; t < n2; t++) {
11882
+ const d = y[t] - rel[t % m] - my;
11883
+ sxy += (t - mx) * d;
11884
+ sxx += (t - mx) * (t - mx);
11885
+ }
11886
+ return fromRelative(y[0], rel, sxy / sxx);
11887
+ }
11888
+
11630
11889
  // xlsx/formula/functions/ets-init.ts
11631
11890
  var MAX_EXACT_SEASON = 24;
11632
- var mean2 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11891
+ var mean7 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11633
11892
  function olsSlope(y) {
11634
11893
  const n2 = y.length;
11635
11894
  const mx = (n2 - 1) / 2;
11636
- const my = mean2(y);
11895
+ const my = mean7(y);
11637
11896
  let sxy = 0;
11638
11897
  let sxx = 0;
11639
11898
  for (let i2 = 0; i2 < n2; i2++) {
@@ -11642,12 +11901,30 @@ function olsSlope(y) {
11642
11901
  }
11643
11902
  return sxx === 0 ? 0 : sxy / sxx;
11644
11903
  }
11904
+ var PADS = {
11905
+ 6: [[0, 6]],
11906
+ 5: [
11907
+ [1, 4],
11908
+ [0, 6]
11909
+ ],
11910
+ 4: [
11911
+ [0, 4],
11912
+ [1, 4],
11913
+ [0, 6]
11914
+ ]
11915
+ };
11916
+ function shortSeriesTrend(y) {
11917
+ const pads = PADS[y.length];
11918
+ if (!pads) return olsSlope(y);
11919
+ const slope = olsSlope(y);
11920
+ return olsSlope([...y, ...pads.map(([src, lag]) => y[src] + lag * slope)]);
11921
+ }
11645
11922
  function split(trend, combined) {
11646
- const level4 = mean2(combined);
11923
+ const level4 = mean7(combined);
11647
11924
  return { level: level4, trend, season: combined.map((c2) => c2 - level4) };
11648
11925
  }
11649
11926
  function heuristicStates(y, m) {
11650
- const trend = (mean2(y.slice(m, 2 * m)) - mean2(y.slice(0, m))) / m;
11927
+ const trend = (mean7(y.slice(m, 2 * m)) - mean7(y.slice(0, m))) / m;
11651
11928
  return split(
11652
11929
  trend,
11653
11930
  Array.from({ length: m }, (_v, k) => y[k] - trend * (k + 1))
@@ -11684,9 +11961,11 @@ function solveSystem(a2, b) {
11684
11961
  function initialStates(y, m, p, run2) {
11685
11962
  const y0 = y[0];
11686
11963
  if (m < 2) {
11687
- const trend2 = olsSlope(y);
11964
+ const trend2 = shortSeriesTrend(y);
11688
11965
  return { level: y0 - trend2, trend: trend2, season: [] };
11689
11966
  }
11967
+ const exact = chainStart(y, m);
11968
+ if (exact) return exact;
11690
11969
  if (m > MAX_EXACT_SEASON) return heuristicStates(y, m);
11691
11970
  const zeros = new Array(y.length).fill(0);
11692
11971
  const unit = (trend2, season) => run2(zeros, m, { level: 0, trend: trend2, season }, p).fitted;
@@ -11706,6 +11985,202 @@ function initialStates(y, m, p, run2) {
11706
11985
  return split(trend, [y0 - trend, ...u.slice(1)]);
11707
11986
  }
11708
11987
 
11988
+ // xlsx/formula/functions/ets-search-map.ts
11989
+ var LOW = 1e-3;
11990
+ var DRIFT_SHIFT = 1.5;
11991
+ var DRIFT_T = 9.3;
11992
+ var CANDIDATES = [
11993
+ ...[2e-3, 0.1, 0.126, 0.25, 0.5, 0.75, 0.9].map((a2) => [a2, LOW]),
11994
+ [0.1, 0.099],
11995
+ [0.126, 0.125],
11996
+ [0.25, 0.249],
11997
+ [0.333333, 0.166667],
11998
+ [0.5, 0.25],
11999
+ [0.5, 0.499],
12000
+ [0.666667, 0.166667],
12001
+ [0.666667, 0.5],
12002
+ [0.75, 0.749],
12003
+ [0.833333, 0.75],
12004
+ [0.9, 0.899],
12005
+ [0.998, 0.099],
12006
+ [0.998, 0.249],
12007
+ [0.998, 0.499],
12008
+ [0.998, 0.749],
12009
+ [0.998, 0.899],
12010
+ [0.166667, 0.0833333],
12011
+ [0.833333, 0.0833333]
12012
+ ];
12013
+ var ALWAYS_DRIFT = /* @__PURE__ */ new Set([
12014
+ "0.1/0.099",
12015
+ "0.998/0.899",
12016
+ "0.998/0.749",
12017
+ "0.166667/0.0833333",
12018
+ "0.25/0.249",
12019
+ "0.9/0.899",
12020
+ "0.666667/0.5",
12021
+ "0.75/0.749"
12022
+ ]);
12023
+ var NEVER_DRIFT = /* @__PURE__ */ new Set(["0.333333/0.166667"]);
12024
+ function trendShape(y, h2) {
12025
+ const n2 = y.length;
12026
+ const hold = h2 > 0 ? h2 : Math.max(1, Math.round(0.3 * n2));
12027
+ const mx = (n2 - 1) / 2;
12028
+ let my = 0;
12029
+ for (const v of y) my += v;
12030
+ my /= n2;
12031
+ let sxy = 0;
12032
+ let sxx = 0;
12033
+ let syy = 0;
12034
+ for (let i2 = 0; i2 < n2; i2++) {
12035
+ const dy = y[i2] - my;
12036
+ sxy += (i2 - mx) * dy;
12037
+ sxx += (i2 - mx) * (i2 - mx);
12038
+ syy += dy * dy;
12039
+ }
12040
+ if (syy === 0 || sxx === 0 || n2 < 3) return { shift: 0, t: 0 };
12041
+ const slope = sxy / sxx;
12042
+ const resid = syy - slope * sxy;
12043
+ const se = Math.sqrt(Math.max(resid, 0) / (n2 - 2) / sxx);
12044
+ let tail = 0;
12045
+ for (let i2 = n2 - hold; i2 < n2; i2++) tail += y[i2];
12046
+ let head = 0;
12047
+ for (let i2 = 0; i2 < n2 - hold; i2++) head += y[i2];
12048
+ const shift3 = Math.abs(tail / hold - head / (n2 - hold)) / Math.sqrt(syy / n2);
12049
+ return { shift: shift3, t: se === 0 ? Number.POSITIVE_INFINITY : Math.abs(slope / se) };
12050
+ }
12051
+ function reportedFor(alpha, beta, shape2) {
12052
+ const key = `${alpha}/${beta}`;
12053
+ let drift;
12054
+ if (beta === LOW) drift = false;
12055
+ else if (ALWAYS_DRIFT.has(key)) drift = true;
12056
+ else if (NEVER_DRIFT.has(key)) drift = false;
12057
+ else drift = shape2.shift <= DRIFT_SHIFT && shape2.t <= DRIFT_T;
12058
+ return { alpha, beta: drift ? LOW : beta, fit: [alpha, beta], drift };
12059
+ }
12060
+
12061
+ // xlsx/formula/functions/ets-search.ts
12062
+ var LOW2 = 1e-3;
12063
+ var MIN_SEARCH_POINTS = 4;
12064
+ var THREE_POINTS = { alpha: 0.1, beta: 0.099, gamma: LOW2, drift: false };
12065
+ var SEASON_ALPHAS = [2e-3, 0.126, 0.251, 0.501, 2 / 3, 0.75, 0.9];
12066
+ var SEASON_STEPS = [LOW2, 0.125, 0.25, 0.5, 0.75, 0.9];
12067
+ var SHORT_SERIES = 16;
12068
+ function better(c2, best) {
12069
+ return c2 < best * (1 - 1e-6) && c2 < best - 1e-12;
12070
+ }
12071
+ var SEASONAL_TRIPLES = [
12072
+ [0.126, LOW2, LOW2],
12073
+ [0.251, LOW2, LOW2],
12074
+ [0.501, LOW2, LOW2],
12075
+ [0.751, LOW2, LOW2],
12076
+ [2e-3, LOW2, 0.125],
12077
+ [2e-3, LOW2, 0.25],
12078
+ [2e-3, LOW2, 0.5],
12079
+ [2e-3, LOW2, 0.75],
12080
+ [0.251, LOW2, 0.25],
12081
+ [0.75, LOW2, 0.249],
12082
+ [0.9, LOW2, 0.099],
12083
+ [0.251, 0.25, LOW2],
12084
+ [0.1, LOW2, 0.899],
12085
+ [0.126, 0.125, LOW2],
12086
+ [0.998, 0.099, LOW2],
12087
+ [0.25, LOW2, 0.749],
12088
+ [0.5, LOW2, 0.499],
12089
+ [0.5, 0.25, LOW2],
12090
+ [0.251, 0.25, 0.25],
12091
+ [0.501, 0.5, LOW2]
12092
+ ];
12093
+ var SHORT_EXTRA_TRIPLES = [
12094
+ [1 / 6, 1 / 12, 1 / 12],
12095
+ [1 / 3, 1 / 6, 1 / 6],
12096
+ [1 / 6, 1 / 12, 0.75],
12097
+ [1 / 3, 1 / 6, 0.5],
12098
+ [5 / 6, 1 / 12, 1 / 12]
12099
+ ];
12100
+ function searchSeasonalLattice(cost, extra = []) {
12101
+ let best = { alpha: 0.126, beta: LOW2, gamma: LOW2 };
12102
+ let bestCost = cost(best);
12103
+ for (const [alpha, beta, gamma2] of [...SEASONAL_TRIPLES, ...extra]) {
12104
+ const c2 = cost({ alpha, beta, gamma: gamma2 });
12105
+ if (better(c2, bestCost)) {
12106
+ bestCost = c2;
12107
+ best = { alpha, beta, gamma: gamma2 };
12108
+ }
12109
+ }
12110
+ return { ...best, drift: false };
12111
+ }
12112
+ function searchSeasonal(n2, cost) {
12113
+ let best = { alpha: 0.9, beta: LOW2, gamma: LOW2 };
12114
+ let bestCost = cost(best);
12115
+ for (const a2 of SEASON_ALPHAS)
12116
+ for (const b of n2 >= 7 && n2 <= SHORT_SERIES ? [LOW2, a2 - LOW2] : [LOW2])
12117
+ for (const g2 of [...SEASON_STEPS, 1 - a2 - LOW2]) {
12118
+ if (b < LOW2 || g2 > 1 - a2 - LOW2 + 1e-9) continue;
12119
+ const c2 = cost({ alpha: a2, beta: b, gamma: g2 });
12120
+ if (better(c2, bestCost)) {
12121
+ bestCost = c2;
12122
+ best = { alpha: a2, beta: b, gamma: g2 };
12123
+ }
12124
+ }
12125
+ return { ...best, drift: false };
12126
+ }
12127
+ function searchLattice(shape2, cost) {
12128
+ let best = [0.9, LOW2];
12129
+ let bestCost = cost({ alpha: 0.9, beta: LOW2, gamma: LOW2 });
12130
+ for (const [alpha, beta] of CANDIDATES) {
12131
+ const c2 = cost({ alpha, beta, gamma: LOW2 });
12132
+ if (better(c2, bestCost)) {
12133
+ bestCost = c2;
12134
+ best = [alpha, beta];
12135
+ }
12136
+ }
12137
+ const out = reportedFor(best[0], best[1], shape2);
12138
+ const [fa, fb] = out.fit;
12139
+ const same11 = fa === out.alpha && fb === out.beta;
12140
+ return {
12141
+ alpha: out.alpha,
12142
+ beta: out.beta,
12143
+ gamma: LOW2,
12144
+ drift: out.drift,
12145
+ ...same11 ? {} : { fit: { alpha: fa, beta: fb, gamma: LOW2 } }
12146
+ };
12147
+ }
12148
+ function chooseSmoothing(n2, m, cost, shape2 = { shift: 9, t: 99 }) {
12149
+ if (m >= 2 && isShortSeasonLength(n2, m)) return searchSeasonalLattice(cost, SHORT_EXTRA_TRIPLES);
12150
+ if (m >= 2) return isExactLength(n2, m) ? searchSeasonalLattice(cost) : searchSeasonal(n2, cost);
12151
+ if (n2 < MIN_SEARCH_POINTS) return THREE_POINTS;
12152
+ return searchLattice(shape2, cost);
12153
+ }
12154
+
12155
+ // xlsx/formula/functions/ets-validate.ts
12156
+ function etsSearchSeries(y) {
12157
+ const pads = PADS[y.length];
12158
+ if (!pads) return y;
12159
+ const slope = olsSlope(y);
12160
+ return [...y, ...pads.map(([src, lag]) => y[src] + lag * slope)];
12161
+ }
12162
+ function etsValidationCost(y, m, init, p, holdout) {
12163
+ const n2 = y.length;
12164
+ const train = n2 - holdout;
12165
+ let { level: level4, trend } = init;
12166
+ const season = [...init.season];
12167
+ let sse = 0;
12168
+ for (let t = 0; t < train; t++) {
12169
+ const k = m >= 2 ? t % m : 0;
12170
+ const e = y[t] - (level4 + trend + (m >= 2 ? season[k] ?? 0 : 0));
12171
+ sse += e * e;
12172
+ level4 += trend + p.alpha * e;
12173
+ trend += p.beta * e;
12174
+ if (m >= 2) season[k] = (season[k] ?? 0) + p.gamma * e;
12175
+ }
12176
+ for (let j = 1; j <= holdout; j++) {
12177
+ const t = train + j - 1;
12178
+ const e = y[t] - (level4 + j * trend + (m >= 2 ? season[t % m] ?? 0 : 0));
12179
+ sse += e * e;
12180
+ }
12181
+ return sse;
12182
+ }
12183
+
11709
12184
  // xlsx/formula/functions/ets-core.ts
11710
12185
  function etsRun(y, m, init, p) {
11711
12186
  let { level: level4, trend } = init;
@@ -11724,36 +12199,36 @@ function etsRun(y, m, init, p) {
11724
12199
  }
11725
12200
  return { fitted, level: level4, trend, season, sse };
11726
12201
  }
11727
- var LOW = 1e-3;
11728
- var SHORT_SERIES = 16;
11729
12202
  var NO_SEASON_GAMMA = Number.EPSILON;
11730
- var ALPHAS = [2e-3, 0.1, 0.126, 0.25, 0.5, 2 / 3, 0.75, 0.9];
11731
- var SEASON_ALPHAS = [2e-3, 0.126, 0.251, 0.501, 2 / 3, 0.75, 0.9];
11732
- var SEASON_STEPS = [LOW, 0.125, 0.25, 0.5, 0.75, 0.9];
11733
12203
  function fitEts(y, seasonLength) {
11734
12204
  const n2 = y.length;
11735
12205
  if (n2 < 2) fail(ERR.NUM);
11736
- const m = seasonLength >= 2 && n2 >= 2 * seasonLength ? seasonLength : 0;
12206
+ const m = seasonLength >= 2 && n2 >= seasonStart(seasonLength) ? seasonLength : 0;
11737
12207
  const solve2 = (p) => {
11738
12208
  const init = initialStates(y, m, p, etsRun);
11739
12209
  return { init, run: etsRun(y, m, init, p) };
11740
12210
  };
11741
- const cost = (v) => solve2({ alpha: v[0], beta: v[1], gamma: v[2] }).run.sse;
11742
- let best = [0.9, LOW, LOW];
11743
- let bestCost = cost(best);
11744
- for (const a2 of m >= 2 ? SEASON_ALPHAS : ALPHAS)
11745
- for (const b of n2 >= 7 && n2 <= SHORT_SERIES ? [LOW, a2 - LOW] : [LOW])
11746
- for (const g2 of m >= 2 ? [...SEASON_STEPS, 1 - a2 - LOW] : [LOW]) {
11747
- if (b < LOW || g2 > 1 - a2 - LOW + 1e-9) continue;
11748
- const c2 = cost([a2, b, g2]);
11749
- if (c2 < bestCost * (1 - 1e-6) && c2 < bestCost - 1e-12) {
11750
- bestCost = c2;
11751
- best = [a2, b, g2];
11752
- }
11753
- }
11754
- const [alpha, beta, gamma2] = best;
11755
- const { run: run2 } = solve2({ alpha, beta, gamma: gamma2 });
11756
- return { alpha, beta, gamma: m >= 2 ? gamma2 : NO_SEASON_GAMMA, m, n: n2, ...run2 };
12211
+ const exact = m < 2 || isExactLength(n2, m);
12212
+ const padded = m >= 2 && exact ? isShortSeasonLength(n2, m) ? shortSearchSeries(y, m) : paddedSearchSeries(y, m) : void 0;
12213
+ const searched = padded ?? (m >= 2 ? y : etsSearchSeries(y));
12214
+ const holdout = m >= 2 && !exact ? 0 : etsHoldout(padded && !(m >= 2 && isShortSeasonLength(n2, m)) ? padded.length : n2, m);
12215
+ const { drift, fit: fit2, ...chosen } = chooseSmoothing(
12216
+ n2,
12217
+ m,
12218
+ (p) => etsValidationCost(searched, m, solve2(p).init, p, holdout),
12219
+ trendShape(y, holdout)
12220
+ );
12221
+ const { run: run2 } = solve2(fit2 ?? chosen);
12222
+ const state = drift ? solve2({ alpha: 1, beta: 0, gamma: chosen.gamma }).run : run2;
12223
+ return {
12224
+ ...chosen,
12225
+ gamma: m >= 2 ? chosen.gamma : NO_SEASON_GAMMA,
12226
+ m,
12227
+ n: n2,
12228
+ ...run2,
12229
+ level: state.level,
12230
+ trend: state.trend
12231
+ };
11757
12232
  }
11758
12233
  function etsHoldout(n2, m) {
11759
12234
  if (n2 < 11) return 0;
@@ -11778,12 +12253,12 @@ function etsErrorSd(fit2, h2) {
11778
12253
  // xlsx/formula/functions/ets-season.ts
11779
12254
  var MAX_POINTS = 8192;
11780
12255
  var MIN_CYCLES = 3;
11781
- var MIN_SHARE = 0.3;
11782
- var mean3 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
12256
+ var MIN_ACF = 0.3;
12257
+ var mean8 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11783
12258
  function detrend(y) {
11784
12259
  const n2 = y.length;
11785
12260
  const mx = (n2 - 1) / 2;
11786
- const my = mean3(y);
12261
+ const my = mean8(y);
11787
12262
  let sxy = 0;
11788
12263
  let sxx = 0;
11789
12264
  for (let i2 = 0; i2 < n2; i2++) {
@@ -11800,34 +12275,23 @@ function detectSeasonality(series) {
11800
12275
  const r = detrend(y);
11801
12276
  const scale2 = Math.max(...y.map(Math.abs), 1);
11802
12277
  if (r.every((v) => Math.abs(v) <= 1e-12 * scale2)) return 0;
11803
- const cos2 = new Float64Array(n2);
11804
- const sin2 = new Float64Array(n2);
11805
- for (let j = 0; j < n2; j++) {
11806
- cos2[j] = Math.cos(2 * Math.PI * j / n2);
11807
- sin2[j] = Math.sin(2 * Math.PI * j / n2);
11808
- }
11809
- let total2 = 0;
11810
- let best = 0;
11811
- let bestK = 0;
11812
- for (let k = 1; k <= Math.floor(n2 / 2); k++) {
11813
- let re = 0;
11814
- let im = 0;
11815
- for (let t = 0; t < n2; t++) {
11816
- const j = k * t % n2;
11817
- const v = r[t];
11818
- re += v * cos2[j];
11819
- im -= v * sin2[j];
11820
- }
11821
- const power2 = re * re + im * im;
11822
- total2 += power2;
11823
- if (k >= MIN_CYCLES && power2 > best) {
11824
- best = power2;
11825
- bestK = k;
11826
- }
12278
+ const maxLag = Math.floor(n2 / MIN_CYCLES);
12279
+ let energy = 0;
12280
+ for (const v of r) energy += v * v;
12281
+ const acf = (lag) => {
12282
+ let s = 0;
12283
+ for (let t = 0; t + lag < n2; t++) s += r[t] * r[t + lag];
12284
+ return s / energy;
12285
+ };
12286
+ let prev = acf(1);
12287
+ let cur = acf(2);
12288
+ for (let lag = 2; lag <= maxLag; lag++) {
12289
+ const next = acf(lag + 1);
12290
+ if (cur >= prev && cur >= next && cur >= MIN_ACF) return lag;
12291
+ prev = cur;
12292
+ cur = next;
11827
12293
  }
11828
- if (bestK === 0 || !(best / total2 >= MIN_SHARE)) return 0;
11829
- const period = Math.round(n2 / bestK);
11830
- return period >= 2 ? period : 0;
12294
+ return 0;
11831
12295
  }
11832
12296
 
11833
12297
  // xlsx/formula/functions/ets-grid.ts
@@ -11899,9 +12363,9 @@ function aggregate2(code, xs) {
11899
12363
  case 4:
11900
12364
  return Math.max(...xs);
11901
12365
  case 5:
11902
- return Math.min(...xs);
11903
- case 6:
11904
12366
  return median2(xs);
12367
+ case 6:
12368
+ return Math.min(...xs);
11905
12369
  default:
11906
12370
  return xs.reduce((a2, b) => a2 + b, 0);
11907
12371
  }
@@ -14579,7 +15043,7 @@ var ENGLISH_PIVOT_CAPTIONS = {
14579
15043
  functions: FUNCTIONS,
14580
15044
  aggregates: aggregateNames()
14581
15045
  };
14582
- var fillCaption = (template, ...args) => template.replace(/\{(\d)\}/g, (_match, at2) => args[Number(at2)] ?? "");
15046
+ var fillCaption = (template2, ...args) => template2.replace(/\{(\d)\}/g, (_match, at2) => args[Number(at2)] ?? "");
14583
15047
  function pivotCaptions(pivot) {
14584
15048
  const own = pivot.captions;
14585
15049
  if (!own) return ENGLISH_PIVOT_CAPTIONS;
@@ -15336,8 +15800,8 @@ var DIV0 = { error: "#DIV/0!" };
15336
15800
  function variance2(numbers3, sample) {
15337
15801
  const n2 = numbers3.length;
15338
15802
  if (n2 < (sample ? 2 : 1)) return DIV0;
15339
- const mean4 = numbers3.reduce((total2, value2) => total2 + value2, 0) / n2;
15340
- const squares = numbers3.reduce((total2, value2) => total2 + (value2 - mean4) ** 2, 0);
15803
+ const mean9 = numbers3.reduce((total2, value2) => total2 + value2, 0) / n2;
15804
+ const squares = numbers3.reduce((total2, value2) => total2 + (value2 - mean9) ** 2, 0);
15341
15805
  return squares / (sample ? n2 - 1 : n2);
15342
15806
  }
15343
15807
  function aggregateValues(records, field, type) {
@@ -17002,11 +17466,11 @@ var ParseCache = class {
17002
17466
  parseNew(formula2) {
17003
17467
  if (formula2.length > MAX_TEMPLATE_LENGTH) return treeOf(makeTemplate(formula2, NO_RUNS));
17004
17468
  const shape2 = formulaShape(formula2);
17005
- const template = this.templates.get(shape2.hash);
17006
- const reused = template && fromTemplate(template, formula2, shape2);
17469
+ const template2 = this.templates.get(shape2.hash);
17470
+ const reused = template2 && fromTemplate(template2, formula2, shape2);
17007
17471
  if (reused) return reused;
17008
17472
  const made = makeTemplate(formula2, shape2);
17009
- if (!template && "ast" in made) {
17473
+ if (!template2 && "ast" in made) {
17010
17474
  if (this.templates.size > MAX_TEMPLATES) this.templates.clear();
17011
17475
  this.templates.set(shape2.hash, made);
17012
17476
  }
@@ -17724,22 +18188,22 @@ function astTraits(ast) {
17724
18188
  traitsCache.set(ast, traits);
17725
18189
  return traits;
17726
18190
  }
17727
- function intervalDelta(a2, b, shift2) {
17728
- const { at: at2, count: count2 } = shift2;
18191
+ function intervalDelta(a2, b, shift3) {
18192
+ const { at: at2, count: count2 } = shift3;
17729
18193
  if (count2 > 0) {
17730
18194
  if (b < at2) return 0;
17731
18195
  if (a2 < at2) return void 0;
17732
- return b + count2 > (shift2.axis === "row" ? MAX_ROW : MAX_COL) ? void 0 : count2;
18196
+ return b + count2 > (shift3.axis === "row" ? MAX_ROW : MAX_COL) ? void 0 : count2;
17733
18197
  }
17734
18198
  const last = at2 - count2 - 1;
17735
18199
  if (b < at2) return 0;
17736
18200
  if (a2 > last) return count2;
17737
18201
  return void 0;
17738
18202
  }
17739
- function areaDelta(area, sheet, shift2) {
18203
+ function areaDelta(area, sheet, shift3) {
17740
18204
  if (area.sheet !== sheet) return 0;
17741
18205
  const { start, end } = area.range;
17742
- return shift2.axis === "row" ? intervalDelta(start.row, end.row, shift2) : intervalDelta(start.col, end.col, shift2);
18206
+ return shift3.axis === "row" ? intervalDelta(start.row, end.row, shift3) : intervalDelta(start.col, end.col, shift3);
17743
18207
  }
17744
18208
  function movedRange(range, axis, delta) {
17745
18209
  if (delta === 0) return range;
@@ -17751,10 +18215,10 @@ function movedRange(range, axis, delta) {
17751
18215
  end: { row: range.end.row, col: range.end.col + delta }
17752
18216
  };
17753
18217
  }
17754
- function reachesEdit(areas, sheet, shift2) {
18218
+ function reachesEdit(areas, sheet, shift3) {
17755
18219
  for (const area of areas) {
17756
18220
  if (area.sheet !== sheet) continue;
17757
- if ((shift2.axis === "row" ? area.range.end.row : area.range.end.col) >= shift2.at) return true;
18221
+ if ((shift3.axis === "row" ? area.range.end.row : area.range.end.col) >= shift3.at) return true;
17758
18222
  }
17759
18223
  return false;
17760
18224
  }
@@ -17803,8 +18267,8 @@ var EngineStructure = class extends EngineCore {
17803
18267
  * changed (cells moved, formulas rewritten). Spills on the sheet, array formulas the edit cuts
17804
18268
  * and anything unexpected fall back to a rebuild on the next recalculation.
17805
18269
  */
17806
- shiftCells(sheet, shift2) {
17807
- if (!this.graphReady() || !this.shiftable(sheet, shift2)) {
18270
+ shiftCells(sheet, shift3) {
18271
+ if (!this.graphReady() || !this.shiftable(sheet, shift3)) {
17808
18272
  this.invalidate();
17809
18273
  return;
17810
18274
  }
@@ -17815,15 +18279,15 @@ var EngineStructure = class extends EngineCore {
17815
18279
  if (own) {
17816
18280
  const next = /* @__PURE__ */ new Map();
17817
18281
  for (const node2 of own.values()) {
17818
- const pos = shift2.axis === "row" ? node2.row : node2.col;
17819
- const delta = intervalDelta(pos, pos, shift2);
18282
+ const pos = shift3.axis === "row" ? node2.row : node2.col;
18283
+ const delta = intervalDelta(pos, pos, shift3);
17820
18284
  if (delta === void 0) {
17821
18285
  this.dropNode(node2);
17822
18286
  continue;
17823
18287
  }
17824
18288
  if (delta !== 0) {
17825
18289
  moved.set(node2, delta);
17826
- if (shift2.axis === "row") node2.row += delta;
18290
+ if (shift3.axis === "row") node2.row += delta;
17827
18291
  else node2.col += delta;
17828
18292
  }
17829
18293
  next.set(cellKey(node2.row, node2.col), node2);
@@ -17832,7 +18296,7 @@ var EngineStructure = class extends EngineCore {
17832
18296
  }
17833
18297
  for (const map of this.nodes.values())
17834
18298
  for (const node2 of map.values()) {
17835
- if (!this.shiftNode(node2, sheet, shift2, moved.get(node2) ?? 0)) {
18299
+ if (!this.shiftNode(node2, sheet, shift3, moved.get(node2) ?? 0)) {
17836
18300
  this.invalidate();
17837
18301
  return;
17838
18302
  }
@@ -17841,11 +18305,11 @@ var EngineStructure = class extends EngineCore {
17841
18305
  this.graphChanged();
17842
18306
  }
17843
18307
  /** No spill or stale spilled value on the sheet, and no array formula the edit cuts. */
17844
- shiftable(sheet, shift2) {
18308
+ shiftable(sheet, shift3) {
17845
18309
  for (const node2 of this.footprints) {
17846
18310
  if (node2.sheet !== sheet) continue;
17847
18311
  if (node2.spill || node2.blockedSpill) return false;
17848
- if (node2.arrayRange && areaDelta({ sheet, range: node2.arrayRange }, sheet, shift2) === void 0)
18312
+ if (node2.arrayRange && areaDelta({ sheet, range: node2.arrayRange }, sheet, shift3) === void 0)
17849
18313
  return false;
17850
18314
  }
17851
18315
  const ws = this.workbook.sheets[sheet];
@@ -17861,19 +18325,19 @@ var EngineStructure = class extends EngineCore {
17861
18325
  this.footprints.delete(node2);
17862
18326
  }
17863
18327
  /** Updates one formula for the edit; false when the graph cannot follow it. */
17864
- shiftNode(node2, sheet, shift2, nodeDelta) {
18328
+ shiftNode(node2, sheet, shift3, nodeDelta) {
17865
18329
  const cell = this.workbook.sheets[node2.sheet]?.rows.get(node2.row)?.get(node2.col);
17866
18330
  if (cell?.formula === void 0) return false;
17867
18331
  if (node2.arrayRange) {
17868
- const delta = areaDelta({ sheet: node2.sheet, range: node2.arrayRange }, sheet, shift2);
18332
+ const delta = areaDelta({ sheet: node2.sheet, range: node2.arrayRange }, sheet, shift3);
17869
18333
  if (delta === void 0) return false;
17870
- node2.arrayRange = movedRange(node2.arrayRange, shift2.axis, delta);
18334
+ node2.arrayRange = movedRange(node2.arrayRange, shift3.axis, delta);
17871
18335
  if (!cell.arrayRange || !sameRange(node2.arrayRange, normalizeRange(cell.arrayRange)))
17872
18336
  return false;
17873
18337
  }
17874
18338
  const changed = cell.formula !== node2.formula;
17875
18339
  const traits = node2.ast && astTraits(node2.ast);
17876
- const reached = reachesEdit(node2.deps, sheet, shift2) || reachesEdit(node2.dynamicDeps, sheet, shift2);
18340
+ const reached = reachesEdit(node2.deps, sheet, shift3) || reachesEdit(node2.dynamicDeps, sheet, shift3);
17877
18341
  if (!changed && !reached && nodeDelta === 0 && !traits?.descriptive && !traits?.opaque)
17878
18342
  return true;
17879
18343
  if (traits?.complex) {
@@ -17882,10 +18346,10 @@ var EngineStructure = class extends EngineCore {
17882
18346
  this.structuralSeeds.add(node2);
17883
18347
  return true;
17884
18348
  }
17885
- const pos = shift2.axis === "row" ? node2.row - nodeDelta : node2.col - nodeDelta;
18349
+ const pos = shift3.axis === "row" ? node2.row - nodeDelta : node2.col - nodeDelta;
17886
18350
  const moves = { seed: !!traits?.descriptive, moved: false, cut: false };
17887
- const deps = this.moveAreas(node2.deps, sheet, shift2, pos, nodeDelta, moves);
17888
- const dynamicDeps = this.moveAreas(node2.dynamicDeps, sheet, shift2, pos, nodeDelta, moves);
18351
+ const deps = this.moveAreas(node2.deps, sheet, shift3, pos, nodeDelta, moves);
18352
+ const dynamicDeps = this.moveAreas(node2.dynamicDeps, sheet, shift3, pos, nodeDelta, moves);
17889
18353
  const { cut, moved: anyMoved } = moves;
17890
18354
  let seed = moves.seed;
17891
18355
  if (cut || changed !== anyMoved) {
@@ -17909,20 +18373,20 @@ var EngineStructure = class extends EngineCore {
17909
18373
  * moved, one was cut (deleted, widened, pushed off the grid) and whether implicit intersection
17910
18374
  * with one can now pick another cell.
17911
18375
  */
17912
- moveAreas(list3, sheet, shift2, pos, nodeDelta, moves) {
18376
+ moveAreas(list3, sheet, shift3, pos, nodeDelta, moves) {
17913
18377
  let out;
17914
18378
  for (let i2 = 0; i2 < list3.length; i2++) {
17915
18379
  const area = list3[i2];
17916
- const delta = areaDelta(area, sheet, shift2);
18380
+ const delta = areaDelta(area, sheet, shift3);
17917
18381
  if (delta === void 0) {
17918
18382
  moves.cut = true;
17919
18383
  continue;
17920
18384
  }
17921
- if (intersectionMoves(area, delta, pos, nodeDelta, shift2.axis)) moves.seed = true;
18385
+ if (intersectionMoves(area, delta, pos, nodeDelta, shift3.axis)) moves.seed = true;
17922
18386
  if (delta === 0) continue;
17923
18387
  moves.moved = true;
17924
18388
  out ??= list3.slice();
17925
- out[i2] = { sheet: area.sheet, range: movedRange(area.range, shift2.axis, delta) };
18389
+ out[i2] = { sheet: area.sheet, range: movedRange(area.range, shift3.axis, delta) };
17926
18390
  }
17927
18391
  return out ?? list3;
17928
18392
  }
@@ -18234,9 +18698,9 @@ function prefixText(prefix) {
18234
18698
  // xlsx/formula/shift-formula.ts
18235
18699
  var templates = /* @__PURE__ */ new Map();
18236
18700
  var MAX_TEMPLATES2 = 2e5;
18237
- function remember(text3, template) {
18701
+ function remember(text3, template2) {
18238
18702
  if (templates.size >= MAX_TEMPLATES2) templates.clear();
18239
- templates.set(text3, template);
18703
+ templates.set(text3, template2);
18240
18704
  }
18241
18705
  function mergeSpacedAreas(tokens2) {
18242
18706
  const out = [];
@@ -18267,16 +18731,16 @@ function templateOf(formula2) {
18267
18731
  const cached = templates.get(formula2);
18268
18732
  if (cached !== void 0) return cached;
18269
18733
  const raw2 = safeTokens(formula2);
18270
- let template = null;
18734
+ let template2 = null;
18271
18735
  if (raw2) {
18272
- template = [];
18736
+ template2 = [];
18273
18737
  let literal3 = "";
18274
18738
  for (const token2 of mergeSpacedAreas(raw2)) {
18275
18739
  if (token2.kind !== "ref" && !(token2.kind === "name" && token2.prefix)) {
18276
18740
  literal3 += token2.text;
18277
18741
  continue;
18278
18742
  }
18279
- if (literal3) template.push(literal3);
18743
+ if (literal3) template2.push(literal3);
18280
18744
  literal3 = "";
18281
18745
  const part = { kind: token2.kind, text: token2.text };
18282
18746
  if (token2.prefix) {
@@ -18285,23 +18749,23 @@ function templateOf(formula2) {
18285
18749
  }
18286
18750
  if (token2.ref) part.ref = token2.ref;
18287
18751
  if (token2.spill) part.spill = true;
18288
- template.push(part);
18752
+ template2.push(part);
18289
18753
  }
18290
- if (literal3) template.push(literal3);
18754
+ if (literal3) template2.push(literal3);
18291
18755
  }
18292
- remember(formula2, template);
18293
- return template;
18756
+ remember(formula2, template2);
18757
+ return template2;
18294
18758
  }
18295
18759
  function rewriteTemplate(formula2, rewrite2) {
18296
- const template = templateOf(formula2);
18297
- if (!template) return formula2;
18760
+ const template2 = templateOf(formula2);
18761
+ if (!template2) return formula2;
18298
18762
  let next;
18299
- for (let i2 = 0; i2 < template.length; i2++) {
18300
- const part = template[i2];
18763
+ for (let i2 = 0; i2 < template2.length; i2++) {
18764
+ const part = template2[i2];
18301
18765
  if (typeof part === "string") continue;
18302
18766
  const changed = rewrite2(part);
18303
18767
  if (!changed) continue;
18304
- next ??= template.slice();
18768
+ next ??= template2.slice();
18305
18769
  next[i2] = changed;
18306
18770
  }
18307
18771
  if (!next) return formula2;
@@ -19935,9 +20399,9 @@ function aggregateCaptionsOf(pivot) {
19935
20399
  ]) {
19936
20400
  const at2 = measure4.caption.indexOf(measure4.field);
19937
20401
  if (at2 < 0 || measure4.caption === measure4.field) continue;
19938
- const template = `${measure4.caption.slice(0, at2)}{0}${measure4.caption.slice(at2 + measure4.field.length)}`;
19939
- if (template !== ENGLISH_PIVOT_CAPTIONS.aggregates[measure4.aggregate])
19940
- out[measure4.aggregate] = template;
20402
+ const template2 = `${measure4.caption.slice(0, at2)}{0}${measure4.caption.slice(at2 + measure4.field.length)}`;
20403
+ if (template2 !== ENGLISH_PIVOT_CAPTIONS.aggregates[measure4.aggregate])
20404
+ out[measure4.aggregate] = template2;
19941
20405
  }
19942
20406
  return Object.keys(out).length ? out : void 0;
19943
20407
  }
@@ -30467,7 +30931,8 @@ var pie = {
30467
30931
  gd16("stAng", "pin 0 adj1 21599999"),
30468
30932
  gd16("endAng", "pin 0 adj2 21599999"),
30469
30933
  gd16("swAng", "+- endAng 0 stAng"),
30470
- gd16("swAng2", "?: swAng swAng +- 21600000 swAng 0"),
30934
+ gd16("swAngWrap", "+- swAng 21600000 0"),
30935
+ gd16("swAng2", "?: swAng swAng swAngWrap"),
30471
30936
  gd16("stx", "cos wd2 stAng"),
30472
30937
  gd16("sty", "sin hd2 stAng"),
30473
30938
  gd16("x1", "+- hc stx 0"),
@@ -30512,7 +30977,8 @@ var chord = {
30512
30977
  gd16("stAng", "pin 0 adj1 21599999"),
30513
30978
  gd16("endAng", "pin 0 adj2 21599999"),
30514
30979
  gd16("swAng", "+- endAng 0 stAng"),
30515
- gd16("swAng2", "?: swAng swAng +- 21600000 swAng 0"),
30980
+ gd16("swAngWrap", "+- swAng 21600000 0"),
30981
+ gd16("swAng2", "?: swAng swAng swAngWrap"),
30516
30982
  gd16("stx", "cos wd2 stAng"),
30517
30983
  gd16("sty", "sin hd2 stAng"),
30518
30984
  gd16("x1", "+- hc stx 0"),
@@ -30536,7 +31002,8 @@ var arc = {
30536
31002
  gd16("stAng", "pin 0 adj1 21599999"),
30537
31003
  gd16("endAng", "pin 0 adj2 21599999"),
30538
31004
  gd16("swAng", "+- endAng 0 stAng"),
30539
- gd16("swAng2", "?: swAng swAng +- 21600000 swAng 0"),
31005
+ gd16("swAngWrap", "+- swAng 21600000 0"),
31006
+ gd16("swAng2", "?: swAng swAng swAngWrap"),
30540
31007
  gd16("stx", "cos wd2 stAng"),
30541
31008
  gd16("sty", "sin hd2 stAng"),
30542
31009
  gd16("x1", "+- hc stx 0"),
@@ -30631,7 +31098,8 @@ var blockArc = {
30631
31098
  gd16("iwd2", "+- wd2 0 thw"),
30632
31099
  gd16("ihd2", "+- hd2 0 thh2"),
30633
31100
  gd16("swAng", "+- endAng 0 stAng"),
30634
- gd16("swAng2", "?: swAng swAng +- 21600000 swAng 0"),
31101
+ gd16("swAngWrap", "+- swAng 21600000 0"),
31102
+ gd16("swAng2", "?: swAng swAng swAngWrap"),
30635
31103
  gd16("mswAng", "+- 0 0 swAng2"),
30636
31104
  gd16("stx", "cos wd2 stAng"),
30637
31105
  gd16("sty", "sin hd2 stAng"),
@@ -38756,8 +39224,8 @@ function writeDiagramFormatDefinition(source3, change) {
38756
39224
  (entry3) => entry3.id === change.value
38757
39225
  ))
38758
39226
  throw new RangeError("Unknown SmartArt format preset.");
38759
- const template = change.kind === "colors" ? buildFabricatedColorsXml(change.value) : buildFabricatedQuickStyleXml(change.value);
38760
- const fresh = parseXml(template).documentElement;
39227
+ const template2 = change.kind === "colors" ? buildFabricatedColorsXml(change.value) : buildFabricatedQuickStyleXml(change.value);
39228
+ const fresh = parseXml(template2).documentElement;
38761
39229
  if (!source3) {
38762
39230
  fresh.setAttribute("uniqueId", `urn:ooxml-core/${change.kind}/${change.value}`);
38763
39231
  return buildXml(fresh);
@@ -40639,8 +41107,8 @@ function buildGeneratedDiagramCache(dataXml2, input) {
40639
41107
  );
40640
41108
  const direct = model2.nodes.find((node2) => node2.modelId === shape2.sourceNodeId);
40641
41109
  const fillIndex = shape2.style?.fill?.index;
40642
- const template = fillIndex ? input.formatScheme?.fillStyles[fillIndex - 1]?.fill : void 0;
40643
- if (!direct?.fill && shape2.fill?.kind === "solid" && shape2.fill.color.kind === "srgb" && (!template || template.kind === "solid" && template.color.kind === "scheme" && template.color.value === "phClr")) {
41110
+ const template2 = fillIndex ? input.formatScheme?.fillStyles[fillIndex - 1]?.fill : void 0;
41111
+ if (!direct?.fill && shape2.fill?.kind === "solid" && shape2.fill.color.kind === "srgb" && (!template2 || template2.kind === "solid" && template2.color.kind === "scheme" && template2.color.value === "phClr")) {
40644
41112
  const original = themed.get(`#${shape2.fill.color.value}`.toUpperCase());
40645
41113
  if (original)
40646
41114
  shape2.fill.color = {
@@ -40648,9 +41116,9 @@ function buildGeneratedDiagramCache(dataXml2, input) {
40648
41116
  transforms: [...original.transforms, ...shape2.fill.color.transforms]
40649
41117
  };
40650
41118
  }
40651
- if (!direct?.fill && shape2.fill?.kind === "gradient" && template?.kind === "gradient") {
41119
+ if (!direct?.fill && shape2.fill?.kind === "gradient" && template2?.kind === "gradient") {
40652
41120
  shape2.fill.stops.forEach((stop, index3) => {
40653
- const authored = template.stops[index3]?.color;
41121
+ const authored = template2.stops[index3]?.color;
40654
41122
  if (authored?.kind === "scheme" && authored.value === "phClr" && stop.color.kind === "srgb") {
40655
41123
  const original = themed.get(`#${stop.color.value}`.toUpperCase());
40656
41124
  if (original)
@@ -45734,7 +46202,12 @@ function vmlCaption(vml, shapeId) {
45734
46202
  const shape2 = vml.slice(start, end < 0 ? void 0 : end);
45735
46203
  const box2 = /<v:textbox[^>]*>([\s\S]*?)<\/v:textbox>/.exec(shape2)?.[1];
45736
46204
  if (!box2) return void 0;
45737
- const text3 = box2.replace(/<br\s*\/?>/gi, "\n").replace(/<[^>]*>/g, "").replace(/&(#x?[0-9a-f]+|\w+);/gi, (match2, code) => {
46205
+ let stripped = box2.replace(/<br\s*\/?>/gi, "\n");
46206
+ for (let prev = ""; prev !== stripped; ) {
46207
+ prev = stripped;
46208
+ stripped = stripped.replace(/<[^>]*>/g, "");
46209
+ }
46210
+ const text3 = stripped.replace(/&(#x?[0-9a-f]+|\w+);/gi, (match2, code) => {
45738
46211
  if (code.startsWith("#")) {
45739
46212
  const value2 = code[1]?.toLowerCase() === "x" ? parseInt(code.slice(2), 16) : Number(code.slice(1));
45740
46213
  return Number.isFinite(value2) ? String.fromCodePoint(value2) : match2;
@@ -49267,12 +49740,12 @@ function reanchor(xml, anchor) {
49267
49740
  ).documentElement;
49268
49741
  for (const candidate of Array.from(holder.childNodes)) {
49269
49742
  if (candidate.nodeType !== 1) continue;
49270
- const template = candidate;
49271
- const original = first(old, template.localName, NS.xdr);
49272
- const position2 = original ? original.cloneNode(true) : doc.importNode(template, true);
49273
- for (const attribute2 of Array.from(template.attributes))
49743
+ const template2 = candidate;
49744
+ const original = first(old, template2.localName, NS.xdr);
49745
+ const position2 = original ? original.cloneNode(true) : doc.importNode(template2, true);
49746
+ for (const attribute2 of Array.from(template2.attributes))
49274
49747
  position2.setAttribute(attribute2.name, attribute2.value);
49275
- for (const value2 of Array.from(template.childNodes)) {
49748
+ for (const value2 of Array.from(template2.childNodes)) {
49276
49749
  if (value2.nodeType !== 1) continue;
49277
49750
  const item2 = value2;
49278
49751
  const existing = first(position2, item2.localName, NS.xdr);
@@ -49475,9 +49948,9 @@ function writeDrawing(writer, partName, objects, sourceDrawing, context) {
49475
49948
 
49476
49949
  // xlsx/edit/range-math.ts
49477
49950
  var axisMax = (axis) => axis === "row" ? MAX_ROW : MAX_COL;
49478
- function shiftSpan(start, end, shift2) {
49479
- const { at: at2, count: count2 } = shift2;
49480
- const max = axisMax(shift2.axis);
49951
+ function shiftSpan(start, end, shift3) {
49952
+ const { at: at2, count: count2 } = shift3;
49953
+ const max = axisMax(shift3.axis);
49481
49954
  if (count2 > 0) {
49482
49955
  if (start >= at2) {
49483
49956
  if (start + count2 > max) return void 0;
@@ -49493,35 +49966,35 @@ function shiftSpan(start, end, shift2) {
49493
49966
  const e = end >= max ? max : end < at2 ? end : end > last ? end - n2 : at2 - 1;
49494
49967
  return s > e ? void 0 : { start: s, end: e };
49495
49968
  }
49496
- function shiftIndex(index3, shift2) {
49497
- const { at: at2, count: count2 } = shift2;
49969
+ function shiftIndex(index3, shift3) {
49970
+ const { at: at2, count: count2 } = shift3;
49498
49971
  if (index3 < at2) return index3;
49499
- if (count2 > 0) return index3 + count2 > axisMax(shift2.axis) ? void 0 : index3 + count2;
49972
+ if (count2 > 0) return index3 + count2 > axisMax(shift3.axis) ? void 0 : index3 + count2;
49500
49973
  return index3 < at2 - count2 ? void 0 : index3 + count2;
49501
49974
  }
49502
- function shiftIndexClamped(index3, shift2) {
49503
- const moved = shiftIndex(index3, shift2);
49975
+ function shiftIndexClamped(index3, shift3) {
49976
+ const moved = shiftIndex(index3, shift3);
49504
49977
  if (moved !== void 0) return moved;
49505
- return shift2.count > 0 ? axisMax(shift2.axis) : shift2.at;
49978
+ return shift3.count > 0 ? axisMax(shift3.axis) : shift3.at;
49506
49979
  }
49507
- function shiftRange(range, shift2) {
49508
- if (shift2.axis === "row") {
49509
- const span5 = shiftSpan(range.start.row, range.end.row, shift2);
49980
+ function shiftRange(range, shift3) {
49981
+ if (shift3.axis === "row") {
49982
+ const span5 = shiftSpan(range.start.row, range.end.row, shift3);
49510
49983
  return span5 && {
49511
49984
  start: { row: span5.start, col: range.start.col },
49512
49985
  end: { row: span5.end, col: range.end.col }
49513
49986
  };
49514
49987
  }
49515
- const span4 = shiftSpan(range.start.col, range.end.col, shift2);
49988
+ const span4 = shiftSpan(range.start.col, range.end.col, shift3);
49516
49989
  return span4 && {
49517
49990
  start: { row: range.start.row, col: span4.start },
49518
49991
  end: { row: range.end.row, col: span4.end }
49519
49992
  };
49520
49993
  }
49521
- function shiftRangeInBand(range, shift2, lo, hi) {
49522
- const other = shift2.axis === "row" ? "col" : "row";
49994
+ function shiftRangeInBand(range, shift3, lo, hi) {
49995
+ const other = shift3.axis === "row" ? "col" : "row";
49523
49996
  if (range.end[other] < lo || range.start[other] > hi) return range;
49524
- if (range.start[other] >= lo && range.end[other] <= hi) return shiftRange(range, shift2);
49997
+ if (range.start[other] >= lo && range.end[other] <= hi) return shiftRange(range, shift3);
49525
49998
  return range;
49526
49999
  }
49527
50000
  function subtractRange(a2, b) {
@@ -49552,7 +50025,7 @@ function pointsAt(token2, formulaSheet, sheet) {
49552
50025
  if (!prefix) return formulaSheet.toLowerCase() === sheet.toLowerCase();
49553
50026
  return prefix.book === void 0 && prefix.sheet2 === void 0 && prefix.sheet.toLowerCase() === sheet.toLowerCase();
49554
50027
  }
49555
- function shiftFormulaInBand(formula2, formulaSheet, sheet, shift2, band) {
50028
+ function shiftFormulaInBand(formula2, formulaSheet, sheet, shift3, band) {
49556
50029
  let tokens2;
49557
50030
  try {
49558
50031
  tokens2 = tokenize(formula2);
@@ -49573,7 +50046,7 @@ function shiftFormulaInBand(formula2, formulaSheet, sheet, shift2, band) {
49573
50046
  },
49574
50047
  end: { row: Math.max(ref.start.row, ref.end.row), col: Math.max(ref.start.col, ref.end.col) }
49575
50048
  };
49576
- const moved = shiftRangeInBand(range, shift2, band.lo, band.hi);
50049
+ const moved = shiftRangeInBand(range, shift3, band.lo, band.hi);
49577
50050
  if (moved && sameRange2(moved, range)) continue;
49578
50051
  const prefix = token2.prefix?.text ?? "";
49579
50052
  if (!moved) {
@@ -49611,15 +50084,15 @@ function carriedRefEdits(sourceSheets, currentSheets, shiftsOf = () => []) {
49611
50084
  edits.deleted.push(source3.name);
49612
50085
  continue;
49613
50086
  }
49614
- for (const shift2 of shiftsOf(current)) edits.shifts.push({ sheet: source3.name, shift: shift2 });
50087
+ for (const shift3 of shiftsOf(current)) edits.shifts.push({ sheet: source3.name, shift: shift3 });
49615
50088
  if (current.name !== source3.name) edits.renamed.push([source3.name, current.name]);
49616
50089
  }
49617
50090
  return edits;
49618
50091
  }
49619
50092
  var hasCarriedRefEdits = (edits) => edits.shifts.length > 0 || edits.deleted.length > 0 || edits.renamed.length > 0;
49620
- function shiftOne(formula2, formulaSheet, sheet, shift2) {
49621
- if (shift2.band) return shiftFormulaInBand(formula2, formulaSheet, sheet, shift2, shift2.band);
49622
- const spec2 = { sheet, axis: shift2.axis, at: shift2.at, count: shift2.count };
50093
+ function shiftOne(formula2, formulaSheet, sheet, shift3) {
50094
+ if (shift3.band) return shiftFormulaInBand(formula2, formulaSheet, sheet, shift3, shift3.band);
50095
+ const spec2 = { sheet, axis: shift3.axis, at: shift3.at, count: shift3.count };
49623
50096
  return shiftFormula(formula2, formulaSheet, spec2);
49624
50097
  }
49625
50098
  function renameAll(formula2, renamed, taken) {
@@ -49642,7 +50115,7 @@ var takenNames = (edits) => new Set(
49642
50115
  );
49643
50116
  function patchCarriedFormula(formula2, formulaSheet, edits) {
49644
50117
  let out = formula2;
49645
- for (const { sheet, shift: shift2 } of edits.shifts) out = shiftOne(out, formulaSheet, sheet, shift2);
50118
+ for (const { sheet, shift: shift3 } of edits.shifts) out = shiftOne(out, formulaSheet, sheet, shift3);
49646
50119
  for (const sheet of edits.deleted) out = deleteSheetInFormula(out, sheet);
49647
50120
  return renameAll(out, edits.renamed, takenNames(edits));
49648
50121
  }
@@ -51498,7 +51971,7 @@ function addChartSeries(space, input) {
51498
51971
  const group2 = groups.find((_, i2) => i2 === (input.groupIndex ?? groups.length - 1));
51499
51972
  if (!group2) throw new RangeError("The chart has no chart group to add a series to");
51500
51973
  const all2 = chartSpaceSeries(draft);
51501
- const template = all2[0];
51974
+ const template2 = all2[0];
51502
51975
  const series = {
51503
51976
  index: nextNumber(all2.map((item2) => item2.index)),
51504
51977
  order: nextNumber(all2.map((item2) => item2.order)),
@@ -51515,7 +51988,7 @@ function addChartSeries(space, input) {
51515
51988
  };
51516
51989
  else if (input.name !== void 0) series.tx = { value: input.name, text: input.name };
51517
51990
  if (input.spPr) series.spPr = structuredClone(input.spPr);
51518
- const templateCategories = template?.categories ?? template?.xValues;
51991
+ const templateCategories = template2?.categories ?? template2?.xValues;
51519
51992
  if (input.categories !== void 0)
51520
51993
  series[categoryKey(group2)] = categorySource(
51521
51994
  input.categories,
@@ -53858,8 +54331,8 @@ async function saveXlsx(workbook) {
53858
54331
 
53859
54332
  // xlsx/edit/shift-preserved.ts
53860
54333
  var XM3 = "http://schemas.microsoft.com/office/excel/2006/main";
53861
- function hasPreservedOverflow(sheet, shift2, clipped, banded) {
53862
- const keys = banded ? ["extLst"] : [shift2.axis === "row" ? "rowBreaks" : "colBreaks", "extLst"];
54334
+ function hasPreservedOverflow(sheet, shift3, clipped, banded) {
54335
+ const keys = banded ? ["extLst"] : [shift3.axis === "row" ? "rowBreaks" : "colBreaks", "extLst"];
53863
54336
  for (const key of keys)
53864
54337
  for (const xml of sheet.preserved.get(key) ?? []) {
53865
54338
  if (!xml.includes(key === "extLst" ? "sqref" : "brk")) continue;
@@ -53875,7 +54348,7 @@ function hasPreservedOverflow(sheet, shift2, clipped, banded) {
53875
54348
  ))
53876
54349
  return true;
53877
54350
  } else if (elements(root).some(
53878
- (node2) => node2.localName === "brk" && shiftIndex(Number(node2.getAttribute("id") ?? "0"), shift2) === void 0
54351
+ (node2) => node2.localName === "brk" && shiftIndex(Number(node2.getAttribute("id") ?? "0"), shift3) === void 0
53879
54352
  ))
53880
54353
  return true;
53881
54354
  }
@@ -53907,11 +54380,11 @@ function editEntries(sheet, key, edit, quick) {
53907
54380
  if (next.length) sheet.preserved.set(key, next);
53908
54381
  else sheet.preserved.delete(key);
53909
54382
  }
53910
- function shiftBreaks(root, shift2) {
54383
+ function shiftBreaks(root, shift3) {
53911
54384
  let changed = false;
53912
54385
  for (const brk of elements(root).filter((e) => e.localName === "brk")) {
53913
54386
  const id = Number(brk.getAttribute("id") ?? "0");
53914
- const moved = shiftIndex(id, shift2);
54387
+ const moved = shiftIndex(id, shift3);
53915
54388
  if (moved === id) continue;
53916
54389
  changed = true;
53917
54390
  if (moved === void 0 || moved === 0) root.removeChild(brk);
@@ -53956,12 +54429,12 @@ function shiftSqrefs(root, moveRange) {
53956
54429
  list3.setAttribute("count", String(elements(list3).length));
53957
54430
  return elements(root).length > 0 ? "changed" : "drop";
53958
54431
  }
53959
- function shiftPreservedXml(sheet, shift2, moveRange, banded) {
54432
+ function shiftPreservedXml(sheet, shift3, moveRange, banded) {
53960
54433
  if (!banded)
53961
54434
  editEntries(
53962
54435
  sheet,
53963
- shift2.axis === "row" ? "rowBreaks" : "colBreaks",
53964
- (root) => shiftBreaks(root, shift2),
54436
+ shift3.axis === "row" ? "rowBreaks" : "colBreaks",
54437
+ (root) => shiftBreaks(root, shift3),
53965
54438
  (xml) => xml.includes("brk")
53966
54439
  );
53967
54440
  editEntries(
@@ -55116,25 +55589,25 @@ function setBorders(ctx, s, range, preset, edge3 = { style: "thin" }) {
55116
55589
  }
55117
55590
 
55118
55591
  // xlsx/edit/insert-guard.ts
55119
- function assertInsertFits(sheet, shift2, band) {
55592
+ function assertInsertFits(sheet, shift3, band) {
55120
55593
  for (const pivot of sheet.pivotTables ?? []) {
55121
- const start = pivot.location.start[shift2.axis];
55122
- const end = pivot.location.end[shift2.axis];
55123
- const other2 = shift2.axis === "row" ? "col" : "row";
55594
+ const start = pivot.location.start[shift3.axis];
55595
+ const end = pivot.location.end[shift3.axis];
55596
+ const other2 = shift3.axis === "row" ? "col" : "row";
55124
55597
  if (band && (band.hi < pivot.location.start[other2] || band.lo > pivot.location.end[other2]))
55125
55598
  continue;
55126
55599
  const partial = band && (band.lo > pivot.location.start[other2] || band.hi < pivot.location.end[other2]);
55127
- const overlap = shift2.count > 0 ? shift2.at > start && shift2.at <= end : shift2.at <= end && shift2.at - shift2.count > start;
55128
- if (overlap || partial && shift2.at <= end)
55600
+ const overlap = shift3.count > 0 ? shift3.at > start && shift3.at <= end : shift3.at <= end && shift3.at - shift3.count > start;
55601
+ if (overlap || partial && shift3.at <= end)
55129
55602
  throw new Error("Cannot move or remove part of a PivotTable. Delete the PivotTable first.");
55130
55603
  }
55131
- if (shift2.count <= 0) return;
55132
- const max = shift2.axis === "row" ? MAX_ROW : MAX_COL;
55133
- if (shift2.at + shift2.count > max + 1)
55604
+ if (shift3.count <= 0) return;
55605
+ const max = shift3.axis === "row" ? MAX_ROW : MAX_COL;
55606
+ if (shift3.at + shift3.count > max + 1)
55134
55607
  throw new RangeError("The insert area extends beyond the sheet.");
55135
- const first2 = max - shift2.count + 1;
55136
- 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);
55137
- const other = shift2.axis === "row" ? "col" : "row";
55608
+ const first2 = max - shift3.count + 1;
55609
+ 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);
55610
+ const other = shift3.axis === "row" ? "col" : "row";
55138
55611
  const clipped = (range) => (!band || range.start[other] >= band.lo && range.end[other] <= band.hi) && rangesIntersect(range, lost);
55139
55612
  const fail2 = () => {
55140
55613
  throw new Error("Cannot insert cells: non-empty cells would be pushed off the sheet.");
@@ -55145,14 +55618,14 @@ function assertInsertFits(sheet, shift2, band) {
55145
55618
  if (col >= lost.start.col && col <= lost.end.col && (!isEmptyCell(cell) || cell.cellMetadata !== void 0 || cell.valueMetadata !== void 0))
55146
55619
  fail2();
55147
55620
  }
55148
- 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))
55621
+ 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))
55149
55622
  fail2();
55150
55623
  for (const { anchor } of sheet.drawings) {
55151
55624
  if (band && (anchor.from[other] < band.lo || anchor.from[other] > band.hi)) continue;
55152
- if (anchor.from[shift2.axis] >= first2 || anchor.to && anchor.to[shift2.axis] >= first2) fail2();
55625
+ if (anchor.from[shift3.axis] >= first2 || anchor.to && anchor.to[shift3.axis] >= first2) fail2();
55153
55626
  }
55154
55627
  if (band) return;
55155
- if (shift2.axis === "row") {
55628
+ if (shift3.axis === "row") {
55156
55629
  for (const [row2, info] of sheet.rowInfo) if (row2 >= first2 && Object.keys(info).length) fail2();
55157
55630
  } else {
55158
55631
  if (normalizeColumns(sheet.columns).some((c2) => c2.min >= first2)) fail2();
@@ -55160,11 +55633,11 @@ function assertInsertFits(sheet, shift2, band) {
55160
55633
  }
55161
55634
 
55162
55635
  // xlsx/edit/shift-rule-anchors.ts
55163
- function rebaseRulesForDeletion(sheet, shift2, band) {
55164
- if (shift2.count >= 0) return;
55165
- const last = shift2.at - shift2.count - 1;
55166
- 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);
55167
- const other = shift2.axis === "row" ? "col" : "row";
55636
+ function rebaseRulesForDeletion(sheet, shift3, band) {
55637
+ if (shift3.count >= 0) return;
55638
+ const last = shift3.at - shift3.count - 1;
55639
+ 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);
55640
+ const other = shift3.axis === "row" ? "col" : "row";
55168
55641
  const surviving = (ranges) => ranges.flatMap(
55169
55642
  (range) => band && (range.start[other] < band.lo || range.end[other] > band.hi) ? [range] : subtractRange(range, removed)
55170
55643
  );
@@ -55429,10 +55902,10 @@ function shiftScenarios(sheet, move) {
55429
55902
  }
55430
55903
 
55431
55904
  // xlsx/edit/shift-sheet.ts
55432
- function shiftSheetContent(sheet, shift2, band) {
55433
- assertInsertFits(sheet, shift2, band);
55434
- const moveRange = (range) => band ? shiftRangeInBand(range, shift2, band.lo, band.hi) : shiftRange(range, shift2);
55435
- shiftCells(sheet, shift2, band, moveRange);
55905
+ function shiftSheetContent(sheet, shift3, band) {
55906
+ assertInsertFits(sheet, shift3, band);
55907
+ const moveRange = (range) => band ? shiftRangeInBand(range, shift3, band.lo, band.hi) : shiftRange(range, shift3);
55908
+ shiftCells(sheet, shift3, band, moveRange);
55436
55909
  sheet.merges = sheet.merges.map(moveRange).filter((m) => !!m && (m.start.row !== m.end.row || m.start.col !== m.end.col));
55437
55910
  sheet.conditionalFormats = sheet.conditionalFormats.map((cf) => ({ ...cf, ranges: cf.ranges.map(moveRange).filter((r) => !!r) })).filter((cf) => cf.ranges.length > 0);
55438
55911
  sheet.dataValidations = sheet.dataValidations.map((dv) => ({ ...dv, ranges: dv.ranges.map(moveRange).filter((r) => !!r) })).filter((dv) => dv.ranges.length > 0);
@@ -55444,7 +55917,7 @@ function shiftSheetContent(sheet, shift2, band) {
55444
55917
  const range = moveRange({ start: c2.address, end: c2.address });
55445
55918
  return range ? [{ ...c2, address: range.start }] : [];
55446
55919
  });
55447
- sheet.tables = sheet.tables.flatMap((t) => shiftTable2(sheet, t, shift2, moveRange));
55920
+ sheet.tables = sheet.tables.flatMap((t) => shiftTable2(sheet, t, shift3, moveRange));
55448
55921
  shiftDataTables(sheet, moveRange);
55449
55922
  shiftScenarios(sheet, moveRange);
55450
55923
  for (const pivot of sheet.pivotTables ?? []) {
@@ -55454,8 +55927,8 @@ function shiftSheetContent(sheet, shift2, band) {
55454
55927
  pivot.dirty = true;
55455
55928
  }
55456
55929
  }
55457
- for (const drawing of sheet.drawings) shiftAnchor(drawing.anchor, shift2, band);
55458
- if (!band) shiftAxisFormats(sheet, shift2);
55930
+ for (const drawing of sheet.drawings) shiftAnchor(drawing.anchor, shift3, band);
55931
+ if (!band) shiftAxisFormats(sheet, shift3);
55459
55932
  if (sheet.autoFilter) {
55460
55933
  const old = sheet.autoFilter.range;
55461
55934
  const range = moveRange(old);
@@ -55464,39 +55937,39 @@ function shiftSheetContent(sheet, shift2, band) {
55464
55937
  clearFilteredRows(sheet);
55465
55938
  } else {
55466
55939
  const filter2 = { ...sheet.autoFilter, range };
55467
- if (shift2.axis === "col" && filter2.columns)
55940
+ if (shift3.axis === "col" && filter2.columns)
55468
55941
  filter2.columns = filter2.columns.flatMap((fc) => {
55469
- const abs2 = shiftIndex(old.start.col + fc.offset, shift2);
55942
+ const abs2 = shiftIndex(old.start.col + fc.offset, shift3);
55470
55943
  return abs2 === void 0 ? [] : [{ ...fc, offset: abs2 - range.start.col }];
55471
55944
  });
55472
55945
  sheet.autoFilter = filter2;
55473
55946
  }
55474
55947
  }
55475
- if (!band) shiftFreeze(sheet, shift2);
55948
+ if (!band) shiftFreeze(sheet, shift3);
55476
55949
  const printArea = sheet.pageSetup?.printArea;
55477
55950
  if (sheet.pageSetup && printArea) {
55478
55951
  const moved = moveRange(printArea);
55479
55952
  if (moved) sheet.pageSetup.printArea = moved;
55480
55953
  else delete sheet.pageSetup.printArea;
55481
55954
  }
55482
- shiftPreservedXml(sheet, shift2, moveRange, !!band);
55955
+ shiftPreservedXml(sheet, shift3, moveRange, !!band);
55483
55956
  }
55484
- function shiftCells(sheet, shift2, band, moveRange) {
55957
+ function shiftCells(sheet, shift3, band, moveRange) {
55485
55958
  const old = sheet.rows;
55486
55959
  sheet.rows = /* @__PURE__ */ new Map();
55487
55960
  for (const [row2, cells] of old)
55488
55961
  for (const [col, cell] of cells) {
55489
- const along = shift2.axis === "row" ? row2 : col;
55490
- const across = shift2.axis === "row" ? col : row2;
55962
+ const along = shift3.axis === "row" ? row2 : col;
55963
+ const across = shift3.axis === "row" ? col : row2;
55491
55964
  const inBand = !band || across >= band.lo && across <= band.hi;
55492
- const moved = inBand ? shiftIndex(along, shift2) : along;
55965
+ const moved = inBand ? shiftIndex(along, shift3) : along;
55493
55966
  if (moved === void 0) continue;
55494
55967
  if (cell.arrayRange) {
55495
55968
  const range = moveRange(cell.arrayRange);
55496
55969
  if (range) cell.arrayRange = range;
55497
55970
  else delete cell.arrayRange;
55498
55971
  }
55499
- if (shift2.axis === "row") putCell(sheet, moved, col, cell);
55972
+ if (shift3.axis === "row") putCell(sheet, moved, col, cell);
55500
55973
  else putCell(sheet, row2, moved, cell);
55501
55974
  }
55502
55975
  }
@@ -55504,73 +55977,73 @@ function uniqueColumnName(columns) {
55504
55977
  const taken = new Set(columns.map((c2) => c2.name.toLowerCase()));
55505
55978
  for (let n2 = 1; ; n2++) if (!taken.has(`column${n2}`)) return `Column${n2}`;
55506
55979
  }
55507
- function shiftTable2(sheet, table3, shift2, moveRange) {
55980
+ function shiftTable2(sheet, table3, shift3, moveRange) {
55508
55981
  const old = table3.range;
55509
55982
  const range = moveRange(old);
55510
55983
  if (!range) return [];
55511
55984
  const next = { ...table3, range, columns: [...table3.columns] };
55512
55985
  const widened = range.end.col - range.start.col !== old.end.col - old.start.col;
55513
- if (shift2.axis === "col" && widened) {
55514
- if (shift2.count > 0) {
55515
- const offset2 = shift2.at - old.start.col;
55516
- for (let i2 = 0; i2 < shift2.count; i2++) {
55986
+ if (shift3.axis === "col" && widened) {
55987
+ if (shift3.count > 0) {
55988
+ const offset2 = shift3.at - old.start.col;
55989
+ for (let i2 = 0; i2 < shift3.count; i2++) {
55517
55990
  const column3 = { name: uniqueColumnName(next.columns) };
55518
55991
  next.columns.splice(offset2 + i2, 0, column3);
55519
55992
  if (next.headerRow) {
55520
55993
  const cell = { value: column3.name };
55521
- putCell(sheet, range.start.row, shift2.at + i2, cell);
55994
+ putCell(sheet, range.start.row, shift3.at + i2, cell);
55522
55995
  }
55523
55996
  }
55524
55997
  } else {
55525
55998
  next.columns = next.columns.filter(
55526
- (_c, i2) => shiftIndex(old.start.col + i2, shift2) !== void 0
55999
+ (_c, i2) => shiftIndex(old.start.col + i2, shift3) !== void 0
55527
56000
  );
55528
56001
  }
55529
56002
  }
55530
56003
  return [next];
55531
56004
  }
55532
- function shiftAnchor(anchor, shift2, band) {
55533
- const key = shift2.axis === "row" ? "row" : "col";
55534
- const other = shift2.axis === "row" ? "col" : "row";
56005
+ function shiftAnchor(anchor, shift3, band) {
56006
+ const key = shift3.axis === "row" ? "row" : "col";
56007
+ const other = shift3.axis === "row" ? "col" : "row";
55535
56008
  if (band && (anchor.from[other] < band.lo || anchor.from[other] > band.hi)) return;
55536
56009
  const from = anchor.from[key];
55537
- const movedFrom = shiftIndexClamped(from, shift2);
55538
- if (shiftIndex(from, shift2) === void 0)
56010
+ const movedFrom = shiftIndexClamped(from, shift3);
56011
+ if (shiftIndex(from, shift3) === void 0)
55539
56012
  anchor.from[key === "row" ? "rowOffset" : "colOffset"] = 0;
55540
56013
  anchor.from[key] = movedFrom;
55541
56014
  if (anchor.to) {
55542
56015
  const to = anchor.to[key];
55543
- const moved = shiftIndex(to, shift2);
56016
+ const moved = shiftIndex(to, shift3);
55544
56017
  if (moved === void 0) {
55545
- anchor.to[key] = Math.max(movedFrom, shiftIndexClamped(to, shift2));
56018
+ anchor.to[key] = Math.max(movedFrom, shiftIndexClamped(to, shift3));
55546
56019
  anchor.to[key === "row" ? "rowOffset" : "colOffset"] = 0;
55547
56020
  } else anchor.to[key] = moved;
55548
56021
  }
55549
56022
  }
55550
- function shiftAxisFormats(sheet, shift2) {
55551
- if (shift2.axis === "row") {
56023
+ function shiftAxisFormats(sheet, shift3) {
56024
+ if (shift3.axis === "row") {
55552
56025
  const old = sheet.rowInfo;
55553
56026
  sheet.rowInfo = /* @__PURE__ */ new Map();
55554
56027
  for (const [row2, info] of old) {
55555
- const moved = shiftIndex(row2, shift2);
56028
+ const moved = shiftIndex(row2, shift3);
55556
56029
  if (moved !== void 0) sheet.rowInfo.set(moved, info);
55557
56030
  }
55558
56031
  return;
55559
56032
  }
55560
56033
  sheet.columns = normalizeColumns(
55561
56034
  sheet.columns.flatMap((info) => {
55562
- const span4 = shiftSpan(info.min, info.max, shift2);
56035
+ const span4 = shiftSpan(info.min, info.max, shift3);
55563
56036
  return span4 ? [{ ...info, min: span4.start, max: span4.end }] : [];
55564
56037
  })
55565
56038
  );
55566
56039
  }
55567
- function shiftFreeze(sheet, shift2) {
56040
+ function shiftFreeze(sheet, shift3) {
55568
56041
  const freeze = sheet.view.freeze;
55569
56042
  if (!freeze) return;
55570
- const key = shift2.axis === "row" ? "rows" : "cols";
56043
+ const key = shift3.axis === "row" ? "rows" : "cols";
55571
56044
  const frozen = freeze[key];
55572
- if (shift2.at >= frozen) return;
55573
- const next = shift2.count > 0 ? frozen + shift2.count : frozen - Math.min(-shift2.count, frozen - shift2.at);
56045
+ if (shift3.at >= frozen) return;
56046
+ const next = shift3.count > 0 ? frozen + shift3.count : frozen - Math.min(-shift3.count, frozen - shift3.at);
55574
56047
  sheet.view.freeze = { ...freeze, [key]: next };
55575
56048
  }
55576
56049
 
@@ -55580,15 +56053,15 @@ function checkSpan(axis, at2, count2) {
55580
56053
  if (!Number.isInteger(at2) || !Number.isInteger(count2) || at2 < 0 || at2 > max || count2 < 1 || at2 + count2 > max + 1)
55581
56054
  throw new RangeError(`Invalid ${axis} span ${at2} + ${count2}`);
55582
56055
  }
55583
- function applyAxisShift(ctx, sheet, shift2) {
55584
- assertInsertFits(sheet, shift2);
55585
- rebaseRulesForDeletion(sheet, shift2);
55586
- const spec2 = { sheet: sheet.name, axis: shift2.axis, at: shift2.at, count: shift2.count };
56056
+ function applyAxisShift(ctx, sheet, shift3) {
56057
+ assertInsertFits(sheet, shift3);
56058
+ rebaseRulesForDeletion(sheet, shift3);
56059
+ const spec2 = { sheet: sheet.name, axis: shift3.axis, at: shift3.at, count: shift3.count };
55587
56060
  rewriteFormulas(
55588
56061
  ctx.workbook,
55589
56062
  (formula2, formulaSheet) => shiftFormula(formula2, formulaSheet, spec2)
55590
56063
  );
55591
- shiftSheetContent(sheet, shift2);
56064
+ shiftSheetContent(sheet, shift3);
55592
56065
  }
55593
56066
  function inheritFormats(sheet, axis, at2, count2) {
55594
56067
  if (at2 === 0) return;
@@ -55614,17 +56087,17 @@ function shiftAxis(ctx, s, axis, at2, count2, insert2) {
55614
56087
  checkSpan(axis, at2, count2);
55615
56088
  const sheet = sheetAt(ctx.workbook, s);
55616
56089
  const noun = axis === "row" ? count2 === 1 ? "row" : "rows" : count2 === 1 ? "column" : "columns";
55617
- const shift2 = { axis, at: at2, count: insert2 ? count2 : -count2 };
55618
- assertInsertFits(sheet, shift2);
56090
+ const shift3 = { axis, at: at2, count: insert2 ? count2 : -count2 };
56091
+ assertInsertFits(sheet, shift3);
55619
56092
  const info = { sheet: s, structural: true };
55620
- if (!sheet.autoFilter || shiftRange(sheet.autoFilter.range, shift2))
55621
- info.calc = { kind: "shift", sheet: s, shift: shift2 };
56093
+ if (!sheet.autoFilter || shiftRange(sheet.autoFilter.range, shift3))
56094
+ info.calc = { kind: "shift", sheet: s, shift: shift3 };
55622
56095
  ctx.run(
55623
56096
  `${insert2 ? "Insert" : "Delete"} ${noun}`,
55624
56097
  "structure",
55625
- [{ kind: "shift", sheet: s, shift: shift2 }],
56098
+ [{ kind: "shift", sheet: s, shift: shift3 }],
55626
56099
  () => {
55627
- applyAxisShift(ctx, sheet, shift2);
56100
+ applyAxisShift(ctx, sheet, shift3);
55628
56101
  if (insert2) inheritFormats(sheet, axis, at2, count2);
55629
56102
  },
55630
56103
  info
@@ -55636,9 +56109,9 @@ var insertColumns = (ctx, s, at2, count2) => shiftAxis(ctx, s, "col", at2, count
55636
56109
  var deleteColumns = (ctx, s, at2, count2) => shiftAxis(ctx, s, "col", at2, count2, false);
55637
56110
 
55638
56111
  // xlsx/edit/cell-shift.ts
55639
- function assertBandIntact(sheet, shift2, band) {
55640
- const zone = shift2.axis === "row" ? cellRange(shift2.at, band.lo, MAX_ROW, band.hi) : cellRange(band.lo, shift2.at, band.hi, MAX_COL);
55641
- const other = shift2.axis === "row" ? "col" : "row";
56112
+ function assertBandIntact(sheet, shift3, band) {
56113
+ const zone = shift3.axis === "row" ? cellRange(shift3.at, band.lo, MAX_ROW, band.hi) : cellRange(band.lo, shift3.at, band.hi, MAX_COL);
56114
+ const other = shift3.axis === "row" ? "col" : "row";
55642
56115
  const torn = (r) => rangesIntersect(r, zone) && (r.start[other] < band.lo || r.end[other] > band.hi);
55643
56116
  if (sheet.merges.some(torn))
55644
56117
  throw new Error("Cannot shift cells: a merged range would be split.");
@@ -55651,25 +56124,25 @@ function shiftBand(ctx, s, range, direction) {
55651
56124
  const vertical = direction === "down" || direction === "up";
55652
56125
  const insert2 = direction === "down" || direction === "right";
55653
56126
  const size = vertical ? r.end.row - r.start.row + 1 : r.end.col - r.start.col + 1;
55654
- const shift2 = {
56127
+ const shift3 = {
55655
56128
  axis: vertical ? "row" : "col",
55656
56129
  at: vertical ? r.start.row : r.start.col,
55657
56130
  count: insert2 ? size : -size
55658
56131
  };
55659
56132
  const band = vertical ? { lo: r.start.col, hi: r.end.col } : { lo: r.start.row, hi: r.end.row };
55660
- assertBandIntact(sheet, shift2, band);
55661
- assertInsertFits(sheet, shift2, band);
56133
+ assertBandIntact(sheet, shift3, band);
56134
+ assertInsertFits(sheet, shift3, band);
55662
56135
  ctx.run(
55663
56136
  `${insert2 ? "Insert" : "Delete"} cells`,
55664
56137
  "structure",
55665
- [{ kind: "shift", sheet: s, shift: shift2, band }],
56138
+ [{ kind: "shift", sheet: s, shift: shift3, band }],
55666
56139
  () => {
55667
- rebaseRulesForDeletion(sheet, shift2, band);
56140
+ rebaseRulesForDeletion(sheet, shift3, band);
55668
56141
  rewriteFormulas(
55669
56142
  ctx.workbook,
55670
- (formula2, formulaSheet) => shiftFormulaInBand(formula2, formulaSheet, sheet.name, shift2, band)
56143
+ (formula2, formulaSheet) => shiftFormulaInBand(formula2, formulaSheet, sheet.name, shift3, band)
55671
56144
  );
55672
- shiftSheetContent(sheet, shift2, band);
56145
+ shiftSheetContent(sheet, shift3, band);
55673
56146
  },
55674
56147
  { sheet: s, ranges: [r], structural: true }
55675
56148
  );
@@ -57222,14 +57695,14 @@ function restoreRefs(workbook, data) {
57222
57695
  }
57223
57696
  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;
57224
57697
  var sameEntry = (a2, b) => a2.formula === b.formula && sameRange3(a2.arrayRange, b.arrayRange);
57225
- function movePosition(spec2, shift2, s, row2, col) {
57226
- if (!spec2 || !shift2 || s !== spec2.sheet) return [row2, col];
57227
- const along = shift2.axis === "row" ? row2 : col;
57228
- const across = shift2.axis === "row" ? col : row2;
57698
+ function movePosition(spec2, shift3, s, row2, col) {
57699
+ if (!spec2 || !shift3 || s !== spec2.sheet) return [row2, col];
57700
+ const along = shift3.axis === "row" ? row2 : col;
57701
+ const across = shift3.axis === "row" ? col : row2;
57229
57702
  if (spec2.band && (across < spec2.band.lo || across > spec2.band.hi)) return [row2, col];
57230
- const moved = shiftIndex(along, shift2);
57703
+ const moved = shiftIndex(along, shift3);
57231
57704
  if (moved === void 0) return void 0;
57232
- return shift2.axis === "row" ? [moved, col] : [row2, moved];
57705
+ return shift3.axis === "row" ? [moved, col] : [row2, moved];
57233
57706
  }
57234
57707
  function diffRefs(workbook, before, spec2) {
57235
57708
  const keptBefore = [];
@@ -57250,37 +57723,37 @@ function diffRefs(workbook, before, spec2) {
57250
57723
  before.formulas = keptBefore;
57251
57724
  return keptAfter;
57252
57725
  }
57253
- function moveCellsRaw(sheet, shift2, band) {
57726
+ function moveCellsRaw(sheet, shift3, band) {
57254
57727
  const old = sheet.rows;
57255
57728
  sheet.rows = /* @__PURE__ */ new Map();
57256
- if (shift2.axis === "row" && !band) {
57729
+ if (shift3.axis === "row" && !band) {
57257
57730
  for (const [row2, cells] of old) {
57258
- const moved = shiftIndex(row2, shift2);
57731
+ const moved = shiftIndex(row2, shift3);
57259
57732
  if (moved !== void 0) sheet.rows.set(moved, cells);
57260
57733
  }
57261
57734
  return;
57262
57735
  }
57263
57736
  for (const [row2, cells] of old)
57264
57737
  for (const [col, cell] of cells) {
57265
- const along = shift2.axis === "row" ? row2 : col;
57266
- const across = shift2.axis === "row" ? col : row2;
57738
+ const along = shift3.axis === "row" ? row2 : col;
57739
+ const across = shift3.axis === "row" ? col : row2;
57267
57740
  const inBand = !band || across >= band.lo && across <= band.hi;
57268
- const moved = inBand ? shiftIndex(along, shift2) : along;
57741
+ const moved = inBand ? shiftIndex(along, shift3) : along;
57269
57742
  if (moved === void 0) continue;
57270
- if (shift2.axis === "row") putCell(sheet, moved, col, cell);
57743
+ if (shift3.axis === "row") putCell(sheet, moved, col, cell);
57271
57744
  else putCell(sheet, row2, moved, cell);
57272
57745
  }
57273
57746
  }
57274
57747
  function shiftEdgeCells(sheet, spec2, phase) {
57275
- const { shift: shift2, band } = spec2;
57748
+ const { shift: shift3, band } = spec2;
57276
57749
  const out = [];
57277
- if (phase === "after" && shift2.count < 0) return out;
57278
- const hit = (along) => phase === "before" ? shiftIndex(along, shift2) === void 0 : along >= shift2.at && along < shift2.at + shift2.count;
57750
+ if (phase === "after" && shift3.count < 0) return out;
57751
+ const hit = (along) => phase === "before" ? shiftIndex(along, shift3) === void 0 : along >= shift3.at && along < shift3.at + shift3.count;
57279
57752
  for (const [row2, cells] of sheet.rows) {
57280
- if (shift2.axis === "row" && !hit(row2)) continue;
57753
+ if (shift3.axis === "row" && !hit(row2)) continue;
57281
57754
  for (const [col, cell] of cells) {
57282
- const along = shift2.axis === "row" ? row2 : col;
57283
- const across = shift2.axis === "row" ? col : row2;
57755
+ const along = shift3.axis === "row" ? row2 : col;
57756
+ const across = shift3.axis === "row" ? col : row2;
57284
57757
  if (band && (across < band.lo || across > band.hi)) continue;
57285
57758
  if (hit(along)) out.push([row2, col, structuredClone(cell)]);
57286
57759
  }
@@ -57423,8 +57896,8 @@ function restoreShift(workbook, snapshot2) {
57423
57896
  const { spec: spec2 } = snapshot2;
57424
57897
  const sheet = workbook.sheets[spec2.sheet];
57425
57898
  if (!sheet) return;
57426
- const shift2 = snapshot2.phase === "before" ? { ...spec2.shift, count: -spec2.shift.count } : spec2.shift;
57427
- moveCellsRaw(sheet, shift2, spec2.band);
57899
+ const shift3 = snapshot2.phase === "before" ? { ...spec2.shift, count: -spec2.shift.count } : spec2.shift;
57900
+ moveCellsRaw(sheet, shift3, spec2.band);
57428
57901
  for (const [row2, col, cell] of snapshot2.cells) putCell(sheet, row2, col, cloneCell(cell));
57429
57902
  restoreRefs(workbook, snapshot2.data);
57430
57903
  workbook.activeSheet = snapshot2.activeSheet;
@@ -61984,8 +62457,8 @@ function scottBinCount(values2, min, max) {
61984
62457
  if (values2.length < 2 || max <= min) {
61985
62458
  return 1;
61986
62459
  }
61987
- const mean4 = values2.reduce((sum3, value2) => sum3 + value2, 0) / values2.length;
61988
- const variance3 = values2.reduce((sum3, value2) => sum3 + (value2 - mean4) ** 2, 0) / (values2.length - 1);
62460
+ const mean9 = values2.reduce((sum3, value2) => sum3 + value2, 0) / values2.length;
62461
+ const variance3 = values2.reduce((sum3, value2) => sum3 + (value2 - mean9) ** 2, 0) / (values2.length - 1);
61989
62462
  const sd = Math.sqrt(variance3);
61990
62463
  if (!(sd > 0)) {
61991
62464
  return 1;
@@ -62237,8 +62710,8 @@ function fitChartTrendline(options2, xVals, yVals) {
62237
62710
  function chartSampleVariance(values2) {
62238
62711
  const count2 = values2.length;
62239
62712
  if (count2 === 0) return 0;
62240
- const mean4 = values2.reduce((sum3, value2) => sum3 + value2, 0) / count2;
62241
- return values2.reduce((sum3, value2) => sum3 + (value2 - mean4) ** 2, 0) / Math.max(count2 - 1, 1);
62713
+ const mean9 = values2.reduce((sum3, value2) => sum3 + value2, 0) / count2;
62714
+ return values2.reduce((sum3, value2) => sum3 + (value2 - mean9) ** 2, 0) / Math.max(count2 - 1, 1);
62242
62715
  }
62243
62716
  function chartErrorBarAmount(options2, values2, displayIndex, sourceIndex, side) {
62244
62717
  switch (options2.valueType) {
@@ -63160,7 +63633,7 @@ function boxWhiskerSvg(model2, frame2, out) {
63160
63633
  trim2
63161
63634
  );
63162
63635
  if (!distribution) return;
63163
- const { stats, whiskerMin, whiskerMax, mean: mean4 } = distribution;
63636
+ const { stats, whiskerMin, whiskerMax, mean: mean9 } = distribution;
63164
63637
  const x = frame2.band(ci) - frame2.bandSize / 2 + si * slot2 + (slot2 - width) / 2;
63165
63638
  const mid = x + width / 2;
63166
63639
  const y = frame2.value;
@@ -63185,10 +63658,10 @@ function boxWhiskerSvg(model2, frame2, out) {
63185
63658
  )
63186
63659
  );
63187
63660
  out.push(line3(x, y(stats.median), x + width, y(stats.median), "#1e293b", 2));
63188
- if (visibility?.meanLine) out.push(line3(x, y(mean4), x + width, y(mean4), "#0f766e", 1.5));
63661
+ if (visibility?.meanLine) out.push(line3(x, y(mean9), x + width, y(mean9), "#0f766e", 1.5));
63189
63662
  if (visibility?.meanMarker !== false)
63190
63663
  out.push(
63191
- `<path d="${boxMeanMarkerPath(mid, y(mean4))}" fill="none" stroke="#0f766e" stroke-width="1.5" data-chart-part="mean"/>`
63664
+ `<path d="${boxMeanMarkerPath(mid, y(mean9))}" fill="none" stroke="#0f766e" stroke-width="1.5" data-chart-part="mean"/>`
63192
63665
  );
63193
63666
  observations.forEach((point2, index3) => {
63194
63667
  const outlier = point2.value < whiskerMin || point2.value > whiskerMax;
@@ -63434,10 +63907,10 @@ function categoryAnalysis(model2, frame2, out) {
63434
63907
  const layout2 = barred ? barLayout(model2, frame2) : void 0;
63435
63908
  model2.series.forEach((series, si) => {
63436
63909
  if (!series.trendlines && !series.errorBars) return;
63437
- const shift2 = layout2 ? layout2.offset(si) + layout2.barSize / 2 : 0;
63910
+ const shift3 = layout2 ? layout2.offset(si) + layout2.barSize / 2 : 0;
63438
63911
  const barPlane = (x, y) => {
63439
63912
  const [px, py] = plane(x, y);
63440
- return model2.horizontal ? [px, py + shift2] : [px + shift2, py];
63913
+ return model2.horizontal ? [px, py + shift3] : [px + shift3, py];
63441
63914
  };
63442
63915
  seriesAnalysis(series, si, (i2) => i2 + 1, plane, barPlane, true, out);
63443
63916
  });
@@ -66351,11 +66824,11 @@ var byId = (sheet, id) => {
66351
66824
  return table3;
66352
66825
  };
66353
66826
  function insertBandRow(workbook, sheet, table3, row2) {
66354
- const shift2 = { axis: "row", at: row2, count: 1 };
66827
+ const shift3 = { axis: "row", at: row2, count: 1 };
66355
66828
  const band = { lo: table3.range.start.col, hi: table3.range.end.col };
66356
- assertInsertFits(sheet, shift2, band);
66357
- rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift2, band));
66358
- shiftSheetContent(sheet, shift2, band);
66829
+ assertInsertFits(sheet, shift3, band);
66830
+ rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift3, band));
66831
+ shiftSheetContent(sheet, shift3, band);
66359
66832
  }
66360
66833
  function setHeaderRow(workbook, sheet, id, on) {
66361
66834
  let table3 = byId(sheet, id);
@@ -69430,10 +69903,10 @@ function createTable(ctx, s, range, hasHeader, styleName = "TableStyleMedium2")
69430
69903
  [hasHeader ? { kind: "sheet", sheet: s } : { kind: "workbook" }],
69431
69904
  () => {
69432
69905
  if (!hasHeader) {
69433
- const shift2 = { axis: "row", at: r.start.row, count: 1 };
69906
+ const shift3 = { axis: "row", at: r.start.row, count: 1 };
69434
69907
  const band = { lo: r.start.col, hi: r.end.col };
69435
- rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift2, band));
69436
- shiftSheetContent(sheet, shift2, band);
69908
+ rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift3, band));
69909
+ shiftSheetContent(sheet, shift3, band);
69437
69910
  r = { start: r.start, end: { row: r.end.row + 1, col: r.end.col } };
69438
69911
  }
69439
69912
  const width = r.end.col - r.start.col + 1;
@@ -71647,7 +72120,7 @@ function shapeStroke(node2, scale2, theme2) {
71647
72120
  }
71648
72121
 
71649
72122
  // xlsx/layout/shape-view.ts
71650
- var escapeXml = (text3) => text3.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
72123
+ var escapeXml = (text3) => text3.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
71651
72124
  var round4 = (value2) => Math.round(value2 * 100) / 100;
71652
72125
  var POINT_PX = 96 / 72;
71653
72126
  var DEFAULT_FONT_PT = 11;
@@ -71707,16 +72180,16 @@ function textSvg(node2, rect3, ctx) {
71707
72180
  const anchorAttr = line4.align === "ctr" ? "middle" : line4.align === "r" ? "end" : "start";
71708
72181
  const baseline = y + (heights[index3] ?? 0) * 0.8;
71709
72182
  y += heights[index3] ?? 0;
71710
- return `<text x="${round4(x)}" y="${round4(baseline)}" font-family="Calibri,Arial,sans-serif" font-size="${round4(line4.fontPx)}" fill="${line4.color}" text-anchor="${anchorAttr}"${line4.bold ? ' font-weight="bold"' : ""}${line4.italic ? ' font-style="italic"' : ""}>${escapeXml(line4.text)}</text>`;
72183
+ return `<text x="${round4(x)}" y="${round4(baseline)}" font-family="Calibri,Arial,sans-serif" font-size="${round4(line4.fontPx)}" fill="${escapeXml(line4.color)}" text-anchor="${anchorAttr}"${line4.bold ? ' font-weight="bold"' : ""}${line4.italic ? ' font-style="italic"' : ""}>${escapeXml(line4.text)}</text>`;
71711
72184
  });
71712
- return `<g clip-path="url(#${clip})">${spans3.join("")}</g>`;
72185
+ return `<g clip-path="url(#${escapeXml(clip)})">${spans3.join("")}</g>`;
71713
72186
  }
71714
72187
  function markerDef(ctx, end, color3) {
71715
72188
  if (!end?.type || end.type === "none") return void 0;
71716
72189
  const id = `${ctx.prefix}m${ctx.counter.n++}`;
71717
72190
  const shape2 = end.type === "oval" ? '<circle cx="5" cy="5" r="4"/>' : end.type === "diamond" ? '<path d="M1 5 L5 1 L9 5 L5 9 Z"/>' : end.type === "arrow" ? '<path d="M1 1 L9 5 L1 9" fill="none" stroke-width="1.5"/>' : '<path d="M1 1 L9 5 L1 9 Z"/>';
71718
72191
  ctx.defs.push(
71719
- `<marker id="${id}" viewBox="0 0 10 10" refX="5" refY="5" markerWidth="4" markerHeight="4" orient="auto-start-reverse" fill="${color3}" stroke="${color3}">${shape2}</marker>`
72192
+ `<marker id="${escapeXml(id)}" viewBox="0 0 10 10" refX="5" refY="5" markerWidth="4" markerHeight="4" orient="auto-start-reverse" fill="${escapeXml(color3)}" stroke="${escapeXml(color3)}">${shape2}</marker>`
71720
72193
  );
71721
72194
  return id;
71722
72195
  }
@@ -71772,7 +72245,7 @@ function drawNode(node2, box2, ctx) {
71772
72245
  const body = paths.map((path3) => {
71773
72246
  const fill2 = fillNone || path3.fill === "none" || node2.kind === "connector" ? "none" : paint2.fill;
71774
72247
  const line4 = path3.stroke === false ? "none" : stroke.stroke;
71775
- return `<path d="${escapeXml(path3.d)}" transform="translate(${round4(box2.x)} ${round4(box2.y)})" fill="${fill2}" stroke="${line4}" stroke-width="${round4(stroke.width)}" stroke-linejoin="miter"${stroke.dash ? ` stroke-dasharray="${stroke.dash}"` : ""}${head ? ` marker-start="url(#${head})"` : ""}${tail ? ` marker-end="url(#${tail})"` : ""}/>`;
72248
+ return `<path d="${escapeXml(path3.d)}" transform="translate(${round4(box2.x)} ${round4(box2.y)})" fill="${escapeXml(fill2)}" stroke="${escapeXml(line4)}" stroke-width="${round4(stroke.width)}" stroke-linejoin="miter"${stroke.dash ? ` stroke-dasharray="${escapeXml(stroke.dash)}"` : ""}${head ? ` marker-start="url(#${escapeXml(head)})"` : ""}${tail ? ` marker-end="url(#${escapeXml(tail)})"` : ""}/>`;
71776
72249
  }).join("");
71777
72250
  const rect3 = textRect ? {
71778
72251
  x: box2.x + textRect.l,
@@ -71803,7 +72276,7 @@ var EDGE = "#adadad";
71803
72276
  var TEXT = "#000000";
71804
72277
  var FONT = 'font-family="Segoe UI,Arial,sans-serif"';
71805
72278
  var round5 = (value2) => Math.round(value2 * 100) / 100;
71806
- var escapeXml2 = (text3) => text3.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
72279
+ var escapeXml2 = (text3) => text3.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
71807
72280
  function caption(text3, x, h2, size) {
71808
72281
  if (!text3) return "";
71809
72282
  return `<text x="${round5(x)}" y="${round5(h2 / 2)}" ${FONT} font-size="${round5(size)}" fill="${TEXT}" dominant-baseline="central">${escapeXml2(text3)}</text>`;
@@ -71826,8 +72299,8 @@ function arrow(cx, cy, up, size = 3) {
71826
72299
  function dropdown(c2, s, items, w, h2, size) {
71827
72300
  const button2 = Math.min(16, w / 2);
71828
72301
  const text3 = s.selected >= 1 ? items[s.selected - 1] ?? "" : "";
71829
- const clip = `<clipPath id="fc-drop-${c2.shapeId}"><rect x="2" y="1" width="${round5(Math.max(0, w - button2 - 4))}" height="${round5(h2 - 2)}"/></clipPath>`;
71830
- return `<defs>${clip}</defs><rect x="0.5" y="0.5" width="${round5(w - 1)}" height="${round5(h2 - 1)}" fill="#fff" stroke="#7a7a7a"/><g clip-path="url(#fc-drop-${c2.shapeId})">${caption(text3, 4, h2, size)}</g><rect data-control-part="drop" x="${round5(w - button2 - 0.5)}" y="1.5" width="${round5(button2 - 1)}" height="${round5(h2 - 3)}" fill="${FACE}" stroke="${EDGE}"/>${arrow(w - button2 / 2, h2 / 2, false)}`;
72302
+ const clip = `<clipPath id="fc-drop-${escapeXml2(String(c2.shapeId))}"><rect x="2" y="1" width="${round5(Math.max(0, w - button2 - 4))}" height="${round5(h2 - 2)}"/></clipPath>`;
72303
+ return `<defs>${clip}</defs><rect x="0.5" y="0.5" width="${round5(w - 1)}" height="${round5(h2 - 1)}" fill="#fff" stroke="#7a7a7a"/><g clip-path="url(#fc-drop-${escapeXml2(String(c2.shapeId))})">${caption(text3, 4, h2, size)}</g><rect data-control-part="drop" x="${round5(w - button2 - 0.5)}" y="1.5" width="${round5(button2 - 1)}" height="${round5(h2 - 3)}" fill="${FACE}" stroke="${EDGE}"/>${arrow(w - button2 / 2, h2 / 2, false)}`;
71831
72304
  }
71832
72305
  function list2(s, items, w, h2, size) {
71833
72306
  const row2 = size * 1.4;
@@ -71855,7 +72328,7 @@ function scroll(c2, s, w, h2) {
71855
72328
  const thumbLength = Math.max(8, Math.min(length, end));
71856
72329
  const offset2 = end + ratio * Math.max(0, length - thumbLength);
71857
72330
  const track = "#f0f0f0";
71858
- const rect3 = (part, x, y, rw, rh, fill2) => `<rect data-control-part="${part}" x="${round5(x)}" y="${round5(y)}" width="${round5(rw)}" height="${round5(rh)}" fill="${fill2}" stroke="${EDGE}"/>`;
72331
+ const rect3 = (part, x, y, rw, rh, fill2) => `<rect data-control-part="${escapeXml2(part)}" x="${round5(x)}" y="${round5(y)}" width="${round5(rw)}" height="${round5(rh)}" fill="${escapeXml2(fill2)}" stroke="${EDGE}"/>`;
71859
72332
  if (horizontal)
71860
72333
  return `${rect3("track", end, 0.5, length, h2 - 1, track)}${rect3("step-down", 0.5, 0.5, end, h2 - 1, FACE)}${rect3("step-up", w - end - 0.5, 0.5, end, h2 - 1, FACE)}${rect3("thumb", offset2, 0.5, thumbLength, h2 - 1, FACE)}<path d="M${round5(end * 0.6)} ${round5(h2 / 2 - 3)} l-3 3 l3 3 Z M${round5(w - end * 0.6)} ${round5(h2 / 2 - 3)} l3 3 l-3 3 Z" fill="#606060"/>`;
71861
72334
  return `${rect3("track", 0.5, end, w - 1, length, track)}${rect3("step-down", 0.5, 0.5, w - 1, end, FACE)}${rect3("step-up", 0.5, h2 - end - 0.5, w - 1, end, FACE)}${rect3("thumb", 0.5, offset2, w - 1, thumbLength, FACE)}${arrow(w / 2, end / 2, true)}${arrow(w / 2, h2 - end / 2, false)}`;